bin/rip/whois_rip.c

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. error_init
  2. main

   1 /***************************************
   2   $Revision: 1.12 $
   3 
   4   Example code: Upper case server.
   5 
   6   Status: NOT REVUED, NOT TESTED
   7 
   8   Author:       Chris Ottrey
   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 #define DEFAULT_PROP_FILE_NAME ".properties"
  41 
  42 #include <signal.h>
  43 #include "erroutines.h"
  44 #include "constants.h"
  45 #include "properties.h"
  46 #include "server.h"
  47 #include "bitmask.h"
  48 #include "thread.h"
  49 
  50 void error_init(int argc, char ** argv) {
     /* [<][>][^][v][top][bottom][index][help] */
  51   er_path_t erlogstr;
  52 
  53   ER_init(argc, argv);
  54 
  55   erlogstr.fdes = stderr;
  56   erlogstr.asp  =  0;
  57   /* 0xfff00000; */
  58   /* ASP_QI_LAST_DET; */
  59   /* 0xffffffff; */
  60   erlogstr.fac  = 0; /* FAC_QI; */
  61      
  62   erlogstr.sev  = ER_SEV_I;
  63   erlogstr.mode = ER_M_SEVCHAR | ER_M_FACSYMB | ER_M_TEXTLONG;
  64 
  65   ER_setpath(& erlogstr);  
  66 
  67 } /* error_init() */
  68 
  69 int main(int argc, char** argv) {
     /* [<][>][^][v][top][bottom][index][help] */
  70   char *prop_file_name;                                              /* 1. */
  71   char *consts;
  72   char *props;
  73   char *result;
  74   sigset_t sset;
  75 
  76 
  77 /* Initialize GLib library to be thread-safe */
  78    g_thread_init(NULL);
  79 
  80 
  81 /* Create signal handling thread and block signals for others */
  82    printf("Starting the signal handler\n");
  83    TH_create((void *(*)(void *))SV_signal_thread, NULL);
  84      
  85    sigemptyset(&sset);
  86    /* SIGTERM will switch the updates on and off */
  87    sigaddset(&sset, SIGTERM);
  88    /* SIGINT stops all servers by setting do_server to 0 */
  89    sigaddset(&sset, SIGINT); 
  90    pthread_sigmask(SIG_BLOCK, &sset, NULL);
  91            
  92   /* Initialize error handling */
  93   error_init(argc, argv);
  94 
  95   /* 1. Get the properties file name from argv[1] (Defaults to ".properties" if none specified) */
  96   if (argc == 2) {
  97     prop_file_name = (char *)calloc(1, strlen(argv[1])+1 );
  98     strcpy(prop_file_name,argv[1]);
  99   } else { 
 100     prop_file_name = (char *)calloc(1, strlen(DEFAULT_PROP_FILE_NAME)+1 );
 101     strcpy(prop_file_name, DEFAULT_PROP_FILE_NAME);
 102   }
 103 
 104   printf("Loading properties from prop_file_name=%s\n", prop_file_name);
 105 
 106   /* 2. Load properties object from prop_file. */
 107   fprintf(stderr,"Properties:\n");
 108   PR_load(prop_file_name);
 109   props= PR_to_string();
 110   fprintf(stderr,"%s\n", props ); free(props);
 111 
 112   /* 3. Set the constants. */
 113   fprintf(stderr,"Constants:\n");  
 114   result=CO_set(); free(result);
 115   consts=CO_to_string();
 116   fprintf(stderr,"%s\n", consts ); free(consts);
 117 
 118   /* 4. Start the server */
 119   SV_start();
 120 
 121   return(0);
 122 
 123 } /* main() */
 124 

/* [<][>][^][v][top][bottom][index][help] */