summaryrefslogtreecommitdiffabout
path: root/src/iiid.cc
Unidiff
Diffstat (limited to 'src/iiid.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--src/iiid.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/iiid.cc b/src/iiid.cc
index 6c23790..c026050 100644
--- a/src/iiid.cc
+++ b/src/iiid.cc
@@ -1,86 +1,86 @@
1#include <syslog.h> 1#include <syslog.h>
2#include <getopt.h> 2#include <getopt.h>
3#include <iostream> 3#include <iostream>
4#include <cassert> 4#include <cassert>
5#include <stdexcept> 5#include <stdexcept>
6#include "eyetil.h" 6#include "eyetil.h"
7#include "eyefiworker.h" 7#include "eyefiworker.h"
8 8
9#include "config.h" 9#include "config.h"
10 10
11#include "eyefi.nsmap" 11#include "eyefi.nsmap"
12 12
13#define PHEADER \ 13#define PHEADER \
14 PACKAGE " Version " VERSION "\n" \ 14 PACKAGE " Version " VERSION "\n" \
15 "Copyright (c) 2009 Klever Group" 15 "Copyright (c) 2009 Klever Group"
16 16
17int main(int argc,char **argv) try { 17int main(int argc,char **argv) try {
18 18
19 int port = 59278; 19 int port = 59278;
20 20
21 while(true) { 21 while(true) {
22 static struct option opts[] = { 22 static struct option opts[] = {
23 { "help", no_argument, 0, 'h' }, 23 { "help", no_argument, 0, 'h' },
24 { "usage", no_argument, 0, 'h' }, 24 { "usage", no_argument, 0, 'h' },
25 { "version", no_argument, 0, 'V' }, 25 { "version", no_argument, 0, 'V' },
26 { "license", no_argument, 0, 'L' }, 26 { "license", no_argument, 0, 'L' },
27 { "port", required_argument, 0, 'p' }, 27 { "port", required_argument, 0, 'p' },
28 { NULL, 0, 0, 0 } 28 { NULL, 0, 0, 0 }
29 }; 29 };
30 int c = getopt_long(argc,argv,"hVLp:",opts,NULL); 30 int c = getopt_long(argc,argv,"hVLp:",opts,NULL);
31 if(c==-1) break; 31 if(c==-1) break;
32 switch(c) { 32 switch(c) {
33 case 'h': 33 case 'h':
34 std::cerr << PHEADER << std::endl << std::endl 34 std::cerr << PHEADER << std::endl << std::endl
35 << " " << argv[0] << " [options]" << std::endl 35 << " " << argv[0] << " [options]" << std::endl
36 << std::endl << 36 << std::endl <<
37 " -h, --help,\n" 37 " -h, --help,\n"
38 " --usage display this text\n" 38 " --usage display this text\n"
39 " -V, --version display version information\n" 39 " -V, --version display version information\n"
40 " -L, --license show license\n" 40 " -L, --license show license\n"
41 " -p <port>, --port=<port> port to listen to\n" 41 " -p <port>, --port=<port> port to listen to\n"
42 " (you're not likely to ever need it)\n" 42 " (you're not likely to ever need it)\n"
43 << std::endl << std::endl; 43 << std::endl << std::endl;
44 exit(0); 44 exit(0);
45 break; 45 break;
46 case 'V': 46 case 'V':
47 std::cerr << VERSION << std::endl; 47 std::cerr << VERSION << std::endl;
48 exit(0); 48 exit(0);
49 break; 49 break;
50 case 'L': 50 case 'L':
51 extern const char *COPYING; 51 extern const char *COPYING;
52 std::cerr << COPYING << std::endl; 52 std::cerr << COPYING << std::endl;
53 exit(0); 53 exit(0);
54 break; 54 break;
55 case 'p': 55 case 'p':
56 port = strtol(optarg,0,0); 56 port = 0xffff&strtol(optarg,0,0);
57 if(errno) { 57 if(errno) {
58 std::cerr << "Failed to parse port number" << std::endl; 58 std::cerr << "Failed to parse port number" << std::endl;
59 exit(1); 59 exit(1);
60 } 60 }
61 break; 61 break;
62 default: 62 default:
63 std::cerr << "Huh?" << std::endl; 63 std::cerr << "Huh?" << std::endl;
64 exit(1); 64 exit(1);
65 break; 65 break;
66 } 66 }
67 } 67 }
68 68
69 const char *ident = rindex(*argv,'/'); 69 const char *ident = rindex(*argv,'/');
70 if(ident) 70 if(ident)
71 ++ident; 71 ++ident;
72 else 72 else
73 ident = *argv; 73 ident = *argv;
74 openlog(ident,LOG_PERROR|LOG_PID,LOG_DAEMON); 74 openlog(ident,LOG_PERROR|LOG_PID,LOG_DAEMON);
75 syslog(LOG_INFO,"Starting iii eye-fi manager"); 75 syslog(LOG_INFO,"Starting iii eye-fi manager");
76 76
77 eyefiworker().run(port); 77 eyefiworker().run(port);
78 78
79 closelog(); 79 closelog();
80 return 0; 80 return 0;
81} catch(std::exception& e) { 81} catch(std::exception& e) {
82 syslog(LOG_CRIT,"Exiting iii daemon, because of error condition"); 82 syslog(LOG_CRIT,"Exiting iii daemon, because of error condition");
83 syslog(LOG_CRIT,"Exception: %s",e.what()); 83 syslog(LOG_CRIT,"Exception: %s",e.what());
84 return 1; 84 return 1;
85} 85}
86 86