Example #1
0
/* Entry point for all editors. */
void do_olc (CHAR_DATA * ch, char *argument)
{
    char command[MAX_INPUT_LENGTH];
    int cmd;

    if (IS_NPC (ch))
        return;

    argument = one_argument (argument, command);

    if (command[0] == '\0')
    {
        do_help (ch, "olc");
        return;
    }

    /* Search Table and Dispatch Command. */
    for (cmd = 0; editor_table[cmd].name != NULL; cmd++)
    {
        if (!str_prefix (command, editor_table[cmd].name))
        {
            (*editor_table[cmd].do_fun) (ch, argument);
            return;
        }
    }

    /* Invalid command, send help. */
    do_help (ch, "olc");
    return;
}
Example #2
0
int main(int argc, char *argv[]) {
    int argPos = 0, argNum = argc;

    initMemInfo();
    for (argPos = 1; argPos < argNum;) {
        if (NCcmArgTest(argv[argPos], "-d", "--debug")) {
            SetDebug();
            NCcmArgShiftLeft(argPos, argv, argc);
            argNum--;
            continue;
        }
        if (NCcmArgTest(argv[argPos], "-h", "--help")) {
            if (argv[argPos + 1][0] == 'e') do_help(NCcmProgName(argv[0]), true); else
                do_help(NCcmProgName(argv[0]), false);
            cleanup(NCsucceeded);
        }
        if (NCcmArgTest(argv[argPos], "- ", "-- ")) {
            NCcmArgShiftLeft(argPos, argv, argc);
            argNum--;
            continue;
        }
        if ((argv[argPos][0] == '-') && (strlen(argv[argPos]) > 1)) {
            CMmsgPrint(CMmsgUsrError, "Unknown option: %s!", argv[argPos]);
            cleanup(NCfailed);
        }
        argPos++;
    }

    cleanup(NCsucceeded);
}
void help_main(void)
{
  int i;
  
  if (!(toys.optflags & FLAG_a)) {
    struct toy_list *t = toys.which;

    if (*toys.optargs && !(t = toy_find(*toys.optargs)))
      error_exit("Unknown command '%s'", *toys.optargs);
    do_help(t);
    return;
  }

  if (toys.optflags & FLAG_h) {
    xprintf("<html>\n<title>Toybox command list</title>\n<body>\n<p>\n");
    for (i=0; i < toys.toycount; i++)
      xprintf("<a href=\"#%s\">%s</a>\n", toy_list[i].name,
              toy_list[i].name);
    xprintf("</p>\n");
  }

  for (i = 0; i < toys.toycount; i++) {
    if (toys.optflags & FLAG_h) xprintf("<hr>\n<pre>\n");
    do_help(toy_list+i);
    if (toys.optflags & FLAG_h) xprintf("</pre>\n");
  }

  if (toys.optflags & FLAG_h) xprintf("</html>");
}
Example #4
0
int main(int argc, char **argv) {
	const char *algo = "md5,sha1"; /* default hashing algorithm */
	int c, rad = 0, quit = 0, bsize = 0;
	RIO *io;

	while ((c = getopt (argc, argv, "rva:s:b:Bhf:t:")) != -1) {
		switch (c) {
		case 'r':
			rad = 1;
			break;
		case 'a':
			algo = optarg;
			break;
		case 'B':
			incremental = 0;
			break;
		case 'b':
			bsize = (int)r_num_math (NULL, optarg);
			break;
		case 's':
			{
				ut64 algobit = r_hash_name_to_bits (algo);
				RHash *ctx = r_hash_new (R_TRUE, algobit);
				from = 0;
				to = strlen (optarg);
				do_hash_internal (ctx, //0, strlen (optarg),
					algobit, (const ut8*) optarg,
					strlen (optarg), 0, 1);
				r_hash_free (ctx);
				quit = R_TRUE;
			}
			break;
		case 'f':
			from = r_num_math (NULL, optarg);
			break;
		case 't':
			to = r_num_math (NULL, optarg);
			break;
		case 'v':
			printf ("rahash2 v"R2_VERSION"\n");
			return 0;
		case 'h':
			return do_help (0);
		}
	}

	if (quit)
		return 0;
	if (optind>=argc)
		return do_help (1);

	io = r_io_new ();
	if (!r_io_open (io, argv[optind], 0, 0)) {
		eprintf ("Cannot open '%s'\n", argv[optind]);
		return 1;
	}
	return do_hash (algo, io, bsize, rad);
}
Example #5
0
File: motd.c Project: jmdjr/sdf-mud
void do_motd( CHAR_DATA * ch, char *argument )
{
   if( IS_NPC( ch ) )
      return;

   if( ch->level >= 103 )
   {
      if( argument[0] == '\0' )
      {
         send_to_char( "Syntax:  motd <imotd / gmotd / amotd / motd / nmotd>\r\n", ch );
         return;
      }
      else
      {
         if( !str_cmp( argument, "imotd" ) )
         {
            do_help( ch, "imotd" );
         }
         else if( !str_cmp( argument, "gmotd" ) )
         {
            do_help( ch, "gmotd" );
         }
         else if( !str_cmp( argument, "amotd" ) )
         {
            do_help( ch, "amotd" );
         }
         else if( !str_cmp( argument, "motd" ) )
         {
            do_help( ch, "motd" );
         }
         else if( !str_cmp( argument, "nmotd" ) )
         {
            do_help( ch, "nmotd" );
         }
         else
         {
            send_to_char( "Syntax:  motd <imotd / gmotd / amotd / motd / nmotd>\r\n", ch );
            return;
         }

      }
   }
   else if( ch->level >= 101 )
   {
      do_help( ch, "gmotd" );
   }
   else if( ch->level >= 50 )
   {
      do_help( ch, "amotd" );
   }
   else if( ch->level >= 2 )
   {
      do_help( ch, "motd" );
   }
   else if( ch->level == 1 )
   {
      do_help( ch, "nmotd" );
   }

}
Example #6
0
int
main(int argc, char** argv)
{
    int res;
    wchar_t* filename;
    int index;
    FILE* out;

    IStorage* storage;

    if (argc < 4) {
        (void)do_help(argc, argv);
        return 1;
    }
    filename = strdupwstr(argv[1]);
    index = atoi(argv[2]);
    out = fopen(argv[3], "wb");
    if (out == NULL)
        fatal("Error opening file to save to");

    res = OpenStore(filename, FALSE, &storage);
    if (res == 0)
        fatal("Error opening store");
    free(filename);

    res = SaveStream(storage, index, out);
    if (res == 0)
        fatal("Error saving stream");

    (int)CloseStore(storage);
    (int)fclose(out);
    return 0;
}
int main(int argc, char** argv)
{
	options opts = parse_cmd_line(argc,argv);

	if(opts.do_help)
	{
		if(opts.error)
		{
			std::cout << "Error parsing the command line." << std::endl;
		}

		do_help(argv);
		return -1;
	}

	if(test_duplicate_list(opts.node_count,opts.use_quick_and_dirty))
	{
		std::cout << "Contratulations. duplicate_list is a success." << std::endl;
	}
	else
	{
		std::cout << "Unfortunately, duplicate_list failed." << std::endl;
	}

	return 0;
}
Example #8
0
int main(int argc, char **argv)
{ char	**real_args;

  if (argc <= 1) usage();

  argc	-= 2;
  real_args = &(argv[2]);
  
  if (!strcmp(argv[1], "info"))
   do_info(argc, real_args);
  elif (!strcmp(argv[1], "monitor"))
   do_monitor(argc, real_args);
  elif (!strcmp(argv[1], "show"))
   do_show(argc, real_args);
  elif (!strcmp(argv[1], "showall"))
   do_showall(argc, real_args);
  elif (!strcmp(argv[1], "list"))
   do_list(argc, real_args);
  elif (!strcmp(argv[1], "owners"))
   do_owners(argc, real_args);
  elif (!strncmp(argv[1], "avail", 5))
   do_avail(argc, real_args);
  elif (!strcmp(argv[1], "help"))
   do_help(argc, real_args);
  else
   { fprintf(stderr, "network: unknown option %s\n", argv[1]);
Example #9
0
int
main(int argc, char** argv)
{
    int res;
    wchar_t* filename; wchar_t* storename; wchar_t* sourcename;
    int index;

    IStorage* storage;

    if (argc < 4) {
        (void)do_help(argc, argv);
        return 1;
    }
    filename = strdupwstr(argv[1]);
    index = atoi(argv[3]);
    sourcename = strdupwstr(argv[2]);
    
    res = OpenStore(filename, TRUE, &storage);
    if (res == 0)
        fatal("Error opening store");
    free(filename);

    res = GetStreamName(storage, index, &storename);
    if (res == 0)
        fatal("Error geting store name");

    res = AddStore(storage, storename, sourcename);
    if (res == 0)
        fatal("Error adding store");

    (void)free(storename);
    (void)free(sourcename);
    (int)CloseStore(storage);
    return 0;
}
Example #10
0
void edit_mail_mode(USER_DATA *usr, char *argument) {
	char arg[INPUT];

	while (isspace(*argument))
		argument++;

	smash_tilde(argument);
	usr->timer = 0;

	argument = one_argument(argument, arg);

	if (arg[0] == '\0') {
		func_rnew_mail(usr);
		return;
	} else if (!str_cmp(arg, "?") || !str_cmp(arg, "h")) {
		do_help(usr, "MAIL_DATA-INDEX");
		return;
	} else if (!str_cmp(arg, "l")) {
		func_list_mail(usr);
		return;
	} else if (!str_cmp(arg, "r")) {
		func_reply_mail(usr, argument);
		return;
	} else if (!str_cmp(arg, "d")) {
		func_delete_mail(usr, argument);
		return;
	} else if (!str_cmp(arg, "q")) {
		func_quit_mail(usr);
		return;
	} else if (!str_cmp(arg, "c")) {
		if (argument[0] == '\0') {
			syntax("[#Wc#x]ompose <user name>", usr);
			return;
		}

		if (!is_user(argument)) {
			send_to_user("No such user.\n\r", usr);
			return;
		}

		if (is_enemy(usr, argument)) {
			send_to_user("You can't sent mail to your enemies.\n\r", usr);
			return;
		}

		mail_attach(usr);
		if (usr->pCurrentMail->to)
			free_string(usr->pCurrentMail->to);
		usr->pCurrentMail->to = str_dup(argument);
		EDIT_MODE(usr) = EDITOR_MAIL_SUBJECT;
		return;
	} else if (is_number(arg)) {
		func_read_mail(usr, arg);
		return;
	} else {
		send_to_user(
				"Unknown mail command, try '?' in order to show help.\n\r", usr);
		return;
	}
}
Example #11
0
int main(int argc, char *const *argv)
{
	om_flags_led = OM_FLAGS_LED_STANDALONE;

	if (parse_options(argc, argv) != 0)
	{
		usage(stderr);
		return 1;
	}
	argc -= optind-1;
	argv += optind-1;

	if (opts.help)
		return do_help(argc, argv);
	if (opts.version)
		return do_version(argc, argv);

	if (argc == 0)
	{
		usage(stderr);
		return 1;
	}
	return do_led(argc, argv);

	return 0;
}
Example #12
0
int main(int argc, char* argv[]) {
	signal(SIGTERM, terminar);
	srand(time(NULL));
	forn(i, argc) {
		if(strcmp(argv[i], "--help") == 0) do_help(argv[0]);
		else if(strcmp(argv[i], "--profiling") == 0 || strcmp(argv[i], "-p") == 0) profiling = true;
		else if(strcmp(argv[i], "--alphabeta") == 0 || strcmp(argv[i], "-ab") == 0) alphabeta = true;
		else if(strcmp(argv[i], "--height") == 0 && argc > i+1) height = atoi(argv[i+1]);
		else if(strcmp(argv[i], "--funcion") == 0 && argc > i+1) funcion = atoi(argv[i+1]);
		else if(strcmp(argv[i], "--adaptive") == 0 && argc > i+2) do_adaptive(argv, i);
		else if(strcmp(argv[i], "--params") == 0) fill_player(def_player, argv, i, argc);
	}
       /* Si c==1, arrancamos leyendo una jugada del otro */
	int c;
	cin >> n >> c;
	if(adaptive) {
		nx = (int) pow((float) n, x);	
		adaptive_info();
	}
	tablero.resize(n, vint(n, VACIO));
	if(profiling) ENABLE_PROFILING(n)
	else DISABLE_PROFILING()
	if(height <= 0) height = n*n/2+1;
	if (n>1 && c) lee_movida();
	while (hay_movida()) {	
		juega_movida();
		// Si no hay movida para hacer se cuelga leyendo, pero el judge nos mata el proceso con SIGTERM
		lee_movida();
	}
	return 0;
}
Example #13
0
void do_mail(USER_DATA *usr, char *argument) {
	char arg[INPUT];

	one_argument(argument, arg);

	if (arg[0] == '\0') {
		print_to_user(usr, "\n\rTotal messages: %-3d\n\r\n\r", count_mail(usr));
		do_help(usr, "MAIL_DATA-INDEX");
		EDIT_MODE(usr) = EDITOR_MAIL;
		return;
	}

	if (!is_user(arg)) {
		send_to_user("No such user.\n\r", usr);
		return;
	}

	if (is_enemy(usr, arg)) {
		send_to_user("You can't sent mail to your enemies.\n\r", usr);
		return;
	}

	mail_attach(usr);
	if (usr->pCurrentMail->to)
		free_string(usr->pCurrentMail->to);
	usr->pCurrentMail->to = str_dup(arg);
	EDIT_MODE(usr) = EDITOR_MAIL_SUBJECT;
}
Example #14
0
/* Dispatch function for backwards compatibility */
void do_note (CHAR_DATA *ch, char *argument)
{
	char arg[MAX_INPUT_LENGTH];

	if (IS_NPC(ch))
		return;
	
	argument = one_argument (argument, arg);
	
	if ((!arg[0]) || (!str_cmp(arg, "read"))) /* 'note' or 'note read X' */
		do_nread (ch, argument);
		
	else if (!str_cmp (arg, "list"))
		do_nlist (ch, argument);

	else if (!str_cmp (arg, "write"))
		do_nwrite (ch, argument);

	else if (!str_cmp (arg, "remove"))
		do_nremove (ch, argument);
		
	else if (!str_cmp (arg, "purge"))
		send_to_char ("Obsolete.\n\r",ch);
	
	else if (!str_cmp (arg, "archive"))
		send_to_char ("Obsolete.\n\r",ch);
	
	else if (!str_cmp (arg, "catchup"))
		do_ncatchup (ch, argument);
	else 
		do_help (ch, "note");
}
Example #15
0
static void process_cmd(char *p, unsigned char is_job)
{
    char cmd[64];
    int i = 0;
    char *p_saved = p;

    get_str(&p, cmd);

    /* table commands */
    while (console_cmd_list[i].name != NULL)
    {
        if (is_cmd(console_cmd_list[i].name))
        {
            
            if (!is_job && console_cmd_list[i].is_job)
            {
                
                create_cmdjob(p_saved);
            }
            else
            {
                console_cmd_list[i].handler(p);
            }
            return;
        }
        i++;
    }
    bdt_log("%s : unknown command\n", p_saved);
    do_help(NULL);
}
Example #16
0
/* Start the help viewer. */
void do_help_void(void)
{
#ifndef DISABLE_HELP
    do_help();
#else
    if (currmenu == MMAIN)
	say_there_is_no_help();
    else
	beep();
#endif /* !DISABLE_HELP */
}
Example #17
0
int run_command(const struct futil_cmd_t *cmd, int argc, char *argv[])
{
	/* Handle the "CMD --help" case ourselves */
	if (2 == argc && 0 == strcmp(argv[1], "--help")) {
		char *fake_argv[] = {"help",
				     (char *)cmd->name,
				     NULL};
		return do_help(2, fake_argv);
	}

	return cmd->handler(argc, argv);
}
Example #18
0
//
// main
//
int main(int argc, char **argv) {

	int dev_demo_map_fd;
	void *demo_driver_map;
	int result;
	
	//
	// parse the command line arguments
	//
	parse_cmdline(argc, argv);

	//
	// open() the /dev/mem device
	//
	dev_demo_map_fd = open("/dev/demo_map", O_RDWR | O_SYNC);
	if(dev_demo_map_fd < 0) {
		perror("dev_demo_map open");
		exit(EXIT_FAILURE);
	}

	//
	// mmap() the base of our demo_driver hardware
	//
	demo_driver_map = mmap(NULL, sysconf(_SC_PAGE_SIZE), PROT_READ|PROT_WRITE, MAP_SHARED, dev_demo_map_fd, 0);
	if(demo_driver_map == MAP_FAILED) {
		perror("dev_demo_map mmap");
		close(dev_demo_map_fd);
		exit(EXIT_FAILURE);
	}

	//
	// perform the operation selected by the command line arguments
	//
	if(g_print_timer	!= NULL) do_print_timer(demo_driver_map);
	if(g_dump_rom		!= NULL) do_dump_rom(demo_driver_map);
	if(g_dump_ram		!= NULL) do_dump_ram(demo_driver_map);
	if(g_fill_ram		!= NULL) do_fill_ram(demo_driver_map);
	if(g_help		!= NULL) do_help();

	//
	// munmap everything and close the /dev/mem file descriptor
	//
	result = munmap(demo_driver_map, sysconf(_SC_PAGE_SIZE));
	if(result < 0) {
		perror("dev_demo_map munmap");
		close(dev_demo_map_fd);
		exit(EXIT_FAILURE);
	}

	close(dev_demo_map_fd);
	exit(EXIT_SUCCESS);
}
Example #19
0
void do_changes( char_data* ch, char* )
{
  species_data*   species;
  int                   i;
 
  do_help( ch, "Changes_Disclaimer" );

  page( ch, "Monsters:\r\n" );

  for( i = 0; i < MAX_SPECIES; i++ ) 
    if( ( species = species_list[i] ) != NULL ) 
      if( species->date > current_time-5*24*60*60 ) 
        page( ch, "  %s\r\n", species->Name( ) );

  return;
}
Example #20
0
/*! \brief HELP command handler
 *
 * \param source_p Pointer to allocated Client struct from which the message
 *                 originally comes from.  This can be a local or remote client.
 * \param parc     Integer holding the number of supplied arguments.
 * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
 *                 pointers.
 * \note Valid arguments for this command are:
 *      - parv[0] = command
 *      - parv[1] = help topic
 */
static int
m_help(struct Client *source_p, int parc, char *parv[])
{
  static uintmax_t last_used = 0;

  if ((last_used + ConfigGeneral.pace_wait_simple) > CurrentTime)
  {
    sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "HELP");
    return 0;
  }

  last_used = CurrentTime;

  do_help(source_p, parv[1]);
  return 0;
}
void
init()
{
#ifdef 0
/*
  Make it so only bigwigs can use this object.
*/
    string  euid;
    object  tp;

    tp   = this_player();
    euid = geteuid( tp );

    if ( ( "/secure/master"->god( euid )             )
      || ( "/secure/master"->high_programmer( euid ) )
      || ( "/secure/master"->query_lord( euid )      )
      || ( tp->query_creator()                       )
      || ( tp->query_app_creator()                   ) )
    {
  add_action( "do_create" , "create" );
  add_action( "do_help"   , "help"   );
  add_action( "do_level"  , "level"  );
  add_action( "do_story"  , "story"  );
  add_action( "do_title"  , "title"  );

  if ( ( "/secure/master"->god( euid )             )
    || ( "/secure/master"->high_programmer( euid ) )
    || ( "/secure/master"->query_lord( euid )      ) )
  {
      add_action( "do_delete" , "delete" );
      add_action( "do_list"   , "list"   );
  }
/*
      Reinitialize settings.
*/
  level = 0;
  story = 0;
  title = 0;

  do_help( "room" );

  tell_room( this_object() , "\nQuest settings have been reset to "
         + "nulls by init().\n\n" );
    }
    ::init();
#endif
}
Example #22
0
void
process_message(int s, UCRP *rm, UCRP *sm)
{
	UCRP_PMSG((stdout, rm));

	switch (rm->type) {
	case UCRP_COMMAND:
		do_command(s, rm, sm);
		break;
	case UCRP_COMPLETE:
		do_complete(s, rm, sm);
		break;
	case UCRP_HELP:
		do_help(s, rm, sm);
		break;
	case UCRP_INTERRUPT:
		ucrp_log(LOG_NOTICE, "%s: ignoring UCRP_INTERRUPT\n",
			 __func__);
		break;
	case UCRP_TELL:
		ucrp_pmsg(stdout, rm);
		break;
	case UCRP_SUSPEND:
		ucrp_log(LOG_NOTICE, "%s: ignoring UCRP_SUSPEND\n",
			 __func__);
		break;
	case UCRP_WAIT:
	{
		char *lp = UCRP_PAYLOAD(rm);
		fprintf(stdout, "%s: UCRP_WAIT: "
			"WAIT_SIGNAL=%d "
			"WAIT_ERROR=%d "
			"WAIT_STATUS=%s\n",
			__func__,
			rm->options & WAIT_SIGNAL ? 1 : 0,
			rm->options & WAIT_ERROR  ? 1 : 0,
			rm->options & WAIT_STATUS ? ucrp_msg_getln(&lp) :
			"N/A");
		break;
	}
	default:
		ucrp_log(LOG_NOTICE, "unknown message type=%u\n", rm->type);
		break;
	}

	return;
}
Example #23
0
File: sacct.c Project: ax3l/slurm
int main(int argc, char **argv)
{
	enum {
		SACCT_LIST,
		SACCT_HELP,
		SACCT_USAGE
	} op;
	int rc = 0;

	slurm_conf_init(NULL);
	sacct_init();
	parse_command_line(argc, argv);

	/* What are we doing? Requests for help take highest priority,
	 * but then check for illogical switch combinations.
	 */

	if (params.opt_help)
		op = SACCT_HELP;
	else
		op = SACCT_LIST;


	switch (op) {
	case SACCT_LIST:
		print_fields_header(print_fields_list);
		if (get_data() == SLURM_ERROR)
			exit(errno);
		if (params.opt_completion)
			do_list_completion();
		else
			do_list();
		break;
	case SACCT_HELP:
		do_help();
		break;
	default:
		fprintf(stderr, "sacct bug: should never get here\n");
		sacct_fini();
		exit(2);
	}

	sacct_fini();
	return (rc);
}
/** Main Function */
int main(int argc, char *argv[])
{
  int i;
  const char *apkfilename=NULL;
  char filename_try[MAXFILENAME+16] = "";
  unzFile uf=NULL;

  /** Checking the no.of args */
  if ( argc == 1 ) {
    do_help();
    return 0;
  } else 

    /** Handling multiple files */
    for ( i = 1; i < argc; i++ ){
      apkfilename = argv[i];
      printf(KBLU"\nFile Name : %s\n"RESET,apkfilename);
      /** Providing the feature to specify just name instead of name.apk */
      if (apkfilename!=NULL) {
        strncpy(filename_try, apkfilename,MAXFILENAME-1);
        /** strncpy doesnt append the trailing NULL, of the string is too long. */
        filename_try[ MAXFILENAME ] = '\0';

        /** Opening apk file using minizip library */
        uf = unzOpen(apkfilename);
        if ( uf == NULL ) {
          strcat(filename_try, ".apk");
          uf = unzOpen(filename_try);
        }
      }

      if (uf == NULL ) {
        printf(KRED"Cannot open %s or %s.apk\n"RESET,apkfilename,apkfilename);
        return 1;
      }
      /** Calling the actual extraction operation */
      do_list(uf);
    }

  /** Closing the file */
  unzCloseCurrentFile(uf);

  return 0;
}
Example #25
0
File: help.c Project: boz/elfcrunch
int command_help( char** argv ){
   cmd_node_t * cmds;

   if(!(cmds = get_command_head()))
      error_ret("can't get commands",COMMAND_ERROR);

   if(!*argv){ /* top-level */
      printf("%s:\t%s\noptions:\n",command_h.str,command_h.msg);
      for(cmds = cmds->opts; cmds ; cmds=cmds->next){
         if(!cmds->cmd ||!cmds->cmd->str ||!cmds->cmd->msg )
            error_ret("command has no name",COMMAND_ERROR);
         printf("%s:\t%s\n",cmds->cmd->str,cmds->cmd->msg);
      }
   }
   else
   {
      return( do_help( cmds , argv ) );
   }
}
Example #26
0
void
do_cmd(
	tffs_handle_t htffs)
{
	tsh_session_t * psession;
	char cmd[MAX_CMD_LEN];

	psession = (tsh_session_t *)malloc(sizeof(tsh_session_t));
	strcpy(psession->cur_dir, "/");
	psession->htffs = htffs;

	while (1) {
		int ci;

		printf("%s:>", psession->cur_dir);
		memset(cmd, 0, MAX_CMD_LEN);
		get_cmd(cmd);
		parse_cmd(cmd, psession);

		if (psession->argc == 0)
			continue;

		for (ci = 0; ci < chs_num; ci++) {
			if (!strcmp(chs[ci].cmd, psession->argv[0])) {
				if (chs[ci].handler == NULL) {
					goto _end;
				}
				else {
					chs[ci].handler(psession);
					break;
				}
			}
		}

		if (ci == chs_num) {
			printf("Unrecognized command %s\n", cmd);
			do_help(psession);
		}
	}

_end:
	free(psession);
}
Example #27
0
/* 
 * builtin_cmd - If the user has typed a built-in command then execute
 *    it immediately.  
 */
int builtin_cmd(char **argv) 
{
    char *cmd = argv[0];

    if (!strcmp(cmd, "help")) { /* quit command */
      do_help();  
      return 1;
    }

    if (!strcmp(cmd, "stop")) { /* quit command */
      do_stop(argv);
      return 1;
    }

    if (!strcmp(cmd, "exit")) { /* quit command */
      do_exit();
      return 1;
    }

    if (!strcmp(cmd, "jobs")) { /* jobs command */
      do_jobs();
      return 1;    
    }

    if (!strcmp(cmd, "bg")) { /* bg and fg commands */
      do_bg(argv);
      return 1;
    }

    if (!strcmp(cmd, "fg")) { /* bg and fg commands */
      do_fg(argv);
      return 1;
    }

    if (!strcmp(cmd, "kill")) { /* bg and fg commands */
      do_kill(argv);
      return 1;
    }


    return 0;     /* not a builtin command */
}
// Main driver for program1
int main(int argc, char** argv)
{
	options opts = parse_cmd_line(argc, argv);

	if(opts.do_help)
	{
		if(opts.error)
		{
			std::cout << "Error parsing command line." << std::endl;
		}

		do_help(argv);
		return -1;
	}

	if(opts.run_tests)
	{
		std::ifstream file;
		file.open(opts.input_file,std::ifstream::out);
		
		test_reverse_word(file);
		file.close();
		return 0;
	}

	char* sentence = &opts.sentence[0];
	std::cout << "Input sentence:  " << opts.sentence << std::endl;

	if(opts.use_quick_and_dirty)
	{
		reverse_words_quick_and_dirty(sentence);
	}
	else
	{
		reverse_words(sentence);
	}

	std::cout << "Output sentence: " << sentence << std::endl;

	return 0;
}
Example #29
0
//++++++++++++++++++++++++++++++++++
void view_edit_search::init_layout(){

    //
    _vbox = new QVBoxLayout();
    setLayout(_vbox);

    //
    _hbox_top = new QHBoxLayout();
    _hbox_mid = new QHBoxLayout();
    _hbox_low = new QHBoxLayout();
    _vbox->addLayout( _hbox_top );
    _vbox->addLayout( _hbox_mid );
    _vbox->addLayout( _hbox_low );

    //  Top.
    //
    _list_attributes = new QListWidget();
    _list_cats = new QListWidget();
    connect( _list_attributes, SIGNAL( itemClicked(QListWidgetItem*) ), this, SLOT( write_categories(QListWidgetItem*) ) );
    connect( _list_cats, SIGNAL( itemClicked(QListWidgetItem*) ), this, SLOT( append_value_to_query(QListWidgetItem*) ) );
    _hbox_top->addWidget( _list_attributes );
    _hbox_top->addWidget( _list_cats );

    //  Mid.
    //
    _text_query = new QTextEdit();
    _hbox_mid->addWidget( _text_query );

    //  Low.
    //
    _button_help = new QPushButton( "Help" );
    _button_submit = new QPushButton( "Submit" );
    _button_cancel = new QPushButton( "Cancel" );
    connect(_button_help, SIGNAL(clicked()), this, SLOT(do_help()) );
    connect(_button_submit, SIGNAL(clicked()), this, SLOT(do_submit()) );
    connect(_button_cancel, SIGNAL(clicked()), this, SLOT(close()) );

    _hbox_low->addWidget( _button_help );
    _hbox_low->addWidget( _button_submit );
    _hbox_low->addWidget( _button_cancel );
}
Example #30
0
int torloris_main(int argc, char **argv) {
	pthread_t threads[THREADS];
	pthread_t cycle_tid;
	thread_args arg;
	void *status;
	int x;
	if(argc != 3)
	do_help(argv[0]);
	arg.host = (const char *)argv[1];
	arg.port = (const char *)argv[2];
	pthread_create(&cycle_tid, NULL, tlcycle_identity, NULL);
	for(x=0; x < THREADS; x++) {
	pthread_create(&threads[x], NULL, tlattack, &arg);
	usleep(200000);
	}
	for(x=0; x < THREADS; x++)
	pthread_join(threads[x], &status);
	pthread_kill(cycle_tid, 15);
	pthread_exit(NULL);
	return 0;
}