annotate src/run.combined.c @ 55:5685fad38195

Fixed compiler warnings from clang (including small bug in private key loading)
author Ivo Smits <Ivo@UCIS.nl>
date Fri, 31 Jan 2014 22:52:46 +0100
parents c8d176154d7c
children 66d9d80215f0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
1 /* Copyright 2010 Ivo Smits <Ivo@UCIS.nl>. All rights reserved.
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
2 Redistribution and use in source and binary forms, with or without modification, are
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
3 permitted provided that the following conditions are met:
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
4
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
5 1. Redistributions of source code must retain the above copyright notice, this list of
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
6 conditions and the following disclaimer.
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
7
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
8 2. Redistributions in binary form must reproduce the above copyright notice, this list
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
9 of conditions and the following disclaimer in the documentation and/or other materials
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
10 provided with the distribution.
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
11
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
12 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
13 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
15 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
16 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
17 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
18 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
19 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
20 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
21
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
22 The views and conclusions contained in the software and documentation are those of the
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
23 authors and should not be interpreted as representing official policies, either expressed
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
24 or implied, of Ivo Smits.*/
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
25
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
26 #include "common.c"
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
27
30
6f0e6b7dc088 Fixed build script to support multiple abis on one machine, bugfix in code, minor improvements
Ivo Smits <Ivo@UCIS.nl>
parents: 27
diff changeset
28 extern struct qtproto qtproto_raw;
6f0e6b7dc088 Fixed build script to support multiple abis on one machine, bugfix in code, minor improvements
Ivo Smits <Ivo@UCIS.nl>
parents: 27
diff changeset
29 extern struct qtproto qtproto_nacl0;
6f0e6b7dc088 Fixed build script to support multiple abis on one machine, bugfix in code, minor improvements
Ivo Smits <Ivo@UCIS.nl>
parents: 27
diff changeset
30 extern struct qtproto qtproto_nacltai;
42
c8d176154d7c Added salty protocol (stateful, little overhead, PFS)
Ivo Smits <Ivo@UCIS.nl>
parents: 38
diff changeset
31 extern struct qtproto qtproto_salty;
27
5ba185ca7102 Fixed error checking during initialization, restructured code a bit to make it even simpler
Ivo Smits <Ivo@UCIS.nl>
parents: 0
diff changeset
32
0
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
33 #ifdef DEBIAN_BINARY
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
34 char* getenvdeb(const char* name) {
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
35 char tmp[1024] = "IF_QT_";
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
36 if (strcmp(name, "INTERFACE") == 0) return getenv("IFACE");
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
37 if (strlen(tmp) + strlen(name) >= 1024) {
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
38 fprintf(stderr, "Error: prefixed environment variable name is too long");
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
39 return NULL;
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
40 }
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
41 strcat(tmp, name);
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
42 return getenv(tmp);
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
43 }
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
44 #endif
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
45
38
d9f5caa13898 Added support for NetBSD, added command line parsing to provide configuration options
Ivo Smits <Ivo@UCIS.nl>
parents: 30
diff changeset
46 int main(int argc, char** argv) {
0
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
47 print_header();
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
48 #ifdef DEBIAN_BINARY
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
49 getconf = getenvdeb;
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
50 #else
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
51 getconf = getenv;
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
52 #endif
38
d9f5caa13898 Added support for NetBSD, added command line parsing to provide configuration options
Ivo Smits <Ivo@UCIS.nl>
parents: 30
diff changeset
53 if (qtprocessargs(argc, argv) < 0) return -1;
0
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
54 char* envval;
55
5685fad38195 Fixed compiler warnings from clang (including small bug in private key loading)
Ivo Smits <Ivo@UCIS.nl>
parents: 42
diff changeset
55 if ((envval = getconf("PROTOCOL"))) {
0
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
56 if (strcmp(envval, "raw") == 0) {
27
5ba185ca7102 Fixed error checking during initialization, restructured code a bit to make it even simpler
Ivo Smits <Ivo@UCIS.nl>
parents: 0
diff changeset
57 return qtrun(&qtproto_raw);
0
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
58 } else if (strcmp(envval, "nacl0") == 0) {
27
5ba185ca7102 Fixed error checking during initialization, restructured code a bit to make it even simpler
Ivo Smits <Ivo@UCIS.nl>
parents: 0
diff changeset
59 return qtrun(&qtproto_nacl0);
0
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
60 } else if (strcmp(envval, "nacltai") == 0) {
27
5ba185ca7102 Fixed error checking during initialization, restructured code a bit to make it even simpler
Ivo Smits <Ivo@UCIS.nl>
parents: 0
diff changeset
61 return qtrun(&qtproto_nacltai);
42
c8d176154d7c Added salty protocol (stateful, little overhead, PFS)
Ivo Smits <Ivo@UCIS.nl>
parents: 38
diff changeset
62 } else if (strcmp(envval, "salty") == 0) {
c8d176154d7c Added salty protocol (stateful, little overhead, PFS)
Ivo Smits <Ivo@UCIS.nl>
parents: 38
diff changeset
63 return qtrun(&qtproto_salty);
0
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
64 } else {
38
d9f5caa13898 Added support for NetBSD, added command line parsing to provide configuration options
Ivo Smits <Ivo@UCIS.nl>
parents: 30
diff changeset
65 return errorexit("Unknown PROTOCOL specified");
0
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
66 }
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
67 } else if (getconf("PRIVATE_KEY")) {
38
d9f5caa13898 Added support for NetBSD, added command line parsing to provide configuration options
Ivo Smits <Ivo@UCIS.nl>
parents: 30
diff changeset
68 fprintf(stderr, "Warning: PROTOCOL not specified, using insecure nacl0 protocol\n");
27
5ba185ca7102 Fixed error checking during initialization, restructured code a bit to make it even simpler
Ivo Smits <Ivo@UCIS.nl>
parents: 0
diff changeset
69 return qtrun(&qtproto_nacl0);
0
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
70 } else {
38
d9f5caa13898 Added support for NetBSD, added command line parsing to provide configuration options
Ivo Smits <Ivo@UCIS.nl>
parents: 30
diff changeset
71 fprintf(stderr, "Warning: PROTOCOL not specified, using insecure raw protocol\n");
27
5ba185ca7102 Fixed error checking during initialization, restructured code a bit to make it even simpler
Ivo Smits <Ivo@UCIS.nl>
parents: 0
diff changeset
72 return qtrun(&qtproto_raw);
0
65c01f57bdce Initial commit
ivo <ivo@UFO-Net.nl>
parents:
diff changeset
73 }
27
5ba185ca7102 Fixed error checking during initialization, restructured code a bit to make it even simpler
Ivo Smits <Ivo@UCIS.nl>
parents: 0
diff changeset
74 }
30
6f0e6b7dc088 Fixed build script to support multiple abis on one machine, bugfix in code, minor improvements
Ivo Smits <Ivo@UCIS.nl>
parents: 27
diff changeset
75