4 * https://tsdemuxer.googlecode.com/svn/trunk/xupnpd
13 +#include <sys/stat.h>
14 +#include <sys/types.h>
15 #include "luacompat.h"
20 int main(int argc,char** argv)
22 - const char* p=strrchr(argv[0],'/');
30 - if(n>=sizeof(location))
31 - n=sizeof(location)-1;
32 - strncpy(location,argv[0],n);
40 - const char* root=getenv("XUPNPDROOTDIR");
45 - FILE* fp=fopen("xupnpd.lua","r");
49 - rc=chdir("/usr/share/xupnpd/");
52 + char *xupnpd_root = "/usr/share/xupnpd/";
56 + while ((c = getopt (argc, argv, "d:")) != -1) {
59 + xupnpd_root = optarg;
63 + fprintf(stderr, "Option -%c requires an argument.\n", optopt);
64 + else if (isprint(optopt))
65 + fprintf(stderr, "Unknown option \"-%c\".\n", optopt);
67 + fprintf(stderr, "Unknown option\n");
74 + if(stat(xupnpd_root, &s) != -1 && S_ISDIR(s.st_mode)) {
75 + c = chdir(xupnpd_root);
78 + fprintf(stderr, "Directory %s doesn't exist.\n", xupnpd_root);
82 lua_State* L=lua_open();