t_point *get_point(char *bu) { t_var var; char *value; t_point *bpoints; initvar(&var); bpoints = malloc(sizeof(t_point) * nbpoints(bu)); while (bu[var.i]) { if (ft_isdigit(bu[var.i]) == 0 && bu[var.i] != '\n' && bu[var.i] != '-') var.i++; else if (bu[var.i] == '\n') incremvar(&var.m, &var.i, &var.j, 1); else { bu = bu + var.i; var.i = 0; while (chartester(bu[var.i]) == 0) incremvar(&var.k, &var.i, &var.j, 0); value = ft_strncpy(ft_strnew(var.k), bu, var.k); bpoints[var.l] = add_point(value, var.m, var.j); incremvar(&var.j, &var.l, &var.k, 1); } } bpoints[var.l] = add_point("-1", -1, -1); return (bpoints); }
void init(shinstance *psh) { /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/exec.c: */ { hash_special_builtins(psh); } /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/input.c: */ { psh->basepf.nextc = psh->basepf.buf = psh->basebuf; } /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/options.c: */ { memcpy(&psh->optlist[0], &ro_optlist[0], sizeof(psh->optlist)); } /* from /Volumes/ScratchHFS/bird/kBuild/svn/trunk/src/kash/var.c: */ { char **envp; initvar(psh); for (envp = sh_environ(psh) ; *envp ; envp++) { if (strchr(*envp, '=')) { setvareq(psh, *envp, VEXPORT|VTEXTFIXED); } } } }
void shprocvar(shinstance *psh) { struct var **vpp; struct var *vp, **prev; for (vpp = psh->vartab ; vpp < psh->vartab + VTABSIZE ; vpp++) { for (prev = vpp ; (vp = *prev) != NULL ; ) { if ((vp->flags & VEXPORT) == 0) { *prev = vp->next; if ((vp->flags & VTEXTFIXED) == 0) ckfree(psh, vp->text); if ((vp->flags & VSTRFIXED) == 0) ckfree(psh, vp); } else { if (vp->flags & VSTACK) { vp->text = savestr(psh, vp->text); vp->flags &=~ VSTACK; } prev = &vp->next; } } } initvar(psh); }
void init() { /* from input.c: */ { extern char basebuf[]; basepf.nextc = basepf.buf = basebuf; } #ifdef XXX /* from var.c: */ { static char *imports[] = {"PATH", "TERM", "HOME", "USER", "PS1", 0}; int x; initvar(); for (x = 0; imports[x]; ++x) { char *p, *q; extern char *getenv(); extern void *malloc(); p = getenv(imports[x]); if (p) { q = malloc(strlen(p) + strlen(imports[x]) + 4); if (q) { sprintf(q, "%s=%s", imports[x], p); setvareq(q, 0); } free(p); } } } #else initvar(); #endif /* XXX */ }
AutoNavigator::AutoNavigator(GameObject& owner, PluginId pid) : Property::Concept(owner, "AutoNavigator", pid) { initvar(ID::PV_TriggerRadius); require("ThrustControl"); require("Physical"); requestEvent(ID::GOE_VALUE_UPDATED); requestEvent(ID::GOE_AUTONAVIGATE); assert(ownerHandle() == rootModule() && "AutoNavigator: This code may contain some out-dated assumptions."); }
void init() { /* from input.c: */ { basepf.nextc = basepf.buf = basebuf; } /* from trap.c: */ { signal(SIGCHLD, SIG_DFL); } /* from output.c: */ { #ifdef USE_GLIBC_STDIO initstreams(); #endif } /* from var.c: */ { char **envp; static char ppid[32] = "PPID="; const char *p; struct stat st1, st2; initvar(); for (envp = environ ; *envp ; envp++) { if (strchr(*envp, '=')) { setvareq(*envp, VEXPORT|VTEXTFIXED); } } fmtstr(ppid + 5, sizeof(ppid) - 5, "%ld", (long) getppid()); setvareq(ppid, VTEXTFIXED); p = lookupvar("PWD"); if (p) if (*p != '/' || stat(p, &st1) || stat(".", &st2) || st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) p = 0; setpwd(p, 0); } }
void init(void) { /* from input.c: */ { extern char basebuf[]; basepf.nextc = basepf.buf = basebuf; } /* from var.c: */ { char **envp; extern char **environ; initvar(); for (envp = environ ; *envp ; envp++) { if (strchr(*envp, '=')) { setvareq(*envp, VEXPORT|VTEXTFIXED); } } } }
int main(int argc, char *argv[]) { register int i; int argi; Source *s; struct block *l; int restricted, errexit; char **wp; struct env env; pid_t ppid; #ifdef MEM_DEBUG chmem_set_defaults("ct", 1); /* chmem_push("+c", 1); */ #endif /* MEM_DEBUG */ #ifdef OS2 setmode (0, O_BINARY); setmode (1, O_TEXT); #endif /* make sure argv[] is sane */ if (!*argv) { static const char *empty_argv[] = { "pdksh", (char *) 0 }; argv = (char **)__UNCONST(empty_argv); argc = 1; } kshname = *argv; ainit(&aperm); /* initialize permanent Area */ /* set up base environment */ memset(&env, 0, sizeof(env)); env.type = E_NONE; ainit(&env.area); e = &env; newblock(); /* set up global l->vars and l->funs */ /* Do this first so output routines (eg, errorf, shellf) can work */ initio(); initvar(); initctypes(); inittraps(); #ifdef KSH coproc_init(); #endif /* KSH */ /* set up variable and command dictionaries */ tinit(&taliases, APERM, 0); tinit(&aliases, APERM, 0); tinit(&homedirs, APERM, 0); /* define shell keywords */ initkeywords(); /* define built-in commands */ tinit(&builtins, APERM, 64); /* must be 2^n (currently 40 builtins) */ for (i = 0; shbuiltins[i].name != NULL; i++) builtin(shbuiltins[i].name, shbuiltins[i].func); for (i = 0; kshbuiltins[i].name != NULL; i++) builtin(kshbuiltins[i].name, kshbuiltins[i].func); init_histvec(); def_path = DEFAULT__PATH; #if defined(HAVE_CONFSTR) && defined(_CS_PATH) { size_t len = confstr(_CS_PATH, (char *) 0, 0); char *new; if (len > 0) { confstr(_CS_PATH, new = alloc(len + 1, APERM), len + 1); def_path = new; } }
int main(void) { DDRC |= (1<<PORTC6) | (1<<PORTC7); //init LEDs //servoTx; SERVO_init(); //Init servos USART_init(); init_counters(); set_counter_1(10000); initvar(); sei(); SERVO_update_EEPROM(BROADCASTING_ID); //move_to_std(); // ------ TESTCODE FOR READING SERVO ------- //servoGoto(1, 3.14/3, 0x200); SERVO_update_EEPROM(BROADCASTING_ID); // NOTE: needs to run once for SERVO_get position to work //---------------------------- _delay_ms(3000); reset_counter_1(); set_counter_1(3000); while(1) { /* uint8_t r = USART_getRotation(); uint8_t s = USART_getSpeed(); uint8_t d = USART_getDirection(); if(s != 0 || r != 50) { std_pos_flag = 0; reset_counter_1(); } move_robot(d, r, s); if(r == 50 && s == 0 && d == 0) { _delay_ms(50); //PORTD ^= (1<<PORTD5); cli(); USART_send_ready(); sei(); } */ /*change_z(-130); move_to_std(); for(int i = 0; i < 5; ++i) { move_robot(0,50,100); //_delay_ms(2000); } _delay_ms(1000); move_to_std(); _delay_ms(1000); */ climb(); //climb_all_one_leg(); //SERVO_update_data(12); //USART_SendValue(SERVO_get_load()); USART_DecodeRxFIFO(); _delay_ms(200); } }
static int main_init(int argc, const char *argv[], Source **sp, struct block **lp) { int argi, i; Source *s = NULL; struct block *l; unsigned char restricted_shell, errexit, utf_flag; char *cp; const char *ccp, **wp; struct tbl *vp; struct stat s_stdin; #if !defined(_PATH_DEFPATH) && defined(_CS_PATH) ssize_t k; #endif #if defined(MKSH_EBCDIC) || defined(MKSH_FAUX_EBCDIC) ebcdic_init(); #endif set_ifs(TC_IFSWS); #ifdef __OS2__ os2_init(&argc, &argv); #endif /* do things like getpgrp() et al. */ chvt_reinit(); /* make sure argv[] is sane, for weird OSes */ if (!*argv) { argv = empty_argv; argc = 1; } kshname = argv[0]; /* initialise permanent Area */ ainit(&aperm); /* max. name length: -2147483648 = 11 (+ NUL) */ vtemp = alloc(offsetof(struct tbl, name[0]) + 12, APERM); /* set up base environment */ env.type = E_NONE; ainit(&env.area); /* set up global l->vars and l->funs */ newblock(); /* Do this first so output routines (eg, errorf, shellf) can work */ initio(); /* determine the basename (without '-' or path) of the executable */ ccp = kshname; goto begin_parsing_kshname; while ((i = ccp[argi++])) { if (mksh_cdirsep(i)) { ccp += argi; begin_parsing_kshname: argi = 0; if (*ccp == '-') ++ccp; } } if (!*ccp) ccp = empty_argv[0]; /* * Turn on nohup by default. (AT&T ksh does not have a nohup * option - it always sends the hup). */ Flag(FNOHUP) = 1; /* * Turn on brace expansion by default. AT&T kshs that have * alternation always have it on. */ Flag(FBRACEEXPAND) = 1; /* * Turn on "set -x" inheritance by default. */ Flag(FXTRACEREC) = 1; /* define built-in commands and see if we were called as one */ ktinit(APERM, &builtins, /* currently up to 54 builtins: 75% of 128 = 2^7 */ 7); for (i = 0; mkshbuiltins[i].name != NULL; i++) if (!strcmp(ccp, builtin(mkshbuiltins[i].name, mkshbuiltins[i].func))) Flag(FAS_BUILTIN) = 1; if (!Flag(FAS_BUILTIN)) { /* check for -T option early */ argi = parse_args(argv, OF_FIRSTTIME, NULL); if (argi < 0) return (1); #if defined(MKSH_BINSHPOSIX) || defined(MKSH_BINSHREDUCED) /* are we called as -sh or /bin/sh or so? */ if (!strcmp(ccp, "sh" MKSH_EXE_EXT)) { /* either also turns off braceexpand */ #ifdef MKSH_BINSHPOSIX /* enable better POSIX conformance */ change_flag(FPOSIX, OF_FIRSTTIME, true); #endif #ifdef MKSH_BINSHREDUCED /* enable kludge/compat mode */ change_flag(FSH, OF_FIRSTTIME, true); #endif } #endif } initvar(); inittraps(); coproc_init(); /* set up variable and command dictionaries */ ktinit(APERM, &taliases, 0); ktinit(APERM, &aliases, 0); #ifndef MKSH_NOPWNAM ktinit(APERM, &homedirs, 0); #endif /* define shell keywords */ initkeywords(); init_histvec(); /* initialise tty size before importing environment */ change_winsz(); #ifdef _PATH_DEFPATH def_path = _PATH_DEFPATH; #else #ifdef _CS_PATH if ((k = confstr(_CS_PATH, NULL, 0)) > 0 && confstr(_CS_PATH, cp = alloc(k + 1, APERM), k + 1) == k + 1) def_path = cp; else #endif /* * this is uniform across all OSes unless it * breaks somewhere hard; don't try to optimise, * e.g. add stuff for Interix or remove /usr * for HURD, because e.g. Debian GNU/HURD is * "keeping a regular /usr"; this is supposed * to be a sane 'basic' default PATH */ def_path = MKSH_UNIXROOT "/bin" MKSH_PATHSEPS MKSH_UNIXROOT "/usr/bin" MKSH_PATHSEPS MKSH_UNIXROOT "/sbin" MKSH_PATHSEPS MKSH_UNIXROOT "/usr/sbin"; #endif /* * Set PATH to def_path (will set the path global variable). * (import of environment below will probably change this setting). */ vp = global(TPATH); /* setstr can't fail here */ setstr(vp, def_path, KSH_RETURN_ERROR); #ifndef MKSH_NO_CMDLINE_EDITING /* * Set edit mode to emacs by default, may be overridden * by the environment or the user. Also, we want tab completion * on in vi by default. */ change_flag(FEMACS, OF_SPECIAL, true); #if !MKSH_S_NOVI Flag(FVITABCOMPLETE) = 1; #endif #endif /* import environment */ init_environ(); /* override default PATH regardless of environment */ #ifdef MKSH_DEFPATH_OVERRIDE vp = global(TPATH); setstr(vp, MKSH_DEFPATH_OVERRIDE, KSH_RETURN_ERROR); #endif /* for security */ typeset(TinitIFS, 0, 0, 0, 0); /* assign default shell variable values */ typeset("PATHSEP=" MKSH_PATHSEPS, 0, 0, 0, 0); substitute(initsubs, 0); /* Figure out the current working directory and set $PWD */ vp = global(TPWD); cp = str_val(vp); /* Try to use existing $PWD if it is valid */ set_current_wd((mksh_abspath(cp) && test_eval(NULL, TO_FILEQ, cp, Tdot, true)) ? cp : NULL); if (current_wd[0]) simplify_path(current_wd); /* Only set pwd if we know where we are or if it had a bogus value */ if (current_wd[0] || *cp) /* setstr can't fail here */ setstr(vp, current_wd, KSH_RETURN_ERROR); for (wp = initcoms; *wp != NULL; wp++) { c_builtin(wp); while (*wp != NULL) wp++; } setint_n(global("OPTIND"), 1, 10); kshuid = getuid(); kshgid = getgid(); kshegid = getegid(); safe_prompt = ksheuid ? "$ " : "# "; vp = global("PS1"); /* Set PS1 if unset or we are root and prompt doesn't contain a # */ if (!(vp->flag & ISSET) || (!ksheuid && !strchr(str_val(vp), '#'))) /* setstr can't fail here */ setstr(vp, safe_prompt, KSH_RETURN_ERROR); setint_n((vp = global("BASHPID")), 0, 10); vp->flag |= INT_U; setint_n((vp = global("PGRP")), (mksh_uari_t)kshpgrp, 10); vp->flag |= INT_U; setint_n((vp = global("PPID")), (mksh_uari_t)kshppid, 10); vp->flag |= INT_U; setint_n((vp = global("USER_ID")), (mksh_uari_t)ksheuid, 10); vp->flag |= INT_U; setint_n((vp = global("KSHUID")), (mksh_uari_t)kshuid, 10); vp->flag |= INT_U; setint_n((vp = global("KSHEGID")), (mksh_uari_t)kshegid, 10); vp->flag |= INT_U; setint_n((vp = global("KSHGID")), (mksh_uari_t)kshgid, 10); vp->flag |= INT_U; setint_n((vp = global("RANDOM")), rndsetup(), 10); vp->flag |= INT_U; setint_n((vp_pipest = global("PIPESTATUS")), 0, 10); /* Set this before parsing arguments */ Flag(FPRIVILEGED) = (kshuid != ksheuid || kshgid != kshegid) ? 2 : 0; /* this to note if monitor is set on command line (see below) */ #ifndef MKSH_UNEMPLOYED Flag(FMONITOR) = 127; #endif /* this to note if utf-8 mode is set on command line (see below) */ UTFMODE = 2; if (!Flag(FAS_BUILTIN)) { argi = parse_args(argv, OF_CMDLINE, NULL); if (argi < 0) return (1); } /* process this later only, default to off (hysterical raisins) */ utf_flag = UTFMODE; UTFMODE = 0; if (Flag(FAS_BUILTIN)) { /* auto-detect from environment variables, always */ utf_flag = 3; } else if (Flag(FCOMMAND)) { s = pushs(SSTRINGCMDLINE, ATEMP); if (!(s->start = s->str = argv[argi++])) errorf(Tf_optfoo, "", "", 'c', Treq_arg); while (*s->str) { if (ctype(*s->str, C_QUOTE)) break; s->str++; } if (!*s->str) s->flags |= SF_MAYEXEC; s->str = s->start; #ifdef MKSH_MIDNIGHTBSD01ASH_COMPAT /* compatibility to MidnightBSD 0.1 /bin/sh (kludge) */ if (Flag(FSH) && argv[argi] && !strcmp(argv[argi], "--")) ++argi; #endif if (argv[argi]) kshname = argv[argi++]; } else if (argi < argc && !Flag(FSTDIN)) { s = pushs(SFILE, ATEMP); #ifdef __OS2__ /* * A bug in OS/2 extproc (like shebang) handling makes * it not pass the full pathname of a script, so we need * to search for it. This changes the behaviour of a * simple "mksh foo", but can't be helped. */ s->file = argv[argi++]; if (search_access(s->file, X_OK) != 0) s->file = search_path(s->file, path, X_OK, NULL); if (!s->file || !*s->file) s->file = argv[argi - 1]; #else s->file = argv[argi++]; #endif s->u.shf = shf_open(s->file, O_RDONLY, 0, SHF_MAPHI | SHF_CLEXEC); if (s->u.shf == NULL) { shl_stdout_ok = false; warningf(true, Tf_sD_s, s->file, cstrerror(errno)); /* mandated by SUSv4 */ exstat = 127; unwind(LERROR); } kshname = s->file; } else { Flag(FSTDIN) = 1; s = pushs(SSTDIN, ATEMP); s->file = "<stdin>"; s->u.shf = shf_fdopen(0, SHF_RD | can_seek(0), NULL); if (isatty(0) && isatty(2)) { Flag(FTALKING) = Flag(FTALKING_I) = 1; /* The following only if isatty(0) */ s->flags |= SF_TTY; s->u.shf->flags |= SHF_INTERRUPT; s->file = NULL; } } /* this bizarreness is mandated by POSIX */ if (fstat(0, &s_stdin) >= 0 && S_ISCHR(s_stdin.st_mode) && Flag(FTALKING)) reset_nonblock(0); /* initialise job control */ j_init(); /* do this after j_init() which calls tty_init_state() */ if (Flag(FTALKING)) { if (utf_flag == 2) { #ifndef MKSH_ASSUME_UTF8 /* auto-detect from locale or environment */ utf_flag = 4; #else /* this may not be an #elif */ #if MKSH_ASSUME_UTF8 utf_flag = 1; #else /* always disable UTF-8 (for interactive) */ utf_flag = 0; #endif #endif } #ifndef MKSH_NO_CMDLINE_EDITING x_init(); #endif } #ifdef SIGWINCH sigtraps[SIGWINCH].flags |= TF_SHELL_USES; setsig(&sigtraps[SIGWINCH], x_sigwinch, SS_RESTORE_ORIG|SS_FORCE|SS_SHTRAP); #endif l = e->loc; if (Flag(FAS_BUILTIN)) { l->argc = argc; l->argv = argv; l->argv[0] = ccp; } else { l->argc = argc - argi; /* * allocate a new array because otherwise, when we modify * it in-place, ps(1) output changes; the meaning of argc * here is slightly different as it excludes kshname, and * we add a trailing NULL sentinel as well */ l->argv = alloc2(l->argc + 2, sizeof(void *), APERM); l->argv[0] = kshname; memcpy(&l->argv[1], &argv[argi], l->argc * sizeof(void *)); l->argv[l->argc + 1] = NULL; getopts_reset(1); } /* divine the initial state of the utf8-mode Flag */ ccp = null; switch (utf_flag) { /* auto-detect from locale or environment */ case 4: #if HAVE_SETLOCALE_CTYPE ccp = setlocale(LC_CTYPE, ""); #if HAVE_LANGINFO_CODESET if (!isuc(ccp)) ccp = nl_langinfo(CODESET); #endif if (!isuc(ccp)) ccp = null; #endif /* FALLTHROUGH */ /* auto-detect from environment */ case 3: /* these were imported from environ earlier */ if (ccp == null) ccp = str_val(global("LC_ALL")); if (ccp == null) ccp = str_val(global("LC_CTYPE")); if (ccp == null) ccp = str_val(global("LANG")); UTFMODE = isuc(ccp); break; /* not set on command line, not FTALKING */ case 2: /* unknown values */ default: utf_flag = 0; /* FALLTHROUGH */ /* known values */ case 1: case 0: UTFMODE = utf_flag; break; } /* Disable during .profile/ENV reading */ restricted_shell = Flag(FRESTRICTED); Flag(FRESTRICTED) = 0; errexit = Flag(FERREXIT); Flag(FERREXIT) = 0; /* * Do this before profile/$ENV so that if it causes problems in them, * user will know why things broke. */ if (!current_wd[0] && Flag(FTALKING)) warningf(false, "can't determine current directory"); if (Flag(FLOGIN)) include(MKSH_SYSTEM_PROFILE, 0, NULL, true); if (!Flag(FPRIVILEGED)) { if (Flag(FLOGIN)) include(substitute("$HOME/.profile", 0), 0, NULL, true); if (Flag(FTALKING)) { cp = substitute("${ENV:-" MKSHRC_PATH "}", DOTILDE); if (cp[0] != '\0') include(cp, 0, NULL, true); } } else { include(MKSH_SUID_PROFILE, 0, NULL, true); /* turn off -p if not set explicitly */ if (Flag(FPRIVILEGED) != 1) change_flag(FPRIVILEGED, OF_INTERNAL, false); } if (restricted_shell) { c_builtin(restr_com); /* After typeset command... */ Flag(FRESTRICTED) = 1; } Flag(FERREXIT) = errexit; if (Flag(FTALKING) && s) hist_init(s); else /* set after ENV */ Flag(FTRACKALL) = 1; alarm_init(); *sp = s; *lp = l; return (0); }
main() { int16 i; int16 j; int16 test[100]; //一、 system initialize: pll clock:150M;hispcp=1 100m/2; lospcp=2 100m/4;eWM,ADC,cpu Timer clock enabled InitSysCtrl(); //修改了默认时钟到150MHz,关闭了无关外设时钟 // DELAY_US(1000000); //二、initialize GPIO:set the GPIO to it's default state: 普通GPIO状态,均为输入,输入采样方式为第一种,均为上拉使能. //epwm disable pull up InitGpio(); //全部引脚初始化 //用户自定义IO初始化(主要包括:逻辑输入输出引脚) InitLogicIO(); //串口初始化 InitScicGpio(); InitSci(); //初始化触摸屏变量 initvar(); // MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart); //EPwm初始化 // InitEPwmGpio(); //PWM IO初始化 //InitEPwm1Gpio(); //InitEPwm2Gpio(); //所有PWM模块都需要开启 //InitEPwm3Gpio(); //InitEPwm4Gpio(); //InitEPwm5Gpio(); //InitEPwm6Gpio(); //三、initialize interrupts:disable cpu interrupt; disabel all pie interrupts and clear all pie interrupt flags DINT; InitPieCtrl(); IER=0x0000; IFR=0x0000; //initialize Pie interrupts and enable pie InitPieVectTable(); //用户自定义的中断初始化 EALLOW; PieVectTable.TINT0 = &cpu_timer0_isr; //Cpu timer0 interrupt PieVectTable.XINT1 = &xint1_isr; EDIS; //四、initialize peripherials and setup peripherials InitFlash(); InitXintf(); //ADC initialize InitAdc(); //ADC setup SetupAdc(); // Adc_Inquire(); //Epwm Setup // SetupEPwm(); //pwm开始产生 //CPU timer0 initialize InitCpuTimers(); // Configure CPU-Timer 0 to interrupt every msecond: // 150MHz CPU Freq, 3m second Period (in uSeconds) ConfigCpuTimer(&CpuTimer0, 150, 3000); StartCpuTimer0(); //五、User specific code, enable interrupts: //在开始中断之前先进行测试循环。此时进行单步运行 //1. I/O test //测试程序,GPIOA的低18位为通用I/O输入 //测试程序,GPIOA的24,25,26,27为通用I/O输入,GPIOB的48-61为通用I/O输入 //由于I/o口均有上拉,所以只要测试输入0时是否正确即可。这样最大限度保护芯片。 for(i=0;i<100;i++) { j=i; } // EALLOW; // GpioCtrlRegs.GPADIR.all = 0x0003FFFF; // GPIO functionality GPIO0-GPIO15 // EDIS; // GpioDataRegs.GPACLEAR.all = 0x0003FFFF; // GpioDataRegs.GPASET.all = 0x0001AAAA; // GpioDataRegs.GPATOGGLE.all = 0x0003FFFF; //2. Communication Test: //具体通讯是否成功还需要更多程序 //测试RS485通讯芯片 GpioDataRegs.GPASET.bit.GPIO21=1; GpioDataRegs.GPATOGGLE.bit.GPIO22=1; //测试CAN通讯芯片 GpioDataRegs.GPATOGGLE.bit.GPIO19=1; for(i=0;i<100;i++) { j=i; } //测试RS485通讯芯片 GpioDataRegs.GPASET.bit.GPIO21=1; GpioDataRegs.GPATOGGLE.bit.GPIO22=1; //测试CAN通讯芯片 GpioDataRegs.GPATOGGLE.bit.GPIO19=1; for(i=0;i<100;i++) { j=i; } // 3. A/D Test //软件启动adc转换 for(i=0;i<100;i++) { AdcRegs.ADCTRL2.bit.SOC_SEQ1=1; Adc_Inquire(); } // 4. PWM Test //每次测一个单相,这样子发现错误及时下电 for(i=0;i<100;i++) { j=i; } *FPGA_PWMA_Wait1=1000; *FPGA_PWMA_Duty1=1000; *FPGA_PWMA_Wait2=2000; *FPGA_PWMA_Duty2=2000; *FPGA_PWMA_Wait3=3000; *FPGA_PWMA_Duty3=3000; *FPGA_PWMA_Wait4=4000; *FPGA_PWMA_Duty4=4000; *FPGA_PWMA_Wait5=5000; *FPGA_PWMA_Duty5=5000; *FPGA_PWMA_Wait6=6000; *FPGA_PWMA_Duty6=6000; *FPGA_PWMA_Wait7=1000; *FPGA_PWMA_Duty7=1000; *FPGA_PWMA_Wait8=2000; *FPGA_PWMA_Duty8=2000; *FPGA_PWMA_Wait9=3000; *FPGA_PWMA_Duty9=3000; *FPGA_PWMA_Wait10=4000; *FPGA_PWMA_Duty10=4000; *FPGA_PWMA_Wait11=5000; *FPGA_PWMA_Duty11=5000; *FPGA_PWMA_Wait12=6000; *FPGA_PWMA_Duty12=6000; for(i=0;i<100;i++) { j=i; } *FPGA_PWMB_Wait1=1000; *FPGA_PWMB_Duty1=1000; *FPGA_PWMB_Wait2=2000; *FPGA_PWMB_Duty2=2000; *FPGA_PWMB_Wait3=3000; *FPGA_PWMB_Duty3=3000; *FPGA_PWMB_Wait4=4000; *FPGA_PWMB_Duty4=4000; *FPGA_PWMB_Wait5=5000; *FPGA_PWMB_Duty5=5000; *FPGA_PWMB_Wait6=6000; *FPGA_PWMB_Duty6=6000; *FPGA_PWMB_Wait7=1000; *FPGA_PWMB_Duty7=1000; *FPGA_PWMB_Wait8=2000; *FPGA_PWMB_Duty8=2000; *FPGA_PWMB_Wait9=3000; *FPGA_PWMB_Duty9=3000; *FPGA_PWMB_Wait10=4000; *FPGA_PWMB_Duty10=4000; *FPGA_PWMB_Wait11=5000; *FPGA_PWMB_Duty11=5000; *FPGA_PWMB_Wait12=6000; *FPGA_PWMB_Duty12=6000; for(i=0;i<100;i++) { j=i; } *FPGA_PWMC_Wait1=1000; *FPGA_PWMC_Duty1=1000; *FPGA_PWMC_Wait2=2000; *FPGA_PWMC_Duty2=2000; *FPGA_PWMC_Wait3=3000; *FPGA_PWMC_Duty3=3000; *FPGA_PWMC_Wait4=4000; *FPGA_PWMC_Duty4=4000; *FPGA_PWMC_Wait5=5000; *FPGA_PWMC_Duty5=5000; *FPGA_PWMC_Wait6=6000; *FPGA_PWMC_Duty6=6000; *FPGA_PWMC_Wait7=1000; *FPGA_PWMC_Duty7=1000; *FPGA_PWMC_Wait8=2000; *FPGA_PWMC_Duty8=2000; *FPGA_PWMC_Wait9=3000; *FPGA_PWMC_Duty9=3000; *FPGA_PWMC_Wait10=4000; *FPGA_PWMC_Duty10=4000; *FPGA_PWMC_Wait11=5000; *FPGA_PWMC_Duty11=5000; *FPGA_PWMC_Wait12=6000; *FPGA_PWMC_Duty12=6000; for(i=0;i<100;i++) { j=i; } *FPGA_PWMD_Wait1=1000; *FPGA_PWMD_Duty1=1000; *FPGA_PWMD_Wait2=2000; *FPGA_PWMD_Duty2=2000; *FPGA_PWMD_Wait3=3000; *FPGA_PWMD_Duty3=3000; *FPGA_PWMD_Wait4=4000; *FPGA_PWMD_Duty4=4000; *FPGA_PWMD_Wait5=5000; *FPGA_PWMD_Duty5=5000; *FPGA_PWMD_Wait6=6000; *FPGA_PWMD_Duty6=6000; *FPGA_PWMD_Wait7=1000; *FPGA_PWMD_Duty7=1000; *FPGA_PWMD_Wait8=2000; *FPGA_PWMD_Duty8=2000; *FPGA_PWMD_Wait9=3000; *FPGA_PWMD_Duty9=3000; *FPGA_PWMD_Wait10=4000; *FPGA_PWMD_Duty10=4000; *FPGA_PWMD_Wait11=5000; *FPGA_PWMD_Duty11=5000; *FPGA_PWMD_Wait12=6000; *FPGA_PWMD_Duty12=6000; for(i=0;i<100;i++) { j=i; } *FPGA_PWME_Wait1=1000; *FPGA_PWME_Duty1=1000; *FPGA_PWME_Wait2=2000; *FPGA_PWME_Duty2=2000; *FPGA_PWME_Wait3=3000; *FPGA_PWME_Duty3=3000; *FPGA_PWME_Wait4=4000; *FPGA_PWME_Duty4=4000; *FPGA_PWME_Wait5=5000; *FPGA_PWME_Duty5=5000; *FPGA_PWME_Wait6=6000; *FPGA_PWME_Duty6=6000; *FPGA_PWME_Wait7=1000; *FPGA_PWME_Duty7=1000; *FPGA_PWME_Wait8=2000; *FPGA_PWME_Duty8=2000; *FPGA_PWME_Wait9=3000; *FPGA_PWME_Duty9=3000; *FPGA_PWME_Wait10=4000; *FPGA_PWME_Duty10=4000; *FPGA_PWME_Wait11=5000; *FPGA_PWME_Duty11=5000; *FPGA_PWME_Wait12=6000; *FPGA_PWME_Duty12=6000; //PWM复位功能演示,复位以后,所有PWM为零。 GpioDataRegs.GPACLEAR.bit.GPIO31=1; DELAY_US(1); GpioDataRegs.GPASET.bit.GPIO31=1; // 5. D/A Test *DAC1=1024; *DAC2=2048; *DAC3=3072; *DAC4=4095; // 6.测试FPGA的I/O // 首先测试是否结果为1 for(j=0;j<10;j++) { for(i=0; i<24; i++) test[i]=*(FPGA_IO1_DATA+i); i=0; } //再测试是否结果为0 for(j=0;j<100;j++) { for(i=0; i<24; i++) test[i]=*(FPGA_IO1_DATA+i); i=0; } //输出功能演示,只有输出使能的IO pin才能输出0 *FPGA_IODIR_LOW=0xFFFF; *FPGA_IODIR_HIGH=0x00FF; j=0; for(i=0; i<24; i++) { *(FPGA_IO1_DATA+i)=j; j=~j; } j=0; for(i=0; i<24; i++) { j=~j; *(FPGA_IO1_DATA+i)=j; } //复位功能演示,复位以后,所有IO上拉。且输出不使能 GpioDataRegs.GPACLEAR.bit.GPIO30=1; DELAY_US(1); GpioDataRegs.GPASET.bit.GPIO30=1; j=*FPGA_IODIR_LOW; j=*FPGA_IODIR_HIGH; j=0; for(i=0; i<24; i++) *(FPGA_IO1_DATA+i)=j; //开用到的中断,最后开中断。测试SCI 通讯以及DSP 和FPGA的通讯 EnableInterrupts(); //cpu timer0 中断 i=0; // 六. 主循环IDLE loop. Just sit and loop forever (optional): for(;;) { // ScicRegs.SCITXBUF=i; DELAY_US(1000); /* if(GpioDataRegs.GPADAT.bit.GPIO27==0) GpioDataRegs.GPBCLEAR.bit.GPIO50=1; else GpioDataRegs.GPBSET.bit.GPIO50=1; if(GpioDataRegs.GPBDAT.bit.GPIO48==0) GpioDataRegs.GPBCLEAR.bit.GPIO51=1; else GpioDataRegs.GPBSET.bit.GPIO51=1; // ModebusRegsDataBuff[0]=i; // GpioDataRegs.GPBTOGGLE.bit.GPIO60=1; // GpioDataRegs.GPBTOGGLE.bit.GPIO61=1; // GpioDataRegs.GPBTOGGLE.bit.GPIO58=1; // GpioDataRegs.GPBTOGGLE.bit.GPIO59=1; GpioDataRegs.GPBCLEAR.bit.GPIO53= 1; GpioDataRegs.GPBCLEAR.bit.GPIO52= 1; i++; // if(i==2000) if(i==FPGA_DATA_Test_length) i=0; // TestState=~TestState; */ slavecomm(); } }
int main(int argc, char *argv[]) { long length; char *buffer; char *server_url = NULL; long i; long filter=0; #ifdef MUST_DISABLE_SIGFPE signal(SIGFPE,SIG_IGN); #endif #ifdef MUST_DISABLE_FPMASK fpsetmask(0); #endif optind = 0; opterr = 0; /* initialize getopt */ /* what do we get for cmdline arguments? for (i=0;i<argc;i++) printf("%d-'%s'\n",i,argv[i]); */ while (1) { static struct option long_options[] = { { "filter", no_argument, 0, 'f' }, { 0, 0, 0, 0} }; int option_index = 0; int opt; opt = getopt_long(argc, argv, "f", long_options, &option_index); if (opt == EOF) { break; } switch(opt) { case 'f': filter=1; break; case '?': printf("unknown commandline option '%s'\n",argv[optind-1]); return -1; } } if (!filter) { rrdcgiDebug(0,0); rrdcgiArg = rrdcgiInit(); server_url = getenv("SERVER_URL"); } /* make sure we have one extra argument, if there are others, we do not care Apache gives several */ /* if ( (optind != argc-2 && strstr( getenv("SERVER_SOFTWARE"),"Apache/2") != NULL) && optind != argc-1) { */ if ( optind >= argc ) { fprintf(stderr, "ERROR: expected a filename\n"); exit(1); } else { length = readfile(argv[optind], &buffer, 1); } if(rrd_test_error()) { fprintf(stderr, "ERROR: %s\n",rrd_get_error()); exit(1); } /* initialize variable heap */ initvar(); #ifdef DEBUG_PARSER /* some fake header for testing */ printf ("Content-Type: text/html\nContent-Length: 10000000\n\n\n"); #endif /* expand rrd directives in buffer recursivly */ for (i=0; buffer[i]; i++) { if (buffer[i] != '<') continue; if (!filter) { parse(&buffer, i, "<RRD::CV", cgiget); parse(&buffer, i, "<RRD::CV::PATH", cgigetqp); parse(&buffer, i, "<RRD::CV::QUOTE", cgigetq); parse(&buffer, i, "<RRD::GETENV", rrdgetenv); } parse(&buffer, i, "<RRD::GETVAR", rrdgetvar); parse(&buffer, i, "<RRD::GOODFOR", rrdgoodfor); parse(&buffer, i, "<RRD::GRAPH", drawgraph); parse(&buffer, i, "<RRD::INCLUDE", includefile); parse(&buffer, i, "<RRD::PRINT", drawprint); parse(&buffer, i, "<RRD::SETCONSTVAR", rrdsetvarconst); parse(&buffer, i, "<RRD::SETENV", rrdsetenv); parse(&buffer, i, "<RRD::SETVAR", rrdsetvar); parse(&buffer, i, "<RRD::TIME::LAST", printtimelast); parse(&buffer, i, "<RRD::TIME::NOW", printtimenow); parse(&buffer, i, "<RRD::TIME::STRFTIME", printstrftime); parse(&buffer, i, "<RRD::INTERNAL", rrdgetinternal); } if (!filter) { printf ("Content-Type: text/html\n" "Content-Length: %d\n", strlen(buffer)); if (labs(goodfor) > 0) { time_t now; now = time(NULL); printf("Last-Modified: %s\n", http_time(&now)); now += labs(goodfor); printf("Expires: %s\n", http_time(&now)); if (goodfor < 0) { printf("Refresh: %ld\n", labs(goodfor)); } } printf("\n"); } /* output result */ printf("%s", buffer); /* cleanup */ calfree(); if (buffer){ free(buffer); } donevar(); exit(0); }
int main(int argc, char *argv[]) { int i; int argi; Source *s; struct block *l; int restricted, errexit; char **wp; struct env env; pid_t ppid; /* make sure argv[] is sane */ if (!*argv) { static const char *empty_argv[] = { "ksh", (char *) 0 }; argv = (char **) empty_argv; argc = 1; } kshname = *argv; ainit(&aperm); /* initialize permanent Area */ /* set up base environment */ memset(&env, 0, sizeof(env)); env.type = E_NONE; ainit(&env.area); e = &env; newblock(); /* set up global l->vars and l->funs */ /* Do this first so output routines (eg, errorf, shellf) can work */ initio(); initvar(); initctypes(); inittraps(); coproc_init(); /* set up variable and command dictionaries */ ktinit(&taliases, APERM, 0); ktinit(&aliases, APERM, 0); ktinit(&homedirs, APERM, 0); /* define shell keywords */ initkeywords(); /* define built-in commands */ ktinit(&builtins, APERM, 64); /* must be 2^n (currently 40 builtins) */ for (i = 0; shbuiltins[i].name != NULL; i++) builtin(shbuiltins[i].name, shbuiltins[i].func); for (i = 0; kshbuiltins[i].name != NULL; i++) builtin(kshbuiltins[i].name, kshbuiltins[i].func); init_histvec(); def_path = _PATH_DEFPATH; { size_t len = confstr(_CS_PATH, (char *) 0, 0); char *new; if (len > 0) { confstr(_CS_PATH, new = alloc(len + 1, APERM), len + 1); def_path = new; } }
void project::initoroject(QString fproject) { QElapsedTimer timerdebug; this->name = fproject; QSqlQuery query; initvar(); this->addgroup("ALL", -1, 0, 0, "", 0); this->addgroup("ALL", -1, 0, 1, "", 0); if (query.exec("SELECT default_table, introindex, introref, introreel, indexbool FROM all_config WHERE project_name='" + fproject +"'")) { while(query.next()) { default_table = (query.value(0).toInt()); introindex = (query.value(1).toString()); introref = (query.value(2).toString()); introreel = (query.value(3).toString()); indexbool = (query.value(4).toBool()); } } else qDebug() << "error get info_project :" << query.lastError(); qDebug() << "init groupe";timerdebug.start(); if (query.exec("SELECT groupname, groupparent, id, type, description, gquestion FROM project_" + fproject + "_groupe")) { while(query.next()) { this->addgroup(query.value(0).toString(), query.value(1).toInt(), query.value(2).toInt(), query.value(3).toInt(), query.value(4).toString(), query.value(5).toInt()); } } else qDebug() << "error get group :" << query.lastError(); qDebug() << "init group time" << timerdebug.elapsed() << "milliseconds"; qDebug() << "init question";timerdebug.start(); if (query.exec("SELECT question,groupid,id,qgroupid,sujet,type,typef,splitchar,value,ref_only FROM project_" + fproject + "_question")) { while(query.next()) { this->addquestion(query.value(0).toString(), query.value(1).toInt(), query.value(2).toInt(), query.value(3).toInt(), query.value(4).toString(), query.value(5).toString(), query.value(6).toInt(), query.value(7).toString(), query.value(8).toInt(), query.value(9).toInt(), 0); } } else qDebug() << "error get question :" << query.lastError(); qDebug() << "init question time" << timerdebug.elapsed() << "milliseconds"; qDebug() << "init persone";timerdebug.start(); if(query.exec("SELECT id, firstname,lastname,email,groupid,questionbool,refbool,jour FROM project_" + fproject + "_project")) { while(query.next()) { this->addperson(query.value(1).toString(), query.value(2).toString(), query.value(3).toString(), query.value(0).toInt(), &listquestion, query.value(4).toInt(), query.value(5).toInt(), query.value(6).toInt(), query.value(7).toInt()); } } else qDebug() << "error get user :"******"init persone time" << timerdebug.elapsed() << "milliseconds"; qDebug() << "init fact";timerdebug.start(); if(query.exec("SELECT idperson,name,time,note,date_info, iteration, idquestion, str FROM project_" + fproject + "_reponse")) { qDebug() << "query select reponse time" << timerdebug.elapsed() << "milliseconds"; while(query.next()) { this->addreponse(query.value(0).toInt(), query.value(1).toString().toStdString(), query.value(2).toInt(), query.value(3).toInt(), query.value(4).toDateTime().toString("dd/MM/yy hh:mm:ss"), query.value(5).toInt(), query.value(6).toInt(), query.value(7).toString()); } } else qDebug() << "error get reponse :" << query.lastError(); qDebug() << "init all reponse time" << timerdebug.elapsed() << "milliseconds"; qDebug() << "remplissage groupe persone";timerdebug.start(); vector<person>::iterator tmp; tmp = this->listp.begin(); while (tmp != this->listp.end()) { if (tmp->groupid > -1 && tmp->groupid < (int)(listgroup.size())) this->listgroup[tmp->getGroupid()].addperson(*tmp); tmp++; } qDebug() << "remplissage groupe personne time" << timerdebug.elapsed() << "milliseconds"; qDebug() << "remplissage groupe question";timerdebug.start(); vector<question>::iterator tmp2; tmp2 = this->listquestion.begin(); while (tmp2 != this->listquestion.end()) { if (tmp2->qgroupid > -1 && tmp2->qgroupid < (int)listqgroup.size()) this->listqgroup[tmp2->qgroupid].addquestion(*tmp2); tmp2++; } qDebug() << "remplissage groupe question time" << timerdebug.elapsed() << "milliseconds"; }
int main(int argc, char *argv[]) { struct stackmark smark, smark2; volatile int state; char *shinit; (void) setlocale(LC_ALL, ""); initcharset(); state = 0; if (setjmp(main_handler.loc)) { switch (exception) { case EXEXEC: exitstatus = exerrno; break; case EXERROR: exitstatus = 2; break; default: break; } if (state == 0 || iflag == 0 || ! rootshell || exception == EXEXIT) exitshell(exitstatus); reset(); if (exception == EXINT) out2fmt_flush("\n"); popstackmark(&smark); FORCEINTON; /* enable interrupts */ if (state == 1) goto state1; else if (state == 2) goto state2; else if (state == 3) goto state3; else goto state4; } handler = &main_handler; #ifdef DEBUG opentrace(); trputs("Shell args: "); trargs(argv); #endif rootpid = getpid(); rootshell = 1; initvar(); setstackmark(&smark); setstackmark(&smark2); procargs(argc, argv); pwd_init(iflag); if (iflag) chkmail(1); if (argv[0] && argv[0][0] == '-') { state = 1; read_profile("/etc/profile"); state1: state = 2; if (privileged == 0) read_profile("${HOME-}/.profile"); else read_profile("/etc/suid_profile"); } state2: state = 3; if (!privileged && iflag) { if ((shinit = lookupvar("ENV")) != NULL && *shinit != '\0') { state = 3; read_profile(shinit); } } state3: state = 4; popstackmark(&smark2); if (minusc) { evalstring(minusc, sflag ? 0 : EV_EXIT); } state4: if (sflag || minusc == NULL) { cmdloop(1); } exitshell(exitstatus); /*NOTREACHED*/ return 0; }
int main(void) { LED_INIT; //servoTx; sei(); USART_init(); MPU_init(); SERVO_init(); init_counters(); initvar(); SERVO_update_EEPROM(BROADCASTING_ID); wait(10); move_to_std(); wait_until_gyro_stable(); LED0_ON; USART_send_message("Gyro Stable"); // ------ TESTCODE FOR READING SERVO ------- //servoGoto(1, 3.14/3, 0x200); SERVO_update_EEPROM(BROADCASTING_ID); // NOTE: needs to run once for SERVO_get position to work //---------------------------- reset_counter_1(); set_counter_1(3000); uint8_t readyCounter = 0; while(1) { MPU_update(); if(USART_get_turn_flag()) { turn_degrees(USART_get_turn_angle(), USART_get_turn_dir()); } if(USART_get_climb_flag()) { climb(); } uint8_t r = USART_getRotation(); uint8_t s = USART_getSpeed(); uint8_t d = USART_getDirection(); if(s != 0 || r != 50) { std_pos_flag = 0; reset_counter_1(); readyCounter = 3; } move_robot(d, r, s); if(r == 50 && s == 0 && d == 0 && readyCounter) { cli(); USART_send_ready(); sei(); readyCounter--; } if(move_to_std_flag == 1) { move_to_std_flag = 0; move_to_std(); } /*climb(); for(int i = 0; i < 10; ++i) { move_robot(0,50,100); //wait(2000); } */ /* change_z(-120); move_to_std(); turn_degrees(180,1); // Takes a predecided number of steps forward // This is good when testing different things. wait(100); for(int i = 0; i < 10; ++i) { move_robot(0,50,100); //wait(2000); } */ USART_decode_rx_fifo(); } }
int main(int argc, char *argv[]) { struct stackmark smark, smark2; volatile int state; char *shinit; #ifdef CBSD char *MY_APP = NULL; char *cbsdpath = NULL; char *workdir = NULL; char *cbsd_disable_history = NULL; //getenv chdir("/var/empty"); /* Only use history when stdin is a tty. */ if ( isatty(0) && isatty(1) ) { cbsd_enable_history = 1; } #endif (void) setlocale(LC_ALL, ""); initcharset(); state = 0; if (setjmp(main_handler.loc)) { switch (exception) { case EXEXEC: exitstatus = exerrno; break; case EXERROR: exitstatus = 2; break; default: break; } if (state == 0 || iflag == 0 || ! rootshell || exception == EXEXIT) exitshell(exitstatus); reset(); if (exception == EXINT) out2fmt_flush("\n"); popstackmark(&smark); FORCEINTON; /* enable interrupts */ if (state == 1) goto state1; else if (state == 2) goto state2; else if (state == 3) goto state3; else goto state4; } handler = &main_handler; #ifdef DEBUG opentrace(); trputs("Shell args: "); trargs(argv); #endif rootpid = getpid(); rootshell = 1; INTOFF; initvar(); setstackmark(&smark); setstackmark(&smark2); #ifdef CBSD if (argc>1) { if (!strcmp(argv[1],"--help")) { system("/usr/local/bin/cbsd help"); exit(0); } else { if (!strcmp(argv[1],"version")) { printf("%s\n",VERSION); exit(0); } } } cbsd_disable_history=lookupvar("NO_CBSD_HISTORY"); if ( cbsd_disable_history != NULL ) cbsd_enable_history=0; workdir=lookupvar("workdir"); if ( workdir == NULL ) { read_profile("/etc/rc.conf"); setvarsafe("workdir", lookupvar("cbsd_workdir"), 0); } workdir=lookupvar("workdir"); if ( workdir == NULL ) { out2fmt_flush("cbsd: no workdir defined\n"); exitshell(1); } setvarsafe("PS1","cbsd@\\h> ",1); setvarsafe("workdir",workdir,1); workdir=lookupvar("workdir"); // ^^ after "setsave*" original is free cbsdpath = calloc(MAXPATHLEN, sizeof(char *)); if (argv[1]) { setvarsafe("CBSD_APP",basename(argv[1]),1); } if (cbsdpath == NULL) { out2fmt_flush("cbsd: out of memory for cbsdpath\n"); exitshell(1); } // %s/modules must be first for opportunity to have a module commands greater priority than the original CBSD command. // This makes it possible to write a 3rd party modules with altered functionality of the original code. sprintf(cbsdpath,"%s/modules:%s/bin:%s/sbin:%s/tools:%s/jailctl:%s/nodectl:%s/system:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin",workdir,cbsd_distdir,cbsd_distdir,cbsd_distdir,cbsd_distdir,cbsd_distdir,cbsd_distdir); setvarsafe("PATH",cbsdpath,1); ckfree(cbsdpath); // read global params first (disable/enable colors, repos etc..) read_profile("${workdir}/etc/defaults/global.conf"); read_profile("${workdir}/etc/global.conf"); if (lookupvar("NOCOLOR") != NULL ) { putenv("NOCOLOR=1"); } // non-interactive global env if (lookupvar("NOINTER") != NULL ) { setvarsafe("inter","1",1); putenv("inter=0"); } read_profile("/usr/local/cbsd/cbsd.conf"); read_profile("${workdir}/etc/defaults/logger.conf"); read_profile("${workdir}/etc/logger.conf"); if (cbsd_enable_history==1) { cbsd_history_file=calloc(MAXPATHLEN, sizeof(char *)); sprintf(cbsd_history_file,"%s/%s",workdir,CBSD_HISTORYFILE); } #endif procargs(argc, argv); pwd_init(iflag); INTON; #ifndef CBSD if (iflag) chkmail(1); #endif if (argv[0] && argv[0][0] == '-') { state = 1; read_profile("/etc/profile"); state1: state = 2; if (privileged == 0) read_profile("${HOME-}/.profile"); else read_profile("/etc/suid_profile"); } state2: state = 3; if (!privileged && iflag) { if ((shinit = lookupvar("ENV")) != NULL && *shinit != '\0') { state = 3; read_profile(shinit); } } state3: state = 4; popstackmark(&smark2); if (minusc) { evalstring(minusc, sflag ? 0 : EV_EXIT); } state4: if (sflag || minusc == NULL) { cmdloop(1); } exitshell(exitstatus); /*NOTREACHED*/ return 0; }