bin/rip/whois_rip.c
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- error_init
- main
1 /***************************************
2 $Revision: 1.24 $
3
4 Example code: main server code.
5
6 Status: NOT REVUED, TESTED
7
8 Author: Chris Ottrey + pretty much everybody else involved :-)
9
10 +html+ <DL COMPACT>
11 +html+ <DT>Online References:
12 +html+ <DD><UL>
13 +html+ </UL>
14 +html+ </DL>
15
16 ******************/ /******************
17 Modification History:
18 ottrey (09/03/1999) Created.
19 ******************/ /******************
20 Copyright (c) 1993, 1994, 1995, 1996, 1997 The TERENA Association
21 Copyright (c) 1998 RIPE NCC
22
23 All Rights Reserved
24
25 Permission to use, copy, modify, and distribute this software and its
26 documentation for any purpose and without fee is hereby granted,
27 provided that the above copyright notice appear in all copies and that
28 both that copyright notice and this permission notice appear in
29 supporting documentation, and that the name of the author not be
30 used in advertising or publicity pertaining to distribution of the
31 software without specific, written prior permission.
32
33 THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
34 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
35 AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
36 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
37 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
38 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
39 ***************************************/
40
41 #include <signal.h>
42 #include "erroutines.h"
43 #include "constants.h"
44 #include "properties.h"
45 #include "server.h"
46 #include "bitmask.h"
47 #include "thread.h"
48 #include "memwrap.h"
49
50 #include "ca_configFns.h"
51 #include "ca_macros.h"
52 #include "ca_srcAttribs.h"
53
54 #include "sk.h"
55
56 void error_init(int argc, char ** argv) {
/* [<][>][^][v][top][bottom][index][help] */
57 char *slash;
58 char progname[32];
59
60 slash = strrchr(argv[0],'/');
61 strncpy(progname, (slash != NULL) ? slash+1 : argv[0], 31);
62 progname[31]=0;
63
64
65 ER_init(progname, 1);
66
67 #if 0
68 /* add one more definition */
69 {
70 char *err_msg = NULL;
71 char *buf =
72 "CREATE test { FORMAT SEVCHAR|FACSYMB|TEXTLONG|DATETIME SOCK 2 }"
73 "( FAC rp ASP RP_SRCH_GEN|RP_SRCH_DET|RP_LOAD_GEN SEV d-f ) "
74 "( FAC QI|SQ ASP SQ_QRYTIME | QI_COLL_GEN SEV d-f )"
75 "( FAC PW ASP PW_I_QRYLOG SEV I-f )"
76 "( FAC ALL SEV E- )"
77 /* "( FAC SV ASP SV_PORT SEV d )" */
78 ;
79
80 int parsres = ER_parse_spec(buf, &err_msg);
81
82 if( parsres != 0 ) { /* print only on failure */
83 puts(err_msg);
84 }
85
86 wr_free(err_msg);
87
88 dieif( parsres != 0 );
89 }
90 #endif
91
92 } /* error_init() */
93
94 int main(int argc, char** argv) {
/* [<][>][^][v][top][bottom][index][help] */
95 char *prop_file_name;
96 char *result;
97 sigset_t sset;
98
99 /* Initialize GLib library to be thread-safe */
100 g_thread_init(NULL);
101
102 /* Create signal handling thread and block signals for others */
103 /* printf("Starting the signal handler\n");*/
104 TH_create((void *(*)(void *))SV_signal_thread, NULL);
105
106 sigemptyset(&sset);
107 /* SIGTERM will switch the updates on and off */
108 sigaddset(&sset, SIGTERM);
109 /* SIGINT stops all servers by setting do_server to 0 */
110 sigaddset(&sset, SIGINT);
111 pthread_sigmask(SIG_BLOCK, &sset, NULL);
112
113
114 /* 1. Get the config file name from argv[1] */
115 if (argc == 2) {
116 prop_file_name = (char *)calloc(1, strlen(argv[1])+1 );
117 strcpy(prop_file_name,argv[1]);
118 } else {
119 die;
120 }
121
122 /* 3. Set the constants. */
123 /* fprintf(stderr,"Constants:\n"); */
124 result=CO_set();
125 free(result);
126 fprintf(stderr,"Configuration [%s]:\n", prop_file_name);
127 ca_init(prop_file_name);
128
129 /* Initialize error handling */
130 error_init(argc, argv);
131
132 /* 4. Start the server */
133 SV_start();
134
135 return(0);
136
137 } /* main() */
138