[Refdb-cvs] CVS: refdb/src backend-bibtex.c,1.16.2.10,1.16.2.11
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2006-04-09 21:35:46
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13303 Modified Files: Tag: Release_0_9_5_stable backend-bibtex.c Log Message: added URLs to the output; fixed INBOOK and BOOK title names Index: backend-bibtex.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-bibtex.c,v retrieving revision 1.16.2.10 retrieving revision 1.16.2.11 diff -u -U2 -r1.16.2.10 -r1.16.2.11 --- backend-bibtex.c 11 Jan 2006 21:01:04 -0000 1.16.2.10 +++ backend-bibtex.c 9 Apr 2006 21:35:42 -0000 1.16.2.11 @@ -46,4 +46,5 @@ /* forward declarations of local functions */ static char* bibtexify_author(char** ptr_bibauthor, char* author); +static char* print_field_bibtex(const char* item, struct renderinfo* ptr_rendinfo, const char* start_string); @@ -428,5 +429,14 @@ item = get_refdb_title_copy(ptr_rendinfo->dbires); if (item != NULL) { - if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), " TITLE = {", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { + char titlestring[32]; + + if (!strcmp(type, "CHAP")) { + strcpy(titlestring, " CHAPTER = {"); + } + else { + strcpy(titlestring, " TITLE = {"); + } + + if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), titlestring, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); LOG_PRINT(LOG_CRIT, get_status_msg(801)); @@ -471,5 +481,14 @@ item = get_refdb_booktitle_copy(ptr_rendinfo->dbires); if (item != NULL) { - if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), " BOOKTITLE = {", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { + char titlestring[32]; + + if (!strcmp(type, "CHAP") + || !strcmp(type, "BOOK")) { + strcpy(titlestring, " TITLE = {"); + } + else { + strcpy(titlestring, " BOOKTITLE = {"); + } + if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), titlestring, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { unload_style(); LOG_PRINT(LOG_CRIT, get_status_msg(801)); @@ -791,4 +810,51 @@ } + /*----------------------------------------------------------------*/ + /* URL, L1 through L4 */ + + /* loop over all link types */ + for (i=0; i<5;i++) { + dbires = request_ulinks(bibconns.conn, my_dbi_result_get_idval(ptr_rendinfo->dbires, "refdb_id"), 0 /* ref entry */, i /* link type */); + if (dbires == NULL) { + return 234; + } + + while ((item = get_ulink(dbires)) != NULL) { + /* currently all types are rendered as URL, but this might need a change later */ + if (i == 0) { /* UR */ + if (print_field_bibtex(item, ptr_rendinfo, " URL = { ") == NULL) { + clean_request(dbires); + return 801; + } + } + else if (i == 1) { /* L1 */ + if (print_field_bibtex(item, ptr_rendinfo, " URL = { ") == NULL) { + clean_request(dbires); + return 801; + } + } + else if (i == 2) { /* L2 */ + if (print_field_bibtex(item, ptr_rendinfo, " URL = { ") == NULL) { + clean_request(dbires); + return 801; + } + } + else if (i == 3) { /* L3 */ + if (print_field_bibtex(item, ptr_rendinfo, " URL = { ") == NULL) { + clean_request(dbires); + return 801; + } + } + else if (i == 4) { /* L4 */ + if (print_field_bibtex(item, ptr_rendinfo, " URL = { ") == NULL) { + clean_request(dbires); + return 801; + } + } + } + + clean_request(dbires); + } /* end for */ + /* 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) { @@ -805,4 +871,51 @@ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + print_field_bibtex(): writes simple field contents to bibtex output + + char* print_field_bibtex returns a ptr to the modified string. Due to + reallocation this may be different from the + ptr passed to this function in the ptr_rendinfo + structure which is also updated accordingly + + const char* item ptr to the contents of the field to write + + struct renderinfo* ptr_rendinfo ptr to a structure with the info + how the reference should be rendered + + const char* start_string ptr to a string to be printed before the + field contents + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +static char* print_field_bibtex(const char* item, struct renderinfo* ptr_rendinfo, const char* start_string) { + char* new_ref; + + if (item != NULL) { + if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), (char*)start_string, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { + LOG_PRINT(LOG_CRIT, get_status_msg(801)); + return NULL; + } + else { + *(ptr_rendinfo->ptr_ref) = new_ref; + } + if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), (char*)item, ptr_rendinfo->ptr_ref_len, 0)) == NULL) { + LOG_PRINT(LOG_CRIT, get_status_msg(801)); + return NULL; + } + else { + *(ptr_rendinfo->ptr_ref) = new_ref; + } + if ((new_ref = mstrcat(*(ptr_rendinfo->ptr_ref), "},\n", ptr_rendinfo->ptr_ref_len, 0)) == NULL) { + LOG_PRINT(LOG_CRIT, get_status_msg(801)); + return NULL; + } + else { + *(ptr_rendinfo->ptr_ref) = new_ref; + } + } + return *(ptr_rendinfo->ptr_ref); +} + + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gettexbib(): executes client command gettexbib |