int StartWebInterface(char * IP , unsigned int port , char * fileroot,char * app_clipart) { flashy_server = AmmServer_Start ( "flashyslideshows", IP, port, 0, /*This means we don't want a specific configuration file*/ fileroot, fileroot ); if (!flashy_server) { return 0; } init_dynamic_content(fileroot,app_clipart); return 1; }
struct AmmServer_Instance * AmmServer_StartWithArgs(const char * name , int argc, char ** argv , const char * ip, unsigned int port, const char * conf_file, const char * web_root_path, const char * templates_root_path) { //First prepare some buffers with default values for all the arguments char serverName[MAX_FILE_PATH]="default"; char webserver_root[MAX_FILE_PATH]="public_html/"; char templates_root[MAX_FILE_PATH]="public_html/templates/"; char configuration_file[MAX_FILE_PATH]={0}; char bindIP[MAX_IP_STRING_SIZE]="0.0.0.0"; unsigned int bindPort=8080; //If we have arguments we change our buffers if (name!=0) { strncpy(serverName,name,MAX_FILE_PATH); } if (web_root_path!=0) { strncpy(webserver_root,web_root_path,MAX_FILE_PATH); } if (templates_root!=0) { strncpy(templates_root,templates_root_path,MAX_FILE_PATH); } if (conf_file!=0) { strncpy(configuration_file,conf_file,MAX_FILE_PATH); } if (ip!=0) { strncpy(bindIP,ip,MAX_IP_STRING_SIZE); } if (port!=0) { bindPort=port; } //If we have a command line arguments we overwrite our buffers if ( (argc>0) && (argv!=0) ) { unsigned int i=0; for (i=0; i<argc; i++) { if ((strcmp(argv[i],"-bind")==0)&&(argc>i+1)) { strncpy(bindIP,argv[i+1],MAX_IP_STRING_SIZE); fprintf(stderr,"Binding to %s \n",bindIP); } else if ((strcmp(argv[i],"-p")==0)&&(argc>i+1)) { bindPort = atoi(argv[i+1]); fprintf(stderr,"Binding to Port %u \n",bindPort); } else if ((strcmp(argv[i],"-port")==0)&&(argc>i+1)) { bindPort = atoi(argv[i+1]); fprintf(stderr,"Binding to Port %u \n",bindPort); } else if ((strcmp(argv[i],"-rootdir")==0)&&(argc>i+1)) { strncpy(webserver_root,argv[i+1],MAX_FILE_PATH); fprintf(stderr,"Setting web server root directory to %s \n",webserver_root); } else if ((strcmp(argv[i],"-templatedir")==0)&&(argc>i+1)) { strncpy(templates_root,argv[i+1],MAX_FILE_PATH); fprintf(stderr,"Setting web template directory to %s \n",templates_root); } else if (strcmp(argv[i],"-conf")==0) { strncpy(configuration_file,conf_file,MAX_FILE_PATH); fprintf(stderr,"Reading Configuration file %s \n",configuration_file); } } } return AmmServer_Start(name,bindIP,bindPort,configuration_file,webserver_root,templates_root); }