mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 16:55:09 +00:00

I ran out of steam writing library routines and imported two BSD-licensed libc routines: sscanf() and getopt(). I will most likely rewrite them sooner or later. For now I just wanted to see figlet running.
50 lines
975 B
C++
50 lines
975 B
C++
#include <stdio.h>
|
|
#include <Kernel/Syscall.h>
|
|
#include <AK/StringImpl.h>
|
|
|
|
extern "C" int main(int, char**);
|
|
|
|
FILE __default_streams[3];
|
|
|
|
int errno;
|
|
FILE* stdin;
|
|
FILE* stdout;
|
|
FILE* stderr;
|
|
char** environ;
|
|
|
|
extern "C" void __malloc_init();
|
|
|
|
extern "C" int _start()
|
|
{
|
|
__malloc_init();
|
|
|
|
errno = 0;
|
|
|
|
__default_streams[0].fd = 0;
|
|
stdin = &__default_streams[0];
|
|
|
|
__default_streams[1].fd = 1;
|
|
stdout = &__default_streams[1];
|
|
|
|
__default_streams[2].fd = 2;
|
|
stderr = &__default_streams[2];
|
|
|
|
StringImpl::initializeGlobals();
|
|
|
|
int status = 254;
|
|
int argc;
|
|
char** argv;
|
|
int rc = Syscall::invoke(Syscall::GetArguments, (dword)&argc, (dword)&argv);
|
|
if (rc < 0)
|
|
goto epilogue;
|
|
rc = Syscall::invoke(Syscall::GetEnvironment, (dword)&environ);
|
|
if (rc < 0)
|
|
goto epilogue;
|
|
status = main(argc, argv);
|
|
|
|
epilogue:
|
|
Syscall::invoke(Syscall::PosixExit, status);
|
|
|
|
// Birger's birthday <3
|
|
return 20150614;
|
|
}
|