[Refdb-cvs] CVS: refdb/src refdbdbib.c,1.36.2.6,1.36.2.7
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2004-09-08 20:24:00
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9518/src Modified Files: Tag: Release_0_9_5_stable refdbdbib.c Log Message: added write_bibstyle_info();add year suffix to first author/year duplicate too;added support for BIBSTYLE output Index: refdbdbib.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdbib.c,v retrieving revision 1.36.2.6 retrieving revision 1.36.2.7 diff -u -U2 -r1.36.2.6 -r1.36.2.7 --- refdbdbib.c 22 Aug 2004 22:22:03 -0000 1.36.2.6 +++ refdbdbib.c 8 Sep 2004 20:23:32 -0000 1.36.2.7 @@ -74,4 +74,5 @@ static int fill_in_authoryear_info(struct BIBCONNS* ptr_bibconns, dbi_result dbires, dbi_result dbires_cit, struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult, struct bibinfo* biblio_info, const char* table_name, char* pubtype, char* current_mset, unsigned long long* nref_counter); static void close_dbi_connections(struct BIBCONNS* ptr_bibconns, const char* drivername); +static int write_bibstyle_info(int fd, const char* bibliofirstindent, const char* biblioblockindent, const char* fontsize, int type); @@ -1522,5 +1523,5 @@ if (dbi_result_get_numrows(dbires2) > 1) { /* more than one entry with identical author/year combo */ /* add a unique suffix to each entry */ - unique_count = 0; + unique_count = 1; /* todo: was 0 */ *suffix = '\0'; /* reset suffix to empty string */ @@ -2055,5 +2056,5 @@ /* loop over all requested styles */ for (; *(ptr_clrequest->ptr_optind) < ptr_clrequest->inargc; (*(ptr_clrequest->ptr_optind))++) { - sprintf(sql_command, "SELECT ID,JOURNAL,CITSEPARATOR,FOLLOWING,PRECEEDING,RANGESEPARATOR,BIBLIOTITLE,INTEXTSEQUENCE,BIBLIOSEQUENCE,STYLE,JANABBREV,FEBABBREV,MARABBREV,APRABBREV,MAYABBREV,JUNABBREV,JULABBREV,AUGABBREV,SEPABBREV,OCTABBREV,NOVABBREV,DECABBREV,JANFULL,FEBFULL,MARFULL,APRFULL,MAYFULL,JUNFULL,JULFULL,AUGFULL,SEPFULL,OCTFULL,NOVFULL,DECFULL,JANTHREELET,FEBTHREELET,MARTHREELET,APRTHREELET,MAYTHREELET,JUNTHREELET,JULTHREELET,AUGTHREELET,SEPTHREELET,OCTTHREELET,NOVTHREELET,DECTHREELET FROM CITSTYLE WHERE JOURNAL='%s'", (ptr_clrequest->inargv)[*(ptr_clrequest->ptr_optind)]); + sprintf(sql_command, "SELECT ID,JOURNAL,CITSEPARATOR,FOLLOWING,PRECEEDING,RANGESEPARATOR,BIBLIOTITLE,INTEXTSEQUENCE,BIBLIOSEQUENCE,BIBLIOFIRSTINDENT,BIBLIOBLOCKINDENT,FONTSIZE,STYLE,JANABBREV,FEBABBREV,MARABBREV,APRABBREV,MAYABBREV,JUNABBREV,JULABBREV,AUGABBREV,SEPABBREV,OCTABBREV,NOVABBREV,DECABBREV,JANFULL,FEBFULL,MARFULL,APRFULL,MAYFULL,JUNFULL,JULFULL,AUGFULL,SEPFULL,OCTFULL,NOVFULL,DECFULL,JANTHREELET,FEBTHREELET,MARTHREELET,APRTHREELET,MAYTHREELET,JUNTHREELET,JULTHREELET,AUGTHREELET,SEPTHREELET,OCTTHREELET,NOVTHREELET,DECTHREELET FROM CITSTYLE WHERE JOURNAL='%s'", (ptr_clrequest->inargv)[*(ptr_clrequest->ptr_optind)]); dbires = dbi_conn_query(conn, sql_command); @@ -2093,5 +2094,5 @@ break; } - if (insert_liliform(&attr_sentinel, "BIBLIOSEQUENCE", (char*)my_dbi_result_get_string(dbires, "BIBLIOSEQUENCE"))) { + if (insert_liliform(&attr_sentinel, "STYLE", (char*)my_dbi_result_get_string(dbires, "STYLE"))) { LOG_PRINT(LOG_WARNING, outomem.text); delete_all_liliform(&attr_sentinel); @@ -2114,7 +2115,4 @@ iwrite_element(ptr_clrequest, "RANGESEPARATOR", NULL, my_dbi_result_get_string(dbires, "RANGESEPARATOR")); - /* bibliotitle */ - iwrite_element(ptr_clrequest, "BIBLIOTITLE", NULL, my_dbi_result_get_string(dbires, "BIBLIOTITLE")); - /* intextdef */ iwrite_pubtype(ptr_clrequest, "INTEXTDEF", citstyle_id, conn); @@ -2126,9 +2124,43 @@ iwrite_pubtype(ptr_clrequest, "YEARONLY", citstyle_id, conn); + /* end citstyle block */ + iwrite_elend(ptr_clrequest, "CITSTYLE"); + + /* begin bibstyle block */ + if (insert_liliform(&attr_sentinel, "BIBLIOSEQUENCE", (char*)my_dbi_result_get_string(dbires, "BIBLIOSEQUENCE"))) { + LOG_PRINT(LOG_WARNING, outomem.text); + delete_all_liliform(&attr_sentinel); + break; + } + + if (insert_liliform(&attr_sentinel, "BIBLIOFIRSTINDENT", (char*)my_dbi_result_get_string(dbires, "BIBLIOFIRSTINDENT"))) { + LOG_PRINT(LOG_WARNING, outomem.text); + delete_all_liliform(&attr_sentinel); + break; + } + + if (insert_liliform(&attr_sentinel, "BIBLIOBLOCKINDENT", (char*)my_dbi_result_get_string(dbires, "BIBLIOBLOCKINDENT"))) { + LOG_PRINT(LOG_WARNING, outomem.text); + delete_all_liliform(&attr_sentinel); + break; + } + + if (insert_liliform(&attr_sentinel, "FONTSIZE", (char*)my_dbi_result_get_string(dbires, "FONTSIZE"))) { + LOG_PRINT(LOG_WARNING, outomem.text); + delete_all_liliform(&attr_sentinel); + break; + } + + iwrite_elstart(ptr_clrequest, "BIBSTYLE", &attr_sentinel, 0); + delete_all_liliform(&attr_sentinel); + + /* bibliotitle */ + iwrite_element(ptr_clrequest, "BIBLIOTITLE", NULL, my_dbi_result_get_string(dbires, "BIBLIOTITLE")); + /* months block */ iwrite_months(ptr_clrequest, dbires); - /* end citstyle block */ - iwrite_elend(ptr_clrequest, "CITSTYLE"); + /* end bibstyle block */ + iwrite_elend(ptr_clrequest, "BIBSTYLE"); /* end citestyle */ @@ -2487,4 +2519,7 @@ const char *item_pubtype; const char *drivername; + const char *bibliofirstindent; + const char *biblioblockindent; + const char *fontsize; /* this array of strings contains part of the variable names in the output file (the column names in the database) */ @@ -2558,8 +2593,8 @@ /* read style elements from the citestyle table */ if (!strcmp(my_dbi_conn_get_cap(conn, "multiple_db"), "t")) { - sprintf(sql_command, "SELECT ID, STYLE from %s.CITSTYLE where JOURNAL=%s", MAIN_DB, format_string); + sprintf(sql_command, "SELECT ID, STYLE, BIBLIOFIRSTINDENT, BIBLIOBLOCKINDENT, FONTSIZE FROM %s.CITSTYLE WHERE JOURNAL=%s", MAIN_DB, format_string); } else { - sprintf(sql_command, "SELECT ID, STYLE from CITSTYLE where JOURNAL=%s", format_string); + sprintf(sql_command, "SELECT ID, STYLE, BIBLIOFIRSTINDENT, BIBLIOBLOCKINDENT, FONTSIZE FROM CITSTYLE WHERE JOURNAL=%s", format_string); } @@ -2577,4 +2612,9 @@ } + /* NULL check will be done later */ + bibliofirstindent = dbi_result_get_string(dbires_cit, "BIBLIOFIRSTINDENT"); + biblioblockindent = dbi_result_get_string(dbires_cit, "BIBLIOBLOCKINDENT"); + fontsize = dbi_result_get_string(dbires_cit, "FONTSIZE"); + /* now retrieve the styles for individual publication types */ n_id = my_dbi_result_get_idval_idx(dbires_cit, 1); @@ -2639,7 +2679,19 @@ if (n_ref_format == REFDOCBK) { + if (write_bibstyle_info(fd, bibliofirstindent, biblioblockindent, fontsize, 1 /* DSSSL */)) { + dbi_result_free(dbires_cit); + dbi_result_free(dbires_ref); + LOG_PRINT(LOG_WARNING, "could not write bibstyle info"); + return 0; + } sprintf(outbuffer, "</style-specification-body>\n</style-specification>\n<style-specification id=\"%s\" use=\"%s\">\n<style-specification-body>\n", STYLESHEET_PRINT_ID, STYLESHEET_PRINT_BASENAME); } else { + if (write_bibstyle_info(fd, bibliofirstindent, biblioblockindent, fontsize, 0 /* XSLT */)) { + dbi_result_free(dbires_cit); + dbi_result_free(dbires_ref); + LOG_PRINT(LOG_WARNING, "could not write bibstyle info"); + return 0; + } strcpy(outbuffer, "</xsl:stylesheet>"); } @@ -2696,4 +2748,9 @@ dbi_result_free(dbires_ref); + if (write_bibstyle_info(fd, bibliofirstindent, biblioblockindent, fontsize, 1 /* DSSSL */)) { + LOG_PRINT(LOG_WARNING, "could not write bibstyle info"); + return 0; + } + sprintf(outbuffer, "</style-specification-body>\n</style-specification>\n<external-specification id=\"%s\" document=\"%s\">\n<external-specification id=\"%s\" document=\"%s\">\n</style-sheet>\n", STYLESHEET_HTML_BASENAME, STYLESHEET_HTML_NAME, STYLESHEET_PRINT_BASENAME, STYLESHEET_PRINT_NAME); numbyte = tiwrite(fd, outbuffer, TERM_YES); @@ -2709,4 +2766,69 @@ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + write_bibstyle_info() writes bibliography style info as part of a + xslt/dsssl driver file + + static int write_bibstyle_info returns 1 in case of an error, 0 if successful + + int fd file descriptor to write data to + + const char* bibliofirstindent ptr to string containing bibliofirstindent info + + const char* biblioblockindent ptr to string containing biblioblockindent info + + const char* fontsize ptr to string containing fontsize info + + int type 0 = xslt output 1 = dsssl output + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +static int write_bibstyle_info(int fd, const char* bibliofirstindent, const char* biblioblockindent, const char* fontsize, int type) { + char outbuffer[512]; + int numbyte; + + /* todo: check string lengths or use mstrcat et al. */ + + *outbuffer = '\0'; + + if (!type) { /* XSLT */ + strcpy(outbuffer, "<!-- REFDBBIBSTYLE --><xsl:attribute-set name=\"refdb.bibliomset\" use-attribute-sets=\"normal.para.spacing\">"); + + if (bibliofirstindent) { + sprintf(outbuffer+strlen(outbuffer), "<xsl:attribute name=\"text-indent\">%s</xsl:attribute>", bibliofirstindent); + } + + if (biblioblockindent) { + sprintf(outbuffer+strlen(outbuffer), "<xsl:attribute name=\"start-indent\">%s</xsl:attribute>", biblioblockindent); + } + + if (fontsize) { + sprintf(outbuffer+strlen(outbuffer), "<xsl:attribute name=\"font-size\">%s</xsl:attribute>", fontsize); + } + + strcat(outbuffer, "</xsl:attribute-set><!-- /REFDBBIBSTYLE -->\n"); + } + else { /* DSSSL */ + if (bibliofirstindent) { + sprintf(outbuffer, "(define text-indent \"%s\")\n", bibliofirstindent); + } + + if (biblioblockindent) { + sprintf(&(outbuffer[strlen(outbuffer)]), "(define start-indent \"%s\")\n", biblioblockindent); + } + + if (fontsize) { + sprintf(&(outbuffer[strlen(outbuffer)]), "(define font-size \"%s\")\n", fontsize); + } + } + + numbyte = tiwrite(fd, outbuffer, TERM_NO); +/* printf("outbuffer:%s<<\n", outbuffer); */ + if (numbyte == -1) { + return 1; + } + + return 0; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ assemble_return_msg() assembles a message from a given static part and a dbi error message |