Example #1
0
json_t *lwqq__parse_retcode_result(json_t *json,int* retcode)
{
	//{"retcode":0,"result":......}

	/**
	 * Frist, we parse retcode that indicate whether we get
	 * correct response from server
	 */
	char* value = json_parse_simple_value(json, "retcode");
	if(!value){
		*retcode = LWQQ_EC_ERROR;
		return NULL;
	}

	*retcode = s_atoi(value,LWQQ_EC_ERROR);

	/**
	 * Second, Check whether there is a "result" key in json object
	 * if success it would return result;
	 * if failed it would return NULL;
	 */
	json_t* result = json_find_first_label_all(json, "result");
	if(result == NULL) return NULL;
	return result->child;
}
Example #2
0
File: params.c Project: cmouse/hbs
void misc_command_params (NICK * nick, CHANNEL * channel, const char *cmd,
                          const char **args, int argc)
{
    SERVER *server;
    if (argc < 2)
    {
        puttext ("NOTICE %s :Usage %s param value\r\n", nick->nick, cmd);
        return;
    }
    server = server_get_current ();
    if (!strcasecmp (args[0], "oblines"))
    {
        int nlines;
        nlines = s_atoi (args[1]);
        if (nlines > 0)
        {
            server->ob.mlines = nlines;
            puttext ("NOTICE %s :Max lines now %d\r\n", nick->nick, nlines);
        }
        else
        {
            puttext ("NOTICE %s :Need positive number\r\n", nick->nick);
        }
    }
    else if (!strcasecmp (args[0], "obmsec"))
    {
        int nmsec;
        nmsec = s_atoi (args[1]);
        if (nmsec > 0)
        {
            server->ob.msec = nmsec;
            puttext ("NOTICE %s :Max msecs now %d\r\n", nick->nick, nmsec);
        }
        else
        {
            puttext ("NOTICE %s :Need positive number\r\n", nick->nick);
        }
    }
}
Example #3
0
/**
 * this process simple result;
 */
int lwqq__process_simple_response(LwqqHttpRequest* req)
{
	//{"retcode":0,"result":{"ret":0}}
	int err = 0;
	json_t *root = NULL;
	lwqq__jump_if_http_fail(req,err);
	lwqq__jump_if_json_fail(root,req->response,err);
	int retcode = s_atoi(json_parse_simple_value(root, "retcode"),LWQQ_EC_ERROR);
	if(retcode != LWQQ_EC_OK){
		err = retcode;
	}
done:
	lwqq__log_if_error(err, req);
	lwqq__clean_json_and_req(root,req);
	return err;
}