blob: b7c984b3123318153654c1ae0af4747d02792f92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/* PPSWrapper
* Copyright (C) 2009- Luo Jinghua <sunmoon1997@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more
*/
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include "pps-fixed.h"
#include "ppswrapper.h"
int main(int argc, char **argv)
{
ppsw_t* ppsw;
int ret;
int c;
int fd = -1;
int port = -1;
int infinit = 0;
extern char *optarg;
extern int optind, optopt;
while ((c = getopt (argc, argv, "f:p:d")) != -1) {
switch(c) {
case 'f':
fd = atoi (optarg);
break;
case 'p':
port = atoi (optarg);
break;
case 'd':
infinit = 1;
default:
break;
}
}
if (fd < 0 && port < 0) {
fprintf(stderr, "expect a port or a fd\n");
return -1;
}
signal (SIGPIPE, SIG_IGN);
ret = chdir ("/tmp/");
ppsw = ppsw_server_create(fd, port);
if (!ppsw) {
fprintf(stderr, "Create server failed\n");
return -1;
}
ppsw_server_run(ppsw, infinit);
ppsw_server_destroy(ppsw);
return 0;
}
|