1 /* refdbd.h header file for refdbd.c */
2 /* markus@mhoenicka.de 2-10-00 */
3 /* $Id: refdbd.h.in,v 1.7.2.15 2006/02/22 20:58:39 mhoenicka Exp $ */
4 
5 /*
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 
20   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
21 
22 #ifndef XmlParse_INCLUDED
23 #include <expat.h>
24 #endif
25 
26 #ifndef backend_included
27 #include "backend.h"
28 #endif
29 
30 struct ADDRESULT {
31   unsigned long long success; /* number of successfully added references */
32   unsigned long long failure; /* number of failures */
33   unsigned long long updated; /* number of successfully updated references */
34   unsigned long long skipped; /* number of skipped references */
35   char *msg; /* ptr to optional error message */
36   size_t msg_len; /* length of optional error message */
37 };
38 
39 struct CLIENT_REQUEST {
40   int fd; /* file descriptor of incoming connection */
41   int n_cgi; /* if 1, handle as CGI request */
42   int* ptr_optind; /* ptr to index of first parsed argument to handle */
43   int inargc; /* number of parsed arguments */
44   int protocol; /* protocol version */
45   int db_timeout; /* db-engine specific timeout (sqlite/sqlite3) */
46   int share_default; /* whether (1) or not (0) to share notes by default */
47   char** inargv; /* ptr to array of parsed arguments */
48   char username[USERNAME_LENGTH]; /* username for database authentication */
49   char passwd[PREFS_BUF_LEN]; /* password for database authentication */
50   char server_ip[PREFS_BUF_LEN]; /* hostname or IP address of database server */
51   char my_hostname[256]; /* hostname of box running refdbd */
52   char dbs_port_address[PREFS_BUF_LEN]; /* port where database server listens */
53   char dbserver[PREFS_BUF_LEN]; /* name of the libdbi driver */
54   char current_db[DBNAME_LENGTH+1]; /* name of reference database */
55   char db_path[PREFS_BUF_LEN]; /* path of dir containing databases */
56   char db_encoding[PREFS_BUF_LEN]; /* input or output encoding */
57   char listname[PREFS_BUF_LEN+USERNAME_LENGTH+2]; /* name of personal list */
58   char limit[PREFS_BUF_LEN]; /* limit:offset for retrieval functions */
59   char namespace[PREFS_BUF_LEN]; /* namespace for XML documents */
60   char client_ip[16]; /* IP address of client */
61   char pdfroot[_POSIX_PATH_MAX+1];
62   char cgi_url[_POSIX_PATH_MAX+1];
63   char check_string[MAX_FMT_LEN]; /* fields to check */
64   char* argument; /* additional unparsed command arguments */
65 };
66 
67 #define MSG_BUF_SIZE 256
68 #define FIFO_NAME "/tmp/refdbd_fifo" /* base name of a fifo */
69 #define MAIN_META "t_meta" /* name of the main database meta table */
70 #define DB_DIR "/usr/local/var/lib/refdb/db" /* directory which holds database and version file */
71 #define MAIN_DB_VERSION 3 /* version tag of main database shipped with this version */
72 #define MIN_MAIN_DB_VERSION 3 /* minimum version tag of readable main database */
73 #define DB_VERSION 4 /* version tag of reference databases created with this version */
74 #define MIN_DB_VERSION 4 /* minimum version tag of reference databases readable */
75 
76 #define CITEKEY_BASE_LENGTH 240 /* maximum length of authorname+year */
77 
78 /* defines for the temporary tables used in duplicate checks */
79 #define TEMP_TABLE_SPECIFIER "TEMPORARY "
80 #define TEMP_TABLE_NAME_PREFIX "temp_"
81 
82 /* here we define some strings that will be used in the DSSSL style specification files */
83 #define STYLESHEET_HTML_NAME "docbook-refdb-html.dsl"
84 #define STYLESHEET_HTML_BASENAME "docbook-refdb-html"
85 #define STYLESHEET_HTML_ID "html"
86 #define STYLESHEET_HTML_PUBID "-//Markus Hoenicka//DOCUMENT RefDB DocBook html stylesheet//EN"
87 
88 #define STYLESHEET_PRINT_NAME "docbook-refdb-print.dsl"
89 #define STYLESHEET_PRINT_BASENAME "docbook-refdb-print"
90 #define STYLESHEET_PRINT_ID "print"
91 #define STYLESHEET_PRINT_PUBID "-//Markus Hoenicka//DOCUMENT RefDB DocBook print stylesheet//EN"
92 
93 /* these defines are for the bibliography style output */
94 #define PROCESSING_INST "<?xml version=\"1.0\"?>\n"
95 #define PROCESSING_INST_UTF8 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
96 #define DOCTYPE_CITESTYLE "<!DOCTYPE CITESTYLE PUBLIC \"-//Markus Hoenicka//DTD CiteStyle V1.7//EN\" \"http://refdb.sourceforge.net/dtd/citestylex-1.7/citestylex.dtd\" [\n<!ENTITY lt \"&#38;#60;\">\n<!ENTITY gt \"&#62;\">\n<!ENTITY amp \"&#38;#38;\">\n<!ENTITY mdash \"&#x2014;\">\n<!ENTITY lsquo \"&#x2018;\">\n<!ENTITY rsquo \"&#x2019;\">\n]>\n"
97 #define DOCTYPE_STYLESET "<!DOCTYPE STYLESET PUBLIC \"-//Markus Hoenicka//DTD CiteStyle V1.7//EN\" \"http://refdb.sourceforge.net/dtd/citestylex-1.7/citestylex.dtd\" [\n<!ENTITY lt \"&#38;#60;\">\n<!ENTITY gt \"&#62;\">\n<!ENTITY amp \"&#38;#38;\">\n<!ENTITY mdash \"&#x2014;\">\n<!ENTITY lsquo \"&#x2018;\">\n<!ENTITY rsquo \"&#x2019;\">\n]>\n"
98 
99 /* this one is for the risx.dtd */
100 #define RISX_PUBID "<!DOCTYPE ris PUBLIC \"-//Markus Hoenicka//DTD Ris V1.2.0//EN\" \"http://refdb.sourceforge.net/dtd/risx-1.2.0/risx.dtd\" [\n<!ENTITY lt \"&#38;#60;\">\n<!ENTITY gt \"&#62;\">\n<!ENTITY amp \"&#38;#38;\">\n<!ENTITY mdash \"&#x2014;\">\n<!ENTITY lsquo \"&#x2018;\">\n<!ENTITY rsquo \"&#x2019;\">\n]>\n"
101 
102 /* the extended notes dtd */
103 #define XNOTE_PUBID "<!DOCTYPE xnoteset PUBLIC \"-//Markus Hoenicka//DTD Xnote V1.2//EN\" \"http://refdb.sourceforge.net/dtd/xnote-1.2/xnote.dtd\" [\n<!ENTITY lt \"&#38;#60;\">\n<!ENTITY gt \"&#62;\">\n<!ENTITY amp \"&#38;#38;\">\n<!ENTITY mdash \"&#x2014;\">\n<!ENTITY lsquo \"&#x2018;\">\n<!ENTITY rsquo \"&#x2019;\">\n]>\n"
104 
105 /* the citationlistx dtd */
106 #define CITATIONLISTX_PUBID "<!DOCTYPE CITATIONLIST PUBLIC \"-//Markus Hoenicka//DTD CitationList V1.0//EN\" \"http://refdb.sourceforge.net/dtd/citationlistx-1.0/citationlistx.dtd\">\n"
107 
108 /* these defines select the addref modes */
109 #define ADDREF_ADD 0
110 #define ADDREF_UPDATE 1
111 #define ADDREF_UPDATE_PERSONAL 2
112 #define ADDREF_CHECK 3
113 
114 /* the following defines are for daemonize & friends */
115 #define ROOT_DIR "/"
116 #define STDIN_FILENO 0
117 #define STDOUT_FILENO 1
118 #define STDERR_FILENO 2
119 
120 /* supported reference types */
121 #define REFTYPES "ABST ADVS ART BILL BOOK CASE CHAP COMP CONF CTLG DATA ELEC GEN HEAR ICOMM INPR JFULL JOUR MAP MGZN MPCT MUSIC NEWS PAMP PAT PCOMM RPRT SER SLIDE SOUND STAT THES UNBILL UNPB VIDEO"
122 
123 struct ADDRESULT* new_addresult();
124 struct bibinfo* new_bibinfo(char* format_string, char* sort_string);
125 
126 dbi_conn connect_to_db(struct CLIENT_REQUEST* ptr_clrequest, const char* special_db, int nocheck);
127 int viewstat(struct CLIENT_REQUEST* ptr_clrequest);
128 int listdb(struct CLIENT_REQUEST* ptr_clrequest, int select, struct ADDRESULT* ptr_addresult);
129 int listuser(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
130 int liststyle(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
131 int getstyle(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
132 int whichdb(struct CLIENT_REQUEST* ptr_clrequest);
133 int createdb(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult, int optind);
134 int real_createdb(struct CLIENT_REQUEST* ptr_clrequest, const char* db_encoding, struct ADDRESULT* ptr_addresult);
135 int deletedb(struct CLIENT_REQUEST* ptr_clrequest, int optind, struct ADDRESULT* ptr_addresult);
136 int child_confserv(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
137 void confserv(char *command, char *server_ip);
138 int addref(struct CLIENT_REQUEST* ptr_clrequest, struct bibinfo* ptr_biblio_info, char* set_owner, struct ADDRESULT* ptr_addresult, int replace_ref, int n_keep_id, int informat, int outformat, Lilid* ptr_sentinel);
139 int deleteref(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
140 int delete_ref_by_id(unsigned long long idval, dbi_conn conn, struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
141 int pickref(struct CLIENT_REQUEST* ptr_clrequest, int n_remove, struct ADDRESULT* ptr_addresult);
142 int pick_one_reference(dbi_conn conn, unsigned long long n_ref_id, unsigned long long n_user_id, const char *listname, const char *username, struct ADDRESULT* ptr_addresult);
143 int dump_one_reference(dbi_conn conn, unsigned long long n_ref_id, unsigned long long n_user_id, const char *listname, const char *username, struct ADDRESULT* ptr_addresult);
144 int adduser(struct CLIENT_REQUEST* ptr_clrequest, char *user_host, char* newuser_passwd, int n_remove, int n_readonly, struct ADDRESULT* ptr_addresult);
145 int addword(struct CLIENT_REQUEST* ptr_clrequest, int n_remove, struct ADDRESULT* ptr_addresult);
146 int listword(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
147 int getfoo(struct CLIENT_REQUEST* ptr_clrequest, int type, int all, char* input_encoding, struct ADDRESULT* ptr_addresult, char* format_string);
148 int getbib(struct CLIENT_REQUEST* ptr_clrequest, struct bibinfo* ptr_biblio_info, int n_ref_format, struct ADDRESULT* ptr_addresult);
149 char* getid(char* idstring, char** db, int* type);
150 char* get_bibtex_id(char* idstring, char** db);
151 int addstyle(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
152 int deletestyle(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
153 int remove_style(dbi_conn conn, unsigned int id);
154 int read_xml(int fd, XML_Parser p, struct ADDRESULT* ptr_addresult);
155 void log_print(int priority, const char* string);
156 int is_refdb_admin(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
157 int run_keyword_scan(struct CLIENT_REQUEST* ptr_clrequest, Lilid* ptr_sentinel, int mode);
158 int addnote(struct CLIENT_REQUEST* ptr_clrequest, char* set_owner, struct ADDRESULT* ptr_addresult, int replace_note, Lilid* ptr_sentinel);
159 int deletenote(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
160 int getnote(struct CLIENT_REQUEST* ptr_clrequest, struct bibinfo *ptr_biblio_info, int ref_format, int n_privatelist, struct ADDRESULT* ptr_addresult, int send_data);
161 int addlink(struct CLIENT_REQUEST* ptr_clrequest, char* set_owner, struct ADDRESULT* ptr_addresult, int n_remove);
162 unsigned long long create_personal_list(dbi_conn conn, char *listname, unsigned long long n_user_id, const char *username);
163 int remove_personal_list(dbi_conn conn, char *quoted_listname, struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
164 int updatejo(struct CLIENT_REQUEST* ptr_clrequest, struct ADDRESULT* ptr_addresult);
165 struct CLIENT_REQUEST* new_client_request(void);
166 struct CLIENT_REQUEST* dup_client_request(struct CLIENT_REQUEST* ptr_clrequest);
167 int initialize_client_request(struct CLIENT_REQUEST* ptr_clrequest);
168 int free_client_request(struct CLIENT_REQUEST* ptr_clrequest);
169 int update_meta(dbi_conn conn, struct CLIENT_REQUEST* ptr_clrequest);
170 int check_is_subseq(const char* author_concat, const char* table_name, int n_currpos, short int n_pubyear, dbi_conn conn);
171 struct ADDRESULT* new_addresult(void);
172 void free_addresult(struct ADDRESULT* ptr_addresult);
173 int daemonize(char* progname);
174 int indent_notbelow_dbib(const char* name);
175 int is_entry_dbib(const char* name);
176 
177 
178 
179