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.15 $
   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 #include "ca_configFns.h"
  51 #include "ca_dictSyms.h"
  52 #include "ca_macros.h"
  53 #include "ca_srcAttribs.h"
  54 
  55 
  56 void error_init(int argc, char ** argv) {
     /* [<][>][^][v][top][bottom][index][help] */
  57   er_path_t erlogstr;
  58 
  59   ER_init(argc, argv);
  60 
  61   erlogstr.fdes = stdout;
  62   erlogstr.asp  =  0;
  63   /* 0xfff00000; */
  64   /* ASP_QI_LAST_DET; */
  65   /* 0xffffffff; */
  66   erlogstr.fac  = 0; /* FAC_QI; */
  67      
  68   erlogstr.sev  = ER_SEV_I;
  69   erlogstr.mode = ER_M_SEVCHAR | ER_M_FACSYMB | ER_M_TEXTLONG | ER_M_DATETIME;
  70 
  71   ER_setpath(& erlogstr);  
  72 
  73 } /* error_init() */
  74 
  75 int main(int argc, char** argv) {
     /* [<][>][^][v][top][bottom][index][help] */
  76   char *prop_file_name;                                              /* 1. */
  77   char *consts;
  78   char *props;
  79   char *result;
  80   sigset_t sset;
  81 
  82 
  83 /* Initialize GLib library to be thread-safe */
  84    g_thread_init(NULL); 
  85 
  86 /* Create signal handling thread and block signals for others */
  87    printf("Starting the signal handler\n");
  88    TH_create((void *(*)(void *))SV_signal_thread, NULL);
  89      
  90    sigemptyset(&sset);
  91    /* SIGTERM will switch the updates on and off */
  92    sigaddset(&sset, SIGTERM);
  93    /* SIGINT stops all servers by setting do_server to 0 */
  94    sigaddset(&sset, SIGINT); 
  95    pthread_sigmask(SIG_BLOCK, &sset, NULL);
  96            
  97   /* Initialize error handling */
  98   error_init(argc, argv);
  99 
 100   /* 1. Get the properties file name from argv[1] (Defaults to ".properties" if none specified) */
 101   if (argc == 2) {
 102     prop_file_name = (char *)calloc(1, strlen(argv[1])+1 );
 103     strcpy(prop_file_name,argv[1]);
 104   } else { 
 105     prop_file_name = (char *)calloc(1, strlen(DEFAULT_PROP_FILE_NAME)+1 );
 106     strcpy(prop_file_name, DEFAULT_PROP_FILE_NAME);
 107   }
 108 
 109   printf("Loading properties from prop_file_name=%s\n", prop_file_name);
 110 
 111   /* 2. Load properties object from prop_file. */
 112   fprintf(stderr,"Properties:\n");
 113   PR_load(prop_file_name);
 114   props= PR_to_string();
 115   fprintf(stderr,"%s\n", props ); free(props);
 116 
 117  /* 3. Set the constants. */
 118   fprintf(stderr,"Constants:\n");  
 119   result=CO_set(); free(result);
 120   consts=CO_to_string();
 121   fprintf(stderr,"%s\n", consts ); free(consts);
 122 
 123  /* 3a. Populate dictionary and load config */
 124   ca_populateDictionary(dictionary, VARS);
 125   ca_readConfig(CO_get_config_file(), confVars, VARS);
 126   fprintf(stderr, "Configuration file: %s - ok\n", CO_get_config_file());
 127 
 128 
 129   /* 4. Start the server */
 130   SV_start();
 131 
 132   return(0);
 133 
 134 } /* main() */
 135 

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