removed Z39.50 Proxy functionality from parameters global overrides and moved into...
[pazpar2-moved-to-github.git] / src / pazpar2.c
1 /* $Id: pazpar2.c,v 1.86 2007-06-06 11:49:48 marc Exp $
2    Copyright (c) 2006-2007, Index Data.
3
4 This file is part of Pazpar2.
5
6 Pazpar2 is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Pazpar2; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 #if HAVE_CONFIG_H
23 #include "cconfig.h"
24 #endif
25
26
27 #include <signal.h>
28 #include <assert.h>
29
30 #include "pazpar2.h"
31 #include "database.h"
32 #include "settings.h"
33
34 int main(int argc, char **argv)
35 {
36     int ret;
37     char *arg;
38
39     if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
40         yaz_log(YLOG_WARN|YLOG_ERRNO, "signal");
41
42     yaz_log_init_prefix("pazpar2");
43
44     //while ((ret = options("f:h:p:z:t:l:dX", argv, argc, &arg)) != -2)
45    while ((ret = options("f:h:p:t:l:dX", argv, argc, &arg)) != -2)
46     {
47         switch (ret)
48         {
49         case 'f':
50             if (!read_config(arg))
51                 exit(1);
52             break;
53         case 'h':
54             strcpy(global_parameters.listener_override, arg);
55             break;
56         case 'p':
57             strcpy(global_parameters.proxy_override, arg);
58             break;
59 /*        case 'z': */
60 /*             strcpy(global_parameters.zproxy_override, arg); */
61 /*             break; */
62         case 't':
63             strcpy(global_parameters.settings_path_override, arg);
64              break;
65         case 'd':
66             global_parameters.dump_records = 1;
67             break;
68         case 'l':
69             yaz_log_init_file(arg);
70             break;
71         case 'X':
72             global_parameters.debug_mode = 1;
73             break;
74         default:
75             fprintf(stderr, "Usage: pazpar2\n"
76                     "    -f configfile\n"
77                     "    -h [host:]port          (REST protocol listener)\n"
78                     "    -p hostname[:portno]    (HTTP proxy)\n"
79                     "    -z hostname[:portno]    (Z39.50 proxy)\n"
80                     "    -t settings\n"
81                     "    -d                      (show internal records)\n"
82                     "    -l file                 log to file\n"
83                     "    -X                      debug mode\n"
84                 );
85             exit(1);
86         }
87     }
88
89     if (!config)
90     {
91         yaz_log(YLOG_FATAL, "Load config with -f");
92         exit(1);
93     }
94     global_parameters.server = config->servers;
95
96     start_http_listener();
97     start_proxy();
98     //start_zproxy();
99     init_settings();
100
101     if (*global_parameters.settings_path_override)
102         settings_read(global_parameters.settings_path_override);
103     else if (global_parameters.server->settings)
104         settings_read(global_parameters.server->settings);
105     else
106         yaz_log(YLOG_WARN, "No settings-directory specified");
107     global_parameters.odr_in = odr_createmem(ODR_DECODE);
108     global_parameters.odr_out = odr_createmem(ODR_ENCODE);
109
110     pazpar2_event_loop();
111
112     return 0;
113 }
114
115
116 /*
117  * Local variables:
118  * c-basic-offset: 4
119  * indent-tabs-mode: nil
120  * End:
121  * vim: shiftwidth=4 tabstop=8 expandtab
122  */