Jump to content

jordanwb

Members
  • Posts

    560
  • Joined

  • Last visited

Everything posted by jordanwb

  1. TBH I have no idea which subforum this should go under so I'm putting it here. I'm working on a cross platform C application that uses among other things the MySQL C connector. MySQL doesn't give an installer that I can use with mingw so I have to compile it myself which isn't a problem. However I can't get cmake to configure it since every test fails. This is my configure log: http://pastebin.com/uAz4PbXv I don't know what kind of info is needed to help solve the issue so let me know. Thanks in advance
  2. Vuze? I think that's the name of it
  3. I'm going to cut straight to the chase, this is my function: void client_job_results (client *c, json_object *obj) { char *tripcode_insert_query = "INSERT INTO tah_tripcodes VALUES ('', ?, ?, ?, ?)"; int job_id, results_count; unsigned long tripcode_len = 10; MYSQL_STMT *tripcode_stmt = mysql_stmt_init(conn); MYSQL_BIND tripcode_params[4]; mysql_stmt_prepare(tripcode_stmt, tripcode_insert_query, strlen(tripcode_insert_query)); memset (tripcode_params, 0, sizeof (tripcode_params)); json_object *jobs_array = json_object_object_get (obj, "jobs"), *job, *results_array, *result_pair; char *password, *tripcode, *utf8_password_orig, *salt = alloca(3), *c_password = alloca (9), *des_result = alloca (14), *utf8_password = alloca (20); // is 20 enough? memset (utf8_password, 0, 20); size_t sjis_pass_len; size_t utf8_pass_len; if (jobs_array == NULL) return; iconv_t cd = iconv_open ("UTF8", "SHIFT_JIS"); for (int i = 0; i < json_object_array_length (jobs_array); i++) { job = json_object_array_get_idx (jobs_array, i); if (job == NULL) { continue; } results_array = json_object_object_get (job, "results"); results_count = json_object_array_length (results_array); if (results_count == 0) continue; job_id = json_object_get_int (json_object_object_get (job, "job-id")); if (job_id == 0) { continue; } for (int j = 0; j < results_count; j++) { result_pair = json_object_array_get_idx (results_array, j); password = json_object_get_string (json_object_object_get (result_pair, "password")); tripcode = json_object_get_string (json_object_object_get (result_pair, "tripcode")); // check to make sure password is correct make_correct_password (password, c_password); make_salt (c_password, salt); DES_fcrypt (c_password, salt, des_result); if (strcmp (des_result + 3, tripcode) != 0) { printf ("Client gave invalid password/tripcode pair; claimed \"%s\" gave \"%s\", but got \"%s\" as a result.\n", password, tripcode, des_result + 3); continue; } // // convert to unicode sjis_pass_len = strlen (password); utf8_pass_len = sjis_pass_len * 2; utf8_password_orig = utf8_password; if (iconv (cd, &password, &sjis_pass_len, &utf8_password, &utf8_pass_len) == -1) { printf ("iconv could not convert password. Error is: %s\n", strerror(errno)); continue; } utf8_pass_len = strlen(utf8_password_orig); // tripcode_params[0].buffer_type = MYSQL_TYPE_LONG; tripcode_params[0].buffer = (void*)&job_id; tripcode_params[1].buffer_type = MYSQL_TYPE_STRING; tripcode_params[1].buffer = (void*)utf8_password_orig; tripcode_params[1].length = &utf8_pass_len; // this param is the number of bytes used in the buffer (# of single byte chars) tripcode_params[2].buffer_type = MYSQL_TYPE_STRING; tripcode_params[2].buffer = (void*)tripcode; tripcode_params[2].length = &tripcode_len; tripcode_params[3].buffer_type = MYSQL_TYPE_LONG; tripcode_params[3].buffer = (void*)&(c->user_id); mysql_stmt_bind_param(tripcode_stmt, (MYSQL_BIND *)&tripcode_params); mysql_stmt_execute (tripcode_stmt); } } iconv_close (cd); mysql_stmt_free_result (tripcode_stmt); } When the program reaches mysql_stmt_bind_param the program crashes and I don't know why. iconv does properly convert the shift_jis strings to UTF8 and the program crashes only when I try to insert unicode characters into the table.
  4. I'm writing a program in C which requires MySQL. I wrote a little test program to make sure I know how to use the API. The problem is a keep getting a segmentation fault when I call mysql_num_fields on line 23: #include <stdio.h> #include <mysql/mysql.h> int main (int argc, char **argv) { mysql_library_init(0, NULL, NULL); MYSQL *database = mysql_init (NULL); if (mysql_real_connect (database, "127.0.0.1", "root", "", "my_database", 0, NULL, 0) == NULL) { return 1; } char *query = "SELECT * FROM my_table"; int result = mysql_query (database, query); MYSQL_RES *res = mysql_store_result (database); // do stuff with result unsigned int num_fields = mysql_num_fields(res); MYSQL_ROW row; while (row = mysql_fetch_row(res)) { unsigned long *lengths; lengths = mysql_fetch_lengths(res); for(int i = 0; i < num_fields; i++) { printf("[%.*s] ", (int) lengths[i], row[i] ? row[i] : "NULL"); } printf("\n"); } mysql_free_result(res); mysql_close (database); mysql_library_end(); return 0; }
  5. I'd like to add that I've being charged for a site that I canceled over a year ago.
  6. I've sent ober an pm to remove EMaxHosting, here's why: apache version emax uses: 1.3.39 Latest version (for gentoo): 2.2.9-r1 MySQL version emax uses: 4.1.22 Latest version (for gentoo): mysql-5.0.60-r1 Kernel version emax uses: 2.6.9 Latest version: 2.6.26.5 Also their home pages sucks and their Customer Management Interface is horrible
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.