From 4bd8e1a084ab88f7a090523983f3a7a199bcb8bd Mon Sep 17 00:00:00 2001 From: maxcodehack Date: Wed, 3 Mar 2021 19:45:47 +0000 Subject: [PATCH] [klibc] Add mkexp tool git-svn-id: svn://kolibrios.org@8631 a494cfbc-eb01-0410-851d-a64ba20cac60 --- contrib/kolibri-libc/linuxtools/mkexp.c | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 contrib/kolibri-libc/linuxtools/mkexp.c diff --git a/contrib/kolibri-libc/linuxtools/mkexp.c b/contrib/kolibri-libc/linuxtools/mkexp.c new file mode 100755 index 0000000000..59906f09f8 --- /dev/null +++ b/contrib/kolibri-libc/linuxtools/mkexp.c @@ -0,0 +1,51 @@ +// MKEXP +// Copyright (C) maxcodehack, 2021 + +#include +#include + +int main(int argc, char** argv) { + if (argc != 3) { + printf("usage: %s [symbols.txt exports.c]\n", argv[0]); + return 0; + } + FILE *input, *output; + if ((input = fopen(argv[1], "r")) == NULL) + { + printf("error: file \"%s\" not found\n", argv[1]); + return 0; + } + char buf[10000]; + + // Head + strcpy(buf, \ + "#include \n" \ + "#include \n" \ + "#include \n" \ + "#include \n" \ + "#include \n" \ + "#include \n" \ + "#include \n\n" \ + "ksys_coff_etable_t EXPORTS[] = {\n"); + + // Generate + char symbol[256]; + while(fscanf(input, "%s", symbol) != EOF) { + strcat(buf, "\t{"); + strcat(buf, symbol); + strcat(buf, ", \""); + strcat(buf, symbol); + strcat(buf, "\"},\n"); + } + strcat(buf, "\t0\n};"); + fclose(input); + + // Output generated + output = fopen(argv[2], "w"); + fputs(buf, output); + fclose(output); + + printf("Done, check %s!\n", argv[2]); + + return 0; +}