2025-03-20 04:16:06 +01:00
|
|
|
Written by retoor@molodetz.nl
|
|
|
|
|
|
|
|
This code provides an entry point for a library with command-line utilities. It forwards arguments to the corresponding tool based on the user's input.
|
|
|
|
|
|
|
|
Includes used:
|
|
|
|
- rhttp.h: Provides functionality for an HTTP file server.
|
|
|
|
- rmerge.h: Includes a tool for merging C source files.
|
|
|
|
- rcov.h: Implements a code coverage tool based on lcov.
|
|
|
|
- rcase.h: Contains a utility to convert file naming conventions between camel case and snake case.
|
|
|
|
|
|
|
|
MIT License
|
|
|
|
|
2025-01-14 18:53:15 +01:00
|
|
|
#ifndef RLIB_MAIN
|
|
|
|
#define RLIB_MAIN
|
|
|
|
#include "rhttp.h"
|
|
|
|
#include "rmerge.h"
|
|
|
|
#include "rcov.h"
|
|
|
|
#include "rcase.h"
|
|
|
|
|
|
|
|
void forward_argument(int *argcc, char *argv[]) {
|
|
|
|
int argc = *argcc;
|
|
|
|
for (int i = 0; i < argc; i++) {
|
|
|
|
argv[i] = argv[i + 1];
|
|
|
|
}
|
2025-03-20 04:16:06 +01:00
|
|
|
(*argcc)--;
|
2025-01-14 18:53:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int rlib_main(int argc, char *argv[]) {
|
|
|
|
if (argc == 1) {
|
|
|
|
printf("rlib\n\n");
|
|
|
|
printf("options:\n");
|
2025-03-20 04:16:06 +01:00
|
|
|
printf(" httpd - a HTTP file server. Accepts port as argument.\n");
|
|
|
|
printf(" rmerge - a merge tool. Converts C source files to one file \n"
|
2025-01-14 18:53:15 +01:00
|
|
|
" with local includes by giving main file as argument.\n");
|
2025-03-20 04:16:06 +01:00
|
|
|
printf(" rcov - coverage tool that cleans up after itself. Based on "
|
2025-01-14 18:53:15 +01:00
|
|
|
"lcov.\n");
|
|
|
|
printf(" rcase - tool to swap input file automatically between"
|
|
|
|
" camel case and snake case.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
forward_argument(&argc, argv);
|
|
|
|
|
|
|
|
if (!strcmp(argv[0], "httpd")) {
|
|
|
|
return rhttp_main(argc, argv);
|
|
|
|
}
|
|
|
|
if (!strcmp(argv[0], "rmerge")) {
|
|
|
|
return rmerge_main(argc, argv);
|
|
|
|
}
|
|
|
|
if (!strcmp(argv[0], "rcov")) {
|
|
|
|
return rcov_main(argc, argv);
|
|
|
|
}
|
|
|
|
if (!strcmp(argv[0], "rcase")) {
|
|
|
|
return rcase_main(argc, argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2025-03-20 04:16:06 +01:00
|
|
|
#endif
|