reshuffle first.c use

This commit is contained in:
Viktor Szakats 2024-09-09 11:50:00 +02:00
parent a695a2141c
commit fbb12eb612
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
6 changed files with 19 additions and 12 deletions

View File

@ -103,12 +103,12 @@ foreach my $src (@src) {
print "\n";
$tlist .= " { \"$nams\", main_$nams },\n";
$tlist .= " {\"$nams\", main_$nams},\n";
}
print <<FOOTER
static const struct onemain s_mains[] = {
$tlist};
#include "first.c"
const struct onemain p_mains[] = {
${tlist} {NULL, NULL}
};
FOOTER
;

View File

@ -22,7 +22,7 @@
#
###########################################################################
# Get 'SERVERPROGS', '<target>_SOURCES' variables, 'CURLX_SRCS', 'USEFUL', 'UTIL'
# Get 'SERVERPROGS', '<target>_SOURCES' variables, 'CURLX_SRCS', 'USEFUL', 'UTIL', 'UTIL_BUNDLE'
curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
@ -39,7 +39,7 @@ if(CURL_TEST_BUNDLES)
set(SERVERPROGS "servers")
set(servers_SOURCES "server_bundle.c")
list(APPEND servers_SOURCES ${CURLX_SRCS} ${USEFUL} ${UTIL})
list(APPEND servers_SOURCES ${CURLX_SRCS} ${USEFUL} ${UTIL} ${UTIL_BUNDLE})
endif()
foreach(_target IN LISTS SERVERPROGS)

View File

@ -51,15 +51,15 @@ endif
# Makefile.inc provides neat definitions
include Makefile.inc
EXTRA_DIST = base64.pl CMakeLists.txt .checksrc first.c first.h
EXTRA_DIST = base64.pl CMakeLists.txt .checksrc
if USE_TEST_BUNDLES
server_bundle.c: $(top_srcdir)/tests/mk-bundle-server.pl
server_bundle.c: $(top_srcdir)/tests/mk-bundle-server.pl $(CURLX_SRCS) $(USEFUL) $(UTIL) $(UTIL_BUNDLE)
@PERL@ $(top_srcdir)/tests/mk-bundle-server.pl $(SERVERPROGS) > server_bundle.c
noinst_PROGRAMS = servers
nodist_servers_SOURCES = server_bundle.c
servers_SOURCES = $(CURLX_SRCS) $(USEFUL) $(UTIL)
servers_SOURCES = $(CURLX_SRCS) $(USEFUL) $(UTIL) $(UTIL_BUNDLE)
CLEANFILES = server_bundle.c
else
noinst_PROGRAMS = $(SERVERPROGS)

View File

@ -67,6 +67,10 @@ UTIL = \
../../lib/strerror.c \
../../lib/strerror.h
UTIL_BUNDLE = \
first.c \
first.h
resolve_SOURCES = $(CURLX_SRCS) $(CURLX_HDRS) $(USEFUL) $(UTIL) \
resolve.c
resolve_LDADD = @CURL_NETWORK_AND_TIME_LIBS@

View File

@ -22,6 +22,7 @@
*
***************************************************************************/
#include <stdio.h>
#include <string.h>
#include "first.h"
int main(int argc, char **argv)
@ -38,9 +39,9 @@ int main(int argc, char **argv)
main_func = NULL;
{
size_t tmp;
for(tmp = 0; tmp < (sizeof(s_mains)/sizeof((s_mains)[0])); ++tmp) {
if(strcmp(main_name, s_mains[tmp].name) == 0) {
main_func = s_mains[tmp].ptr;
for(tmp = 0; p_mains[tmp].ptr; ++tmp) {
if(strcmp(main_name, p_mains[tmp].name) == 0) {
main_func = p_mains[tmp].ptr;
break;
}
}

View File

@ -30,4 +30,6 @@ struct onemain {
main_func_t ptr;
};
extern const struct onemain p_mains[];
#endif /* HEADER_SERVER_FIRST_H */