mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Add program_invocation_short_name(3).
This commit is contained in:
parent
b9d633108d
commit
03ab6cf26e
2 changed files with 12 additions and 0 deletions
|
@ -33,6 +33,7 @@ __BEGIN_DECLS
|
||||||
@include(errno_values.h)
|
@include(errno_values.h)
|
||||||
|
|
||||||
extern char* program_invocation_name;
|
extern char* program_invocation_name;
|
||||||
|
extern char* program_invocation_short_name;
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -28,15 +28,26 @@
|
||||||
|
|
||||||
extern "C" { char program_invocation_name_data[256] = ""; }
|
extern "C" { char program_invocation_name_data[256] = ""; }
|
||||||
extern "C" { char* program_invocation_name = program_invocation_name_data; }
|
extern "C" { char* program_invocation_name = program_invocation_name_data; }
|
||||||
|
extern "C" { char* program_invocation_short_name; }
|
||||||
|
|
||||||
extern "C" void init_error_functions();
|
extern "C" void init_error_functions();
|
||||||
extern "C" void init_stdio();
|
extern "C" void init_stdio();
|
||||||
extern "C" void init_signal();
|
extern "C" void init_signal();
|
||||||
|
|
||||||
|
static char* find_last_elem(char* str)
|
||||||
|
{
|
||||||
|
size_t len = strlen(str);
|
||||||
|
for ( size_t i = len; i; i-- )
|
||||||
|
if ( str[i-1] == '/' )
|
||||||
|
return str + i;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void initialize_standard_library(int argc, char* argv[])
|
extern "C" void initialize_standard_library(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if ( argc )
|
if ( argc )
|
||||||
strcpy(program_invocation_name, argv[0]);
|
strcpy(program_invocation_name, argv[0]);
|
||||||
|
program_invocation_short_name = find_last_elem(program_invocation_name);
|
||||||
|
|
||||||
// Initialize stuff such as errno.
|
// Initialize stuff such as errno.
|
||||||
init_error_functions();
|
init_error_functions();
|
||||||
|
|
Loading…
Reference in a new issue