Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
main.c File Reference
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "civetweb.h"
#include <sys/utsname.h>
#include <sys/wait.h>
#include <unistd.h>

Go to the source code of this file.

Data Structures

struct  tuser_data
 

Macros

#define _XOPEN_SOURCE   600 /* For PATH_MAX on linux */
 
#define IGNORE_UNUSED_RESULT(a)   ((void)((a) && 1))
 
#define NO_RETURN
 
#define _LARGEFILE_SOURCE   /* For fseeko(), ftello() */
 
#define _FILE_OFFSET_BITS   64 /* Use 64-bit file offsets by default */
 
#define __STDC_FORMAT_MACROS   /* <inttypes.h> wants this for C++ */
 
#define __STDC_LIMIT_MACROS   /* C++ wants that for INT64_MAX */
 
#define printf    DO_NOT_USE_THIS_FUNCTION__USE_fprintf /* Required for unit testing */
 
#define DIRSEP   '/'
 
#define WINCDECL
 
#define abs_path(rel, abs, abs_size)   (realpath((rel), (abs)))
 
#define DEBUG_ASSERT(cond)
 
#define PATH_MAX   (1024)
 
#define MAX_OPTIONS   (100) /* TODO: Read from civetweb.c ? */
 
#define MAX_CONF_FILE_LINE_SIZE   (8 * 1024)
 
#define CONFIG_FILE   "civetweb.conf"
 
#define PASSWORDS_FILE_NAME   ".htpasswd"
 

Enumerations

enum  {
  OPTION_TITLE , OPTION_ICON , OPTION_WEBPAGE , OPTION_ADD_DOMAIN ,
  OPTION_HIDE_TRAY , NUM_MAIN_OPTIONS
}
 

Functions

static void WINCDECL signal_handler (int sig_num)
 
static NO_RETURN void die (const char *fmt,...)
 
static void warn (const char *fmt,...)
 
static void show_server_name (void)
 
static NO_RETURN void show_usage_and_exit (const char *exeName)
 
static char * sdup (const char *str)
 
static const char * get_option (const char **options, const char *option_name)
 
static int set_option (const char **options, const char *name, const char *value)
 
static int read_config_file (const char *config_file, const char **options)
 
static void process_command_line_arguments (int argc, char *argv[], const char **options)
 
static void init_system_info (void)
 
static void init_server_name (void)
 
static void free_system_info (void)
 
static int is_path_absolute (const char *path)
 
static int verify_existence (const char **options, const char *option_name, int must_be_dir)
 
static void set_absolute_path (const char *options[], const char *option_name, const char *path_to_civetweb_exe)
 
static int run_client (const char *url_arg)
 
static int sanitize_options (const char *options[], const char *arg0)
 
static void start_civetweb (int argc, char *argv[])
 
static void stop_civetweb (void)
 
int main (int argc, char *argv[])
 

Variables

volatile int g_exit_flag = 0
 
static char g_server_base_name [40]
 
static const char * g_server_name
 
static const char * g_icon_name
 
static const char * g_website
 
static int g_num_add_domains
 
static const char ** g_add_domain
 
static int g_hide_tray = 0
 
static char * g_system_info
 
static char g_config_file_name [PATH_MAX]
 
static struct mg_contextg_ctx
 
static struct tuser_data g_user_data
 
static struct mg_option main_config_options []
 

Macro Definition Documentation

◆ __STDC_FORMAT_MACROS

#define __STDC_FORMAT_MACROS   /* <inttypes.h> wants this for C++ */

Definition at line 78 of file vendor/civetweb/main.c.

◆ __STDC_LIMIT_MACROS

#define __STDC_LIMIT_MACROS   /* C++ wants that for INT64_MAX */

Definition at line 81 of file vendor/civetweb/main.c.

◆ _FILE_OFFSET_BITS

#define _FILE_OFFSET_BITS   64 /* Use 64-bit file offsets by default */

Definition at line 75 of file vendor/civetweb/main.c.

◆ _LARGEFILE_SOURCE

#define _LARGEFILE_SOURCE   /* For fseeko(), ftello() */

Definition at line 72 of file vendor/civetweb/main.c.

◆ _XOPEN_SOURCE

#define _XOPEN_SOURCE   600 /* For PATH_MAX on linux */

Definition at line 45 of file vendor/civetweb/main.c.

◆ abs_path

#define abs_path ( rel,
abs,
abs_size )   (realpath((rel), (abs)))

Definition at line 146 of file vendor/civetweb/main.c.

Referenced by set_absolute_path().

◆ CONFIG_FILE

#define CONFIG_FILE   "civetweb.conf"

Definition at line 212 of file vendor/civetweb/main.c.

Referenced by process_command_line_arguments().

◆ DEBUG_ASSERT

#define DEBUG_ASSERT ( cond)

Definition at line 168 of file vendor/civetweb/main.c.

Referenced by init_server_name().

◆ DIRSEP

#define DIRSEP   '/'

Definition at line 144 of file vendor/civetweb/main.c.

Referenced by process_command_line_arguments(), and set_absolute_path().

◆ IGNORE_UNUSED_RESULT

#define IGNORE_UNUSED_RESULT ( a)    ((void)((a) && 1))

Definition at line 57 of file vendor/civetweb/main.c.

Referenced by set_absolute_path().

◆ MAX_CONF_FILE_LINE_SIZE

#define MAX_CONF_FILE_LINE_SIZE   (8 * 1024)

Definition at line 177 of file vendor/civetweb/main.c.

Referenced by read_config_file().

◆ MAX_OPTIONS

#define MAX_OPTIONS   (100) /* TODO: Read from civetweb.c ? */

Definition at line 176 of file vendor/civetweb/main.c.

Referenced by set_option(), and start_civetweb().

◆ NO_RETURN

#define NO_RETURN

Definition at line 67 of file vendor/civetweb/main.c.

◆ PASSWORDS_FILE_NAME

#define PASSWORDS_FILE_NAME   ".htpasswd"

Definition at line 216 of file vendor/civetweb/main.c.

◆ PATH_MAX

#define PATH_MAX   (1024)

Definition at line 173 of file vendor/civetweb/main.c.

Referenced by set_absolute_path().

◆ printf

◆ WINCDECL

#define WINCDECL

Definition at line 145 of file vendor/civetweb/main.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
OPTION_TITLE 
OPTION_ICON 
OPTION_WEBPAGE 
OPTION_ADD_DOMAIN 
OPTION_HIDE_TRAY 
NUM_MAIN_OPTIONS 

Definition at line 224 of file vendor/civetweb/main.c.

224 {
230#if defined(DAEMONIZE)
231 ENABLE_DAEMONIZE,
232#endif
233
235};
@ OPTION_WEBPAGE
@ OPTION_HIDE_TRAY
@ NUM_MAIN_OPTIONS
@ OPTION_ADD_DOMAIN

Function Documentation

◆ die()

static NO_RETURN void die ( const char * fmt,
... )
static

Definition at line 258 of file vendor/civetweb/main.c.

259{
260 va_list ap;
261 char msg[1024] = "";
262
263 va_start(ap, fmt);
264 (void)vsnprintf(msg, sizeof(msg) - 1, fmt, ap);
265 msg[sizeof(msg) - 1] = 0;
266 va_end(ap);
267
268#if defined(_WIN32)
269 MessageBox(NULL, msg, "Error", MB_ICONERROR | MB_OK);
270#else
271 fprintf(stderr, "%s\n", msg);
272#endif
273
274 exit(EXIT_FAILURE);
275}
#define NULL
Definition gmacros.h:924

References NULL.

Referenced by process_command_line_arguments(), sdup(), set_option(), and start_civetweb().

◆ free_system_info()

static void free_system_info ( void )
static

Definition at line 856 of file vendor/civetweb/main.c.

857{
859}
#define free
Definition civetweb.c:1542
static char * g_system_info

References free, and g_system_info.

Referenced by main().

◆ get_option()

static const char * get_option ( const char ** options,
const char * option_name )
static

Definition at line 471 of file vendor/civetweb/main.c.

472{
473 int i = 0;
474 const char *opt_value = NULL;
475
476 /* TODO (low, api makeover): options should be an array of key-value-pairs,
477 * like
478 * struct {const char * key, const char * value} options[]
479 * but it currently is an array with
480 * options[2*i] = key, options[2*i + 1] = value
481 * (probably with a MG_LEGACY_INTERFACE definition)
482 */
483 while (options[2 * i] != NULL) {
484 if (strcmp(options[2 * i], option_name) == 0) {
485 opt_value = options[2 * i + 1];
486 break;
487 }
488 i++;
489 }
490 return opt_value;
491}

References NULL.

Referenced by set_absolute_path(), and verify_existence().

◆ init_server_name()

static void init_server_name ( void )
static

Definition at line 838 of file vendor/civetweb/main.c.

839{
841 == NUM_MAIN_OPTIONS + 1);
842 DEBUG_ASSERT((strlen(mg_version()) + 12) < sizeof(g_server_base_name));
844 sizeof(g_server_base_name),
845 "CivetWeb V%s",
846 mg_version());
849 g_website = "http://civetweb.github.io/civetweb/";
852}
CIVETWEB_API const char * mg_version(void)
Definition civetweb.c:3514
#define snprintf
Definition civetweb.c:1543
static const char * g_server_name
static const char * g_icon_name
#define DEBUG_ASSERT(cond)
static int g_num_add_domains
static char g_server_base_name[40]
static const char ** g_add_domain
static const char * g_website
static struct mg_option main_config_options[]

References DEBUG_ASSERT, g_add_domain, g_icon_name, g_num_add_domains, g_server_base_name, g_server_name, g_website, main_config_options, mg_version(), NULL, NUM_MAIN_OPTIONS, and snprintf.

Referenced by main().

◆ init_system_info()

static void init_system_info ( void )
static

Definition at line 825 of file vendor/civetweb/main.c.

826{
827 int len = mg_get_system_info(NULL, 0);
828 if (len > 0) {
829 g_system_info = (char *)malloc((unsigned)len + 1);
830 (void)mg_get_system_info(g_system_info, len + 1);
831 } else {
832 g_system_info = sdup("Not available");
833 }
834}
#define malloc
Definition civetweb.c:1539
CIVETWEB_API int mg_get_system_info(char *buffer, int buflen)
Definition civetweb.c:21512
static char * sdup(const char *str)

References g_system_info, malloc, mg_get_system_info(), NULL, and sdup().

Referenced by main().

◆ is_path_absolute()

static int is_path_absolute ( const char * path)
static

Definition at line 863 of file vendor/civetweb/main.c.

864{
865#if defined(_WIN32)
866 return path != NULL
867 && ((path[0] == '\\' && path[1] == '\\') || /* UNC path, e.g.
868 \\server\dir */
869 (isalpha((unsigned char)path[0]) && path[1] == ':'
870 && path[2] == '\\')); /* E.g. X:\dir */
871#else
872 return path != NULL && path[0] == '/';
873#endif
874}

References NULL.

Referenced by set_absolute_path().

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 3235 of file vendor/civetweb/main.c.

3236{
3239 start_civetweb(argc, argv);
3240 fprintf(stdout,
3241 "%s started on port(s) %s with web root [%s]\n",
3243 mg_get_option(g_ctx, "listening_ports"),
3244 mg_get_option(g_ctx, "document_root"));
3245
3246 while (g_exit_flag == 0) {
3247 sleep(1);
3248 }
3249
3250 fprintf(stdout,
3251 "Exiting on signal %d, waiting for all threads to finish...",
3252 g_exit_flag);
3253 fflush(stdout);
3254 stop_civetweb();
3255 fprintf(stdout, "%s", " done.\n");
3256
3258
3259 return EXIT_SUCCESS;
3260}
#define mg_get_option
Definition civetweb.c:3185
static void free_system_info(void)
static void stop_civetweb(void)
static void start_civetweb(int argc, char *argv[])
static struct mg_context * g_ctx
volatile int g_exit_flag
static void init_server_name(void)
static void init_system_info(void)

References free_system_info(), g_ctx, g_exit_flag, g_server_name, init_server_name(), init_system_info(), mg_get_option, start_civetweb(), and stop_civetweb().

◆ process_command_line_arguments()

static void process_command_line_arguments ( int argc,
char * argv[],
const char ** options )
static

Definition at line 738 of file vendor/civetweb/main.c.

739{
740 char *p;
741 size_t i, cmd_line_opts_start = 1;
742#if defined(CONFIG_FILE2)
743 FILE *fp = NULL;
744#endif
745
746 /* Should we use a config file ? */
747 if ((argc > 1) && (argv[1] != NULL) && (argv[1][0] != '-')
748 && (argv[1][0] != 0)) {
749 /* The first command line parameter is a config file name. */
751 sizeof(g_config_file_name) - 1,
752 "%s",
753 argv[1]);
754 cmd_line_opts_start = 2;
755 } else if ((p = strrchr(argv[0], DIRSEP)) == NULL) {
756 /* No config file set. No path in arg[0] found.
757 * Use default file name in the current path. */
759 sizeof(g_config_file_name) - 1,
760 "%s",
762 } else {
763 /* No config file set. Path to exe found in arg[0].
764 * Use default file name next to the executable. */
766 sizeof(g_config_file_name) - 1,
767 "%.*s%c%s",
768 (int)(p - argv[0]),
769 argv[0],
770 DIRSEP,
772 }
773 g_config_file_name[sizeof(g_config_file_name) - 1] = 0;
774
775#if defined(CONFIG_FILE2)
776 fp = fopen(g_config_file_name, "r");
777
778 /* try alternate config file */
779 if (fp == NULL) {
780 fp = fopen(CONFIG_FILE2, "r");
781 if (fp != NULL) {
782 strcpy(g_config_file_name, CONFIG_FILE2);
783 }
784 }
785 if (fp != NULL) {
786 fclose(fp);
787 }
788#endif
789
790 /* read all configurations from a config file */
791 if (0 == read_config_file(g_config_file_name, options)) {
792 if (cmd_line_opts_start == 2) {
793 /* If config file was set in command line and open failed, die. */
794 /* Errno will still hold the error from fopen. */
795 die("Cannot open config file %s: %s",
797 strerror(errno));
798 }
799 /* Otherwise: CivetWeb can work without a config file */
800 }
801
802 /* If we're under MacOS and started by launchd, then the second
803 argument is process serial number, -psn_.....
804 In this case, don't process arguments at all. */
805 if (argv[1] == NULL || memcmp(argv[1], "-psn_", 5) != 0) {
806 /* Handle command line flags.
807 They override config file and default settings. */
808 for (i = cmd_line_opts_start; argv[i] != NULL; i += 2) {
809 if (argv[i][0] != '-' || argv[i + 1] == NULL) {
810 show_usage_and_exit(argv[0]);
811 }
812 if (!set_option(options, &argv[i][1], argv[i + 1])) {
813 fprintf(
814 stderr,
815 "command line option is invalid, ignoring it:\n %s %s\n",
816 argv[i],
817 argv[i + 1]);
818 }
819 }
820 }
821}
static NO_RETURN void die(const char *fmt,...)
static int read_config_file(const char *config_file, const char **options)
static NO_RETURN void show_usage_and_exit(const char *exeName)
#define DIRSEP
#define CONFIG_FILE
static int set_option(const char **options, const char *name, const char *value)
static char g_config_file_name[PATH_MAX]

References CONFIG_FILE, die(), DIRSEP, g_config_file_name, NULL, read_config_file(), set_option(), show_usage_and_exit(), and snprintf.

Referenced by start_civetweb().

◆ read_config_file()

static int read_config_file ( const char * config_file,
const char ** options )
static

Definition at line 666 of file vendor/civetweb/main.c.

667{
668 char line[MAX_CONF_FILE_LINE_SIZE], *p;
669 FILE *fp = NULL;
670 size_t i, j, line_no = 0;
671
672 /* Open the config file */
673 fp = fopen(config_file, "r");
674 if (fp == NULL) {
675 /* Failed to open the file. Keep errno for the caller. */
676 return 0;
677 }
678
679 /* Load config file settings first */
680 fprintf(stdout, "Loading config file %s\n", config_file);
681
682 /* Loop over the lines in config file */
683 while (fgets(line, sizeof(line), fp) != NULL) {
684
685 if (!line_no && !memcmp(line, "\xEF\xBB\xBF", 3)) {
686 /* strip UTF-8 BOM */
687 p = line + 3;
688 } else {
689 p = line;
690 }
691 line_no++;
692
693 /* Ignore empty lines and comments */
694 for (i = 0; isspace((unsigned char)p[i]);)
695 i++;
696 if (p[i] == '#' || p[i] == '\0') {
697 continue;
698 }
699
700 /* Skip spaces, \r and \n at the end of the line */
701 for (j = strlen(p); (j > 0)
702 && (isspace((unsigned char)p[j - 1])
703 || iscntrl((unsigned char)p[j - 1]));)
704 p[--j] = 0;
705
706 /* Find the space character between option name and value */
707 for (j = i; !isspace((unsigned char)p[j]) && (p[j] != 0);)
708 j++;
709
710 /* Terminate the string - then the string at (p+i) contains the
711 * option name */
712 p[j] = 0;
713 j++;
714
715 /* Trim additional spaces between option name and value - then
716 * (p+j) contains the option value */
717 while (isspace((unsigned char)p[j])) {
718 j++;
719 }
720
721 /* Set option */
722 if (!set_option(options, p + i, p + j)) {
723 fprintf(stderr,
724 "%s: line %d is invalid, ignoring it:\n %s",
725 config_file,
726 (int)line_no,
727 p);
728 }
729 }
730
731 (void)fclose(fp);
732
733 return 1;
734}
#define MAX_CONF_FILE_LINE_SIZE

References MAX_CONF_FILE_LINE_SIZE, NULL, and set_option().

Referenced by process_command_line_arguments(), and start_civetweb().

◆ run_client()

static int run_client ( const char * url_arg)
static

Definition at line 995 of file vendor/civetweb/main.c.

996{
997 /* connection data */
998 char *url = sdup(url_arg); /* OOM will cause program to exit */
999 char *host;
1000 char *resource;
1001 int is_ssl = 0;
1002 unsigned long port = 0;
1003 size_t sep;
1004 char *endp = 0;
1005 char empty[] = "";
1006
1007 /* connection object */
1008 struct mg_connection *conn;
1009 char ebuf[1024] = {0};
1010
1011#if 0 /* Unreachable code, since sdup will never return NULL */
1012 /* Check out of memory */
1013 if (!url) {
1014 fprintf(stderr, "Out of memory\n");
1015 return 0;
1016 }
1017#endif
1018
1019 /* Check parameter */
1020 if (!strncmp(url, "http://", 7)) {
1021 host = url + 7;
1022 port = 80;
1023 } else if (!strncmp(url, "https://", 8)) {
1024 host = url + 8;
1025 is_ssl = 1;
1026 port = 443;
1027 } else {
1028 fprintf(stderr, "URL must start with http:// or https://\n");
1029 free(url);
1030 return 0;
1031 }
1032 if ((host[0] <= 32) || (host[0] > 126) || (host[0] == '/')
1033 || (host[0] == ':')) {
1034 fprintf(stderr, "Invalid host\n");
1035 free(url);
1036 return 0;
1037 }
1038
1039 sep = strcspn(host, "/:");
1040 switch (host[sep]) {
1041 case 0:
1042 resource = empty;
1043 break;
1044 case '/':
1045 host[sep] = 0;
1046 resource = host + sep + 1;
1047 break;
1048 case ':':
1049 host[sep] = 0;
1050 port = strtoul(host + sep + 1, &endp, 10);
1051 if (!endp || (*endp != '/' && *endp != 0) || (port < 1)
1052 || (port > 0xFFFF)) {
1053 fprintf(stderr, "Invalid port\n");
1054 free(url);
1055 return 0;
1056 }
1057 if (*endp) {
1058 *endp = 0;
1059 resource = endp + 1;
1060 } else {
1061 resource = empty;
1062 }
1063 break;
1064 default:
1065 fprintf(stderr, "Syntax error\n");
1066 free(url);
1067 return 0;
1068 }
1069
1070 fprintf(stdout, "Protocol: %s\n", is_ssl ? "https" : "http");
1071 fprintf(stdout, "Host: %s\n", host);
1072 fprintf(stdout, "Port: %lu\n", port);
1073 fprintf(stdout, "Resource: %s\n", resource);
1074
1075 /* Initialize library */
1076 if (is_ssl) {
1078 } else {
1080 }
1081
1082 /* Connect to host */
1083 conn = mg_connect_client(host, (int)port, is_ssl, ebuf, sizeof(ebuf));
1084 if (conn) {
1085 /* Connecting to server worked */
1086 char buf[1024] = {0};
1087 int ret;
1088
1089 fprintf(stdout, "Connected to %s\n", host);
1090
1091 /* Send GET request */
1092 mg_printf(conn,
1093 "GET /%s HTTP/1.1\r\n"
1094 "Host: %s\r\n"
1095 "Connection: close\r\n"
1096 "\r\n",
1097 resource,
1098 host);
1099
1100 /* Wait for server to respond with a HTTP header */
1101 ret = mg_get_response(conn, ebuf, sizeof(ebuf), 10000);
1102
1103 if (ret >= 0) {
1104 const struct mg_response_info *ri = mg_get_response_info(conn);
1105
1106 fprintf(stdout,
1107 "Response info: %i %s\n",
1108 ri->status_code,
1109 ri->status_text);
1110
1111 /* Respond reader read. Read body (if any) */
1112 ret = mg_read(conn, buf, sizeof(buf));
1113 while (ret > 0) {
1114 fwrite(buf, 1, (unsigned)ret, stdout);
1115 ret = mg_read(conn, buf, sizeof(buf));
1116 }
1117
1118 fprintf(stdout, "Closing connection to %s\n", host);
1119
1120 } else {
1121 /* Server did not reply to HTTP request */
1122 fprintf(stderr, "Got no response from %s:\n%s\n", host, ebuf);
1123 }
1124 mg_close_connection(conn);
1125
1126 } else {
1127 /* Connecting to server failed */
1128 fprintf(stderr, "Error connecting to %s:\n%s\n", host, ebuf);
1129 }
1130
1131 /* Free memory and exit library */
1132 free(url);
1134 return 1;
1135}
CIVETWEB_API const struct mg_response_info * mg_get_response_info(const struct mg_connection *conn)
Definition civetweb.c:3561
CIVETWEB_API int mg_get_response(struct mg_connection *conn, char *ebuf, size_t ebuf_len, int timeout)
Definition civetweb.c:18822
CIVETWEB_API unsigned mg_exit_library(void)
Definition civetweb.c:22477
CIVETWEB_API unsigned mg_init_library(unsigned features)
Definition civetweb.c:22347
CIVETWEB_API int mg_printf(struct mg_connection *conn, const char *fmt,...)
Definition civetweb.c:7034
CIVETWEB_API struct mg_connection * mg_connect_client(const char *host, int port, int use_ssl, char *error_buffer, size_t error_buffer_size)
Definition civetweb.c:18253
CIVETWEB_API void mg_close_connection(struct mg_connection *conn)
Definition civetweb.c:17938
CIVETWEB_API int mg_read(struct mg_connection *conn, void *buf, size_t len)
Definition civetweb.c:6614
@ MG_FEATURES_DEFAULT
Definition civetweb.h:57
@ MG_FEATURES_TLS
Definition civetweb.h:66
size_t fwrite(const void *, size_t, size_t, FILE *)
const char * status_text
Definition civetweb.h:193

References mg_connection::buf, free, fwrite(), mg_close_connection(), mg_connect_client(), mg_exit_library(), MG_FEATURES_DEFAULT, MG_FEATURES_TLS, mg_get_response(), mg_get_response_info(), mg_init_library(), mg_printf(), mg_read(), sdup(), mg_response_info::status_code, and mg_response_info::status_text.

Referenced by start_civetweb().

◆ sanitize_options()

static int sanitize_options ( const char * options[],
const char * arg0 )
static

Definition at line 1139 of file vendor/civetweb/main.c.

1141{
1142 int ok = 1;
1143 /* Make sure we have absolute paths for files and directories */
1144 set_absolute_path(options, "document_root", arg0);
1145 set_absolute_path(options, "put_delete_auth_file", arg0);
1146 set_absolute_path(options, "cgi_interpreter", arg0);
1147 set_absolute_path(options, "access_log_file", arg0);
1148 set_absolute_path(options, "error_log_file", arg0);
1149 set_absolute_path(options, "global_auth_file", arg0);
1150#if defined(USE_LUA)
1151 set_absolute_path(options, "lua_preload_file", arg0);
1152#endif
1153 set_absolute_path(options, "ssl_certificate", arg0);
1154
1155 /* Make extra verification for certain options */
1156 if (!verify_existence(options, "document_root", 1))
1157 ok = 0;
1158 if (!verify_existence(options, "cgi_interpreter", 0))
1159 ok = 0;
1160 if (!verify_existence(options, "ssl_certificate", 0))
1161 ok = 0;
1162 if (!verify_existence(options, "ssl_ca_path", 1))
1163 ok = 0;
1164 if (!verify_existence(options, "ssl_ca_file", 0))
1165 ok = 0;
1166#if defined(USE_LUA)
1167 if (!verify_existence(options, "lua_preload_file", 0))
1168 ok = 0;
1169#endif
1170 return ok;
1171}
static void set_absolute_path(const char *options[], const char *option_name, const char *path_to_civetweb_exe)
static int verify_existence(const char **options, const char *option_name, int must_be_dir)

References set_absolute_path(), and verify_existence().

Referenced by start_civetweb().

◆ sdup()

static char * sdup ( const char * str)
static

Definition at line 453 of file vendor/civetweb/main.c.

454{
455 size_t len;
456 char *p;
457
458 len = strlen(str) + 1;
459 p = (char *)malloc(len);
460
461 if (p == NULL) {
462 die("Cannot allocate %u bytes", (unsigned)len);
463 }
464
465 memcpy(p, str, len);
466 return p;
467}

References die(), malloc, and NULL.

Referenced by init_system_info(), run_client(), and set_option().

◆ set_absolute_path()

static void set_absolute_path ( const char * options[],
const char * option_name,
const char * path_to_civetweb_exe )
static

Definition at line 914 of file vendor/civetweb/main.c.

917{
918 char path[PATH_MAX] = "", absolute[PATH_MAX] = "";
919 const char *option_value;
920 const char *p;
921
922 /* Check whether option is already set */
923 option_value = get_option(options, option_name);
924
925 /* If option is already set and it is an absolute path,
926 leave it as it is -- it's already absolute. */
927 if (option_value != NULL && !is_path_absolute(option_value)) {
928 /* Not absolute. Use the directory where civetweb executable lives
929 be the relative directory for everything.
930 Extract civetweb executable directory into path. */
931 if ((p = strrchr(path_to_civetweb_exe, DIRSEP)) == NULL) {
932 IGNORE_UNUSED_RESULT(getcwd(path, sizeof(path)));
933 } else {
934 snprintf(path,
935 sizeof(path) - 1,
936 "%.*s",
937 (int)(p - path_to_civetweb_exe),
938 path_to_civetweb_exe);
939 path[sizeof(path) - 1] = 0;
940 }
941
942 strncat(path, "/", sizeof(path) - strlen(path) - 1);
943 strncat(path, option_value, sizeof(path) - strlen(path) - 1);
944
945 /* Absolutize the path, and set the option */
946 IGNORE_UNUSED_RESULT(abs_path(path, absolute, sizeof(absolute)));
947 set_option(options, option_name, absolute);
948 }
949}
static int is_path_absolute(const char *path)
#define abs_path(rel, abs, abs_size)
static const char * get_option(const char **options, const char *option_name)
#define IGNORE_UNUSED_RESULT(a)
#define PATH_MAX

References abs_path, DIRSEP, get_option(), IGNORE_UNUSED_RESULT, is_path_absolute(), NULL, PATH_MAX, set_option(), and snprintf.

Referenced by sanitize_options().

◆ set_option()

static int set_option ( const char ** options,
const char * name,
const char * value )
static

Definition at line 495 of file vendor/civetweb/main.c.

496{
497 int i, type;
498 const struct mg_option *default_options = mg_get_valid_options();
499 const char *multi_sep = NULL;
500
501 for (i = 0; main_config_options[i].name != NULL; i++) {
502 /* These options are evaluated by main.c, not civetweb.c.
503 * Do not add it to options, and return OK */
504 if (!strcmp(name, main_config_options[OPTION_TITLE].name)) {
506 return 1;
507 }
508 if (!strcmp(name, main_config_options[OPTION_ICON].name)) {
509
511 return 1;
512 }
515 return 1;
516 }
518 if (!strcmp(value, "yes")) {
519 g_hide_tray = 1;
520 } else if (!strcmp(value, "no")) {
521 g_hide_tray = 0;
522 }
523 return 1;
524 }
526 if (g_num_add_domains > 0) {
527 g_add_domain = (const char **)realloc(
528 (void *)g_add_domain,
529 sizeof(char *) * ((unsigned)g_num_add_domains + 1u));
530 if (!g_add_domain) {
531 die("Out of memory");
532 }
535 } else {
536 g_add_domain = (const char **)malloc(sizeof(char *));
537 if (!g_add_domain) {
538 die("Out of memory");
539 }
540 g_add_domain[0] = sdup(value);
542 }
543 return 1;
544 }
545 }
546
547 /* Not an option of main.c, so check if it is a CivetWeb server option */
548 type = MG_CONFIG_TYPE_UNKNOWN; /* type "unknown" means "option not found" */
549 for (i = 0; default_options[i].name != NULL; i++) {
550 if (!strcmp(default_options[i].name, name)) {
551 type = default_options[i].type;
552 break; /* no need to search for another option */
553 }
554 }
555
556 switch (type) {
557
559 /* unknown option */
560 return 0; /* return error */
561
563 /* integer number >= 0, e.g. number of threads */
564 {
565 char *chk = 0;
566 unsigned long num = strtoul(value, &chk, 10);
567 (void)num; /* do not check value, only syntax */
568 if ((chk == NULL) || (*chk != 0) || (chk == value)) {
569 /* invalid number */
570 return 0;
571 }
572 }
573 break;
574
576 /* any text */
577 break;
578
580 /* list of text items, separated by , */
581 multi_sep = ",";
582 break;
583
585 /* lines of text, separated by carriage return line feed */
586 multi_sep = "\r\n";
587 break;
588
590 /* boolean value, yes or no */
591 if ((0 != strcmp(value, "yes")) && (0 != strcmp(value, "no"))) {
592 /* invalid boolean */
593 return 0;
594 }
595 break;
596
598 /* boolean value, yes or no */
599 if ((0 != strcmp(value, "yes")) && (0 != strcmp(value, "no"))
600 && (0 != strcmp(value, "optional"))) {
601 /* invalid boolean */
602 return 0;
603 }
604 break;
605
608 /* TODO (low): check this option when it is set, instead of calling
609 * verify_existence later */
610 break;
611
613 /* list of patterns, separated by | */
614 multi_sep = "|";
615 break;
616
617 default:
618 die("Unknown option type - option %s", name);
619 }
620
621 for (i = 0; i < MAX_OPTIONS; i++) {
622 if (options[2 * i] == NULL) {
623 /* Option not set yet. Add new option */
624 options[2 * i] = sdup(name);
625 options[2 * i + 1] = sdup(value);
626 options[2 * i + 2] = NULL;
627 break;
628 } else if (!strcmp(options[2 * i], name)) {
629 if (multi_sep) {
630 /* Option already set. Append new value. */
631 char *s =
632 (char *)malloc(strlen(options[2 * i + 1])
633 + strlen(multi_sep) + strlen(value) + 1);
634 if (!s) {
635 die("Out of memory");
636 }
637 sprintf(s, "%s%s%s", options[2 * i + 1], multi_sep, value);
638 free((char *)options[2 * i + 1]);
639 options[2 * i + 1] = s;
640 } else {
641 /* Option already set. Overwrite */
642 free((char *)options[2 * i + 1]);
643 options[2 * i + 1] = sdup(value);
644 }
645 break;
646 }
647 }
648
649 if (i == MAX_OPTIONS) {
650 die("Too many options specified");
651 }
652
653 if (options[2 * i] == NULL) {
654 die("Out of memory");
655 }
656 if (options[2 * i + 1] == NULL) {
657 die("Illegal escape sequence, or out of memory");
658 }
659
660 /* option set correctly */
661 return 1;
662}
#define realloc
Definition civetweb.c:1541
CIVETWEB_API const struct mg_option * mg_get_valid_options(void)
Definition civetweb.c:2833
@ MG_CONFIG_TYPE_UNKNOWN
Definition civetweb.h:694
@ MG_CONFIG_TYPE_FILE
Definition civetweb.h:697
@ MG_CONFIG_TYPE_STRING
Definition civetweb.h:696
@ MG_CONFIG_TYPE_DIRECTORY
Definition civetweb.h:698
@ MG_CONFIG_TYPE_EXT_PATTERN
Definition civetweb.h:700
@ MG_CONFIG_TYPE_STRING_MULTILINE
Definition civetweb.h:702
@ MG_CONFIG_TYPE_STRING_LIST
Definition civetweb.h:701
@ MG_CONFIG_TYPE_YES_NO_OPTIONAL
Definition civetweb.h:703
@ MG_CONFIG_TYPE_NUMBER
Definition civetweb.h:695
@ MG_CONFIG_TYPE_BOOLEAN
Definition civetweb.h:699
const char * name
Definition lsqlite3.c:2154
int value
Definition lsqlite3.c:2155
CURL_EXTERN CURLMcode curl_socket_t s
Definition multi.h:318
const char * name
Definition civetweb.h:686
#define MAX_OPTIONS
static int g_hide_tray

References die(), free, g_add_domain, g_hide_tray, g_icon_name, g_num_add_domains, g_server_name, g_website, main_config_options, malloc, MAX_OPTIONS, MG_CONFIG_TYPE_BOOLEAN, MG_CONFIG_TYPE_DIRECTORY, MG_CONFIG_TYPE_EXT_PATTERN, MG_CONFIG_TYPE_FILE, MG_CONFIG_TYPE_NUMBER, MG_CONFIG_TYPE_STRING, MG_CONFIG_TYPE_STRING_LIST, MG_CONFIG_TYPE_STRING_MULTILINE, MG_CONFIG_TYPE_UNKNOWN, MG_CONFIG_TYPE_YES_NO_OPTIONAL, mg_get_valid_options(), mg_option::name, name, NULL, OPTION_ADD_DOMAIN, OPTION_HIDE_TRAY, OPTION_ICON, OPTION_TITLE, OPTION_WEBPAGE, realloc, s, sdup(), mg_option::type, and value.

Referenced by process_command_line_arguments(), read_config_file(), set_absolute_path(), and start_civetweb().

◆ show_server_name()

static void show_server_name ( void )
static

Definition at line 303 of file vendor/civetweb/main.c.

304{
305#if defined(BUILD_DATE)
306 const char *bd = BUILD_DATE;
307#else
308 const char *bd = __DATE__;
309#endif
310#if defined(WIN32)
311 (void)MakeConsole();
312#endif
313
314 fprintf(stderr, "CivetWeb v%s, built on %s\n", mg_version(), bd);
315}

References mg_version().

Referenced by show_usage_and_exit(), and start_civetweb().

◆ show_usage_and_exit()

static NO_RETURN void show_usage_and_exit ( const char * exeName)
static

Definition at line 319 of file vendor/civetweb/main.c.

320{
321 const struct mg_option *options;
322 int i;
323
324 if (exeName == 0 || *exeName == 0) {
325 exeName = "civetweb";
326 }
327
329
330 fprintf(stderr, "\nUsage:\n");
331 fprintf(stderr, " Start server with a set of options:\n");
332 fprintf(stderr, " %s [config_file]\n", exeName);
333 fprintf(stderr, " %s [-option value ...]\n", exeName);
334 fprintf(stderr, " Run as client:\n");
335 fprintf(stderr, " %s -C url\n", exeName);
336 fprintf(stderr, " Show system information:\n");
337 fprintf(stderr, " %s -I\n", exeName);
338 fprintf(stderr, " Add user/change password:\n");
339 fprintf(stderr,
340 " %s -A <htpasswd_file> <realm> <user> <passwd>\n",
341 exeName);
342 fprintf(stderr, " Remove user:\n");
343 fprintf(stderr, " %s -R <htpasswd_file> <realm> <user>\n", exeName);
344 fprintf(stderr, "\nOPTIONS:\n");
345
346 options = mg_get_valid_options();
347 for (i = 0; options[i].name != NULL; i++) {
348 fprintf(stderr,
349 " -%s %s\n",
350 options[i].name,
351 ((options[i].default_value == NULL)
352 ? "<empty>"
353 : options[i].default_value));
354 }
355
356 options = main_config_options;
357 for (i = 0; options[i].name != NULL; i++) {
358 fprintf(stderr,
359 " -%s %s\n",
360 options[i].name,
361 ((options[i].default_value == NULL)
362 ? "<empty>"
363 : options[i].default_value));
364 }
365
366 exit(EXIT_FAILURE);
367}
const char * default_value
Definition civetweb.h:688
static void show_server_name(void)

References mg_option::default_value, main_config_options, mg_get_valid_options(), mg_option::name, name, NULL, and show_server_name().

Referenced by process_command_line_arguments(), and start_civetweb().

◆ signal_handler()

static void WINCDECL signal_handler ( int sig_num)
static

Definition at line 251 of file vendor/civetweb/main.c.

252{
253 g_exit_flag = sig_num;
254}

References g_exit_flag.

Referenced by start_civetweb().

◆ start_civetweb()

static void start_civetweb ( int argc,
char * argv[] )
static

Definition at line 1181 of file vendor/civetweb/main.c.

1182{
1183 struct mg_callbacks callbacks;
1184 const char *options[2 * MAX_OPTIONS + 1];
1185 struct mg_init_data init;
1186 struct mg_error_data error;
1187 char error_text[256];
1188 int i;
1189
1190 /* Start option -I:
1191 * Show system information and exit
1192 * This is very useful for diagnosis. */
1193 if (argc > 1 && !strcmp(argv[1], "-I")) {
1194
1195#if defined(WIN32)
1196 (void)MakeConsole();
1197#endif
1198 fprintf(stdout,
1199 "\n%s (%s)\n%s\n",
1203
1204 exit(EXIT_SUCCESS);
1205 }
1206
1207 /* Edit passwords file: Add user or change password, if -A option is
1208 * specified */
1209 if (argc > 1 && !strcmp(argv[1], "-A")) {
1210 if (argc != 6) {
1211 show_usage_and_exit(argv[0]);
1212 }
1213 exit(mg_modify_passwords_file(argv[2], argv[3], argv[4], argv[5])
1214 ? EXIT_SUCCESS
1215 : EXIT_FAILURE);
1216 }
1217
1218 /* Edit passwords file: Remove user, if -R option is specified */
1219 if (argc > 1 && !strcmp(argv[1], "-R")) {
1220 if (argc != 5) {
1221 show_usage_and_exit(argv[0]);
1222 }
1223 exit(mg_modify_passwords_file(argv[2], argv[3], argv[4], NULL)
1224 ? EXIT_SUCCESS
1225 : EXIT_FAILURE);
1226 }
1227
1228 /* Client mode */
1229 if (argc > 1 && !strcmp(argv[1], "-C")) {
1230 if (argc != 3) {
1231 show_usage_and_exit(argv[0]);
1232 }
1233
1234 exit(run_client(argv[2]) ? EXIT_SUCCESS : EXIT_FAILURE);
1235 }
1236
1237 /* Call Lua with additional CivetWeb specific Lua functions, if -L option
1238 * is specified */
1239 if (argc > 1 && !strcmp(argv[1], "-L")) {
1240
1241#if defined(USE_LUA)
1242 if (argc != 3) {
1243 show_usage_and_exit(argv[0]);
1244 }
1245#if defined(WIN32)
1246 (void)MakeConsole();
1247#endif
1248 exit(run_lua(argv[2]));
1249#else
1251 fprintf(stderr, "\nError: Lua support not enabled\n");
1252 exit(EXIT_FAILURE);
1253#endif
1254 }
1255
1256 /* Call Duktape, if -E option is specified */
1257 if (argc > 1 && !strcmp(argv[1], "-E")) {
1258
1259#if defined(USE_DUKTAPE)
1260 if (argc != 3) {
1261 show_usage_and_exit(argv[0]);
1262 }
1263#if defined(WIN32)
1264 (void)MakeConsole();
1265#endif
1266 exit(run_duktape(argv[2]));
1267#else
1269 fprintf(stderr, "\nError: Ecmascript support not enabled\n");
1270 exit(EXIT_FAILURE);
1271#endif
1272 }
1273
1274 /* Show usage if -h or --help options are specified */
1275 if (argc == 2
1276 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "-H")
1277 || !strcmp(argv[1], "--help"))) {
1278 show_usage_and_exit(argv[0]);
1279 }
1280
1281 /* Initialize options structure */
1282 memset((void *)options, 0, sizeof(options));
1283 set_option(options, "document_root", ".");
1284
1285 /* Update config based on command line arguments */
1286 process_command_line_arguments(argc, argv, options);
1287
1288 i = sanitize_options(options, argv[0]);
1289 if (!i) {
1290 die("Invalid options");
1291 }
1292
1293 /* Setup signal handler: quit on Ctrl-C */
1294 signal(SIGTERM, signal_handler);
1295 signal(SIGINT, signal_handler);
1296
1297#if defined(DAEMONIZE)
1298 /* Daemonize */
1299 for (i = 0; options[i] != NULL; i++) {
1300 if (strcmp(options[i], "daemonize") == 0) {
1301 if (options[i + 1] != NULL) {
1302 if (mg_strcasecmp(options[i + 1], "yes") == 0) {
1303 fprintf(stdout, "daemonize.\n");
1304 if (daemon(0, 0) != 0) {
1305 fprintf(stdout, "Failed to daemonize main process.\n");
1306 exit(EXIT_FAILURE);
1307 }
1308 FILE *fp;
1309 if ((fp = fopen(PID_FILE, "w")) == 0) {
1310 fprintf(stdout, "Can not open %s.\n", PID_FILE);
1311 exit(EXIT_FAILURE);
1312 }
1313 fprintf(fp, "%d", getpid());
1314 fclose(fp);
1315 }
1316 }
1317 break;
1318 }
1319 }
1320#endif
1321
1322 /* Initialize user data */
1323 memset(&g_user_data, 0, sizeof(g_user_data));
1324
1325 memset(&callbacks, 0, sizeof(callbacks));
1326
1327 memset(&init, 0, sizeof(init));
1328 init.callbacks = &callbacks;
1329 init.configuration_options = options;
1330 init.user_data = &g_user_data;
1331
1332 memset(&error, 0, sizeof(error));
1333 error.text = error_text;
1334 error.text_buffer_size = sizeof(error_text);
1335
1336 /* Start Civetweb */
1337 g_ctx = mg_start2(&init, &error);
1338
1339 /* mg_start copies all options to an internal buffer.
1340 * The options data field here is not required anymore. */
1341 for (i = 0; options[i] != NULL; i++) {
1342 free((char *)options[i]);
1343 }
1344
1345 /* If mg_start fails, it returns NULL */
1346 if (g_ctx == NULL) {
1347#ifdef _WIN32
1348 /* On Windows: provide option to edit configuration file. */
1349 char msgboxtxt[1024];
1350 int ret;
1351 sprintf(msgboxtxt,
1352 "Failed to start %s with code %u:\n%s\n\nEdit settings?",
1354 error.code,
1355 error_text);
1356 ret =
1357 MessageBox(NULL, msgboxtxt, "Error", MB_ICONERROR | MB_YESNOCANCEL);
1358 if (ret == IDYES) {
1359 show_settings_dialog();
1360
1361 /* Hitting "save" will also restart the server. */
1362 if (g_ctx != NULL) {
1363 return;
1364 }
1365 }
1366 exit(EXIT_FAILURE);
1367#else
1368 die("Failed to start %s with code %u:\n%s",
1370 error.code,
1371 error_text);
1372#endif
1373 }
1374
1375#if defined(MG_EXPERIMENTAL_INTERFACES)
1376 for (i = 0; i < g_num_add_domains; i++) {
1377
1378 int j;
1379 memset(options, 0, sizeof(options));
1380 set_option(options, "document_root", ".");
1381
1382 if (0 == read_config_file(g_add_domain[i], options)) {
1383 die("Cannot open config file %s: %s",
1384 g_add_domain[i],
1385 strerror(errno));
1386 }
1387
1388 j = sanitize_options(options, argv[0]);
1389 if (!j) {
1390 die("Invalid options");
1391 }
1392
1393 j = mg_start_domain(g_ctx, (const char **)options);
1394 if (j < 0) {
1395 die("Error loading domain file %s: %i", g_add_domain[i], j);
1396 } else {
1397 fprintf(stdout, "Domain file %s loaded\n", g_add_domain[i]);
1398 }
1399
1400 for (j = 0; options[j] != NULL; j++) {
1401 free((void *)options[j]);
1402 }
1403 }
1404#endif
1405}
CIVETWEB_API int mg_start_domain(struct mg_context *ctx, const char **options)
Definition civetweb.c:21422
CIVETWEB_API struct mg_context * mg_start2(struct mg_init_data *init, struct mg_error_data *error)
Definition civetweb.c:20464
CIVETWEB_API int mg_strcasecmp(const char *s1, const char *s2)
Definition civetweb.c:3034
CIVETWEB_API int mg_modify_passwords_file(const char *fname, const char *domain, const char *user, const char *pass)
Definition civetweb.c:9220
int run_lua(const char *file_name)
static void error(LoadState *S, const char *why)
static int run_client(const char *url_arg)
static int sanitize_options(const char *options[], const char *arg0)
static void process_command_line_arguments(int argc, char *argv[], const char **options)
static struct tuser_data g_user_data
static void WINCDECL signal_handler(int sig_num)

References mg_init_data::callbacks, mg_init_data::configuration_options, die(), error(), free, g_add_domain, g_ctx, g_num_add_domains, g_server_base_name, g_server_name, g_system_info, g_user_data, MAX_OPTIONS, mg_modify_passwords_file(), mg_start2(), mg_start_domain(), mg_strcasecmp(), NULL, process_command_line_arguments(), read_config_file(), run_client(), run_lua(), sanitize_options(), set_option(), show_server_name(), show_usage_and_exit(), signal_handler(), and mg_init_data::user_data.

Referenced by main().

◆ stop_civetweb()

static void stop_civetweb ( void )
static

Definition at line 1409 of file vendor/civetweb/main.c.

1410{
1411 mg_stop(g_ctx);
1412}
CIVETWEB_API void mg_stop(struct mg_context *ctx)
Definition civetweb.c:20346

References g_ctx, and mg_stop().

Referenced by main().

◆ verify_existence()

static int verify_existence ( const char ** options,
const char * option_name,
int must_be_dir )
static

Definition at line 878 of file vendor/civetweb/main.c.

879{
880 struct stat st;
881 const char *path = get_option(options, option_name);
882
883#if defined(_WIN32)
884 wchar_t wbuf[1024];
885 char mbbuf[1024];
886 int len;
887
888 if (path) {
889 memset(wbuf, 0, sizeof(wbuf));
890 memset(mbbuf, 0, sizeof(mbbuf));
891 len = MultiByteToWideChar(
892 CP_UTF8, 0, path, -1, wbuf, sizeof(wbuf) / sizeof(wbuf[0]) - 1);
893 wcstombs(mbbuf, wbuf, sizeof(mbbuf) - 1);
894 path = mbbuf;
895 (void)len;
896 }
897#endif
898
899 if (path != NULL
900 && (stat(path, &st) != 0
901 || ((S_ISDIR(st.st_mode) ? 1 : 0) != must_be_dir))) {
902 warn("Invalid path for %s: [%s]: (%s). Make sure that path is either "
903 "absolute, or it is relative to civetweb executable.",
904 option_name,
905 path,
906 strerror(errno));
907 return 0;
908 }
909 return 1;
910}
static void warn(const char *fmt,...)

References get_option(), NULL, and warn().

Referenced by sanitize_options().

◆ warn()

static void warn ( const char * fmt,
... )
static

Definition at line 279 of file vendor/civetweb/main.c.

280{
281 va_list ap;
282 char msg[512] = "";
283
284 va_start(ap, fmt);
285 (void)vsnprintf(msg, sizeof(msg) - 1, fmt, ap);
286 msg[sizeof(msg) - 1] = 0;
287 va_end(ap);
288
289#if defined(_WIN32)
290 MessageBox(NULL, msg, "Warning", MB_OK);
291#else
292 fprintf(stderr, "%s\n", msg);
293#endif
294}

References NULL.

Referenced by verify_existence().

Variable Documentation

◆ g_add_domain

const char** g_add_domain
static

Definition at line 197 of file vendor/civetweb/main.c.

Referenced by init_server_name(), set_option(), and start_civetweb().

◆ g_config_file_name

char g_config_file_name[PATH_MAX]
static
Initial value:
=
""

Definition at line 203 of file vendor/civetweb/main.c.

Referenced by process_command_line_arguments().

◆ g_ctx

struct mg_context* g_ctx
static

Definition at line 207 of file vendor/civetweb/main.c.

Referenced by main(), start_civetweb(), and stop_civetweb().

◆ g_exit_flag

volatile int g_exit_flag = 0

Definition at line 185 of file vendor/civetweb/main.c.

Referenced by main(), and signal_handler().

◆ g_hide_tray

int g_hide_tray = 0
static

Definition at line 199 of file vendor/civetweb/main.c.

Referenced by set_option().

◆ g_icon_name

const char* g_icon_name
static

Definition at line 191 of file vendor/civetweb/main.c.

Referenced by init_server_name(), and set_option().

◆ g_num_add_domains

int g_num_add_domains
static

Definition at line 195 of file vendor/civetweb/main.c.

Referenced by init_server_name(), set_option(), and start_civetweb().

◆ g_server_base_name

char g_server_base_name[40]
static

Definition at line 187 of file vendor/civetweb/main.c.

Referenced by init_server_name(), and start_civetweb().

◆ g_server_name

const char* g_server_name
static

Definition at line 189 of file vendor/civetweb/main.c.

Referenced by init_server_name(), main(), set_option(), and start_civetweb().

◆ g_system_info

char* g_system_info
static

Definition at line 202 of file vendor/civetweb/main.c.

Referenced by free_system_info(), init_system_info(), and start_civetweb().

◆ g_user_data

struct tuser_data g_user_data
static

Definition at line 209 of file vendor/civetweb/main.c.

Referenced by start_civetweb().

◆ g_website

const char* g_website
static

Definition at line 193 of file vendor/civetweb/main.c.

Referenced by init_server_name(), and set_option().

◆ main_config_options

struct mg_option main_config_options[]
static
Initial value:

Definition at line 237 of file vendor/civetweb/main.c.

237 {
238 {"title", MG_CONFIG_TYPE_STRING, NULL},
239 {"icon", MG_CONFIG_TYPE_STRING, NULL},
240 {"website", MG_CONFIG_TYPE_STRING, NULL},
241 {"add_domain", MG_CONFIG_TYPE_STRING_LIST, NULL},
242 {"hide_tray", MG_CONFIG_TYPE_BOOLEAN, NULL},
243#if defined(DAEMONIZE)
244 {"daemonize", MG_CONFIG_TYPE_BOOLEAN, "no"},
245#endif
246

Referenced by init_server_name(), set_option(), and show_usage_and_exit().