int main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr,"usage: cutewiki <wikiname> \n"); exit(1); } /* Try to set different non-UTF-8 locale */ if (!setlocale(LC_ALL, "")) { fprintf(stderr, "Error: Setting locale failed!\n"); exit(1); } //svr_init(); wiki_init(argv[1]); user_init(); rcs_init(); pagelist_init(wiki->pagedir); fprintf(stderr, "Info: CuteWiki started with configuration '%s'.\n", wiki->wikiname); wiki_loop(); pagelist_exit(); user_exit(); wiki_exit(); svr_exit(); return 0; }
int main(int argc, char *argv[]) { const char *dir = "."; if (argc > 1) dir = argv[1]; printf("---====== Fastwiki on PC ======---\n"); printf("Author: qianshanhai\n"); printf("Version: %s, %s %s\n", _VERSION, __DATE__, __TIME__); wiki_init(dir); fgetc(stdin); return 0; }
int main(int argc, char **argv) { HttpRequest *req = NULL; int port = 8000; int c; char *didiwiki_home = NULL; int restore_WikiHelp = 0; struct in_addr address; /* default values */ debug = 0; //normal mode hostlogin = 0; //host will have to login nologin = 0; //users will have to login. dosendmail = 0; //don't send systematically email at each registration lgindex = 20; //print 20 files before to make a new index box /* by default bind server to "0.0.0.0" */ address.s_addr = inet_addr("0.0.0.0"); while (1) { static struct option long_options[] = { {"autologin", no_argument, 0, 'a'}, {"nologin", no_argument, 0, 'n'}, {"debug", no_argument, 0, 'd'}, {"version", no_argument, 0, 'v'}, {"listen", required_argument, 0, 'l'}, {"port", required_argument, 0, 'p'}, {"home", required_argument, 0, 'h'}, {"restore", no_argument, 0, 'r'}, {"sendmail", no_argument, 0, 's'}, {"index", required_argument, 0, 'i'}, {"help", no_argument, 0, 10 }, {0, 0, 0, 0} }; /* getopt_long stores the option index here */ int option_index = 0; c = getopt_long (argc, argv, "adl:p:h:i:rsv", long_options, &option_index); /* detect the end of the options */ if (c == -1) break; switch (c) { case 0: break; case 'i': //set index length lgindex = atoi(optarg); if (lgindex==0) lgindex=20; fprintf(stderr,"Index length = %i\n",lgindex); break; case 'a': //autologin for the localhost hostlogin = 1; fprintf(stderr,"Localhost is logged in.\n"); break; case 'n': //autologin any user nologin = 1; fprintf(stderr,"Any user registrered or not will be logged in.\n"); break; case 'd': debug = 1; break; case 'v': printf("CiWiki alias DidiWiki - version %s\n\n",VERSION); return 0; case 'p': //default port is 8000 port = atoi(optarg); break; case 'h': //default home directory is ~/.didiwiki didiwiki_home = optarg; break; case 'l': //listen a inet address if(inet_aton(optarg,&address) == 0) { fprintf(stderr, "didiwiki: invalid ip address \"%s\"\n", optarg); exit(1); } else address.s_addr = inet_addr(optarg); break; case 'r': //rewrite Wikihelp page restore_WikiHelp=1; break; case 's': dosendmail= 1; break; case 10: usage(); break; default: usage(); } } //end while wiki_init(didiwiki_home,restore_WikiHelp); if (debug) { req = http_request_new(); /* reads request from stdin */ } else { req = http_server(address, port); /* forks here */ } wiki_handle_http_request(req); return 0; }