Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

perfsvr.cc File Reference

#include "rcs_defs.hh"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cms_cfg.hh"
#include "nml.hh"
#include "nml_srv.hh"
#include "nmlmsg.hh"
#include "cms.hh"
#include "rcs_prnt.hh"
#include "timer.hh"
#include "perftype.hh"

Include dependency graph for perfsvr.cc:

Include dependency graph

Go to the source code of this file.

Defines

#define MAX_NML_CHANNELS   100

Functions

int run_perfsvr (char *config_file, char *host_name)
int main (int argc, char **argv)

Variables

char program_id [] = "perfsvr version 1.7 compiled on " __DATE__
char * default_perfsvr_config_file = "test.nml"
char * default_perfsvr_host_name = "localhost"


Define Documentation

#define MAX_NML_CHANNELS   100
 

Definition at line 32 of file perfsvr.cc.


Function Documentation

int run_perfsvr char *    config_file,
char *    host_name
 

Definition at line 135 of file perfsvr.cc.

00136 {
00137   FILE *fp;
00138   char line[CMS_CONFIG_LINELEN];
00139   int line_len, line_number = 0;
00140   char buffer_name[CMS_CONFIG_LINELEN];
00141   char buffer_host[CMS_CONFIG_LINELEN];
00142   NML *nml_channel[MAX_NML_CHANNELS];
00143   int num_nml_channels;
00144 
00145   /* Open the configuration file. */
00146   if ((fp = fopen(config_file, "r")) == NULL)
00147   {
00148     rcs_print_error("nmlperf: Can't open '%s'\n", config_file);
00149     exit(-1);
00150   }
00151 
00152   /* Read the configuration file line by line to find buffers. */
00153   num_nml_channels = 0;
00154   while (!feof(fp) && num_nml_channels < MAX_NML_CHANNELS)
00155   {
00156     if ((fgets(line, CMS_CONFIG_LINELEN, fp)) == NULL)
00157     {
00158       break;
00159     }
00160 
00161     line_number++;
00162     line_len = strlen(line);
00163     if(line_len > CMS_CONFIG_LINELEN)
00164     {
00165       rcs_print_error("cms_cfg: Line length of line number %d in %s exceeds max length of %d", line_number, config_file, CMS_CONFIG_LINELEN);
00166     }
00167 
00168     if(line_len > 1)
00169     {
00170       if(line[line_len-2] == '\\' )
00171       {
00172         if ((fgets(line+line_len-2, CMS_CONFIG_LINELEN-line_len, fp)) == NULL)
00173         {
00174           break;
00175         }
00176         line_number++;
00177       }
00178     }
00179 
00180     if(line[0] != 'B')
00181     {
00182       continue;
00183     }
00184 
00185     sscanf(line+1, "%s %*s %s", buffer_name, buffer_host);
00186 
00187     /* Try to connect locally if the buffer host matches this one. */
00188 
00189     if(!strcmp(buffer_host, host_name))
00190     {
00191       printf("\nAttempting to connect to %s locally . . .\n",buffer_name);
00192       nml_channel[num_nml_channels] = new NML(perf_types_format,buffer_name,"perfsvr", config_file);
00193       num_nml_channels++;
00194     }
00195   }
00196 
00197   if(NULL != fp)
00198     {
00199       fclose(fp);
00200       fp = NULL;
00201     }
00202 
00203   printf("Press Control-C to stop server(s).\n");
00204   run_nml_servers();
00205   return 0;
00206 }

int main int    argc,
char **    argv
 

Definition at line 60 of file perfsvr.cc.

00062 {
00063 
00064 
00065   //set_rcs_print_destination(RCS_PRINT_TO_STDOUT);
00066   //set_rcs_print_flag(PRINT_EVERYTHING);
00067 
00068   /* Print File name, version, and compile date. */
00069   rcs_puts(program_id);
00070   rcs_errors_printed = 0;
00071   if(max_rcs_errors_to_print < 40)
00072     {
00073       max_rcs_errors_to_print = 40;
00074     }
00075 
00076 
00077 #ifndef VXWORKS
00078   char config_file[80];
00079   char host_name[80];
00080   printf("PERFSVR:\n");
00081   if(argc > 2)
00082   {
00083     /* Get host_name and config_file from command line */
00084     strcpy(config_file, argv[1]);
00085     strcpy(host_name, argv[2]);
00086    }
00087   else
00088   {
00089     /* Prompt user for config_file and host name */
00090     printf("Configuration File? [%s]", default_perfsvr_config_file);
00091     fgets(config_file,80,stdin);
00092     if(config_file[0] == 0 || config_file[0] == '\r' || config_file[0] == '\n')
00093       {
00094         strncpy(config_file, default_perfsvr_config_file, 80);
00095       }
00096 
00097     printf("Host Name? [%s]", default_perfsvr_host_name);
00098     fgets(host_name,80,stdin);
00099      if(host_name[0] == 0 || host_name[0] == '\r' || host_name[0] == '\n')
00100       {
00101         strncpy(host_name, default_perfsvr_host_name, 80);
00102       }
00103 }
00104 
00105 
00106   printf("print everything ? (y/n) ");
00107   char print_everything[16];
00108   fgets(print_everything, 16, stdin);
00109   if(print_everything[0] == 'y' || print_everything[0] == 'Y')
00110   {
00111     set_rcs_print_flag(PRINT_EVERYTHING);
00112   }
00113   run_perfsvr(config_file,host_name);
00114 #else
00115 
00116   if(config_file == NULL)
00117     {
00118       config_file = default_perfsvr_config_file;
00119     }
00120   if(host_name == NULL)
00121     {
00122       host_name = default_perfsvr_host_name;
00123     }
00124 
00125   if(print_everything == 1)
00126    {
00127     set_rcs_print_flag(PRINT_EVERYTHING);
00128   }
00129   perfsvr_tid = taskSpawn("tperfsvr",100,VX_FP_TASK,0x4000, (FUNCPTR) run_perfsvr,
00130             config_file, host_name,0,0,0,
00131             0,0,0,0,0);
00132 #endif
00133 }


Variable Documentation

char program_id[] = "perfsvr version 1.7 compiled on " __DATE__ [static]
 

Definition at line 2 of file perfsvr.cc.

char* default_perfsvr_config_file = "test.nml"
 

Definition at line 33 of file perfsvr.cc.

char* default_perfsvr_host_name = "localhost"
 

Definition at line 34 of file perfsvr.cc.


Generated on Sun Dec 2 15:57:26 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001