#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "linklist.hh"
#include "rcs_prnt.hh"
#include "cms.hh"
Include dependency graph for nmlcfg.cc:
Go to the source code of this file.
|
Definition at line 50 of file nmlcfg.cc. 00051 { 00052 NO_OPS, 00053 READ_ONLY, 00054 WRITE_ONLY, 00055 READ_WRITE 00056 }; |
|
Definition at line 336 of file nmlcfg.cc. Referenced by main().
00337 { 00338 char line[256]; 00339 int linelen = 0; 00340 FILE *fp = NULL; 00341 char *include_dir; 00342 char tempfile[256]; 00343 int templinenum; 00344 00345 fp = fopen (filename, "r"); 00346 if (NULL == fp) 00347 { 00348 include_dir = (char *) include_dir_list.get_head (); 00349 while (fp == NULL && include_dir != NULL) 00350 { 00351 strncpy (tempfile, include_dir, 256); 00352 strcat (tempfile, "/"); 00353 strcat (tempfile, filename); 00354 fp = fopen (filename, "r"); 00355 } 00356 } 00357 else 00358 { 00359 strncpy (tempfile, filename, 256); 00360 } 00361 current_config_file = tempfile; 00362 linenum = templinenum = 0; 00363 if (NULL == fp) 00364 { 00365 fprintf (stderr, "Can't open file %s.\n", filename); 00366 exit (-1); 00367 } 00368 while (!feof (fp)) 00369 { 00370 memset (line, 0, 256); 00371 if (NULL == fgets (line, 256, fp)) 00372 { 00373 fclose (fp); 00374 return 0; 00375 } 00376 templinenum++; 00377 linenum = templinenum; 00378 linelen = strlen (line); 00379 if (linelen < 1) 00380 { 00381 continue; 00382 } 00383 while (linelen > 0) 00384 { 00385 if (line[linelen - 1] == '\r' || 00386 line[linelen - 1] == '\n' || 00387 line[linelen - 1] == '\t' || line[linelen - 1] == ' ') 00388 { 00389 line[linelen - 1] = 0; 00390 linelen--; 00391 continue; 00392 } 00393 if (line[linelen - 1] == '\\') 00394 { 00395 line[linelen - 1] = 0; 00396 linelen--; 00397 if (NULL == fgets (line + linelen, 256 - linelen, fp)) 00398 { 00399 fclose (fp); 00400 return 0; 00401 } 00402 templinenum++; 00403 linenum = templinenum; 00404 linelen = strlen (line); 00405 continue; 00406 } 00407 break; 00408 } 00409 if (nmlcfg_verbose) 00410 { 00411 printf ("%d %s\n", linenum, line); 00412 } 00413 if (linelen < 1) 00414 { 00415 if (!last_line_blank) 00416 { 00417 comments.store_at_tail ((void *) " ", 2, 1); 00418 } 00419 last_line_blank = 1; 00420 continue; 00421 } 00422 replace_defined_variables (line); 00423 if (line[0] == '#') 00424 { 00425 if (line[1] == '#') 00426 { 00427 last_line_blank = 0; 00428 comments.store_at_tail (line + 1, 255, 1); 00429 } 00430 continue; 00431 } 00432 if (!strncmp (line, "buffer_default", 14) 00433 || !strncmp (line, "BUFFER_DEFAULT", 14)) 00434 { 00435 parse_buffer_info (line, &default_buffer); 00436 continue; 00437 } 00438 if (!strncmp (line, "process_default", 14) 00439 || !strncmp (line, "PROCESS_DEFAULT", 14)) 00440 { 00441 parse_process_info (line, &default_process); 00442 continue; 00443 } 00444 if (!strncmp (line, "include", 7) || !strncmp (line, "INCLUDE", 7)) 00445 { 00446 char *fnptr = line + 7; 00447 while (*fnptr == ' ' || *fnptr == '\t') 00448 { 00449 fnptr++; 00450 } 00451 nmlcfg_read_file (fnptr); 00452 current_config_file = tempfile; 00453 continue; 00454 } 00455 if (!strncmp (line, "define", 6) || !strncmp (line, "DEFINE", 6)) 00456 { 00457 add_nmlcfg_var (line); 00458 continue; 00459 } 00460 last_line_blank = 0; 00461 if (line[0] == 'b' || line[0] == 'B') 00462 { 00463 temp_buffer_info.initialize (); 00464 strcpy (temp_buffer_info.host, default_buffer.host); 00465 temp_buffer_info.buftype = default_buffer.buftype; 00466 temp_buffer_info.size = default_buffer.size; 00467 temp_buffer_info.brpi = default_buffer.brpi; 00468 temp_buffer_info.neut = default_buffer.neut; 00469 temp_buffer_info.buffer_number = default_buffer.buffer_number; 00470 temp_buffer_info.shmem_key = default_buffer.shmem_key; 00471 temp_buffer_info.bsem_key = default_buffer.bsem_key; 00472 temp_buffer_info.max_proc = default_buffer.max_proc; 00473 temp_buffer_info.vme_addr = default_buffer.vme_addr; 00474 temp_buffer_info.remotetype = default_buffer.remotetype; 00475 temp_buffer_info.remote_port = default_buffer.remote_port; 00476 temp_buffer_info.encoding_type = default_buffer.encoding_type; 00477 temp_buffer_info.queue = default_buffer.queue; 00478 temp_buffer_info.enable_diag = default_buffer.enable_diag; 00479 temp_buffer_info.use_autocnum = default_buffer.use_autocnum; 00480 temp_buffer_info.comment_num = comments.list_size; 00481 parse_buffer_info (line, &temp_buffer_info); 00482 temp_buffer_info.orig_size = temp_buffer_info.size; 00483 if (!temp_buffer_info.oldstyle) 00484 { 00485 if (temp_buffer_info.queue > 1) 00486 { 00487 temp_buffer_info.size *= temp_buffer_info.queue; 00488 temp_buffer_info.size += temp_buffer_info.queue * 12; 00489 } 00490 if (temp_buffer_info.queue) 00491 { 00492 temp_buffer_info.size += 20; 00493 } 00494 temp_buffer_info.size += 64; 00495 if (temp_buffer_info.size % 64) 00496 { 00497 temp_buffer_info.size += 00498 (64 - (temp_buffer_info.size % 64)); 00499 } 00500 if (temp_buffer_info.buftype == CMS_GLOBMEM_TYPE 00501 && temp_buffer_info.enable_diag) 00502 { 00503 if (temp_buffer_info.max_proc > 1) 00504 { 00505 temp_buffer_info.size += 00506 144 * temp_buffer_info.max_proc; 00507 } 00508 else 00509 { 00510 // This assumes only 5 buffers connect. 00511 temp_buffer_info.size += 720; 00512 } 00513 } 00514 00515 } 00516 check_buffer_info (&temp_buffer_info); 00517 strcat (temp_buffer_info.endline, default_buffer.endline); 00518 buffer_list.store_at_tail (&temp_buffer_info, sizeof (BUFFER_INFO), 00519 1); 00520 if (!temp_buffer_info.oldstyle) 00521 { 00522 if (temp_buffer_info.buftype == CMS_GLOBMEM_TYPE 00523 && default_buffer.vme_addr > 0) 00524 { 00525 default_buffer.vme_addr += temp_buffer_info.size; 00526 } 00527 if (temp_buffer_info.buftype == CMS_SHMEM_TYPE) 00528 { 00529 default_buffer.shmem_key++; 00530 if (default_buffer.bsem_key > 0) 00531 { 00532 default_buffer.bsem_key++; 00533 } 00534 } 00535 default_buffer.buffer_number++; 00536 } 00537 continue; 00538 } 00539 if (line[0] == 'p' || line[0] == 'P') 00540 { 00541 temp_process_info.initialize (); 00542 strcpy (temp_process_info.host, default_process.host); 00543 strcpy (temp_process_info.name, default_process.name); 00544 strcpy (temp_process_info.bufname, default_process.bufname); 00545 temp_process_info.proctype = default_process.proctype; 00546 temp_process_info.subscription_interval = 00547 default_process.subscription_interval; 00548 temp_process_info.retry_interval = default_process.retry_interval; 00549 temp_process_info.timeout = default_process.timeout; 00550 temp_process_info.c_num = default_process.c_num; 00551 temp_process_info.isserver = default_process.isserver; 00552 temp_process_info.master = default_process.master; 00553 temp_process_info.ops = default_process.ops; 00554 temp_process_info.comment_num = comments.list_size; 00555 parse_process_info (line, &temp_process_info); 00556 check_process_info (&temp_process_info); 00557 strcat (temp_process_info.endline, default_process.endline); 00558 process_list.store_at_tail (&temp_process_info, 00559 sizeof (PROCESS_INFO), 1); 00560 continue; 00561 } 00562 rcs_print_error ("%s:%d: Line of config file was not recognized.\n", 00563 current_config_file, linenum); 00564 rcs_print_error ("%s:%d: -->%s\n", current_config_file, linenum, line); 00565 } 00566 fclose (fp); 00567 current_config_file = unknown_config_file; 00568 return (0); 00569 } |
|
Definition at line 1510 of file nmlcfg.cc. Referenced by parse_buffer_info(), and parse_process_info().
01511 { 01512 if (str[0] == 'y' || str[0] == 'Y' || str[0] == 't' || str[0] == 'T') 01513 { 01514 return 1; 01515 } 01516 if (str[0] >= '0' && str[0] <= '9') 01517 { 01518 return atol (str); 01519 } 01520 return 0; 01521 } |
|
Definition at line 900 of file nmlcfg.cc. Referenced by nmlcfg_read_file().
00901 { 00902 char *word[32]; 00903 bi->oldstyle = (NULL == strstr (bufline, "name=")) 00904 && (NULL == strstr (bufline, "default")); 00905 int num_words = separate_words (word, 32, bufline); 00906 if (bi->oldstyle) 00907 { 00908 if (num_words < 9) 00909 { 00910 rcs_print_error ("%s:%d Invalid line\n", 00911 current_config_file, linenum); 00912 return -1; 00913 } 00914 bi->queue = 0; 00915 bi->use_autocnum = 0; 00916 bi->enable_diag = 0; 00917 bi->bsem_key = -1; 00918 strcpy (bi->name, word[1]); 00919 strcpy (bi->host, word[3]); 00920 char *buffer_type_name = word[2]; 00921 /* Determine the BufferType. */ 00922 if (!strcmp (buffer_type_name, "SHMEM")) 00923 { 00924 bi->buftype = CMS_SHMEM_TYPE; 00925 } 00926 else if (!strcmp (buffer_type_name, "GLOBMEM")) 00927 { 00928 bi->buftype = CMS_GLOBMEM_TYPE; 00929 } 00930 else if (!strcmp (buffer_type_name, "BBDMEM")) 00931 { 00932 bi->buftype = CMS_BBDMEM_TYPE; 00933 } 00934 else if (!strcmp (buffer_type_name, "PHANTOM")) 00935 { 00936 bi->buftype = CMS_PHANTOM_BUFFER; 00937 } 00938 else if (!strcmp (buffer_type_name, "LOCMEM")) 00939 { 00940 bi->buftype = CMS_LOCMEM_TYPE; 00941 } 00942 else if (!strcmp (buffer_type_name, "FILEMEM")) 00943 { 00944 bi->buftype = CMS_FILEMEM_TYPE; 00945 } 00946 else 00947 { 00948 rcs_print_error ("%s:%d: CMS: invalid buffer type (%s)\n", 00949 current_config_file, linenum, buffer_type_name); 00950 exit (-1); 00951 } 00952 00953 bi->size = (long) atol (word[4]); 00954 bi->neut = (int) atol (word[5]); 00955 bi->buffer_number = atol (word[7]); 00956 bi->max_proc = atol (word[8]); 00957 memset (bi->endline, 0, 80); 00958 int last_word = 9; 00959 if (bi->buftype == CMS_SHMEM_TYPE) 00960 { 00961 bi->shmem_key = atol (word[9]); 00962 last_word = 10; 00963 } 00964 for (int i = last_word; i < num_words - 1; i++) 00965 { 00966 if (NULL == word[i]) 00967 { 00968 break; 00969 } 00970 strcat (bi->endline, " "); 00971 strcat (bi->endline, word[i]); 00972 } 00973 } 00974 else 00975 { 00976 for (int i = 1; i < num_words - 1; i++) 00977 { 00978 if (NULL == word[i]) 00979 { 00980 break; 00981 } 00982 00983 if (!strncmp (word[i], "bufname=", 8) 00984 || !strncmp (word[i], "BUFNAME=", 8)) 00985 { 00986 strncpy (bi->name, ((char *) word[i]) + 8, 80); 00987 continue; 00988 } 00989 if (!strncmp (word[i], "name=", 5) 00990 || !strncmp (word[i], "NAME=", 5)) 00991 { 00992 strncpy (bi->name, ((char *) word[i]) + 5, 80); 00993 continue; 00994 } 00995 if (!strncmp (word[i], "bufhost=", 8) 00996 || !strncmp (word[i], "BUFHOST=", 8)) 00997 { 00998 strncpy (bi->host, ((char *) word[i]) + 8, 80); 00999 continue; 01000 } 01001 if (!strncmp (word[i], "host=", 5) 01002 || !strncmp (word[i], "HOST=", 5)) 01003 { 01004 strncpy (bi->host, ((char *) word[i]) + 5, 80); 01005 continue; 01006 } 01007 if (!strncmp (word[i], "buftype=", 8) 01008 || !strncmp (word[i], "BUFTYPE=", 8)) 01009 { 01010 char *buffer_type_name = ((char *) word[i]) + 8; 01011 if (!strncmp (buffer_type_name, "SHMEM", 5) || 01012 !strncmp (buffer_type_name, "shmem", 5)) 01013 { 01014 bi->buftype = CMS_SHMEM_TYPE; 01015 } 01016 else if (!strcmp (buffer_type_name, "GLOBMEM") || 01017 !strcmp (buffer_type_name, "globmem")) 01018 { 01019 bi->buftype = CMS_GLOBMEM_TYPE; 01020 } 01021 else if (!strcmp (buffer_type_name, "BBDMEM") || 01022 !strcmp (buffer_type_name, "bbdmem") || 01023 !strcmp (buffer_type_name, "BBD") || 01024 !strcmp (buffer_type_name, "bbd")) 01025 { 01026 bi->buftype = CMS_BBDMEM_TYPE; 01027 } 01028 else if (!strcmp (buffer_type_name, "PHANTOM") || 01029 !strcmp (buffer_type_name, "phantom")) 01030 { 01031 bi->buftype = CMS_PHANTOM_BUFFER; 01032 } 01033 else if (!strcmp (buffer_type_name, "LOCMEM") || 01034 !strcmp (buffer_type_name, "locmem")) 01035 { 01036 bi->buftype = CMS_LOCMEM_TYPE; 01037 } 01038 else if (!strcmp (buffer_type_name, "FILEMEM") || 01039 !strcmp (buffer_type_name, "filemem")) 01040 { 01041 bi->buftype = CMS_FILEMEM_TYPE; 01042 } 01043 else 01044 { 01045 rcs_print_error 01046 ("%s:%d: CMS Invalid buffer type (%s) on line %d of %s\n", 01047 current_config_file, linenum, buffer_type_name); 01048 exit (-1); 01049 } 01050 continue; 01051 } 01052 if (!strncmp (word[i], "size=", 5) 01053 || !strncmp (word[i], "SIZE=", 5)) 01054 { 01055 bi->size = strtoul (((char *) word[i]) + 5, NULL, 0); 01056 continue; 01057 } 01058 if (!strncmp (word[i], "brpi=", 5) 01059 || !strncmp (word[i], "BRPI=", 5)) 01060 { 01061 bi->brpi = strtod (((char *) word[i]) + 5, NULL); 01062 continue; 01063 } 01064 if (!strncmp (word[i], "bbd_size=", 9) 01065 || !strncmp (word[i], "BBD_SIZE=", 9)) 01066 { 01067 bi->bbd_size = strtol (((char *) word[i]) + 9, NULL, 0); 01068 continue; 01069 } 01070 if (!strncmp (word[i], "force_type=", 11) 01071 || !strncmp (word[i], "force_type=", 11)) 01072 { 01073 bi->force_type = strtol (((char *) word[i]) + 11, NULL, 0); 01074 continue; 01075 } 01076 if (!strncmp (word[i], "neut=", 5) 01077 || !strncmp (word[i], "NEUT=", 5)) 01078 { 01079 bi->neut = is_true (((char *) word[i]) + 5); 01080 continue; 01081 } 01082 if (!strncmp (word[i], "neutral=", 8) 01083 || !strncmp (word[i], "NEUTRAL=", 8)) 01084 { 01085 bi->neut = is_true (((char *) word[i]) + 8); 01086 continue; 01087 } 01088 if (!strncmp (word[i], "buffer_number=", 14) 01089 || !strncmp (word[i], "BUFFER_NUMBER=", 14)) 01090 { 01091 bi->buffer_number = strtol (((char *) word[i]) + 5, NULL, 0); 01092 continue; 01093 } 01094 if (!strncmp (word[i], "bufnumber=", 10) 01095 || !strncmp (word[i], "BUFNUMBER=", 10)) 01096 { 01097 bi->buffer_number = strtol (((char *) word[i]) + 10, NULL, 0); 01098 continue; 01099 } 01100 if (!strncmp (word[i], "bufnumber=", 10) 01101 || !strncmp (word[i], "BUFNUMBER=", 10)) 01102 { 01103 bi->buffer_number = strtol (((char *) word[i]) + 10, NULL, 0); 01104 continue; 01105 } 01106 if (!strncmp (word[i], "key=", 4) || !strncmp (word[i], "KEY=", 4)) 01107 { 01108 bi->shmem_key = strtol (((char *) word[i]) + 4, NULL, 0); 01109 continue; 01110 } 01111 if (!strncmp (word[i], "bsem=", 5) 01112 || !strncmp (word[i], "BSEM=", 5)) 01113 { 01114 bi->bsem_key = strtol (((char *) word[i]) + 5, NULL, 0); 01115 continue; 01116 } 01117 if (!strncmp (word[i], "max_proc=", 9) 01118 || !strncmp (word[i], "MAX_PROC=", 9)) 01119 { 01120 bi->max_proc = strtol (((char *) word[i]) + 9, NULL, 0); 01121 continue; 01122 } 01123 if (!strncmp (word[i], "vme_addr=", 9) 01124 || !strncmp (word[i], "VME_ADDR=", 9)) 01125 { 01126 bi->vme_addr = strtoul (((char *) word[i]) + 9, NULL, 0); 01127 continue; 01128 } 01129 if (!strncmp (word[i], "remotetype=", 11) 01130 || !strncmp (word[i], "REMOTETYPE=", 11)) 01131 { 01132 char *remote_type_name = ((char *) word[i]) + 11; 01133 if (!strncmp (remote_type_name, "tcp", 3) || 01134 !strncmp (remote_type_name, "TCP", 3)) 01135 { 01136 bi->remotetype = CMS_TCP_REMOTE_PORT_TYPE; 01137 } 01138 else if (!strncmp (remote_type_name, "udp", 3) || 01139 !strncmp (remote_type_name, "UDP", 3)) 01140 { 01141 bi->remotetype = CMS_UDP_REMOTE_PORT_TYPE; 01142 } 01143 else if (!strncmp (remote_type_name, "stcp", 4) || 01144 !strncmp (remote_type_name, "STCP", 4)) 01145 { 01146 bi->remotetype = CMS_STCP_REMOTE_PORT_TYPE; 01147 } 01148 else 01149 { 01150 rcs_print_error ("%s:%d: Remote type not recognized %s\n", 01151 current_config_file, linenum, 01152 remote_type_name); 01153 exit (-1); 01154 } 01155 continue; 01156 } 01157 if (!strncmp (word[i], "remote_port=", 13) 01158 || !strncmp (word[i], "REMOTE_PORT=", 13)) 01159 { 01160 bi->remote_port = strtol (((char *) word[i]) + 13, NULL, 0); 01161 continue; 01162 } 01163 if (!strncmp (word[i], "port=", 5) 01164 || !strncmp (word[i], "PORT=", 5)) 01165 { 01166 bi->remote_port = strtol (((char *) word[i]) + 5, NULL, 0); 01167 continue; 01168 } 01169 char *encoding_type_name = NULL; 01170 if (!strncmp (word[i], "enc=", 4) || !strncmp (word[i], "ENC=", 4)) 01171 { 01172 encoding_type_name = ((char *) word[i]) + 4; 01173 } 01174 else if (!strncmp (word[i], "encoding_type=", 14) 01175 || !strncmp (word[i], "ENCODING_TYPE=", 14)) 01176 { 01177 encoding_type_name = ((char *) word[i]) + 14; 01178 } 01179 if (NULL != encoding_type_name) 01180 { 01181 if (!strncmp (encoding_type_name, "xdr", 3) || 01182 !strncmp (encoding_type_name, "XDR", 3)) 01183 { 01184 bi->encoding_type = CMS_XDR_ENCODING; 01185 } 01186 else if (!strncmp (encoding_type_name, "ascii", 5) || 01187 !strncmp (encoding_type_name, "ASCII", 5)) 01188 { 01189 bi->encoding_type = CMS_DISPLAY_ASCII_ENCODING; 01190 } 01191 else if (!strncmp (encoding_type_name, "disp", 4) || 01192 !strncmp (encoding_type_name, "DISP", 4)) 01193 { 01194 bi->encoding_type = CMS_DISPLAY_ASCII_ENCODING; 01195 } 01196 else if (!strncmp (encoding_type_name, "display", 7) || 01197 !strncmp (encoding_type_name, "DISPLAY", 7)) 01198 { 01199 bi->encoding_type = CMS_DISPLAY_ASCII_ENCODING; 01200 } 01201 else 01202 { 01203 rcs_print_error 01204 ("%s:%d: Unknown encoding type %d on line %d of %s\n", 01205 current_config_file, linenum, encoding_type_name); 01206 exit (-1); 01207 } 01208 continue; 01209 } 01210 if (!strncmp (word[i], "queue=", 6) 01211 || !strncmp (word[i], "QUEUE=", 6)) 01212 { 01213 bi->queue = is_true (((char *) word[i]) + 6); 01214 continue; 01215 } 01216 if (!strncmp (word[i], "diag=", 5) 01217 || !strncmp (word[i], "DIAG=", 5)) 01218 { 01219 bi->enable_diag = is_true (((char *) word[i]) + 5); 01220 continue; 01221 } 01222 if (!strncmp (word[i], "autocnum=", 9) 01223 || !strncmp (word[i], "AUTOCNUM=", 9)) 01224 { 01225 bi->use_autocnum = is_true (((char *) word[i]) + 9); 01226 continue; 01227 } 01228 if (strncmp (word[i], "retry=", 6)) 01229 { 01230 if (warn) 01231 { 01232 rcs_print ("%s:%d: Warning: %s not recognized.\n", 01233 current_config_file, linenum, word[i]); 01234 } 01235 } 01236 strcat (bi->endline, " "); 01237 strcat (bi->endline, word[i]); 01238 } 01239 } 01240 return (0); 01241 } |
|
Definition at line 1246 of file nmlcfg.cc. Referenced by nmlcfg_read_file().
01247 { 01248 static int bad_cnums = 0; 01249 char *word[32]; 01250 pi->oldstyle = (NULL == strstr (bufline, "name=")) 01251 && (NULL == strstr (bufline, "default")); 01252 int num_words = separate_words (word, 32, bufline); 01253 if (pi->oldstyle) 01254 { 01255 if (num_words < 10) 01256 { 01257 rcs_print_error ("%s:%d: Invalid line\n", 01258 current_config_file, linenum); 01259 return -1; 01260 } 01261 pi->subscription_interval = 0; 01262 pi->retry_interval = 0; 01263 strcpy (pi->name, word[1]); 01264 if (!strncmp (pi->name, "default", 7)) 01265 { 01266 default_lines_detected = 1; 01267 } 01268 strcpy (pi->bufname, word[2]); 01269 if (!strncmp (pi->bufname, "default", 7)) 01270 { 01271 default_lines_detected = 1; 01272 } 01273 strcpy (pi->host, word[4]); 01274 char *process_type_name = word[3]; 01275 /* Determine the ProcessType. */ 01276 if (!strcmp (process_type_name, "REMOTE")) 01277 { 01278 pi->proctype = CMS_REMOTE_TYPE; 01279 } 01280 else if (!strcmp (process_type_name, "LOCAL")) 01281 { 01282 pi->proctype = CMS_LOCAL_TYPE; 01283 } 01284 else if (!strcmp (process_type_name, "PHANTOM")) 01285 { 01286 pi->proctype = CMS_PHANTOM_USER; 01287 } 01288 else if (!strcmp (process_type_name, "AUTO")) 01289 { 01290 pi->proctype = CMS_AUTO_TYPE; 01291 } 01292 else 01293 { 01294 rcs_print_error ("%s:%d: CMS: invalid process type (%s)\n", 01295 current_config_file, linenum, process_type_name); 01296 exit (-1); 01297 } 01298 pi->ops = NO_OPS; 01299 if (strstr (word[5], "R") != NULL) 01300 { 01301 pi->ops = READ_ONLY; 01302 } 01303 if (strstr (word[5], "W") != NULL) 01304 { 01305 if (pi->ops == READ_ONLY) 01306 { 01307 pi->ops = READ_WRITE; 01308 } 01309 else 01310 { 01311 pi->ops = WRITE_ONLY; 01312 } 01313 } 01314 pi->isserver = atol (word[6]); 01315 if (!strcmp (word[7], "INF")) 01316 { 01317 pi->timeout = -1.0; 01318 } 01319 else 01320 { 01321 pi->timeout = strtod (word[7], NULL); 01322 } 01323 if (NULL != word[8]) 01324 { 01325 pi->master = atol (word[8]); 01326 } 01327 if (word[9] != NULL) 01328 { 01329 pi->c_num = atol (word[9]); 01330 } 01331 else 01332 { 01333 pi->c_num = ++bad_cnums; 01334 } 01335 memset (pi->endline, 0, 80); 01336 int last_word = 10; 01337 for (int i = last_word; i < num_words - 1; i++) 01338 { 01339 if (NULL == word[i]) 01340 { 01341 break; 01342 } 01343 strcat (pi->endline, " "); 01344 strcat (pi->endline, word[i]); 01345 } 01346 } 01347 else 01348 { 01349 for (int i = 1; i < num_words - 1; i++) 01350 { 01351 if (NULL == word[i]) 01352 { 01353 break; 01354 } 01355 01356 if (!strncmp (word[i], "bufname=", 8) 01357 || !strncmp (word[i], "BUFNAME=", 8)) 01358 { 01359 strncpy (pi->bufname, ((char *) word[i]) + 8, 80); 01360 if (!strncmp (pi->bufname, "default", 7)) 01361 { 01362 default_lines_detected = 1; 01363 } 01364 continue; 01365 } 01366 if (!strncmp (word[i], "name=", 5) 01367 || !strncmp (word[i], "NAME=", 5)) 01368 { 01369 strncpy (pi->name, ((char *) word[i]) + 5, 80); 01370 if (!strncmp (pi->name, "default", 7)) 01371 { 01372 default_lines_detected = 1; 01373 } 01374 continue; 01375 } 01376 if (!strncmp (word[i], "procname=", 9) 01377 || !strncmp (word[i], "PROCNAME=", 9)) 01378 { 01379 strncpy (pi->name, ((char *) word[i]) + 9, 80); 01380 continue; 01381 } 01382 if (!strncmp (word[i], "prochost=", 9) 01383 || !strncmp (word[i], "PROCHOST=", 9)) 01384 { 01385 strncpy (pi->host, ((char *) word[i]) + 9, 80); 01386 continue; 01387 } 01388 if (!strncmp (word[i], "host=", 5) 01389 || !strncmp (word[i], "HOST=", 5)) 01390 { 01391 strncpy (pi->host, ((char *) word[i]) + 5, 80); 01392 continue; 01393 } 01394 if (!strncmp (word[i], "proctype=", 9) 01395 || !strncmp (word[i], "PROCTYPE=", 9)) 01396 { 01397 char *process_type_name = ((char *) word[i]) + 9; 01398 if (!strncmp (process_type_name, "LOCAL", 5) || 01399 !strncmp (process_type_name, "local", 5)) 01400 { 01401 pi->proctype = CMS_LOCAL_TYPE; 01402 } 01403 else if (!strcmp (process_type_name, "REMOTE") || 01404 !strcmp (process_type_name, "remote")) 01405 { 01406 pi->proctype = CMS_REMOTE_TYPE; 01407 } 01408 else if (!strcmp (process_type_name, "PHANTOM") || 01409 !strcmp (process_type_name, "phantom")) 01410 { 01411 pi->proctype = CMS_PHANTOM_USER; 01412 } 01413 else if (!strcmp (process_type_name, "AUTO") || 01414 !strcmp (process_type_name, "auto")) 01415 { 01416 pi->proctype = CMS_AUTO_TYPE; 01417 } 01418 else 01419 { 01420 rcs_print_error ("%s:%d: CMS Invalid process type (%s)\n", 01421 current_config_file, linenum, 01422 process_type_name); 01423 exit (-1); 01424 } 01425 continue; 01426 } 01427 if (!strncmp (word[i], "ops=", 4) || !strncmp (word[i], "OPS=", 4)) 01428 { 01429 char *cops_ptr = word[i] + 4; 01430 pi->ops = NO_OPS; 01431 if (strstr (cops_ptr, "R") != NULL 01432 || strstr (cops_ptr, "r") != NULL) 01433 { 01434 pi->ops = READ_ONLY; 01435 } 01436 if (strstr (cops_ptr, "W") != NULL 01437 || strstr (cops_ptr, "w") != NULL) 01438 { 01439 if (pi->ops == READ_ONLY) 01440 { 01441 pi->ops = READ_WRITE; 01442 } 01443 else 01444 { 01445 pi->ops = WRITE_ONLY; 01446 } 01447 } 01448 continue; 01449 } 01450 if (!strncmp (word[i], "timeout=", 8) 01451 || !strncmp (word[i], "TIMEOUT=", 8)) 01452 { 01453 if (!strncmp (((char *) word[i]) + 8, "INF", 3) 01454 || !strncmp (((char *) word[i]) + 8, "inf", 3)) 01455 { 01456 pi->timeout = -1.0; 01457 } 01458 else 01459 { 01460 pi->timeout = strtod (((char *) word[i]) + 8, NULL); 01461 } 01462 continue; 01463 } 01464 if (!strncmp (word[i], "master=", 7) 01465 || !strncmp (word[i], "MASTER=", 7)) 01466 { 01467 pi->master = is_true (((char *) word[i]) + 7); 01468 continue; 01469 } 01470 if (!strncmp (word[i], "server=", 7) 01471 || !strncmp (word[i], "SERVER=", 7)) 01472 { 01473 pi->isserver = is_true (((char *) word[i]) + 7); 01474 continue; 01475 } 01476 if (!strncmp (word[i], "c_num=", 14) 01477 || !strncmp (word[i], "C_NUM=", 14)) 01478 { 01479 pi->c_num = strtol (((char *) word[i]) + 5, NULL, 0); 01480 continue; 01481 } 01482 if (!strncmp (word[i], "sub=", 4) || !strncmp (word[i], "SUB=", 4)) 01483 { 01484 pi->subscription_interval = 01485 strtod (((char *) word[i]) + 10, NULL); 01486 continue; 01487 } 01488 if (!strncmp (word[i], "retry=", 4) 01489 || !strncmp (word[i], "RETRY=", 4)) 01490 { 01491 pi->retry_interval = strtod (((char *) word[i]) + 10, NULL); 01492 strcat (pi->endline, " "); 01493 strcat (pi->endline, word[i]); 01494 continue; 01495 } 01496 if (warn) 01497 { 01498 rcs_print ("%s:%d: Warning: %s not recognized.\n", 01499 current_config_file, linenum, word[i]); 01500 } 01501 strcat (pi->endline, " "); 01502 strcat (pi->endline, word[i]); 01503 } 01504 } 01505 return (0); 01506 } |
|
Definition at line 776 of file nmlcfg.cc. Referenced by nmlcfg_read_file().
00777 { 00778 BUFFER_INFO *bi = (BUFFER_INFO *) buffer_list.get_head (); 00779 while (bi != NULL) 00780 { 00781 bi->bufline_line_number = linenum; 00782 if (!strcmp (bi_to_check->name, bi->name)) 00783 { 00784 rcs_print_error ("%s:%d: Error: More than one buffer line for %s\n", 00785 current_config_file, linenum, bi->name); 00786 exit (-1); 00787 break; 00788 } 00789 if (bi_to_check->buffer_number == bi->buffer_number) 00790 { 00791 if (warn) 00792 { 00793 rcs_print 00794 ("%s:%d: Warning %s and %s both have buffer_number %d\n", 00795 current_config_file, linenum, bi->name, bi_to_check->name, 00796 bi->buffer_number); 00797 } 00798 return (-1); 00799 } 00800 if (bi_to_check->buftype != bi->buftype) 00801 { 00802 bi = (BUFFER_INFO *) buffer_list.get_next (); 00803 continue; 00804 } 00805 if (bi->buftype == CMS_SHMEM_TYPE) 00806 { 00807 if (bi->shmem_key == bi_to_check->shmem_key) 00808 { 00809 if (warn) 00810 { 00811 rcs_print 00812 ("%s:%d: Warning: %s and %s both have shared mem key %d\n", 00813 current_config_file, linenum, bi->name, 00814 bi_to_check->name, bi->shmem_key); 00815 } 00816 return (-1); 00817 } 00818 if (bi->bsem_key == bi_to_check->bsem_key && bi->bsem_key > 0) 00819 { 00820 if (warn) 00821 { 00822 rcs_print 00823 ("%s:%d: Warning: %s and %s both have blocking semaphore key %d\n", 00824 current_config_file, linenum, bi->name, 00825 bi_to_check->name, bi->bsem_key); 00826 } 00827 return (-1); 00828 } 00829 if (bi->bsem_key == bi_to_check->shmem_key) 00830 { 00831 if (warn) 00832 { 00833 rcs_print 00834 ("%s:%d: Warning: The blocking semaphore key of %s conflicts with the shared memory key of %s which both equal %d\n", 00835 current_config_file, linenum, bi->name, 00836 bi_to_check->name, bi->bsem_key); 00837 } 00838 return (-1); 00839 } 00840 if (bi->shmem_key == bi_to_check->bsem_key) 00841 { 00842 if (warn) 00843 { 00844 rcs_print 00845 ("%s:%d: Warning: The blocking semaphore key of %s conflicts with the shared memory key of %s which both equal %d\n", 00846 current_config_file, linenum, bi_to_check->name, 00847 bi->name, bi->shmem_key); 00848 } 00849 return (-1); 00850 } 00851 } 00852 if (bi->buftype == CMS_GLOBMEM_TYPE) 00853 { 00854 if (bi_to_check->vme_addr <= 0 && !bi_to_check->oldstyle) 00855 { 00856 if (warn) 00857 { 00858 rcs_print 00859 ("%s:%d: Warning the VME address of %s is less than or equal to zero.\n", 00860 current_config_file, linenum, bi_to_check->name); 00861 } 00862 return (-1); 00863 } 00864 if (bi->vme_addr > 0) 00865 { 00866 if (bi->vme_addr >= bi_to_check->vme_addr 00867 && bi->vme_addr < bi_to_check->vme_addr + bi_to_check->size) 00868 { 00869 if (warn) 00870 { 00871 rcs_print 00872 ("%s:%d: Warning: Buffers %s and %s seem to have conflicting VME addresses at 0x%X and 0x%X and a size of %d.\n", 00873 current_config_file, linenum, bi->name, 00874 bi_to_check->name, bi->vme_addr, 00875 bi_to_check->vme_addr, bi_to_check->size); 00876 } 00877 return (-1); 00878 } 00879 if (bi_to_check->vme_addr >= bi->vme_addr 00880 && bi_to_check->vme_addr < bi->vme_addr + bi->size) 00881 { 00882 if (warn) 00883 { 00884 rcs_print 00885 ("%s:%d: Warning: Buffers %s and %s seem to have conflicting VME addresses at 0x%X and 0x%X and a size of %d.\n", 00886 current_config_file, linenum, bi_to_check->name, 00887 bi->name, bi_to_check->vme_addr, bi->vme_addr, 00888 bi->size); 00889 } 00890 return (-1); 00891 } 00892 } 00893 } 00894 bi = (BUFFER_INFO *) buffer_list.get_next (); 00895 } 00896 return 0; 00897 } |
|
Definition at line 699 of file nmlcfg.cc. Referenced by nmlcfg_read_file().
00700 { 00701 BUFFER_INFO *bi = (BUFFER_INFO *) buffer_list.get_head (); 00702 while (NULL != bi) 00703 { 00704 if (!strcmp (bi->name, pi_to_check->bufname)) 00705 { 00706 break; 00707 } 00708 bi = (BUFFER_INFO *) buffer_list.get_next (); 00709 } 00710 if (NULL == bi) 00711 { 00712 if (!strcmp (pi_to_check->bufname, "default")) 00713 { 00714 bi = &default_buffer; 00715 } 00716 else 00717 { 00718 rcs_print_error 00719 ("%s:%d: There is no buffer line for %s, but the process %s is configured to connect to it.\n", 00720 current_config_file, linenum, pi_to_check->bufname, 00721 pi_to_check->name); 00722 return (-1); 00723 } 00724 } 00725 if (pi_to_check->c_num < 0) 00726 { 00727 pi_to_check->c_num = bi->processes_connected; 00728 } 00729 PROCESS_INFO *pi = (PROCESS_INFO *) bi->proc_list.get_head (); 00730 while (NULL != pi) 00731 { 00732 if (warn) 00733 { 00734 if (pi->master && pi_to_check->master) 00735 { 00736 rcs_print 00737 ("%s:%d: Warning: Both %s and %s are masters for %s\n", 00738 current_config_file, linenum, pi->name, pi_to_check->name, 00739 bi->name); 00740 } 00741 if (pi->isserver && pi_to_check->isserver) 00742 { 00743 rcs_print 00744 ("%s:%d: Warning: Both %s and %s are servers for %s\n", 00745 current_config_file, linenum, pi->name, pi_to_check->name, 00746 bi->name); 00747 } 00748 if (pi->c_num == pi_to_check->c_num) 00749 { 00750 rcs_print 00751 ("%s:%d: Warning: Both %s and %s have the same c_num(%d) for buffer %s.\n", 00752 current_config_file, linenum, pi->name, pi_to_check->name, 00753 pi->c_num, bi->name); 00754 } 00755 } 00756 pi = (PROCESS_INFO *) bi->proc_list.get_next (); 00757 } 00758 bi->processes_connected++; 00759 bi->proc_list.store_at_tail (pi_to_check, sizeof (PROCESS_INFO), 1); 00760 if (pi_to_check->c_num >= bi->max_proc && bi->max_proc > 0) 00761 { 00762 if (warn) 00763 { 00764 rcs_print 00765 ("%s:%d: Warning: Process %s has a c_num of %d which is greater that the maximum processes allowed of %d for buffer %s\n", 00766 current_config_file, linenum, pi_to_check->name, 00767 pi_to_check->c_num, bi->max_proc, bi->name); 00768 } 00769 } 00770 return (0); 00771 } |
|
Definition at line 1526 of file nmlcfg.cc. Referenced by main().
01527 { 01528 FILE *fp = NULL; 01529 int using_stdout = 0; 01530 01531 if (!strcmp (filename, "stdout")) 01532 { 01533 printf ("\n\nOutput:\n"); 01534 fp = stdout; 01535 using_stdout = 1; 01536 } 01537 else 01538 { 01539 fp = fopen (filename, "w"); 01540 } 01541 if (NULL == fp) 01542 { 01543 rcs_print_error 01544 ("nmlcfg: error: Can't open %s for output (errno = %d:%s).\n", 01545 filename, errno, strerror (errno)); 01546 exit (-1); 01547 } 01548 fprintf (fp, "# %s\n", filename); 01549 int first_buffer = 1; 01550 BUFFER_INFO *bi = (BUFFER_INFO *) buffer_list.get_head (); 01551 int comment_num = 0; 01552 char *comment = (char *) comments.get_head (); 01553 char line[256]; 01554 memset (line, 0, 256); 01555 char last_host_name[80]; 01556 CMS_BUFFERTYPE last_buftype = CMS_SHMEM_TYPE; 01557 strcpy (last_host_name, "localhost"); 01558 int buffer_default_line_needed = 0; 01559 char default_buffer_line[80]; 01560 char *bdl = default_buffer_line; 01561 memset (default_buffer_line, 0, 80); 01562 strcpy (default_buffer_line, "buffer_default "); 01563 int last_vme_addr = 0; 01564 while (bi != NULL) 01565 { 01566 while (comment != NULL && comment_num < bi->comment_num) 01567 { 01568 fprintf (fp, "%s\n", comment); 01569 comment = (char *) comments.get_next (); 01570 comment_num++; 01571 } 01572 if (first_buffer) 01573 { 01574 fprintf (fp, "\n# Buffers:\n"); 01575 if (!inverse_mode) 01576 { 01577 fprintf (fp, 01578 "# %10s \t%7.7s \t%10s \tsize \tneut \t0 \tbuf# \tmax_proc \t. . .\n", 01579 "name", "type", "host"); 01580 } 01581 } 01582 first_buffer = 0; 01583 int orig_max_proc = bi->max_proc; 01584 if (bi->max_proc <= 0 && bi->processes_connected > 1) 01585 { 01586 bi->max_proc = bi->processes_connected + 1; 01587 } 01588 else if (bi->max_proc <= 0 && process_list.list_size > 1 01589 && process_list.list_size < 20) 01590 { 01591 bi->max_proc = process_list.list_size + 1; 01592 } 01593 else if (bi->max_proc <= 0) 01594 { 01595 bi->max_proc = 20; 01596 } 01597 if (bi->use_autocnum && default_lines_detected && bi->max_proc < 20) 01598 { 01599 bi->max_proc = 20; 01600 } 01601 if (bi->use_autocnum && !bi->oldstyle) 01602 { 01603 bi->size += 40 * bi->max_proc; 01604 } 01605 if (!bi->oldstyle && bi->enable_diag && bi->buftype != CMS_GLOBMEM_TYPE) 01606 { 01607 bi->size += 144 * bi->max_proc; 01608 } 01609 if (!bi->oldstyle && bi->enable_diag && bi->buftype == CMS_GLOBMEM_TYPE 01610 && bi->max_proc > 5 && orig_max_proc < 1) 01611 { 01612 rcs_print_error 01613 ("%s:%d Warning the size allocated for this buffer may not be enough to support %d processes and enable the logging of diagnostics data. It is suggested that you either specify max_proc, disable diagnostics, or increase the buffer size by %d.\n", 01614 current_config_file, bi->bufline_line_number, bi->max_proc, 01615 144 * (bi->max_proc - 5)); 01616 } 01617 01618 if (inverse_mode) 01619 { 01620 if (strcmp (last_host_name, bi->host)) 01621 { 01622 buffer_default_line_needed = 1; 01623 bdl = default_buffer_line + strlen (default_buffer_line); 01624 sprintf (bdl, "host=%s ", bi->host); 01625 strcpy (last_host_name, bi->host); 01626 } 01627 if (last_buftype != bi->buftype) 01628 { 01629 buffer_default_line_needed = 1; 01630 bdl = default_buffer_line + strlen (default_buffer_line); 01631 sprintf (bdl, "buftype=%s ", buf_type_name[bi->buftype]); 01632 last_buftype = bi->buftype; 01633 } 01634 if (abs (bi->vme_addr - last_vme_addr) > 0x10000) 01635 { 01636 buffer_default_line_needed = 1; 01637 bdl = default_buffer_line + strlen (default_buffer_line); 01638 sprintf (bdl, "vme_addr=0x%X ", bi->vme_addr); 01639 last_vme_addr = bi->vme_addr; 01640 } 01641 if (buffer_default_line_needed) 01642 { 01643 buffer_default_line_needed = 0; 01644 fprintf (fp, "%s\n", default_buffer_line); 01645 memset (default_buffer_line, 0, 80); 01646 strcpy (default_buffer_line, "buffer_default "); 01647 } 01648 sprintf (line, "b name=%s ", bi->name); 01649 char *l; 01650 if (bi->size > 1024) 01651 { 01652 l = line + strlen (line); 01653 sprintf (l, "size=%d ", bi->size); 01654 } 01655 if (bi->neut) 01656 { 01657 l = line + strlen (line); 01658 sprintf (l, "neutral=1 "); 01659 } 01660 if (bi->queue) 01661 { 01662 l = line + strlen (line); 01663 sprintf (l, "queue=1 "); 01664 } 01665 if (bi->enable_diag) 01666 { 01667 l = line + strlen (line); 01668 sprintf (l, "diag=1 "); 01669 } 01670 if (bi->use_autocnum) 01671 { 01672 l = line + strlen (line); 01673 sprintf (l, "autocnum "); 01674 } 01675 if (bi->force_type > 0) 01676 { 01677 l = line + strlen (line); 01678 sprintf (l, "force_type=%d ", bi->force_type); 01679 } 01680 fprintf (fp, "%s\n", line); 01681 } 01682 else 01683 { 01684 if (bi->oldstyle) 01685 { 01686 switch (bi->buftype) 01687 { 01688 case CMS_SHMEM_TYPE: 01689 sprintf (line, 01690 "B %10s \tSHMEM \t%10s \t%d \t%d \t0 \t%d \t%d \t%d \t%s", 01691 bi->name, bi->host, bi->size, bi->neut, 01692 bi->buffer_number, bi->max_proc, bi->shmem_key, 01693 bi->endline); 01694 break; 01695 01696 default: 01697 sprintf (line, 01698 "B %10s \t%7.7s \t%10s \t%d \t%d \t0 \t%d \t%d \t%s", 01699 bi->name, buf_type_name[bi->buftype], bi->host, 01700 bi->size, bi->neut, bi->buffer_number, 01701 bi->max_proc, bi->endline); 01702 break; 01703 } 01704 } 01705 else 01706 { 01707 switch (bi->buftype) 01708 { 01709 case CMS_SHMEM_TYPE: 01710 if (bi->bsem_key > 0) 01711 { 01712 sprintf (line, 01713 "B %10s \tSHMEM \t%10s \t%d \t%d \t0 \t%d \t%d \t%d \t%s=%d bsem=%d %10s", 01714 bi->name, bi->host, bi->size, bi->neut, 01715 bi->buffer_number, bi->max_proc, bi->shmem_key, 01716 remote_port_name[bi->remotetype], 01717 bi->remote_port, bi->bsem_key, bi->endline); 01718 } 01719 else 01720 { 01721 sprintf (line, 01722 "B %10s \tSHMEM \t%10s \t%d \t%d \t0 \t%d \t%d \t%d \t%s=%d %s", 01723 bi->name, bi->host, bi->size, bi->neut, 01724 bi->buffer_number, bi->max_proc, bi->shmem_key, 01725 remote_port_name[bi->remotetype], 01726 bi->remote_port, bi->endline); 01727 } 01728 break; 01729 01730 case CMS_GLOBMEM_TYPE: 01731 if (bi->vme_addr > 0) 01732 { 01733 sprintf (line, 01734 "B %10s \tGLOBMEM \t%10s \t%d \t%d \t0 \t%d \t%d \t%s=%d vme_addr=0x%lX %s", 01735 bi->name, bi->host, bi->size, bi->neut, 01736 bi->buffer_number, bi->max_proc, 01737 remote_port_name[bi->remotetype], 01738 bi->remote_port, bi->vme_addr, bi->endline); 01739 } 01740 else 01741 { 01742 sprintf (line, 01743 "B %10s \tGLOBMEM \t%10s \t%d \t%d \t0 \t%d \t%d \t%s=%d %s", 01744 bi->name, bi->host, bi->size, bi->neut, 01745 bi->buffer_number, bi->max_proc, 01746 remote_port_name[bi->remotetype], 01747 bi->remote_port, bi->endline); 01748 } 01749 break; 01750 01751 case CMS_BBDMEM_TYPE: 01752 if (bi->bbd_size < 1) 01753 { 01754 bi->bbd_size = bi->orig_size; 01755 } 01756 sprintf (line, 01757 "B %10s \tBBDMEM \t%10s \t%d \t%d \t0 \t%d \t%d \t%s=%d bbd_size=%d force_type=%d %s", 01758 bi->name, bi->host, bi->size, bi->neut, 01759 bi->buffer_number, bi->max_proc, 01760 remote_port_name[bi->remotetype], bi->remote_port, 01761 bi->bbd_size, bi->force_type, bi->endline); 01762 break; 01763 01764 01765 default: 01766 sprintf (line, 01767 "B %10s \t%7.7s \t%10s \t%d \t%d \t0 \t%d \t%d \t%s", 01768 bi->name, buf_type_name[bi->buftype], bi->host, 01769 bi->size, bi->neut, bi->buffer_number, 01770 bi->max_proc, bi->endline); 01771 break; 01772 } 01773 switch (bi->encoding_type) 01774 { 01775 case CMS_XDR_ENCODING: 01776 strcat (line, " xdr"); 01777 break; 01778 01779 case CMS_ASCII_ENCODING: 01780 strcat (line, " ascii"); 01781 break; 01782 01783 case CMS_DISPLAY_ASCII_ENCODING: 01784 strcat (line, " disp"); 01785 break; 01786 01787 case CMS_NO_ENCODING: 01788 default: 01789 break; 01790 } 01791 if (bi->queue) 01792 { 01793 strcat (line, " queue"); 01794 } 01795 if (bi->use_autocnum) 01796 { 01797 strcat (line, " autocnum"); 01798 } 01799 if (bi->enable_diag) 01800 { 01801 strcat (line, " diag"); 01802 } 01803 if (bi->brpi > 0.0) 01804 { 01805 sprintf (line + strlen (line), " brpi=%f", bi->brpi); 01806 } 01807 } 01808 fprintf (fp, "%s\n", line); 01809 memset (line, 0, 256); 01810 } 01811 bi = (BUFFER_INFO *) buffer_list.get_next (); 01812 } 01813 int first_process_line = 1; 01814 PROCESS_INFO *pi = (PROCESS_INFO *) process_list.get_head (); 01815 char last_pi_procname[80]; 01816 int last_was_server = 0; 01817 CMS_PROCESSTYPE last_pi_proctype = CMS_REMOTE_TYPE; 01818 int last_was_master = 0; 01819 memset (last_pi_procname, 0, 80); 01820 char process_default_string[80]; 01821 char *pds = process_default_string; 01822 memset (process_default_string, 0, 80); 01823 int process_default_string_needed = 0; 01824 01825 while (pi != NULL) 01826 { 01827 while (comment != NULL && comment_num < pi->comment_num) 01828 { 01829 fprintf (fp, "%s\n", comment); 01830 comment = (char *) comments.get_next (); 01831 comment_num++; 01832 } 01833 if (first_process_line) 01834 { 01835 fprintf (fp, "\n# Processes: \n"); 01836 if (!inverse_mode) 01837 { 01838 fprintf (fp, 01839 "# %10s \t%10s \t%10s \t%10s \t%10s \tserver \ttimeout \tmaster \tc_num \t . . .\n", 01840 "Name", "Buffer", "type", "host", "ops"); 01841 } 01842 } 01843 first_process_line = 0; 01844 if (inverse_mode) 01845 { 01846 strcpy (process_default_string, "process_default "); 01847 if (strcmp (pi->name, last_pi_procname)) 01848 { 01849 pds = process_default_string + strlen (process_default_string); 01850 process_default_string_needed = 1; 01851 fprintf (fp, "\n"); 01852 sprintf (pds, "name=%s ", pi->name); 01853 strcpy (last_pi_procname, pi->name); 01854 } 01855 if (last_was_server != pi->isserver) 01856 { 01857 pds = process_default_string + strlen (process_default_string); 01858 process_default_string_needed = 1; 01859 sprintf (pds, "server=%d ", pi->isserver); 01860 last_was_server = pi->isserver; 01861 } 01862 if (last_was_server != pi->master) 01863 { 01864 pds = process_default_string + strlen (process_default_string); 01865 process_default_string_needed = 1; 01866 sprintf (pds, "master=%d ", pi->master); 01867 last_was_master = pi->master; 01868 } 01869 if (last_pi_proctype != pi->proctype) 01870 { 01871 pds = process_default_string + strlen (process_default_string); 01872 process_default_string_needed = 1; 01873 sprintf (pds, "proctype=%s ", proc_type_name[pi->proctype]); 01874 last_pi_proctype = pi->proctype; 01875 } 01876 if (process_default_string_needed) 01877 { 01878 process_default_string_needed = 0; 01879 fprintf (fp, "%s\n", process_default_string); 01880 memset (process_default_string, 0, 80); 01881 } 01882 fprintf (fp, "p bufname=%s\n", pi->bufname); 01883 } 01884 else 01885 { 01886 if (!pi->oldstyle && pi->subscription_interval > 0.0) 01887 { 01888 if (pi->timeout > 0.0) 01889 { 01890 fprintf (fp, 01891 "P %10s \t%10s \t%10s \t%10s \t%10s \t%d \t%f \t%d \t%d sub=%f %10s\n", 01892 pi->name, pi->bufname, 01893 proc_type_name[pi->proctype], pi->host, 01894 ops_string[pi->ops], pi->isserver, pi->timeout, 01895 pi->master, pi->c_num, pi->subscription_interval, 01896 pi->endline); 01897 } 01898 else 01899 { 01900 fprintf (fp, 01901 "P %10s \t%10s \t%10s \t%10s \t%10s \t%d \tINF \t%d \t%d sub=%f %10s\n", 01902 pi->name, pi->bufname, 01903 proc_type_name[pi->proctype], pi->host, 01904 ops_string[pi->ops], pi->isserver, pi->master, 01905 pi->c_num, pi->subscription_interval, pi->endline); 01906 } 01907 } 01908 else 01909 { 01910 int no_cnum = 0; 01911 if (pi->buf_info != 0) 01912 { 01913 if (pi->buf_info->use_autocnum) 01914 { 01915 no_cnum = 1; 01916 } 01917 } 01918 if (!strcmp (pi->name, "default")) 01919 { 01920 no_cnum = 1; 01921 } 01922 if (!no_cnum) 01923 { 01924 if (pi->timeout > 0.0) 01925 { 01926 fprintf (fp, 01927 "P %10s \t%10s \t%10s \t%10s \t%10s \t%d \t%f \t%d \t%d %10s\n", 01928 pi->name, pi->bufname, 01929 proc_type_name[pi->proctype], pi->host, 01930 ops_string[pi->ops], pi->isserver, pi->timeout, 01931 pi->master, pi->c_num, pi->endline); 01932 } 01933 else 01934 { 01935 fprintf (fp, 01936 "P %10s \t%10s \t%10s \t%10s \t%10s \t%d \tINF \t%d \t%d %10s\n", 01937 pi->name, pi->bufname, 01938 proc_type_name[pi->proctype], pi->host, 01939 ops_string[pi->ops], pi->isserver, pi->master, 01940 pi->c_num, pi->endline); 01941 } 01942 } 01943 else 01944 { 01945 if (pi->timeout > 0.0) 01946 { 01947 fprintf (fp, 01948 "P %10s \t%10s \t%10s \t%10s \t%10s \t%d \t%f \t%d \t% %10s\n", 01949 pi->name, pi->bufname, 01950 proc_type_name[pi->proctype], pi->host, 01951 ops_string[pi->ops], pi->isserver, pi->timeout, 01952 pi->master, pi->endline); 01953 } 01954 else 01955 { 01956 fprintf (fp, 01957 "P %10s \t%10s \t%10s \t%10s \t%10s \t%d \tINF \t%d \t %10s\n", 01958 pi->name, pi->bufname, 01959 proc_type_name[pi->proctype], pi->host, 01960 ops_string[pi->ops], pi->isserver, pi->master, 01961 pi->endline); 01962 } 01963 } 01964 } 01965 } 01966 pi = (PROCESS_INFO *) process_list.get_next (); 01967 } 01968 while (comment != NULL) 01969 { 01970 fprintf (fp, "%s\n", comment); 01971 comment = (char *) comments.get_next (); 01972 } 01973 fprintf (fp, "\n"); 01974 if (using_stdout) 01975 { 01976 fflush (fp); 01977 } 01978 else 01979 { 01980 fclose (fp); 01981 } 01982 return (0); 01983 } |
|
Definition at line 656 of file nmlcfg.cc. Referenced by nmlcfg_read_file().
00657 { 00658 char *var_ptr = line + 6; 00659 while (*var_ptr == ' ' || *var_ptr == '\t') 00660 { 00661 var_ptr++; 00662 } 00663 char *val_ptr = var_ptr; 00664 while (*val_ptr != '=') 00665 { 00666 if (0 == *val_ptr) 00667 { 00668 return -1; 00669 } 00670 val_ptr++; 00671 } 00672 *val_ptr = 0; 00673 val_ptr++; 00674 char *end_var_ptr = val_ptr - 2; 00675 while (*end_var_ptr == ' ' || *end_var_ptr == '\t') 00676 { 00677 if (var_ptr >= end_var_ptr) 00678 { 00679 return -1; 00680 } 00681 *end_var_ptr = 0; 00682 end_var_ptr--; 00683 } 00684 00685 while (*var_ptr == ' ' || *var_ptr == '\t') 00686 { 00687 var_ptr++; 00688 } 00689 strncpy (temp_var_info.val, val_ptr, 80); 00690 strncpy (temp_var_info.name, var_ptr, 80); 00691 temp_var_info.namelen = strlen (temp_var_info.name); 00692 temp_var_info.vallen = strlen (temp_var_info.val); 00693 var_list.store_at_tail (&temp_var_info, sizeof (VAR_INFO), 1); 00694 return (0); 00695 } |
|
Definition at line 573 of file nmlcfg.cc. Referenced by nmlcfg_read_file().
00574 { 00575 char temp_line[256]; 00576 memset (temp_line, 0, 256); 00577 strncpy (temp_line, line, 256); 00578 char *cptr = temp_line; 00579 char *lptr = line; 00580 while (*cptr) 00581 { 00582 if (*cptr == '$') 00583 { 00584 cptr++; 00585 int varname_len = 1; 00586 char *vptr = cptr + 1; 00587 int used_parens = 0; 00588 if (*cptr == '(') 00589 { 00590 cptr++; 00591 used_parens = 1; 00592 vptr++; 00593 while (*vptr != ')') 00594 { 00595 varname_len++; 00596 if (*vptr == 0 || *vptr == '\n' || *vptr == '\r') 00597 { 00598 fprintf (stderr, "Bad variable reference %s:%d.\n", 00599 current_config_file, linenum); 00600 return (-1); 00601 } 00602 vptr++; 00603 } 00604 } 00605 else 00606 { 00607 while (*vptr != 0 && *vptr != ' ' && *vptr != '\t' 00608 && *vptr != '\n' && *vptr != '\r') 00609 { 00610 varname_len++; 00611 vptr++; 00612 } 00613 } 00614 VAR_INFO *vi = (VAR_INFO *) var_list.get_head (); 00615 while (vi != NULL) 00616 { 00617 if (vi->namelen == varname_len) 00618 { 00619 if (!strncmp (cptr, vi->name, vi->namelen)) 00620 { 00621 strcpy (lptr, vi->val); 00622 lptr += vi->vallen; 00623 cptr += vi->namelen; 00624 if (used_parens) 00625 { 00626 cptr++; 00627 } 00628 break; 00629 } 00630 } 00631 vi = (VAR_INFO *) var_list.get_next (); 00632 } 00633 if (NULL == vi) 00634 { 00635 char *endname_ptr = cptr; 00636 while (*endname_ptr != ' ' && *endname_ptr != 0 00637 && *endname_ptr != '\t') 00638 { 00639 endname_ptr++; 00640 } 00641 *endname_ptr = 0; 00642 fprintf (stderr, "Variable %s on line %d of %s is undefined.\n", 00643 cptr, linenum, current_config_file); 00644 exit (-1); 00645 } 00646 } 00647 *lptr = *cptr; 00648 cptr++; 00649 lptr++; 00650 } 00651 *lptr = 0; 00652 return (0); 00653 } |
|
Definition at line 229 of file nmlcfg.cc. 00230 { 00231 strcpy (output_file, "stdout"); 00232 memset (temp_file, 0, 256); 00233 00234 if (argc < 1) 00235 { 00236 fprintf (stderr, 00237 "nmlcfg usage: [-D name=val] [-I dir] [-o output_file] files . . .\n"); 00238 exit (-1); 00239 } 00240 00241 char flag = 0; 00242 00243 for (int i = 1; i < argc; i++) 00244 { 00245 if (!strcmp (argv[i], "-inverse")) 00246 { 00247 inverse_mode = 1; 00248 continue; 00249 } 00250 if (argv[i][0] == '-') 00251 { 00252 flag = argv[i][1]; 00253 switch (flag) 00254 { 00255 case 'w': 00256 warn = 0; 00257 flag = 0; 00258 break; 00259 00260 case 'W': 00261 flag = 0; 00262 warn = 1; 00263 break; 00264 00265 case 'v': 00266 nmlcfg_verbose = 1; 00267 flag = 0; 00268 break; 00269 00270 default: 00271 break; 00272 } 00273 continue; 00274 } 00275 switch (flag) 00276 { 00277 00278 case 'o': 00279 strncpy (output_file, argv[i], 256); 00280 // rcs_print("output_file=%s\n",output_file); 00281 break; 00282 00283 case 'D': 00284 { 00285 char *eq = strstr (argv[i], "="); 00286 if (eq != NULL) 00287 { 00288 *eq = 0; 00289 strncpy (temp_var_info.name, argv[i], 80); 00290 strncpy (temp_var_info.val, eq + 1, 80); 00291 // rcs_print("(%s)=(%s)\n",temp_var_info.name, temp_var_info.val); 00292 temp_var_info.namelen = strlen (temp_var_info.name); 00293 temp_var_info.vallen = strlen (temp_var_info.val); 00294 var_list.store_at_tail (&temp_var_info, sizeof (VAR_INFO), 0); 00295 } 00296 } 00297 break; 00298 00299 case 'I': 00300 strncpy (temp_dir, argv[i], 256); 00301 include_dir_list.store_at_tail (temp_dir, 256, 1); 00302 break; 00303 00304 case 0: 00305 strncpy (temp_file, argv[i], 256); 00306 file_list.store_at_tail (temp_file, 256, 1); 00307 break; 00308 00309 default: 00310 fprintf (stderr, 00311 "nmlcfg usage: [-D name=val] [-I dir] [-o output_file] files . . .\n"); 00312 exit (-1); 00313 break; 00314 } 00315 flag = 0; 00316 } 00317 if (file_list.list_size < 1) 00318 { 00319 fprintf (stderr, 00320 "nmlcfg usage: [-D name=val] [-I dir] [-o output_file] files . . .\n"); 00321 exit (-1); 00322 } 00323 00324 char *filename = (char *) file_list.get_head (); 00325 while (filename != NULL) 00326 { 00327 nmlcfg_read_file (filename); 00328 filename = (char *) file_list.get_next (); 00329 } 00330 nmlcfg_write_output (output_file); 00331 } |
|
|
|
Initial value: { "NO", "R", "W", "RW" } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Initial value: { "NONE", "RPC", "TTY", "TCP", "STCP", "UDP" } |
|
Initial value: { "SHMEM", "GLOBMEM", "PHANTOM", "LOCMEM", "FILEMEM", "BBDMEM", "RTLMEM" } |
|
Initial value: { "REMOTE", "LOCAL", "PHANTOM", "AUTO" } |
|
|
|
|