diff options
Diffstat (limited to 'cygwin')
-rwxr-xr-x | cygwin/Makefile | 6 | ||||
-rwxr-xr-x | cygwin/cygloader.c | 33 |
2 files changed, 39 insertions, 0 deletions
diff --git a/cygwin/Makefile b/cygwin/Makefile new file mode 100755 index 000000000..124628f9c --- /dev/null +++ b/cygwin/Makefile @@ -0,0 +1,6 @@ +OBJS=cygloader.o +all: $(OBJS) +$(OBJS) : %.o: %.c + $(CC) $< -o asterisk.exe +clean: + rm -f asterisk.exe diff --git a/cygwin/cygloader.c b/cygwin/cygloader.c new file mode 100755 index 000000000..0d48c0f6c --- /dev/null +++ b/cygwin/cygloader.c @@ -0,0 +1,33 @@ +#include <unistd.h> +#include <dlfcn.h> +#include <stdio.h> + +#define OK 0 +#define MODULE_NOT_FOUND 1 +#define INVALID_NUMBER_ARGUMENTS 2 + +int main(int argc, char **argv) { + /* Asterisk entry point */ + char* error = NULL; + int (*ast_main)(int argc, char **argv); + + void *handle = dlopen ("asterisk.dll", RTLD_GLOBAL); + if (handle == NULL) { + fputs (dlerror(), stderr); + fputs ("\r\n", stderr); + return MODULE_NOT_FOUND; + } + printf("\r\nAsterisk module loaded successfully"); + ast_main = dlsym(handle, "main"); + if ((error = dlerror()) != NULL) { + fputs("Asterisk main not found", stderr); + fputs(error, stderr); + exit(1); + } + printf("\r\nAsterisk entry point found"); + /* run asterisk main */ + (*ast_main)(argc, argv); + dlclose(handle); + printf("\r\nAsterisk stopped"); + return OK; +} |