ensure that dependencies are rebuilt after 'make update' so that builds don't break...
[asterisk/asterisk.git] / cygwin / cygloader.c
1 #include <unistd.h>
2 #include <dlfcn.h>
3 #include <stdio.h>
4
5 #define OK                                      0
6 #define MODULE_NOT_FOUND                        1
7 #define INVALID_NUMBER_ARGUMENTS        2
8
9 int main(int argc, char **argv) {
10         /* Asterisk entry point */
11         char* error = NULL;
12         int (*ast_main)(int argc, char **argv);
13
14         void *handle = dlopen ("asterisk.dll", RTLD_GLOBAL);
15         if (handle == NULL) {
16                 fputs (dlerror(), stderr);
17                 fputs ("\r\n", stderr);
18                 return MODULE_NOT_FOUND;
19         }
20         printf("\r\nAsterisk module loaded successfully");
21         ast_main = dlsym(handle, "main");
22                 if ((error = dlerror()) != NULL) {
23                         fputs("Asterisk main not found", stderr);
24                         fputs(error, stderr);
25                         exit(1);
26                 }
27         printf("\r\nAsterisk entry point found");
28         /* run asterisk main */
29         (*ast_main)(argc, argv);
30         dlclose(handle);
31         printf("\r\nAsterisk stopped");
32         return OK;
33 }