int argparse(int argc, char* argv[]) { int i; int ret = 1; if(argc < 2) { fprintf(stderr, "Please specify a TA file to open\n"); return 0; } arginit(); args.inputFile = argv[1]; for(i = 2;i < argc; i++) { //options if(strcmp(argv[i], "-c") == 0 && ret++) args.outputMode = OUTPUT_CHAR; if(++i == argc) break; //parameters if(strcmp(argv[i-1], "-u") == 0 && ret++) args.TAUnit = strtol(argv[i], NULL, 0); else if(strcmp(argv[i-1], "-p") == 0 && ret++) args.partition = strtol(argv[i], NULL, 0); } return ret; }
void main(void) { hwrpb = (Hwrpb*)0x10000000; hwrpb = (Hwrpb*)(KZERO|hwrpb->phys); arginit(); machinit(); options(); ioinit(); clockinit(); confinit(); archinit(); xinit(); memholes(); if(i8237alloc != nil) i8237alloc(); mmuinit(); if(arch->coreinit) arch->coreinit(); trapinit(); screeninit(); printinit(); /* it's now safe to print */ /* dumpopts(); /* DEBUG */ i8250console(); quotefmtinstall(); print("\nPlan 9\n"); cpuidprint(); if(arch->corehello) arch->corehello(); procinit0(); initseg(); timersinit(); links(); chandevreset(); pageinit(); swapinit(); savefpregs(&initfp); initfp.fpstatus = 0x68028000; userinit(); schedinit(); }
int main( int argc, char *argv[] ) { const char *fs = NULL; char **eargv = NULL; int eargc; setlocale( LC_CTYPE, "" ); setlocale( LC_NUMERIC, "C" ); /* for parsing cmdline & prog */ cmdname = argv[0]; if( argc == 1 ) { fprintf( stderr, "usage: %s [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]\n", cmdname ); exit( 1 ); } signal( SIGFPE, fpecatch ); srand_seed = 1; srand( (unsigned)srand_seed ); yyin = NULL; symtab = makesymtab( NSYMTAB/NSYMTAB ); if( argc == 2 && argv[1][0] == '@' && argv[1][1] != '\0' ) { const char *env; env = getenv( &argv[1][1] ); if( env != NULL ) { eargc = ParseEnvVar( env, NULL, NULL ); // count parameters. eargv = malloc( eargc * sizeof( char * ) + strlen( env ) + 1 + eargc ); ParseEnvVar( env, eargv, (char *)( eargv + eargc ) ); argc = eargc; argv = eargv; } } while( argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0' ) { if( strcmp( argv[1], "-version" ) == 0 || strcmp( argv[1], "--version" ) == 0 ) { printf( "awk %s\n", version ); exit( 0 ); break; } if( strncmp( argv[1], "--", 2 ) == 0 ) { /* explicit end of args */ argc--; argv++; break; } switch( argv[1][1] ) { case 's': if( strcmp( argv[1], "-safe" ) == 0 ) safe = true; break; case 'f': /* next argument is program filename */ if( argv[1][2] != '\0' ) { /* arg is -fsomething */ if( npfile >= MAX_PFILE - 1 ) { FATAL( "too many -f options" ); } pfile[npfile++] = unquote( &argv[1][2] ); } else { /* arg is -f something */ argc--; argv++; if( argc <= 1 ) { FATAL( "no program filename" ); } if( npfile >= MAX_PFILE - 1 ) { FATAL( "too many -f options" ); } pfile[npfile++] = unquote( argv[1] ); } break; case 'F': /* set field separator */ if( argv[1][2] != '\0' ) { /* arg is -Fsomething */ if( argv[1][2] == 't' && argv[1][3] == '\0' ) { /* wart: t=>\t */ fs = "\t"; } else if( argv[1][2] != '\0' ) { fs = &argv[1][2]; } } else { /* arg is -F something */ argc--; argv++; if( argc > 1 && argv[1][0] == 't' && argv[1][1] == '\0' ) { /* wart: t=>\t */ fs = "\t"; } else if( argc > 1 && argv[1][0] != '\0' ) { fs = &argv[1][0]; } } if( fs == NULL || *fs == '\0' ) WARNING( "field separator FS is empty" ); break; case 'v': /* -v a=1 to be done NOW. one -v for each */ if( argv[1][2] != '\0' ) { /* arg is -vsomething */ char *p; p = unquote( &argv[1][2] ); if( isclvar( p ) ) { setclvar( p ); } else { FATAL( "invalid -v option argument: %s", p ); } } else { /* arg is -v something */ char *p; argc--; argv++; if( argc <= 1 ) { FATAL( "no variable name" ); } p = unquote( argv[1] ); if( isclvar( p ) ) { setclvar( p ); } else { FATAL( "invalid -v option argument: %s", p ); } } break; case 'd': dbg = atoi( &argv[1][2] ); if( dbg == 0 ) dbg = 1; printf( "awk %s\n", version ); break; default: WARNING( "unknown option %s ignored", argv[1] ); break; } argc--; argv++; } /* argv[1] is now the first argument */ if( npfile == 0 ) { /* no -f; first argument is program */ char *p; if( argc <= 1 ) { if( dbg ) exit( 0 ); FATAL( "no program given" ); } p = unquote( argv[1] ); dprintf(( "program = |%s|\n", p )); lexprog = p; argc--; argv++; } for( eargc = 1; eargc < argc; ++eargc ) { argv[eargc] = unquote( argv[eargc] ); } recinit( recsize ); syminit(); compile_time = 1; argv[0] = cmdname; /* put prog name at front of arglist */ dprintf(( "argc=%d, argv[0]=%s\n", argc, argv[0] )); arginit( argc, argv ); if( !safe ) envinit( environ ); yyparse(); setlocale( LC_NUMERIC, "" ); /* back to whatever it is locally */ if( fs ) *FS = qstring( fs, '\0' ); dprintf(( "errorflag=%d\n", errorflag )); if( errorflag == 0 ) { compile_time = 0; run( winner ); } else { bracecheck(); } return( errorflag ); }
int main(int argc, const char *argv[]) { const char *fs = NULL, *marg; int temp; __progname = argv[0]; _wildcard(&argc, &argv); setlocale(LC_ALL, ""); cmdname = __progname; if (argc == 1) { fprintf(stderr, "Usage: %s [-f programfile | 'program'] [-Ffieldsep] [-v var=value] [-safe] [-mrn] [-mfn] [files]\n", cmdname); exit(1); } signal(SIGFPE, fpecatch); yyin = NULL; symtab = makesymtab(NSYMTAB); while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') { if (strcmp(argv[1], "--") == 0) { /* explicit end of args */ argc--; argv++; break; } switch (argv[1][1]) { case 's': if (strcmp(argv[1], "-safe") == 0) safe = 1; break; case 'f': /* next argument is program filename */ argc--; argv++; if (argc <= 1) ERROR "no program filename" FATAL; pfile[npfile++] = argv[1]; break; case 'F': /* set field separator */ if (argv[1][2] != 0) { /* arg is -Fsomething */ if (argv[1][2] == 't' && argv[1][3] == 0) /* wart: t=>\t */ fs = "\t"; else if (argv[1][2] != 0) fs = &argv[1][2]; } else { /* arg is -F something */ argc--; argv++; if (argc > 1 && argv[1][0] == 't' && argv[1][1] == 0) /* wart: t=>\t */ fs = "\t"; else if (argc > 1 && argv[1][0] != 0) fs = &argv[1][0]; } if (fs == NULL || *fs == '\0') ERROR "field separator FS is empty" WARNING; break; case 'v': /* -v a=1 to be done NOW. one -v for each */ if (argv[1][2] == '\0' && --argc > 1 && isclvar((++argv)[1])) setclvar((char*)argv[1]); break; case 'm': /* more memory: -mr=record, -mf=fields */ /* no longer needed */ marg = argv[1]; if (argv[1][3]) temp = atoi(&argv[1][3]); else { argv++; argc--; temp = atoi(&argv[1][0]); } switch (marg[2]) { case 'r': recsize = temp; break; case 'f': nfields = temp; break; default: ERROR "unknown option %s\n", marg FATAL; } break; case 'd': dbg = atoi(&argv[1][2]); if (dbg == 0) dbg = 1; printf("awk %s\n", version); break; case 'V': /* added for exptools "standard" */ printf("awk %s\n", version); exit(0); break; default: ERROR "unknown option %s ignored", argv[1] WARNING; break; } argc--; argv++; } /* argv[1] is now the first argument */ if (npfile == 0) { /* no -f; first argument is program */ if (argc <= 1) { if (dbg) exit(0); ERROR "no program given" FATAL; } dprintf( ("program = |%s|\n", argv[1]) ); lexprog = argv[1]; argc--; argv++; } recinit(recsize); syminit(); compile_time = 1; argv[0] = cmdname; /* put prog name at front of arglist */ dprintf( ("argc=%d, argv[0]=%s\n", argc, argv[0]) ); arginit(argc, argv); if (!safe) envinit(environ); yyparse(); if (fs) *FS = qstring(fs, '\0'); dprintf( ("errorflag=%d\n", errorflag) ); if (errorflag == 0) { compile_time = 0; run(winner); } else bracecheck(); return(errorflag); }
int main(int argc, char *argv[]) { const char *fs = NULL; setlocale(LC_CTYPE, ""); setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */ cmdname = argv[0]; if (argc == 1) { fprintf(stderr, "usage: %s [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]\n", cmdname); exit(1); } signal(SIGFPE, fpecatch); yyin = NULL; symtab = makesymtab(NSYMTAB/NSYMTAB); while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') { if (strcmp(argv[1],"-version") == 0 || strcmp(argv[1],"--version") == 0) { printf("awk %s\n", version); exit(0); break; } if (strncmp(argv[1], "--", 2) == 0) { /* explicit end of args */ argc--; argv++; break; } switch (argv[1][1]) { case 's': if (strcmp(argv[1], "-safe") == 0) safe = 1; break; case 'f': /* next argument is program filename */ argc--; argv++; if (argc <= 1) FATAL("no program filename"); if (npfile >= MAX_PFILE - 1) FATAL("too many -f options"); pfile[npfile++] = argv[1]; break; case 'F': /* set field separator */ if (argv[1][2] != 0) { /* arg is -Fsomething */ if (argv[1][2] == 't' && argv[1][3] == 0) /* wart: t=>\t */ fs = "\t"; else if (argv[1][2] != 0) fs = &argv[1][2]; } else { /* arg is -F something */ argc--; argv++; if (argc > 1 && argv[1][0] == 't' && argv[1][1] == 0) /* wart: t=>\t */ fs = "\t"; else if (argc > 1 && argv[1][0] != 0) fs = &argv[1][0]; } if (fs == NULL || *fs == '\0') WARNING("field separator FS is empty"); break; case 'v': /* -v a=1 to be done NOW. one -v for each */ if (argv[1][2] == '\0' && --argc > 1 && isclvar((++argv)[1])) setclvar(argv[1]); break; case 'd': dbg = atoi(&argv[1][2]); if (dbg == 0) dbg = 1; printf("awk %s\n", version); break; default: WARNING("unknown option %s ignored", argv[1]); break; } argc--; argv++; } /* argv[1] is now the first argument */ if (npfile == 0) { /* no -f; first argument is program */ if (argc <= 1) { if (dbg) exit(0); FATAL("no program given"); } dprintf( ("program = |%s|\n", argv[1]) ); lexprog = argv[1]; argc--; argv++; } recinit(recsize); syminit(); compile_time = 1; argv[0] = cmdname; /* put prog name at front of arglist */ dprintf( ("argc=%d, argv[0]=%s\n", argc, argv[0]) ); arginit(argc, argv); if (!safe) envinit(environ); yyparse(); setlocale(LC_NUMERIC, ""); /* back to whatever it is locally */ if (fs) *FS = qstring(fs, '\0'); dprintf( ("errorflag=%d\n", errorflag) ); if (errorflag == 0) { compile_time = 0; run(winner); } else bracecheck(); return(errorflag); }
//=============================================================================== // MAIN MAIN MAIN MAIN MAIN main(int argc, char *argv[]) { int n,i,j,col,command,i1; unsigned char rele=0;// sosto9nie rele short c_step=0,T0=0; long rele_timer=0; unsigned short save; int ind=0,chk_num,Time_out=5,Con1=1; if (p->verbose) printf("START MO3A<->RELE\n\n"); //=============================================================================== // timer 10ms event_sig.sigev_signo = SIGALRM; tm10 = timer_create(CLOCK_REALTIME,&event_sig ); // ёючфрэшх ЄрщьхЁр if (tm10==-1) printf("\ntimer opening error: %s",strerror(errno)); timer_sig.it_value.tv_sec = 0L; timer_sig.it_value.tv_nsec = 0L; timer_sig.it_interval.tv_sec = 0L; timer_sig.it_interval.tv_nsec = 0L; //--------------------------------------------nastroika rele---------------------------- arginit(argc,argv,"тест модуля cp384\n"); argp("IO=", "%d", &ind, "Индекс модуля на шине CPCI"); argp("V_Br=","%x",&V_Bridge,"ID производителя"); argp("D_Br=", "%x", &D_Bridge, "ID устройства"); argp("delay=", "%d", &Time_out, "Таймаут запуска теста"); argp("Con1=", "%x", &Con1, "Режим надетой заглушки - 0 - нет"); delay(Time_out); //Определение Базового адреса внутренних регистров моста i=new_func_read(D_Bridge,V_Bridge,&my_device,BAR0,ind); if (i==-1) {printf("Мост отсутствует");exit(1);} else if (!PCI_IS_MEM(mass[BAR0])) {printf("PCI устройство не обнаружено");exit(1);} //Отображение портов модуля в PCI Memory Space printf ("Memory %08x\n",ba=PCI_MEM_ADDR(mass[BAR0])); //----Попытка работать с памятью fd1=shm_open("Physical",O_RDWR,0777); ptr1=(char *)mmap(0,64*1024,PROT_READ|PROT_WRITE|PROT_NOCACHE,MAP_SHARED,fd1, PCI_MEM_ADDR(mass[BAR0])&~4095); printf ("ptr1 = %x %8x\n",ptr1,ba); if (ptr1==(char *)-1) {printf ("FAULT\n"); exit (-1);} addr1=ptr1 + (ba&4095); printf ("Memory configuration addr = %x\n",addr1); *(unsigned int*)(addr1)=0xFFFFFFFF; i=1; printf("WRITE O_CTL %x %x\n",0x2000 + 0x400*i,*(unsigned int*)(addr1 +0x2000 + 0x400*i)=0); i++; printf("READ O_STA_A %x, %x\n",0x2000 + 0x400*i,*(unsigned int*)(addr1 +0x2000 + 0x400*i)); i++; printf("WRITE I_CTL %x\n",*(unsigned int*)(addr1 +0x4400)=0x80); //--------------------------------------------nastroika rele---------------------------- //create_shmem(); delay(500); open_shmem(); delay(500); //--------------------------------------------------------------------- while(1) { if (rele_timer!=p->sys_timer) //timer { rele_timer=p->sys_timer; if (p->cur_step!=0) //est' wag dl9 vipolnenni9 { c_step=p->cur_step; for (i=0;i<p->work_com[c_step].num_mini_com;i++) //prosmotrim vse minicomandi na wage if((p->work_com[c_step].s[i].n_chan==N_CHAN)&&(p->work_com[c_step].s[i].status!=2)) //na tekuwem wage (i - minikomanda) est' komanda dl9 nas { if((p->verbose>1)&&(p->work_com[c_step].s[i].status==0)) printf("\nSTEP=%d minicom for RELE : %d status=%d time %d \n", p->cur_step, p->work_com[c_step].s[i].n_com, p->work_com[c_step].s[i].status, p->sys_timer); switch(p->work_com[c_step].s[i].n_com) { /*case 1: p->work_com[c_step].s[i].status=1; rele|=(1<<p->inbufMN3.a_params[0]); *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA 0x2C00 %x\n",rele); if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00)); p->work_com[c_step].s[i].status=2; break; case 2: p->work_com[c_step].s[i].status=1; rele &= ~(1 << p->inbufMN3.a_params[0]); *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA 0x2C00 %x\n",rele); if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00)); p->work_com[c_step].s[i].status=2; break; */ case 10: //off 1 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=1; rele &= ~1; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele); } if (p->work_com[c_step].s[i].status==1) { if ((*(unsigned int*)(addr1 + 0x4C00)&0x08)==0) p->work_com[c_step].s[i].status=2; if(p->verbose>1) printf("READ DATA %x %x\n",*(unsigned int*)(addr1 + 0x4C00),*(unsigned int*)(addr1 + 0x4C00)&0x01); } break; case 11: //on 1 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=1; rele|=1; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele); } if (p->work_com[c_step].s[i].status==1) { if (*(unsigned int*)(addr1 + 0x4C00)&0x08) p->work_com[c_step].s[i].status=2; if(p->verbose>1) printf("READ DATA %x \n",*(unsigned int*)(addr1 + 0x4C00)); } break; case 20: //off 2 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=1; rele &= ~2; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele); } if (p->work_com[c_step].s[i].status==1) { if ((*(unsigned int*)(addr1 + 0x4C00)&0x02)==0) p->work_com[c_step].s[i].status=2; if(p->verbose>1) printf("READ DATA %x %x\n",*(unsigned int*)(addr1 + 0x4C00),*(unsigned int*)(addr1 + 0x4C00)&0x01); } break; case 21: //on 2 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=1; rele|=2; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele); } if (p->work_com[c_step].s[i].status==1) { if (*(unsigned int*)(addr1 + 0x4C00)&0x02) p->work_com[c_step].s[i].status=2; if(p->verbose>1) printf("READ DATA %x \n",*(unsigned int*)(addr1 + 0x4C00)); } break; case 30: //off 3 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=1; rele &= ~4; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele); } if (p->work_com[c_step].s[i].status==1) { if ((p->inbufMN3.a_params[0]==0)&&((*(unsigned int*)(addr1 + 0x4C00)&0x04)==0)) p->work_com[c_step].s[i].status=2; if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00)); } break; case 31: //on 3 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=1; rele|=4; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele); //p->work_com[c_step].t_start = p->sys_timer; //if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00)); } //if ((p->work_com[c_step].s[i].status==1)&&(p->sys_timer - p->work_com[c_step].t_start > 20)) if (p->work_com[c_step].s[i].status==1) { if (*(unsigned int*)(addr1 + 0x4C00)&0x04) p->work_com[c_step].s[i].status=2; //if ((p->inbufMN3.a_params[0]==0)&&((*(unsigned int*)(addr1 + 0x4C00)&0x04)==0)) p->work_com[c_step].s[i].status=2; if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00)); } break; case 40: //off 4 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=2; rele &= ~8; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele); } break; case 41: //on 4 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=2; rele|=8; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele); } break; case 50: //off 5 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=2; rele &= ~0x10; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele); } break; case 51: //on 5 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=2; rele|=0x10; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele); } break; case 60: //off 6 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=1; rele &= ~0x20; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA 0x2C00 %x\n",rele); } if (p->work_com[c_step].s[i].status==1) { //if ((*(unsigned int*)(addr1 + 0x4C00)&0x20)==0) p->work_com[c_step].s[i].status=2; if(p->verbose>1) printf("READ DATA %x %x\n",*(unsigned int*)(addr1 + 0x4C00),*(unsigned int*)(addr1 + 0x4C00)&0x01); } break; case 61: //on 6 rele if (p->work_com[c_step].s[i].status==0) { p->work_com[c_step].s[i].status=1; rele|=0x20; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA 0x2C00 %x\n",rele); } if (p->work_com[c_step].s[i].status==1) { //if (*(unsigned int*)(addr1 + 0x4C00)&0x20) p->work_com[c_step].s[i].status=2; if(p->verbose>1) printf("READ DATA %x \n",*(unsigned int*)(addr1 + 0x4C00)); } break; case 25: p->work_com[c_step].s[i].status=1; if (p->inbufMN3.a_params[0]) rele|=2; else rele &= ~2; *(unsigned int*)(addr1 +0x2C00)=rele; if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele); if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00)); p->work_com[c_step].s[i].status=2; break; case 29: p->work_com[c_step].s[i].status=1; //if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00)); p->work_com[c_step].s[i].status=2; break; case 90: // pause //if(p->verbose>1) printf(" %d\n",p->work_com[c_step].t_stop-p->sys_timer); if (p->work_com[c_step].t_stop-p->sys_timer<20) p->work_com[c_step].s[i].status=2; break; case 104: //Ogidanie Ispravnosti R999 //p->work_com[c_step].s[i].status=1; //if(p->verbose>1) if (p->inbufMN3.a_params[0]&&(*(unsigned int*)(addr1 + 0x4C00)&0x04)) p->work_com[c_step].s[i].status=2; if ((p->inbufMN3.a_params[0]==0)&&((*(unsigned int*)(addr1 + 0x4C00)&0x04)==0)) p->work_com[c_step].s[i].status=2; //if ((*(unsigned int*)(addr1 + 0x4C00)&0x04)&&(p->inbufMN3.a_params[0])) p->work_com[c_step].s[i].status=2; printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00)); //p->work_com[c_step].s[i].status=2; break; default: printf("Bad minicom %d for %d chan : %d",p->work_com[c_step].s[i].n_com, N_CHAN); p->work_com[c_step].s[i].status=3; }//switch (n_com) //------------------------------------------------------- //esli previweno vrem9 ozhidani9 //if ((p->work_com[c_step].s[i].status==1)&&(p->work_com[c_step].s[i].t_stop>p->sys_timer)) p->work_com[c_step].s[i].status=3; //------------------------------------------------------- }//ewe ne vipoln9li //if (p->work_com[c_step].s[i].w_answ[0]==2) //esli nado gdat' otveta //if (p->work_com[c_step].s[i].w_answ[1]=1) } //step>0 }//timer }//while timer_delete(tm10); }
void main(int argc, char **argv) { int i, nets = 0; char *ann; rfork(RFNOTEG); formatinit(); machinit(); conf.confdev = "n"; /* Devnone */ ARGBEGIN{ case 'a': /* announce on this net */ ann = EARGF(usage()); if (nets >= Maxnets) { fprint(2, "%s: too many networks to announce: %s\n", argv0, ann); exits("too many nets"); } annstrs[nets++] = ann; break; case 'c': /* use new, faster cache layout */ oldcachefmt = 0; break; case 'f': /* enter configuration mode first */ conf.configfirst++; break; case 'm': /* name device-map file */ conf.devmap = EARGF(usage()); break; default: usage(); break; }ARGEND if (argc != 1) usage(); conf.confdev = argv[0]; /* config string for dev holding full config */ Binit(&bin, 0, OREAD); confinit(); print("\nPlan 9 %d-bit cached-worm file server with %d-deep indir blks\n", sizeof(Off)*8 - 1, NIBLOCK); printsizes(); qlock(&reflock); qunlock(&reflock); serveq = newqueue(1000, "9P service"); /* tunable */ raheadq = newqueue(1000, "readahead"); /* tunable */ mbinit(); netinit(); scsiinit(); files = malloc(conf.nfile * sizeof *files); for(i=0; i < conf.nfile; i++) { qlock(&files[i]); qunlock(&files[i]); } wpaths = malloc(conf.nwpath * sizeof(*wpaths)); uid = malloc(conf.nuid * sizeof(*uid)); gidspace = malloc(conf.gidspace * sizeof(*gidspace)); authinit(); print("iobufinit\n"); iobufinit(); arginit(); boottime = time(nil); print("sysinit\n"); sysinit(); /* * Ethernet i/o processes */ netstart(); /* * read ahead processes */ newproc(rahead, 0, "rah"); /* * server processes */ for(i=0; i < conf.nserve; i++) newproc(serve, 0, "srv"); /* * worm "dump" copy process */ newproc(wormcopy, 0, "wcp"); /* * processes to read the console */ consserve(); /* * "sync" copy process * this doesn't return. */ procsetname("scp"); synccopy(); }
/* figures out what's what*/ struct args * parse(char *input) { // the arguements will go here struct args *arguments = arginit(); allocCheck(arguments); //did malloc work? int i = 1; //this will be important in the later day char **args;// the tokenized input args = malloc(sizeof(char *) * MAX_INPUT); allocCheck(args); /*TOKENIZE THAT! YEA*/ for (args[0] = strtok(input, DELIM); NULL != args[i-1]; i++) args[i] = strtok(NULL, DELIM); args[i] = NULL; //shrink it down to size args = realloc(args, sizeof(char *) * (i+1)); allocCheck(args); /* alrighty, what's the program we should run */ arguments->program = malloc(sizeof(char) * MAX_INPUT); allocCheck(args); strncpy(arguments->program, args[0], strlen(args[0]) + 1); int j, len, size; i = j = 0; char c; /* how many arguments apply to this specific program? */ while (NULL != args[i]) { c = args[i][0]; if ('|' == c || '<' == c || '>' == c || '&' == c) break; i++; } arguments->program_args = malloc(sizeof(char *) * (i + 1)); /* now fill program_args with the arguments for that program */ for (j = 0; j < i; j++) { len = strlen(args[j]) + 1; arguments->program_args[j] = malloc(sizeof(char) * len); allocCheck(arguments->program_args[j]); strncpy(arguments->program_args[j], args[j], len); } arguments->program_args[j] = NULL; /* now figure out how many arguments are left */ //i = i-1; size = 0; while (NULL != args[i+size]) { size ++; } /* stick the remaining arguments in the pipe_args */ //arguments->pipe_args = malloc(sizeof(char *) * (size + 1)); for (j = 0; j < (size); j++) { if (args[j+i][0] == '|') break; else if (args[j+i][0] == '&') arguments->background = 1; else if (args[j+i][0] == '<' && arguments->in_redir == 0) { arguments->in_redir = 1; j++; len = strlen(args[j+i]) + 1; arguments->in_file = malloc(sizeof(char) * len); allocCheck(arguments->in_file); strncpy(arguments->in_file, args[j+i], len); } else if (args[j+i][0] == '>' && arguments->out_redir == 0) { arguments->out_redir = 1; j++; len = strlen(args[j+i]) + 1; arguments->out_file = malloc(sizeof(char) * len); allocCheck(arguments->out_file); strncpy(arguments->out_file, args[j+i], len); } } arguments->pipe_args = malloc(sizeof(char *) * (size + 1)); //arguments->background = 0; int s = 0; for (; j < (size); j++) { len = strlen(args[j+i]) + 1; arguments->pipe_args[s] = malloc(sizeof(char) * len); allocCheck(arguments->pipe_args[s]); strncpy(arguments->pipe_args[s], args[j+i], len); s++; } arguments->pipe_args[s] = NULL; arguments->pipe_args = realloc(arguments->pipe_args, sizeof(char *) * (j+1)); allocCheck(arguments->pipe_args); // you're done! i = 0; /*while(NULL != arguments->pipe_args[i]) { printf("arg[%d]: %s\n", i, arguments->pipe_args[i]); i++; }*/ //string_array_free(args); free(args); return arguments; }
int main (int argc, char **argv, char **envp) { int vecp; char *vec[4]; struct TSAPdisconnect tds; struct TSAPdisconnect *td = &tds; arginit (argv); envinit (); advise (LLOG_NOTICE, NULLCP, "listening on %s", taddr2str (&tas)); if (TNetListen (&tas, td) == NOTOK) ts_adios (td, "TNetListen failed"); for (;;) { int nfds, secs; fd_set ifds, *rfds; if (!isbound && prebind) bind_to_dsa (); if (isbound) { rfds = &ifds; nfds = dsap_ad + 1; FD_ZERO (rfds); FD_SET (dsap_ad, rfds); secs = NOTOK; } else nfds = 0, rfds = NULLFD, secs = prebind ? 5 * 60L : NOTOK; if (TNetAcceptAux (&vecp, vec, NULLIP, NULLTA, nfds, rfds, NULLFD, NULLFD, secs, td) == NOTOK) { ts_advise (td, LLOG_EXCEPTIONS, "TNetAccept failed"); continue; } if (rfds && FD_ISSET (dsap_ad, rfds)) { /* DSA timed us out... */ if (debug) advise (LLOG_DEBUG, NULLCP, "unbound from directory"); ds_unbind (); isbound = 0; } if (vecp <= 0) continue; if (debug) break; switch (TNetFork (vecp, vec, td)) { case OK: ll_hdinit (pgm_log, pgmname); break; case NOTOK: ts_advise (td, LLOG_EXCEPTIONS, "TNetFork failed"); continue; default: if (isbound) { if (dsap_ad != NOTOK) close (dsap_ad), dsap_ad = NOTOK; isbound = 0; } continue; } break; } dased (vecp, vec); return 0; }