comparison src/run.combined.c @ 27:5ba185ca7102

Fixed error checking during initialization, restructured code a bit to make it even simpler
author Ivo Smits <Ivo@UCIS.nl>
date Sat, 09 Apr 2011 17:36:48 +0200
parents 65c01f57bdce
children 6f0e6b7dc088
comparison
equal deleted inserted replaced
26:68c67c6d2080 27:5ba185ca7102
23 authors and should not be interpreted as representing official policies, either expressed 23 authors and should not be interpreted as representing official policies, either expressed
24 or implied, of Ivo Smits.*/ 24 or implied, of Ivo Smits.*/
25 25
26 #include "common.c" 26 #include "common.c"
27 27
28 struct qtproto qtproto_raw;
29 struct qtproto qtproto_nacl0;
30 struct qtproto qtproto_nacltai;
31
28 #ifdef DEBIAN_BINARY 32 #ifdef DEBIAN_BINARY
29 char* getenvdeb(const char* name) { 33 char* getenvdeb(const char* name) {
30 char tmp[1024] = "IF_QT_"; 34 char tmp[1024] = "IF_QT_";
31 if (strcmp(name, "INTERFACE") == 0) return getenv("IFACE"); 35 if (strcmp(name, "INTERFACE") == 0) return getenv("IFACE");
32 if (strlen(tmp) + strlen(name) >= 1024) { 36 if (strlen(tmp) + strlen(name) >= 1024) {
46 getconf = getenv; 50 getconf = getenv;
47 #endif 51 #endif
48 char* envval; 52 char* envval;
49 if (envval = getconf("PROTOCOL")) { 53 if (envval = getconf("PROTOCOL")) {
50 if (strcmp(envval, "raw") == 0) { 54 if (strcmp(envval, "raw") == 0) {
51 return tunmain_raw(); 55 return qtrun(&qtproto_raw);
52 } else if (strcmp(envval, "nacl0") == 0) { 56 } else if (strcmp(envval, "nacl0") == 0) {
53 return tunmain_nacl0(); 57 return qtrun(&qtproto_nacl0);
54 } else if (strcmp(envval, "nacltai") == 0) { 58 } else if (strcmp(envval, "nacltai") == 0) {
55 return tunmain_nacltai(); 59 return qtrun(&qtproto_nacltai);
56 } else { 60 } else {
57 fprintf(stderr, "Unknown protocol specified: %s\n", envval); 61 fprintf(stderr, "Unknown protocol specified: %s\n", envval);
58 return -1; 62 return -1;
59 } 63 }
60 } else if (getconf("PRIVATE_KEY")) { 64 } else if (getconf("PRIVATE_KEY")) {
61 return tunmain_nacl0(); 65 return qtrun(&qtproto_nacl0);
62 } else { 66 } else {
63 return tunmain_raw(); 67 return qtrun(&qtproto_raw);
64 } 68 }
65 } 69 }