- Timestamp:
- Oct 8, 2010, 12:52:54 AM (10 years ago)
- Location:
- zzuf/trunk
- Files:
-
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/configure.ac
r4676 r4683 12 12 AC_PROG_LIBTOOL 13 13 14 dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right 15 dnl now otherwise it might be set in an obscure if statement. Same thing for 16 dnl PKG_PROG_PKG_CONFIG which needs to be called first. 17 AC_EGREP_CPP(yes, foo) 18 PKG_PROG_PKG_CONFIG() 19 20 dnl Don't let pkg-config fuck our cross-compilation environment 21 m4_pattern_allow([^PKG_CONFIG_LIBDIR$]) 22 if test "$build" != "$host" -a "${PKG_CONFIG_LIBDIR}" = ""; then 23 export PKG_CONFIG_LIBDIR=/dev/null 24 fi 25 14 26 AC_C_INLINE 15 27 AC_C_FUNC … … 23 35 AC_MSG_RESULT($SONAME) 24 36 AC_DEFINE_UNQUOTED(SONAME, "$SONAME", [Define to the libzzuf full name]) 37 38 PKG_CHECK_MODULES(CACA, caca >= 0.99.beta18, 39 [:], 40 [AC_MSG_RESULT(no) 41 AC_MSG_ERROR([you need libcaca version 0.99.beta18 or later])]) 25 42 26 43 # Optimizations … … 46 63 AC_SUBST(DLL_LDFLAGS) 47 64 48 AC_CHECK_HEADERS(windows.h winsock2.h io.h process.h unistd.h inttypes.h stdint.h getopt.hlibc.h malloc.h dlfcn.h regex.h sys/cdefs.h sys/socket.h netinet/in.h arpa/inet.h sys/uio.h aio.h sys/mman.h sys/wait.h sys/resource.h sys/time.h endian.h mach/task.h)65 AC_CHECK_HEADERS(windows.h winsock2.h io.h process.h unistd.h inttypes.h stdint.h libc.h malloc.h dlfcn.h regex.h sys/cdefs.h sys/socket.h netinet/in.h arpa/inet.h sys/uio.h aio.h sys/mman.h sys/wait.h sys/resource.h sys/time.h endian.h mach/task.h) 49 66 50 67 AC_CHECK_FUNCS(setenv waitpid setrlimit gettimeofday fork kill pipe _pipe) … … 162 179 AC_DEFINE_UNQUOTED(ATTRIBUTE_PRINTF(x,y), $ac_v_attribute_printf, [Define to the __printf__ attribute if present]) 163 180 164 ac_cv_have_getopt_long="no"165 AC_CHECK_FUNCS(getopt_long,166 [ac_cv_have_getopt_long="yes"],167 [AC_CHECK_LIB(gnugetopt, getopt_long,168 [ac_cv_have_getopt_long="yes"169 GETOPT_LIBS="${GETOPT_LIBS} -lgnugetopt"])])170 if test "$ac_cv_have_getopt_long" != "no"; then171 AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the `getopt_long' function.)172 fi173 AM_CONDITIONAL(NEED_GETOPT_LONG, test "$ac_cv_have_getopt_long" = "no")174 AC_SUBST(GETOPT_LIBS)175 176 181 AC_CHECK_LIB(m, log, [MATH_LIBS="-lm"]) 177 182 AC_SUBST(MATH_LIBS) -
zzuf/trunk/msvc/config.h
r4676 r4683 50 50 /* #undef HAVE_GETDELIM */ 51 51 /* #undef HAVE_GETLINE */ 52 /* #undef HAVE_GETOPT_H */53 /* #undef HAVE_GETOPT_LONG */54 52 #define HAVE_GETPAGESIZE 1 55 53 /* #undef HAVE_GETTIMEOFDAY */ -
zzuf/trunk/msvc/zzat.vcxproj
r4675 r4683 94 94 </ItemDefinitionGroup> 95 95 <ItemGroup> 96 <ClCompile Include="..\src\mygetopt.c" />97 96 <ClCompile Include="..\src\zzat.c"> 98 97 <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)%(FileName)1.obj</ObjectFileName> … … 101 100 </ItemGroup> 102 101 <ItemGroup> 103 <ClInclude Include="..\src\mygetopt.h" />104 102 <ClInclude Include="config.h" /> 105 103 </ItemGroup> -
zzuf/trunk/msvc/zzuf.vcxproj
r4675 r4683 101 101 <ClInclude Include="..\src\md5.h" /> 102 102 <ClInclude Include="..\src\myfork.h" /> 103 <ClInclude Include="..\src\mygetopt.h" />104 103 <ClInclude Include="..\src\opts.h" /> 105 104 <ClInclude Include="..\src\timer.h" /> … … 113 112 <ClCompile Include="..\src\md5.c" /> 114 113 <ClCompile Include="..\src\myfork.c" /> 115 <ClCompile Include="..\src\mygetopt.c" />116 114 <ClCompile Include="..\src\opts.c" /> 117 115 <ClCompile Include="..\src\timer.c" /> -
zzuf/trunk/src/Makefile.am
r4657 r4683 24 24 common/fuzz.c common/fuzz.h 25 25 26 if NEED_GETOPT_LONG 27 GETOPT = mygetopt.c mygetopt.h 28 endif 29 30 zzuf_SOURCES = $(ZZUF) $(COMMON) $(GETOPT) 26 zzuf_SOURCES = $(ZZUF) $(COMMON) 31 27 zzuf_CFLAGS = -DLIBDIR=\"$(libdir)/zzuf\" -I$(srcdir)/common 32 zzuf_LDFLAGS = $( MATH_LIBS) $(WINSOCK2_LIBS)28 zzuf_LDFLAGS = $(CACA_LIBS) $(MATH_LIBS) $(WINSOCK2_LIBS) 33 29 zzuf_DEPENDENCIES = libzzuf.la 34 30 35 zzat_SOURCES = $(ZZAT) $(GETOPT) 31 zzat_SOURCES = $(ZZAT) 32 zzat_LDFLAGS = $(CACA_LIBS) 36 33 37 34 libzzuf_la_SOURCES = $(LIBZZUF) $(COMMON) 38 35 libzzuf_la_CFLAGS = -DLIBZZUF -I$(srcdir)/libzzuf -I$(srcdir)/common 39 36 libzzuf_la_LDFLAGS = -avoid-version -no-undefined $(DLL_LDFLAGS) 40 libzzuf_la_LIBADD = $( GETOPT_LIBS) $(DL_LIBS) $(MATH_LIBS) $(WINSOCK2_LIBS)37 libzzuf_la_LIBADD = $(DL_LIBS) $(MATH_LIBS) $(WINSOCK2_LIBS) 41 38 42 39 echo-sources: ; echo $(SOURCES) -
zzuf/trunk/src/zzat.c
r4654 r4683 51 51 #include <string.h> 52 52 53 #if !defined HAVE_GETOPT_LONG 54 # include "mygetopt.h" 55 #elif defined HAVE_GETOPT_H 56 # include <getopt.h> 57 #endif 58 59 #if defined HAVE_GETOPT_LONG 60 # define mygetopt getopt_long 61 # define myoptind optind 62 # define myoptarg optarg 63 # define myoption option 64 #endif 53 #include <caca.h> 65 54 66 55 static int run(char const *sequence, char const *file); … … 100 89 #define MOREINFO "Try `%s --help' for more information.\n" 101 90 int option_index = 0; 102 static struct myoption long_options[] =91 static struct caca_option long_options[] = 103 92 { 104 93 { "show-all", 0, NULL, 'A' }, … … 117 106 { NULL, 0, NULL, 0 } 118 107 }; 119 int c = mygetopt(argc, argv, OPTSTR, long_options, &option_index);108 int c = caca_getopt(argc, argv, OPTSTR, long_options, &option_index); 120 109 121 110 if (c == -1) … … 143 132 break; 144 133 case 'r': /* --repeat */ 145 repeat = atoi( myoptarg);134 repeat = atoi(caca_optarg); 146 135 break; 147 136 case 's': /* --squeeze-blank */ … … 158 147 break; 159 148 case 'x': /* --execute */ 160 if ( myoptarg[0] == '=')161 myoptarg++;162 sequence = myoptarg;149 if (caca_optarg[0] == '=') 150 caca_optarg++; 151 sequence = caca_optarg; 163 152 break; 164 153 case 'l': /* --list */ … … 178 167 } 179 168 180 if ( myoptind >= argc)169 if (caca_optind >= argc) 181 170 { 182 171 fprintf(stderr, "E: zzat: too few arguments\n"); … … 185 174 186 175 while (repeat-- > 0) 187 for (i = myoptind; i < argc; i++)176 for (i = caca_optind; i < argc; i++) 188 177 { 189 178 int ret = run(sequence, argv[i]); -
zzuf/trunk/src/zzuf.c
r4669 r4683 24 24 # include <inttypes.h> 25 25 #endif 26 #if !defined HAVE_GETOPT_LONG27 # include "mygetopt.h"28 #elif defined HAVE_GETOPT_H29 # include <getopt.h>30 #endif31 26 #include <stdio.h> 32 27 #include <stdlib.h> … … 55 50 # include <sys/resource.h> /* for RLIMIT_AS */ 56 51 #endif 52 53 #include <caca.h> 57 54 58 55 #include "common.h" … … 65 62 #include "timer.h" 66 63 67 #if defined HAVE_GETOPT_LONG68 # define mygetopt getopt_long69 # define myoptind optind70 # define myoptarg optarg71 # define myoption option72 #endif73 74 64 #if !defined SIGKILL 75 65 # define SIGKILL 9 … … 157 147 #define MOREINFO "Try `%s --help' for more information.\n" 158 148 int option_index = 0; 159 static struct myoption long_options[] =149 static struct caca_option long_options[] = 160 150 { 161 151 /* Long option, needs arg, flag, short option */ … … 200 190 { NULL, 0, NULL, 0 } 201 191 }; 202 int c = mygetopt(argc, argv, OPTSTR, long_options, &option_index);192 int c = caca_getopt(argc, argv, OPTSTR, long_options, &option_index); 203 193 204 194 if(c == -1) … … 208 198 { 209 199 case 'a': /* --allow */ 210 opts->allow = myoptarg;200 opts->allow = caca_optarg; 211 201 break; 212 202 case 'A': /* --autoinc */ … … 214 204 break; 215 205 case 'b': /* --bytes */ 216 opts->bytes = myoptarg;206 opts->bytes = caca_optarg; 217 207 break; 218 208 case 'B': /* --max-bytes */ 219 if( myoptarg[0] == '=')220 myoptarg++;221 opts->maxbytes = atoi( myoptarg);209 if(caca_optarg[0] == '=') 210 caca_optarg++; 211 opts->maxbytes = atoi(caca_optarg); 222 212 break; 223 213 #if defined HAVE_REGEX_H … … 227 217 #endif 228 218 case 'C': /* --max-crashes */ 229 if( myoptarg[0] == '=')230 myoptarg++;231 opts->maxcrashes = atoi( myoptarg);219 if(caca_optarg[0] == '=') 220 caca_optarg++; 221 opts->maxcrashes = atoi(caca_optarg); 232 222 if(opts->maxcrashes <= 0) 233 223 opts->maxcrashes = 0; … … 237 227 break; 238 228 case 'D': /* --delay */ 239 if( myoptarg[0] == '=')240 myoptarg++;241 opts->delay = (int64_t)(atof( myoptarg) * 1000000.0);229 if(caca_optarg[0] == '=') 230 caca_optarg++; 231 opts->delay = (int64_t)(atof(caca_optarg) * 1000000.0); 242 232 break; 243 233 #if defined HAVE_REGEX_H 244 234 case 'E': /* --exclude */ 245 exclude = merge_regex(exclude, myoptarg);235 exclude = merge_regex(exclude, caca_optarg); 246 236 if(!exclude) 247 237 { 248 238 fprintf(stderr, "%s: invalid regex -- `%s'\n", 249 argv[0], myoptarg);239 argv[0], caca_optarg); 250 240 _zz_opts_fini(opts); 251 241 return EXIT_FAILURE; … … 254 244 #endif 255 245 case 'f': /* --fuzzing */ 256 opts->fuzzing = myoptarg;246 opts->fuzzing = caca_optarg; 257 247 break; 258 248 case 'F': … … 265 255 #if defined HAVE_REGEX_H 266 256 case 'I': /* --include */ 267 include = merge_regex(include, myoptarg);257 include = merge_regex(include, caca_optarg); 268 258 if(!include) 269 259 { 270 260 fprintf(stderr, "%s: invalid regex -- `%s'\n", 271 argv[0], myoptarg);261 argv[0], caca_optarg); 272 262 _zz_opts_fini(opts); 273 263 return EXIT_FAILURE; … … 276 266 #endif 277 267 case 'j': /* --jobs */ 278 if( myoptarg[0] == '=')279 myoptarg++;280 opts->maxchild = atoi( myoptarg) > 1 ? atoi(myoptarg) : 1;268 if(caca_optarg[0] == '=') 269 caca_optarg++; 270 opts->maxchild = atoi(caca_optarg) > 1 ? atoi(caca_optarg) : 1; 281 271 break; 282 272 case 'l': /* --list */ 283 opts->list = myoptarg;273 opts->list = caca_optarg; 284 274 break; 285 275 case 'm': /* --md5 */ … … 288 278 #if defined HAVE_SETRLIMIT && defined ZZUF_RLIMIT_MEM 289 279 case 'M': /* --max-memory */ 290 if( myoptarg[0] == '=')291 myoptarg++;292 opts->maxmem = atoi( myoptarg);280 if(caca_optarg[0] == '=') 281 caca_optarg++; 282 opts->maxmem = atoi(caca_optarg); 293 283 break; 294 284 #endif … … 298 288 break; 299 289 case 'O': /* --opmode */ 300 if( myoptarg[0] == '=')301 myoptarg++;302 if (!strcmp( myoptarg, "preload"))290 if(caca_optarg[0] == '=') 291 caca_optarg++; 292 if (!strcmp(caca_optarg, "preload")) 303 293 opts->opmode = OPMODE_PRELOAD; 304 else if (!strcmp( myoptarg, "copy"))294 else if (!strcmp(caca_optarg, "copy")) 305 295 opts->opmode = OPMODE_COPY; 306 296 else 307 297 { 308 298 fprintf(stderr, "%s: invalid operating mode -- `%s'\n", 309 argv[0], myoptarg);299 argv[0], caca_optarg); 310 300 _zz_opts_fini(opts); 311 301 return EXIT_FAILURE; … … 313 303 break; 314 304 case 'p': /* --ports */ 315 opts->ports = myoptarg;305 opts->ports = caca_optarg; 316 306 break; 317 307 case 'P': /* --protect */ 318 opts->protect = myoptarg;308 opts->protect = caca_optarg; 319 309 break; 320 310 case 'q': /* --quiet */ … … 322 312 break; 323 313 case 'r': /* --ratio */ 324 if( myoptarg[0] == '=')325 myoptarg++;326 tmp = strchr( myoptarg, ':');327 opts->minratio = atof( myoptarg);314 if(caca_optarg[0] == '=') 315 caca_optarg++; 316 tmp = strchr(caca_optarg, ':'); 317 opts->minratio = atof(caca_optarg); 328 318 opts->maxratio = tmp ? atof(tmp + 1) : opts->minratio; 329 319 break; 330 320 case 'R': /* --refuse */ 331 opts->refuse = myoptarg;321 opts->refuse = caca_optarg; 332 322 break; 333 323 case 's': /* --seed */ 334 if( myoptarg[0] == '=')335 myoptarg++;336 tmp = strchr( myoptarg, ':');337 opts->seed = atol( myoptarg);324 if(caca_optarg[0] == '=') 325 caca_optarg++; 326 tmp = strchr(caca_optarg, ':'); 327 opts->seed = atol(caca_optarg); 338 328 opts->endseed = tmp ? tmp[1] ? (uint32_t)atol(tmp + 1) 339 329 : (uint32_t)-1L … … 344 334 break; 345 335 case 't': /* --max-time */ 346 if( myoptarg[0] == '=')347 myoptarg++;348 opts->maxtime = (int64_t)atoi( myoptarg) * 1000000;336 if(caca_optarg[0] == '=') 337 caca_optarg++; 338 opts->maxtime = (int64_t)atoi(caca_optarg) * 1000000; 349 339 break; 350 340 #if defined HAVE_SETRLIMIT && defined ZZUF_RLIMIT_CPU 351 341 case 'T': /* --max-cputime */ 352 if( myoptarg[0] == '=')353 myoptarg++;354 opts->maxcpu = (int)(atof( myoptarg) + 0.5);342 if(caca_optarg[0] == '=') 343 caca_optarg++; 344 opts->maxcpu = (int)(atof(caca_optarg) + 0.5); 355 345 break; 356 346 #endif 357 347 case 'U': /* --max-usertime */ 358 if( myoptarg[0] == '=')359 myoptarg++;360 opts->maxusertime = (int64_t)(atof( myoptarg) * 1000000.0);348 if(caca_optarg[0] == '=') 349 caca_optarg++; 350 opts->maxusertime = (int64_t)(atof(caca_optarg) * 1000000.0); 361 351 break; 362 352 case 'x': /* --check-exit */ … … 420 410 * Mode 1: asked to read from the standard input 421 411 */ 422 if( myoptind >= argc)412 if(caca_optind >= argc) 423 413 { 424 414 if(opts->verbose) … … 449 439 int dashdash = 0; 450 440 451 for(i = myoptind + 1; i < argc; i++)441 for(i = caca_optind + 1; i < argc; i++) 452 442 { 453 443 if(dashdash) … … 504 494 for(i = 0; i < opts->maxchild; i++) 505 495 { 506 int len = argc - myoptind;496 int len = argc - caca_optind; 507 497 opts->child[i].newargv = malloc((len + 1) * sizeof(char *)); 508 memcpy(opts->child[i].newargv, argv + myoptind,498 memcpy(opts->child[i].newargv, argv + caca_optind, 509 499 len * sizeof(char *)); 510 500 opts->child[i].newargv[len] = (char *)NULL; … … 705 695 tmpdir = "/tmp"; 706 696 707 for (j = myoptind + 1; j < opts->oldargc; j++)697 for (j = caca_optind + 1; j < opts->oldargc; j++) 708 698 { 709 699 fpin = fopen(opts->oldargv[j], "r"); … … 723 713 } 724 714 725 opts->child[i].newargv[j - myoptind] = strdup(tmpname);715 opts->child[i].newargv[j - caca_optind] = strdup(tmpname); 726 716 727 717 _zz_register(k); … … 898 888 if (opts->opmode == OPMODE_COPY) 899 889 { 900 for (j = myoptind + 1; j < opts->oldargc; j++)890 for (j = caca_optind + 1; j < opts->oldargc; j++) 901 891 { 902 if (opts->child[i].newargv[j - myoptind] != opts->oldargv[j])892 if (opts->child[i].newargv[j - caca_optind] != opts->oldargv[j]) 903 893 { 904 unlink(opts->child[i].newargv[j - myoptind]);905 free(opts->child[i].newargv[j - myoptind]);906 opts->child[i].newargv[j - myoptind] = opts->oldargv[j];894 unlink(opts->child[i].newargv[j - caca_optind]); 895 free(opts->child[i].newargv[j - caca_optind]); 896 opts->child[i].newargv[j - caca_optind] = opts->oldargv[j]; 907 897 } 908 898 }
Note: See TracChangeset
for help on using the changeset viewer.