Subversion Repositories Tewi

Rev

Rev 168 | Rev 183 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 168 Rev 182
Line 1... Line 1...
1
/* $Id: main.c 168 2024-09-26 20:24:04Z nishi $ */
1
/* $Id: main.c 182 2024-09-27 12:55:12Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
Line 23... Line 23...
23
 
23
 
24
#ifdef __MINGW32__
24
#ifdef __MINGW32__
25
#include <windows.h>
25
#include <windows.h>
26
#endif
26
#endif
27
 
27
 
-
 
28
#ifdef _PSP
-
 
29
#include <pspkernel.h>
-
 
30
#include <pspdebug.h>
-
 
31
 
-
 
32
PSP_MODULE_INFO("Tewi HTTPd", PSP_MODULE_USER, 1, 1);
-
 
33
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
-
 
34
 
-
 
35
#define printf(...) pspDebugScreenPrintf(__VA_ARGS__)
-
 
36
#endif
-
 
37
 
28
extern bool cm_do_log;
38
extern bool cm_do_log;
29
extern struct tw_config config;
39
extern struct tw_config config;
30
extern FILE* logfile;
40
extern FILE* logfile;
31
 
41
 
32
char tw_server[2048];
42
char tw_server[2048];
Line 80... Line 90...
80
	logfile = stderr;
90
	logfile = stderr;
81
#ifdef SERVICE
91
#ifdef SERVICE
82
	SERVICE_TABLE_ENTRY table[] = {{"Tewi HTTPd", servmain}, {NULL, NULL}};
92
	SERVICE_TABLE_ENTRY table[] = {{"Tewi HTTPd", servmain}, {NULL, NULL}};
83
	StartServiceCtrlDispatcher(table);
93
	StartServiceCtrlDispatcher(table);
84
#else
94
#else
-
 
95
#ifdef _PSP
-
 
96
	pspDebugScreenInit();
-
 
97
	pspDebugScreenSetXY(0, 0);
-
 
98
#endif
85
	int st = startup(argc, argv);
99
	int st = startup(argc, argv);
86
	if(st != -1) return st;
100
	if(st != -1) return st;
87
	tw_server_loop();
101
	tw_server_loop();
88
#endif
102
#endif
89
	return 0;
103
	return 0;
Line 111... Line 125...
111
					if(argv[i] == NULL) {
125
					if(argv[i] == NULL) {
112
						fprintf(stderr, "Missing argument\n");
126
						fprintf(stderr, "Missing argument\n");
113
						return 1;
127
						return 1;
114
					}
128
					}
115
					confpath = argv[i];
129
					confpath = argv[i];
-
 
130
#ifndef _PSP
116
				} else if(strcmp(argv[i], "--logfile") == 0 || strcmp(argv[i], "-l") == 0) {
131
				} else if(strcmp(argv[i], "--logfile") == 0 || strcmp(argv[i], "-l") == 0) {
117
					i++;
132
					i++;
118
					if(argv[i] == NULL) {
133
					if(argv[i] == NULL) {
119
						fprintf(stderr, "Missing argument\n");
134
						fprintf(stderr, "Missing argument\n");
120
						return 1;
135
						return 1;
Line 125... Line 140...
125
					logfile = fopen(argv[i], "a");
140
					logfile = fopen(argv[i], "a");
126
					if(logfile == NULL) {
141
					if(logfile == NULL) {
127
						fprintf(stderr, "Failed to open logfile\n");
142
						fprintf(stderr, "Failed to open logfile\n");
128
						return 1;
143
						return 1;
129
					}
144
					}
-
 
145
#endif
130
				} else if(strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-V") == 0) {
146
				} else if(strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-V") == 0) {
131
					printf("Tewi HTTPd Tewi/%s\n", tw_get_version());
147
					printf("Tewi HTTPd Tewi/%s\n", tw_get_version());
132
					printf("Under public domain.\n");
148
					printf("Under public domain.\n");
133
					printf("Original by 2024 Nishi\n");
149
					printf("Original by 2024 Nishi\n");
134
					printf("\n");
150
					printf("\n");
135
					printf("Usage: %s [--config|-C config] [--verbose|-v] [--version|-V]\n", argv[0]);
151
					printf("Usage: %s [--config|-C config] [--verbose|-v] [--version|-V]\n", argv[0]);
136
					printf("--config  | -C config      : Specify config\n");
152
					printf("--config  | -C config      : Specify config\n");
-
 
153
#ifndef _PSP
137
					printf("--logfile | -l logfile     : Specify logfile\n");
154
					printf("--logfile | -l logfile     : Specify logfile\n");
-
 
155
#endif
138
					printf("--verbose | -v             : Verbose mode\n");
156
					printf("--verbose | -v             : Verbose mode\n");
139
					printf("--version | -V             : Version information\n");
157
					printf("--version | -V             : Version information\n");
140
					return 0;
158
					return 0;
141
				} else {
159
				} else {
142
					fprintf(stderr, "Unknown option: %s\n", argv[i]);
160
					fprintf(stderr, "Unknown option: %s\n", argv[i]);