refdb-cvs Mailing List for RefDB (Page 73)
Status: Beta
Brought to you by:
mhoenicka
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(47) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(88) |
Feb
(50) |
Mar
(36) |
Apr
(9) |
May
(30) |
Jun
(30) |
Jul
(22) |
Aug
(16) |
Sep
(42) |
Oct
(18) |
Nov
(29) |
Dec
(23) |
2005 |
Jan
(18) |
Feb
(28) |
Mar
(21) |
Apr
(35) |
May
(62) |
Jun
(22) |
Jul
(5) |
Aug
(40) |
Sep
(98) |
Oct
(81) |
Nov
(51) |
Dec
(62) |
2006 |
Jan
(46) |
Feb
(36) |
Mar
(8) |
Apr
(16) |
May
(14) |
Jun
(16) |
Jul
(47) |
Aug
(60) |
Sep
(34) |
Oct
(16) |
Nov
(46) |
Dec
(11) |
2007 |
Jan
(16) |
Feb
(13) |
Mar
(58) |
Apr
(32) |
May
(4) |
Jun
(8) |
Jul
(31) |
Aug
(46) |
Sep
(22) |
Oct
(30) |
Nov
(58) |
Dec
(15) |
2008 |
Jan
(8) |
Feb
(8) |
Mar
(2) |
Apr
(6) |
May
(3) |
Jun
(2) |
Jul
(1) |
Aug
|
Sep
|
Oct
(6) |
Nov
(3) |
Dec
(5) |
2009 |
Jan
(1) |
Feb
(20) |
Mar
(8) |
Apr
(5) |
May
(8) |
Jun
(3) |
Jul
(6) |
Aug
(4) |
Sep
(7) |
Oct
(8) |
Nov
(2) |
Dec
(1) |
2010 |
Jan
(1) |
Feb
(4) |
Mar
|
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2011 |
Jan
(5) |
Feb
(5) |
Mar
(13) |
Apr
(3) |
May
|
Jun
|
Jul
(4) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2012 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(5) |
Nov
|
Dec
(3) |
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(13) |
2014 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
(4) |
May
(1) |
Jun
(1) |
Jul
|
Aug
(6) |
Sep
(3) |
Oct
|
Nov
(2) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2017 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2022 |
Jan
(9) |
Feb
(16) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Markus H. <mho...@us...> - 2004-01-18 21:20:52
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv28760 Modified Files: refdbib.c Log Message: added output encoding support Index: refdbib.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbib.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -U2 -r1.37 -r1.38 --- refdbib.c 2 Sep 2003 15:02:11 -0000 1.37 +++ refdbib.c 18 Jan 2004 21:20:46 -0000 1.38 @@ -64,5 +64,5 @@ /*+ this array will hold the user preferences +*/ -Prefs prefs[17] = { +Prefs prefs[18] = { {"serverip", ""}, {"port", ""}, @@ -81,4 +81,5 @@ {"refdblib", ""}, {"startnumber", ""}, + {"encoding", ""}, {"", ""} }; @@ -100,4 +101,5 @@ char verbose[PREFS_BUF_LEN] = ""; /* verbose output? */ char startnumber[PREFS_BUF_LEN] = ""; /* first number of reference */ +char encoding[PREFS_BUF_LEN] = ""; /* output encoding */ char confdir[_POSIX_PATH_MAX+1] = ""; /* path to the config files */ @@ -201,4 +203,5 @@ prefs[14].varvalue = refdblib; prefs[15].varvalue = startnumber; + prefs[16].varvalue = encoding; /* a slimy hack to detect options before getopt runs */ @@ -227,5 +230,5 @@ /* read command line settings. These may override the config file settings */ - while ((n_opt = getopt(argc, argv, "c:d:D:e:f:hi:l:L:nN:p:qS:t:T:u:vVw:y:")) != -1) { + while ((n_opt = getopt(argc, argv, "c:d:D:e:E:f:hi:l:L:nN:p:qS:t:T:u:vVw:y:")) != -1) { switch (n_opt) { case 'c': @@ -245,4 +248,8 @@ log_dest[PREFS_BUF_LEN-1] = '\0'; break; + case 'E': + strncpy(encoding, optarg, PREFS_BUF_LEN); + encoding[PREFS_BUF_LEN-1] = '\0'; + break; case 'f': if (!strcmp(optarg, "stdin")) { @@ -251,5 +258,5 @@ break; case 'h': - fprintf(stderr, "Create a bibliography file based on an ID or citation key list\nThe list must be provided as an XML document using the citationlistx DTD either on stdin or by passing the file\'s path as an argument\nUsage: refdbib [-c pager ] [-d db] [-D dir] [-e logdest] [-f stdin] [-h] [-i address] [-l log-level] [-L logfile] [-n] [-N number] [-p port] [-q] [-S style] [-t type] [-T time] [-u name] [-v] [-V] [-w password] [-y confdir] file\nOptions: -c pager command\n -d use database db\n -D save driver files in dir\n -e log destination (0=stderr, 1=syslog, 2=custom file)\n -f stdin read data from stdin (kludge only required for Cygwin)\n -h prints this help\n -i set server IP address\n -l set the log level\n -L set the log file\n -n send no driver file\n -N start numbering bibliography entries with number\n -p set server port\n -q ignore init-file\n -S use bibliography style\n -t output type (db31|db31x|teix|bibtex)\n -T set timeout in seconds\n -u set username\n -v show version information\n -V switch to verbose mode\n -w set password\n -y look for configuration files in confdir\n"); + fprintf(stderr, "Create a bibliography file based on an ID or citation key list\nThe list must be provided as an XML document using the citationlistx DTD either on stdin or by passing the file\'s path as an argument\nUsage: refdbib [-c pager ] [-d db] [-D dir] [-e logdest] [-E encoding] [-f stdin] [-h] [-i address] [-l log-level] [-L logfile] [-n] [-N number] [-p port] [-q] [-S style] [-t type] [-T time] [-u name] [-v] [-V] [-w password] [-y confdir] file\nOptions: -c pager command\n -d use database db\n -D save driver files in dir\n -e log destination (0=stderr, 1=syslog, 2=custom file)\n -E encoding set the output character encoding\n -f stdin read data from stdin (kludge only required for Cygwin)\n -h prints this help\n -i set server IP address\n -l set the log level\n -L set the log file\n -n send no driver file\n -N start numbering bibliography entries with number\n -p set server port\n -q ignore init-file\n -S use bibliography style\n -t output type (db31|db31x|teix|bibtex)\n -T set timeout in seconds\n -u set username\n -v show version information\n -V switch to verbose mode\n -w set password\n -y look for configuration files in confdir\n"); exit (0); break; @@ -594,5 +601,5 @@ strcat(outbuffer, " -n"); } - if (strlen(passwd) > 0) { + if (*passwd) { strcat(outbuffer, " -w "); strcat(outbuffer, scrambled_passwd); @@ -610,4 +617,9 @@ } + if (*encoding) { + strcat(outbuffer, " -E "); + strcat(outbuffer, encoding); + } + /* now send the command to the application server */ /* printf("%s\n", outbuffer); */ |
From: Markus H. <mho...@us...> - 2004-01-18 21:19:14
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv28194 Modified Files: refdbdnote.c refdbdref.c Log Message: added character encoding conversion Index: refdbdnote.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdnote.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -U2 -r1.14 -r1.15 --- refdbdnote.c 17 Jan 2004 23:07:41 -0000 1.14 +++ refdbdnote.c 18 Jan 2004 21:19:11 -0000 1.15 @@ -605,4 +605,5 @@ char *quoted_token; char *eostring; + const char* db_encoding; char operator[5]; char the_id[32]; @@ -611,4 +612,5 @@ struct lilimem sentinel; struct renderinfo rendinfo; + iconv_t conv_descriptor; sentinel.ptr_mem = NULL; @@ -690,4 +692,30 @@ driver = dbi_conn_get_driver(conn); + /* get the database encoding */ + db_encoding = dbi_conn_get_encoding(conn); + + /* if we need to convert, create a conversion descriptor for iconv() */ + if (db_encoding && *(ptr_biblio_info->encoding) && strcmp(db_encoding, ptr_biblio_info->encoding)) { + conv_descriptor = iconv_open(!strcmp(ptr_biblio_info->encoding, "US-ASCII") ? "ASCII" : ptr_biblio_info->encoding, !strcmp(db_encoding, "US-ASCII") ? "ASCII" : db_encoding); + if (conv_descriptor == (iconv_t)(-1)) { + LOG_PRINT(LOG_WARNING, "cannot set conversion descriptor"); + iwrite(ptr_clrequest->fd, "cannot set conversion descriptor\n", 33); + delete_all_lilimem(&sentinel); + return 0; + } + else { + LOG_PRINT(LOG_DEBUG, "database encoding is:"); + LOG_PRINT(LOG_DEBUG, db_encoding); + } + } + else { + conv_descriptor = NULL; + LOG_PRINT(LOG_DEBUG, "no character encoding conversion required"); + } + + LOG_PRINT(LOG_DEBUG, "output encoding is:"); + LOG_PRINT(LOG_DEBUG, ptr_biblio_info->encoding); + + token = ptr_clrequest->argument; newtoken = token; @@ -1842,4 +1870,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -1858,4 +1889,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -1871,4 +1905,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -1882,4 +1919,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -1896,4 +1936,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -1914,4 +1957,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -1935,4 +1981,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -1940,4 +1989,71 @@ sql_command = new_sql_command; } + + + /* run a character encoding conversion if required */ + if (conv_descriptor && *sql_command) { + size_t inlength; + size_t outlength; + char* my_sql_command = NULL; /* this ptr will be modified by iconv() */ + char* my_sql_command_start = NULL; /* records initial state of my_elvalue */ + const char* my_instring = NULL; /* this ptr will be modified by iconv() */ + inlength = strlen(sql_command) + 1; + /* with the encodings supported by our database engines, the converted + string can't be longer than three times the input string */ + /* todo: is this assumption correct? */ + outlength = 3*inlength; + + if ((my_sql_command = (char*)malloc(outlength)) == NULL) { + iwrite(ptr_clrequest->fd, outomem_n.text, outomem_n.length); + dbi_result_free(rendinfo.dbires); + dbi_conn_close(conn); + delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } + return 0; + } + + /* keep start of the converted string */ + my_sql_command_start = my_sql_command; + + /* variable will be modified by iconv, so don't use original */ + my_instring = (const char*)sql_command; + + /* now actually do the conversion */ + if (iconv(conv_descriptor, &my_instring, &inlength, &my_sql_command, &outlength) == (size_t)(-1)) { + if (errno == EILSEQ) { + sprintf(sql_command, "iconv: invalid input character sequence\n"); + LOG_PRINT(LOG_WARNING, "iconv: invalid input character sequence"); + } + else if (errno == E2BIG) { + sprintf(sql_command, "iconv: output buffer too small\n"); + LOG_PRINT(LOG_WARNING, "iconv: output buffer too small"); + } + else if (errno == EINVAL) { + sprintf(sql_command, "iconv: incomplete input character\n"); + LOG_PRINT(LOG_WARNING, "iconv: incomplete input character"); + } + + iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); + dbi_result_free(rendinfo.dbires); + dbi_conn_close(conn); + delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } + return 0; + } + /* else: conversion went ok. We free the original string and replace + it with the converted copy */ + if (sql_command) { + free(sql_command); + } + sql_command = my_sql_command_start; + } + /* else: no conversion required */ + + + iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); sql_command[0] = '\0'; @@ -1954,4 +2070,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -1966,4 +2085,8 @@ delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } + return nref_counter; } Index: refdbdref.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdref.c,v retrieving revision 1.52 retrieving revision 1.53 diff -u -U2 -r1.52 -r1.53 --- refdbdref.c 18 Jan 2004 01:01:02 -0000 1.52 +++ refdbdref.c 18 Jan 2004 21:19:11 -0000 1.53 @@ -345,6 +345,4 @@ LOG_PRINT(LOG_DEBUG, "input encoding is:"); LOG_PRINT(LOG_DEBUG, input_encoding); - LOG_PRINT(LOG_DEBUG, "output encoding is:"); - LOG_PRINT(LOG_DEBUG, db_encoding); } } @@ -354,4 +352,7 @@ } + LOG_PRINT(LOG_DEBUG, "database encoding is:"); + LOG_PRINT(LOG_DEBUG, db_encoding); + if (!strcmp(my_dbi_conn_get_cap(conn, "multiple_db"), "f")) { /* pgsql, sqlite need another connection to retrieve values from @@ -615,6 +616,5 @@ } - /* ToDo: run iconv here */ - + /* run a character encoding conversion if required */ if (conv_descriptor && *ris_set) { inlength = strlen(ris_set) + 1; @@ -2093,4 +2093,5 @@ char *quoted_token; char *eostring; + const char* db_encoding; char operator[5]; char the_id[32]; @@ -2099,4 +2100,5 @@ struct lilimem sentinel; struct renderinfo rendinfo; + iconv_t conv_descriptor; sentinel.ptr_mem = NULL; @@ -2197,14 +2199,32 @@ driver = dbi_conn_get_driver(conn); - /* select database */ -/* if (dbi_conn_select_db(conn, ptr_clrequest->current_db) == -1) { */ -/* if (ptr_clrequest->n_cgi) { /\* cgi output *\/ */ -/* iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); */ -/* } */ -/* iwrite(ptr_clrequest->fd, connerr_n.text, connerr_n.length); */ -/* dbi_conn_close(conn); */ -/* delete_all_lilimem(&sentinel); */ -/* return 0; */ -/* } */ + /* get the database encoding */ + db_encoding = dbi_conn_get_encoding(conn); + + /* if we need to convert, create a conversion descriptor for iconv() */ + if (db_encoding && *(ptr_biblio_info->encoding) && strcmp(db_encoding, ptr_biblio_info->encoding)) { + conv_descriptor = iconv_open(!strcmp(ptr_biblio_info->encoding, "US-ASCII") ? "ASCII" : ptr_biblio_info->encoding, !strcmp(db_encoding, "US-ASCII") ? "ASCII" : db_encoding); + if (conv_descriptor == (iconv_t)(-1)) { + LOG_PRINT(LOG_WARNING, "cannot set conversion descriptor"); + if (ptr_clrequest->n_cgi) { /* cgi output */ + iwrite(ptr_clrequest->fd, cgihead_plain.text, cgihead_plain.length); + } + iwrite(ptr_clrequest->fd, "cannot set conversion descriptor\n", 33); + delete_all_lilimem(&sentinel); + return 0; + } + else { + LOG_PRINT(LOG_DEBUG, "database encoding is:"); + LOG_PRINT(LOG_DEBUG, db_encoding); + } + } + else { + conv_descriptor = NULL; + LOG_PRINT(LOG_DEBUG, "no character encoding conversion required"); + } + + LOG_PRINT(LOG_DEBUG, "output encoding is:"); + LOG_PRINT(LOG_DEBUG, ptr_biblio_info->encoding); + token = ptr_clrequest->argument; @@ -2922,4 +2942,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3035,4 +3058,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3656,4 +3682,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3706,4 +3735,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3720,4 +3752,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3734,4 +3769,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3753,4 +3791,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3764,4 +3805,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3821,4 +3865,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3837,4 +3884,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3851,4 +3901,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3868,4 +3921,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3889,4 +3945,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3913,4 +3972,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3918,4 +3980,68 @@ sql_command = new_sql_command; } + + /* run a character encoding conversion if required */ + if (conv_descriptor && *sql_command) { + size_t inlength; + size_t outlength; + char* my_sql_command = NULL; /* this ptr will be modified by iconv() */ + char* my_sql_command_start = NULL; /* records initial state of my_elvalue */ + const char* my_instring = NULL; /* this ptr will be modified by iconv() */ + inlength = strlen(sql_command) + 1; + /* with the encodings supported by our database engines, the converted + string can't be longer than three times the input string */ + /* todo: is this assumption correct? */ + outlength = 3*inlength; + + if ((my_sql_command = (char*)malloc(outlength)) == NULL) { + iwrite(ptr_clrequest->fd, outomem_n.text, outomem_n.length); + dbi_result_free(rendinfo.dbires); + dbi_conn_close(conn); + delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } + return 0; + } + + /* keep start of the converted string */ + my_sql_command_start = my_sql_command; + + /* variable will be modified by iconv, so don't use original */ + my_instring = (const char*)sql_command; + + /* now actually do the conversion */ + if (iconv(conv_descriptor, &my_instring, &inlength, &my_sql_command, &outlength) == (size_t)(-1)) { + if (errno == EILSEQ) { + sprintf(sql_command, "iconv: invalid input character sequence\n"); + LOG_PRINT(LOG_WARNING, "iconv: invalid input character sequence"); + } + else if (errno == E2BIG) { + sprintf(sql_command, "iconv: output buffer too small\n"); + LOG_PRINT(LOG_WARNING, "iconv: output buffer too small"); + } + else if (errno == EINVAL) { + sprintf(sql_command, "iconv: incomplete input character\n"); + LOG_PRINT(LOG_WARNING, "iconv: incomplete input character"); + } + + iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); + dbi_result_free(rendinfo.dbires); + dbi_conn_close(conn); + delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } + return 0; + } + /* else: conversion went ok. We free the original string and replace + it with the converted copy */ + if (sql_command) { + free(sql_command); + } + sql_command = my_sql_command_start; + } + /* else: no conversion required */ + iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); sql_command[0] = '\0'; @@ -3932,4 +4058,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -3944,4 +4073,8 @@ delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } + return nref_counter; } |
From: Markus H. <mho...@us...> - 2004-01-18 21:17:43
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv28035 Modified Files: refdbdbib.c Log Message: added character encoding conversion Index: refdbdbib.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdbib.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -U2 -r1.29 -r1.30 --- refdbdbib.c 3 Jan 2004 20:11:43 -0000 1.29 +++ refdbdbib.c 18 Jan 2004 21:17:37 -0000 1.30 @@ -34,4 +34,5 @@ #include <arpa/inet.h> #include <expat.h> +#include <iconv.h> #include <dbi/dbi.h> @@ -96,5 +97,5 @@ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int getbib(struct CLIENT_REQUEST* ptr_clrequest, struct bibinfo* biblio_info, char *table_name, int n_ref_format, int n_send_stylespec, struct ADDRESULT* ptr_addresult) { +int getbib(struct CLIENT_REQUEST* ptr_clrequest, struct bibinfo* ptr_biblio_info, char *table_name, int n_ref_format, int n_send_stylespec, struct ADDRESULT* ptr_addresult) { XML_Parser p; struct getbib_data gbdata; @@ -156,6 +157,8 @@ const char* item; const char* item1; + const char* db_encoding; struct BIBCONNS bibconns; struct lilimem sentinel; + iconv_t conv_descriptor; sentinel.ptr_mem = NULL; @@ -163,6 +166,6 @@ sentinel.varname[0] = '\0'; - biblio_info->entry_id = NULL; - biblio_info->xreflabel = xreflabel; + ptr_biblio_info->entry_id = NULL; + ptr_biblio_info->xreflabel = xreflabel; bibconns.conn = NULL; /* connection to the default reference database */ @@ -170,5 +173,5 @@ bibconns.conn_source = NULL; /* connection to source reference database */ - nref_counter = biblio_info->n_startnumber - 1; /* numbering starts here */ + nref_counter = ptr_biblio_info->n_startnumber - 1; /* numbering starts here */ sql_command_len = 4096; @@ -254,9 +257,42 @@ } - myjournal = strdup(biblio_info->format_string); + + + /* get the database encoding */ + db_encoding = dbi_conn_get_encoding(bibconns.conn); + + /* if we need to convert, create a conversion descriptor for iconv() */ + if (db_encoding && *(ptr_biblio_info->encoding) && strcmp(db_encoding, ptr_biblio_info->encoding)) { + conv_descriptor = iconv_open(!strcmp(ptr_biblio_info->encoding, "US-ASCII") ? "ASCII" : ptr_biblio_info->encoding, !strcmp(db_encoding, "US-ASCII") ? "ASCII" : db_encoding); + if (conv_descriptor == (iconv_t)(-1)) { + LOG_PRINT(LOG_WARNING, "cannot set conversion descriptor"); + iwrite(ptr_clrequest->fd, "cannot set conversion descriptor\n", 33); + delete_all_lilimem(&sentinel); + close_dbi_connections(&bibconns, drivername); + return 0; + } + else { + LOG_PRINT(LOG_DEBUG, "database encoding is:"); + LOG_PRINT(LOG_DEBUG, db_encoding); + } + } + else { + conv_descriptor = NULL; + LOG_PRINT(LOG_DEBUG, "no character encoding conversion required"); + } + + LOG_PRINT(LOG_DEBUG, "output encoding is:"); + LOG_PRINT(LOG_DEBUG, ptr_biblio_info->encoding); + + + + myjournal = strdup(ptr_biblio_info->format_string); if (!myjournal || insert_lilimem(&sentinel, (void**)&myjournal, NULL)) { LOG_PRINT(LOG_WARNING, outomem.text); delete_all_lilimem(&sentinel); close_dbi_connections(&bibconns, drivername); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -277,4 +313,7 @@ close_dbi_connections(&bibconns, drivername); LOG_PRINT(LOG_WARNING, "could not write to client"); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -289,4 +328,7 @@ close_dbi_connections(&bibconns, drivername); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -294,4 +336,7 @@ close_dbi_connections(&bibconns, drivername); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -301,4 +346,7 @@ close_dbi_connections(&bibconns, drivername); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -307,4 +355,7 @@ close_dbi_connections(&bibconns, drivername); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -379,4 +430,7 @@ close_dbi_connections(&bibconns, drivername); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -398,4 +452,7 @@ close_dbi_connections(&bibconns, drivername); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -425,4 +482,7 @@ close_dbi_connections(&bibconns, drivername); delete_all_lilimem(&sentinel); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -443,4 +503,7 @@ delete_all_lilimem(&sentinel); close_dbi_connections(&bibconns, drivername); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -450,4 +513,7 @@ delete_all_lilimem(&sentinel); close_dbi_connections(&bibconns, drivername); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -460,4 +526,7 @@ delete_all_lilimem(&sentinel); close_dbi_connections(&bibconns, drivername); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -477,4 +546,7 @@ delete_all_lilimem(&sentinel); close_dbi_connections(&bibconns, drivername); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -485,4 +557,7 @@ delete_all_lilimem(&sentinel); close_dbi_connections(&bibconns, drivername); + if (conv_descriptor) { + iconv_close(conv_descriptor); + } return 0; } @@ -520,5 +595,5 @@ /* write doctype line etc */ - prepare_render_dbib(outbuffer, biblio_info, bibconns.conn_refdb, n_ref_format); + prepare_render_dbib(outbuffer, ptr_biblio_info, bibconns.conn_refdb, n_ref_format); bibsequence = dbi_result_get_string(dbires, "BIBLIOSEQUENCE"); @@ -637,5 +712,5 @@ if (!nis_numeric) { /* only useful for author/year style */ - if (fill_in_authoryear_info(&bibconns, dbires, dbires_cit, ptr_clrequest, ptr_addresult, biblio_info, table_name, intext_string, current_mset, &nref_counter)) { + if (fill_in_authoryear_info(&bibconns, dbires, dbires_cit, ptr_clrequest, ptr_addresult, ptr_biblio_info, table_name, intext_string, current_mset, &nref_counter)) { LOG_PRINT(LOG_DEBUG, "fill in author/year info failed"); dbi_result_free(dbires_cit); @@ -769,6 +844,6 @@ } - biblio_info->entry_id = my_dbi_result_get_string_copy(dbires, "entry_id"); - if (!biblio_info->entry_id || !strcmp(biblio_info->entry_id, "ERROR") || insert_lilimem(&sentinel, (void**)&(biblio_info->entry_id), "id_string")) { + ptr_biblio_info->entry_id = my_dbi_result_get_string_copy(dbires, "entry_id"); + if (!ptr_biblio_info->entry_id || !strcmp(ptr_biblio_info->entry_id, "ERROR") || insert_lilimem(&sentinel, (void**)&(ptr_biblio_info->entry_id), "id_string")) { iwrite(ptr_clrequest->fd, "", 1); if (!assemble_return_msg(ptr_addresult, notempselectcolon.text, bibconns.conn)) { @@ -780,5 +855,5 @@ goto Finish; } - biblio_info->year_unique_suffix = dbi_result_get_string(dbires, "year_uni_suffix"); + ptr_biblio_info->year_unique_suffix = dbi_result_get_string(dbires, "year_uni_suffix"); /* compare current string with the string of the previous iteration */ @@ -801,8 +876,8 @@ if (item && *item && prev_authorconcat && *prev_authorconcat && strcmp(item, prev_authorconcat) == 0) { - biblio_info->is_subseq = 1; + ptr_biblio_info->is_subseq = 1; } else { - biblio_info->is_subseq = 0; + ptr_biblio_info->is_subseq = 0; } @@ -817,5 +892,5 @@ item = dbi_result_get_string(dbires, "dbname"); - if ((new_outbuffer = render_dbib(&outbuffer, &outbuffer_len, &bibconns, dbires1 /* reference info */, item /* database */, biblio_info, ptr_clrequest->username, "", nref_counter)) == NULL) { + if ((new_outbuffer = render_dbib(&outbuffer, &outbuffer_len, &bibconns, dbires1 /* reference info */, item /* database */, ptr_biblio_info, ptr_clrequest->username, "", nref_counter)) == NULL) { iwrite(ptr_clrequest->fd, "", 1); nfailed++; @@ -833,4 +908,61 @@ } + /* todo: run iconv here */ + + + /* run a character encoding conversion if required */ + if (conv_descriptor && *outbuffer) { + size_t inlength; + size_t outlength; + char* my_outbuffer = NULL; /* this ptr will be modified by iconv() */ + char* my_outbuffer_start = NULL; /* records initial state of my_elvalue */ + const char* my_instring = NULL; /* this ptr will be modified by iconv() */ + inlength = strlen(outbuffer) + 1; + /* with the encodings supported by our database engines, the converted + string can't be longer than three times the input string */ + /* todo: is this assumption correct? */ + outlength = 3*inlength; + + if ((my_outbuffer = (char*)malloc(outlength)) == NULL) { + iwrite(ptr_clrequest->fd, outomem_n.text, outomem_n.length); + /* dbi_result_free(rendinfo.dbires); */ + dbi_result_free(dbires); + close_dbi_connections(&bibconns, drivername); + goto Finish; + } + + /* keep start of the converted string */ + my_outbuffer_start = my_outbuffer; + + /* variable will be modified by iconv, so don't use original */ + my_instring = (const char*)outbuffer; + + /* now actually do the conversion */ + if (iconv(conv_descriptor, &my_instring, &inlength, &my_outbuffer, &outlength) == (size_t)(-1)) { + if (errno == EILSEQ) { + iwrite(ptr_clrequest->fd, "iconv: invalid input character sequence\n", 40); + LOG_PRINT(LOG_WARNING, "iconv: invalid input character sequence"); + } + else if (errno == E2BIG) { + iwrite(ptr_clrequest->fd, "iconv: output buffer too small\n", 31); + LOG_PRINT(LOG_WARNING, "iconv: output buffer too small"); + } + else if (errno == EINVAL) { + iwrite(ptr_clrequest->fd, "iconv: incomplete input character\n", 34); + LOG_PRINT(LOG_WARNING, "iconv: incomplete input character"); + } + + close_dbi_connections(&bibconns, drivername); + goto Finish; + } + /* else: conversion went ok. We free the original string and replace + it with the converted copy */ + if (outbuffer) { + free(outbuffer); + } + outbuffer = my_outbuffer_start; + } + /* else: no conversion required */ + iwrite(ptr_clrequest->fd, outbuffer, strlen(outbuffer)); outbuffer[0] = '\0'; @@ -847,5 +979,5 @@ } /* end loop over all distinct references */ - if ((new_outbuffer = finish_render_dbib(&outbuffer, &outbuffer_len, &bibconns, biblio_info, table_name, ptr_clrequest)) == NULL) { + if ((new_outbuffer = finish_render_dbib(&outbuffer, &outbuffer_len, &bibconns, ptr_biblio_info, table_name, ptr_clrequest)) == NULL) { iwrite(ptr_clrequest->fd, "", 1); nfailed++; @@ -887,5 +1019,5 @@ Finish: - ptr_addresult->success = nref_counter - biblio_info->n_startnumber + 1; + ptr_addresult->success = nref_counter - ptr_biblio_info->n_startnumber + 1; ptr_addresult->failure = nfailed; numbyte = tread(ptr_clrequest->fd, inbuffer, COMMAND_INBUF_LEN); @@ -899,4 +1031,8 @@ } + if (conv_descriptor) { + iconv_close(conv_descriptor); + } + return (nfailed) ? 1:0; } |
From: Markus H. <mho...@us...> - 2004-01-18 21:15:34
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv27697 Modified Files: refdbd.c Log Message: set biblio_info.encoding for getbib() and gettexbib() Index: refdbd.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbd.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -U2 -r1.66 -r1.67 --- refdbd.c 18 Jan 2004 00:59:05 -0000 1.66 +++ refdbd.c 18 Jan 2004 21:15:31 -0000 1.67 @@ -1588,4 +1588,6 @@ /*********************************************** getbib ****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "getbib") == 0) { + biblio_info.encoding = db_encoding; + /* generate a pseudo-unique table name consisting of the process id and the current time */ @@ -1618,4 +1620,6 @@ /*********************************************** gettexbib ****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "gettexbib") == 0) { + biblio_info.encoding = db_encoding; + result = gettexbib(ptr_child_clrequest, &biblio_info, &addresult); /* let the client know what happened */ |
From: Markus H. <mho...@us...> - 2004-01-18 01:01:16
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv12453 Modified Files: refdbdref.c Log Message: do character conversion for RIS data if required Index: refdbdref.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdref.c,v retrieving revision 1.51 retrieving revision 1.52 diff -u -U2 -r1.51 -r1.52 --- refdbdref.c 17 Jan 2004 23:07:41 -0000 1.51 +++ refdbdref.c 18 Jan 2004 01:01:02 -0000 1.52 @@ -336,12 +336,14 @@ /* if we need to convert, create a conversion descriptor for iconv() */ - if (db_encoding && strcmp(db_encoding, "UTF-8")) { - ardata.conv_descriptor = iconv_open(!strcmp(db_encoding, "US-ASCII") ? "ASCII" : db_encoding, "UTF-8"); + if (db_encoding && strcmp(db_encoding, !strcmp(reftype, "risx") ? "UTF-8" : input_encoding)) { + ardata.conv_descriptor = iconv_open(!strcmp(db_encoding, "US-ASCII") ? "ASCII" : db_encoding, !strcmp(reftype, "risx") ? "UTF-8" : input_encoding); if (ardata.conv_descriptor == (iconv_t)(-1)) { ardata.conv_descriptor = NULL; - LOG_PRINT(LOG_WARNING, "cannot set output encoding"); + LOG_PRINT(LOG_WARNING, "cannot set conversion descriptor"); } else { - LOG_PRINT(LOG_DEBUG, "encoding is now:"); + LOG_PRINT(LOG_DEBUG, "input encoding is:"); + LOG_PRINT(LOG_DEBUG, input_encoding); + LOG_PRINT(LOG_DEBUG, "output encoding is:"); LOG_PRINT(LOG_DEBUG, db_encoding); } @@ -349,5 +351,5 @@ else { ardata.conv_descriptor = NULL; - LOG_PRINT(LOG_DEBUG, "encoding is UTF-8, no conversion required"); + LOG_PRINT(LOG_DEBUG, "no character encoding conversion required"); } @@ -590,4 +592,10 @@ /* read the data proper unless size was zero (= end of transmission) */ if (n_requested_bufsize) { + size_t inlength; + size_t outlength; + char* my_ris_set = NULL; /* this ptr will be modified by iconv() */ + char* my_ris_set_start = NULL; /* records initial state of my_elvalue */ + const char* my_instring = NULL; /* this ptr will be modified by iconv() */ + /* acknowledge that we have a buffer ready, let them data come... */ numbyte = iwrite(ptr_clrequest->fd, positive.text, positive.length+1); @@ -609,4 +617,60 @@ /* ToDo: run iconv here */ + if (conv_descriptor && *ris_set) { + inlength = strlen(ris_set) + 1; + /* with the encodings supported by our database engines, the converted + string can't be longer than the input string */ + outlength = inlength; + + if ((my_ris_set = (char*)malloc(outlength)) == NULL) { + ptr_addresult->failure++; + sprintf(return_msg, "out of memory\n"); + LOG_PRINT(LOG_WARNING, "failed processing dataset"); + numbyte = iwrite(ptr_clrequest->fd, return_msg, strlen(return_msg)+1); + if (numbyte == -1) { + LOG_PRINT(LOG_INFO, "timeout while writing"); + free(ris_set); + return 0; + } + } + + /* keep start of the converted string */ + my_ris_set_start = my_ris_set; + + /* variable will be modified by iconv, so don't use original */ + my_instring = (const char*)ris_set; + + /* now actually do the conversion */ + if (iconv(conv_descriptor, &my_instring, &inlength, &my_ris_set, &outlength) == (size_t)(-1)) { + if (errno == EILSEQ) { + sprintf(return_msg, "iconv: invalid input character sequence\n"); + LOG_PRINT(LOG_WARNING, "iconv: invalid input character sequence"); + } + else if (errno == E2BIG) { + sprintf(return_msg, "iconv: output buffer too small\n"); + LOG_PRINT(LOG_WARNING, "iconv: output buffer too small"); + } + else if (errno == EINVAL) { + sprintf(return_msg, "iconv: incomplete input character\n"); + LOG_PRINT(LOG_WARNING, "iconv: incomplete input character"); + } + + numbyte = iwrite(ptr_clrequest->fd, return_msg, strlen(return_msg)+1); + if (numbyte == -1) { + LOG_PRINT(LOG_INFO, "timeout while writing"); + free(ris_set); + return 0; + } + return 0; + } + /* else: conversion went ok. We free the original string and replace + it with the converted copy */ + if (ris_set) { + free(ris_set); + } + ris_set = my_ris_set_start; + } + /* else: no conversion required */ + /* split reference into lines and squeeze contents into database */ result = process_ris_set(ris_set, conn, conn_refdb, replace_ref, (char*)the_user, ptr_clrequest, n_keep_id, ptr_sentinel); |
From: Markus H. <mho...@us...> - 2004-01-18 00:59:11
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv12097 Modified Files: refdbd.c Log Message: UTF-8 is now default encoding Index: refdbd.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbd.c,v retrieving revision 1.65 retrieving revision 1.66 diff -u -U2 -r1.65 -r1.66 --- refdbd.c 17 Jan 2004 23:04:23 -0000 1.65 +++ refdbd.c 18 Jan 2004 00:59:05 -0000 1.66 @@ -108,5 +108,5 @@ char keep_pnames[PREFS_BUF_LEN] = ""; /* whether to keep periodical names */ char upper_citekey[PREFS_BUF_LEN] = ""; /* whether to uppercase citation keys */ -char default_db_encoding[PREFS_BUF_LEN] = ""; /* default char encoding for new databases */ +char default_db_encoding[PREFS_BUF_LEN] = "UTF-8"; /* default char encoding for new databases */ char keyword_scan[PREFS_BUF_LEN] = ""; /* run automatic keyword scan if 't' */ @@ -1244,4 +1244,7 @@ /*********************************************** addref ****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "addref") == 0) { + if (!*db_encoding) { + strcpy(db_encoding, default_db_encoding); + } result = addref(ptr_child_clrequest, set_owner, &addresult, 0, n_keep_id, format_string, &id_sentinel, db_encoding); @@ -1274,4 +1277,7 @@ /*********************************************** updateref ****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "updateref") == 0) { + if (!*db_encoding) { + strcpy(db_encoding, default_db_encoding); + } result = addref(ptr_child_clrequest, set_owner, &addresult, n_personal, n_keep_id, format_string, &id_sentinel, db_encoding); @@ -1452,4 +1458,7 @@ /*********************************************** addnote ****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "addnote") == 0) { + if (!*db_encoding) { + strcpy(db_encoding, default_db_encoding); + } result = addnote(ptr_child_clrequest, set_owner, &addresult, 0, &id_sentinel, db_encoding); @@ -1460,4 +1469,7 @@ /*********************************************** updatenote ****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "updatenote") == 0) { + if (!*db_encoding) { + strcpy(db_encoding, default_db_encoding); + } result = addnote(ptr_child_clrequest, set_owner, &addresult, 1, &id_sentinel, db_encoding); |
From: Markus H. <mho...@us...> - 2004-01-18 00:55:10
|
Update of /cvsroot/refdb/refdb In directory sc8-pr-cvs1:/tmp/cvs-serv11547 Modified Files: configure.in Log Message: added test for libiconv Index: configure.in =================================================================== RCS file: /cvsroot/refdb/refdb/configure.in,v retrieving revision 1.42 retrieving revision 1.43 diff -u -U2 -r1.42 -r1.43 --- configure.in 6 Jan 2004 21:23:17 -0000 1.42 +++ configure.in 18 Jan 2004 00:55:06 -0000 1.43 @@ -207,4 +207,7 @@ AC_SEARCH_LIBS_VAR(compress, z, , , , refdbd_LDADD) +dnl need character encoding support +AC_SEARCH_LIBS_VAR(iconv, iconv, , , , refdbd_LDADD) + fi dnl end if build server |
From: Markus H. <mho...@us...> - 2004-01-17 23:07:44
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv25105 Modified Files: refdbdnote.c refdbdref.c Log Message: retrieve database encoding for XML import Index: refdbdnote.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdnote.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -U2 -r1.13 -r1.14 --- refdbdnote.c 4 Jan 2004 01:57:31 -0000 1.13 +++ refdbdnote.c 17 Jan 2004 23:07:41 -0000 1.14 @@ -25,4 +25,5 @@ #include <dbi/dbi.h> #include <expat.h> /* the xml parser header file */ +#include <iconv.h> #include "refdb.h" @@ -68,6 +69,8 @@ added ID values + char* input_encoding encoding of the input data + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int addnote(struct CLIENT_REQUEST* ptr_clrequest, char* set_owner, struct ADDRESULT* ptr_addresult, int replace_note, Lilid* ptr_sentinel) { +int addnote(struct CLIENT_REQUEST* ptr_clrequest, char* set_owner, struct ADDRESULT* ptr_addresult, int replace_note, Lilid* ptr_sentinel, char* input_encoding) { dbi_conn conn; dbi_conn conn_refdb = NULL; @@ -79,4 +82,5 @@ char *the_user; /* name (either set_owner or username) */ char *return_msg; /* string to hold a return message for the client */ + const char *db_encoding; /* encoding of database */ const char *drivername; /* name of the libdbi driver */ char old_db[DBNAME_LENGTH+1]; @@ -119,4 +123,24 @@ } + /* get the database encoding */ + db_encoding = dbi_conn_get_encoding(conn); + + /* if we need to convert, create a conversion descriptor for iconv() */ + if (db_encoding && strcmp(db_encoding, "UTF-8")) { + andata.conv_descriptor = iconv_open(!strcmp(db_encoding, "US-ASCII") ? "ASCII" : db_encoding, "UTF-8"); + if (andata.conv_descriptor == (iconv_t)(-1)) { + andata.conv_descriptor = NULL; + LOG_PRINT(LOG_WARNING, "cannot set output encoding"); + } + else { + LOG_PRINT(LOG_DEBUG, "encoding is now:"); + LOG_PRINT(LOG_DEBUG, db_encoding); + } + } + else { + andata.conv_descriptor = NULL; + LOG_PRINT(LOG_DEBUG, "encoding is UTF-8, no conversion required"); + } + while (1) { /* leave with break */ /* create the parser instance */ @@ -217,4 +241,8 @@ delete_all_lilimem(&sentinel); + if (andata.conv_descriptor) { + iconv_close(andata.conv_descriptor); + } + return success; } Index: refdbdref.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdref.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -U2 -r1.50 -r1.51 --- refdbdref.c 10 Jan 2004 01:26:39 -0000 1.50 +++ refdbdref.c 17 Jan 2004 23:07:41 -0000 1.51 @@ -27,4 +27,5 @@ #include <time.h> #include <expat.h> /* the xml parser header file */ +#include <iconv.h> #include <dbi/dbi.h> @@ -59,5 +60,5 @@ /* forward declaration of local functions */ -static unsigned long long read_ris_data(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult, dbi_conn conn, dbi_conn conn_refdb, int replace_ref, int n_keep_id, const char* the_user, Lilid* ptr_sentinel); +static unsigned long long read_ris_data(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult, dbi_conn conn, dbi_conn conn_refdb, int replace_ref, int n_keep_id, const char* the_user, Lilid* ptr_sentinel, iconv_t conv_descriptor); static int real_run_keyword_scan(struct CLIENT_REQUEST* ptr_clrequest, Lilid* ptr_sentinel, int mode, int* ptr_insert); @@ -270,6 +271,8 @@ added ID values + char* input_encoding encoding of the input data + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -int addref(struct CLIENT_REQUEST* ptr_clrequest, char* set_owner, struct ADDRESULT* ptr_addresult, int replace_ref, int n_keep_id, const char* reftype, Lilid* ptr_sentinel) { +int addref(struct CLIENT_REQUEST* ptr_clrequest, char* set_owner, struct ADDRESULT* ptr_addresult, int replace_ref, int n_keep_id, const char* reftype, Lilid* ptr_sentinel, char* input_encoding) { dbi_conn conn; dbi_conn conn_refdb = NULL; @@ -281,4 +284,5 @@ char *the_user; /* name (either set_owner or username) */ char *return_msg; /* string to hold a return message for the client */ + const char *db_encoding; /* encoding of database */ const char *drivername; /* name of the libdbi driver */ char old_db[DBNAME_LENGTH+1]; @@ -328,4 +332,24 @@ } + /* get the database encoding */ + db_encoding = dbi_conn_get_encoding(conn); + + /* if we need to convert, create a conversion descriptor for iconv() */ + if (db_encoding && strcmp(db_encoding, "UTF-8")) { + ardata.conv_descriptor = iconv_open(!strcmp(db_encoding, "US-ASCII") ? "ASCII" : db_encoding, "UTF-8"); + if (ardata.conv_descriptor == (iconv_t)(-1)) { + ardata.conv_descriptor = NULL; + LOG_PRINT(LOG_WARNING, "cannot set output encoding"); + } + else { + LOG_PRINT(LOG_DEBUG, "encoding is now:"); + LOG_PRINT(LOG_DEBUG, db_encoding); + } + } + else { + ardata.conv_descriptor = NULL; + LOG_PRINT(LOG_DEBUG, "encoding is UTF-8, no conversion required"); + } + if (!strcmp(my_dbi_conn_get_cap(conn, "multiple_db"), "f")) { /* pgsql, sqlite need another connection to retrieve values from @@ -341,4 +365,7 @@ dbi_conn_close(conn); delete_all_lilimem(&sentinel); + if (ardata.conv_descriptor) { + iconv_close(ardata.conv_descriptor); + } LOG_PRINT(LOG_ERR, connerr.text); return 0; @@ -450,5 +477,5 @@ } - ullresult = read_ris_data(ptr_clrequest, ptr_addresult, conn, conn_refdb, replace_ref, n_keep_id, the_user, ptr_sentinel); + ullresult = read_ris_data(ptr_clrequest, ptr_addresult, conn, conn_refdb, replace_ref, n_keep_id, the_user, ptr_sentinel, ardata.conv_descriptor); } @@ -466,4 +493,8 @@ free_authorinfo(ardata.ptr_ainfo); + if (ardata.conv_descriptor) { + iconv_close(ardata.conv_descriptor); + } + return success; } @@ -496,6 +527,8 @@ added ID values + iconv_t conv_descriptor conversion descriptor for iconv() + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -static unsigned long long read_ris_data(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult, dbi_conn conn, dbi_conn conn_refdb, int replace_ref, int n_keep_id, const char* the_user, Lilid* ptr_sentinel) { +static unsigned long long read_ris_data(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult, dbi_conn conn, dbi_conn conn_refdb, int replace_ref, int n_keep_id, const char* the_user, Lilid* ptr_sentinel, iconv_t conv_descriptor) { int numbyte; int success = 1; /* be optimistic */ @@ -574,4 +607,6 @@ } + /* ToDo: run iconv here */ + /* split reference into lines and squeeze contents into database */ result = process_ris_set(ris_set, conn, conn_refdb, replace_ref, (char*)the_user, ptr_clrequest, n_keep_id, ptr_sentinel); |
From: Markus H. <mho...@us...> - 2004-01-17 23:06:01
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv24814 Modified Files: refdbda.c Log Message: getfoo(): new encoding argument Index: refdbda.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbda.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -U2 -r1.37 -r1.38 --- refdbda.c 3 Jan 2004 20:11:43 -0000 1.37 +++ refdbda.c 17 Jan 2004 23:05:57 -0000 1.38 @@ -1631,6 +1631,8 @@ int all if 1, return all synonyms of a journal name query + char* db_encoding output encoding + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -void getfoo(struct CLIENT_REQUEST* ptr_clrequest, int type, int all) { +void getfoo(struct CLIENT_REQUEST* ptr_clrequest, int type, int all, char* db_encoding) { dbi_conn conn; dbi_result dbires; |
From: Markus H. <mho...@us...> - 2004-01-17 23:04:26
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv24567 Modified Files: refdbd.c refdbd.h.in Log Message: pass encoding to addref(), addnote(), getfoo() Index: refdbd.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbd.c,v retrieving revision 1.64 retrieving revision 1.65 diff -u -U2 -r1.64 -r1.65 --- refdbd.c 4 Jan 2004 16:00:52 -0000 1.64 +++ refdbd.c 17 Jan 2004 23:04:23 -0000 1.65 @@ -1244,5 +1244,5 @@ /*********************************************** addref ****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "addref") == 0) { - result = addref(ptr_child_clrequest, set_owner, &addresult, 0, n_keep_id, format_string, &id_sentinel); + result = addref(ptr_child_clrequest, set_owner, &addresult, 0, n_keep_id, format_string, &id_sentinel, db_encoding); /* let the client know what happened */ @@ -1274,5 +1274,5 @@ /*********************************************** updateref ****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "updateref") == 0) { - result = addref(ptr_child_clrequest, set_owner, &addresult, n_personal, n_keep_id, format_string, &id_sentinel); + result = addref(ptr_child_clrequest, set_owner, &addresult, n_personal, n_keep_id, format_string, &id_sentinel, db_encoding); /* let the client know what happened */ @@ -1452,5 +1452,5 @@ /*********************************************** addnote ****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "addnote") == 0) { - result = addnote(ptr_child_clrequest, set_owner, &addresult, 0, &id_sentinel); + result = addnote(ptr_child_clrequest, set_owner, &addresult, 0, &id_sentinel, db_encoding); /* let the client know what happened */ @@ -1460,5 +1460,5 @@ /*********************************************** updatenote ****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "updatenote") == 0) { - result = addnote(ptr_child_clrequest, set_owner, &addresult, 1, &id_sentinel); + result = addnote(ptr_child_clrequest, set_owner, &addresult, 1, &id_sentinel, db_encoding); /* let the client know what happened */ @@ -1526,40 +1526,40 @@ /*********************************************** getau *****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "getau") == 0) { - getfoo(ptr_child_clrequest, 0, 0); + getfoo(ptr_child_clrequest, 0, 0, db_encoding); } /*********************************************** geted *****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "geted") == 0) { - getfoo(ptr_child_clrequest, 6, 0); + getfoo(ptr_child_clrequest, 6, 0, db_encoding); } /*********************************************** getas *****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "getas") == 0) { - getfoo(ptr_child_clrequest, 7, 0); + getfoo(ptr_child_clrequest, 7, 0, db_encoding); } /*********************************************** getkw *****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "getkw") == 0) { - getfoo(ptr_child_clrequest, 1, 0); + getfoo(ptr_child_clrequest, 1, 0, db_encoding); } /*********************************************** getjo *****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "getjo") == 0) { - getfoo(ptr_child_clrequest, 2, n_all); + getfoo(ptr_child_clrequest, 2, n_all, db_encoding); } /*********************************************** getjf *****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "getjf") == 0) { - getfoo(ptr_child_clrequest, 3, n_all); + getfoo(ptr_child_clrequest, 3, n_all, db_encoding); } /*********************************************** getj1 *****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "getj1") == 0) { - getfoo(ptr_child_clrequest, 4, n_all); + getfoo(ptr_child_clrequest, 4, n_all, db_encoding); } /*********************************************** getj2 *****/ else if (strcmp((ptr_child_clrequest->inargv)[0], "getj2") == 0) { - getfoo(ptr_child_clrequest, 5, n_all); + getfoo(ptr_child_clrequest, 5, n_all, db_encoding); } Index: refdbd.h.in =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbd.h.in,v retrieving revision 1.4 retrieving revision 1.5 diff -u -U2 -r1.4 -r1.5 --- refdbd.h.in 28 Dec 2003 23:42:05 -0000 1.4 +++ refdbd.h.in 17 Jan 2004 23:04:23 -0000 1.5 @@ -106,5 +106,5 @@ void child_confserv(struct CLIENT_REQUEST* ptr_clrequest); void confserv(char *command, char *server_ip); -int addref(struct CLIENT_REQUEST* ptr_clrequest, char* set_owner, struct ADDRESULT* ptr_addresult, int replace_ref, int n_keep_id, const char* reftype, Lilid* ptr_sentinel); +int addref(struct CLIENT_REQUEST* ptr_clrequest, char* set_owner, struct ADDRESULT* ptr_addresult, int replace_ref, int n_keep_id, const char* reftype, Lilid* ptr_sentinel, char* input_encoding); int deleteref(struct CLIENT_REQUEST* ptr_clrequest, struct DELRESULT* ptr_delresult); unsigned long long getref(struct CLIENT_REQUEST* ptr_clrequest, struct bibinfo* ptr_biblio_info, int ref_format, int n_privatelist, char *pdfroot, char *cgi_url); @@ -112,5 +112,5 @@ int adduser(struct CLIENT_REQUEST* ptr_clrequest, char *user_host, char* newuser_passwd, int n_remove); int addword(struct CLIENT_REQUEST* ptr_clrequest, int n_remove); -void getfoo(struct CLIENT_REQUEST* ptr_clrequest, int type, int all); +void getfoo(struct CLIENT_REQUEST* ptr_clrequest, int type, int all, char* input_encoding); int getbib(struct CLIENT_REQUEST* ptr_clrequest, struct bibinfo* ptr_biblio_info, char *table_name, int n_ref_format, int n_send_stylespec, struct ADDRESULT* ptr_addresult); char* getid(char* idstring, char** db, int* type); @@ -122,5 +122,5 @@ int is_refdb_admin(struct CLIENT_REQUEST* ptr_clrequest); int run_keyword_scan(struct CLIENT_REQUEST* ptr_clrequest, Lilid* ptr_sentinel, int mode); -int addnote(struct CLIENT_REQUEST* ptr_clrequest, char* set_owner, struct ADDRESULT* ptr_addresult, int replace_note, Lilid* ptr_sentinel); +int addnote(struct CLIENT_REQUEST* ptr_clrequest, char* set_owner, struct ADDRESULT* ptr_addresult, int replace_note, Lilid* ptr_sentinel, char* input_encoding); int deletenote(struct CLIENT_REQUEST* ptr_clrequest, struct DELRESULT* ptr_delresult); unsigned long long getnote(struct CLIENT_REQUEST* ptr_clrequest, struct bibinfo *ptr_biblio_info, int ref_format, int n_privatelist, char *cgi_url); |
From: Markus H. <mho...@us...> - 2004-01-17 22:56:19
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv22892 Modified Files: refdbc.c Log Message: distinguish toencoding and fromencoding; move E option to individual commands; pass encoding to server in addref/addnote;fixed addnote help string Index: refdbc.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbc.c,v retrieving revision 1.61 retrieving revision 1.62 diff -u -U2 -r1.61 -r1.62 --- refdbc.c 28 Dec 2003 21:35:13 -0000 1.61 +++ refdbc.c 17 Jan 2004 22:56:16 -0000 1.62 @@ -104,5 +104,5 @@ /*+ this array will hold the user preferences +*/ -Prefs prefs[20] = { +Prefs prefs[21] = { {"serverip", ""}, {"port", ""}, @@ -123,5 +123,6 @@ {"refdblib", ""}, {"reftype", ""}, - {"encoding", ""}, + {"toencoding", ""}, + {"fromencoding", ""}, {"", ""} }; @@ -145,5 +146,6 @@ char refdblib[PREFS_BUF_LEN] = ""; /*+ path to shareable files +*/ char current_db[PREFS_BUF_LEN] = ""; -char encoding[PREFS_BUF_LEN] = ""; /*+ encoding for output +*/ +char fromencoding[PREFS_BUF_LEN] = ""; /*+ encoding of input +*/ +char toencoding[PREFS_BUF_LEN] = ""; /*+ encoding for output +*/ char reftype[PREFS_BUF_LEN] = "ris"; /* input data type (ris|risx) */ char confdir[_POSIX_PATH_MAX] = ""; /* path to the config files */ @@ -320,5 +322,6 @@ prefs[16].varvalue = refdblib; prefs[17].varvalue = reftype; - prefs[18].varvalue = encoding; + prefs[18].varvalue = toencoding; + prefs[19].varvalue = fromencoding; /* look for custom config directory */ @@ -365,8 +368,4 @@ log_dest[PREFS_BUF_LEN-1] = '\0'; break; - case 'E': - strncpy(encoding, optarg, PREFS_BUF_LEN); - encoding[PREFS_BUF_LEN-1] = '\0'; - break; case 'F': strncpy(default_fields, optarg, PREFS_BUF_LEN); @@ -433,4 +432,5 @@ /* now all the options that the commands will take care of */ case 'a': /* fall through, we assemble the command string */ + case 'E': case 'f': case 'k': @@ -1698,4 +1698,5 @@ char db[DBNAME_LENGTH] = ""; char pdf_root[_POSIX_PATH_MAX] = ""; + char my_toencoding[PREFS_BUF_LEN] = ""; char type_string[10] = ""; char **inargv; /* tokens of the argument */ @@ -1742,4 +1743,5 @@ strcpy(db, current_db); /* use default db if set */ + strcpy(my_toencoding, toencoding); /* use default encoding if set */ if (n_cgi) { @@ -1991,4 +1993,8 @@ db[_POSIX_PATH_MAX-1] = '\0'; /* terminate in case string got truncated */ break; + case 'E': + strncpy(my_toencoding, optarg, PREFS_BUF_LEN); + my_toencoding[PREFS_BUF_LEN-1] = '\0'; + break; case 'f': /* printf("-f %s\n", optarg); */ @@ -2054,5 +2060,4 @@ case 'C': /* fall through */ case 'e': - case 'E': case 'F': case 'g': @@ -2202,7 +2207,7 @@ } - if (*encoding) { + if (*my_toencoding) { strcat(slvals.outbuffer, " -E "); - strcat(slvals.outbuffer, encoding); + strcat(slvals.outbuffer, my_toencoding); } @@ -2355,4 +2360,5 @@ char inbuffer[COMMAND_INBUF_LEN] = ""; char db[_POSIX_PATH_MAX] = ""; + char my_toencoding[PREFS_BUF_LEN] = ""; char **inargv; /* tokens of the argument */ char *newarg; @@ -2375,4 +2381,5 @@ strcpy(db, current_db); /* use default db if set */ + strcpy(my_toencoding, toencoding); /* used default encoding if set */ slvals.outbuffer = outbuffer; @@ -2567,4 +2574,8 @@ strcpy(db, optarg); /* override preset db */ break; + case 'E': + strncpy(my_toencoding, optarg, PREFS_BUF_LEN); + my_toencoding[PREFS_BUF_LEN-1] = '\0'; + break; case 'h': if (type == 0 || type == 6 | type == 7) { @@ -2602,5 +2613,4 @@ case 'C': case 'e': /* fall through - nothing to do */ - case 'E': case 'f': case 'F': @@ -2687,8 +2697,14 @@ strcat(slvals.outbuffer, " -u "); strcat(slvals.outbuffer, username); - if (strlen(passwd) > 0) { + if (*passwd) { strcat(slvals.outbuffer, " -w "); strcat(slvals.outbuffer, scrambled_passwd); } + + if (*my_toencoding) { + strcat(slvals.outbuffer, " -E "); + strcat(slvals.outbuffer, my_toencoding); + } + strcat(slvals.outbuffer, " -d "); strcat(slvals.outbuffer, db); @@ -2719,18 +2735,19 @@ { int n_sockfd; /* file descriptor of the socket */ - char *outbuffer = NULL; - char *inbuffer = NULL; char srv_inbuffer[COMMAND_INBUF_LEN] = ""; - char *ris_set_buffer = NULL; + char my_fromencoding[PREFS_BUF_LEN] = ""; + char outtype[10] = ""; /* output type for server response */ + char scrambled_passwd[PASSWD_LENGTH*3+1] = ""; + char db[_POSIX_PATH_MAX+1] = ""; /* the database name */ + char outfile[_POSIX_PATH_MAX+1] = ""; /* output filename */ + char my_reftype[PREFS_BUF_LEN]; /* input data type (ris|risx) */ char thebytes[11] = ""; - char **inargv; /* tokens of the argument */ char set_owner[32] = ""; + char *ris_set_buffer = NULL; + char **inargv; /* tokens of the argument */ char *newarg = NULL; - char db[_POSIX_PATH_MAX+1] = ""; /* the database name */ - char outfile[_POSIX_PATH_MAX+1] = ""; /* output filename */ + char *outbuffer = NULL; + char *inbuffer = NULL; char *outpipe = NULL; - char outtype[10] = ""; /* output type for server response */ - char scrambled_passwd[PASSWD_LENGTH*3+1] = ""; - char my_reftype[PREFS_BUF_LEN]; /* input data type (ris|risx) */ int numbyte; int n_result; @@ -2767,4 +2784,5 @@ strcpy(db, current_db); /* use default db if set */ strcpy(my_reftype, reftype); + strcpy(my_fromencoding, fromencoding); /* use default encoding if set */ if (n_cgi) { @@ -2856,4 +2874,8 @@ db[PREFS_BUF_LEN-1] = '\0'; break; + case 'E': + strncpy(my_fromencoding, optarg, PREFS_BUF_LEN); + my_fromencoding[PREFS_BUF_LEN-1] = '\0'; + break; case 'f': /* printf("-f %s\n", optarg); */ @@ -2894,5 +2916,4 @@ case 'C': /* fall through - nothing to do */ case 'e': - case 'E': case 'F': case 'g': @@ -2947,4 +2968,8 @@ strcpy(db, optarg); /* override preset db */ break; + case 'E': + strncpy(my_fromencoding, optarg, PREFS_BUF_LEN); + my_fromencoding[PREFS_BUF_LEN-1] = '\0'; + break; case 'f': /* printf("-f %s\n", optarg); */ @@ -2985,5 +3010,4 @@ case 'C': /* fall through - nothing to do */ case 'e': - case 'E': case 'F': case 'g': @@ -3087,5 +3111,5 @@ strcat(outbuffer, " -u "); strcat(outbuffer, username); - if (strlen(passwd) > 0) { + if (*passwd) { strcat(outbuffer, " -w "); strcat(outbuffer, scrambled_passwd); @@ -3097,9 +3121,14 @@ strcat(outbuffer, my_reftype); - if (set_owner[0]) { + if (*set_owner) { strcat(outbuffer, " -U "); strcat(outbuffer, set_owner); } + if (*my_fromencoding) { + strcat(outbuffer, " -E "); + strcat(outbuffer, my_fromencoding); + } + if (n_personal) { strcat(outbuffer, " -p"); @@ -3401,18 +3430,19 @@ { int n_sockfd; /* file descriptor of the socket */ - char *outbuffer = NULL; - char *inbuffer = NULL; char srv_inbuffer[COMMAND_INBUF_LEN] = ""; - char *ris_set_buffer = NULL; char thebytes[11] = ""; - char **inargv; /* tokens of the argument */ char set_owner[32] = ""; - char *newarg = NULL; char db[_POSIX_PATH_MAX+1] = ""; /* the database name */ char outfile[_POSIX_PATH_MAX+1] = ""; /* output filename */ - char *outpipe = NULL; char outtype[10] = ""; /* output type for server response */ char scrambled_passwd[PASSWD_LENGTH*3+1] = ""; char my_reftype[PREFS_BUF_LEN]; /* input data type (ris|risx) */ + char my_fromencoding[PREFS_BUF_LEN] = ""; + char *outbuffer = NULL; + char *inbuffer = NULL; + char *ris_set_buffer = NULL; + char **inargv; /* tokens of the argument */ + char *newarg = NULL; + char *outpipe = NULL; int numbyte; int n_result; @@ -3420,5 +3450,4 @@ int n_read_done = 0; size_t n_setlength; -/* int n_ris_file_done = 0; */ int n_setcount = 0; int inargc = 0; /* number of tokens of the argument */ @@ -3449,5 +3478,5 @@ strcpy(db, current_db); /* use default db if set */ strcpy(my_reftype, reftype); - + strcpy(my_fromencoding, fromencoding); /* use default encoding if set */ /* parse the argument. first we cut the argument into pieces with strtok, then we use getopt to interpret */ @@ -3521,4 +3550,8 @@ db[PREFS_BUF_LEN-1] = '\0'; break; + case 'E': + strncpy(my_fromencoding, optarg, PREFS_BUF_LEN); + my_fromencoding[PREFS_BUF_LEN-1] = '\0'; + break; case 'f': /* printf("-f %s\n", optarg); */ @@ -3529,5 +3562,5 @@ case 'h': delete_all_lilimem(&sentinel); - fprintf(errstream, "Replaces the specified notes in the database\nSyntax: updateref [-c command] [-d database] [-h] [-o outfile] [-O outfile] [-P] [-t type] [-U username] {file|-f infile}\nOptions: -c command pipe the output through command\n -d database specify the database to work with\n -f infile Read the names of the files with the references from file infile\n -g deffile read global fields from file deffile\n -h prints this mini-help\n -o outfile save the output in outfile (overwrite)\n -O outfile append the output to outfile\n -P update only personal information (AV, N1, RP)\n -t input data type (ris|risx), ris is default\n -U username specify a different username than the current user\n All other arguments are interpreted as filenames.\n"); + fprintf(errstream, "Replaces the specified notes in the database\nSyntax: updatenote [-c command] [-d database] [-h] [-o outfile] [-O outfile] [-P] [-t type] [-U username] {file|-f infile}\nOptions: -c command pipe the output through command\n -d database specify the database to work with\n -f infile Read the names of the files with the notes from file infile\n -g deffile read global fields from file deffile\n -h prints this mini-help\n -o outfile save the output in outfile (overwrite)\n -O outfile append the output to outfile\n -U username specify a different username than the current user\n All other arguments are interpreted as filenames.\n"); return 0; break; @@ -3544,7 +3577,4 @@ n_file_append = 1; break; - case 'P': - n_personal = 1; - break; case 't': strncpy(my_reftype, optarg, PREFS_BUF_LEN - 1); @@ -3559,5 +3589,4 @@ case 'C': /* fall through - nothing to do */ case 'e': - case 'E': case 'F': case 'g': @@ -3569,4 +3598,5 @@ case 'p': case 'q': + case 'P': case 'r': case 'R': @@ -3612,4 +3642,8 @@ strcpy(db, optarg); /* override preset db */ break; + case 'E': + strncpy(my_fromencoding, optarg, PREFS_BUF_LEN); + my_fromencoding[PREFS_BUF_LEN-1] = '\0'; + break; case 'f': /* printf("-f %s\n", optarg); */ @@ -3620,5 +3654,5 @@ case 'h': delete_all_lilimem(&sentinel); - fprintf(errstream, "Adds the specified notes to the database\nSyntax: addref [-c command] [-d database] [-g deffile] [-h] [-k] [-o outfile] [-O outfile] [-U username] {file|-f infile}\nOptions: -c command pipe the output through command\n -d database specify the database to work with\n -f infile Read the names of the files with the references from file infile\n -g deffile read global fields from file deffile\n -h prints this mini-help\n -k keep reference ID\n -o outfile save the output in outfile (overwrite)\n -O outfile append the output to outfile\n -t input data type (ris|risx), ris is default\n -U username specify a different username than the current user\n All other arguments are interpreted as filenames.\n"); + fprintf(errstream, "Adds the specified notes to the database\nSyntax: addnote [-c command] [-d database] [-g deffile] [-h] [-k] [-o outfile] [-O outfile] [-U username] {file|-f infile}\nOptions: -c command pipe the output through command\n -d database specify the database to work with\n -f infile Read the names of the files with the notes from file infile\n -g deffile read global fields from file deffile\n -h prints this mini-help\n -k keep note ID\n -o outfile save the output in outfile (overwrite)\n -O outfile append the output to outfile\n -U username specify a different username than the current user\n All other arguments are interpreted as filenames.\n"); return 0; break; @@ -3650,5 +3684,4 @@ case 'C': /* fall through - nothing to do */ case 'e': - case 'E': case 'F': case 'g': @@ -3750,5 +3783,5 @@ strcat(outbuffer, " -u "); strcat(outbuffer, username); - if (strlen(passwd) > 0) { + if (*passwd) { strcat(outbuffer, " -w "); strcat(outbuffer, scrambled_passwd); @@ -3760,9 +3793,14 @@ strcat(outbuffer, my_reftype); - if (set_owner[0]) { + if (*set_owner) { strcat(outbuffer, " -U "); strcat(outbuffer, set_owner); } + if (*my_fromencoding) { + strcat(outbuffer, " -E "); + strcat(outbuffer, my_fromencoding); + } + if (n_personal) { strcat(outbuffer, " -p"); @@ -4287,4 +4325,5 @@ char pdf_root[_POSIX_PATH_MAX] = ""; char type_string[10] = ""; + char my_toencoding[PREFS_BUF_LEN] = ""; char **inargv; /* tokens of the argument */ char *newarg; @@ -4330,4 +4369,5 @@ strcpy(db, current_db); /* use default db if set */ + strcpy(my_toencoding, toencoding); /* use default encoding if set */ /* parse the argument. first we cut the argument @@ -4400,4 +4440,8 @@ db[_POSIX_PATH_MAX-1] = '\0'; /* terminate in case string got truncated */ break; + case 'E': + strncpy(my_toencoding, optarg, PREFS_BUF_LEN); + my_toencoding[PREFS_BUF_LEN-1] = '\0'; + break; case 'f': /* printf("-f %s\n", optarg); */ @@ -4463,5 +4507,4 @@ case 'C': /* fall through */ case 'e': - case 'E': case 'F': case 'g': @@ -4609,7 +4652,7 @@ } - if (*encoding) { + if (*my_toencoding) { strcat(slvals.outbuffer, " -E "); - strcat(slvals.outbuffer, encoding); + strcat(slvals.outbuffer, my_toencoding); } @@ -5068,5 +5111,9 @@ return 0; } - else if (!strcmp(varname, "encoding")) { + else if (!strcmp(varname, "toencoding")) { + /* nothing to do */ + return 0; + } + else if (!strcmp(varname, "fromencoding")) { /* nothing to do */ return 0; |
From: Markus H. <mho...@us...> - 2004-01-17 22:50:23
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv22100 Modified Files: noteshandler.h risxhandler.h Log Message: added conversion descriptor to struct Index: noteshandler.h =================================================================== RCS file: /cvsroot/refdb/refdb/src/noteshandler.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -U2 -r1.4 -r1.5 --- noteshandler.h 21 Dec 2003 23:11:38 -0000 1.4 +++ noteshandler.h 17 Jan 2004 22:50:20 -0000 1.5 @@ -51,4 +51,5 @@ dbi_conn conn_refdb; dbi_driver driver; + iconv_t conv_descriptor; /* conversion descriptor for iconv */ }; Index: risxhandler.h =================================================================== RCS file: /cvsroot/refdb/refdb/src/risxhandler.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -U2 -r1.8 -r1.9 --- risxhandler.h 7 Oct 2003 23:19:27 -0000 1.8 +++ risxhandler.h 17 Jan 2004 22:50:20 -0000 1.9 @@ -59,4 +59,5 @@ dbi_conn conn_refdb; dbi_driver driver; + iconv_t conv_descriptor; /* conversion descriptor for iconv */ }; |
From: Markus H. <mho...@us...> - 2004-01-17 22:47:24
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv21530 Modified Files: noteshandler.c risxhandler.c Log Message: added character conversion to end_handler() Index: noteshandler.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/noteshandler.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -U2 -r1.10 -r1.11 --- noteshandler.c 3 Jan 2004 20:11:43 -0000 1.10 +++ noteshandler.c 17 Jan 2004 22:47:20 -0000 1.11 @@ -27,6 +27,8 @@ #include <string.h> #include <time.h> /* for strftime */ +#include <errno.h> #include <expat.h> /* header of the XML parser */ #include <syslog.h> /* priority levels of log messages */ +#include <iconv.h> #include <dbi/dbi.h> @@ -623,4 +625,68 @@ if (!ptr_andata->ndb_error && !ptr_andata->nmem_error) { + /* do a character conversion if required. expat dumps all + character data as UTF-8 regardless of the input encoding */ + size_t inlength; + size_t outlength; + char* my_elvalue = NULL; /* this ptr will be modified by iconv() */ + char* my_elvalue_start = NULL; /* records initial state of my_elvalue */ + const char* my_instring = NULL; /* this ptr will be modified by iconv() */ + + if (ptr_andata->conv_descriptor && *((ptr_andata->ptr_first)->ptr_elvalue)) { + inlength = strlen((ptr_andata->ptr_first)->ptr_elvalue) + 1; + /* with the encodings supported by our database engines, the converted + string can't be longer than the input string */ + outlength = inlength; + + if ((my_elvalue = (char*)malloc(outlength)) == NULL) { + if ((new_msgpool = mstrcat(ptr_andata->msgpool, outomem_n.text, &(ptr_andata->msgpool_len), 0)) == NULL) { + return; + } + else { + ptr_andata->msgpool = new_msgpool; + } + (ptr_andata->nmem_error)++; + return; + } + + /* keep start of the converted string */ + my_elvalue_start = my_elvalue; + + /* variable will be modified by iconv, so don't use original */ + my_instring = (const char*)((ptr_andata->ptr_first)->ptr_elvalue); + + /* now actually do the conversion */ + if (iconv(ptr_andata->conv_descriptor, &my_instring, &inlength, &my_elvalue, &outlength) == (size_t)(-1)) { + if (errno == EILSEQ) { + new_msgpool = mstrcat(ptr_andata->msgpool, "iconv: invalid input character sequence\n", &(ptr_andata->msgpool_len), 0); + LOG_PRINT(LOG_WARNING, "iconv: invalid input character sequence"); + } + else if (errno == E2BIG) { + new_msgpool = mstrcat(ptr_andata->msgpool, "iconv: output buffer too small\n", &(ptr_andata->msgpool_len), 0); + LOG_PRINT(LOG_WARNING, "iconv: output buffer too small"); + } + else if (errno == EINVAL) { + new_msgpool = mstrcat(ptr_andata->msgpool, "iconv: incomplete input character\n", &(ptr_andata->msgpool_len), 0); + LOG_PRINT(LOG_WARNING, "iconv: incomplete input character"); + } + + if (new_msgpool == NULL) { + return; + } + else { + ptr_andata->msgpool = new_msgpool; + } + (ptr_andata->ndb_error)++; + return; + } + /* else: conversion went ok. We free the original string and replace + it with the converted copy */ + if ((ptr_andata->ptr_first)->ptr_elvalue) { + free((ptr_andata->ptr_first)->ptr_elvalue); + } + (ptr_andata->ptr_first)->ptr_elvalue = my_elvalue_start; + } + /* else: no conversion required */ + /* ------------------------------------------------------------ */ if (!strcmp(el, "title") && ptr_andata->replace_note != 2) { Index: risxhandler.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/risxhandler.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -U2 -r1.21 -r1.22 --- risxhandler.c 7 Jan 2004 19:43:03 -0000 1.21 +++ risxhandler.c 17 Jan 2004 22:47:20 -0000 1.22 @@ -30,6 +30,8 @@ #include <stdlib.h> #include <string.h> +#include <errno.h> #include <expat.h> /* header of the XML parser */ #include <syslog.h> /* priority levels of log messages */ +#include <iconv.h> #include <dbi/dbi.h> @@ -636,4 +638,68 @@ if (!ptr_ardata->ndb_error && !ptr_ardata->nmem_error) { + /* do a character conversion if required. expat dumps all + character data as UTF-8 regardless of the input encoding */ + size_t inlength; + size_t outlength; + char* my_elvalue = NULL; /* this ptr will be modified by iconv() */ + char* my_elvalue_start = NULL; /* records initial state of my_elvalue */ + const char* my_instring = NULL; /* this ptr will be modified by iconv() */ + + if (ptr_ardata->conv_descriptor && *((ptr_ardata->ptr_first)->ptr_elvalue)) { + inlength = strlen((ptr_ardata->ptr_first)->ptr_elvalue) + 1; + /* with the encodings supported by our database engines, the converted + string can't be longer than the input string */ + outlength = inlength; + + if ((my_elvalue = (char*)malloc(outlength)) == NULL) { + if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) { + return; + } + else { + ptr_ardata->msgpool = new_msgpool; + } + (ptr_ardata->nmem_error)++; + return; + } + + /* keep start of the converted string */ + my_elvalue_start = my_elvalue; + + /* variable will be modified by iconv, so don't use original */ + my_instring = (const char*)((ptr_ardata->ptr_first)->ptr_elvalue); + + /* now actually do the conversion */ + if (iconv(ptr_ardata->conv_descriptor, &my_instring, &inlength, &my_elvalue, &outlength) == (size_t)(-1)) { + if (errno == EILSEQ) { + new_msgpool = mstrcat(ptr_ardata->msgpool, "iconv: invalid input character sequence\n", &(ptr_ardata->msgpool_len), 0); + LOG_PRINT(LOG_WARNING, "iconv: invalid input character sequence"); + } + else if (errno == E2BIG) { + new_msgpool = mstrcat(ptr_ardata->msgpool, "iconv: output buffer too small\n", &(ptr_ardata->msgpool_len), 0); + LOG_PRINT(LOG_WARNING, "iconv: output buffer too small"); + } + else if (errno == EINVAL) { + new_msgpool = mstrcat(ptr_ardata->msgpool, "iconv: incomplete input character\n", &(ptr_ardata->msgpool_len), 0); + LOG_PRINT(LOG_WARNING, "iconv: incomplete input character"); + } + + if (new_msgpool == NULL) { + return; + } + else { + ptr_ardata->msgpool = new_msgpool; + } + (ptr_ardata->ndb_error)++; + return; + } + /* else: conversion went ok. We free the original string and replace + it with the converted copy */ + if ((ptr_ardata->ptr_first)->ptr_elvalue) { + free((ptr_ardata->ptr_first)->ptr_elvalue); + } + (ptr_ardata->ptr_first)->ptr_elvalue = my_elvalue_start; + } + /* else: no conversion required */ + /* ------------------------------------------------------------ */ if (!strcmp(el, "title") && ptr_ardata->replace_ref != 2) { |
From: Markus H. <mho...@us...> - 2004-01-17 00:11:06
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv14351/src Modified Files: backend-risx.c Log Message: handle dates that lack the trailing slash Index: backend-risx.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-risx.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -U2 -r1.25 -r1.26 --- backend-risx.c 10 Jan 2004 01:25:47 -0000 1.25 +++ backend-risx.c 17 Jan 2004 00:11:03 -0000 1.26 @@ -1016,5 +1016,5 @@ nhave_other++; slash = strchr(item, (int)'/'); - + /* fill the slashes array with up to three slashes. Only the first three may be relevant, as the others would be part of the otherinfo string */ while (slash != NULL && i < 3) { @@ -1068,7 +1068,10 @@ } - if (slashes[1] && slashes[2] && slashes[2]-slashes[1] > 1) { + if (slashes[1] && ((slashes[2] && slashes[2]-slashes[1] > 1) + || (!slashes[2] && *(slashes[1]+1) != '\0' && (*(slashes[1]+2) == '\0' || *(slashes[1]+3) == '\0')))) { /* have day */ - *(slashes[2]) = '\0'; + if (slashes[2]) { + *(slashes[2]) = '\0'; + } if (print_element_x(slashes[1]+1, &buffer1, &buffer1_len, "day", NULL, NULL, ptr_indent) == NULL) { free(buffer1); @@ -1076,4 +1079,5 @@ } } + if (! (slashes[2] && *(slashes[2]+1))) { |
From: Markus H. <mho...@us...> - 2004-01-17 00:10:02
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv14079/src Modified Files: Makefile.am Log Message: refdbd.h will not be nuked by make clean Index: Makefile.am =================================================================== RCS file: /cvsroot/refdb/refdb/src/Makefile.am,v retrieving revision 1.19 retrieving revision 1.20 diff -u -U2 -r1.19 -r1.20 --- Makefile.am 6 Jan 2004 18:11:33 -0000 1.19 +++ Makefile.am 17 Jan 2004 00:09:59 -0000 1.20 @@ -5,5 +5,5 @@ BUILT_SOURCES=refdbd.h EXTRA_DIST=refdbd.h.in -MOSTLYCLEANFILES=refdbd.h +MAINTAINERCLEANFILES=refdbd.h RISXVERSION = $(shell grep DOCTYPE $(srcdir)/../dtd/risx.dtd | sed 's%.*V\([^/]*\).*%\1%') |
From: Markus H. <mho...@us...> - 2004-01-17 00:05:19
|
Update of /cvsroot/refdb/refdb/dtd In directory sc8-pr-cvs1:/tmp/cvs-serv13229/dtd Modified Files: Makefile.am Log Message: do not distribute catalog but build it from catalog.in on the user side Index: Makefile.am =================================================================== RCS file: /cvsroot/refdb/refdb/dtd/Makefile.am,v retrieving revision 1.8 retrieving revision 1.9 diff -u -U2 -r1.8 -r1.9 --- Makefile.am 4 Dec 2003 00:41:37 -0000 1.8 +++ Makefile.am 17 Jan 2004 00:05:16 -0000 1.9 @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -objects = catalog citestylex.dtd citationlistx.dtd risx.dtd xnote.dtd - +objects = citestylex.dtd citationlistx.dtd risx.dtd xnote.dtd +install_objects = catalog $(objects) EXTRA_DIST = $(objects) catalog.in noinst_DATA = catalog |
From: Markus H. <mho...@us...> - 2004-01-17 00:01:30
|
Update of /cvsroot/refdb/refdb/doc In directory sc8-pr-cvs1:/tmp/cvs-serv12428/doc Modified Files: Makefile Log Message: added distdir target Index: Makefile =================================================================== RCS file: /cvsroot/refdb/refdb/doc/Makefile,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -U2 -r1.1.1.1 -r1.2 --- Makefile 22 May 2001 05:34:04 -0000 1.1.1.1 +++ Makefile 17 Jan 2004 00:01:27 -0000 1.2 @@ -5,2 +5,4 @@ distclean: echo "nothing to do yet" +distdir: + echo "nothing to do yet" |
From: Markus H. <mho...@us...> - 2004-01-14 23:21:37
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv1089 Modified Files: readln.c readln.h Log Message: replaced dupstr() by strdup(); removed dupstr() Index: readln.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/readln.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -U2 -r1.3 -r1.4 --- readln.c 13 Dec 2002 20:34:52 -0000 1.3 +++ readln.c 14 Jan 2004 23:21:34 -0000 1.4 @@ -145,5 +145,5 @@ if (strncmp (name, text, len) == 0) - return (dupstr(name)); + return (strdup(name)); } @@ -152,17 +152,3 @@ } -/* **************************************************************** */ -/* */ -/* helper functions */ -/* */ -/* **************************************************************** */ - -char* dupstr (char* s) -{ - char *r; - - r = xmalloc (strlen (s) + 1); - strcpy (r, s); - return (r); -} Index: readln.h =================================================================== RCS file: /cvsroot/refdb/refdb/src/readln.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -U2 -r1.2 -r1.3 --- readln.h 13 Dec 2002 20:34:54 -0000 1.2 +++ readln.h 14 Jan 2004 23:21:34 -0000 1.3 @@ -35,5 +35,4 @@ COMMAND *find_command(char *name, COMMAND *commands); int execute_line (char *line, COMMAND *commands); -char* dupstr (char* s); char *command_generator (char *text, int state); char **refdb_completion (); |
From: Markus H. <mho...@us...> - 2004-01-10 01:26:42
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv5596 Modified Files: refdbdref.c Log Message: don't output anything if query returns zero datasets Index: refdbdref.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdref.c,v retrieving revision 1.49 retrieving revision 1.50 diff -u -U2 -r1.49 -r1.50 --- refdbdref.c 4 Jan 2004 01:58:20 -0000 1.49 +++ refdbdref.c 10 Jan 2004 01:26:39 -0000 1.50 @@ -3823,19 +3823,21 @@ } - /* create a "footer" if necessary */ - /* fill in variable elements of structure */ - rendinfo.ptr_ref = &sql_command; - rendinfo.ptr_ref_len = &sql_command_len; + if (nref_counter) { + /* create a "footer" if necessary */ + /* fill in variable elements of structure */ + rendinfo.ptr_ref = &sql_command; + rendinfo.ptr_ref_len = &sql_command_len; - if ((new_sql_command = finish_render(&rendinfo)) == NULL) { - dbi_result_free(rendinfo.dbires); - dbi_conn_close(conn); - delete_all_lilimem(&sentinel); - return 0; + if ((new_sql_command = finish_render(&rendinfo)) == NULL) { + dbi_result_free(rendinfo.dbires); + dbi_conn_close(conn); + delete_all_lilimem(&sentinel); + return 0; + } + else { + sql_command = new_sql_command; + } + iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); } - else { - sql_command = new_sql_command; - } - iwrite(ptr_clrequest->fd, sql_command, strlen(sql_command)); dbi_result_free(rendinfo.dbires); |
From: Markus H. <mho...@us...> - 2004-01-10 01:25:49
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv5530 Modified Files: backend-risx.c Log Message: output ris end tag on separate line Index: backend-risx.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-risx.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -U2 -r1.24 -r1.25 --- backend-risx.c 7 Jan 2004 19:31:50 -0000 1.24 +++ backend-risx.c 10 Jan 2004 01:25:47 -0000 1.25 @@ -106,5 +106,5 @@ char* new_ref; - new_ref = mstrcpy(*(ptr_rendinfo->ptr_ref), "</ris>\n", ptr_rendinfo->ptr_ref_len); + new_ref = mstrcpy(*(ptr_rendinfo->ptr_ref), "\n</ris>\n", ptr_rendinfo->ptr_ref_len); if (new_ref == NULL) { |
From: Markus H. <mho...@us...> - 2004-01-08 20:50:20
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv922 Modified Files: backend.c Log Message: get_refdb_note_date(): fixed localtime vs. gmtime typo Index: backend.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -U2 -r1.23 -r1.24 --- backend.c 4 Jan 2004 01:56:42 -0000 1.23 +++ backend.c 8 Jan 2004 20:50:17 -0000 1.24 @@ -284,8 +284,8 @@ if (the_time) { if (!mode) { - strftime(date, 256, "%a %b %d %Y", localtime(&the_time)); + strftime(date, 256, "%a %b %d %Y", gmtime(&the_time)); } else { - strftime(date, 256, "%Y-%m-%d", localtime(&the_time)); + strftime(date, 256, "%Y-%m-%d", gmtime(&the_time)); } } |
From: Markus H. <mho...@us...> - 2004-01-07 19:43:06
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv29508 Modified Files: risxhandler.c Log Message: check get_attr() for NULL; skip adding PATH to availability data that erroneously carries this prefix Index: risxhandler.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/risxhandler.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -U2 -r1.20 -r1.21 --- risxhandler.c 3 Jan 2004 20:11:44 -0000 1.20 +++ risxhandler.c 7 Jan 2004 19:43:03 -0000 1.21 @@ -739,5 +739,5 @@ /* else: corporate name is in ptr_ainfo->name anyway */ - /* role attribute */ + /* role attribute, function checks for NULL value */ set_authorinfo_role(ptr_ardata->ptr_ainfo, get_attr(ptr_ardata->ptr_first, "role")); @@ -1135,34 +1135,36 @@ type = get_attr(ptr_ardata->ptr_first, "type"); - if (!strcmp(type, "1")) { - strcpy(tofield, "user1"); - } - else if (!strcmp(type, "2")) { - strcpy(tofield, "user2"); - } - else if (!strcmp(type, "3")) { - strcpy(tofield, "user3"); - } - else if (!strcmp(type, "4")) { - strcpy(tofield, "user4"); - } - else if (!strcmp(type, "5")) { - strcpy(tofield, "user5"); - } + if (type) { + if (!strcmp(type, "1")) { + strcpy(tofield, "user1"); + } + else if (!strcmp(type, "2")) { + strcpy(tofield, "user2"); + } + else if (!strcmp(type, "3")) { + strcpy(tofield, "user3"); + } + else if (!strcmp(type, "4")) { + strcpy(tofield, "user4"); + } + else if (!strcmp(type, "5")) { + strcpy(tofield, "user5"); + } - result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver); - if (result == 1) { - LOG_PRINT(LOG_WARNING, outomem.text); - if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) { - (ptr_ardata->nmem_error)++; + result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver); + if (result == 1) { + LOG_PRINT(LOG_WARNING, outomem.text); + if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) { + (ptr_ardata->nmem_error)++; + return; + } + else { + ptr_ardata->msgpool = new_msgpool; + } + (ptr_ardata->ndb_error)++; return; } - else { - ptr_ardata->msgpool = new_msgpool; - } - (ptr_ardata->ndb_error)++; - return; + /* else: all fine */ } - /* else: all fine */ } /* ------------------------------------------------------------ */ @@ -1173,28 +1175,30 @@ type = get_attr(ptr_ardata->ptr_first, "type"); - if (!strcmp(type, "1")) { - strcpy(tofield, "misc1"); - } - else if (!strcmp(type, "2")) { - strcpy(tofield, "misc2"); - } - else if (!strcmp(type, "3")) { - strcpy(tofield, "misc3"); - } + if (type) { + if (!strcmp(type, "1")) { + strcpy(tofield, "misc1"); + } + else if (!strcmp(type, "2")) { + strcpy(tofield, "misc2"); + } + else if (!strcmp(type, "3")) { + strcpy(tofield, "misc3"); + } - result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver); - if (result == 1) { - LOG_PRINT(LOG_WARNING, outomem.text); - if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) { - (ptr_ardata->nmem_error)++; + result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver); + if (result == 1) { + LOG_PRINT(LOG_WARNING, outomem.text); + if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) { + (ptr_ardata->nmem_error)++; + return; + } + else { + ptr_ardata->msgpool = new_msgpool; + } + (ptr_ardata->ndb_error)++; return; } - else { - ptr_ardata->msgpool = new_msgpool; - } - (ptr_ardata->ndb_error)++; - return; + /* else: all fine */ } - /* else: all fine */ } /* ------------------------------------------------------------ */ @@ -1205,31 +1209,33 @@ type = get_attr(ptr_ardata->ptr_first, "type"); - if (!strcmp(type, "pdf")) { - strcpy(tofield, "linkpdf"); - } - else if (!strcmp(type, "fulltext")) { - strcpy(tofield, "linkfull"); - } - else if (!strcmp(type, "related")) { - strcpy(tofield, "linkrel"); - } - else /* if (!strcmp(type, "image")) */ { - strcpy(tofield, "linkimg"); - } + if (type) { + if (!strcmp(type, "pdf")) { + strcpy(tofield, "linkpdf"); + } + else if (!strcmp(type, "fulltext")) { + strcpy(tofield, "linkfull"); + } + else if (!strcmp(type, "related")) { + strcpy(tofield, "linkrel"); + } + else /* if (!strcmp(type, "image")) */ { + strcpy(tofield, "linkimg"); + } - result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver); - if (result == 1) { - LOG_PRINT(LOG_WARNING, outomem.text); - if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) { - (ptr_ardata->nmem_error)++; + result = set_risdata_field(ptr_ardata->ptr_risdata, tofield, (ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->driver); + if (result == 1) { + LOG_PRINT(LOG_WARNING, outomem.text); + if ((new_msgpool = mstrcat(ptr_ardata->msgpool, outomem_n.text, &(ptr_ardata->msgpool_len), 0)) == NULL) { + (ptr_ardata->nmem_error)++; + return; + } + else { + ptr_ardata->msgpool = new_msgpool; + } + (ptr_ardata->ndb_error)++; return; } - else { - ptr_ardata->msgpool = new_msgpool; - } - (ptr_ardata->ndb_error)++; - return; + /* else: all fine */ } - /* else: all fine */ } /* ------------------------------------------------------------ */ @@ -1270,15 +1276,26 @@ type = get_attr(ptr_ardata->ptr_first, "type"); - if (!strcmp(type, "useroot")) { + if (type && !strcmp(type, "useroot")) { if ((temp_avail = malloc(strlen((ptr_ardata->ptr_first)->ptr_elvalue)+6)) == NULL) { (ptr_ardata->nmem_error)++; return; } - strcpy(temp_avail, "PATH:"); + + /* skip adding PATH: to data that already contain this prefix + this was added erroneously by some previous versions */ + if (strncmp((ptr_ardata->ptr_first)->ptr_elvalue, "PATH:", 5)) { + strcpy(temp_avail, "PATH:"); + } + else { + *temp_avail = '\0'; + } strcat(temp_avail, (ptr_ardata->ptr_first)->ptr_elvalue); result = update_avail(temp_avail, ptr_ardata->n_refdb_id, ptr_ardata->n_user_id, ptr_ardata->conn, ptr_ardata->driver); + + free(temp_avail); } else { + /* full string, not a path */ result = update_avail((ptr_ardata->ptr_first)->ptr_elvalue, ptr_ardata->n_refdb_id, ptr_ardata->n_user_id, ptr_ardata->conn, ptr_ardata->driver); } |
From: Markus H. <mho...@us...> - 2004-01-07 19:31:53
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv27439 Modified Files: backend-risx.c Log Message: do not output PATH prefix in availability element Index: backend-risx.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/backend-risx.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -U2 -r1.23 -r1.24 --- backend-risx.c 6 Jan 2004 15:37:13 -0000 1.23 +++ backend-risx.c 7 Jan 2004 19:31:50 -0000 1.24 @@ -1143,4 +1143,5 @@ struct REPRINT reprint; char attribute[10]; + size_t path_skip = 0; if (get_reprint(ptr_rendinfo->dbires, &reprint, username, 4) @@ -1165,4 +1166,5 @@ if (!strncmp(reprint.avail, "PATH:", 5)) { strcpy(attribute, "useroot"); + path_skip = 5; } else { @@ -1170,5 +1172,5 @@ } - if (print_element_x(reprint.avail, ptr_buffer, ptr_buffer_len, "availability", "type", attribute, ptr_indent) == NULL) { + if (print_element_x(reprint.avail+path_skip, ptr_buffer, ptr_buffer_len, "availability", "type", attribute, ptr_indent) == NULL) { return NULL; } |
From: Markus H. <mho...@us...> - 2004-01-06 23:06:40
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1:/tmp/cvs-serv722 Modified Files: authorinfo.c tokenize.c Log Message: added support for hyphenated double initials in author names Index: authorinfo.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/authorinfo.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -U2 -r1.3 -r1.4 --- authorinfo.c 28 Dec 2003 00:43:19 -0000 1.3 +++ authorinfo.c 6 Jan 2004 23:06:36 -0000 1.4 @@ -45,4 +45,5 @@ char* temp_middle; char* new_temp_author; + char bitsandpieces[6]; size_t temp_author_len = 256; @@ -71,15 +72,35 @@ } - if ((new_temp_author = mstrcat(temp_author, ptr_ainfo->firstname, &temp_author_len, 0)) == NULL) { - (*ptr_error)++; - free(temp_author); - return NULL; + /* we've got to analyze whether this is a full first name or some + hyphenated double initial */ + if (ptr_ainfo->firstname[1] == '-') { + *bitsandpieces = *(ptr_ainfo->firstname); + *(bitsandpieces + 1) = '.'; + *(bitsandpieces + 2) = '-'; + *(bitsandpieces + 3) = *(ptr_ainfo->firstname + 2); + *(bitsandpieces + 4) = '.'; + *(bitsandpieces + 5) = '\0'; + } + else if (*(ptr_ainfo->firstname + 1) == '\0') { + *bitsandpieces = *ptr_ainfo->firstname; + *(bitsandpieces + 1) = '.'; + *(bitsandpieces + 2) = '\0'; } else { - temp_author = new_temp_author; + *bitsandpieces = '\0'; } - if (ptr_ainfo->firstname[1] == '\0') { - if ((new_temp_author = mstrcat(temp_author, ".", &temp_author_len, 0)) == NULL) { + if (*bitsandpieces) { + if ((new_temp_author = mstrcat(temp_author, bitsandpieces, &temp_author_len, 0)) == NULL) { + (*ptr_error)++; + free(temp_author); + return NULL; + } + else { + temp_author = new_temp_author; + } + } + else { + if ((new_temp_author = mstrcat(temp_author, ptr_ainfo->firstname, &temp_author_len, 0)) == NULL) { (*ptr_error)++; free(temp_author); @@ -112,16 +133,35 @@ } - if ((new_temp_author = mstrcat(temp_author, item, &temp_author_len, 0)) == NULL) { - (*ptr_error)++; - free(temp_author); - free(temp_middle); - return NULL; + /* check whether middle name is hyphenated initial */ + if (*(item + 1) == '-') { + *bitsandpieces = *item; + *(bitsandpieces + 1) = '.'; + *(bitsandpieces + 2) = '-'; + *(bitsandpieces + 3) = *(item + 2); + *(bitsandpieces + 4) = '.'; + *(bitsandpieces + 5) = '\0'; + } + else if (*(item + 1) == '\0') { + *bitsandpieces = *item; + *(bitsandpieces + 1) = '.'; + *(bitsandpieces + 2) = '\0'; } else { - temp_author = new_temp_author; + *bitsandpieces = '\0'; } - if (item[1] == '\0') { - if ((new_temp_author = mstrcat(temp_author, ".", &temp_author_len, 0)) == NULL) { + if (*bitsandpieces) { + if ((new_temp_author = mstrcat(temp_author, bitsandpieces, &temp_author_len, 0)) == NULL) { + (*ptr_error)++; + free(temp_author); + free(temp_middle); + return NULL; + } + else { + temp_author = new_temp_author; + } + } + else { + if ((new_temp_author = mstrcat(temp_author, item, &temp_author_len, 0)) == NULL) { (*ptr_error)++; free(temp_author); Index: tokenize.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/tokenize.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -U2 -r1.10 -r1.11 --- tokenize.c 6 Jan 2004 15:41:57 -0000 1.10 +++ tokenize.c 6 Jan 2004 23:06:36 -0000 1.11 @@ -971,11 +971,33 @@ } - /* now there's two options: + /* now there's three options: - the next char is the first initial, followed by a period + - the next char is the first initial of a hyphenated double + name - the next word is the full first name */ if (*(ptr_atoken->first + 1) == '.') { - *(ptr_atoken->first + 1) = '\0'; - middle = ptr_atoken->first + 2; + if (*(ptr_atoken->first + 2) == '-') { + /* now we've got to find the end of the hyphenated name, remove + the periods, and terminate the string appropriately */ + middle = ptr_atoken->first + 3; + while (*middle && *middle != ' ') { + middle++; + } + + if (*(middle-1) == '.') { + *(middle-1) = '\0'; + } + else if (*middle == ' ') { + *middle = '\0'; + middle++; + } + + memmove(ptr_atoken->first + 1, ptr_atoken->first + 2, strlen(ptr_atoken->first + 2)+1); + } + else { + *(ptr_atoken->first + 1) = '\0'; + middle = ptr_atoken->first + 2; + } } else if (*(ptr_atoken->first + 1)) { /* string doesn't end here */ @@ -1008,6 +1030,26 @@ /* middle name could be abbreviated, so look for a dot */ if (*(middle + 1) == '.') { - *(middle + 1) = '\0'; - next_middle = middle + 2; + if (*(middle + 2) == '-') { + /* now we've got to find the end of the hyphenated name, remove + the periods, and terminate the string appropriately */ + next_middle = middle + 3; + while (*next_middle && *next_middle != ' ') { + next_middle++; + } + + if (*(next_middle-1) == '.') { + *(next_middle-1) = '\0'; + } + else if (*next_middle == ' ') { + *next_middle = '\0'; + next_middle++; + } + + memmove(middle + 1, middle + 2, strlen(middle + 2)+1); + } + else { + *(middle + 1) = '\0'; + next_middle = middle + 2; + } } else { |
From: Markus H. <mho...@us...> - 2004-01-06 21:50:44
|
Update of /cvsroot/refdb/refdb/examples In directory sc8-pr-cvs1:/tmp/cvs-serv15627/examples Modified Files: testrefs.xml Log Message: updated prolog Index: testrefs.xml =================================================================== RCS file: /cvsroot/refdb/refdb/examples/testrefs.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -U2 -r1.1 -r1.2 --- testrefs.xml 7 Jul 2003 22:23:29 -0000 1.1 +++ testrefs.xml 6 Jan 2004 21:50:41 -0000 1.2 @@ -1,4 +1,4 @@ <?xml version="1.0"?> -<!DOCTYPE ris PUBLIC "-//Markus Hoenicka//DTD Ris//EN" "http://refdb.sourceforge.net/dtd/risx.dtd"> +<!DOCTYPE ris PUBLIC "-//Markus Hoenicka//DTD Ris V1.0.2//EN" "http://refdb.sourceforge.net/dtd/risx/risx-1.02/risx.dtd"> <ris> <entry type="BOOK" id="31" citekey="MILLER1999"> |