예제 #1
0
int     main( int argc, char *argv[] ) {
//======================================

// FORTRAN compiler main line.

    int         ret_code;
    char        *opts[MAX_OPTIONS+1];
    char        *p;
#if !defined( __INCL_ERRMSGS__ )
    char        imageName[_MAX_PATH];
#endif

#if !defined( __WATCOMC__ )
    _argc = argc;
    _argv = argv;
#else
    argc = argc;
    argv = argv;
#endif
#if defined( __INCL_ERRMSGS__ )
    __InitError();
    __ErrorInit( NULL );
#else
    _cmdname( imageName );
    __InitResource();
    __ErrorInit( imageName );
#endif
#if defined( _M_IX86 )
    _real87 = _8087 = 0;
#endif
    p = getenv( _WFC );
    if( p != NULL && *p != '\0' ) {
        strcpy( CmdBuff, p );
        p = &CmdBuff[ strlen( p ) ];
        *p = ' ';
        ++p;
    } else {
        p = CmdBuff;
    }
    getcmd( p );
    ret_code = 0;
    InitCompMain();
    if( MainCmdLine( &SrcName, &CmdPtr, opts, CmdBuff ) ) {
        SrcExtn = SDSrcExtn( SrcName ); // parse the file name in case we get
        ProcOpts( opts );               // an error in ProcOpts() so error
        InitPredefinedMacros();         // file can be created
        ret_code = CompMain( CmdBuff );
    } else {
        ShowUsage();
    }
    FiniCompMain();
    __ErrorFini();
    return( ret_code );
}
예제 #2
0
파일: main.c 프로젝트: kidaak/pkgsrc
/*
 * Help/usage command.
 * Call each command handler with argc == 0 and argv[0] == name.
 */
void
help(int argc, char *argv[])
{
	struct cmd *c;
	char *nargv[1], *cmd;
	const char *p;
	int isusage;

	cmd = argv[0];
	isusage = (strcmp(cmd, "usage") == 0);
	if (argc == 0 || (isusage && argc == 1)) {
		UPRINTF("usage: %s [command [...]]\n", cmd);
		return;
	}
	if (argc == 1) {
		StringList *buf;

		buf = ftp_sl_init();
		fprintf(ttyout,
		    "%sommands may be abbreviated.  Commands are:\n\n",
		    proxy ? "Proxy c" : "C");
		for (c = cmdtab; (p = c->c_name) != NULL; c++)
			if (!proxy || c->c_proxy)
				ftp_sl_add(buf, ftp_strdup(p));
		list_vertical(buf);
		sl_free(buf, 1);
		return;
	}

#define	HELPINDENT ((int) sizeof("disconnect"))

	while (--argc > 0) {
		char *arg;
		char cmdbuf[MAX_C_NAME];

		arg = *++argv;
		c = getcmd(arg);
		if (c == (struct cmd *)-1)
			fprintf(ttyout, "?Ambiguous %s command `%s'\n",
			    cmd, arg);
		else if (c == NULL)
			fprintf(ttyout, "?Invalid %s command `%s'\n",
			    cmd, arg);
		else {
			if (isusage) {
				(void)strlcpy(cmdbuf, c->c_name, sizeof(cmdbuf));
				nargv[0] = cmdbuf;
				(*c->c_handler)(0, nargv);
			} else
				fprintf(ttyout, "%-*s\t%s\n", HELPINDENT,
				    c->c_name, c->c_help);
		}
	}
}
예제 #3
0
int rcptfilter_ctlmsg()
{
	std::string cmd=getcmd();

	std::cerr << "200 Ok" << std::endl;

	if (is_cmd(cmd.c_str(), "subscribe") ||
	    is_cmd(cmd.c_str(), "alias-subscribe"))
		return 99;

	return 0;
}
예제 #4
0
/* terminal mode */
void terminal(void)
{
	for (;;) {
		printf("%s", prompt);

		getcmd();

		/* execute a user command */
		if (cmd_buf[0])
			execcmd();
	}
}
예제 #5
0
/*
 * Help command.
 */
void
help(int argc, char **argv)
{
	struct cmd *c;

	if (argc == 1) {
		int i, j, w;
		int columns, width = 0, lines;

		printf("Commands may be abbreviated.  Commands are:\n\n");
		for (c = cmdtab; c->c_name; c++) {
			int len = strlen(c->c_name);

			if (len > width)
				width = len;
		}
		width = (width + 8) &~ 7;
		columns = 80 / width;
		if (columns == 0)
			columns = 1;
		lines = (NCMDS + columns - 1) / columns;
		for (i = 0; i < lines; i++) {
			for (j = 0; j < columns; j++) {
				c = cmdtab + j * lines + i;
				if (c->c_name)
					printf("%s", c->c_name);
				if (c + lines >= &cmdtab[NCMDS]) {
					printf("\n");
					break;
				}
				w = strlen(c->c_name);
				while (w < width) {
					w = (w + 8) &~ 7;
					putchar('\t');
				}
			}
		}
		return;
	}
	while (--argc > 0) {
		char *arg;

		arg = *++argv;
		c = getcmd(arg);
		if (c == (struct cmd *)-1)
			printf("?Ambiguous help command %s\n", arg);
		else if (c == NULL)
			printf("?Invalid help command %s\n", arg);
		else
			printf("%-*s\t%s\n", (int) HELPINDENT,
				c->c_name, c->c_help);
	}
}
예제 #6
0
void
boot(dev_t bootdev)
{
	const char *bootfile = kernels[0];
	int i = 0, try = 0, st;
	u_long marks[MARK_MAX];

	machdep();

	snprintf(prog_ident, sizeof(prog_ident),
	    ">> OpenBSD/" MACHINE " %s %s", progname, version);
	printf("%s\n", prog_ident);

	devboot(bootdev, cmd.bootdev);
	strlcpy(cmd.image, bootfile, sizeof(cmd.image));
	cmd.boothowto = 0;
	cmd.conf = "/etc/boot.conf";
	cmd.addr = (void *)DEFAULT_KERNEL_ADDRESS;
	cmd.timeout = 5;

	st = read_conf();
	if (!bootprompt)
		snprintf(cmd.path, sizeof cmd.path, "%s:%s",
		    cmd.bootdev, cmd.image);

	while (1) {
		/* no boot.conf, or no boot cmd in there */
		if (bootprompt && st <= 0)
			do {
				printf("boot> ");
			} while(!getcmd());
		st = 0;
		bootprompt = 1;	/* allow reselect should we fail */

		printf("booting %s: ", cmd.path);
		marks[MARK_START] = (u_long)cmd.addr;
		if (loadfile(cmd.path, marks, LOAD_ALL) >= 0)
			break;

		if (kernels[++i] == NULL) {
			try += 1;
			bootfile = kernels[i=0];
		} else
			bootfile = kernels[i];
		strlcpy(cmd.image, bootfile, sizeof(cmd.image));
		printf(" failed(%d). will try %s\n", errno, bootfile);

		if (try < 2) {
			if (cmd.timeout > 0)
				cmd.timeout++;
		} else {
			if (cmd.timeout)
예제 #7
0
파일: main.c 프로젝트: pmyadlowsky/qmx
static void sigsnag(int sig, siginfo_t *info, void *data) {
	log_msg("SIGNAL: %s[%d]\n", strsignal(sig), sig);
	log_msg("ERRNO: %s[%d]\n", strerror(errno), errno);
	log_msg("CMD: %s\n", getcmd(info->si_pid));
	struct passwd *pwd = getpwuid(info->si_uid);
	log_msg("USER: %s\n", pwd->pw_name);
	if (sig == SIGCHLD) {
		while (waitpid(-1, NULL, WNOHANG) > 0);
		}
	else if (sig == SIGHUP);
	else running = 0;
	return;
	}
예제 #8
0
파일: main.c 프로젝트: 274914765/C
/*
 * Command parser.
 */
static void command (void)
{
    struct cmd *c;

    for (;;)
    {
#ifdef WITH_READLINE
        if (line)
            free (line);
        line = readline (prompt);
        if (!line)
            exit (0);            /* EOF */
#else
        fputs (prompt, stdout);
        if (fgets (line, LBUFLEN, stdin) == 0)
        {
            if (feof (stdin))
            {
                exit (0);
            }
            else
            {
                continue;
            }
        }
#endif
        if ((line[0] == 0) || (line[0] == '\n'))
            continue;
#ifdef WITH_READLINE
#ifdef HAVE_READLINE_HISTORY_H
        add_history (line);
#endif
#endif
        makeargv ();
        if (margc == 0)
            continue;

        c = getcmd (margv[0]);
        if (c == (struct cmd *) -1)
        {
            printf ("?Ambiguous command\n");
            continue;
        }
        if (c == 0)
        {
            printf ("?Invalid command\n");
            continue;
        }
        (*c->handler) (margc, margv);
    }
}
예제 #9
0
파일: term.c 프로젝트: caihang/vivi
void serial_term(void)
{
	char cmd_buf[MAX_CMDBUF_SIZE];

	for (;;) {
		printk("%s> ", prompt);

		getcmd(cmd_buf, MAX_CMDBUF_SIZE);

		/* execute a user command */
		if (cmd_buf[0])
			exec_string(cmd_buf);
	}
}
예제 #10
0
int  main()
/*********/

{
    char                *cmd;
    void               (*parse_object)( void );

#if defined( _M_I86SM ) || defined( _M_I86MM )
    _heapgrow();    /* grow the near heap */
#endif
    if( !MsgInit() ) return( EXIT_FAILURE );
    cmd = AllocMem( CMD_LINE_SIZE );
    getcmd( cmd );
    InitOutput();
    initOptions();
    parseOptions( cmd );
    openFiles();
    InitObj();
    parse_object = InitORL() ? ParseObjectORL : ParseObjectOMF;
    for( ;; ) {
        InitTables();
        ModNameORL = rootName;
        parse_object();
        if( Mod == NULL ) {
            break;
        }
        if( srcReqd ) {
            if( SrcName == NULL ) {
                if( CommentName != NULL ) {
                    SrcName = CommentName;
                } else if( Mod->name != NULL ) {
                    SrcName = Mod->name;
                } else {
                    SrcName = rootName;
                }
            }
            OpenSource();
        }
        DisAssemble();
        if( Source != NULL ) {
            CloseTxt( Source );
        }
        SrcName = NULL;         /* if another module, get name from obj file */
    }
    if( UseORL ) FiniORL();
    CloseBin( ObjFile );
    CloseTxt( Output );
    MsgFini();
    return( 0 );
}
예제 #11
0
int main_getcmd(int argc, char **argv)
{
  char data[] = "DT 555-1212";
  int index = 0, num = 0, start = 0, end = 0;
  int cmd = 0;


  while (cmd != AT_CMD_END) {
    cmd = getcmd(data, &index, &num, &start, &end);
    printf("Cmd: %c Index: %d Num: %d Start: %d End: %d\n", cmd, index, num, start, end);
  }

  return 0;
}
예제 #12
0
파일: ConnectCmds.cpp 프로젝트: elfmz/far2l
void Connection::doproxy(int argc, char *argv[])
{
	PROC(("doproxy","%d [%s,%s,%s]",argc,(argc>=1)?argv[0]:"nil",(argc>=2)?argv[1]:"nil",(argc>=3)?argv[2]:"nil"));
	struct cmd *c;

	if(argc < 2)
	{
		code = -1;
		return;
	}

	c = getcmd(argv[1]);

	//Not found
	if(c == (cmd*)-1 || c == 0)
	{
		WINPORT(SetLastError)(ERROR_BAD_DRIVER_LEVEL);
		code = -1;
		return;
	}

	//Unsupported in proxy mode
	if(!c->c_proxy)
	{
		WINPORT(SetLastError)(ERROR_BAD_NET_RESP);
		code = -1;
		return;
	}

	//Allready in proxy mode
	if(proxy > 0)
		ExecCmdTab(c, argc-1, argv+1);
	else
	{
		//Temp switch to proxy mode
		pswitch(1);

		if(c->c_conn && !connected)
		{
			pswitch(0);
			code = -1;
			return;
		}

		ExecCmdTab(c, argc-1, argv+1);
		proxflag = (connected) ? 1 : 0;
		pswitch(0);
	}
}
예제 #13
0
int main(                       // MAIN-LINE FOR DLL DRIVER
    #if !defined(RAW_CMDLINE)
    int argc,                   // - arg count
    char **argv                 // - arg.s
    #endif
    )
{
    int retcode;                // - return code

    #if defined(USE_ARGV)
        retcode = IdeDrvExecDLLArgv( &info, argc, argv );
    #elif defined(wpp_drv)
        argc = argc;
        argv = argv;
        getcmd( cmd_line );
        retcode = IdeDrvExecDLL( &info, cmd_line );
    #elif defined(RAW_CMDLINE)
        size_t  len;
        char    *lcl_argv[2];

        len = _bgetcmd( NULL, INT_MAX );
        lcl_argv[1] = NULL;
        if( len >= sizeof( cmd_line ) ) {
            lcl_argv[0] = CMemAlloc( len + 1 );
        } else {
            lcl_argv[0] = cmd_line;
        }
        _bgetcmd( lcl_argv[0], len + 1 );
        retcode = IdeDrvExecDLL( &info, cmd_line );
        if( len >= sizeof( cmd_line ) ) {
            CMemFree( lcl_argv[0] );
        }
    #else
        argc = argc;
        cmd_line[0] = cmd_line[0];
        retcode = IdeDrvExecDLL( &info, &argv[1] );
    #endif
    switch( retcode ) {
      case IDEDRV_SUCCESS :
      case IDEDRV_ERR_RUN :
      case IDEDRV_ERR_RUN_EXEC :
      case IDEDRV_ERR_RUN_FATAL :
        break;
      default :
        retcode = IdeDrvPrintError( &info );
        break;
    }
    return retcode;
}
예제 #14
0
void GUImain( void )
{
    char buff[256];

    // fix up env vars if necessary
    watcom_setup_env();

    SetErrorMode( SEM_FAILCRITICALERRORS );
    SetHandleCount( 60 );
    _8087 = 0;
    CmdData=buff;
    getcmd( CmdData );
    DebugMain();
    InitHookFunc();
}
예제 #15
0
int request(char* cmdline){
	int cmdno,chk;
	char *cmd;
	cmd=getcmd(cmdline);
	cmdno=isvalidcmd(cmd);
	
	if(cmdno){
		chk=exec(cmdno,cmdline);
		if(chk)
			return 1;//executed successfully
		else
			return -1;//execution failure
	}
	return 0;//wrong command
}
예제 #16
0
int smtpfilter_ctlmsg()
{
	std::string cmd=getcmd();
	std::string msg(readmsg());

	std::string addr;

	{
		const char *address_cstr;

		if ((address_cstr=is_cmd(cmd.c_str(), "subscribe")) != 0)
		{
			addr=returnaddr(msg, address_cstr);
		}
		else if ((address_cstr=is_cmd(cmd.c_str(), "alias-subscribe"))
			 != 0)
		{
			addr=extract_alias_to_subscribe(msg);
		}
		else
		{
			std::cerr << "200 Ok" << std::endl;
			return 0;
		}
	}

	uaddrlower(addr);

	if (cmdget_s("UNICODE") != "1")
	{
		std::string::const_iterator b=addr.begin(), e=addr.end();

		while (b != e)
		{
			if (*b & 0x80)
			{
				std::cerr << "550 This mailing list does not "
					"accept Unicode E-mail addresses, yet."
					  << std::endl;
				return EX_SOFTWARE;
			}
			++b;
		}
	}

	std::cerr << "200 Ok" << std::endl;
	return 0;
}
예제 #17
0
파일: psh.c 프로젝트: adi-mishra/CSC369
/*
 * interactive
 * runs the interactive shell.  basically, just infinitely loops, grabbing
 * commands and running them (and printing the exit status if it's not
 * success.)
 */
static
void
interactive(void)
{
	static char buf[ARG_MAX];
	int status;

	while (1) {
		printf("OS/161$ ");
		getcmd(buf, sizeof(buf));
		status = docommand(buf);
		if (status) {
			printf("Command returned %d\n", status);
		}
	}
}
예제 #18
0
void MainWindow::readPendingDatagrams(void)
{
    QByteArray datagram;

    while (sender->hasPendingDatagrams()) {

    datagram.resize(sender->pendingDatagramSize());
    sender->readDatagram(datagram.data(), datagram.size());

    //ui->textEdit->setPlainText(datagram);
    //qDebug()<<datagram;



    }
    getcmd(QString(datagram));
}
예제 #19
0
파일: ex.c 프로젝트: shodanium/deco
static void readex ()
{
	register char *cp, *ep;

	for (nex=0; (ep=getex()); ++nex) {
		if (nex >= EXSZ-1)
			break;
		ex[nex].pat = ep;
		if ((cp = getcmd ()))
			ex[nex].cmd = cp;
	}
	while (nex>0 && ! ex[nex-1].cmd) {
		--nex;
		free (ex[nex].pat);
	}
	ex[nex].pat = 0;
}
예제 #20
0
파일: lpc.c 프로젝트: darksoul42/bitrig
/*
 * Command parser.
 */
static void
cmdscanner(void)
{
	struct cmd *c;

	for (;;) {
		if (gotintr) {
			putchar('\n');
			gotintr = 0;
		}
		if (fromatty) {
			printf("lpc> ");
			fflush(stdout);
		}

		siginterrupt(SIGINT, 1);
		if (fgets(cmdline, MAX_CMDLINE, stdin) == NULL) {
			if (errno == EINTR && gotintr) {
				siginterrupt(SIGINT, 0);
				return;
			}
			siginterrupt(SIGINT, 0);
			quit(0, NULL);
		}
		siginterrupt(SIGINT, 0);

		makeargv();
		if (margc == 0)
			break;
		c = getcmd(margv[0]);
		if (c == (struct cmd *)-1) {
			printf("?Ambiguous command\n");
			continue;
		}
		if (c == 0) {
			printf("?Invalid command\n");
			continue;
		}
		if (c->c_priv && getuid() && ingroup(LPR_OPER) == 0) {
			printf("?Privileged command\n");
			continue;
		}
		(*c->c_handler)(margc, margv);
	}
}
예제 #21
0
extern bool InitParsing( void )
/*****************************/
// initialize the parsing stuff, and see if there is anything on the command
// line.
{
    CmdFile = MemAlloc( sizeof( cmdfilelist ) );
    CmdFile->next = NULL;
    CmdFile->buffer = MemAlloc( MAX_LINE );   // maximum size of a command line.
    CmdFile->how = COMMANDLINE;
    CmdFile->oldhow = COMMANDLINE;
    CmdFile->where = MIDST;
    CmdFile->name = NULL;
    CmdFile->file = NIL_HANDLE;
    getcmd( CmdFile->buffer );
    CmdFile->current = CmdFile->buffer;
    EatWhite();
    return( true );
}
예제 #22
0
파일: Shell.c 프로젝트: Lutes/McGill
int main(){
	
	char *args[20];
	int bg;
	int j;
	for (j = 0; j<101; j++){ 
		history[j] = "\0";
    		bh[j] = "\0";
		bpid[j] = 0;
	}

	while(1){

  		int childid;
		int i = 0;
		int cnt = getcmd(">>  ", args, &bg);
		if (cnt == -1)
			continue;
	
		if (bg){
        		printf("\nBackground enabled..\n");
		}
		
		else
       			printf("\nBackground not enabled \n");

		childid = fork();
		if (childid == 0){  	                
			if (execvp(args[0],args) == -1)
				perror("execvp Error:");
		}
        
		else{
			if (bg == 0){
				waitpid(childid,NULL,0);
			}
			else {
				bpid[c - 1] = childid;
			}
			
		}
	}

}
예제 #23
0
bool		exec_client(fds c, double tdt)
{
  char		*s;

  s = getcmd(c);
  if (((c && (c->trick) && ((t_client*)c->trick)->close) || !fds_alive(c)) &&
      (c->write || net_close(c)))
    return (true);
  if (!(c->trick) || !(((t_client*)c->trick)->_m))
    return (mod_discovery(c, &s));
  s = flood_check(c, s);
  if (scheduler_(c, tdt))
    return (scheduler_dispatch(c));
  else if (!scheduler_active(c) && callback_(c, s, tdt))
    return (callback_handler(c, s));
  else if (s && !scheduler_active(c) && (find_action(c, s) != -1))
    flood_read(c);
  return (true);
}
예제 #24
0
cmdline_t *CmdLineParse( void ) {
/*****************************/

    const char  *env_var;
    char        *cmd_line;
    size_t      cmd_len;
    act_grp_t   *cur;
    act_grp_t   *next;

    tempFileNum = 0;
    env_var = getenv( ENVVAR );
    if( env_var != NULL ) {
        parseString( env_var );
    }
    cmd_line = MemAlloc( 10240 );   /* FIXME - arbitrarily large constant! */
    getcmd( cmd_line );
    cmd_len = strlen( cmd_line );
    if( cmd_len > 0 ) {
        cmd_line = MemRealloc( cmd_line, cmd_len + 1 );
        parseString( cmd_line );
    }
    MemFree( cmd_line );

    /* reverse the stack of actions */
    cmdLine.action = NULL;  /* no actions by default */
    cur = curAct;
    while( cur != NULL ) {
        next = cur->next;
        if( cur->num_files == 0 ) { /* trim out the needless actions */
            MemFree( cur );
        } else {
            cur->next = cmdLine.action; /* stack it up */
            cmdLine.action = cur;
        }
        cur = next;
    }
    if( cmdLine.action == NULL ) {
        usage();
    }
    cmdLine.quiet = cmdLine.action->quiet;
    header();
    return( &cmdLine );
}
예제 #25
0
void main( int argc, char *argv[] )
{
    char        *av[4];
    auto char   cmdline[128];

    av[0] = dos4g_path();           /* Locate the DOS/4GW loader */
    av[1] = argv[0];                /* name of executable to run */
    av[2] = getcmd( cmdline );      /* command line */
    av[3] = NULL;                   /* end of list */
#ifdef QUIET
    putenv( "DOS4G=QUIET" );        /* disables DOS/4GW Copyright banner */
                                    /* (note: you must display elsewhere) */
#endif
    execvp( (const char *)av[0], (const char **)av );
    puts( "Stub exec failed:" );
    puts( av[0] );
    puts( strerror( errno ) );
    exit( 1 );                      /* indicate error */
}
예제 #26
0
void GUImain( void )
{
    char        *buff;
    int         len;

    // fix up env vars if necessary
    watcom_setup_env();

    SetErrorMode( ERR_MODE );
#if defined( _M_IX86 )
    _8087 = 0;
#endif
    len = _bgetcmd( NULL, 0 );
    _AllocA( buff, len + 1 );
    getcmd( buff );
    CmdData = buff;

    DebugMain();
}
예제 #27
0
void run()
{
 int ncmd = sizeof(Cmd_Map) / sizeof(Cmd_Entry);
  int i;
  char cmd[100];

  while (1) {
    getcmd(cmd);
    for (i = 0; i < ncmd; i++) {    
      if (strcmp(cmd, Cmd_Map[i].cmd) == 0) {
        Cmd_Map[i].execute();
        break;
      }
    }
    if (i >= ncmd) {
      printf("Unknown command.\n");
    }
  }
}
예제 #28
0
struct cmdargs *
get_pending_cmd(void)
{
    SELECT_ARG_TYPE ready;
    struct timeval  to;
    int             nfound;

    FD_ZERO(&ready);
    FD_SET(0, &ready);
    to.tv_sec = 0;
    to.tv_usec = 0;

    nfound = select(1, &ready, NULL, NULL, &to);
    if (nfound && FD_ISSET(0, &ready)) {
        return getcmd();
    } else {
	return NULL;
    }
}
예제 #29
0
/*
 * Open a new command line context.
 */
int OpenCmdLineContext( void )
/****************************/
{
    int                 len;

    if( curContextInitialized )  Zoinks();
    clear_context( &curContext );

    /*** Make a copy of the command line ***/
    len = _bgetcmd( NULL, 0 ) + 1;
    curContext.dataStart = AllocMem( len );
    getcmd( curContext.dataStart );

    curContext.data = curContext.dataStart;
    curContext.dataLen = strlen( curContext.dataStart );
    curContextInitialized = 1;
    curContext.type = COMMAND_LINE_CONTEXT;
    return( 0 );
}
/*
 * interactive
 * runs the interactive shell.  basically, just infinitely loops, grabbing
 * commands and running them (and printing the exit status if it's not
 * success.)
 */
static
void
interactive(void)
{
	char buf[ARG_MAX];
	int status;

	while (1) {
		printf("OS/161$ ");
		getcmd(buf, sizeof(buf));
		status = docommand(buf);
		if (status) {
			printf("Exit %d\n", status);
		}
#ifdef WNOHANG
		waitpoll();
#endif
	}
}