コード例 #1
0
ファイル: socket.c プロジェクト: jmckaskill/adbus
static adbus_Bool EnvironmentString(adbus_Bool connect, adbus_BusType type, char* buf, size_t sz)
{
    UNUSED(connect);
    if (type == ADBUS_DEFAULT_BUS) {
        return CopyEnv("DBUS_STARTER_ADDRESS", buf, sz)
            || CopyEnv("DBUS_SESSION_BUS_ADDRESS", buf, sz)
#ifdef _WIN32
            || (connect && CopySharedMem(L"Local\\DBUS_SESSION_BUS_ADDRESS", buf, sz))
#endif
            || CopyString("autostart:", buf, sz);

    } else if (type == ADBUS_SESSION_BUS) {
        return CopyEnv("DBUS_SESSION_BUS_ADDRESS", buf, sz)
#ifdef _WIN32
            || (connect && CopySharedMem(L"Local\\DBUS_SESSION_BUS_ADDRESS", buf, sz))
#endif
            || CopyString("autostart:", buf, sz);

    } else if (type == ADBUS_SYSTEM_BUS) {
        return CopyEnv("DBUS_SYSTEM_BUS_ADDRESS", buf, sz)
#ifndef _WIN32
            || CopyString("unix:file=/var/run/dbus/system_bus_socket", buf, sz)
#endif
            || CopyString("autostart:", buf, sz);

    } else {
        return 0;
    }
}
コード例 #2
0
ファイル: proctitle.c プロジェクト: ColumPaget/Alaya
//The command-line args that we've been passed (argv) will occupy a block of contiguous memory that
//contains these args and the environment strings. In order to change the command-line args we isolate
//this block of memory by iterating through all the strings in it, and making copies of them. The
//pointers in 'argv' and 'environ' are then redirected to these copies. Now we can overwrite the whole
//block of memory with our new command-line arguments.
void ProcessTitleCaptureBuffer(char **argv)
{
char **arg, *end=NULL, *tmp;

#ifdef __GNU_LIBRARY__
extern char *program_invocation_name;
extern char *program_invocation_short_name;

program_invocation_name=strdup(program_invocation_name);
program_invocation_short_name=strdup(program_invocation_short_name);
#endif

TitleBuffer=argv[0];
arg=argv;
while (*arg)
{
for (end=*arg; *end != '\0'; end++) ;
*arg=strdup(*arg);
arg++;
}

arg=environ;
//clearenv();  //clearenv is not portable
environ[0]=NULL;
while (*arg)
{
	for (end=*arg; *end != '\0'; end++);
	CopyEnv(*arg);
	arg++;
}

TitleLen=end-TitleBuffer;
}
コード例 #3
0
ファイル: trpld.c プロジェクト: ArmstrongJ/open-watcom-v2
char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver )
{
    FILE                *fp;
    trap_file_header    __far *head;
    char                filename[256];
    char                *p;
    char                chr;

    if( parms == NULL || *parms == '\0' )
        parms = DEFAULT_TRP_NAME;
    p = filename;
    for( ; (chr = *parms) != '\0'; parms++ ) {
        if( chr == TRAP_PARM_SEPARATOR ) {
            parms++;
            break;
        }
        *p++ = chr;
    }
#ifdef USE_FILENAME_VERSION
    *p++ = ( USE_FILENAME_VERSION / 10 ) + '0';
    *p++ = ( USE_FILENAME_VERSION % 10 ) + '0';
#endif
    *p = '\0';
    fp = DIGLoader( Open )( filename, p - filename, DEFAULT_TRP_EXT, NULL, 0 );
    if( fp == NULL ) {
        sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename );
        return( buff );
    }
    p = ReadInTrap( fp );
    DIGLoader( Close )( fp );
    sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename );
    if( p == NULL ) {
        if( (p = SetTrapHandler()) != NULL || (p = CopyEnv()) != NULL ) {
            strcpy( buff, p );
        } else {
            strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
            head = EXTENDER_RM2PM( TrapMem.rm, 0 );
            if( head->sig == TRAP_SIGNATURE ) {
                PMData->initfunc.s.offset = head->init;
                PMData->reqfunc.s.offset  = head->req;
                PMData->finifunc.s.offset = head->fini;
                PMData->initfunc.s.segment = TrapMem.rm;
                PMData->reqfunc.s.segment  = TrapMem.rm;
                PMData->finifunc.s.segment = TrapMem.rm;
                if( CallTrapInit( parms, buff, trap_ver ) ) {
                    if( TrapVersionOK( *trap_ver ) ) {
                        TrapVer = *trap_ver;
                        ReqFunc = DoTrapAccess;
                        return( NULL );
                    }
                    strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
                }
            }
        }
    }
    KillTrap();
    return( buff );
}
コード例 #4
0
char *LoadTrap( char *trapbuff, char *buff, trap_version *trap_ver )
{
    char                *err;
    char                *parm;
    char                *end;
    dig_fhandle         dh;
    trap_file_header    __far *head;


    if( trapbuff == NULL ) {
        trapbuff = DEFAULT_TRP_NAME;
    }
    end = strchr( trapbuff, PARM_SEPARATOR );
    if( end == NULL ) {
        end = &trapbuff[strlen( trapbuff )];
        parm = end;
    } else {
        parm = end + 1;
    }
    dh = DIGPathOpen( trapbuff, end - trapbuff, DEFAULT_TRP_EXT, NULL, 0 );
    if( dh == DIG_NIL_HANDLE ) {
        sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trapbuff );
        return( buff );
    }
    err = ReadInTrap( DIGGetSystemHandle( dh ) );
    DIGPathClose( dh );
    sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trapbuff );
    if( err == NULL ) {
        if( (err = SetTrapHandler()) != NULL || (err = CopyEnv()) != NULL ) {
            strcpy( buff, err );
        } else {
            strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
            head = MK_PM( TrapMem.segm.rm, 0 );
            if( head->sig == TRAP_SIGNATURE ) {
                PMData->initfunc.s.offset = head->init;
                PMData->reqfunc.s.offset  = head->req;
                PMData->finifunc.s.offset = head->fini;
                PMData->initfunc.s.segment = TrapMem.segm.rm;
                PMData->reqfunc.s.segment  = TrapMem.segm.rm;
                PMData->finifunc.s.segment = TrapMem.segm.rm;
                if( CallTrapInit( parm, buff, trap_ver ) ) {
                    if( TrapVersionOK( *trap_ver ) ) {
                        TrapVer = *trap_ver;
                        ReqFunc = DoTrapAccess;
                        return( NULL );
                    }
                    strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
                }
            }
        }
    }
    KillTrap();
    return( buff );
}
コード例 #5
0
ファイル: trplddsx.c プロジェクト: MikeyG/open-watcom-v2
char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver )
{
    char                *err;
    const char          *end;
    dig_fhandle         dh;
    trap_file_header    __far *head;


    if( parms == NULL || *parms == '\0' ) {
        parms = DEFAULT_TRP_NAME;
    }
    for( end = parms; *end != '\0' && *end != TRAP_PARM_SEPARATOR; ++end )
        ;
    dh = DIGPathOpen( parms, end - parms, DEFAULT_TRP_EXT, NULL, 0 );
    if( dh == DIG_NIL_HANDLE ) {
        sprintf( buff, TC_ERR_CANT_LOAD_TRAP, parms );
        return( buff );
    }
    err = ReadInTrap( DIGGetSystemHandle( dh ) );
    DIGPathClose( dh );
    sprintf( buff, TC_ERR_CANT_LOAD_TRAP, parms );
    if( err == NULL ) {
        if( (err = SetTrapHandler()) != NULL || (err = CopyEnv()) != NULL ) {
            strcpy( buff, err );
        } else {
            strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
            head = MK_PM( TrapMem.segm.rm, 0 );
            if( head->sig == TRAP_SIGNATURE ) {
                PMData->initfunc.s.offset = head->init;
                PMData->reqfunc.s.offset  = head->req;
                PMData->finifunc.s.offset = head->fini;
                PMData->initfunc.s.segment = TrapMem.segm.rm;
                PMData->reqfunc.s.segment  = TrapMem.segm.rm;
                PMData->finifunc.s.segment = TrapMem.segm.rm;
                parms = end;
                if( *parms != '\0' )
                    ++parms;
                if( CallTrapInit( parms, buff, trap_ver ) ) {
                    if( TrapVersionOK( *trap_ver ) ) {
                        TrapVer = *trap_ver;
                        ReqFunc = DoTrapAccess;
                        return( NULL );
                    }
                    strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
                }
            }
        }
    }
    KillTrap();
    return( buff );
}
コード例 #6
0
ファイル: trpld.c プロジェクト: Azarien/open-watcom-v2
char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver )
{
    char                *err;
    const char          *ptr;
    dig_ldhandle        ldfh;
    trap_file_header    __far *head;
#ifdef USE_FILENAME_VERSION
    char                filename[256];
    char                *p;
#endif

    if( parms == NULL || *parms == '\0' ) {
        parms = DEFAULT_TRP_NAME;
    }
#ifdef USE_FILENAME_VERSION
    for( ptr = parms, p = filename; *ptr != '\0' && *ptr != TRAP_PARM_SEPARATOR; ++ptr ) {
        *p++ = *ptr;
    }
    *p++ = ( USE_FILENAME_VERSION / 10 ) + '0';
    *p++ = ( USE_FILENAME_VERSION % 10 ) + '0';
    *p = '\0';
    ldfh = DIGLoader( Open )( filename, p - filename, DEFAULT_TRP_EXT, NULL, 0 );
#else
    for( ptr = parms; *ptr != '\0' && *ptr != TRAP_PARM_SEPARATOR; ++ptr ) {
        ;
    }
    ldfh = DIGLoader( Open )( parms, ptr - parms, DEFAULT_TRP_EXT, NULL, 0 );
#endif
    if( ldfh == DIGLD_NIL_HANDLE ) {
        sprintf( buff, TC_ERR_CANT_LOAD_TRAP, parms );
        return( buff );
    }
    err = ReadInTrap( ldfh );
    DIGLoader( Close )( ldfh );
    sprintf( buff, TC_ERR_CANT_LOAD_TRAP, parms );
    if( err == NULL ) {
        if( (err = SetTrapHandler()) != NULL || (err = CopyEnv()) != NULL ) {
            strcpy( buff, err );
        } else {
            strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
            head = MK_PM( TrapMem.segm.rm, 0 );
            if( head->sig == TRAP_SIGNATURE ) {
                PMData->initfunc.s.offset = head->init;
                PMData->reqfunc.s.offset  = head->req;
                PMData->finifunc.s.offset = head->fini;
                PMData->initfunc.s.segment = TrapMem.segm.rm;
                PMData->reqfunc.s.segment  = TrapMem.segm.rm;
                PMData->finifunc.s.segment = TrapMem.segm.rm;
                parms = ptr;
                if( *parms != '\0' )
                    ++parms;
                if( CallTrapInit( parms, buff, trap_ver ) ) {
                    if( TrapVersionOK( *trap_ver ) ) {
                        TrapVer = *trap_ver;
                        ReqFunc = DoTrapAccess;
                        return( NULL );
                    }
                    strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
                }
            }
        }
    }
    KillTrap();
    return( buff );
}
コード例 #7
0
char *LoadTrap( char *trapbuff, char *buff, trap_version *trap_ver )
{
    char                *err;
    char                *parm;
    char                *end;
    handle              dh;
    trap_file_header    __far *head;
    char                init_error[256];


    if( trapbuff == NULL ) {
        trapbuff = DEFAULT_TRP_NAME;
    }
    end = strchr( trapbuff, PARM_SEPARATOR );
    if( end == NULL ) {
        end = &trapbuff[ strlen( trapbuff ) ];
        parm = end;
    } else {
        parm = end + 1;
    }
    dh = PathOpen( trapbuff, end - trapbuff, DEFAULT_TRP_EXT );
    if( dh == NIL_HANDLE ) {
        sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trapbuff );
        return( buff );
    }
    err = ReadInTrap( GetSystemHandle( dh ) );
    FileClose( dh );
    if( err != NULL ) {
        sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trapbuff );
        KillTrap();
        return( buff );
    }
    err = SetTrapHandler();
    if( err != NULL ) {
        KillTrap();
        return( err );
    }
    err = CopyEnv();
    if( err != NULL ) {
        KillTrap();
        return( err );
    }
    head = MK_PM( TrapMem.s.rm, 0 );
    if( head->sig != TRAP_SIGNATURE ) {
        KillTrap();
        strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
        return( buff );
    }
    PMData->initfunc.s.offset = head->init;
    PMData->reqfunc.s.offset  = head->req;
    PMData->finifunc.s.offset = head->fini;
    PMData->initfunc.s.segment = TrapMem.s.rm;
    PMData->reqfunc.s.segment  = TrapMem.s.rm;
    PMData->finifunc.s.segment = TrapMem.s.rm;
    if( !CallTrapInit( parm, init_error, trap_ver ) ) {
        KillTrap();
        strcpy( buff, init_error );
        return( buff );
    }
    if( !TrapVersionOK( *trap_ver ) ) {
        KillTrap();
        strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
        return( buff );
    }
    TrapVer = *trap_ver;
    ReqFunc = DoTrapAccess;
    return( NULL );
}