MCPcopy Create free account
hub / github.com/TASEmulators/fceux / main

Function main

fceux-server/server.cpp:689–947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

687
688
689int main(int argc, char *argv[])
690{
691 struct sockaddr_in sockin;
692 socklen_t sockin_len;
693 int i;
694 char* pass = 0;
695 /* If we can't load the default config file, use some defined values */
696 if(!LoadConfigFile(DEFAULT_CONFIG))
697 {
698 ServerConfig.Port = DEFAULT_PORT;
699 ServerConfig.MaxClients = DEFAULT_MAX;
700 ServerConfig.ConnectTimeout = DEFAULT_TIMEOUT;
701 ServerConfig.FrameDivisor = DEFAULT_FRAMEDIVISOR;
702 }
703 char* configfile = 0;
704
705 for(i=1; i<argc ;i++)
706 {
707 if(!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
708 {
709 printf("Usage: %s [OPTION]...\n" ,argv[0]);
710 printf("Begins the FCE Ultra game server with given options.\n");
711 printf("This server will first look in %s for options. If that \nfile does not exist, it will use the defaults given here. Any argument given \ndirectly will override any default values.\n\n", DEFAULT_CONFIG);
712
713 printf("-h\t--help\t\tDisplays this help message.\n");
714 printf("-v\t--version\t\tDisplays the version number and quits.\n");
715 printf("-p\t--port\t\tStarts server on given port. (default=%d)\n", DEFAULT_PORT);
716 printf("-w\t--password\tSpecifies a password for entry.\n");
717 printf("-m\t--maxclients\tSpecifies the maximum amount of clients allowed \n\t\t\tto access the server. (default=%d)\n", DEFAULT_MAX);
718 printf("-t\t--timeout\tSpecifies the amount of seconds before the server \n\t\t\ttimes out. (default=%d)\n", DEFAULT_TIMEOUT);
719 printf("-f\t--framedivisor\tSpecifies frame divisor.\n\t\t\t(eg: 60 / framedivisor = updates per second)(default=%d)\n", DEFAULT_FRAMEDIVISOR);
720 printf("-c\t--configfile\tLoads the given configuration file.\n");
721 return -1;
722 }
723 if(!strcmp(argv[i], "--port") || !strcmp(argv[i], "-p"))
724 {
725 i++;
726 if(argc == i)
727 {
728 printf("Please specify a port to use.\n");
729 return -1;
730 }
731 ServerConfig.Port = atoi(argv[i]);
732 continue;
733 }
734 if(!strcmp(argv[i], "--password") || !strcmp(argv[i], "-w"))
735 {
736 i++;
737 if(argc == i)
738 {
739 printf("Please specify a password.\n");
740 return -1;
741 }
742 pass = argv[i];
743 struct md5_context md5;
744 ServerConfig.Password = (uint8 *)malloc(16);
745 md5_starts(&md5);
746 md5_update(&md5,(uint8*)pass,strlen(pass));

Callers

nothing calls this directly

Calls 10

LoadConfigFileFunction · 0.85
StartNBTCPReceiveFunction · 0.85
KillClientFunction · 0.85
CheckNBTCPReceiveFunction · 0.85
MakeSendTCPFunction · 0.85
md5_startsFunction · 0.70
md5_updateFunction · 0.70
md5_finishFunction · 0.70
RefreshThrottleFPSFunction · 0.70
SpeedThrottleFunction · 0.70

Tested by

no test coverage detected