Exemplo n.º 1
0
static int
do_help_command(int argc, char *argv[])
{
    const Command *command;
    int i;

    if (argc != 2) {
        help_usage();
        return 0;
    }

    char *command_name = argv[1];

    for (i = 0; i < ARRAY_SIZE(commands); i++) {
        command = commands[i];

        if (strcmp(command_name, command->name) == 0) {
            (command->usage) ();
            return 0;
        }
    }

    std::cerr << "Error: Unknown command: " << command_name
              << " (see \"apitrace help\").\n";

    return 1;
}
Exemplo n.º 2
0
/**
 * Updates the applications main terminal screen
 *
 * This is usually called in response to certain events
 */
void apme_screen_update(void)
{
    struct aion_group_iter iter;
    char buf[256];

    /* Reset screen */
    term_clear();

    term_setcolor(TERM_FG_YELLOW);
    printf("***** APme version %s (by Snowsong @ Nexus)\n\n", APME_VERSION_STRING);

    term_setcolor(TERM_FG_YELLOW);
    term_setcolor(TERM_BG_BLUE);
    printf("=================== Current Group Status ===========");
    term_setcolor(TERM_COLOR_RESET);
    printf("\n\n");

    for (aion_group_first(&iter); !aion_group_end(&iter); aion_group_next(&iter))
    {
        /* Paint ourselves green */
        if (aion_player_is_self(iter.agi_name))
        {
            term_setcolor(TERM_FG_GREEN);
        }
        else
        {
            term_setcolor(TERM_COLOR_RESET);
        }

        printf(" * %-16s (AP: %d) %s\n", iter.agi_name, iter.agi_apvalue, iter.agi_invfull ? " -- FULL INVENTORY" : "");
    }

    printf("\n");
    term_setcolor(TERM_FG_YELLOW);
    term_setcolor(TERM_BG_BLUE);
    printf("====================================================");
    term_setcolor(TERM_COLOR_RESET);
    printf("\n\n");

    if (aion_aploot_rights(buf, sizeof(buf)))
    {
        term_setcolor(TERM_FG_MAGENTA);
        printf("Current AP loot info:\n%s\n", buf);
    }
    term_setcolor(TERM_COLOR_RESET);

    term_setcolor(TERM_FG_CYAN);
    help_usage(buf, sizeof(buf));
    printf("\n%s\n", help_mainscreen);
    printf("%s\n", buf);
    term_setcolor(TERM_COLOR_RESET);

    fflush(stdout);
}
Exemplo n.º 3
0
static void help_cmd(int argc, char **argv) {
  if(argc > 2) {
    printf("Too much arguments !\n");
    printf("   Usage : %s help\n", PACKAGE);
    printf("   Usage : %s help <cmd>\n", PACKAGE);
  } else if(argc == 2) {
    help_cmd_info(argv[1]);
  } else {
    help_usage();
  }

  exit(EXIT_FAILURE);
}
Exemplo n.º 4
0
int
cmd_help(int argc, char *argv[])
{
	struct commands *cmd;
	char *cp;
    
	if (argc < 2)
		help_usage();
	cp = argv[1];
	cmd = lookupcmd(cp);
	if (cmd == NULL)
		errx(EX_DATAERR, "unknown command %s", cp);
	if (cmd->usage == NULL)
		errx(EX_DATAERR, "no specific help for command %s", cp);
	cmd->usage();
	exit(0);
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
	int re = 1;
	if (argc < 2) return usage();
	if (strcmp(argv[1], "index") == 0) re = index_build(argc - 1, argv + 1);
	else if (strcmp(argv[1], "aln") == 0) re = load_input_map(argc - 1, argv + 1);
	else if (strcmp(argv[1], "--help") == 0) return help_usage();
	else {
		fprintf(stderr, "wrong command: '%s'\n", argv[1]);
		return 1;
	}
	
	if(re == 0)
	{
		fprintf(stderr, "Program finished\n");
	}
}
Exemplo n.º 6
0
static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
  FAR const char *cmd = NULL;
#ifndef CONFIG_NSH_HELP_TERSE
  bool verbose = false;
  int i;
#endif

  /* The command may be followed by a verbose option */

#ifndef CONFIG_NSH_HELP_TERSE
  i = 1;
  if (argc > i)
    {
      if (strcmp(argv[i], "-v") == 0)
        {
          verbose = true;
          i++;
        }
    }

  /* The command line may end with a command name */

  if (argc > i)
    {
      cmd = argv[i];
    }

  /* Show the generic usage if verbose is requested */

  if (verbose)
    {
      help_usage(vtbl);
    }
#else
  if (argc > 1)
    {
      cmd = argv[1];
    }
#endif

  /* Are we showing help on a single command? */

  if (cmd)
    {
      /* Yes.. show the single command */

      help_cmd(vtbl, cmd);
    }
  else
    {
       /* In verbose mode, show detailed help for all commands */

#ifndef CONFIG_NSH_HELP_TERSE
      if (verbose)
        {
          nsh_output(vtbl, "Where <cmd> is one of:\n");
          help_allcmds(vtbl);
        }

      /* Otherwise, just show the list of command names */

      else
#endif
        {
          help_cmd(vtbl, "help");
          nsh_output(vtbl, "\n");
          help_cmdlist(vtbl);
        }

      /* And show the list of built-in applications */

      help_builtins(vtbl);
    }

  return OK;
}
Exemplo n.º 7
0
// yep, that is what I chose to call it : Help functions
int
GLU_helps_those_who_help_themselves( const char *help_str )
{
  if( are_equal( help_str , "--help=MODE" ) ) {
    mode_types( ) ;
  } else if( are_equal( help_str , "--help=HEADER" ) ) {
    header_types( ) ;
  } else if( are_equal( help_str , "--help=DIM" ) ) {
    fprintf( stdout , "DIM_%%d = %%d - Specified lattice dimensions for the "
	     "UNIT, RANDOM and INSTANTON\n"
	     "              types of HEADER. If we are not using these, "
	     "lattice\n"
	     "              dimensions are taken from the configuration "
	     "header\n" ) ;
  } else if( are_equal( help_str , "--help=CONFNO" ) ) {
    fprintf( stdout , "CONFNO = %%d - User-specified configuration number. "
	     "All configuration types except NERSC do not directly provide\n"
	     "              a configuration number. So you should supply one "
	     "for the output configuration\n" ) ;
  } else if( are_equal( help_str , "--help=RANDOM_TRANSFORM" ) ) {
    fprintf( stdout , "RANDOM_TRANSFORM = YES    - Perform a lattice-wide "
	     "random gauge transformation of the fields\n"
	     "                 = {!YES} - Do nothing\n" ) ;
  } else if( are_equal( help_str , "--help=SEED" ) ) {
    fprintf( stdout , "SEED = %%d - User specified RNG seed \n" 
	     "        0 - Generates a SEED from urandom if it is available\n") ;
  } else if( are_equal( help_str , "--help=GFTYPE" ) ) {
    gftype_types( ) ;
  } else if( are_equal( help_str , "--help=GFTUNE" ) ) {
    fprintf( stdout , "GFTUNE = %%lf - User specified tuning parameter for "
	     "the gauge fixing this should generally be < 0.1, less "
	     "important for the default CG routines\n" ) ;
  } else if( are_equal( help_str , "--help=IMPROVEMENTS" ) ) {
    improvement_types( ) ;
  } else if( are_equal( help_str , "--help=ACCURACY" ) ) {
    fprintf( stdout , "ACCURACY = %%d - Stops the gauge fixing after an "
	     "average accuracy of better than 10^{-ACCURACY} has been "
	     "achieved\n" ) ;
  } else if( are_equal( help_str , "--help=MAX_ITERS" ) ) {
    fprintf( stdout , "MAX_ITERS = %%d - After this many iterations the "
	     "routine restarts from the beginning with a random transformation "
	     "of the\n"
	     "                 fields and after %d restarts it complains about "
	     "changing the tuning\n" , GF_GLU_FAILURES ) ;
  } else if( are_equal( help_str , "--help=CUTTYPE" ) ) {
    cuttype_types( ) ;
  } else if( are_equal( help_str , "--help=FIELD_DEFINTION" ) ) {
    fprintf( stdout , "FIELD_DEFINITION = LOG        - Exact logarithm "
	     "definition of the gauge fields\n" ) ;
    fprintf( stdout , "FIELD_DEFINITION = {ALL ELSE} - Hermitian projection "
	     "definition of the gauge fields (denoted LINEAR)\n" ) ;
  } else if( are_equal( help_str , "--help=MOM_CUT" ) ) {
    momcut_types( ) ;
  } else if( are_equal( help_str , "--help=MAX_T" ) ) {
    fprintf( stdout , "MAX_T = %%d - serves as the maximum T separation for "
	     "the Polyakov lines\n"
	     "             in the STATIC_POTENTIAL code. Computes "
	     "T=1,2,...,MAX_T separations\n" ) ;
  } else if( are_equal( help_str , "--help=MAXMOM" ) ) {
    fprintf( stdout , "MAXMOM = %%d - maximum allowed n_{mu}n_{mu} "
	     "where n_{mu} is a Fourier mode\n" ) ;
  } else if( are_equal( help_str , "--help=CYL_WIDTH" ) ) {
    fprintf( stdout , "CYL_WIDTH = %%lf - momenta are allowed within the "
	     "body-diagonal cylinder of width CYL_WIDTH * 2 \\pi / L \n"
	     "                  where L is the smallest lattice direction's "
	     "length\n" ) ;
  } else if( are_equal( help_str , "--help=ANGLE" ) ) {
    fprintf( stdout , "ANGLE = %%lf - conical cut's angle of the apex of "
	     "the cone\n" ) ;
  } else if( are_equal( help_str , "--help=OUTPUT" ) ) {
    fprintf( stdout , "OUTPUT = %%s - prefix destination for where the "
	     "output file for the cut procedure will be written. The actual "
	     "output file\n"
	     "              is generated within the code, the output format "
	     "requires CONFNO to be set \n" ) ;
  } else if( are_equal( help_str , "--help=SMEARTYPE" ) ) {
    smeartype_types( ) ;
  } else if( are_equal( help_str , "--help=DIRECTION" ) ) {
    fprintf( stdout , "DIRECTION = SPATIAL    - smears the fields for each "
	     "time-slice only in the ND-1 polarisation directions\n" ) ;
    fprintf( stdout , "          = {ALL ELSE} - fully smears all the links "
	     "in all the directions\n" ) ;
  } else if( are_equal( help_str , "--help=SMITERS" ) ) {
    fprintf( stdout , "SMITERS = %%d - maximum number of smearing iterations "
	     "to perform, some routines such as the Wilson flow will "
	     "often finish\n"
	     "               before this number is reached\n" ) ;
  } else if( are_equal( help_str , "--help=ALPHA" ) ) {
    fprintf( stdout , "ALPHA_%%d = %%lf - Smearing parameters for each "
	     "level of smearing, expects ND-1 of these\n"
	     "                 e.g. ALPHA_1, ALPHA_2 .. ALPHA_ND-1 "
	     "for Hypercubically blocked smearing in\n"
	     "                 all directions. For the Wilson flow and for "
	     "APE, LOG and STOUT smearings ALPHA_1 is the only relevant\n"
	     "                 parameter and all others are ignored\n" ) ;
  } else if( are_equal( help_str , "--help=U1_MEAS" ) ) {
    U1meas_types( ) ;
  } else if( are_equal( help_str , "--help=U1_ALPHA" ) ) {
    fprintf( stdout , "U1_ALPHA = %%lf - The non-compact bare coupling "
	     "g^{2} / 4\\pi, beta is 1 / ( \\pi ND U1_ALPHA ) \n" ) ;
    fprintf( stdout , "\n*caution* FFTW must be linked\n" ) ; 
  } else if( are_equal( help_str , "--help=U1_CHARGE" ) ) {
    fprintf( stdout , "U1_CHARGE = %%lf - Charges the U(1) fields upon "
	     "compactification \n" 
	     "                  U(1)_{mu} = exp( i U1_CHARGE "
	     "sqrt( 4 \\pi U1_ALPHA ) A_{mu} ) \n" ) ;
  } else if( are_equal( help_str , "--help=CONFIG_INFO" ) ) {
    fprintf( stdout , "CONFIG_INFO = %%s - Provide some small details "
	     "for when we write out the configuration file\n" ) ;
  } else if( are_equal( help_str , "--help=STORAGE" ) ) {
    storage_types( ) ;
  } else if( are_equal( help_str , "--help=BETA" ) ) {
    fprintf( stdout , "BETA = %%f - the parameter 2N/g_0^2 with which "
	     "we weight the ensembles in the heatbath\n" ) ;
  } else if( are_equal( help_str , "--help=ITERS" ) ) {
    fprintf( stdout , "ITERS = %%d - the total number of iterations after "
	     "thermalisation that the HB-OR does\n" ) ;
  } else if( are_equal( help_str , "--help=MEASURE" ) ) {
    fprintf( stdout , "MEASURE = %%d - the number of combined HB-OR iters "
	     "before a measurement of the plaquette and polyakov loops\n" ) ;
  } else if( are_equal( help_str , "--help=OVER_ITERS" ) ) {
    fprintf( stdout , "OVER_ITERS = %%d - the number of overrelaxation "
	     "iterations in the combined HB-OR\n" ) ;
  } else if( are_equal( help_str , "--help=SAVE" ) ) {
    fprintf( stdout , "SAVE = %%d - the iteration count at which we save "
	     "a configuration in the HB-OR\n" ) ;
  } else if( are_equal( help_str , "--help=THERMALISATION" ) ) {
    fprintf( stdout , "THERMALISATION = %%d - the number of HB-OR iterations "
	     "of thermalisation before measurement and saving\n" ) ;    
  } else if( are_equal( help_str , "--autoin=LANDAU" ) ) {
    create_input_file( "GAUGE_FIXING" , "LANDAU" ,
		       "TOPOLOGICAL_SUSCEPTIBILITY" ) ;
  } else if( are_equal( help_str , "--autoin=COULOMB" ) ) {
    create_input_file( "GAUGE_FIXING" , "COULOMB" ,
		       "TOPOLOGICAL_SUSCEPTIBILITY" ) ;
  } else if( are_equal( help_str , "--autoin=HEATBATH" ) ) {
    create_input_file( "HEATBATH" , "COULOMB" ,
		       "TOPOLOGICAL_SUSCEPTIBILITY") ;   
  } else if( are_equal( help_str , "--autoin=STATIC_POTENTIAL" ) ) {
    create_input_file( "CUTTING" , "LANDAU" ,
		       "STATIC_POTENTIAL" ) ;
  } else if( are_equal( help_str , "--autoin=SUNCxU1" ) ) {
    create_input_file( "SUNCxU1" , "LANDAU" ,
		       "TOPOLOGICAL_SUSCEPTIBILITY" ) ;
  } else if( are_equal( help_str , "--autoin=WFLOW" ) ) {
    create_input_file( "SMEARING" , "LANDAU" ,
		       "TOPOLOGICAL_SUSCEPTIBILITY" ) ;
  } else {
    fprintf( stdout , "[IO] Unrecognised {input_file} query \"%s\" for\n" , 
	     help_str ) ;
    help_usage() ;
  }
  return GLU_SUCCESS ;
}
Exemplo n.º 8
0
void command_help(doc *d, char **args, int nargs)
{
  if (nargs) return help_usage();
  help();
}
Exemplo n.º 9
0
/* IMPLMENTATION */
int main(int argc, char**argv)
{
    char    cmdConcat[PSMCLI_CMD_LEN_MAX]    = {0};
    char    *pCfg                            = CCSP_MSG_BUS_CFG;
    void    *bus_handle                      = NULL;
    int     tmpLen                           = 0;
    int     cmdTableLen                      = sizeof(cmdsTable) / sizeof(cmdsTable_s);
    int     ret                              = 0;
    char    component_id[256]                = {0} ;
    int     local_argc                       = argc;
    char    **local_argv                     = argv;
    int     i                                = 0;

    enable_ccsp_exception_handlers();

    sprintf(prog_name, "PsmCli.pid%d", getpid());

    // check debug print levell
    psmcli_debug_print = psmcli_get_debug_level(psmcli_debug_file_name);

    // save command line
    for(i=0; i<(argc-1) && (strlen(argv[i])+strlen(cmdLine)+2)<=PSMCLI_STRLEN_MAX; i++) {
        strcat(cmdLine, argv[i]);
        strcat(cmdLine, " ");
    }
    if(i == argc-1 && (strlen(argv[i])+strlen(cmdLine)+1)<=PSMCLI_STRLEN_MAX)
        strcat(cmdLine, argv[i]);

#ifdef PSMCLI_TESTING_LOCAL
    // Echo input
    CcspTraceDebug(("<%s>: invocation = '%s'", prog_name, cmdLine));
#endif

    // Check if the number of args is >= 2
    if(argc < 3) {

        help_usage();

        if((argc == 2) && (!strcmp(argv[1], "help"))) {
            exit(0);
        } else {
            exit(CCSP_ERR_INVALID_ARGUMENTS);
        }
    }
    
    // try to set the subsystem prefix
    if (strcmp(argv[1], "nosubsys") == 0)  {
        if(argc < 4) { // must be followed by a cmd
 	    help_usage();
	    exit(CCSP_ERR_INVALID_ARGUMENTS);
        }
        subsys_prefix[0] = '\0';  
        local_argc = argc - 1;
        local_argv = argv + 1;
    }
    else if (strcmp(argv[1], "subsys") == 0) {
        if(argc < 5) { // must be followed by a string and then a cmd
 	    help_usage();
	    exit(CCSP_ERR_INVALID_ARGUMENTS);
        }
        else {
            strncpy(subsys_prefix, argv[2], 256); // truncate if >256
            subsys_prefix[255] = '\0';  // in case it is not terminated
            local_argc = argc - 2;
            local_argv = argv + 2;
        }
    }
    else { // no subsys nor nosubsys specified, use default prefix
        strcpy(subsys_prefix, PSMCLI_SUBSYSTEM_PREFIX_DEFAULT);
        local_argc = argc;
        local_argv = argv;
    }

    // try to get an unique name for the connection
    sprintf(component_id, "%s.pid%d", psmcli_component_id, getpid()); 

    // Assuming the component_id generated with pid is unique, 
    // So skip the checking to increase speed. RTian 6/19/2013
    /*
    {

    // #define PSMCLI_SUBSYSTEM_PREFIX_GEN_RAND_MAX        997     // a prime close to 1000
    // #define PSMCLI_SUBSYSTEM_PREFIX_GEN_NTRY_MAX        20
    // #include <time.h>

        int nTry = 0, ret = 0;

        srand(time(NULL)*getpid());  // seed the random number generator

        do {
            // each section in component id separated by . cannot start with a number!!! 
            sprintf
                (
                    component_id, 
                    "%s.pid%d.sub%d", 
                    psmcli_component_id, 
                    getpid(), 
                    rand()%PSMCLI_SUBSYSTEM_PREFIX_GEN_RAND_MAX
                ); 
        
            // check if the id is in use already
            ret = psmcli_bus_name_in_use(component_id, pCfg); 
            if(ret < 0 || ret == 1) { nTry++; }
            else break;  // if(ret == 0)

        } while (nTry < PSMCLI_SUBSYSTEM_PREFIX_GEN_NTRY_MAX);

        if (nTry == PSMCLI_SUBSYSTEM_PREFIX_GEN_NTRY_MAX)  
            CcspTraceWarning(("<%s> Error: cannot generate unique id.  Id to be used is %s\n", prog_name, component_id));
    }
    */

    //    CcspTraceDebug(("<%s>: unique component_id = %s\n", prog_name, component_id));

    // Connect to  Dbus and get bus_handle
    // we begin the initiation of dbus    
#ifdef DBUS_INIT_SYNC_MODE
    ret = CCSP_Message_Bus_Init_Synced(component_id, 
                                       pCfg, 
                                       &bus_handle, 
                                       (CCSP_MESSAGE_BUS_MALLOC)Ansc_AllocateMemory_Callback, 
                                       Ansc_FreeMemory_Callback);
#else
    ret = CCSP_Message_Bus_Init(component_id, 
                                pCfg, 
                                &bus_handle, 
                                (CCSP_MESSAGE_BUS_MALLOC)Ansc_AllocateMemory_Callback, 
                                Ansc_FreeMemory_Callback);
#endif
    
    if ( ret == -1 )
    {
        // Dbus connection error
        // Comment below
        CcspTraceWarning(("<%s> Error: DBUS connection error, returned %d,  exitting w/ %d = CCSP_MESSAGE_BUS_CANNOT_CONNECT\n", 
                        prog_name, ret, CCSP_MESSAGE_BUS_CANNOT_CONNECT));
        exit(CCSP_MESSAGE_BUS_CANNOT_CONNECT);
    }

    //    CcspTraceDebug(("<%s>: Message_Bus_Init ok.\n", prog_name));

    // Check if commands are "get -e" or "getdetail -e"
    if((strlen(local_argv[2]) == strlen("-e")) && 
       (!strncmp(local_argv[2], "-e", strlen("-e")))) {
    	// "get -e" or "getdetail -e" command
    	tmpLen = strlen(local_argv[1]);
        
    	// Concatenate command and option
    	if(tmpLen <= (PSMCLI_CMD_LEN_MAX - strlen(" -e"))) {
            strcpy(cmdConcat, local_argv[1]);
            strcat(cmdConcat, " -e"); 
            cmdConcat[PSMCLI_CMD_LEN_MAX-1] = '\0';
            
            i = 0;
            // Search command jumop tables
            while(i < cmdTableLen) {
                if(!strncmp(cmdsTable[i].cmd, cmdConcat, PSMCLI_CMD_LEN_MAX)) {
                    flockfile(stdout);
                    ret = cmdsTable[i].process_cmd(local_argc, (char const * const *)local_argv, bus_handle);
                    funlockfile(stdout);
                    break;
                }
                i++;
            }
            
            if(i == cmdTableLen) {
                CcspTraceWarning(("<%s>: unknown cmd %s, exiting with %d = CCSP_INVALID_PSMCLI_CMD\n", 
                                prog_name, cmdConcat, CCSP_INVALID_PSMCLI_CMD));
                ret = CCSP_INVALID_PSMCLI_CMD;
                goto  EXIT;
            }
            
    	} else {
            CcspTraceWarning(("<%s> Error: Invalid command usage, exiting w/ %d = CCSP_ERR_INVALID_ARGUMENTS\n", 
                            prog_name, CCSP_ERR_INVALID_ARGUMENTS));
            ret = CCSP_ERR_INVALID_ARGUMENTS;
            goto  EXIT;
    	}
        // Check for other commands - get, getdetail, set, setdetail, del
    } else {
    	
    	// Search commands jump table
    	i = 0;
    	while(i < cmdTableLen) {
            if(!strncmp(cmdsTable[i].cmd, local_argv[1], PSMCLI_CMD_LEN_MAX)) {
                flockfile(stdout);
                ret = cmdsTable[i].process_cmd(local_argc, (char const * const *)local_argv, bus_handle);
                funlockfile(stdout);
                break;
            }
            i++;
    	}
        
    	if(i == cmdTableLen) {
            CcspTraceWarning(("<%s>: unknown cmd %s, exiting with %d = CCSP_INVALID_PSMCLI_CMD\n", 
                            prog_name, local_argv[1], CCSP_INVALID_PSMCLI_CMD));
            ret = CCSP_INVALID_PSMCLI_CMD;
            goto  EXIT;
    	}
    }

EXIT:
    CCSP_Message_Bus_Exit(bus_handle);

#ifdef PSMCLI_TESTING_LOCAL
    // Echo return value
    CcspTraceDebug(("<%s>: final return value = %d\n", prog_name, ret));
#endif

    exit(ret);
    // return ret;
}