Changeset 927 for trunk/src


Ignore:
Timestamp:
Jan 2, 2004, 8:17:21 PM (22 years ago)
Author:
bird
Message:

Initial porting.

Location:
trunk/src/emx/src/lib/bsd
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/bsd/gen/getprogname.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r926 r927  
    88#include "libc_private.h"
    99
     10#ifdef __EMX__
     11#define INCL_BASE
     12#define INCL_FSMACROS
     13#include <os2emx.h>
     14#include <string.h>
     15const char *__progname = NULL;
     16#endif
     17
    1018__weak_reference(_getprogname, getprogname);
     19
    1120
    1221const char *
    1322_getprogname(void)
    1423{
     24#ifdef __EMX__
     25    /*
     26     * On demand initiation.
     27     * THREADS: The assignment isn't safe.
     28     * THREADS: pib_pchcmd is pointing into environment space which in theory
     29     *          can be changed by any other thread while we're parsing it.
     30     */
     31    if (!__progname)
     32    {
     33        char *psz, *psz2;
     34        PTIB ptib;
     35        PPIB ppib;
     36        FS_VAR();
    1537
     38        FS_SAVE();
     39        DosGetInfoBlocks(&ptib, &ppib);
     40        FS_RESTORE();
     41
     42        psz = ppib->pib_pchcmd;
     43        psz2 = strlen(psz) + psz;
     44        while (psz2 >= psz)
     45        {
     46            if (*psz2 == '\\' || *psz2 == '/' || *psz2 == ':')
     47                break;
     48            psz2--;
     49        }
     50        psz2++;
     51        /* This is in the volatile env. block - dupe it. */
     52        __progname = strdup(psz2);
     53    }
     54#endif
    1655        return (__progname);
    1756}
  • trunk/src/emx/src/lib/bsd/gen/setprogname.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r926 r927  
    1010setprogname(const char *progname)
    1111{
    12         const char *p;
    13 
     12    const char *p;
     13#ifdef __EMX__
     14    p = strlen(progname) + progname;
     15    while (p >= progname)
     16    {
     17        if (*p == '\\' || *p == '/' || *p == ':')
     18        {
     19            __progname = p + 1;
     20            return;
     21        }
     22        p--;
     23    }
     24    __progname = progname;
     25    return;
     26#else
    1427        p = strrchr(progname, '/');
    1528        if (p != NULL)
     
    1730        else
    1831                __progname = progname;
     32#endif
    1933}
  • trunk/src/emx/src/lib/bsd/stdlib/getopt.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r926 r927  
    4242#include <stdlib.h>
    4343#include <string.h>
     44#include <unistd.h>
    4445#include "un-namespace.h"
    4546
     
    6162 */
    6263int
    63 getopt(nargc, nargv, ostr)
     64_STD(getopt)(nargc, nargv, ostr)
    6465        int nargc;
    6566        char * const *nargv;
Note: See TracChangeset for help on using the changeset viewer.