Exemplo n.º 1
0
static void travel_command_list(eng_ctx_t* eng_ctx) {
    cmd_list_t* cmd_list = eng_ctx->cmd_list;
    cmd_t* cmd = get_first_cmd(cmd_list);
    
    set_seed(eng_ctx);

    while (cmd != cmd_list->tail) {
        switch (cmd->type) {
        case INSERT:
            mysql_insert(eng_ctx);
            break;
        case DELETE:
            mysql_delete(eng_ctx);
            break;
        case UPDATE:
            mysql_update(eng_ctx);
            break;
        case SELECT:
            mysql_select(eng_ctx);
            break;
        default: break;
        }
        cmd = cmd->next;
    }

    return;
}
Exemplo n.º 2
0
int readQueueMessages() {

	int ret;
	MYSQL_RES *result = NULL;
	MYSQL_ROW row = NULL;
	int send;
	result = mysql_select(octstr_format(SQL_SELECT_MO, octstr_get_cstr(integratorQueueId)));
	int num_rows = mysql_num_rows(result);
	debug("httpClient", 0, "%i messages in the queue", num_rows);
	if (num_rows == 0) {
		mysql_free_result(result);
		return 0;
	}

	while ((row = mysql_fetch_row(result))) {
		SMSmsg msg;
		//initRowMO(msg);
		int ret;
		strcpy(msg.id, row[0]);
		strcpy(msg.phone, row[1]);
		strcpy(msg.shortNumber, row[2]);
		strcpy(msg.text, row[7]);
		strcpy(msg.carrier, row[17]);
		debug("httpClient", 0, "processing MT msg id %s phone=%s text=%s", msg.id, msg.phone, msg.text);
		ret = sendMT(&msg, row[16]);
		debug("httpClient", 0, "Return Processing code = %d - %d - %s", ret, msg.errCode, msg.errText);

		if(ret==0)
		{
			mysql_update(octstr_format(SQL_UPDATE_MO_STATUS, "DISPATCHED", row[0]));
		}else{
			mysql_update(octstr_format(SQL_UPDATE_MO_STATUS_ERROR, "NOTDISPATCHED",msg.errCode,msg.errText,row[0]));
		}

	}
	mysql_free_result(result);
	return 0;

}
Exemplo n.º 3
0
Msg *mysql_fetch_msg()
{
    Msg *msg = NULL;
    Octstr *sql, *delet, *id;
    MYSQL_RES *res;
    MYSQL_ROW row;

    sql = octstr_format(SQLBOX_MYSQL_SELECT_QUERY, sqlbox_insert_table);
#if defined(SQLBOX_TRACE)
     debug("SQLBOX", 0, "sql: %s", octstr_get_cstr(sql));
#endif
    res = mysql_select(sql);
    if (res == NULL) {
        debug("sqlbox", 0, "SQL statement failed: %s", octstr_get_cstr(sql));
    }
    else {
        if (mysql_num_rows(res) >= 1) {
            row = mysql_fetch_row(res);
            id = octstr_null_create(row[0]);
            /* save fields in this row as msg struct */
            msg = msg_create(sms);
            msg->sms.sender     = octstr_null_create(row[2]);
            msg->sms.receiver   = octstr_null_create(row[3]);
            msg->sms.udhdata    = octstr_null_create(row[4]);
            msg->sms.msgdata    = octstr_null_create(row[5]);
            msg->sms.time       = atol_null(row[6]);
            msg->sms.smsc_id    = octstr_null_create(row[7]);
            msg->sms.service    = octstr_null_create(row[8]);
            msg->sms.account    = octstr_null_create(row[9]);
            /* msg->sms.id      = atol_null(row[10]); */
            msg->sms.sms_type   = atol_null(row[11]);
            msg->sms.mclass     = atol_null(row[12]);
            msg->sms.mwi        = atol_null(row[13]);
            msg->sms.coding     = atol_null(row[14]);
            msg->sms.compress   = atol_null(row[15]);
            msg->sms.validity   = atol_null(row[16]);
            msg->sms.deferred   = atol_null(row[17]);
            msg->sms.dlr_mask   = atol_null(row[18]);
            msg->sms.dlr_url    = octstr_null_create(row[19]);
            msg->sms.pid        = atol_null(row[20]);
            msg->sms.alt_dcs    = atol_null(row[21]);
            msg->sms.rpi        = atol_null(row[22]);
            msg->sms.charset    = octstr_null_create(row[23]);
            msg->sms.binfo      = octstr_null_create(row[25]);
            msg->sms.meta_data  = octstr_null_create(row[26]);
            if (row[24] == NULL) {
                msg->sms.boxc_id= octstr_duplicate(sqlbox_id);
            }
            else {
                msg->sms.boxc_id= octstr_null_create(row[24]);
            }
            /* delete current row */
            delet = octstr_format(SQLBOX_MYSQL_DELETE_QUERY, sqlbox_insert_table, id);
#if defined(SQLBOX_TRACE)
            debug("SQLBOX", 0, "sql: %s", octstr_get_cstr(delet));
#endif
            mysql_update(delet);
            octstr_destroy(id);
            octstr_destroy(delet);
        }
        mysql_free_result(res);
    }
    octstr_destroy(sql);
    return msg;
}