[Refdb-cvs] CVS: refdb/src refdbdref.c,1.65.2.8,1.65.2.9
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2005-05-05 17:28:57
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21416 Modified Files: Tag: Release_0_9_5_stable refdbdref.c Log Message: fixed getref() return codes;added sqlite3 support Index: refdbdref.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdref.c,v retrieving revision 1.65.2.8 retrieving revision 1.65.2.9 diff -u -U2 -r1.65.2.8 -r1.65.2.9 --- refdbdref.c 3 May 2005 20:30:08 -0000 1.65.2.8 +++ refdbdref.c 5 May 2005 17:28:37 -0000 1.65.2.9 @@ -367,5 +367,5 @@ if (!strcmp(my_dbi_conn_get_cap(conn, "multiple_db"), "f")) { - /* pgsql, sqlite need another connection to retrieve values from + /* pgsql, sqlite, sqlite3 need another connection to retrieve values from the refdb database */ @@ -1749,8 +1749,8 @@ drivername = dbi_driver_get_name(dbi_conn_get_driver(conn)); - if (!strcmp(drivername, "mysql") || !strcmp(drivername, "sqlite")) { + if (!strcmp(my_dbi_conn_get_cap(conn, "named_seq"), "f")) { n_user_id = dbi_conn_sequence_last(conn, NULL); } - else if (!strcmp(drivername, "pgsql")) { + else { n_user_id = dbi_conn_sequence_last(conn, "t_user_user_id_seq"); } @@ -1994,5 +1994,5 @@ getref(): implements the client command getref - int getref returns 0 = no error, 1 = out of memory, 2 = subselect failed + int getref returns 0 = no error, 1 = out of memory or db open error, 2 = subselect failed struct CLIENT_REQUEST* ptr_clrequest ptr to structure with client info @@ -2077,10 +2077,7 @@ inargv = (char**)malloc((size_t)inargcmax*sizeof(char*)); if (inargv == NULL || insert_lilimem(&sentinel, (void**)&inargv, NULL)) { - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); - return 0; + return 1; } @@ -2091,10 +2088,7 @@ if (sql_command == NULL || insert_lilimem(&sentinel, (void**)&sql_command, NULL)) { delete_all_lilimem(&sentinel); - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); - return 0; + return 1; } sql_command[0] = '\0'; /* start with an empty string */ @@ -2106,10 +2100,7 @@ if (sql_command1 == NULL || insert_lilimem(&sentinel, (void**)&sql_command1, NULL)) { delete_all_lilimem(&sentinel); - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); - return 0; + return 1; } sql_command1[0] = '\0'; /* start with an empty string */ @@ -2121,10 +2112,7 @@ if (buffer == NULL || insert_lilimem(&sentinel, (void**)&buffer, NULL)) { delete_all_lilimem(&sentinel); - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); - return 0; + return 1; } buffer[0] = '\0'; /* start with an empty string */ @@ -2136,10 +2124,7 @@ if (stringbuf == NULL || insert_lilimem(&sentinel, (void**)&stringbuf, NULL)) { delete_all_lilimem(&sentinel); - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); - return 0; + return 1; } buffer[0] = '\0'; /* start with an empty string */ @@ -2149,11 +2134,8 @@ /* connect to the database */ if ((conn = connect_to_db(ptr_clrequest, NULL, 0)) == NULL) { - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 204, TERM_NO); LOG_PRINT(LOG_WARNING, get_status_msg(204)); delete_all_lilimem(&sentinel); - return 0; + return 1; } @@ -2170,11 +2152,8 @@ LOG_PRINT(LOG_DEBUG, db_encoding); LOG_PRINT(LOG_DEBUG, ptr_biblio_info->encoding); - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 701, TERM_NO); LOG_PRINT(LOG_WARNING, get_status_msg(701)); delete_all_lilimem(&sentinel); - return 0; + return 1; } else { @@ -3825,7 +3804,4 @@ } else if (retval == 2) { - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 234, TERM_NO); LOG_PRINT(LOG_WARNING, get_status_msg(234)); @@ -3837,5 +3813,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } @@ -3891,5 +3867,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } else { @@ -3909,5 +3885,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } else { @@ -3928,5 +3904,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } if (dbi_driver_quote_string(driver, "ed_token) == -1) { @@ -3941,7 +3917,4 @@ dbires = dbi_conn_query(conn, sql_command1); if (!dbires) { - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 234, TERM_NO); LOG_PRINT(LOG_WARNING, get_status_msg(234)); @@ -3951,11 +3924,8 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } if ((new_sql_command = mstrcat(sql_command, " AND t_refdb.refdb_id IN (", &sql_command_len, 0)) == NULL) { - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); @@ -3966,5 +3936,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } else { @@ -3978,7 +3948,4 @@ if ((new_sql_command = mstrcat(sql_command, the_id, &sql_command_len, 0)) == NULL) { retval = 1; - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); @@ -3989,5 +3956,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } else { @@ -3996,7 +3963,4 @@ if ((new_sql_command = mstrcat(sql_command, ",", &sql_command_len, 0)) == NULL) { retval = 1; - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); @@ -4007,5 +3971,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } else { @@ -4014,10 +3978,7 @@ } /* end while */ } - else { /* if now rows are available */ + else { /* if no rows are available */ if ((new_sql_command = mstrcat(sql_command, "0,", &sql_command_len, 0)) == NULL) { retval = 1; - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); @@ -4028,5 +3989,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } else { @@ -4039,7 +4000,4 @@ /* overwrite the trailing comma */ if (retval || ((new_sql_command = mstrcat(sql_command, ")", &sql_command_len, 1)) == NULL)) { - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); @@ -4049,5 +4007,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } else { @@ -4059,7 +4017,4 @@ if (strncmp(ptr_biblio_info->sort_string, "PY", 2) == 0) { if (retval || ((new_sql_command = mstrcat(sql_command, " ORDER BY t_refdb.refdb_pubyear", &sql_command_len, 0)) == NULL)) { - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); @@ -4069,5 +4024,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } else { @@ -4077,7 +4032,4 @@ else { if (retval || ((new_sql_command = mstrcat(sql_command, " ORDER BY t_refdb.refdb_id", &sql_command_len, 0)) == NULL)) { - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 801, TERM_NO); LOG_PRINT(LOG_CRIT, get_status_msg(801)); @@ -4087,5 +4039,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } else { @@ -4098,7 +4050,4 @@ rendinfo.dbires = dbi_conn_query(conn, sql_command); if (!rendinfo.dbires) { - if (ptr_clrequest->n_cgi) { /* cgi output */ - iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); - } send_status(ptr_clrequest->fd, 234, TERM_NO); LOG_PRINT(LOG_WARNING, get_status_msg(234)); @@ -4108,5 +4057,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } @@ -4131,5 +4080,5 @@ iconv_close(conv_descriptor); } - return 0; + return 1; } |