#module \
User

#define CREATE_URL	(CONFIG_SERVER_URL + "/create_user.php")
#define FETCH_URL	(CONFIG_SERVER_URL + "/fetch_user.php")

#deffunc local \
Create \
		str	p_name,\
		local	l_res,\
		local	l_size,\
		local	l_data
	HTTPLoad CREATE_URL + "?name=" + p_name

	If stat = 0 {
		Repeat
			HTTPInfo l_res, HTTPINFO_MODE

			Switch l_res
				Case HTTPMODE_READY
				Case HTTPMODE_NONE
				Case HTTPMODE_ERROR
					Break
			SwEnd

			Wait 5
		Loop

		If l_res = HTTPMODE_READY {
			HTTPInfo l_size, HTTPINFO_SIZE

			SDim l_data, l_size

			HTTPInfo l_data, HTTPINFO_DATA
			Split l_data, ",", l_data

			id = l_data.0
			pass = l_data.1
			inheritanceCode = l_data.2

			Return
		}
	}

	id = 0
	pass = ""
	inheritanceCode = ""

	Return -1

#deffunc local \
Fetch \
		int	p_id,\
		local	l_data
	id = userId@Setting
	pass = userPasscode@Setting

	HTTPLoad StrF ("%s?id=%d&pass=%s", CREATE_URL, id, pass)
	HTTPInfo l_data

	Return

#global

