now as well.
Also, both functions will now test if the executable exists and is valid; that
way, load_image()/exec*() can catch many errors without having to create a new
team (or erase the current one - an exec*("my invalid app") might now return
with an error).
The runtime linker now exports a function to test executables that is aware
of the search paths, and will also check user permissions upfront.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13113 a95241bf-73f2-0310-859d-f6bbb57e9c96
51 lines
970 B
C
51 lines
970 B
C
/*
|
|
* Copyright 2005, Axel Dörfler, [email protected].
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
|
* Distributed under the terms of the NewOS License.
|
|
*/
|
|
|
|
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <syscalls.h>
|
|
|
|
#include "rld_priv.h"
|
|
|
|
|
|
char *
|
|
getenv(const char *name)
|
|
{
|
|
// ToDo: this should use the real environ pointer once available!
|
|
// (or else, any updates to the search paths while the app is running are ignored)
|
|
char **environ = gProgramArgs->envp;
|
|
int32 length = strlen(name);
|
|
int32 i;
|
|
|
|
for (i = 0; environ[i] != NULL; i++) {
|
|
if (!strncmp(name, environ[i], length) && environ[i][length] == '=')
|
|
return environ[i] + length + 1;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
int
|
|
printf(const char *fmt, ...)
|
|
{
|
|
va_list args;
|
|
char buf[1024];
|
|
int i;
|
|
|
|
va_start(args, fmt);
|
|
i = vsprintf(buf, fmt, args);
|
|
va_end(args);
|
|
|
|
_kern_write(2, 0, buf, strlen(buf));
|
|
|
|
return i;
|
|
}
|