Example #1
0
void EiC_comm_switch(void)
{
    int EiC_insertpath(char *);
    int EiC_removepath(char *);
    void EiC_listpath(void);
    char EiC_nextchar(void);
    
    char *buf;
    if (EiC_lexan() == ID) {
	if(EiC_gettype(token->Val.sym->type) == ID) {
	    EiC_remsym(token->Val.sym);
	}

	buf = getNextInput();
	    
	switch(EiC_LEXEM[0]) {
	  case 'I':
	    if(!*buf || !EiC_insertpath(buf))
	     EiC_warningerror("Failed to add path"); 
	    break;
	  case 'R':
	    if(!*buf || !EiC_removepath(buf))
	     EiC_warningerror("Failed to remove path"); 
	    break;
	  case 'L':
	    EiC_listpath();break;
	  default:	    
	    EiC_error("Unknown command switch");
	}	    	    
	    
    } else 
	EiC_error("Expected command switch");

}
Example #2
0
int do_sw_commands(char *cp)
{
    while(*cp) {
	switch(*cp++) {
	case 'D': dodefine(cp);  return 1;
	case 'I': EiC_insertpath(cp); return 1;
	case '\?':
	case 'h':
	case 'H': usage();
	case 'c':
	case 'C': EiC_TIMER = 1; break;
	#ifndef NO_HTML
	case 'e':
	    // connect stderr to stdout 
	    dup2(1,2); 
	    // setup stdout to behave like stderr 
	    if(setvbuf(stdout,NULL,_IONBF,0) != 0)
		EiC_error("failed to setup stdout\n");
	    // inform the browser 
	    puts("Content-type: text/plain\n\n");
	    break;
	#endif
	case 'v':
	case 'V': puts(Version); exit(1);

	case 'R': prompt = 1;
	case 'r': reStart = 1;  break;

	case 's': 
	case 'S': silent = 1; break; 

	case 'f': ScriptMode = 1; break;
	case 'p': EiC_SHOWLINE = 1; break;
	case 'P': EiC_showIncludes = 1; break;
	case 't':
	case 'T': EiC_traceON = 1; break;
	case 'n': HistoryFile = 0; break;
	case 'N': StartUpH = 0; break;
	case 'A': EiC_Interact = 0; break;
	default:
	    while(isspace(*cp)) cp++;
	    if(*cp == '-')  /* assume script mode */
		while(isspace(*++cp));
	    else if(*cp)  /* catch for lines ending with whitespace */
		return 0;
	}
    }
    return 1;
}