![]() |
Sockets-config.cpp File Reference#include <stdio.h> #include <string.h> #include "sockets-config.h" #include <map> #include <string> #include <cstdlib>
Include dependency graph for Sockets-config.cpp:
![]() Go to the source code of this file.
Detailed Description
Definition in file Sockets-config.cpp. Function Documentation
Definition at line 364 of file Sockets-config.cpp. References any_set, quiet, replace_makefile(), set_namespace(), set_platform(), setup_configuration(), show_configuration(), and show_info(). 00365 { 00366 bool info = false; 00367 bool usage = false; 00368 setup_configuration(); 00369 for (int i = 1; i < argc; i++) 00370 if (!strcmp(argv[i], "-info")) 00371 info = true; 00372 else 00373 if (!strncmp(argv[i], "--enable-", 9)) 00374 set(&argv[i][9], true); 00375 else 00376 if (!strncmp(argv[i], "--disable-", 10)) 00377 set(&argv[i][10], false); 00378 else 00379 if (!strncmp(argv[i], "--platform=", 11)) 00380 set_platform(&argv[i][11]); 00381 else 00382 if (!strncmp(argv[i], "--name=", 7)) 00383 replace_makefile("NAME", &argv[i][7]); 00384 else 00385 if (!strncmp(argv[i], "--prefix=", 9)) 00386 replace_makefile("PREFIX", &argv[i][9]); 00387 else 00388 if (!strncmp(argv[i], "--namespace=", 12)) 00389 set_namespace(&argv[i][12]); 00390 else 00391 if (!strcmp(argv[i], "-v")) 00392 any_set = true; 00393 else 00394 if (!strcmp(argv[i], "-q")) 00395 quiet = true; 00396 else 00397 if (*argv[i] == '-') 00398 { 00399 fprintf(stderr, "Unknown command line option: %s\n", argv[i]); 00400 usage = true; 00401 } 00402 else 00403 usage = true; 00404 if (usage) 00405 { 00406 fprintf(stderr, "Usage: %s [-info] [-v] [-h] [--platform=PLATFORM] [--prefix=<path>] [--name=<Name>] [--namespace=<ns>] [--enable-OPTION] [--disable-OPTION]\n", *argv); 00407 fprintf(stderr, "\n"); 00408 fprintf(stderr, "Options (default value)\n"); 00409 fprintf(stderr, "\n"); 00410 fprintf(stderr, " -info Show compiled options\n"); 00411 fprintf(stderr, " -v Show configuration options\n"); 00412 fprintf(stderr, " -q Don't show extra info\n"); 00413 fprintf(stderr, " -h Show this help\n"); 00414 fprintf(stderr, "\n"); 00415 fprintf(stderr, " --platform= Select target platform\n"); 00416 fprintf(stderr, " --prefix= Set installation path (/usr/local/$NAME)\n"); 00417 fprintf(stderr, " --name= Set library name (Sockets)\n"); 00418 fprintf(stderr, " --namespace= Set C++ namespace for entire library\n"); 00419 fprintf(stderr, "\n"); 00420 fprintf(stderr, "Defined platforms\n"); 00421 fprintf(stderr, "\n"); 00422 fprintf(stderr, " linux-x86-32\n"); 00423 fprintf(stderr, " linux-x86-64\n"); 00424 fprintf(stderr, " win32-cygwin\n"); 00425 fprintf(stderr, " solaris9-sparc-64\n"); 00426 fprintf(stderr, " macosx\n"); 00427 fprintf(stderr, " solaris8\n"); 00428 fprintf(stderr, "\n"); 00429 fprintf(stderr, "Possible OPTION values:\n"); 00430 fprintf(stderr, "\n"); 00431 fprintf(stderr, " openssl Enable openssl library\n"); 00432 fprintf(stderr, " ipv6 Add ipv6 support\n"); 00433 fprintf(stderr, " sctp Add SCTP support\n"); 00434 fprintf(stderr, " no_addrinfo Do not use addrinfo API for dns requests\n"); 00435 fprintf(stderr, " pool Enable client connection pool\n"); 00436 fprintf(stderr, " socks4 Enable socks4 client support\n"); 00437 fprintf(stderr, " resolver Enable asynchronous dns\n"); 00438 fprintf(stderr, " reconnect Enable tcp reconnect\n"); 00439 fprintf(stderr, " detach Enable detach functionality\n"); 00440 fprintf(stderr, " exceptions Enable C++ exceptions on some error conditions\n"); 00441 fprintf(stderr, " xml2 Enable libxml2 support\n"); 00442 fprintf(stderr, "\n"); 00443 fprintf(stderr, "Use with no options to show platform configuration options in CFLAGS format.\n"); 00444 return 0; 00445 } 00446 if (argc > 1 && info) 00447 { 00448 show_info(); 00449 return 0; 00450 } 00451 if (any_set) 00452 { 00453 if (!quiet) 00454 show_configuration(); 00455 return 0; 00456 } 00457 printf(" -D_VERSION='\"%s\"'", _VERSION); 00458 00459 #ifdef LINUX 00460 printf(" -DLINUX"); 00461 #endif 00462 #ifdef MACOSX 00463 printf(" -DMACOSX"); 00464 #endif 00465 #ifdef SOLARIS 00466 printf(" -DSOLARIS"); 00467 #endif 00468 #ifdef SOLARIS8 00469 printf(" -DSOLARIS8"); 00470 #endif 00471 #ifdef _WIN32 00472 printf(" -D_WIN32"); 00473 #endif 00474 #ifdef __CYGWIN__ 00475 printf(" -D__CYGWIN__"); 00476 #endif 00477 #ifdef SOCKETS_NAMESPACE 00478 printf(" -DSOCKETS_NAMESPACE=%s", SOCKETS_NAMESPACE_STR); 00479 #endif 00480 #ifdef _DEBUG 00481 printf(" -D_DEBUG"); 00482 #endif 00483 00484 }
Definition at line 242 of file Sockets-config.cpp. References any_set. Referenced by main(), and set_platform(). 00243 { 00244 FILE *fil = fopen("Makefile", "rt"); 00245 if (!fil) 00246 { 00247 fprintf(stderr, "Can't read file: Makefile, aborting\n"); 00248 exit(-5); 00249 } 00250 FILE *fil2 = fopen("Makefile.tmp", "wt"); 00251 if (!fil2) 00252 { 00253 fprintf(stderr, "Can't write to file: Makefile.tmp, aborting\n"); 00254 exit(-6); 00255 } 00256 char slask[1000]; 00257 fgets(slask, 1000, fil); 00258 while (!feof(fil)) 00259 { 00260 while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10)) 00261 slask[strlen(slask) - 1] = 0; 00262 if (!strncmp(slask, name.c_str(), name.size()) && slask[name.size()] == 32) 00263 { 00264 if (name.size() < 6) 00265 fprintf(fil2, "%s =\t\t%s\n", name.c_str(), value.c_str()); 00266 else 00267 fprintf(fil2, "%s =\t%s\n", name.c_str(), value.c_str()); 00268 } 00269 else 00270 { 00271 fprintf(fil2, "%s\n", slask); 00272 } 00273 fgets(slask, 1000, fil); 00274 } 00275 fclose(fil); 00276 fclose(fil2); 00277 rename("Makefile.tmp", "Makefile"); 00278 any_set = true; 00279 }
Definition at line 129 of file Sockets-config.cpp. 00130 { 00131 std::map<std::string, std::string>::iterator it = mmap.find(param); 00132 if (it == mmap.end()) 00133 { 00134 fprintf(stderr, "Option '%s' not found, aborting\n", param); 00135 exit(-1); 00136 } 00137 FILE *fil = fopen("sockets-config.h", "rt"); 00138 if (!fil) 00139 { 00140 fprintf(stderr, "Can't open configuration file 'sockets-config.h', aborting\n"); 00141 exit(-2); 00142 } 00143 FILE *fil2 = fopen("sockets-config.h.tmp", "wt"); 00144 if (!fil2) 00145 { 00146 fprintf(stderr, "Can't write to temporary configuration file, aborting\n"); 00147 exit(-3); 00148 } 00149 char slask[1000]; 00150 fgets(slask, 1000, fil); 00151 while (!feof(fil)) 00152 { 00153 bool replaced = false; 00154 while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10)) 00155 slask[strlen(slask) - 1] = 0; 00156 if (!strncmp(slask, "#define ", 8) || 00157 !strncmp(slask, "//#define ", 10)) 00158 { 00159 int i = (*slask == '#') ? 8 : 10; 00160 if (!strncmp(slask + i, it -> second.c_str(), it -> second.size())) 00161 { 00162 if (!enable) 00163 fprintf(fil2, "//"); 00164 fprintf(fil2, "#define %s\n", it -> second.c_str()); 00165 replaced = true; 00166 } 00167 } 00168 if (!replaced) 00169 fprintf(fil2, "%s\n", slask); 00170 // 00171 fgets(slask, 1000, fil); 00172 } 00173 fclose(fil); 00174 fclose(fil2); 00175 #ifdef _WIN32 00176 unlink("sockets-config.h"); 00177 #endif 00178 rename("sockets-config.h.tmp", "sockets-config.h"); 00179 any_set = true; 00180 }
Definition at line 308 of file Sockets-config.cpp. References any_set. Referenced by main(). 00309 { 00310 /* 00311 # uncomment these lines if the library should be in its own namespace 00312 #CFLAGS += -DSOCKETS_NAMESPACE=sockets 00313 #CFLAGS += -DSOCKETS_NAMESPACE_STR='"sockets"' 00314 */ 00315 bool found = false; 00316 bool set = false; 00317 FILE *fil = fopen("Makefile", "rt"); 00318 if (!fil) 00319 { 00320 fprintf(stderr, "Can't read file: Makefile, aborting\n"); 00321 exit(-8); 00322 } 00323 FILE *fil2 = fopen("Makefile.tmp", "wt"); 00324 if (!fil2) 00325 { 00326 fprintf(stderr, "Can't write to file: Makefile.tmp, aborting\n"); 00327 exit(-9); 00328 } 00329 char slask[1000]; 00330 fgets(slask, 1000, fil); 00331 while (!feof(fil)) 00332 { 00333 while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10)) 00334 slask[strlen(slask) - 1] = 0; 00335 if (strstr(slask, "SOCKETS_NAMESPACE")) 00336 { 00337 if (*slask == '#') 00338 fprintf(fil2, "%s\n", slask); 00339 else 00340 fprintf(fil2, "# %s\n", slask); 00341 found = true; 00342 } 00343 else 00344 if (found && !set) 00345 { 00346 fprintf(fil2, "CFLAGS +=\t-DSOCKETS_NAMESPACE=%s\n", ns); 00347 fprintf(fil2, "CFLAGS +=\t-DSOCKETS_NAMESPACE_STR='\"%s\"'\n", ns); 00348 fprintf(fil2, "%s\n", slask); 00349 set = true; 00350 } 00351 else 00352 { 00353 fprintf(fil2, "%s\n", slask); 00354 } 00355 fgets(slask, 1000, fil); 00356 } 00357 fclose(fil); 00358 fclose(fil2); 00359 rename("Makefile.tmp", "Makefile"); 00360 any_set = true; 00361 }
Definition at line 294 of file Sockets-config.cpp. References replace_makefile(). Referenced by main(). 00295 { 00296 if (!strcmp(platform, "linux-x86-32") || 00297 !strcmp(platform, "linux-x86-64") || 00298 !strcmp(platform, "win32-cygwin") || 00299 !strcmp(platform, "solaris9-sparc-64") || 00300 !strcmp(platform, "macosx") || 00301 !strcmp(platform, "solaris8")) 00302 { 00303 replace_makefile("PLATFORM", platform); 00304 } 00305 }
Definition at line 113 of file Sockets-config.cpp. References mmap. Referenced by main(). 00114 { 00115 mmap["openssl"] = "HAVE_OPENSSL"; 00116 mmap["ipv6"] = "ENABLE_IPV6"; 00117 mmap["sctp"] = "USE_SCTP"; 00118 mmap["no_addrinfo"] = "NO_GETADDRINFO"; 00119 mmap["pool"] = "ENABLE_POOL"; 00120 mmap["socks4"] = "ENABLE_SOCKS4"; 00121 mmap["resolver"] = "ENABLE_RESOLVER"; 00122 mmap["reconnect"] = "ENABLE_RECONNECT"; 00123 mmap["detach"] = "ENABLE_DETACH"; 00124 mmap["exceptions"] = "ENABLE_EXCEPTIONS"; 00125 mmap["xml2"] = "ENABLE_XML"; 00126 }
Definition at line 183 of file Sockets-config.cpp. References mmap. Referenced by main(). 00184 { 00185 printf("Library options (sockets-config.h)\n"); 00186 FILE *fil = fopen("sockets-config.h", "rt"); 00187 if (!fil) 00188 { 00189 fprintf(stderr, "Can't open configuration file 'sockets-config.h', aborting\n"); 00190 exit(-4); 00191 } 00192 char slask[1000]; 00193 fgets(slask, 1000, fil); 00194 while (!feof(fil)) 00195 { 00196 while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10)) 00197 slask[strlen(slask) - 1] = 0; 00198 if (!strncmp(slask, "#define ", 8) || 00199 !strncmp(slask, "//#define ", 10)) 00200 { 00201 int i = (*slask == '#') ? 8 : 10; 00202 std::string def(&slask[i]); 00203 for (std::map<std::string, std::string>::iterator it = mmap.begin(); it != mmap.end(); it++) 00204 { 00205 if (def == it -> second) 00206 { 00207 std::string tmp(it -> first); 00208 tmp += " "; 00209 while (tmp.size() < 15) 00210 tmp += "."; 00211 printf("%s %s\n", tmp.c_str(), (*slask == '#') ? "ENABLED" : "DISABLED"); 00212 } 00213 } 00214 } 00215 fgets(slask, 1000, fil); 00216 } 00217 fclose(fil); 00218 printf("Build options (Makefile)\n"); 00219 fil = fopen("Makefile", "rt"); 00220 if (!fil) 00221 { 00222 fprintf(stderr, "Can't read file: Makefile, aborting\n"); 00223 exit(-7); 00224 } 00225 fgets(slask, 1000, fil); 00226 while (!feof(fil)) 00227 { 00228 while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10)) 00229 slask[strlen(slask) - 1] = 0; 00230 if (!strncmp(slask, "PLATFORM ", 9) || 00231 !strncmp(slask, "PREFIX ", 7) || 00232 (strstr(slask, "SOCKETS_NAMESPACE") && *slask != '#') || 00233 !strncmp(slask, "NAME ", 5) 00234 ) 00235 printf("%s\n", slask); 00236 fgets(slask, 1000, fil); 00237 } 00238 fclose(fil); 00239 }
Definition at line 37 of file Sockets-config.cpp. Referenced by main(). 00038 { 00039 #ifdef HAVE_OPENSSL 00040 printf("SSL support\n"); 00041 #endif 00042 #ifdef IPPROTO_IPV6 00043 printf("IPv6 support\n"); 00044 #endif 00045 #ifdef USE_SCTP 00046 #ifdef IPPROTO_SCTP 00047 printf("SCTP support\n"); 00048 # ifdef HAVE_SCTP 00049 printf(" HAVE_SCTP: yes\n"); 00050 # else 00051 printf(" HAVE_SCTP: no\n"); 00052 # endif 00053 # ifdef HAVE_KERNEL_SCTP 00054 printf(" HAVE_KERNEL_SCTP: yes\n"); 00055 # else 00056 printf(" HAVE_KERNEL_SCTP: no\n"); 00057 # endif 00058 # ifdef HAVE_SCTP_PRSCTP 00059 printf(" HAVE_SCTP_PRSCTP: yes\n"); 00060 # else 00061 printf(" HAVE_SCTP_PRSCTP: no\n"); 00062 # endif 00063 # ifdef HAVE_SCTP_ADDIP 00064 printf(" HAVE_SCTP_ADDIP: yes\n"); 00065 # else 00066 printf(" HAVE_SCTP_ADDIP: no\n"); 00067 # endif 00068 # ifdef HAVE_SCTP_CANSET_PRIMARY 00069 printf(" HAVE_SCTP_CANSETPRIMARY: yes\n"); 00070 # else 00071 printf(" HAVE_SCTP_CANSETPRIMARY: no\n"); 00072 # endif 00073 # ifdef HAVE_SCTP_SAT_NETWORK_CAPABILITY 00074 printf(" HAVE_SCTP_SAT_NETWORK_CAPABILITY: yes\n"); 00075 # else 00076 printf(" HAVE_SCTP_SAT_NETWORK_CAPABILITY: no\n"); 00077 # endif 00078 # ifdef HAVE_SCTP_MULTIBUF 00079 printf(" HAVE_SCTP_MULTIBUF: yes\n"); 00080 # else 00081 printf(" HAVE_SCTP_MULTIBUF: no\n"); 00082 # endif 00083 # ifdef HAVE_SCTP_NOCONNECT 00084 printf(" HAVE_SCTP_NOCONNECT: yes\n"); 00085 # else 00086 printf(" HAVE_SCTP_NOCONNECT: no\n"); 00087 # endif 00088 # ifdef HAVE_SCTP_EXT_RCVINFO 00089 printf(" HAVE_SCTP_EXT_RCVINFO: yes\n"); 00090 # else 00091 printf(" HAVE_SCTP_EXT_RCVINFO: no\n"); 00092 # endif 00093 #else 00094 printf("No SCTP support\n"); 00095 #endif 00096 #endif 00097 }
Variable Documentation
Definition at line 32 of file Sockets-config.cpp. Referenced by main(), replace_makefile(), set(), and set_namespace().
Definition at line 33 of file Sockets-config.cpp. Referenced by set(), setup_configuration(), and show_configuration().
|