static int parse_data(struct asfd *asfd, struct cstat *clist, struct asfd *cfd, struct conf **confs) { if(asfd==cfd) return parse_client_data(asfd, clist, confs); return parse_parent_data(asfd, clist); }
config_info::config_info( int argc, char **argv ) { int dn=-1, cn=-1, pn=-1, lp=-1; is_version=0; num_clients=1; protocol_lib_path=NULL; client_lib_path=NULL; payload_lib_path=NULL; client_min=client_max=client_inc=client_time=0; payload_min=payload_max=payload_inc=payload_time=0; protocol_dest_port=0; protocol_dest_address=NULL; installed=0; error_string=NULL; if (argc<3) { if (argv[1] && strcmp( argv[1], "-v" )) { set_error( "Not enough parameters specified" ); return; } } for (int cnt=1;cnt<argc;cnt++) { int result; if (argv[cnt][0]!='-' && argv[cnt][0]!='/') { set_error( "Parameter specified that does not start with - or /" ); return; } switch (argv[cnt][1]) { case 'd': result=parse_protocol_data( cnt, argc, argv, &dn ); if (result) return; cnt+=1; continue; case 'c': result=parse_client_data( cnt, argc, argv, &cn ); if (result) return; cnt+=1; continue; case 'p': result=parse_payload_data( cnt, argc, argv, &pn ); if (result) return; cnt+=1; continue; case 'n': // num clients if (!argv[cnt+1]) { set_error( "Parameter specified without value" ); return; } num_clients=atol( argv[cnt+1] ); cnt+=1; continue; case 'L': // lib path if (!argv[cnt+1]) { set_error( "Parameter specified without value" ); return; } lp=cnt+1; cnt+=1; continue; case 'v': // version char buf[1024]; snprintf( buf, 1024, "%s version %s", PRODUCT_NAME, PRODUCT_VERSION ); set_error( buf ); is_version=1; return; default: set_error( "Unknown parameter specified" ); return; } } // Logic checking if (dn==-1 || cn==-1 || pn==-1) { set_error( "You must specify -cn and -dn and -pn" ); return; } if (num_clients<1) { set_error( "You must specify at least one client" ); return; } char err_msg[1024]; protocol_lib_path=set_library_path( argc, argv, dn, lp, "protocol", err_msg, 1024 ); if (!protocol_lib_path) { set_error( err_msg ); return; } client_lib_path=set_library_path( argc, argv, cn, lp, "client", err_msg, 1024 ); if (!client_lib_path) { set_error( err_msg ); return; } payload_lib_path=set_library_path( argc, argv, pn, lp, "payload", err_msg, 1024 ); if (!payload_lib_path) { set_error( err_msg ); return; } if (protocol_dest_port<=0) { set_error( "Protocol destination port must be defined" ); return; } if (!protocol_dest_address) { set_error( "Protocol destination address must be defined" ); return; } installed=1; }