Thread: [Refdb-cvs] CVS: refdb/src backend-bibtex.c,1.16,1.16.2.1 backend-bibtex.h,1.6,1.6.2.1 backend-db31.
Status: Beta
Brought to you by:
mhoenicka
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31575 Modified Files: Tag: Release_0_9_5_stable backend-bibtex.c backend-bibtex.h backend-db31.c backend-db31.h backend-dbib.c backend-dbib.h backend-dbiba.c backend-html.c backend-html.h backend-ris.c backend-ris.h backend-risx.c backend-risx.h backend-scrn.c backend-scrn.h backend-teix.c backend-teix.h backend.h backendn-html.c backendn-html.h backendn-notex.c backendn-notex.h backendn-scrn.c backendn-scrn.h client-commands.c connect.c connect.h dbfncs.c nmed2ris.c noteshandler.c readris.c refdb-client.c refdb-client.h refdb.h refdba.c refdba.h refdbc.c refdbc.h refdbd.c refdbd.h.in refdbda.c refdbdbib.c refdbdnote.c refdbdref.c refdbib.c refdbib.h risdb.c risdb.h risxhandler.c writenote.c writenote.h writeris.c writeris.h xmlhandler.c xmlhandler.h xmlout.c Log Message: refactored client-server protocol Index: backend-bibtex.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-bibtex.c,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -U2 -r1.16 -r1.16.2.1 --- backend-bibtex.c 29 Jan 2004 01:42:06 -0000 1.16 +++ backend-bibtex.c 15 Apr 2005 22:45:05 -0000 1.16.2.1 @@ -26,4 +26,5 @@ #include "refdb.h" +#include "connect.h" #include "linklist.h" #include "backend.h" @@ -49,4 +50,6 @@ extern dbi_result dbi_style_res; +extern char cs_term[]; + /* forward declarations of local functions */ static char* bibtexify_author(char** ptr_bibauthor, char* author); @@ -57,6 +60,5 @@ query - char prepare_render_bibtex returns a ptr to the result string - if successful, NULL if not + int prepare_render_bibtex returns 0 if successful, >0 if not struct renderinfo* ptr_rendinfo ptr to a structure with the info @@ -64,8 +66,8 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -char* prepare_render_bibtex(struct renderinfo* ptr_rendinfo) { +int prepare_render_bibtex(struct renderinfo* ptr_rendinfo) { /* we just make sure that we start with a clean string */ (*(ptr_rendinfo->ptr_ref))[0] = '\0'; - return *(ptr_rendinfo->ptr_ref); + return 0; } @@ -73,6 +75,5 @@ finish_render_bibtex(): writes a footer for the bibtex output of a query - char* finish_render_bibtex returns ptr to the buffer if successful, - NULL if failed + int finish_render_bibtex returns 0 if successful, >0 if failed struct renderinfo* ptr_rendinfo ptr to a structure with the info @@ -80,15 +81,15 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -char* finish_render_bibtex(struct renderinfo* ptr_rendinfo) { +int finish_render_bibtex(struct renderinfo* ptr_rendinfo) { char* new_ref; if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; - } - else { - *(ptr_rendinfo->ptr_ref) = new_ref; - return new_ref; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } + + *(ptr_rendinfo->ptr_ref) = new_ref; + + return 0; } @@ -96,6 +97,5 @@ render_bibtex() renders a RIS dataset for bibtex output - char* render_bibtex returns ptr to the buffer if successful, - NULL if failed + int render_bibtex returns 0 if successful, >0 if failed struct renderinfo* ptr_rendinfo ptr to a structure with the info @@ -103,5 +103,5 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -char* render_bibtex(struct renderinfo* ptr_rendinfo) { +int render_bibtex(struct renderinfo* ptr_rendinfo) { int nperiodical_type; int sql_command_len; @@ -132,5 +132,6 @@ if ((type = get_refdb_type(ptr_rendinfo->dbires)) == NULL) { - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(234)); + return 234; } @@ -145,6 +146,6 @@ sql_command = (char*)malloc(sql_command_len); if (!sql_command) { - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } @@ -152,7 +153,7 @@ quoted_journal = mstrdup((ptr_rendinfo->ptr_biblio_info)->format_string); if (!dbi_driver_quote_string(driver, "ed_journal)) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(sql_command); - return NULL; + return 801; } @@ -167,7 +168,7 @@ /* need another connection to the database refdb */ if ((bibconns.conn_refdb = connect_to_db(ptr_rendinfo->ptr_clrequest, MAIN_DB, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, connerr.text); + LOG_PRINT(LOG_WARNING, get_status_msg(202)); free(sql_command); - return NULL; + return 202; } } @@ -180,9 +181,9 @@ if (!dbirescit) { - LOG_PRINT(LOG_WARNING, "CITSTYLE select failed"); + LOG_PRINT(LOG_WARNING, get_status_msg(234)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 234; } @@ -190,17 +191,17 @@ n_id = my_dbi_result_get_idval_idx(dbirescit, 1); if (!load_style(type, n_id, bibconns.conn_refdb)) { - LOG_PRINT(LOG_WARNING, "could not load style information"); + LOG_PRINT(LOG_WARNING, get_status_msg(234)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 234; } } else { - LOG_PRINT(LOG_WARNING, "could not load style information"); + LOG_PRINT(LOG_WARNING, get_status_msg(234)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 234; } @@ -300,5 +301,5 @@ dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 234; } @@ -328,5 +329,6 @@ dbi_conn_close(bibconns.conn_refdb); } - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(234)); + return 234; } @@ -349,6 +351,6 @@ dbi_conn_close(bibconns.conn_refdb); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } else { @@ -367,5 +369,5 @@ dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } @@ -377,6 +379,6 @@ dbi_conn_close(bibconns.conn_refdb); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } else { @@ -390,6 +392,6 @@ dbi_conn_close(bibconns.conn_refdb); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } else { @@ -402,9 +404,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "},\n", ptr_rendinfo->ptr_ref_len, 5)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -415,9 +417,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), ",\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -433,9 +435,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), " TITLE = {", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -444,9 +446,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), (char*)item, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { /* title */ unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -455,9 +457,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "},\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -476,9 +478,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), " BOOKTITLE = {", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -487,9 +489,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), (char*)item, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { /* book title */ unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -498,9 +500,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "},\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -515,9 +517,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), " SERIES = {", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -526,9 +528,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), (char*)item, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { /* series title */ unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -537,9 +539,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "},\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -556,9 +558,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), " JOURNAL = {", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -572,5 +574,5 @@ dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } } @@ -584,6 +586,6 @@ if ((item = get_periodical(bibconns.conn, date_buffer, NULL, nperiodical_type, &errcode, my_dbi_result_get_idval(ptr_rendinfo->dbires, "refdb_id"))) != NULL) { if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), " JOURNAL = {", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } else { @@ -591,6 +593,6 @@ } if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), (char*)item, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } else { @@ -602,9 +604,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "},\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -618,9 +620,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), " VOLUME = {", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -629,9 +631,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), (char*)item, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { /* volume */ unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -640,9 +642,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "},\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -658,9 +660,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), " NUMBER = {", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -669,9 +671,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), (char*)item, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { /* issue */ unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -680,9 +682,9 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "},\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); if (!n_multiple_db) { dbi_conn_close(bibconns.conn_refdb); } - return NULL; + return 801; } else { @@ -703,6 +705,6 @@ if (item != NULL) { if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), " PAGES = {", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } else { @@ -710,6 +712,6 @@ } if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), (char*)item, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { /* start page */ - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } else { @@ -720,6 +722,6 @@ if (item != NULL) { if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "-", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } else { @@ -727,6 +729,6 @@ } if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), (char*)item, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { /* end page */ - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } else { @@ -735,6 +737,6 @@ } if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "},\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } else { @@ -745,6 +747,6 @@ /* eliminate the trailing comma and finish with an empty line */ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "\n}\n", ptr_rendinfo->ptr_ref_len, 2)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } else { @@ -753,5 +755,5 @@ /* printf("%s\n", ref); */ - return *(ptr_rendinfo->ptr_ref); + return 0; } @@ -777,6 +779,8 @@ int result; int not_done = 1; + int cs_status; size_t n_bufsize; size_t nsql_command_len = 4096; /* should be enough */ + size_t buffer_len = 4096; char *sql_command = NULL; char *id_list = NULL; @@ -789,4 +793,5 @@ char *the_db; char *drivername; + char *buffer; char prev_db[DBNAME_LENGTH] = ""; dbi_conn conn; @@ -814,6 +819,6 @@ if (id_list == NULL || insert_lilimem(&sentinel, (void**)&id_list, NULL)) { delete_all_lilimem(&sentinel); - iwrite(ptr_clrequest->fd, outomem_n.text, outomem_n.length); - LOG_PRINT(LOG_CRIT, outomem.text); + send_status(ptr_clrequest->fd, 801, TERM_NO); + LOG_PRINT(LOG_CRIT, get_status_msg(801)); return 1; } @@ -822,21 +827,32 @@ if (sql_command == NULL || insert_lilimem(&sentinel, (void**)&sql_command, NULL)) { delete_all_lilimem(&sentinel); - iwrite(ptr_clrequest->fd, outomem_n.text, outomem_n.length); - LOG_PRINT(LOG_CRIT, outomem.text); + send_status(ptr_clrequest->fd, 801, TERM_NO); + LOG_PRINT(LOG_CRIT, get_status_msg(801)); return 1; } - /* send acknowledgement to client */ - numbyte = tiwrite(ptr_clrequest->fd, positive.text, TERM_YES); - if (numbyte == -1) { - LOG_PRINT(LOG_INFO, "could not write to client"); + /* fill in variable elements of structure */ + buffer = (char*)malloc(buffer_len); + if (buffer == NULL || insert_lilimem(&sentinel, (void**)&(buffer), NULL)) { delete_all_lilimem(&sentinel); + send_status(ptr_clrequest->fd, 801, TERM_NO); + LOG_PRINT(LOG_CRIT, get_status_msg(801)); return 1; } + buffer[0] = '\0'; + rendinfo.ptr_ref_len = &buffer_len; + rendinfo.ptr_ref = &buffer; + + /* send acknowledgement to client */ + send_status(ptr_clrequest->fd, 0, TERM_NO); + + /* status is always 0 */ + cs_status = read_status(ptr_clrequest->fd); + /* read whitespace-separated id list from client*/ numbyte = tread(ptr_clrequest->fd, id_list, n_bufsize); if (numbyte == -1) { - LOG_PRINT(LOG_INFO, "could not read from client"); + LOG_PRINT(LOG_INFO, get_status_msg(109)); delete_all_lilimem(&sentinel); return 1; @@ -848,6 +864,6 @@ /* connect to database server*/ if ((conn = connect_to_db(ptr_clrequest, NULL, 0)) == NULL) { - iwrite(ptr_clrequest->fd, connerr_n.text, connerr_n.length); - LOG_PRINT(LOG_ERR, "could not connect to database server"); + send_status(ptr_clrequest->fd, 204, TERM_NO); + LOG_PRINT(LOG_ERR, get_status_msg(204)); delete_all_lilimem(&sentinel); return 1; @@ -858,9 +874,15 @@ if (drivername == NULL || insert_lilimem(&sentinel, (void**)&drivername, NULL)) { delete_all_lilimem(&sentinel); - iwrite(ptr_clrequest->fd, outomem_n.text, outomem_n.length); - LOG_PRINT(LOG_CRIT, outomem.text); + send_status(ptr_clrequest->fd, 801, TERM_NO); + LOG_PRINT(LOG_ERR, get_status_msg(801)); return 1; } + /* create a "header" if necessary */ + /* prepare_render resets sql_command */ + + + prepare_render_bibtex(&rendinfo); + while (not_done) { /* search for the start of a token */ @@ -868,5 +890,5 @@ token++; } - + if (token == eof_string){ break; @@ -912,8 +934,8 @@ if (strcmp(prev_db, the_db)) { if (dbi_conn_select_db(conn, the_db)) { - iwrite(ptr_clrequest->fd, connerr_n.text, connerr_n.length); + send_status(ptr_clrequest->fd, 204, TERM_NO); + LOG_PRINT(LOG_ERR, get_status_msg(204)); dbi_conn_close(conn); delete_all_lilimem(&sentinel); - LOG_PRINT(LOG_WARNING, "could not connect to database"); return 1; } @@ -925,6 +947,6 @@ dbi_conn_close(conn); if ((conn = connect_to_db(ptr_clrequest, the_db, 0)) == NULL) { - iwrite(ptr_clrequest->fd, connerr_n.text, connerr_n.length); - LOG_PRINT(LOG_ERR, "could not connect to database server"); + send_status(ptr_clrequest->fd, 204, TERM_NO); + LOG_PRINT(LOG_ERR, get_status_msg(204)); delete_all_lilimem(&sentinel); return 1; @@ -938,5 +960,6 @@ rendinfo.dbires = dbi_conn_query(conn, sql_command); if (!rendinfo.dbires) { - tiwrite(ptr_clrequest->fd, "select failed\n", TERM_NO); + send_status(ptr_clrequest->fd, 234, TERM_NO); + LOG_PRINT(LOG_ERR, get_status_msg(234)); dbi_conn_close(conn); delete_all_lilimem(&sentinel); @@ -944,71 +967,63 @@ } - /* create a "header" if necessary */ - /* prepare_render resets sql_command */ - - /* fill in variable elements of structure */ - rendinfo.ptr_ref = &sql_command; - rendinfo.ptr_ref_len = &nsql_command_len; - - prepare_render_bibtex(&rendinfo); - /* fetch all articles we're interested in */ while (dbi_result_next_row(rendinfo.dbires)) { + int cs_status; + /* fill in variable elements of structure */ - rendinfo.ptr_ref = &sql_command; - rendinfo.ptr_ref_len = &nsql_command_len; + /* todo: what's this? why -1?*/ rendinfo.nref_counter = -1; rendinfo.database = the_db; rendinfo.dbname = dbstring; - /* recycle sql_command */ - if ((new_sql_command = render_bibtex(&rendinfo)) == NULL) { - iwrite(ptr_clrequest->fd, outomem_n.text, outomem_n.length); - dbi_result_free(rendinfo.dbires); - dbi_conn_close(conn); - delete_all_lilimem(&sentinel); - ptr_addresult->failure++; - return 1; - } - else { - sql_command = new_sql_command; + if ((cs_status = render_bibtex(&rendinfo)) != 0) { + if (cs_status == 801) { + send_status(ptr_clrequest->fd, cs_status, TERM_NO); + LOG_PRINT(LOG_ERR, get_status_msg(cs_status)); + dbi_result_free(rendinfo.dbires); + dbi_conn_close(conn); + delete_all_lilimem(&sentinel); + return 1; + } + else { + ptr_addresult->failure++; + } } + ptr_addresult->success++; - iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); - sql_command[0] = '\0'; - } + + /* send ok status, then the terminated result string */ + send_status(ptr_clrequest->fd, 404, TERM_NO); + iwrite(ptr_clrequest->fd, buffer, strlen(buffer)); + iwrite(ptr_clrequest->fd, cs_term, TERM_LEN); + + /* reset buffer string */ + buffer[0] = '\0'; + + /* read client response */ + cs_status = read_status(ptr_clrequest->fd); + + if (cs_status) { + break; + } + } /* end while */ + + } /* end while have more tokens */ /* create a "footer" if necessary */ /* fill in variable elements of structure */ - rendinfo.ptr_ref = &sql_command; - rendinfo.ptr_ref_len = &nsql_command_len; - - if ((new_sql_command = finish_render_bibtex(&rendinfo)) == NULL) { - dbi_result_free(rendinfo.dbires); - dbi_conn_close(conn); - delete_all_lilimem(&sentinel); - return 1; - } - else { - sql_command = new_sql_command; - } - iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); -/* dbi_result_free(dbires); */ + if ((cs_status = finish_render_bibtex(&rendinfo)) != 0) { + send_status(ptr_clrequest->fd, cs_status, TERM_NO); + LOG_PRINT(LOG_ERR, get_status_msg(cs_status)); + dbi_result_free(rendinfo.dbires); + dbi_conn_close(conn); + delete_all_lilimem(&sentinel); + return 1; } - dbi_conn_close(conn); + send_status(ptr_clrequest->fd, 402, TERM_NO); + tiwrite(ptr_clrequest->fd, buffer, TERM_YES); - tiwrite(ptr_clrequest->fd, "", TERM_YES); /* finish sending data */ - - /* wait for receipt from client, reuse sql_command */ - result = tread(ptr_clrequest->fd, sql_command, nsql_command_len); - - if (result == -1) { - LOG_PRINT(LOG_WARNING, "could not read ack from client"); - } - - if (strncmp(sql_command, positive.text, positive.length) != 0) { - LOG_PRINT(LOG_WARNING, "could not read ack from client"); - } + dbi_conn_close(conn); delete_all_lilimem(&sentinel); Index: backend-bibtex.h =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-bibtex.h,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -U2 -r1.6 -r1.6.2.1 --- backend-bibtex.h 13 Dec 2002 20:34:10 -0000 1.6 +++ backend-bibtex.h 15 Apr 2005 22:45:05 -0000 1.6.2.1 @@ -20,7 +20,7 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -char* prepare_render_bibtex(struct renderinfo* ptr_rendinfo); -char* finish_render_bibtex(struct renderinfo* ptr_rendinfo); -char* render_bibtex(struct renderinfo* ptr_rendinfo); +int prepare_render_bibtex(struct renderinfo* ptr_rendinfo); +int finish_render_bibtex(struct renderinfo* ptr_rendinfo); +int render_bibtex(struct renderinfo* ptr_rendinfo); int gettexbib(struct CLIENT_REQUEST* ptr_clrequest, struct bibinfo* ptr_biblio_info, struct ADDRESULT* ptr_addresult); Index: backend-db31.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-db31.c,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -U2 -r1.16 -r1.16.2.1 --- backend-db31.c 5 Oct 2003 10:36:16 -0000 1.16 +++ backend-db31.c 15 Apr 2005 22:45:05 -0000 1.16.2.1 @@ -52,6 +52,5 @@ query - char* prepare_render_db31 returns a ptr to the result string or - NULL if failed + int prepare_render_db31 returns 0 if successful,>0 if failed struct renderinfo* ptr_rendinfo ptr to a structure with the info @@ -59,5 +58,5 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -char* prepare_render_db31(struct renderinfo* ptr_rendinfo) { +int prepare_render_db31(struct renderinfo* ptr_rendinfo) { /* ToDo: control with format_string whether or not to include the document type declaration. For the time being the declaration does go in but is commented out */ @@ -70,8 +69,9 @@ else { /* we have a problem */ - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(302)); + return 302; } - return *(ptr_rendinfo->ptr_ref); + return 0; } @@ -79,6 +79,5 @@ finish_render_db31(): writes a footer for the docbook output of a query - char* finish_render_ris returns ptr to the buffer if successful, - NULL if failed + int finish_render_ris returns 0 if successful, >0 if failed struct renderinfo* ptr_rendinfo ptr to a structure with the info @@ -86,14 +85,15 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -char* finish_render_db31(struct renderinfo* ptr_rendinfo) { +int finish_render_db31(struct renderinfo* ptr_rendinfo) { char* new_ref; if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "</bibliography>\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - return NULL; - } - else { - *(ptr_rendinfo->ptr_ref) = new_ref; - return new_ref; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } + + *(ptr_rendinfo->ptr_ref) = new_ref; + + return 0; } @@ -101,5 +101,5 @@ render_db31() renders a RIS dataset for DocBook V.3.1 export - char* render_db31 returns ptr to ref if successful, NULL if not + int render_db31 returns 0 if successful, >0 if not struct renderinfo* ptr_rendinfo ptr to a structure with the info @@ -107,5 +107,5 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -char* render_db31(struct renderinfo* ptr_rendinfo) { +int render_db31(struct renderinfo* ptr_rendinfo) { char have_author = 0; char id[32] = ""; /* reference ID */ @@ -136,6 +136,6 @@ if ((chunk_buf = (char*)malloc(chunk_buf_len)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + return 801; } @@ -143,6 +143,7 @@ if ((type = get_refdb_type(ptr_rendinfo->dbires)) == NULL) { + LOG_PRINT(LOG_WARNING, get_status_msg(234)); free(chunk_buf); - return NULL; + return 234; } @@ -165,7 +166,7 @@ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "</abbrev>\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(chunk_buf); - return NULL; + return 801; } else { @@ -177,7 +178,7 @@ if (chunk && *chunk) { if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), chunk, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); - free(chunk_buf); - return NULL; + LOG_PRINT(LOG_WARNING, get_status_msg(801)); + free(chunk_buf); + return 801; } else { @@ -190,7 +191,7 @@ if (chunk && *chunk) { if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), chunk, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(chunk_buf); - return NULL; + return 801; } else { @@ -203,7 +204,7 @@ if (chunk && *chunk) { if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), chunk, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(chunk_buf); - return NULL; + return 801; } else { @@ -221,7 +222,7 @@ if (chunk && *chunk) { if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), chunk, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(chunk_buf); - return NULL; + return 801; } else { @@ -240,7 +241,7 @@ if (chunk && *chunk) { if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), chunk, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(chunk_buf); - return NULL; + return 801; } else { @@ -252,7 +253,7 @@ /* finish bibliography entry */ if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "</biblioentry>\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(chunk_buf); - return NULL; + return 801; } else { @@ -262,5 +263,5 @@ free(chunk_buf); - return *(ptr_rendinfo->ptr_ref); + return 0; } @@ -300,5 +301,5 @@ if ((author_buf = (char*)malloc(author_buf_len)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -306,5 +307,5 @@ /* start analytic information */ if ((new_ref = mstrcat(*ptr_chunk_buf, "<biblioset relation=\"analytic\">\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(author_buf); return NULL; @@ -324,5 +325,5 @@ n_have_data++; if ((new_ref = mstrcat(*ptr_chunk_buf, author_result, ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(author_buf); return NULL; @@ -357,5 +358,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -367,5 +368,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -377,5 +378,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -389,5 +390,5 @@ /* finish analytic information */ if ((new_ref = mstrcat(*ptr_chunk_buf, "</biblioset>\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -444,5 +445,5 @@ if ((author_buf = (char*)malloc(author_buf_len)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -452,5 +453,5 @@ /* start monographic information */ if ((new_ref = mstrcat(*ptr_chunk_buf, "<biblioset relation=\"monogr\">\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(author_buf); return NULL; @@ -476,5 +477,5 @@ n_have_data++; if ((new_ref = mstrcat(*ptr_chunk_buf, author_result, ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(author_buf); return NULL; @@ -496,5 +497,5 @@ n_have_data++; if ((new_ref = mstrcat(*ptr_chunk_buf, author_result, ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(author_buf); return NULL; @@ -530,5 +531,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "<biblioset relation=\"", ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -539,5 +540,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, journaltype[i], ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -548,5 +549,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "\">\n", ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -557,5 +558,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "<title>", ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -566,5 +567,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, entitize_buf, ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -575,5 +576,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "</title>\n</biblioset>\n", ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -615,5 +616,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -625,5 +626,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -635,5 +636,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -651,5 +652,5 @@ if ((item = get_refdb_issn(ptr_rendinfo->dbires)) != NULL) { if ((new_ref = mstrcat(*ptr_chunk_buf, "<isbn>", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -659,5 +660,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, (char*)item, ptr_chunk_buf_len, 0)) == NULL) { /* isbn/issn */ - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -667,5 +668,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "</isbn>\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -682,5 +683,5 @@ if ((item = get_refdb_publisher(ptr_rendinfo->dbires)) != NULL) { if ((new_ref = mstrcat(*ptr_chunk_buf, "<publisher><publishername>", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -690,5 +691,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, (char*)item, ptr_chunk_buf_len, 0)) == NULL) { /* publisher */ - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -698,5 +699,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "</publishername>", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -710,5 +711,5 @@ if ((item = get_refdb_city(ptr_rendinfo->dbires)) != NULL) { if ((new_ref = mstrcat(*ptr_chunk_buf, "<address>", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -718,5 +719,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, (char*)item, ptr_chunk_buf_len, 0)) == NULL) { /* city */ - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -726,5 +727,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "</address>", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -736,5 +737,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "</publisher>\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -759,5 +760,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "<volumenum>", ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -768,5 +769,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, entitize_buf, ptr_chunk_buf_len, 0)) == NULL) { /* volume */ free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -777,5 +778,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "</volumenum>\n", ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -789,5 +790,5 @@ if ((item = get_refdb_issue(ptr_rendinfo->dbires)) != NULL) { if ((entitize_buf = mstrdup((char*)item)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -800,5 +801,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "<issuenum>", ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -809,5 +810,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, entitize_buf, ptr_chunk_buf_len, 0)) == NULL) { /* issue */ free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -818,5 +819,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "</issuenum>\n", ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -830,5 +831,5 @@ if ((item = get_refdb_startpage(ptr_rendinfo->dbires)) != NULL) { if ((entitize_buf = mstrdup((char*)item)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -841,5 +842,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "<pagenums>", ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -850,5 +851,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, entitize_buf, ptr_chunk_buf_len, 0)) == NULL) { /* start page */ free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -861,5 +862,5 @@ if ((item = get_refdb_endpage(ptr_rendinfo->dbires)) != NULL) { if ((entitize_buf = mstrdup((char*)item)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -872,5 +873,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "-", ptr_chunk_buf_len, 0)) == NULL) { free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -881,5 +882,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, entitize_buf, ptr_chunk_buf_len, 0)) == NULL) { /* end page */ free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -891,5 +892,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "</pagenums>\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -902,5 +903,5 @@ if ((item = get_refdb_pubyear(ptr_rendinfo->dbires, periodical)) != NULL) { if ((new_ref = mstrcat(*ptr_chunk_buf, "<pubdate>", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -910,5 +911,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, periodical, ptr_chunk_buf_len, 0)) == NULL) { /* year */ - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -918,5 +919,5 @@ if ((new_ref = mstrcat(*ptr_chunk_buf, "</pubdate>\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -929,5 +930,5 @@ /* finish monographic information */ if ((new_ref = mstrcat(*ptr_chunk_buf, "</biblioset>\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -974,5 +975,5 @@ if ((author_buf = (char*)malloc(author_buf_len)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -980,5 +981,5 @@ /* start series info */ if ((new_ref = mstrcat(*ptr_chunk_buf, "<biblioset relation=\"series\">\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(author_buf); return NULL; @@ -998,5 +999,5 @@ n_have_data++; if ((new_ref = mstrcat(*ptr_chunk_buf, author_result, ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); free(author_buf); return NULL; @@ -1028,5 +1029,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1038,5 +1039,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1048,5 +1049,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1061,5 +1062,5 @@ /* finish series information */ if ((new_ref = mstrcat(*ptr_chunk_buf, "</biblioset>\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1100,5 +1101,5 @@ /* start bibliomisc element */ if ((new_ref = mstrcat(*ptr_chunk_buf, "<bibliomisc role=\"annotation\">", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1126,5 +1127,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1136,5 +1137,5 @@ /* finish notes */ if ((new_ref = mstrcat(*ptr_chunk_buf, "</bibliomisc>\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1175,5 +1176,5 @@ /* start abstract */ if ((new_ref = mstrcat(*ptr_chunk_buf, "<abstract>\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1201,5 +1202,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1211,5 +1212,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1221,5 +1222,5 @@ free((char*)item); free(entitize_buf); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1233,5 +1234,5 @@ /* finish abstract information */ if ((new_ref = mstrcat(*ptr_chunk_buf, "</abstract>\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1450,5 +1451,5 @@ if (dbauthor == NULL) { clean_request(dbires); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1462,5 +1463,5 @@ clean_request(dbires); free(dbauthor); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1473,5 +1474,5 @@ clean_request(dbires); free(dbauthor); - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } @@ -1486,5 +1487,5 @@ if (!nis_first) { if ((new_ref = mstrcat(*ptr_chunk_buf, "\n</authorgroup>\n", ptr_chunk_buf_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); + LOG_PRINT(LOG_WARNING, get_status_msg(801)); return NULL; } Index: backend-db31.h =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-db31.h,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -U2 -r1.4 -r1.4.2.1 --- backend-db31.h 13 Dec 2002 20:34:12 -0000 1.4 +++ backend-db31.h 15 Apr 2005 22:45:05 -0000 1.4.2.1 @@ -20,7 +20,7 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -char* prepare_render_db31(struct renderinfo* ptr_rendinfo); -char* finish_render_db31(struct renderinfo* ptr_rendinfo); -char* render_db31(struct renderinfo* ptr_rendinfo); +int prepare_render_db31(struct renderinfo* ptr_rendinfo); +int finish_render_db31(struct renderinfo* ptr_rendinfo); +int render_db31(struct renderinfo* ptr_rendinfo); Index: backend-dbib.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-dbib.c,v retrieving revision 1.28.2.3 retrieving revision 1.28.2.4 diff -u -U2 -r1.28.2.3 -r1.28.2.4 --- backend-dbib.c 21 Aug 2004 15:42:05 -0000 1.28.2.3 +++ backend-dbib.c 15 Apr 2005 22:45:05 -0000 1.28.2.4 @@ -36,4 +36,5 @@ #include "strfncs.h" #include "dbfncs.h" +#include "connect.h" extern int n_log_level; @@ -50,5 +51,5 @@ query - int prepare_render_dbib returns 0 if ok, 1 if error + int prepare_render_dbib returns 0 if ok, >0 if error [...2730 lines suppressed...] } - ref_buffer[0] = '\0'; + + *ptr_ref = new_ref; } - } /* while */ - } /* if */ + ref_buffer[0] = '\0'; + } + } /* end while */ + dbi_result_free(dbires_pos); unload_style(); @@ -2549,5 +2086,5 @@ free(ref_buffer); - return *ptr_ref; + return error; } Index: backend-dbib.h =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-dbib.h,v retrieving revision 1.9 retrieving revision 1.9.2.1 diff -u -U2 -r1.9 -r1.9.2.1 --- backend-dbib.h 9 Sep 2003 22:33:37 -0000 1.9 +++ backend-dbib.h 15 Apr 2005 22:45:05 -0000 1.9.2.1 @@ -27,10 +27,10 @@ int prepare_render_dbib(char* ref, struct bibinfo* ptr_biblio_info, dbi_result dbires, int n_ref_format); -char* finish_render_dbib(char** ptr_ref, size_t* ptr_ref_len, struct BIBCONNS* ptr_bibconns, struct bibinfo* ptr_biblio_info, char* table_name, struct CLIENT_REQUEST* ptr_clrequest); -char* render_dbib(char** ptr_ref, size_t* ref_len, struct BIBCONNS* ptr_bibconns, dbi_result dbires, const char* database, struct bibinfo* ptr_biblio_info, char* username, char* pdfroot, int nref_counter); -char* format_entry(char** ptr_ref, size_t* ptr_ref_len, char* pubtype, struct BIBCONNS* ptr_bibconns, dbi_result dbiresref, dbi_result dbires, const char* database, const char* username, int nref_counter, char* current_mset, struct bibinfo* ptr_biblio_info); +int finish_render_dbib(char** ptr_ref, size_t* ptr_ref_len, struct BIBCONNS* ptr_bibconns, struct bibinfo* ptr_biblio_info, char* table_name, struct CLIENT_REQUEST* ptr_clrequest); +int render_dbib(char** ptr_ref, size_t* ref_len, struct BIBCONNS* ptr_bibconns, dbi_result dbires, const char* database, struct bibinfo* ptr_biblio_info, char* username, char* pdfroot, int nref_counter); +int format_entry(char** ptr_ref, size_t* ptr_ref_len, char* pubtype, struct BIBCONNS* ptr_bibconns, dbi_result dbiresref, dbi_result dbires, const char* database, const char* username, int nref_counter, char* current_mset, struct bibinfo* ptr_biblio_info); char* format_refnumber(char** ptr_ref, size_t* ptr_ref_len, struct BIBCONNS* ptr_bibconns, dbi_result dbires, dbi_result dbiresref, int nref_counter, int n_intext); -char* format_authorlist(char** ptr_ref, size_t* ptr_ref_len, struct BIBCONNS* ptr_bibconns, dbi_result dbires, dbi_result dbiresref, int type, const char* database, int n_intext, struct bibinfo* ptr_biblio_info); +int format_authorlist(char** ptr_ref, size_t* ptr_ref_len, struct BIBCONNS* ptr_bibconns, dbi_result dbires, dbi_result dbiresref, int type, const char* database, int n_intext, struct bibinfo* ptr_biblio_info); char* format_pubdate(char** ptr_ref, size_t* ptr_ref_len, struct BIBCONNS* ptr_bibconns, dbi_result dbires, dbi_result dbiresref, dbi_result dbirescit, int type, int n_intext, const char* year_unique_suffix); char* format_title(char** ptr_ref, size_t* ptr_ref_len, struct BIBCONNS* ptr_bibconns, dbi_result dbires, dbi_result dbires_ref, int type, int n_intext); Index: backend-dbiba.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-dbiba.c,v retrieving revision 1.26.2.8 retrieving revision 1.26.2.9 diff -u -U2 -r1.26.2.8 -r1.26.2.9 --- backend-dbiba.c 23 Aug 2004 22:15:19 -0000 1.26.2.8 +++ backend-dbiba.c 15 Apr 2005 22:45:05 -0000 1.26.2.9 @@ -44,5 +44,5 @@ /* forward declarations of local functions */ static char* arabic_to_roman(char* roman, const char* arabic); -static char* format_authorname(char** ptr_ref, size_t* ptr_ref_len, struct AUTHOR_INFO* ptr_ainfo, const char* authorsep, const char* nameorder, const char* initialstyle, const char* author_upper, const char* author_preceeding, const char* author_following, int nis_intext, int type); +static int format_authorname(char** ptr_ref, size_t* ptr_ref_len, struct AUTHOR_INFO* ptr_ainfo, const char* authorsep, const char* nameorder, const char* initialstyle, const char* author_upper, const char* author_preceeding, const char* author_following, int nis_intext, int type); static char* format_day(char* ref, size_t* ptr_ref_len, const char* day, const char* dayformat, const char* pad); static char* format_firstmiddlename(char** ptr_ref, size_t* ptr_ref_len, struct AUTHOR_INFO* ptr_ainfo, const char* author_upper, const char* initialstyle, int nis_intext, int type); @@ -159,5 +159,5 @@ bibliography entry as a DocBook bibliomixed text - char* format_authorlist returns ptr to the buffer if successful, NULL if failed + int format_authorlist returns 0 if successful, >0 if failed char** ptr_ref ptr to a ptr to a buffer created with malloc which will receive @@ -191,5 +191,5 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -char* format_authorlist(char** ptr_ref, size_t* ptr_ref_len, struct BIBCONNS* ptr_bibconns, dbi_result dbires, dbi_result dbires_ref, int type, const char* database, int n_intext, struct bibinfo* ptr_biblio_info) { +int format_authorlist(char** ptr_ref, size_t* ptr_ref_len, struct BIBCONNS* ptr_bibconns, dbi_result dbires, dbi_result dbires_ref, int type, const char* database, int n_intext, struct bibinfo* ptr_biblio_info) { int num_authors; int nauthor_count = 0; @@ -197,4 +197,5 @@ int nauthor_display; int nhave_content = 0; + int n_status; unsigned long long n_id; /* const char* authors; */ @@ -358,6 +359,5 @@ n_id = my_dbi_result_get_idval(dbires, "refdb_id"); if (!n_id) { - LOG_PRINT(LOG_WARNING, "format_authorlist: cannot retrieve ID"); - return NULL; + return 244; } sprintf(id, ULLSPEC, (unsigned long long)n_id); @@ -416,5 +416,5 @@ if (item && !*item && !dbi_conn_error_flag(ptr_bibconns->conn_refdb)) { free(item); - return *ptr_ref; /* ASAME is empty string -> suppress authorlist */ + return 0; /* ASAME is empty string -> suppress authorlist */ } else if (item) { @@ -422,15 +422,13 @@ if (item1 && *item1 && !dbi_conn_error_flag(ptr_bibconns->conn_refdb)) { /* preceeding */ if (sgml_entitize(&item1, NULL) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); free(item); free(item1); - return NULL; + return 801; } if ((new_ref = mstrcat(*ptr_ref, item1, ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); free(item1); free(item); - return NULL; + return 801; } else { @@ -445,15 +443,13 @@ if (item1 && *item1 && !dbi_conn_error_flag(ptr_bibconns->conn_refdb)) { /* textpreceeding */ if (sgml_entitize(&item1, NULL) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); free(item1); free(item); - return NULL; + return 801; } if ((new_ref = mstrcat(*ptr_ref, item1, ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); free(item1); free(item); - return NULL; + return 801; } else { @@ -468,12 +464,10 @@ if (sgml_entitize(&item, NULL) == NULL) { free(item); - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } if ((new_ref = mstrcat(*ptr_ref, item, ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); free(item); - return NULL; + return 801; } else { @@ -488,13 +482,11 @@ if (item && *item && !dbi_conn_error_flag(ptr_bibconns->conn_refdb)) { /* following */ if (sgml_entitize(&item, NULL) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); free(item); - return NULL; + return 801; } if ((new_ref = mstrcat(*ptr_ref, item, ptr_ref_len, 0)) == NULL) { - LOG_PRINT(LOG_WARNING, outomem.text); free(item); - return NULL; + return 801; } else { @@ -505,5 +497,5 @@ free(item); } - return *ptr_ref; + return 0; } /* else: ASAME undefined, process authorlist as usual */ @@ -514,6 +506,5 @@ if (sgml_entitize(&alist_preceeding, NULL) == NULL) { free(alist_preceeding); - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } @@ -546,6 +537,5 @@ free(alist_preceeding); clean_request(dbires_author); - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } @@ -570,5 +560,5 @@ free(alist_preceeding); } - return *ptr_ref; + return 0; } } @@ -599,6 +589,5 @@ } clean_request(dbires_author); - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } else { @@ -621,6 +610,5 @@ } clean_request(dbires_author); - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } @@ -631,6 +619,5 @@ } clean_request(dbires_author); - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } else { @@ -653,5 +640,5 @@ author_upper = dbi_result_get_string_idx(dbires_ref, n_namefirstupper_index); - if ((new_ref = format_authorname(ptr_ref, ptr_ref_len, &ainfo, authorsep, nameorder, initialstyle, author_upper, author_preceeding, author_following, n_intext, type)) == NULL) { + if ((n_status = format_authorname(ptr_ref, ptr_ref_len, &ainfo, authorsep, nameorder, initialstyle, author_upper, author_preceeding, author_following, n_intext, type)) != 0) { clean_request(dbires_author); free(author_anonymous); @@ -659,9 +646,7 @@ free(author_following); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return n_status; } - *ptr_ref = new_ref; free(author_anonymous); } @@ -709,6 +694,5 @@ free(author_following); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } else { @@ -722,6 +706,5 @@ free(author_following); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } @@ -732,6 +715,5 @@ free(author_following); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } else { @@ -745,6 +727,5 @@ } free(item); - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } else { @@ -766,6 +747,5 @@ free(author_following); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } else { @@ -779,6 +759,5 @@ free(author_following); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } @@ -789,6 +768,5 @@ free(author_following); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } else { @@ -801,6 +779,5 @@ free(author_following); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } else { @@ -816,14 +793,13 @@ } - if ((new_ref = format_authorname(ptr_ref, ptr_ref_len, &ainfo, authorsep, nameorder, initialstyle, author_upper, author_preceeding, author_following, n_intext, type)) == NULL) { + if ((n_status = format_authorname(ptr_ref, ptr_ref_len, &ainfo, authorsep, nameorder, initialstyle, author_upper, author_preceeding, author_following, n_intext, type)) != 0) { clean_request(dbires_author); if (author_following) { free(author_following); } - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return n_status; } - *ptr_ref = new_ref; +/* *ptr_ref = new_ref; */ } /* end while have authors */ } /* end if have author_anonymous */ @@ -836,12 +812,10 @@ if (sgml_entitize(&author_following, NULL) == NULL) { free(author_following); - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } if ((new_ref = mstrcat(*ptr_ref, author_following, ptr_ref_len, 0)) == NULL) { free(author_following); - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } else { @@ -857,12 +831,10 @@ if (sgml_entitize(&item, NULL) == NULL) { free(item); - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } if ((new_ref = mstrcat(*ptr_ref, item, ptr_ref_len, 0)) == NULL) { free(item); - LOG_PRINT(LOG_WARNING, outomem.text); - return NULL; + return 801; } else { @@ -878,5 +850,5 @@ (*ptr_ref)[0] = '\0'; /* return empty string if no real content */ } - return *ptr_ref; + return 0; } ... [truncated message content] |