[Refdb-cvs] CVS: refdb/src backend-dbiba.c,1.28,1.29 refdbdref.c,1.66,1.67 xmlhandler.c,1.23,1.24 xm
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2004-06-20 21:45:47
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9496 Modified Files: backend-dbiba.c refdbdref.c xmlhandler.c xmlout.c Log Message: merge from stable branch Index: backend-dbiba.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-dbiba.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -U2 -r1.28 -r1.29 --- backend-dbiba.c 15 Jun 2004 00:53:34 -0000 1.28 +++ backend-dbiba.c 20 Jun 2004 21:45:32 -0000 1.29 @@ -3342,5 +3342,16 @@ } } - else if (nameorder && strcmp(nameorder, "LASTCOMMAFIRSTMIDDLE") == 0) { + else if (nameorder && (strcmp(nameorder, "LASTCOMMAFIRSTMIDDLE") == 0 + || strcmp(nameorder, "LASTCOMMASPCFIRSTMIDDLE") == 0)) { + char sep[3]; + + /* quick and dirty strcmp */ + if (nameorder[9] == 'F') { + strcpy(sep, ","); + } + else { + strcpy(sep, ", "); + } + if ((new_ref = format_lastname(ptr_ref, ptr_ref_len, *(ptr_ainfo->lastname) ? ptr_ainfo->lastname : ptr_ainfo->name, author_upper, nis_intext, type)) == NULL) { LOG_PRINT(LOG_WARNING, outomem.text); @@ -3352,5 +3363,5 @@ if ((*(ptr_ainfo->lastname) || *(ptr_ainfo->name)) && (*(ptr_ainfo->firstname) || *ptr_ainfo->middlename)) { - if ((new_ref = mstrcat(*ptr_ref, ",", ptr_ref_len, 0)) == NULL) { + if ((new_ref = mstrcat(*ptr_ref, sep, ptr_ref_len, 0)) == NULL) { LOG_PRINT(LOG_WARNING, outomem.text); return NULL; Index: refdbdref.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdref.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -U2 -r1.66 -r1.67 --- refdbdref.c 17 May 2004 23:41:08 -0000 1.66 +++ refdbdref.c 20 Jun 2004 21:45:37 -0000 1.67 @@ -1348,5 +1348,5 @@ dbi_result_free(dbires); - sprintf(sql_command, "SELECT user_id, xuser_id FROM t_xuser WHERE refdb_id="ULLSPEC, (unsigned long long)idval); + sprintf(sql_command, "SELECT t_user.user_id, t_user.user_name, t_xuser.xuser_id FROM t_user, t_xuser WHERE t_user.user_id=t_xuser.user_id AND t_xuser.refdb_id="ULLSPEC, (unsigned long long)idval); LOG_PRINT(LOG_DEBUG, sql_command); dbires_user = dbi_conn_query(conn, sql_command); @@ -1362,13 +1362,34 @@ } - if (dbi_result_get_numrows(dbires_user) > 1) { - /* dataset is used by at least one other user, refuse to delete it */ - sprintf(sql_command, "ID "ULLSPEC" is still in use\n", (unsigned long long)idval); - tiwrite(ptr_clrequest->fd, sql_command, TERM_NO); - my_dbi_conn_unlock(conn); - my_dbi_conn_rollback(conn); - dbi_result_free(dbires_user); - ptr_delresult->skipped++; - return 1; + if (dbi_result_get_numrows(dbires_user) >= 1) { + int used_by_other = 1; + + if (dbi_result_get_numrows(dbires_user) == 1) { + if (dbi_result_next_row(dbires_user) == 0) { + if (ptr_clrequest->n_cgi) { + iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); + } + tiwrite(ptr_clrequest->fd, "deleteref failed\n", TERM_NO); + my_dbi_conn_unlock(conn); + my_dbi_conn_rollback(conn); + LOG_PRINT(LOG_WARNING, "query error"); + return 0; + } + + if (!strcmp(ptr_clrequest->username, my_dbi_result_get_string(dbires_user, "user_name"))) { + used_by_other--; + } + } + + if (used_by_other) { + /* dataset is used by at least one other user, refuse to delete it */ + sprintf(sql_command, "ID "ULLSPEC" is still in use\n", (unsigned long long)idval); + tiwrite(ptr_clrequest->fd, sql_command, TERM_NO); + my_dbi_conn_unlock(conn); + my_dbi_conn_rollback(conn); + dbi_result_free(dbires_user); + ptr_delresult->skipped++; + return 1; + } } Index: xmlhandler.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/xmlhandler.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -U2 -r1.23 -r1.24 --- xmlhandler.c 17 May 2004 23:54:34 -0000 1.23 +++ xmlhandler.c 20 Jun 2004 21:45:37 -0000 1.24 @@ -510,6 +510,26 @@ /* the name of the style */ if (strcmp((ptr_asdata->ptr_first)->elname, "STYLENAME") == 0) { - strncpy(ptr_asdata->the_journal, (ptr_asdata->ptr_first)->ptr_elvalue, 255); - ptr_asdata->the_journal[255] = '\0'; + char* the_journal_q = NULL; + + if ((the_journal_q = strdup((ptr_asdata->ptr_first)->ptr_elvalue)) == NULL) { + (*(ptr_asdata->ptr_nmem_error))++; + LOG_PRINT(LOG_WARNING, "error in sql command"); + } + else { + if (dbi_driver_quote_string(dbi_conn_get_driver(ptr_asdata->conn), &the_journal_q) == -1) { + (*(ptr_asdata->ptr_nmem_error))++; + LOG_PRINT(LOG_WARNING, "error in sql command"); + } + } + + if (the_journal_q) { + strncpy(ptr_asdata->the_journal, the_journal_q, 255); + ptr_asdata->the_journal[255] = '\0'; + free(the_journal_q); + } + else { + ptr_asdata->the_journal[0] = '\0'; + } + strcpy(column_name, "JOURNAL"); strcpy(table_name, "CITSTYLE"); @@ -788,5 +808,6 @@ else if (strcmp((ptr_asdata->ptr_first)->elname, "CITESTYLE") == 0) { (*(ptr_asdata->ptr_set_count))++; - sprintf(sql_command, "SELECT ID FROM CITSTYLE WHERE JOURNAL='%s' ORDER BY ID ASC", ptr_asdata->the_journal); + /* the_journal is already quoted */ + sprintf(sql_command, "SELECT ID FROM CITSTYLE WHERE JOURNAL=%s ORDER BY ID ASC", ptr_asdata->the_journal); dbires = dbi_conn_query(ptr_asdata->conn, sql_command); LOG_PRINT(LOG_DEBUG, sql_command); @@ -831,25 +852,40 @@ if (n_chardata) { - if (pubtype[0]) { - sprintf(sql_command, "UPDATE REFSTYLE SET %s='%s' WHERE CITSTYLEID="ULLSPEC" AND PUBTYPE='", column_name, (ptr_asdata->ptr_first)->ptr_elvalue, (unsigned long long)current_id); - /* we have to add pubtype outside of the sprintf call. The reason is unclear, but may be a hidden overflow or something */ - strcat(sql_command, pubtype); - strcat(sql_command, "\'"); - } - else { - sprintf(sql_command, "UPDATE %s SET %s='%s' WHERE ID="ULLSPEC, table_name, column_name, (ptr_asdata->ptr_first)->ptr_elvalue, (unsigned long long)current_id); - } - /* printf("%s\n", sql_command); */ - dbires = dbi_conn_query(ptr_asdata->conn, sql_command); - LOG_PRINT(LOG_DEBUG, sql_command); - if (!dbires) { - (*(ptr_asdata->ptr_ndb_error))++; - LOG_PRINT(LOG_WARNING, "error in sql command"); + char* elvalue_q = NULL; + + /* quote element value */ + if ((elvalue_q = strdup((ptr_asdata->ptr_first)->ptr_elvalue)) == NULL) { + /* todo: bail out */ } else { - dbi_result_free(dbires); + if (dbi_driver_quote_string(dbi_conn_get_driver(ptr_asdata->conn), &elvalue_q) == -1) { + /* todo: bail out */ + } } - } - } + + if (elvalue_q) { + if (pubtype[0]) { + sprintf(sql_command, "UPDATE REFSTYLE SET %s=%s WHERE CITSTYLEID="ULLSPEC" AND PUBTYPE='", column_name, elvalue_q, (unsigned long long)current_id); + /* we have to add pubtype outside of the sprintf call. The reason is unclear, but may be a hidden overflow or something */ + strcat(sql_command, pubtype); + strcat(sql_command, "\'"); + } + else { + sprintf(sql_command, "UPDATE %s SET %s=%s WHERE ID="ULLSPEC, table_name, column_name, elvalue_q, (unsigned long long)current_id); + } + + free(elvalue_q); + dbires = dbi_conn_query(ptr_asdata->conn, sql_command); + LOG_PRINT(LOG_DEBUG, sql_command); + if (!dbires) { + (*(ptr_asdata->ptr_ndb_error))++; + LOG_PRINT(LOG_WARNING, "error in sql command"); + } + else { + dbi_result_free(dbires); + } + } /* end if elvalue_q */ + } /* end if n_chardata */ + } /* end if no mem or db errors */ /* remove attributes of the current element from the list */ Index: xmlout.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/xmlout.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -U2 -r1.6 -r1.7 --- xmlout.c 29 Jan 2004 01:42:51 -0000 1.6 +++ xmlout.c 20 Jun 2004 21:45:38 -0000 1.7 @@ -168,4 +168,6 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ int iwrite_element(struct CLIENT_REQUEST* ptr_clrequest, const char* elname, Liliform *ptr_first, const char *elvalue) { + char* entitize_buf; + if (!elvalue || !*elvalue || !elname || !*elname) { /* nothing to do */ @@ -177,8 +179,17 @@ } - if (tiwrite(ptr_clrequest->fd, elvalue, TERM_NO) == -1) { + /* take care of entities */ + if ((entitize_buf = strdup(elvalue)) == NULL + || sgml_entitize(&entitize_buf, NULL) == NULL) { + return 1; + } + + if (tiwrite(ptr_clrequest->fd, entitize_buf, TERM_NO) == -1) { + free(entitize_buf); return 1; } + free(entitize_buf); + if (iwrite_elend(ptr_clrequest, elname)) { return 1; |