int main_ztv_webui_init(int argc, char *argv[]) { if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'A') { if (argc != 6) show_usage_and_exit(); exit(mg_edit_passwords(argv[2], argv[3], argv[4],argv[5])); } if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) show_usage_and_exit(); #ifndef _WIN32 (void) signal(SIGCHLD, signal_handler); #endif /* _WIN32 */ (void) signal(SIGTERM, signal_handler); (void) signal(SIGINT, signal_handler); if ((ctx = mg_start()) == NULL) { (void) printf("%s\n", "Cannot initialize Mongoose context"); exit(EXIT_FAILURE); } process_command_line_arguments(ctx, argv); if (mg_get_option(ctx, "ports") == NULL && mg_set_option(ctx, "ports", "8080") != 1) exit(EXIT_FAILURE); printf("Mongoose %s started on port(s) [%s], serving directory [%s]\n", mg_version(), mg_get_option(ctx, "ports"), mg_get_option(ctx, "root")); mg_set_uri_callback(ctx, "/login", &login_page, NULL); mg_set_uri_callback(ctx, "/ztv", &ztv_page, NULL); mg_set_uri_callback(ctx, "/share.apk", &share_pkg,NULL); mg_set_uri_callback(ctx, "/shs", &shs_page, NULL); mg_set_uri_callback(ctx, "/about", &shs_page, NULL); mg_set_uri_callback(ctx, "/uploadfile", &upload_page, NULL); mg_set_uri_callback(ctx, "/upload.html", &upload_input_page, NULL); mg_set_uri_callback(ctx, "/upload.htm", &upload_input_page, NULL); mg_set_uri_callback(ctx, "/r.html", &rili_page, NULL); mg_set_uri_callback(ctx, "/r.manifest", &r_manifest_page, NULL); mg_set_uri_callback(ctx, "/http302Jobs.mp4", &http302Jobs_mp4_page, NULL); mg_set_uri_callback(ctx, "/bbs.html", &bbs_input_page, NULL); mg_set_uri_callback(ctx, "/bbs", &bbs_page, NULL); fflush(stdout); /* while (exit_flag == 0) sleep(1); (void) printf("Exiting on signal %d, " "waiting for all threads to finish...", exit_flag); fflush(stdout); mg_stop(ctx); (void) printf("%s", " done.\n"); */ return (EXIT_SUCCESS); }
int mongoosed_main(int argc, char *argv[]) { char dflt_port[5] = "80"; #if !defined(NO_AUTH) if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'A') { if (argc != 6) show_usage_and_exit(argv[0]); exit(mg_edit_passwords(argv[2], argv[3], argv[4],argv[5])); } #endif /* NO_AUTH */ if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) show_usage_and_exit(argv[0]); #if defined(_WIN32) (void) sprintf(service_name, "Mongoose %s", mg_version()); try_to_run_as_nt_service(); #endif /* _WIN32 */ #ifndef _WIN32 (void) signal(SIGCHLD, signal_handler); #endif /* _WIN32 */ (void) signal(SIGTERM, signal_handler); (void) signal(SIGINT, signal_handler); if ((ctx = mg_start()) == NULL) { (void) printf("%s\n", "Cannot initialize Mongoose context"); exit(EXIT_FAILURE); } process_command_line_arguments(ctx, argv); if (mg_get_option(ctx, "ports") == NULL && mg_set_option(ctx, "ports", dflt_port /*"8080"*/) != 1) exit(EXIT_FAILURE); printf("Mongoose %s started on port(s) [%s], serving directory [%s]\n", mg_version(), mg_get_option(ctx, "ports"), mg_get_option(ctx, "root")); fflush(stdout); while (exit_flag == 0) sleep(1); (void) printf("Exiting on signal %d, " "waiting for all threads to finish...", exit_flag); fflush(stdout); mg_stop(ctx); (void) printf("%s", " done.\n"); return (EXIT_SUCCESS); }
static void start_mongoose(int argc, char *argv[]) { char *options[MAX_OPTIONS]; int i; /* Edit passwords file if -A option is specified */ if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'A') { if (argc != 6) { show_usage_and_exit(); } exit(mg_edit_passwords(argv[2], argv[3], argv[4], argv[5]) ? EXIT_SUCCESS : EXIT_FAILURE); } /* Show usage if -h or --help options are specified */ if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) { show_usage_and_exit(); } /* Update config based on command line arguments */ process_command_line_arguments(argv, options); /* Setup signal handler: quit on Ctrl-C */ signal(SIGTERM, signal_handler); signal(SIGINT, signal_handler); /* Start Mongoose */ ctx = mg_start(NULL, NULL, (const char **) options); for (i = 0; options[i] != NULL; i++) { free(options[i]); } if (ctx == NULL) { die("%s", "Failed to start Mongoose. Maybe some options are " "assigned bad values?\nTry to run with '-e error_log.txt' " "and check error_log.txt for more information."); } }