MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / saneMain

Function saneMain

Examples/AsyncWebServer/AsyncWebServer.cpp:238–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236};
237
238Result saneMain(Span<const StringSpan> args)
239{
240 AsyncWebServerExample sample;
241 SocketNetworking::initNetworking();
242 Console::tryAttachingToParentConsole();
243 Console console;
244 StringPath currentDirPath;
245 StringView directory;
246 StringView interface;
247 uint16_t port = static_cast<uint16_t>(sample.port);
248
249 globalConsole = &console;
250 CommandLineOption cmdOptions[9];
251 cmdOptions[0].longName = "directory";
252 cmdOptions[0].help = "Directory to serve (defaults to current working directory)";
253 cmdOptions[0].valueName = "PATH";
254 cmdOptions[0].shortName = 'd';
255 cmdOptions[0].value = CommandLineValue::stringView(directory);
256
257 cmdOptions[1].longName = "sendfile";
258 cmdOptions[1].negativeLongName = "no-sendfile";
259 cmdOptions[1].help = "Enable or disable async file send optimization";
260 cmdOptions[1].value = CommandLineValue::boolean(sample.useSendFile);
261
262 cmdOptions[2].longName = "epoll";
263 cmdOptions[2].negativeLongName = "uring";
264 cmdOptions[2].help = "Select Linux async backend (epoll or io_uring)";
265 cmdOptions[2].value = CommandLineValue::boolean(sample.useEpoll);
266
267 cmdOptions[3].longName = "clients";
268 cmdOptions[3].help = "Maximum number of concurrent clients";
269 cmdOptions[3].valueName = "NUM";
270 cmdOptions[3].shortName = 'c';
271 cmdOptions[3].value = CommandLineValue::int32(sample.maxClients);
272
273 cmdOptions[4].longName = "threads";
274 cmdOptions[4].help = "Number of worker threads for file operations";
275 cmdOptions[4].valueName = "NUM";
276 cmdOptions[4].shortName = 't';
277 cmdOptions[4].value = CommandLineValue::int32(sample.numThreads);
278
279 cmdOptions[5].longName = "port";
280 cmdOptions[5].help = "Port to listen on";
281 cmdOptions[5].valueName = "PORT";
282 cmdOptions[5].shortName = 'p';
283 cmdOptions[5].value = CommandLineValue::uint16(port);
284
285 cmdOptions[6].longName = "interface";
286 cmdOptions[6].help = "Interface to listen on (for LAN use 0.0.0.0)";
287 cmdOptions[6].valueName = "ADDRESS";
288 cmdOptions[6].shortName = 'i';
289 cmdOptions[6].value = CommandLineValue::stringView(interface);
290
291 cmdOptions[7].longName = "uploads";
292 cmdOptions[7].negativeLongName = "no-uploads";
293 cmdOptions[7].help = "Enable or disable PUT and multipart uploads";
294 cmdOptions[7].value = CommandLineValue::boolean(sample.enableUploads);
295

Callers 1

asyncWebServerMainFunction · 0.70

Calls 9

flushMethod · 0.80
printMethod · 0.80
ResultClass · 0.50
parseMethod · 0.45
isEmptyMethod · 0.45
createMethod · 0.45
startMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected