VirtualBox

Changeset 1229 in kBuild for trunk/src/kash


Ignore:
Timestamp:
Oct 8, 2007 10:29:04 PM (17 years ago)
Author:
bird
Message:

stubs, made echo work.

Location:
trunk/src/kash
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/main.c

    r1222 r1229  
    450450{
    451451        size_t len;
    452         strip_argv0(argv0, &len);
     452        argv0 = strip_argv0(argv0, &len);
    453453
    454454        fprintf(stdout,
  • trunk/src/kash/output.c

    r1218 r1229  
    109109        file->fd = BLOCK_OUT;
    110110        file->flags = 0;
     111        file->psh = psh;
    111112}
    112113#endif
  • trunk/src/kash/shinstance.c

    r1225 r1229  
    4242    shinstance *psh;
    4343
    44     psh = malloc(sizeof(*psh));
     44    psh = calloc(sizeof(*psh), 1);
    4545    if (psh)
    4646    {
    47         memset(psh, 0, sizeof(*psh));
    48 
    4947        /* memalloc.c */
    5048        psh->stacknleft = MINSIZE;
     
    6159        psh->output.bufsize = OUTBUFSIZ;
    6260        psh->output.fd = 1;
     61        psh->output.psh = psh;
    6362        psh->errout.bufsize = 100;
    6463        psh->errout.fd = 2;
     64        psh->errout.psh = psh;
    6565        psh->memout.fd = MEM_OUT;
     66        psh->memout.psh = psh;
    6667        psh->out1 = &psh->output;
    6768        psh->out2 = &psh->errout;
     
    8182char *sh_getenv(shinstance *psh, const char *var)
    8283{
     84#ifdef SH_PURE_STUB_MODE
    8385    return NULL;
     86#elif defined(SH_STUB_MODE)
     87    return getenv(var);
     88#else
     89#endif
    8490}
    8591
    8692char **sh_environ(shinstance *psh)
    8793{
     94#ifdef SH_PURE_STUB_MODE
    8895    static char *s_null[2] = {0,0};
    8996    return &s_null[0];
     97#elif defined(SH_STUB_MODE)
     98    return environ;
     99#else
     100#endif
    90101}
    91102
    92103const char *sh_gethomedir(shinstance *psh, const char *user)
    93104{
     105#ifdef SH_PURE_STUB_MODE
    94106    return NULL;
     107#elif defined(SH_STUB_MODE)
     108# ifdef _MSC_VER
     109    return NULL;
     110# else
     111    struct passwd *pwd = getpwnam(user);
     112    return pwd ? pwd->pw_dir;
     113# endif
     114#else
     115#endif
    95116}
    96117
    97118int sh_sigaction(int signo, const struct sh_sigaction *newp, struct sh_sigaction *oldp)
    98119{
    99     return -1;
     120#ifdef SH_PURE_STUB_MODE
     121    return -1;
     122#elif defined(SH_STUB_MODE)
     123# ifdef _MSC_VER
     124    return -1;
     125# else
     126    struct sigaction old;
     127    if (newp)
     128        return -1;
     129    if (sigaction(signo, NULL, &old))
     130        return -1;
     131    oldp->sh_flags = old.sa_flags;
     132    oldp->sh_handler = old.sa_handler;
     133    oldp->sh_mask = old.sa_mask;
     134    return 0;
     135# endif
     136#else
     137#endif
    100138}
    101139
     
    112150void sh_sigemptyset(sh_sigset_t *setp)
    113151{
    114 
     152    memset(setp, 0, sizeof(*setp));
    115153}
    116154
     
    122160void sh_abort(shinstance *psh)
    123161{
     162#ifdef SH_PURE_STUB_MODE
     163#elif defined(SH_STUB_MODE)
     164    abort();
     165#else
     166#endif
    124167}
    125168
    126169void sh_raise_sigint(shinstance *psh)
    127170{
    128 
     171#ifdef SH_PURE_STUB_MODE
     172#elif defined(SH_STUB_MODE)
     173    raise(SIGINT);
     174#else
     175#endif
    129176}
    130177
    131178int sh_kill(shinstance *psh, pid_t pid, int signo)
    132179{
    133     return -1;
     180#ifdef SH_PURE_STUB_MODE
     181    return -1;
     182#elif defined(SH_STUB_MODE)
     183# ifdef _MSC_VER
     184    return -1;
     185# else
     186    return kill(pid, signo);
     187# endif
     188#else
     189#endif
    134190}
    135191
    136192int sh_killpg(shinstance *psh, pid_t pgid, int signo)
    137193{
    138     return -1;
     194#ifdef SH_PURE_STUB_MODE
     195    return -1;
     196#elif defined(SH_STUB_MODE)
     197# ifdef _MSC_VER
     198    return -1;
     199# else
     200    return killpg(pgid, signo);
     201# endif
     202#else
     203#endif
    139204}
    140205
    141206clock_t sh_times(shinstance *psh, shtms *tmsp)
    142207{
    143     return 0;
     208#ifdef SH_PURE_STUB_MODE
     209    return 0;
     210#elif defined(SH_STUB_MODE)
     211# ifdef _MSC_VER
     212    return 0;
     213# else
     214    return times(tmsp);
     215# endif
     216#else
     217#endif
    144218}
    145219
    146220int sh_sysconf_clk_tck(void)
    147221{
     222#ifdef SH_PURE_STUB_MODE
    148223    return 1;
     224#else
     225# ifdef _MSC_VER
     226    return CLK_TCK;
     227# else
     228    return sysconf(_SC_CLK_TCK)
     229# endif
     230#endif
    149231}
    150232
    151233pid_t sh_fork(shinstance *psh)
    152234{
    153     return -1;
     235#ifdef SH_PURE_STUB_MODE
     236    return -1;
     237#elif defined(SH_STUB_MODE)
     238# ifdef _MSC_VER
     239    return -1;
     240# else
     241    return fork();
     242# endif
     243#else
     244#endif
    154245}
    155246
    156247pid_t sh_waitpid(shinstance *psh, pid_t pid, int *statusp, int flags)
    157248{
    158     return -1;
     249#ifdef SH_PURE_STUB_MODE
     250    return -1;
     251#elif defined(SH_STUB_MODE)
     252# ifdef _MSC_VER
     253    return -1;
     254# else
     255    return waitpid(pid, statusp, flags);
     256# endif
     257#else
     258#endif
    159259}
    160260
    161261void sh__exit(shinstance *psh, int rc)
    162262{
     263#ifdef SH_PURE_STUB_MODE
     264    return -1;
     265#elif defined(SH_STUB_MODE)
     266    _exit(rc);
     267#else
     268#endif
    163269}
    164270
    165271int sh_execve(shinstance *psh, const char *exe, const char * const *argv, const char * const *envp)
    166272{
    167     return -1;
     273#ifdef SH_PURE_STUB_MODE
     274    return -1;
     275#elif defined(SH_STUB_MODE)
     276# ifdef _MSC_VER
     277    return -1;
     278# else
     279    return execve(exe, (char **)argv, (char **)envp);
     280# endif
     281#else
     282#endif
    168283}
    169284
    170285uid_t sh_getuid(shinstance *psh)
    171286{
    172     return 0;
     287#ifdef SH_PURE_STUB_MODE
     288    return 0;
     289#elif defined(SH_STUB_MODE)
     290# ifdef _MSC_VER
     291    return 0;
     292# else
     293    return getuid();
     294# endif
     295#else
     296#endif
    173297}
    174298
    175299uid_t sh_geteuid(shinstance *psh)
    176300{
    177     return 0;
     301#ifdef SH_PURE_STUB_MODE
     302    return 0;
     303#elif defined(SH_STUB_MODE)
     304# ifdef _MSC_VER
     305    return 0;
     306# else
     307    return geteuid();
     308# endif
     309#else
     310#endif
    178311}
    179312
    180313gid_t sh_getgid(shinstance *psh)
    181314{
    182     return 0;
     315#ifdef SH_PURE_STUB_MODE
     316    return 0;
     317#elif defined(SH_STUB_MODE)
     318# ifdef _MSC_VER
     319    return 0;
     320# else
     321    return getgid();
     322# endif
     323#else
     324#endif
    183325}
    184326
    185327gid_t sh_getegid(shinstance *psh)
    186328{
    187     return 0;
     329#ifdef SH_PURE_STUB_MODE
     330    return 0;
     331#elif defined(SH_STUB_MODE)
     332# ifdef _MSC_VER
     333    return 0;
     334# else
     335    return getegid();
     336# endif
     337#else
     338#endif
    188339}
    189340
    190341pid_t sh_getpid(shinstance *psh)
    191342{
    192     return 0;
     343#ifdef SH_PURE_STUB_MODE
     344    return 0;
     345#elif defined(SH_STUB_MODE)
     346# ifdef _MSC_VER
     347    return _getpid();
     348# else
     349    return getpid();
     350# endif
     351#else
     352#endif
    193353}
    194354
    195355pid_t sh_getpgrp(shinstance *psh)
    196356{
    197     return 0;
     357#ifdef SH_PURE_STUB_MODE
     358    return 0;
     359#elif defined(SH_STUB_MODE)
     360# ifdef _MSC_VER
     361    return _getpid();
     362# else
     363    return getpgrp();
     364# endif
     365#else
     366#endif
    198367}
    199368
    200369pid_t sh_getpgid(shinstance *psh, pid_t pid)
    201370{
     371#ifdef SH_PURE_STUB_MODE
    202372    return pid;
     373#elif defined(SH_STUB_MODE)
     374# ifdef _MSC_VER
     375    return pid;
     376# else
     377    return getpgid(pid);
     378# endif
     379#else
     380#endif
    203381}
    204382
    205383int sh_setpgid(shinstance *psh, pid_t pid, pid_t pgid)
    206384{
    207     return -1;
     385#ifdef SH_PURE_STUB_MODE
     386    return -1;
     387#elif defined(SH_STUB_MODE)
     388# ifdef _MSC_VER
     389    return -1;
     390# else
     391    return setpgid(pid, pgid);
     392# endif
     393#else
     394#endif
    208395}
    209396
    210397pid_t sh_tcgetpgrp(shinstance *psh, int fd)
    211398{
    212     return -1;
     399#ifdef SH_PURE_STUB_MODE
     400    return -1;
     401#elif defined(SH_STUB_MODE)
     402# ifdef _MSC_VER
     403    return -1;
     404# else
     405    return tcgetpgrp(fd);
     406# endif
     407#else
     408#endif
    213409}
    214410
    215411int sh_tcsetpgrp(shinstance *psh, int fd, pid_t pgrp)
    216412{
    217     return -1;
     413#ifdef SH_PURE_STUB_MODE
     414    return -1;
     415#elif defined(SH_STUB_MODE)
     416# ifdef _MSC_VER
     417    return -1;
     418# else
     419    return tcsetpgrp(fd, pgrp);
     420# endif
     421#else
     422#endif
    218423}
    219424
    220425int sh_getrlimit(shinstance *psh, int resid, shrlimit *limp)
    221426{
    222     return -1;
     427#ifdef SH_PURE_STUB_MODE
     428    return -1;
     429#elif defined(SH_STUB_MODE)
     430# ifdef _MSC_VER
     431    return -1;
     432# else
     433    return getrlimit(resid, limp);
     434# endif
     435#else
     436#endif
    223437}
    224438
    225439int sh_setrlimit(shinstance *psh, int resid, const shrlimit *limp)
    226440{
    227     return -1;
    228 }
    229 
     441#ifdef SH_PURE_STUB_MODE
     442    return -1;
     443#elif defined(SH_STUB_MODE)
     444# ifdef _MSC_VER
     445    return -1;
     446# else
     447    return setrlimit(resid, limp);
     448# endif
     449#else
     450#endif
     451}
     452
  • trunk/src/kash/shinstance.h

    r1225 r1229  
    200200    int                 njobs;          /**< size of array */
    201201    int                 jobs_invalid;   /**< set in child */
    202 #if JOBS
    203202    int                 initialpgrp;    /**< pgrp of shell on invocation */
    204203    int                 curjob/* = -1*/;/**< current job */
    205 #endif
    206204    int                 ttyfd/* = -1*/;
    207205    int                 jobctl;         /**< job control enabled / disabled */
    208206    char               *cmdnextc;
    209207    int                 cmdnleft;
     208
    210209
    211210    /* mail.c */
     
    290289    /* var.h */
    291290    struct localvar    *localvars;
    292 #if ATTY
    293291    struct var          vatty;
    294 #endif
    295292    struct var          vifs;
    296293    struct var          vmail;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette