Beispiel #1
0
static void print_flags_help(struct isl_arg *decl,
	struct isl_prefixes *prefixes, void *opt)
{
	int i, j;
	int pos;

	pos = print_arg_help(decl, prefixes, 0);
	printf("=");
	pos++;

	for (i = 0; decl->u.flags.flags[i].name; ++i) {
		if (i) {
			printf(",");
			pos++;
		}
		for (j = i;
		     decl->u.flags.flags[j].mask == decl->u.flags.flags[i].mask;
		     ++j) {
			if (j != i) {
				printf("|");
				pos++;
			}
			printf("%s", decl->u.flags.flags[j].name);
			pos += strlen(decl->u.flags.flags[j].name);
		}
		i = j - 1;
	}

	pos = print_help_msg(decl, pos);
	print_default_flags(decl, opt, pos);

	printf("\n");
}
Beispiel #2
0
static void print_str_list_help(struct isl_arg *decl,
	struct isl_prefixes *prefixes)
{
	int pos;
	const char *a = decl->argument_name ? decl->argument_name : "string";
	pos = print_arg_help(decl, prefixes, 0);
	pos = print_argument_name(decl, a, pos);
	pos = print_help_msg(decl, pos);
	printf("\n");
}
Beispiel #3
0
static void print_ulong_help(struct isl_arg *decl,
	struct isl_prefixes *prefixes)
{
	int pos;
	pos = print_arg_help(decl, prefixes, 0);
	printf("=ulong");
	pos += 6;
	print_help_msg(decl, pos);
	printf("\n");
}
Beispiel #4
0
static void print_bool_help(struct isl_arg *decl,
	struct isl_prefixes *prefixes, void *opt)
{
	int pos;
	unsigned *p = opt ? (unsigned *)(((char *) opt) + decl->offset) : NULL;
	int no = p ? *p == 1 : 0;
	pos = print_arg_help(decl, prefixes, no);
	pos = print_help_msg(decl, pos);
	if (decl->offset != (size_t) -1)
		print_default(decl, no ? "yes" : "no", pos);
	printf("\n");
}
Beispiel #5
0
static void print_str_help(struct isl_arg *decl,
	struct isl_prefixes *prefixes, void *opt)
{
	int pos;
	const char *a = decl->argument_name ? decl->argument_name : "string";
	const char **p = (const char **)(((char *) opt) + decl->offset);
	pos = print_arg_help(decl, prefixes, 0);
	pos = print_argument_name(decl, a, pos);
	pos = print_help_msg(decl, pos);
	if (*p)
		print_default(decl, *p, pos);
	printf("\n");
}
Beispiel #6
0
static void print_int_help(struct isl_arg *decl,
	struct isl_prefixes *prefixes, void *opt)
{
	int pos;
	char val[20];
	int *p = (int *)(((char *) opt) + decl->offset);
	pos = print_arg_help(decl, prefixes, 0);
	pos = print_argument_name(decl, decl->argument_name, pos);
	pos = print_help_msg(decl, pos);
	snprintf(val, sizeof(val), "%d", *p);
	print_default(decl, val, pos);
	printf("\n");
}
Beispiel #7
0
static void print_long_help(struct isl_arg *decl,
	struct isl_prefixes *prefixes, void *opt)
{
	int pos;
	long *p = (long *)(((char *) opt) + decl->offset);
	pos = print_arg_help(decl, prefixes, 0);
	if (*p != decl->u.l.default_selected) {
		printf("[");
		pos++;
	}
	printf("=long");
	pos += 5;
	if (*p != decl->u.l.default_selected) {
		printf("]");
		pos++;
	}
	print_help_msg(decl, pos);
	printf("\n");
}
Beispiel #8
0
static void print_choice_help(struct isl_arg *decl,
	struct isl_prefixes *prefixes, void *opt)
{
	int i;
	int pos;

	pos = print_arg_help(decl, prefixes, 0);
	printf("=");
	pos++;

	for (i = 0; decl->u.choice.choice[i].name; ++i) {
		if (i) {
			printf("|");
			pos++;
		}
		printf("%s", decl->u.choice.choice[i].name);
		pos += strlen(decl->u.choice.choice[i].name);
	}

	pos = print_help_msg(decl, pos);
	print_default_choice(decl, opt, pos);

	printf("\n");
}
Beispiel #9
0
/**
 * Help function.
 */
static void print_main_application_options ( void )
{
    int is_term = isatty ( fileno ( stdout ) );
    print_help_msg ( "-no-config", "", "Do not load configuration, use default values.", NULL, is_term );
    print_help_msg ( "-v,-version", "", "Print the version number and exit.", NULL, is_term  );
    print_help_msg ( "-dmenu", "", "Start in dmenu mode.", NULL, is_term );
    print_help_msg ( "-display", "[string]", "X server to contact.", "${DISPLAY}", is_term );
    print_help_msg ( "-h,-help", "", "This help message.", NULL, is_term );
    print_help_msg ( "-dump-xresources", "", "Dump the current configuration in Xresources format and exit.", NULL, is_term );
    print_help_msg ( "-dump-xresources-theme", "", "Dump the current color scheme in Xresources format and exit.", NULL, is_term );
    print_help_msg ( "-e", "[string]", "Show a dialog displaying the passed message and exit.", NULL, is_term );
    print_help_msg ( "-markup", "", "Enable pango markup where possible.", NULL, is_term );
    print_help_msg ( "-normal-window", "", "In dmenu mode, behave as a normal window. (experimental)", NULL, is_term );
    print_help_msg ( "-show", "[mode]", "Show the mode 'mode' and exit. The mode has to be enabled.", NULL, is_term );
}
Beispiel #10
0
/* test function */
int main(int argc, char *argv[])
{
	
	int ofdmmode;
	int bandwidth;
	int coderate;
	int guardinterval;
	int modulation;
	int alpha;
	int cellid;
	int oversampling;
	int outputformat;
	float gain;
	int opt;
	DVBT_settings *dvbtsettings;

	oversampling = 1;
	alpha = 1;
	cellid = 0;
	gain = 1.0f;
	
	opterr = 0;
	while ((opt = getopt(argc, argv, "to:b:c:g:m:a:i:s:f:z:v:")) != -1)
	{
		switch (opt)
		{
		case 'o':
			ofdmmode = atoi(optarg);
			break;
		case 'b':
			bandwidth = atoi(optarg);
			break;
		case 'c':
			coderate = atoi(optarg);
			break;
		case 'g':
			guardinterval = atoi(optarg);
			break;
		case 'm':
			modulation = atoi(optarg);
			break;
		case 'a':
			alpha = atoi(optarg);
			break;
		case 'i':
			cellid = atoi(optarg);
			break;
		case 'v':
			oversampling = atoi(optarg);
			break;
		case 's':
			outputformat = atoi(optarg);
			break;
		case 'f':
			gain = atof(optarg);
			break;
		case 'h':
			print_help_msg();
			break;
		case '?':
			fprintf(stderr, "unknown arg %c\n", optopt);
        break;
		}
	}

	try {
		dvbtsettings = new DVBT_settings(ofdmmode, bandwidth, coderate, guardinterval, modulation, alpha, cellid, oversampling, static_cast<dvbt_data_formats>(outputformat), gain);
	}
	catch(...)
	{
		fprintf(stderr,"failed to init DVBT_Settings\n");
		return 1;
	}

	DVBT_pipe *pin = new DVBT_pipe("pin");
	DVBT_pipe *pout = new DVBT_pipe("pout");
	std::thread wt(write_thread, pout);
	std::thread rt(read_thread, pin);
	
	DVBT_ce dvbtce(pin,pout,dvbtsettings);
	while(dvbtce.encode())
	{
	};
	
	rt.join();
	wt.join();
	delete pin;
	delete pout;
	return 0;
}
Beispiel #11
0
static bool
process_command_line (ProgramOptions *opts, int argc, char* argv[])
{
    opts->program_name = argv [0];
    opts->charmap_name = "";
    opts->source_name  = "";
    opts->map_file     = 0;
    opts->alias_file   = 0;
    opts->locale_name  = 0;

    opts->gen          = false;
    opts->force_output = false;
    opts->use_ucs      = false;
    opts->no_position  = false;
    opts->link_aliases = false;

    int i;   // index of command line argument being processed

    for (i = 1; i < argc && '-' == argv [i][0]; ++i) {

        switch (argv [i][1]) {

        case 'f':   // set character set description file name
            if (argv [i + 1])
                opts->charmap_name = argv [++i];
            break;

        case 'i':   // set locale definition file name
            if (argv [i + 1])
                opts->source_name = argv [++i];
            break;

        case 'c':   // create output even if warnings are issued
            opts->force_output = true;
            break;

        case 'g':   // generate more than one locale database
            opts->gen = true;
            break;

        case 'm':
            if (argv [i + 1])
                opts->map_file = argv [++i];
            break;

        case 'a':
            if (argv [i + 1])
                opts->alias_file = argv [++i];
            break;

        case 'r':
            if (argv [i + 1])
                opts->charmap_dir = argv [++i];
            break;

        case 's':
            if (argv [i + 1])
                opts->src_dir = argv [++i];
            break;

        case 'd':
            if (argv [i + 1])
                opts->output_dir = argv [++i];
            break;

        case 'w':   // disable one or all warnings
            if (argv [i][2])
                issue_diag (std::atoi (argv [i] + 2), false, 0, 0);
            else
                issue_diag (W_DISABLE, false, 0, 0);
            break;

        case '?':
            print_help_msg ();
            return false;

        case '-':
            if (0 == std::strcmp (argv [i] + 2, "help")) {
                print_help_msg ();
                return false;
            }

            if (0 == std::strcmp (argv [i] + 2, "ucs")) {
                // --ucs: use UCS as the internal wchar_t encoding
                opts->use_ucs = true;
                break;
            }
            else if (0 == std::strcmp (argv [i] + 2, "no_position")) {
                opts->no_position = true;
                break;
            }
            else if (0 == std::strcmp (argv [i] + 2, "aliases")) {
                opts->link_aliases = true;
                break;
            }
            else if (0 == std::strcmp (argv [i] + 2, "notes")) {
                // --notes: enable informational messages (notes)
                issue_diag (I_ENABLE, false, 0, 0);
                break;
            }
            // fall through

        default:
            issue_diag (E_CMDARG, true, 0, "invalid option %s\n", argv [i]);
        }
    }

    if (opts->gen) {

        bool errors = false;

        // make sure that all the required options are specified
        if (0 == opts->map_file) {
            issue_diag (E_NOARG, true, 0, 
                        "option %s requires a string argument\n", "-m");
        }

        if (opts->charmap_dir.empty ()) {
            issue_diag (E_NOARG, true, 0, 
                        "option %s requires a string argument\n", "-r");
        }

        if (opts->src_dir.empty ()) {
            issue_diag (E_NOARG, true, 0, 
                        "option %s requires a string argument\n", "-s");
        }

        if (opts->output_dir.empty ()) {
            issue_diag (E_NOARG, true, 0, 
                        "option %s requires a string argument\n", "-d");
        }

        // append a slash to the directories if the user didn't
        if (opts->output_dir [opts->output_dir.size () - 1] != _RWSTD_PATH_SEP)
            opts->output_dir += _RWSTD_PATH_SEP;

        if (opts->src_dir [opts->src_dir.size () - 1] != _RWSTD_PATH_SEP)
            opts->src_dir += _RWSTD_PATH_SEP;

        if (opts->charmap_dir [opts->charmap_dir.size () - 1] != _RWSTD_PATH_SEP)
            opts->charmap_dir += _RWSTD_PATH_SEP;
    }

    if (0 == argv [i] && !opts->gen) {
        issue_diag (E_NOARG, true, 0, "missing command line argument\n");
    }

    opts->locale_name = argv [i];

    if (argv [i + 1]) {
        issue_diag (E_XARG, true, 0,
                    "extra command line arguments after %s\n", argv [i]);
    }

    return true;
}
Beispiel #12
0
void print_dmenu_options ( void )
{
    int is_term = isatty ( fileno ( stdout ) );
    print_help_msg ( "-mesg", "[string]", "Print a small user message under the prompt (uses pango markup)", NULL, is_term );
    print_help_msg ( "-p", "[string]", "Prompt to display left of entry field", NULL, is_term );
    print_help_msg ( "-selected-row", "[integer]", "Select row", NULL, is_term );
    print_help_msg ( "-format", "[string]", "Output format string", "s", is_term );
    print_help_msg ( "-u", "[list]", "List of row indexes to mark urgent", NULL, is_term );
    print_help_msg ( "-a", "[list]", "List of row indexes to mark active", NULL, is_term );
    print_help_msg ( "-l", "[integer] ", "Number of rows to display", NULL, is_term );
    print_help_msg ( "-i", "", "Set filter to be case insensitive", NULL, is_term );
    print_help_msg ( "-only-match", "", "Force selection or custom entry", NULL, is_term );
    print_help_msg ( "-no-custom", "", "Don't accept custom entry", NULL, is_term );
    print_help_msg ( "-select", "[string]", "Select the first row that matches", NULL, is_term );
    print_help_msg ( "-password", "", "Do not show what the user inputs. Show '*' instead.", NULL, is_term );
    print_help_msg ( "-markup-rows", "", "Allow and render pango markup as input data.", NULL, is_term );
    print_help_msg ( "-sep", "[char]", "Element separator.", "'\\n'", is_term );
}
Beispiel #13
0
int main(int argc, char *args[])
{

	int ret;
	int param_opt = 0;
	int nInstanceId = 0;
	char *pszProcName = NULL;
	char *pszSyncMode = NULL;
	char *pszLogPath = NULL;
	bool bBulk = false;
	int nBulkCount = 0;
	bool bBackup = false;
	bool bSync = false;

	if(argc < 2)
	{
		print_help_msg();
		return 0;
	}
											
	while( -1 != (param_opt = getopt(argc, args, "hp:b:k:i:f:")))
	{
		switch(param_opt)
		{
			case 'h' :
				print_help_msg();
				return 0;
			case 'p' :
				pszProcName =  optarg ;
				printf("process Name %s\n", pszProcName);
				break;
//			case 'c' :
//				unSendCount = atoi(optarg);
//				printf("Send Count %u\n", unSendCount);
//				break;
			case 'b' :
				bBulk = true;
				nBulkCount = atoi(optarg);
				printf("Bulk Mode On, Count %d\n", nBulkCount);
				break;
			case 'k' :
				bBackup = true;
				pszSyncMode = optarg;
				if(strncmp (pszSyncMode, "sync", strlen("sync")) == 0)
				{
					bSync = true;
				}

				printf("Backup on Sync Mode[%s] On\n", pszSyncMode);

				break;
//			case 's' :
//				unDataSize = atoi(optarg);
//				printf("Send Data Size %u\n", unDataSize);
//				break;
			case 'f' :
				pszLogPath = optarg;
				printf("File Log Path %s\n", pszLogPath);
				break;
			case 'i' :
				nInstanceId = atoi(optarg);
				printf("Instance ID %d\n", nInstanceId);
				break;
															
			default :
				break;

		}			
	}

	//Init CLQManager
	//Arguments : NODE ID, Process Name, Process Instance ID, Backup Flag, MSync Flag, Log Path(생략 가능)
	CLQManager	*m_pclsCLQ = new CLQManager("OFCS", "AP", pszProcName, nInstanceId, bBackup,  bSync , pszLogPath);
	if(m_pclsCLQ->Initialize(DEF_CMD_TYPE_RECV) < 0)
	{
		printf("CLQManager Init Failed ErrMsg[%s]\n", m_pclsCLQ->GetErrorMsg());
		return -1;
	}

	//Init Stat Thread
#if 1
	pthread_t thread_id;
	ret = pthread_create(&thread_id, NULL, &thread_start, NULL);

	if(ret != 0)
	{
		RTE_LOG(INFO, EAL, "Thread create failed\n");
		return -1;
	}
									
#endif

	while(1)
	{
		ret = m_pclsCLQ->ReadWait();
		switch(ret)
		{
			case DEF_SIG_DATA :
				if(bBulk)
				{
					process_bulk_data(m_pclsCLQ, nBulkCount);
				}
				else
				{
					process_data(m_pclsCLQ);
				}

				break;
			case DEF_SIG_COMMAND :
				process_command(m_pclsCLQ, pszProcName, nInstanceId);
				break;
			default:
				break;
		}
	}


	return 0;
}
Beispiel #14
0
/* This function processes the command line options ('-- and -' pararamteres),
   changing the structure of parameters accordingly. */
void process_flags (parameter_t* p, const int argc, char** argv)
{
  int c;
  int option_index;

  /* The next variables have to be static since getopt_long() has to able to
     determine their addresses at compilation time (see info libc ->
     getopt_long()). */

  /* dump everything to the same place as ofp */
  static int energy_file = FALSE;

  /* do not dump event numbers by default */
  static int dump_eventno = FALSE;

  /* dump everything to stdout */
  static int config_file = FALSE;

  /* dump everything to the same place as ofp */
  static int eventno_file = FALSE;

  /* by, default, run using local file deposition instead of memory (slower)*/
  static int run_fast = FALSE;

  /* verbose output? */
  static int verbose = FALSE;

  /* When dumping digis, do you want to dump only control? */
  static int ctrl = FALSE;

  /* This global defines the options to take */
  static struct option long_options[] =
  {
    /* These options set a flag. */
    {"control-only", 0, &ctrl, 1},
    {"energy-file",  0, &energy_file,  1},
    {"dump-eventno", 0, &dump_eventno, 1},
    {"config-file",  0, &config_file,  1},
    {"eventno-file", 0, &eventno_file, 1},
    {"fast-output",  0, &run_fast,     1},
    {"verbose",      0, &verbose,      1},

    /* These options have arguments */
    {"config-weighted", 1, 0, 'c'},
    {"dump", 1, 0, 'd'},
    {"event-number", 1, 0, 'e'},
    {"format", 1, 0, 'f'},
    {"dump-energy", 1, 0, 'g'},
    {"help", 0, 0, 'h'},
    {"input-file", 1, 0, 'i'},
    {"eventno-comment", 1, 0, 'k'},
    {"layer", 1, 0, 'l'},
    {"max-radius", 1, 0, 'm'},
    {"normalization", 1, 0, 'n'},
    {"file-prefix", 1, 0, 'o'},
    {"particle", 1, 0, 'p'},
    {"roi-number", 1, 0, 'r'},
    {"select", 1, 0, 's'},
    {"energy-comment", 1, 0, 't'},
    {"load-nevents", 1, 0, 'x'},
    {0, 0, 0, 0}
  };
  
  while (EOF != (c=getopt_long(argc, argv, "c:i:o:k:g:he:r:d:f:p:l:s:n:m:t:x:",
			       long_options, &option_index) ) ) {
    switch (c) {

    case 0: /* Got a nil-flagged option */
      break;

    case 'c': /* The limits if using NORM_WEIGHTED_* normalization type */
      to_config_weighted(optarg, &p->config_weighted);
      break;
      
    case 'd': /* What to dump? */
      if ( strcasecmp(optarg, "digis" ) == 0 ) {
	p->dump_digis = TRUE;
      }

      else if ( strcasecmp(optarg, "rings" ) == 0 ) {
	p->dump_rings = TRUE;
      }

      else if ( strcasecmp(optarg, "udigis" ) == 0 ) {
	p->dump_uniform_digis = TRUE;
      }

      /* this is the default, do nothing */
      else if ( strcasecmp(optarg, "rois" ) == 0 ) {}

      else {
	fprintf(stderr,"(param)ERROR: Can't recognize format -> %s\n", optarg);
	exit(EXIT_FAILURE);
      }
      break;

    case 'e': /* dump only event 'number' */
      p->event_no = to_valid_long(optarg);
      p->process_all_events = FALSE;
      break;

    case 'f': /* What to dump? */
      if ( strcasecmp(optarg, "snns" ) == 0 ) {
	p->format_snns = TRUE;
      }

      /* this is the default, do nothing */
      else if ( strcasecmp(optarg, "raw" ) == 0 ) {}

      else {
	fprintf(stderr,"(param)ERROR: Can't recognize format -> %s\n", optarg);
	exit(EXIT_FAILURE);
      }
      break;

    case 'g': /* What energy values would you like printed? */
      string2edump(&p->dump_energy,optarg);
      break;

    case 'i': { /* input from file 'infile' */
      struct stat buf;
      /* Ok, open the file we're going to work with, in case of error,
	 give up */
      if (NULL==(p->ifp=fopen(optarg,"r"))) {
	fprintf(stderr, "(param) Can't open input file %s\n", optarg);
	exit(EXIT_FAILURE);
      }

      /* If opened the input filename, copy the filename to a safe place, so it
	 can be re-used latter */
      strncpy(p->ifname,optarg, MAX_FILENAME);

      /* get file status, includding optimal buffer block size */
      stat(optarg, &buf);
      /* set the output file buffer to be optimal, or we'll take longer to 
	 process the output */
      p->ifbuf = (char*)malloc(buf.st_blksize);
      if (setvbuf(p->ifp, p->ifbuf, _IOFBF, buf.st_blksize) != 0) {
	fprintf(stderr, "(param) Can't create input file buffer\n");
	exit(EXIT_FAILURE);
      }

      break;
    }

    case 'k': { /* the string to be used when dumping the event numbers */
      strncpy(p->event_comment_str, optarg, 4);
      break;
    }

    case 'l': /* Which layers to require? */
      string2layer(&p->layer_flags,optarg);
      break;

    case 'm': /* The radius for 'unity+' normalization */
      p->max_radius = to_valid_double(optarg);
      break;

    case 'n': /* Which normalization to use? */
      string2normalization(&p->normalization,optarg);
      break;

    case 'o': { /* output to file 'outfile' */
      strncpy(p->ofhint, optarg, MAX_FILENAME);
      fprintf(stderr,"(param)WARN: Using file prefix -> %s\n", p->ofhint);
      p->output_file = TRUE;
      break;
    }      

    case 'p': /* What's the target? */
      if ( strcasecmp(optarg, "jet" ) == 0 ) {
	p->particle = JET;
      }

      else if ( strcasecmp(optarg, "electron" ) == 0 ) {
	p->particle = ELECTRON;
      }

      else {
	fprintf(stderr,"(param)ERROR: A type of particle ?? -> %s\n", optarg);
	exit(EXIT_FAILURE);
      }
      break;

    case 'r': /* dump only the roi 'roi'. This option has only sense with -e
		 comming first! */
      p->roi_no = to_valid_long(optarg);
      p->process_all_rois = FALSE;
      break;

    case 's': /* Which layers to print to output? */
      string2layer(&p->print_flags,optarg);
      break;

    case 't': /* the string to be used when dumping the RoI energy values */
      strncpy(p->edump_comment_str, optarg, 4);
      break;

    case 'x': /* How many events to load per processing loop */
      p->load_events = to_valid_long(optarg);
      break;

    case 'h': /* give help */
    case '?':
    default:
      print_help_msg(stderr,argv[0]);
      exit(EXIT_SUCCESS);
      break;

    } /* end of switch on (c) */
  } /* end of while on (getopt) */

  /* Set the corresponding variables on parameter_t */
  p->energy_file = energy_file;
  p->dump_eventno = dump_eventno;
  p->config_file = config_file;
  p->eventno_file = eventno_file;
  p->run_fast = run_fast;
  p->verbose = verbose;
  p->control_only = ctrl;

  /* Now we initialize the output environment which may be files or obstacks */
  open_output(p);

  /* Now we test the coherency of some flags */
  test_flags(p);

  /* dump configuration. It shall close the config file automatically. Do *NOT*
     attempt to write on it afterwards! */
  dump_config(p->cfp, p);

} /* end of process flags */