Codebase list admesh / ee327e7
Imported Upstream version 0.96 Anton Gladky 10 years ago
21 changed file(s) with 308 addition(s) and 1971 deletion(s). Raw diff Collapse all Expand all
346346 After ADMesh has processed a mesh, it prints out a page of information about
347347 that mesh. The output looks like the following:
348348
349 ================= Results produced by ADMesh version 0.95 =================
349 ================= Results produced by ADMesh version 0.96 =================
350350 Input file : sphere.stl
351351 File type : Binary STL file
352 Header : Processed by ADMesh version 0.95
352 Header : Processed by ADMesh version 0.96
353353 ============== Size ==============
354354 Min X = -1.334557, Max X = 1.370952
355355 Min Y = -1.377953, Max Y = 1.377230
383383 file and ASCII STL file. ADMesh automatically detect the type of input
384384 file.
385385
386 Header : Processed by ADMesh version 0.95
386 Header : Processed by ADMesh version 0.96
387387 The first 80 characters of the STL file. The first 80 bytes of a binary
388388 STL file or the first line of an ASCII STL file can contain some text.
389389 Usually, the CAD system that has created that file, or the last program
0 Anthony Martin <amartin@engr.csulb.edu>, the full source code; 1995, 1996
1 Andy Doucette <andy@printathing.com>, bug-fixes; 2013
2 Anton Gladky <gladk@debian.org>, switch to cmake; 2013
0 PROJECT(admesh C)
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
2
3 INCLUDE(GNUInstallDirs)
4 #===========================================================
5 IF(NOT(CMAKE_C_FLAGS))
6 SET(CMAKE_BUILD_TYPE Release)
7 SET(CMAKE_C_FLAGS "-Wall -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2")
8 ENDIF (NOT(CMAKE_C_FLAGS))
9 #===========================================================
10 FIND_LIBRARY(M_LIB m)
11 #===========================================================
12 ADD_EXECUTABLE(admesh admesh.c connect.c stl_io.c stlinit.c util.c normals.c shared.c)
13 TARGET_LINK_LIBRARIES(admesh ${M_LIB})
14 INSTALL(TARGETS admesh DESTINATION ${CMAKE_INSTALL_BINDIR})
15 #===========================================================
16 INSTALL(FILES ADMESH.DOC block.stl DESTINATION ${CMAKE_INSTALL_DOCDIR})
17 INSTALL(FILES admesh.1 DESTINATION ${CMAKE_INSTALL_MANDIR})
18 #===========================================================
00 Tue Aug 1 03:25:46 PDT 1995 Anthony Martin <amartin@engr.csulb.edu>
11
22 * Fix it so that big endian systems write a little endian file
3 Also, write null characters after the label in stl_write_binary
3 Also, write null characters after the label in stl_write_binary
44
55 Tue Aug 1 03:25:46 PDT 1995 Anthony Martin <amartin@engr.csulb.edu>
66
77 * Change stl_fill_holes so that duplicate facets are not likely
8 to be generated. Should improve quality of filled holes.
8 to be generated. Should improve quality of filled holes.
99
1010 Wed Aug 2 16:56:03 PDT 1995 Anthony Martin <amartin@engr.csulb.edu>
1111
12 * Add support for generating shared vertices
13 * Move fclose(stl->fp) to stl_open()
12 * Add support for generating shared vertices
13 * Move fclose(stl->fp) to stl_open()
1414
1515 Tue Oct 31 13:56:25 PST 1995 Anthony Martin <amartin@engr.csulb.edu>
1616
17 * Don't use area any more to see whether or not the normal should
18 be calculated. Just go ahead and calculate the normal, and let the
19 code in stl_normalize vector() take care of the case of a normal
20 with zero area.
21 * Changes call to stl_check_normal_vector() in stl_add_facet() so
22 that it doesn't check the normal vector after it adds it. Just
23 caused accounting error for normals fixed.
17 * Don't use area any more to see whether or not the normal should
18 be calculated. Just go ahead and calculate the normal, and let the
19 code in stl_normalize vector() take care of the case of a normal
20 with zero area.
21 * Changes call to stl_check_normal_vector() in stl_add_facet() so
22 that it doesn't check the normal vector after it adds it. Just
23 caused accounting error for normals fixed.
2424
2525 Wed Nov 1 08:39:17 PST 1995 Anthony Martin <amartin@engr.csulb.edu>
2626 * Initialize normal vector to 0,0,0 when a new facet is added.
2727
2828 Sat Jan 20 23:43:01 PST 1996 Anthony Martin <amartin@engr.csulb.edu>
2929 * stlinit.c Initialize pointers to NULL. Check whether they have
30 been allocated before free()ing them. Duh.
31
30 been allocated before free()ing them. Duh.
31
3232 Thu Jan 25 16:02:57 PST 1996 Anthony Martin <amartin@engr.csulb.edu>
3333 * shared.c Add fclose(fp); to stl_write_off().
34 * stl_io.c Add dxf write capability
35 * shared.c Add vrml write capability
34 * stl_io.c Add dxf write capability
35 * shared.c Add vrml write capability
3636
3737 Fri Jul 26 11:31:50 PDT 1996 Anthony Martin <amartin@engr.csulb.edu>
38 * Update normals after rotation
39 * Add code to calculate the volume of the part
38 * Update normals after rotation
39 * Add code to calculate the volume of the part
40
41 Wed, 03 Jul 2013 16:57:55 +0200 Anton Gladky <gladk@debian.org>
42 Andy Doucette (2):
43 Fix merge-command.
44 Fix translate-command.
45
46 Anton Gladky (11):
47 Add cmake-support.
48 Remove Makefile and configure-files.
49 Remove embedded getopt-files.
50 Install block.stl.
51 Update doc-files.
52 Fix compilation warnings.
53 Add version.h.
54 Close file properly. Import patch from Debian.
55 Set version 0.96
56 Generate and install manpage. Used help2man.
57 Update version number in README and Doc
4058
4159
60
0 To install ADMesh, you will need a system with a c compiler.
0 To install ADMesh, you will need a system with a c compiler and cmake.
11 Do the following:
22
3 1. Get the file admesh-0.95.tar.gz
4 2. Extract the archive. i.e. type something like the following:
5 tar -zxvf admesh-0.95.tar.gz
6 or if that doesn't work, try the following:
7 cat admesh-0.95.tar.gz | gzip -d | tar xvf -
8 The source files will be extracted into a directory called admesh-0.95
9 3. cd admesh-0.95
10 4. type the following:
11 ./configure
12 make
3 1. Get the file admesh-XXX.tar.gz
4 2. Extract the archive. i.e. type something like the following:
5 tar -zxvf admesh-XXX.tar.gz
6 The source files will be extracted into a directory
7 3. Create build directory:
8 mkdir build
9 cd build
10 4. Type the following:
11 cmake -DCMAKE_INSTALL_PREFIX=/INSTALL_PATH/FOR/ADMESH ./../ADMESH_SRC_DIR
12 make
13 make install
1314
14 That should do it. You should have an executable file called admesh. There
15 is only the one stand-alone executable and there are no configuration files
16 or environment variables to be set. I don't believe that that the included
17 configure script will run under MS-DOS or Windows, so you will need to edit
18 the included Makefile.in file by hand to compile it.
15 That should do it. You should have an executable file called admesh in:
16 /INSTALL_PATH/FOR/ADMESH/bin/admesh
17
18 To regenerate manpage for admesh, use help2man tool:
19 help2man admessh --name="a program for processing triangulated solid meshes" > admesh.1
+0
-21
Makefile.in less more
0 #! /bin/sh
1
2 SHELL = /bin/sh
3 CC = @CC@
4 CFLAGS = -I@srcdir@ @CFLAGS@
5 CPPFLAGS = @CPPFLAGS@
6 LDFLAGS = @LDFLAGS@
7 LIBOBJS = @LIBOBJS@
8 .SUFFIXES:
9 .SUFFIXES: .c .o
10
11 OBJ = admesh.o connect.o stl_io.o stlinit.o util.o normals.o shared.o @LIBOBJS@
12
13 all: @srcdir@/configure $(OBJ)
14 $(CC) @LDFLAGS@ -o admesh $(OBJ) @LIBS@
15
16 clean:
17 rm -f $(OBJ) admesh core admesh.core core.admesh
18 rm -f config.h config.log config.status\
19 config.cache Makefile
20
0 ADMesh version 0.95
0 ADMesh version 0.96
11 ********************
22
33 ADMesh is a program for processing triangulated solid meshes. Currently,
2626
2727 ** ADMesh outputs the following statistics after processing:
2828
29 ================= Results produced by ADMesh version 0.95 =================
29 ================= Results produced by ADMesh version 0.96 =================
3030 Input file : sphere.stl
3131 File type : Binary STL file
32 Header : Processed by ADMesh version 0.95
32 Header : Processed by ADMesh version 0.96
3333 ============== Size ==============
3434 Min X = -1.334557, Max X = 1.370952
3535 Min Y = -1.377953, Max Y = 1.377230
9494 its source code cannot be used in commercial software. Details of the GPL
9595 are in the file COPYING that comes with the ADMesh software package.
9696
97 ADMesh can be obtained via http from:
98 http://www.engr.csulb.edu/~amartin/admesh/admesh-0.95.tar.gz
99 or visit my home page at:
100 http://www.engr.csulb.edu/~amartin
97 ADMesh can be obtained on Launchpad from:
98 https://launchpad.net/admesh
99 or from GitHub:
100 https://github.com/gladk/admesh
101101
102102 Send questions, comments, suggestions, etc. to me at the following address.
103103 <amartin@engr.csulb.edu>
0 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.43.3.
1 .TH ADMESH "1" "July 2013" "ADMesh - version 0.96" "User Commands"
2 .SH NAME
3 ADMesh \- a program for processing triangulated solid meshes
4 .SH SYNOPSIS
5 .B admesh
6 [\fIOPTION\fR]... \fIfile\fR
7 .SH DESCRIPTION
8 ADMesh version 0.96
9 Copyright \(co 1995, 1996 Anthony D. Martin
10 .TP
11 \fB\-\-x\-rotate\fR=\fIangle\fR
12 Rotate CCW about x\-axis by angle degrees
13 .TP
14 \fB\-\-y\-rotate\fR=\fIangle\fR
15 Rotate CCW about y\-axis by angle degrees
16 .TP
17 \fB\-\-z\-rotate\fR=\fIangle\fR
18 Rotate CCW about z\-axis by angle degrees
19 .TP
20 \fB\-\-xy\-mirror\fR
21 Mirror about the xy plane
22 .TP
23 \fB\-\-yz\-mirror\fR
24 Mirror about the yz plane
25 .TP
26 \fB\-\-xz\-mirror\fR
27 Mirror about the xz plane
28 .TP
29 \fB\-\-scale\fR=\fIfactor\fR
30 Scale the file by factor (multiply by factor)
31 .TP
32 \fB\-\-translate\fR=\fIx\fR,y,z
33 Translate the file to x, y, and z
34 .TP
35 \fB\-\-merge\fR=\fIname\fR
36 Merge file called name with input file
37 .TP
38 \fB\-e\fR, \fB\-\-exact\fR
39 Only check for perfectly matched edges
40 .TP
41 \fB\-n\fR, \fB\-\-nearby\fR
42 Find and connect nearby facets. Correct bad facets
43 .TP
44 \fB\-t\fR, \fB\-\-tolerance\fR=\fItol\fR
45 Initial tolerance to use for nearby check = tol
46 .TP
47 \fB\-i\fR, \fB\-\-iterations\fR=\fIi\fR
48 Number of iterations for nearby check = i
49 .TP
50 \fB\-m\fR, \fB\-\-increment\fR=\fIinc\fR
51 Amount to increment tolerance after iteration=inc
52 .HP
53 \fB\-u\fR, \fB\-\-remove\-unconnected\fR Remove facets that have 0 neighbors
54 .TP
55 \fB\-f\fR, \fB\-\-fill\-holes\fR
56 Add facets to fill holes
57 .TP
58 \fB\-d\fR, \fB\-\-normal\-directions\fR
59 Check and fix direction of normals(ie cw, ccw)
60 .TP
61 \fB\-\-reverse\-all\fR
62 Reverse the directions of all facets and normals
63 .TP
64 \fB\-v\fR, \fB\-\-normal\-values\fR
65 Check and fix normal values
66 .TP
67 \fB\-c\fR, \fB\-\-no\-check\fR
68 Don't do any check on input file
69 .TP
70 \fB\-b\fR, \fB\-\-write\-binary\-stl\fR=\fIname\fR
71 Output a binary STL file called name
72 .TP
73 \fB\-a\fR, \fB\-\-write\-ascii\-stl\fR=\fIname\fR
74 Output an ascii STL file called name
75 .TP
76 \fB\-\-write\-off\fR=\fIname\fR
77 Output a Geomview OFF format file called name
78 .TP
79 \fB\-\-write\-dxf\fR=\fIname\fR
80 Output a DXF format file called name
81 .TP
82 \fB\-\-write\-vrml\fR=\fIname\fR
83 Output a VRML format file called name
84 .TP
85 \fB\-\-help\fR
86 Display this help and exit
87 .TP
88 \fB\-\-version\fR
89 Output version information and exit
90 .PP
91 The functions are executed in the same order as the options shown here.
92 So check here to find what happens if, for example, \fB\-\-translate\fR and \fB\-\-merge\fR
93 options are specified together. The order of the options specified on the
94 command line is not important.
95 .SH "SEE ALSO"
96 The full documentation for
97 .B ADMesh
98 is maintained as a Texinfo manual. If the
99 .B info
100 and
101 .B ADMesh
102 programs are properly installed at your site, the command
103 .IP
104 .B info ADMesh
105 .PP
106 should give you access to the complete manual.
2323
2424
2525 #include "stl.h"
26 #include "version.h"
2627
2728 static void usage(int status, char *program_name);
2829
29 void
30 main(int argc, char **argv)
30 int main(int argc, char **argv)
3131 {
3232 stl_file stl_in;
3333 int i;
239239 }
240240 if(version_flag)
241241 {
242 printf("ADMesh - version 0.95\n");
242 printf("ADMesh - version %g\n",VERSION);
243243 exit(0);
244244 }
245245
254254 }
255255
256256 printf("\
257 ADMesh version 0.95, Copyright (C) 1995, 1996 Anthony D. Martin\n\
257 ADMesh version %g, Copyright (C) 1995, 1996 Anthony D. Martin\n\
258258 ADMesh comes with NO WARRANTY. This is free software, and you are welcome to\n\
259 redistribute it under certain conditions. See the file COPYING for details.\n");
259 redistribute it under certain conditions. See the file COPYING for details.\n",VERSION);
260260
261261
262262 printf("Opening %s\n", input_file);
306306 if(merge_flag)
307307 {
308308 printf("Merging %s with %s\n", input_file, merge_name);
309 //Open the file and add the contents to stl_in:
309310 stl_open_merge(&stl_in, merge_name);
310311 }
311312
432433 if(write_dxf_flag)
433434 {
434435 printf("Writing DXF file %s\n", dxf_name);
435 stl_write_dxf(&stl_in, dxf_name, "Created by ADMesh version 0.95");
436 char *tmp_msg = NULL;
437 sprintf(tmp_msg,"Created by ADMesh version %g",VERSION);
438 stl_write_dxf(&stl_in, dxf_name, tmp_msg);
436439 }
437440
438441 if(write_vrml_flag)
444447 if(write_ascii_stl_flag)
445448 {
446449 printf("Writing ascii file %s\n", ascii_name);
447 stl_write_ascii(&stl_in, ascii_name,
448 "Processed by ADMesh version 0.95");
450
451 char *tmp_msg = NULL;
452 sprintf(tmp_msg,"Processed by ADMesh version %g",VERSION);
453 stl_write_ascii(&stl_in, ascii_name, tmp_msg);
449454 }
450455
451456 if(write_binary_stl_flag)
452457 {
453458 printf("Writing binary file %s\n", binary_name);
454 stl_write_binary(&stl_in, binary_name,
455 "Processed by ADMesh version 0.95");
459
460 char *tmp_msg = NULL;
461 sprintf(tmp_msg,"Processed by ADMesh version %g",VERSION);
462 stl_write_binary(&stl_in, binary_name, tmp_msg);
456463 }
457464
458465 if(exact_flag)
475482 else
476483 {
477484 printf("\n\
478 ADMesh version 0.95\n\
485 ADMesh version %g\n\
479486 Copyright (C) 1995, 1996 Anthony D. Martin\n\
480 Usage: %s [OPTION]... file\n", program_name);
487 Usage: %s [OPTION]... file\n", VERSION, program_name);
481488 printf("\n\
482489 --x-rotate=angle Rotate CCW about x-axis by angle degrees\n\
483490 --y-rotate=angle Rotate CCW about y-axis by angle degrees\n\
+0
-752
configure less more
0 #! /bin/sh
1
2 # Guess values for system-dependent variables and create Makefiles.
3 # Generated automatically using autoconf version 2.4
4 # Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
5 #
6 # This configure script is free software; the Free Software Foundation
7 # gives unlimited permission to copy, distribute and modify it.
8
9 # Defaults:
10 ac_help=
11 ac_default_prefix=/usr/local
12 # Any additions from configure.in:
13
14 # Initialize some variables set by options.
15 # The variables have the same names as the options, with
16 # dashes changed to underlines.
17 build=NONE
18 cache_file=./config.cache
19 exec_prefix=NONE
20 host=NONE
21 no_create=
22 nonopt=NONE
23 no_recursion=
24 prefix=NONE
25 program_prefix=NONE
26 program_suffix=NONE
27 program_transform_name=s,x,x,
28 silent=
29 site=
30 srcdir=
31 target=NONE
32 verbose=
33 x_includes=NONE
34 x_libraries=NONE
35
36 # Initialize some other variables.
37 subdirs=
38
39 ac_prev=
40 for ac_option
41 do
42
43 # If the previous option needs an argument, assign it.
44 if test -n "$ac_prev"; then
45 eval "$ac_prev=\$ac_option"
46 ac_prev=
47 continue
48 fi
49
50 case "$ac_option" in
51 -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
52 *) ac_optarg= ;;
53 esac
54
55 # Accept the important Cygnus configure options, so we can diagnose typos.
56
57 case "$ac_option" in
58
59 -build | --build | --buil | --bui | --bu | --b)
60 ac_prev=build ;;
61 -build=* | --build=* | --buil=* | --bui=* | --bu=* | --b=*)
62 build="$ac_optarg" ;;
63
64 -cache-file | --cache-file | --cache-fil | --cache-fi \
65 | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
66 ac_prev=cache_file ;;
67 -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
68 | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
69 cache_file="$ac_optarg" ;;
70
71 -disable-* | --disable-*)
72 ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
73 # Reject names that are not valid shell variable names.
74 if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
75 { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
76 fi
77 ac_feature=`echo $ac_feature| sed 's/-/_/g'`
78 eval "enable_${ac_feature}=no" ;;
79
80 -enable-* | --enable-*)
81 ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
82 # Reject names that are not valid shell variable names.
83 if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
84 { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
85 fi
86 ac_feature=`echo $ac_feature| sed 's/-/_/g'`
87 case "$ac_option" in
88 *=*) ;;
89 *) ac_optarg=yes ;;
90 esac
91 eval "enable_${ac_feature}='$ac_optarg'" ;;
92
93 -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
94 | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
95 | --exec | --exe | --ex)
96 ac_prev=exec_prefix ;;
97 -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
98 | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
99 | --exec=* | --exe=* | --ex=*)
100 exec_prefix="$ac_optarg" ;;
101
102 -gas | --gas | --ga | --g)
103 # Obsolete; use --with-gas.
104 with_gas=yes ;;
105
106 -help | --help | --hel | --he)
107 # Omit some internal or obsolete options to make the list less imposing.
108 # This message is too long to be a string in the A/UX 3.1 sh.
109 cat << EOF
110 Usage: configure [options] [host]
111 Options: [defaults in brackets after descriptions]
112 Configuration:
113 --cache-file=FILE cache test results in FILE
114 --help print this message
115 --no-create do not create output files
116 --quiet, --silent do not print \`checking...' messages
117 --version print the version of autoconf that created configure
118 Directory and file names:
119 --prefix=PREFIX install architecture-independent files in PREFIX
120 [$ac_default_prefix]
121 --exec-prefix=PREFIX install architecture-dependent files in PREFIX
122 [same as prefix]
123 --srcdir=DIR find the sources in DIR [configure dir or ..]
124 --program-prefix=PREFIX prepend PREFIX to installed program names
125 --program-suffix=SUFFIX append SUFFIX to installed program names
126 --program-transform-name=PROGRAM run sed PROGRAM on installed program names
127 Host type:
128 --build=BUILD configure for building on BUILD [BUILD=HOST]
129 --host=HOST configure for HOST [guessed]
130 --target=TARGET configure for TARGET [TARGET=HOST]
131 Features and packages:
132 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
133 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
134 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
135 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
136 --x-includes=DIR X include files are in DIR
137 --x-libraries=DIR X library files are in DIR
138 --enable and --with options recognized:$ac_help
139 EOF
140 exit 0 ;;
141
142 -host | --host | --hos | --ho)
143 ac_prev=host ;;
144 -host=* | --host=* | --hos=* | --ho=*)
145 host="$ac_optarg" ;;
146
147 -nfp | --nfp | --nf)
148 # Obsolete; use --without-fp.
149 with_fp=no ;;
150
151 -no-create | --no-create | --no-creat | --no-crea | --no-cre \
152 | --no-cr | --no-c)
153 no_create=yes ;;
154
155 -no-recursion | --no-recursion | --no-recursio | --no-recursi \
156 | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
157 no_recursion=yes ;;
158
159 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
160 ac_prev=prefix ;;
161 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
162 prefix="$ac_optarg" ;;
163
164 -program-prefix | --program-prefix | --program-prefi | --program-pref \
165 | --program-pre | --program-pr | --program-p)
166 ac_prev=program_prefix ;;
167 -program-prefix=* | --program-prefix=* | --program-prefi=* \
168 | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
169 program_prefix="$ac_optarg" ;;
170
171 -program-suffix | --program-suffix | --program-suffi | --program-suff \
172 | --program-suf | --program-su | --program-s)
173 ac_prev=program_suffix ;;
174 -program-suffix=* | --program-suffix=* | --program-suffi=* \
175 | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
176 program_suffix="$ac_optarg" ;;
177
178 -program-transform-name | --program-transform-name \
179 | --program-transform-nam | --program-transform-na \
180 | --program-transform-n | --program-transform- \
181 | --program-transform | --program-transfor \
182 | --program-transfo | --program-transf \
183 | --program-trans | --program-tran \
184 | --progr-tra | --program-tr | --program-t)
185 ac_prev=program_transform_name ;;
186 -program-transform-name=* | --program-transform-name=* \
187 | --program-transform-nam=* | --program-transform-na=* \
188 | --program-transform-n=* | --program-transform-=* \
189 | --program-transform=* | --program-transfor=* \
190 | --program-transfo=* | --program-transf=* \
191 | --program-trans=* | --program-tran=* \
192 | --progr-tra=* | --program-tr=* | --program-t=*)
193 program_transform_name="$ac_optarg" ;;
194
195 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
196 | -silent | --silent | --silen | --sile | --sil)
197 silent=yes ;;
198
199 -site | --site | --sit)
200 ac_prev=site ;;
201 -site=* | --site=* | --sit=*)
202 site="$ac_optarg" ;;
203
204 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
205 ac_prev=srcdir ;;
206 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
207 srcdir="$ac_optarg" ;;
208
209 -target | --target | --targe | --targ | --tar | --ta | --t)
210 ac_prev=target ;;
211 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
212 target="$ac_optarg" ;;
213
214 -v | -verbose | --verbose | --verbos | --verbo | --verb)
215 verbose=yes ;;
216
217 -version | --version | --versio | --versi | --vers)
218 echo "configure generated by autoconf version 2.4"
219 exit 0 ;;
220
221 -with-* | --with-*)
222 ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
223 # Reject names that are not valid shell variable names.
224 if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
225 { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
226 fi
227 ac_package=`echo $ac_package| sed 's/-/_/g'`
228 case "$ac_option" in
229 *=*) ;;
230 *) ac_optarg=yes ;;
231 esac
232 eval "with_${ac_package}='$ac_optarg'" ;;
233
234 -without-* | --without-*)
235 ac_package=`echo $ac_option|sed -e 's/-*without-//'`
236 # Reject names that are not valid shell variable names.
237 if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
238 { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
239 fi
240 ac_package=`echo $ac_package| sed 's/-/_/g'`
241 eval "with_${ac_package}=no" ;;
242
243 --x)
244 # Obsolete; use --with-x.
245 with_x=yes ;;
246
247 -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
248 | --x-incl | --x-inc | --x-in | --x-i)
249 ac_prev=x_includes ;;
250 -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
251 | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
252 x_includes="$ac_optarg" ;;
253
254 -x-libraries | --x-libraries | --x-librarie | --x-librari \
255 | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
256 ac_prev=x_libraries ;;
257 -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
258 | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
259 x_libraries="$ac_optarg" ;;
260
261 -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
262 ;;
263
264 *)
265 if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
266 echo "configure: warning: $ac_option: invalid host type" 1>&2
267 fi
268 if test "x$nonopt" != xNONE; then
269 { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
270 fi
271 nonopt="$ac_option"
272 ;;
273
274 esac
275 done
276
277 if test -n "$ac_prev"; then
278 { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
279 fi
280
281 trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
282
283 # File descriptor usage:
284 # 0 standard input
285 # 1 file creation
286 # 2 errors and warnings
287 # 3 some systems may open it to /dev/tty
288 # 4 used on the Kubota Titan
289 # 6 checking for... messages and results
290 # 5 compiler messages saved in config.log
291 if test "$silent" = yes; then
292 exec 6>/dev/null
293 else
294 exec 6>&1
295 fi
296 exec 5>./config.log
297
298 echo "\
299 This file contains any messages produced by compilers while
300 running configure, to aid debugging if configure makes a mistake.
301 " 1>&5
302
303 # Strip out --no-create and --no-recursion so they do not pile up.
304 # Also quote any args containing shell metacharacters.
305 ac_configure_args=
306 for ac_arg
307 do
308 case "$ac_arg" in
309 -no-create | --no-create | --no-creat | --no-crea | --no-cre \
310 | --no-cr | --no-c) ;;
311 -no-recursion | --no-recursion | --no-recursio | --no-recursi \
312 | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
313 *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
314 ac_configure_args="$ac_configure_args '$ac_arg'" ;;
315 *) ac_configure_args="$ac_configure_args $ac_arg" ;;
316 esac
317 done
318
319 # NLS nuisances.
320 # Only set LANG and LC_ALL to C if already set.
321 # These must not be set unconditionally because not all systems understand
322 # e.g. LANG=C (notably SCO).
323 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
324 if test "${LANG+set}" = set; then LANG=C; export LANG; fi
325
326 # confdefs.h avoids OS command line length limits that DEFS can exceed.
327 rm -rf conftest* confdefs.h
328 # AIX cpp loses on an empty file, so make sure it contains at least a newline.
329 echo > confdefs.h
330
331 # A filename unique to this package, relative to the directory that
332 # configure is in, which we can look for to find out if srcdir is correct.
333 ac_unique_file=stl.h
334
335 # Find the source files, if location was not specified.
336 if test -z "$srcdir"; then
337 ac_srcdir_defaulted=yes
338 # Try the directory containing this script, then its parent.
339 ac_prog=$0
340 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
341 test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
342 srcdir=$ac_confdir
343 if test ! -r $srcdir/$ac_unique_file; then
344 srcdir=..
345 fi
346 else
347 ac_srcdir_defaulted=no
348 fi
349 if test ! -r $srcdir/$ac_unique_file; then
350 if test "$ac_srcdir_defaulted" = yes; then
351 { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
352 else
353 { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
354 fi
355 fi
356 srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
357
358 # Prefer explicitly selected file to automatically selected ones.
359 if test -z "$CONFIG_SITE"; then
360 if test "x$prefix" != xNONE; then
361 CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
362 else
363 CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
364 fi
365 fi
366 for ac_site_file in $CONFIG_SITE; do
367 if test -r "$ac_site_file"; then
368 echo "loading site script $ac_site_file"
369 . "$ac_site_file"
370 fi
371 done
372
373 if test -r "$cache_file"; then
374 echo "loading cache $cache_file"
375 . $cache_file
376 else
377 echo "creating cache $cache_file"
378 > $cache_file
379 fi
380
381 ac_ext=c
382 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
383 ac_cpp='$CPP $CPPFLAGS'
384 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5'
385 ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5'
386
387 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
388 # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
389 if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
390 ac_n= ac_c='
391 ' ac_t=' '
392 else
393 ac_n=-n ac_c= ac_t=
394 fi
395 else
396 ac_n= ac_c='\c' ac_t=
397 fi
398
399
400
401 # Extract the first word of "gcc", so it can be a program name with args.
402 set dummy gcc; ac_word=$2
403 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
404 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
405 echo $ac_n "(cached) $ac_c" 1>&6
406 else
407 if test -n "$CC"; then
408 ac_cv_prog_CC="$CC" # Let the user override the test.
409 else
410 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
411 for ac_dir in $PATH; do
412 test -z "$ac_dir" && ac_dir=.
413 if test -f $ac_dir/$ac_word; then
414 ac_cv_prog_CC="gcc"
415 break
416 fi
417 done
418 IFS="$ac_save_ifs"
419 test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="cc"
420 fi
421 fi
422 CC="$ac_cv_prog_CC"
423 if test -n "$CC"; then
424 echo "$ac_t""$CC" 1>&6
425 else
426 echo "$ac_t""no" 1>&6
427 fi
428
429
430 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
431 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
432 echo $ac_n "(cached) $ac_c" 1>&6
433 else
434 cat > conftest.c <<EOF
435 #ifdef __GNUC__
436 yes;
437 #endif
438 EOF
439 if ${CC-cc} -E conftest.c 2>&5 | egrep yes >/dev/null 2>&1; then
440 ac_cv_prog_gcc=yes
441 else
442 ac_cv_prog_gcc=no
443 fi
444 fi
445 echo "$ac_t""$ac_cv_prog_gcc" 1>&6
446 if test $ac_cv_prog_gcc = yes; then
447 GCC=yes
448 if test "${CFLAGS+set}" != set; then
449 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
450 if eval "test \"`echo '$''{'ac_cv_prog_gcc_g'+set}'`\" = set"; then
451 echo $ac_n "(cached) $ac_c" 1>&6
452 else
453 echo 'void f(){}' > conftest.c
454 if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
455 ac_cv_prog_gcc_g=yes
456 else
457 ac_cv_prog_gcc_g=no
458 fi
459 rm -f conftest*
460
461 fi
462 echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6
463 if test $ac_cv_prog_gcc_g = yes; then
464 CFLAGS="-g -O"
465 else
466 CFLAGS="-O"
467 fi
468 fi
469 else
470 GCC=
471 test "${CFLAGS+set}" = set || CFLAGS="-g"
472 fi
473
474
475 if test x$GCC = xyes; then
476 CFLAGS2="-O2 -Wall -Wno-implicit"
477 else
478 CFLAGS2="-O"
479 fi
480
481 echo $ac_n "checking for -lm""... $ac_c" 1>&6
482 if eval "test \"`echo '$''{'ac_cv_lib_m'+set}'`\" = set"; then
483 echo $ac_n "(cached) $ac_c" 1>&6
484 else
485 ac_save_LIBS="$LIBS"
486 LIBS="-lm $LIBS"
487 cat > conftest.$ac_ext <<EOF
488 #line 490 "configure"
489 #include "confdefs.h"
490
491 int main() { return 0; }
492 int t() {
493 main()
494 ; return 0; }
495 EOF
496 if eval $ac_link; then
497 rm -rf conftest*
498 eval "ac_cv_lib_m=yes"
499 else
500 rm -rf conftest*
501 eval "ac_cv_lib_m=no"
502 fi
503 rm -f conftest*
504 LIBS="$ac_save_LIBS"
505
506 fi
507 if eval "test \"`echo '$ac_cv_lib_'m`\" = yes"; then
508 echo "$ac_t""yes" 1>&6
509 ac_tr_lib=HAVE_LIB`echo m | tr '[a-z]' '[A-Z]'`
510 cat >> confdefs.h <<EOF
511 #define $ac_tr_lib 1
512 EOF
513
514 LIBS="-lm $LIBS"
515
516 else
517 echo "$ac_t""no" 1>&6
518 fi
519
520
521
522
523 echo $ac_n "checking for getopt_long""... $ac_c" 1>&6
524 if eval "test \"`echo '$''{'ac_cv_func_getopt_long'+set}'`\" = set"; then
525 echo $ac_n "(cached) $ac_c" 1>&6
526 else
527 cat > conftest.$ac_ext <<EOF
528 #line 530 "configure"
529 #include "confdefs.h"
530 /* System header to define __stub macros and hopefully few prototypes,
531 which can conflict with char getopt_long(); below. */
532 #include <assert.h>
533 /* Override any gcc2 internal prototype to avoid an error. */
534 char getopt_long();
535
536 int main() { return 0; }
537 int t() {
538
539 /* The GNU C library defines this for functions which it implements
540 to always fail with ENOSYS. Some functions are actually named
541 something starting with __ and the normal name is an alias. */
542 #if defined (__stub_getopt_long) || defined (__stub___getopt_long)
543 choke me
544 #else
545 getopt_long();
546 #endif
547
548 ; return 0; }
549 EOF
550 if eval $ac_link; then
551 rm -rf conftest*
552 eval "ac_cv_func_getopt_long=yes"
553 else
554 rm -rf conftest*
555 eval "ac_cv_func_getopt_long=no"
556 fi
557 rm -f conftest*
558
559 fi
560 if eval "test \"`echo '$ac_cv_func_'getopt_long`\" = yes"; then
561 echo "$ac_t""yes" 1>&6
562 :
563 else
564 echo "$ac_t""no" 1>&6
565 LIBOBJS="$LIBOBJS getopt.o getopt1.o"
566 fi
567
568
569
570 CFLAGS="$CFLAGS $CFLAGS2"
571
572 trap '' 1 2 15
573 cat > confcache <<\EOF
574 # This file is a shell script that caches the results of configure
575 # tests run on this system so they can be shared between configure
576 # scripts and configure runs. It is not useful on other systems.
577 # If it contains results you don't want to keep, you may remove or edit it.
578 #
579 # By default, configure uses ./config.cache as the cache file,
580 # creating it if it does not exist already. You can give configure
581 # the --cache-file=FILE option to use a different cache file; that is
582 # what configure does when it calls configure scripts in
583 # subdirectories, so they share the cache.
584 # Giving --cache-file=/dev/null disables caching, for debugging configure.
585 # config.status only pays attention to the cache file if you give it the
586 # --recheck option to rerun configure.
587 #
588 EOF
589 # Ultrix sh set writes to stderr and can't be redirected directly,
590 # and sets the high bit in the cache file unless we assign to the vars.
591 (set) 2>&1 |
592 sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \
593 >> confcache
594 if cmp -s $cache_file confcache; then
595 :
596 else
597 if test -w $cache_file; then
598 echo "updating cache $cache_file"
599 cat confcache > $cache_file
600 else
601 echo "not updating unwritable cache $cache_file"
602 fi
603 fi
604 rm -f confcache
605
606 trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
607
608 test "x$prefix" = xNONE && prefix=$ac_default_prefix
609 # Let make expand exec_prefix.
610 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
611
612 # Any assignment to VPATH causes Sun make to only execute
613 # the first set of double-colon rules, so remove it if not needed.
614 # If there is a colon in the path, we need to keep it.
615 if test "x$srcdir" = x.; then
616 ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
617 fi
618
619 trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
620
621 # Transform confdefs.h into DEFS.
622 # Protect against shell expansion while executing Makefile rules.
623 # Protect against Makefile macro expansion.
624 cat > conftest.defs <<\EOF
625 s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%-D\1=\2%g
626 s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
627 s%\[%\\&%g
628 s%\]%\\&%g
629 s%\$%$$%g
630 EOF
631 DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
632 rm -f conftest.defs
633
634
635 # Without the "./", some shells look in PATH for config.status.
636 : ${CONFIG_STATUS=./config.status}
637
638 echo creating $CONFIG_STATUS
639 rm -f $CONFIG_STATUS
640 cat > $CONFIG_STATUS <<EOF
641 #! /bin/sh
642 # Generated automatically by configure.
643 # Run this file to recreate the current configuration.
644 # This directory was configured as follows,
645 # on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
646 #
647 # $0 $ac_configure_args
648 #
649 # Compiler output produced by configure, useful for debugging
650 # configure, is in ./config.log if it exists.
651
652 ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
653 for ac_option
654 do
655 case "\$ac_option" in
656 -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
657 echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
658 exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
659 -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
660 echo "$CONFIG_STATUS generated by autoconf version 2.4"
661 exit 0 ;;
662 -help | --help | --hel | --he | --h)
663 echo "\$ac_cs_usage"; exit 0 ;;
664 *) echo "\$ac_cs_usage"; exit 1 ;;
665 esac
666 done
667
668 ac_given_srcdir=$srcdir
669
670 trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
671
672 # Protect against being on the right side of a sed subst in config.status.
673 sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g;
674 s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF
675 $ac_vpsub
676 $extrasub
677 s%@CFLAGS@%$CFLAGS%g
678 s%@CPPFLAGS@%$CPPFLAGS%g
679 s%@CXXFLAGS@%$CXXFLAGS%g
680 s%@DEFS@%$DEFS%g
681 s%@LDFLAGS@%$LDFLAGS%g
682 s%@LIBS@%$LIBS%g
683 s%@exec_prefix@%$exec_prefix%g
684 s%@prefix@%$prefix%g
685 s%@program_transform_name@%$program_transform_name%g
686 s%@CC@%$CC%g
687 s%@LIBOBJS@%$LIBOBJS%g
688
689 CEOF
690 EOF
691 cat >> $CONFIG_STATUS <<EOF
692
693 CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
694 EOF
695 cat >> $CONFIG_STATUS <<\EOF
696 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
697 # Support "outfile[:infile]", defaulting infile="outfile.in".
698 case "$ac_file" in
699 *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
700 ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
701 *) ac_file_in="${ac_file}.in" ;;
702 esac
703
704 # Adjust relative srcdir, etc. for subdirectories.
705
706 # Remove last slash and all that follows it. Not all systems have dirname.
707 ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
708 if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
709 # The file is in a subdirectory.
710 test ! -d "$ac_dir" && mkdir "$ac_dir"
711 ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
712 # A "../" for each directory in $ac_dir_suffix.
713 ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
714 else
715 ac_dir_suffix= ac_dots=
716 fi
717
718 case "$ac_given_srcdir" in
719 .) srcdir=.
720 if test -z "$ac_dots"; then top_srcdir=.
721 else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
722 /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
723 *) # Relative path.
724 srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
725 top_srcdir="$ac_dots$ac_given_srcdir" ;;
726 esac
727
728 echo creating "$ac_file"
729 rm -f "$ac_file"
730 configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
731 case "$ac_file" in
732 *Makefile*) ac_comsub="1i\\
733 # $configure_input" ;;
734 *) ac_comsub= ;;
735 esac
736 sed -e "$ac_comsub
737 s%@configure_input@%$configure_input%g
738 s%@srcdir@%$srcdir%g
739 s%@top_srcdir@%$top_srcdir%g
740 " -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file
741 fi; done
742 rm -f conftest.subs
743
744
745
746 exit 0
747 EOF
748 chmod +x $CONFIG_STATUS
749 rm -fr confdefs* $ac_clean_files
750 test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
751
+0
-30
configure.in less more
0 dnl Process this file with autoconf to produce a configure script.
1 AC_INIT(stl.h)
2
3 dnl Checks for programs.
4 AC_PROG_CC
5
6 dnl Some cc's allow prototypes, etc. Should check them individually
7 if test x$GCC = xyes; then
8 CFLAGS2="-O2 -Wall -Wno-implicit"
9 else
10 CFLAGS2="-O"
11 fi
12
13 dnl Checks for libraries.
14 dnl Replace `main' with a function in -lm:
15 AC_CHECK_LIB(m, main)
16
17 dnl Checks for header files.
18 dnl AC_HEADER_STDC
19
20 dnl Checks for library functions.
21 dnl AC_FUNC_MEMCMP
22
23 AC_CHECK_FUNC(getopt_long, , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"])
24 AC_SUBST(LIBOBJS)dnl
25
26
27 CFLAGS="$CFLAGS $CFLAGS2"
28
29 AC_OUTPUT(Makefile)
8181 {
8282 facet = stl->facet_start[i];
8383
84 //If any two of the three vertices are found to be exactally the same, call them degenerate and remove the facet.
8485 if( !memcmp(&facet.vertex[0], &facet.vertex[1],
8586 sizeof(stl_vertex))
8687 || !memcmp(&facet.vertex[1], &facet.vertex[2],
+0
-762
getopt.c less more
0 /* Getopt for GNU.
1 NOTE: getopt is now part of the C library, so if you don't know what
2 "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
3 before changing it!
4
5 Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95
6 Free Software Foundation, Inc.
7
8 This program is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 2, or (at your option) any
11 later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22 /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
23 Ditto for AIX 3.2 and <stdlib.h>. */
24 #ifndef _NO_PROTO
25 #define _NO_PROTO
26 #endif
27
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31
32 #if !defined (__STDC__) || !__STDC__
33 /* This is a separate conditional since some stdc systems
34 reject `defined (const)'. */
35 #ifndef const
36 #define const
37 #endif
38 #endif
39
40 #include <stdio.h>
41
42 /* Comment out all this code if we are using the GNU C Library, and are not
43 actually compiling the library itself. This code is part of the GNU C
44 Library, but also included in many other GNU distributions. Compiling
45 and linking in this code is a waste when using the GNU C library
46 (especially if it is a shared library). Rather than having every GNU
47 program understand `configure --with-gnu-libc' and omit the object files,
48 it is simpler to just do this in the source for each such file. */
49
50 #if defined (_LIBC) || !defined (__GNU_LIBRARY__)
51
52
53 /* This needs to come after some library #include
54 to get __GNU_LIBRARY__ defined. */
55 #ifdef __GNU_LIBRARY__
56 /* Don't include stdlib.h for non-GNU C libraries because some of them
57 contain conflicting prototypes for getopt. */
58 #include <stdlib.h>
59 #endif /* GNU C library. */
60
61 /* This is for other GNU distributions with internationalized messages.
62 The GNU C Library itself does not yet support such messages. */
63 #if HAVE_LIBINTL_H
64 # include <libintl.h>
65 #else
66 # define gettext(msgid) (msgid)
67 #endif
68
69 /* This version of `getopt' appears to the caller like standard Unix `getopt'
70 but it behaves differently for the user, since it allows the user
71 to intersperse the options with the other arguments.
72
73 As `getopt' works, it permutes the elements of ARGV so that,
74 when it is done, all the options precede everything else. Thus
75 all application programs are extended to handle flexible argument order.
76
77 Setting the environment variable POSIXLY_CORRECT disables permutation.
78 Then the behavior is completely standard.
79
80 GNU application programs can use a third alternative mode in which
81 they can distinguish the relative order of options and other arguments. */
82
83 #include "getopt.h"
84
85 /* For communication from `getopt' to the caller.
86 When `getopt' finds an option that takes an argument,
87 the argument value is returned here.
88 Also, when `ordering' is RETURN_IN_ORDER,
89 each non-option ARGV-element is returned here. */
90
91 char *optarg = NULL;
92
93 /* Index in ARGV of the next element to be scanned.
94 This is used for communication to and from the caller
95 and for communication between successive calls to `getopt'.
96
97 On entry to `getopt', zero means this is the first call; initialize.
98
99 When `getopt' returns EOF, this is the index of the first of the
100 non-option elements that the caller should itself scan.
101
102 Otherwise, `optind' communicates from one call to the next
103 how much of ARGV has been scanned so far. */
104
105 /* XXX 1003.2 says this must be 1 before any call. */
106 int optind = 0;
107
108 /* The next char to be scanned in the option-element
109 in which the last option character we returned was found.
110 This allows us to pick up the scan where we left off.
111
112 If this is zero, or a null string, it means resume the scan
113 by advancing to the next ARGV-element. */
114
115 static char *nextchar;
116
117 /* Callers store zero here to inhibit the error message
118 for unrecognized options. */
119
120 int opterr = 1;
121
122 /* Set to an option character which was unrecognized.
123 This must be initialized on some systems to avoid linking in the
124 system's own getopt implementation. */
125
126 int optopt = '?';
127
128 /* Describe how to deal with options that follow non-option ARGV-elements.
129
130 If the caller did not specify anything,
131 the default is REQUIRE_ORDER if the environment variable
132 POSIXLY_CORRECT is defined, PERMUTE otherwise.
133
134 REQUIRE_ORDER means don't recognize them as options;
135 stop option processing when the first non-option is seen.
136 This is what Unix does.
137 This mode of operation is selected by either setting the environment
138 variable POSIXLY_CORRECT, or using `+' as the first character
139 of the list of option characters.
140
141 PERMUTE is the default. We permute the contents of ARGV as we scan,
142 so that eventually all the non-options are at the end. This allows options
143 to be given in any order, even with programs that were not written to
144 expect this.
145
146 RETURN_IN_ORDER is an option available to programs that were written
147 to expect options and other ARGV-elements in any order and that care about
148 the ordering of the two. We describe each non-option ARGV-element
149 as if it were the argument of an option with character code 1.
150 Using `-' as the first character of the list of option characters
151 selects this mode of operation.
152
153 The special argument `--' forces an end of option-scanning regardless
154 of the value of `ordering'. In the case of RETURN_IN_ORDER, only
155 `--' can cause `getopt' to return EOF with `optind' != ARGC. */
156
157 static enum
158 {
159 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
160 } ordering;
161
162 /* Value of POSIXLY_CORRECT environment variable. */
163 static char *posixly_correct;
164
165 #ifdef __GNU_LIBRARY__
166 /* We want to avoid inclusion of string.h with non-GNU libraries
167 because there are many ways it can cause trouble.
168 On some systems, it contains special magic macros that don't work
169 in GCC. */
170 #include <string.h>
171 #define my_index strchr
172 #else
173
174 /* Avoid depending on library functions or files
175 whose names are inconsistent. */
176
177 char *getenv ();
178
179 static char *
180 my_index (str, chr)
181 const char *str;
182 int chr;
183 {
184 while (*str)
185 {
186 if (*str == chr)
187 return (char *) str;
188 str++;
189 }
190 return 0;
191 }
192
193 /* If using GCC, we can safely declare strlen this way.
194 If not using GCC, it is ok not to declare it. */
195 #ifdef __GNUC__
196 /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
197 That was relevant to code that was here before. */
198 #if !defined (__STDC__) || !__STDC__
199 /* gcc with -traditional declares the built-in strlen to return int,
200 and has done so at least since version 2.4.5. -- rms. */
201 extern int strlen (const char *);
202 #endif /* not __STDC__ */
203 #endif /* __GNUC__ */
204
205 #endif /* not __GNU_LIBRARY__ */
206
207 /* Handle permutation of arguments. */
208
209 /* Describe the part of ARGV that contains non-options that have
210 been skipped. `first_nonopt' is the index in ARGV of the first of them;
211 `last_nonopt' is the index after the last of them. */
212
213 static int first_nonopt;
214 static int last_nonopt;
215
216 /* Exchange two adjacent subsequences of ARGV.
217 One subsequence is elements [first_nonopt,last_nonopt)
218 which contains all the non-options that have been skipped so far.
219 The other is elements [last_nonopt,optind), which contains all
220 the options processed since those non-options were skipped.
221
222 `first_nonopt' and `last_nonopt' are relocated so that they describe
223 the new indices of the non-options in ARGV after they are moved. */
224
225 static void
226 exchange (argv)
227 char **argv;
228 {
229 int bottom = first_nonopt;
230 int middle = last_nonopt;
231 int top = optind;
232 char *tem;
233
234 /* Exchange the shorter segment with the far end of the longer segment.
235 That puts the shorter segment into the right place.
236 It leaves the longer segment in the right place overall,
237 but it consists of two parts that need to be swapped next. */
238
239 while (top > middle && middle > bottom)
240 {
241 if (top - middle > middle - bottom)
242 {
243 /* Bottom segment is the short one. */
244 int len = middle - bottom;
245 register int i;
246
247 /* Swap it with the top part of the top segment. */
248 for (i = 0; i < len; i++)
249 {
250 tem = argv[bottom + i];
251 argv[bottom + i] = argv[top - (middle - bottom) + i];
252 argv[top - (middle - bottom) + i] = tem;
253 }
254 /* Exclude the moved bottom segment from further swapping. */
255 top -= len;
256 }
257 else
258 {
259 /* Top segment is the short one. */
260 int len = top - middle;
261 register int i;
262
263 /* Swap it with the bottom part of the bottom segment. */
264 for (i = 0; i < len; i++)
265 {
266 tem = argv[bottom + i];
267 argv[bottom + i] = argv[middle + i];
268 argv[middle + i] = tem;
269 }
270 /* Exclude the moved top segment from further swapping. */
271 bottom += len;
272 }
273 }
274
275 /* Update records for the slots the non-options now occupy. */
276
277 first_nonopt += (optind - last_nonopt);
278 last_nonopt = optind;
279 }
280
281 /* Initialize the internal data when the first call is made. */
282
283 static const char *
284 _getopt_initialize (optstring)
285 const char *optstring;
286 {
287 /* Start processing options with ARGV-element 1 (since ARGV-element 0
288 is the program name); the sequence of previously skipped
289 non-option ARGV-elements is empty. */
290
291 first_nonopt = last_nonopt = optind = 1;
292
293 nextchar = NULL;
294
295 posixly_correct = getenv ("POSIXLY_CORRECT");
296
297 /* Determine how to handle the ordering of options and nonoptions. */
298
299 if (optstring[0] == '-')
300 {
301 ordering = RETURN_IN_ORDER;
302 ++optstring;
303 }
304 else if (optstring[0] == '+')
305 {
306 ordering = REQUIRE_ORDER;
307 ++optstring;
308 }
309 else if (posixly_correct != NULL)
310 ordering = REQUIRE_ORDER;
311 else
312 ordering = PERMUTE;
313
314 return optstring;
315 }
316
317 /* Scan elements of ARGV (whose length is ARGC) for option characters
318 given in OPTSTRING.
319
320 If an element of ARGV starts with '-', and is not exactly "-" or "--",
321 then it is an option element. The characters of this element
322 (aside from the initial '-') are option characters. If `getopt'
323 is called repeatedly, it returns successively each of the option characters
324 from each of the option elements.
325
326 If `getopt' finds another option character, it returns that character,
327 updating `optind' and `nextchar' so that the next call to `getopt' can
328 resume the scan with the following option character or ARGV-element.
329
330 If there are no more option characters, `getopt' returns `EOF'.
331 Then `optind' is the index in ARGV of the first ARGV-element
332 that is not an option. (The ARGV-elements have been permuted
333 so that those that are not options now come last.)
334
335 OPTSTRING is a string containing the legitimate option characters.
336 If an option character is seen that is not listed in OPTSTRING,
337 return '?' after printing an error message. If you set `opterr' to
338 zero, the error message is suppressed but we still return '?'.
339
340 If a char in OPTSTRING is followed by a colon, that means it wants an arg,
341 so the following text in the same ARGV-element, or the text of the following
342 ARGV-element, is returned in `optarg'. Two colons mean an option that
343 wants an optional arg; if there is text in the current ARGV-element,
344 it is returned in `optarg', otherwise `optarg' is set to zero.
345
346 If OPTSTRING starts with `-' or `+', it requests different methods of
347 handling the non-option ARGV-elements.
348 See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
349
350 Long-named options begin with `--' instead of `-'.
351 Their names may be abbreviated as long as the abbreviation is unique
352 or is an exact match for some defined option. If they have an
353 argument, it follows the option name in the same ARGV-element, separated
354 from the option name by a `=', or else the in next ARGV-element.
355 When `getopt' finds a long-named option, it returns 0 if that option's
356 `flag' field is nonzero, the value of the option's `val' field
357 if the `flag' field is zero.
358
359 The elements of ARGV aren't really const, because we permute them.
360 But we pretend they're const in the prototype to be compatible
361 with other systems.
362
363 LONGOPTS is a vector of `struct option' terminated by an
364 element containing a name which is zero.
365
366 LONGIND returns the index in LONGOPT of the long-named option found.
367 It is only valid when a long-named option has been found by the most
368 recent call.
369
370 If LONG_ONLY is nonzero, '-' as well as '--' can introduce
371 long-named options. */
372
373 int
374 _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
375 int argc;
376 char *const *argv;
377 const char *optstring;
378 const struct option *longopts;
379 int *longind;
380 int long_only;
381 {
382 optarg = NULL;
383
384 if (optind == 0)
385 {
386 optstring = _getopt_initialize (optstring);
387 optind = 1; /* Don't scan ARGV[0], the program name. */
388 }
389
390 if (nextchar == NULL || *nextchar == '\0')
391 {
392 /* Advance to the next ARGV-element. */
393
394 if (ordering == PERMUTE)
395 {
396 /* If we have just processed some options following some non-options,
397 exchange them so that the options come first. */
398
399 if (first_nonopt != last_nonopt && last_nonopt != optind)
400 exchange ((char **) argv);
401 else if (last_nonopt != optind)
402 first_nonopt = optind;
403
404 /* Skip any additional non-options
405 and extend the range of non-options previously skipped. */
406
407 while (optind < argc
408 && (argv[optind][0] != '-' || argv[optind][1] == '\0'))
409 optind++;
410 last_nonopt = optind;
411 }
412
413 /* The special ARGV-element `--' means premature end of options.
414 Skip it like a null option,
415 then exchange with previous non-options as if it were an option,
416 then skip everything else like a non-option. */
417
418 if (optind != argc && !strcmp (argv[optind], "--"))
419 {
420 optind++;
421
422 if (first_nonopt != last_nonopt && last_nonopt != optind)
423 exchange ((char **) argv);
424 else if (first_nonopt == last_nonopt)
425 first_nonopt = optind;
426 last_nonopt = argc;
427
428 optind = argc;
429 }
430
431 /* If we have done all the ARGV-elements, stop the scan
432 and back over any non-options that we skipped and permuted. */
433
434 if (optind == argc)
435 {
436 /* Set the next-arg-index to point at the non-options
437 that we previously skipped, so the caller will digest them. */
438 if (first_nonopt != last_nonopt)
439 optind = first_nonopt;
440 return EOF;
441 }
442
443 /* If we have come to a non-option and did not permute it,
444 either stop the scan or describe it to the caller and pass it by. */
445
446 if ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
447 {
448 if (ordering == REQUIRE_ORDER)
449 return EOF;
450 optarg = argv[optind++];
451 return 1;
452 }
453
454 /* We have found another option-ARGV-element.
455 Skip the initial punctuation. */
456
457 nextchar = (argv[optind] + 1
458 + (longopts != NULL && argv[optind][1] == '-'));
459 }
460
461 /* Decode the current option-ARGV-element. */
462
463 /* Check whether the ARGV-element is a long option.
464
465 If long_only and the ARGV-element has the form "-f", where f is
466 a valid short option, don't consider it an abbreviated form of
467 a long option that starts with f. Otherwise there would be no
468 way to give the -f short option.
469
470 On the other hand, if there's a long option "fubar" and
471 the ARGV-element is "-fu", do consider that an abbreviation of
472 the long option, just like "--fu", and not "-f" with arg "u".
473
474 This distinction seems to be the most useful approach. */
475
476 if (longopts != NULL
477 && (argv[optind][1] == '-'
478 || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
479 {
480 char *nameend;
481 const struct option *p;
482 const struct option *pfound = NULL;
483 int exact = 0;
484 int ambig = 0;
485 int indfound = 0; /* Initialize to prevent warning */
486 int option_index;
487
488 for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
489 /* Do nothing. */ ;
490
491 /* Test all long options for either exact match
492 or abbreviated matches. */
493 for (p = longopts, option_index = 0; p->name; p++, option_index++)
494 if (!strncmp (p->name, nextchar, nameend - nextchar))
495 {
496 if (nameend - nextchar == strlen (p->name))
497 {
498 /* Exact match found. */
499 pfound = p;
500 indfound = option_index;
501 exact = 1;
502 break;
503 }
504 else if (pfound == NULL)
505 {
506 /* First nonexact match found. */
507 pfound = p;
508 indfound = option_index;
509 }
510 else
511 /* Second or later nonexact match found. */
512 ambig = 1;
513 }
514
515 if (ambig && !exact)
516 {
517 if (opterr)
518 fprintf (stderr, gettext ("%s: option `%s' is ambiguous\n"),
519 argv[0], argv[optind]);
520 nextchar += strlen (nextchar);
521 optind++;
522 return '?';
523 }
524
525 if (pfound != NULL)
526 {
527 option_index = indfound;
528 optind++;
529 if (*nameend)
530 {
531 /* Don't test has_arg with >, because some C compilers don't
532 allow it to be used on enums. */
533 if (pfound->has_arg)
534 optarg = nameend + 1;
535 else
536 {
537 if (opterr)
538 if (argv[optind - 1][1] == '-')
539 /* --option */
540 fprintf (stderr,
541 gettext ("%s: option `--%s' doesn't allow an argument\n"),
542 argv[0], pfound->name);
543 else
544 /* +option or -option */
545 fprintf (stderr,
546 gettext ("%s: option `%c%s' doesn't allow an argument\n"),
547 argv[0], argv[optind - 1][0], pfound->name);
548
549 nextchar += strlen (nextchar);
550 return '?';
551 }
552 }
553 else if (pfound->has_arg == 1)
554 {
555 if (optind < argc)
556 optarg = argv[optind++];
557 else
558 {
559 if (opterr)
560 fprintf (stderr,
561 gettext ("%s: option `%s' requires an argument\n"),
562 argv[0], argv[optind - 1]);
563 nextchar += strlen (nextchar);
564 return optstring[0] == ':' ? ':' : '?';
565 }
566 }
567 nextchar += strlen (nextchar);
568 if (longind != NULL)
569 *longind = option_index;
570 if (pfound->flag)
571 {
572 *(pfound->flag) = pfound->val;
573 return 0;
574 }
575 return pfound->val;
576 }
577
578 /* Can't find it as a long option. If this is not getopt_long_only,
579 or the option starts with '--' or is not a valid short
580 option, then it's an error.
581 Otherwise interpret it as a short option. */
582 if (!long_only || argv[optind][1] == '-'
583 || my_index (optstring, *nextchar) == NULL)
584 {
585 if (opterr)
586 {
587 if (argv[optind][1] == '-')
588 /* --option */
589 fprintf (stderr, gettext ("%s: unrecognized option `--%s'\n"),
590 argv[0], nextchar);
591 else
592 /* +option or -option */
593 fprintf (stderr, gettext ("%s: unrecognized option `%c%s'\n"),
594 argv[0], argv[optind][0], nextchar);
595 }
596 nextchar = (char *) "";
597 optind++;
598 return '?';
599 }
600 }
601
602 /* Look at and handle the next short option-character. */
603
604 {
605 char c = *nextchar++;
606 char *temp = my_index (optstring, c);
607
608 /* Increment `optind' when we start to process its last character. */
609 if (*nextchar == '\0')
610 ++optind;
611
612 if (temp == NULL || c == ':')
613 {
614 if (opterr)
615 {
616 if (posixly_correct)
617 /* 1003.2 specifies the format of this message. */
618 fprintf (stderr, gettext ("%s: illegal option -- %c\n"),
619 argv[0], c);
620 else
621 fprintf (stderr, gettext ("%s: invalid option -- %c\n"),
622 argv[0], c);
623 }
624 optopt = c;
625 return '?';
626 }
627 if (temp[1] == ':')
628 {
629 if (temp[2] == ':')
630 {
631 /* This is an option that accepts an argument optionally. */
632 if (*nextchar != '\0')
633 {
634 optarg = nextchar;
635 optind++;
636 }
637 else
638 optarg = NULL;
639 nextchar = NULL;
640 }
641 else
642 {
643 /* This is an option that requires an argument. */
644 if (*nextchar != '\0')
645 {
646 optarg = nextchar;
647 /* If we end this ARGV-element by taking the rest as an arg,
648 we must advance to the next element now. */
649 optind++;
650 }
651 else if (optind == argc)
652 {
653 if (opterr)
654 {
655 /* 1003.2 specifies the format of this message. */
656 fprintf (stderr,
657 gettext ("%s: option requires an argument -- %c\n"),
658 argv[0], c);
659 }
660 optopt = c;
661 if (optstring[0] == ':')
662 c = ':';
663 else
664 c = '?';
665 }
666 else
667 /* We already incremented `optind' once;
668 increment it again when taking next ARGV-elt as argument. */
669 optarg = argv[optind++];
670 nextchar = NULL;
671 }
672 }
673 return c;
674 }
675 }
676
677 int
678 getopt (argc, argv, optstring)
679 int argc;
680 char *const *argv;
681 const char *optstring;
682 {
683 return _getopt_internal (argc, argv, optstring,
684 (const struct option *) 0,
685 (int *) 0,
686 0);
687 }
688
689 #endif /* _LIBC or not __GNU_LIBRARY__. */
690
691 #ifdef TEST
692
693 /* Compile with -DTEST to make an executable for use in testing
694 the above definition of `getopt'. */
695
696 int
697 main (argc, argv)
698 int argc;
699 char **argv;
700 {
701 int c;
702 int digit_optind = 0;
703
704 while (1)
705 {
706 int this_option_optind = optind ? optind : 1;
707
708 c = getopt (argc, argv, "abc:d:0123456789");
709 if (c == EOF)
710 break;
711
712 switch (c)
713 {
714 case '0':
715 case '1':
716 case '2':
717 case '3':
718 case '4':
719 case '5':
720 case '6':
721 case '7':
722 case '8':
723 case '9':
724 if (digit_optind != 0 && digit_optind != this_option_optind)
725 printf ("digits occur in two different argv-elements.\n");
726 digit_optind = this_option_optind;
727 printf ("option %c\n", c);
728 break;
729
730 case 'a':
731 printf ("option a\n");
732 break;
733
734 case 'b':
735 printf ("option b\n");
736 break;
737
738 case 'c':
739 printf ("option c with value `%s'\n", optarg);
740 break;
741
742 case '?':
743 break;
744
745 default:
746 printf ("?? getopt returned character code 0%o ??\n", c);
747 }
748 }
749
750 if (optind < argc)
751 {
752 printf ("non-option ARGV-elements: ");
753 while (optind < argc)
754 printf ("%s ", argv[optind++]);
755 printf ("\n");
756 }
757
758 exit (0);
759 }
760
761 #endif /* TEST */
+0
-129
getopt.h less more
0 /* Declarations for getopt.
1 Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
2
3 This program is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 2, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
16
17 #ifndef _GETOPT_H
18 #define _GETOPT_H 1
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 /* For communication from `getopt' to the caller.
25 When `getopt' finds an option that takes an argument,
26 the argument value is returned here.
27 Also, when `ordering' is RETURN_IN_ORDER,
28 each non-option ARGV-element is returned here. */
29
30 extern char *optarg;
31
32 /* Index in ARGV of the next element to be scanned.
33 This is used for communication to and from the caller
34 and for communication between successive calls to `getopt'.
35
36 On entry to `getopt', zero means this is the first call; initialize.
37
38 When `getopt' returns EOF, this is the index of the first of the
39 non-option elements that the caller should itself scan.
40
41 Otherwise, `optind' communicates from one call to the next
42 how much of ARGV has been scanned so far. */
43
44 extern int optind;
45
46 /* Callers store zero here to inhibit the error message `getopt' prints
47 for unrecognized options. */
48
49 extern int opterr;
50
51 /* Set to an option character which was unrecognized. */
52
53 extern int optopt;
54
55 /* Describe the long-named options requested by the application.
56 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
57 of `struct option' terminated by an element containing a name which is
58 zero.
59
60 The field `has_arg' is:
61 no_argument (or 0) if the option does not take an argument,
62 required_argument (or 1) if the option requires an argument,
63 optional_argument (or 2) if the option takes an optional argument.
64
65 If the field `flag' is not NULL, it points to a variable that is set
66 to the value given in the field `val' when the option is found, but
67 left unchanged if the option is not found.
68
69 To have a long-named option do something other than set an `int' to
70 a compiled-in constant, such as set a value from `optarg', set the
71 option's `flag' field to zero and its `val' field to a nonzero
72 value (the equivalent single-letter option character, if there is
73 one). For long options that have a zero `flag' field, `getopt'
74 returns the contents of the `val' field. */
75
76 struct option
77 {
78 #if defined (__STDC__) && __STDC__
79 const char *name;
80 #else
81 char *name;
82 #endif
83 /* has_arg can't be an enum because some compilers complain about
84 type mismatches in all the code that assumes it is an int. */
85 int has_arg;
86 int *flag;
87 int val;
88 };
89
90 /* Names for the values of the `has_arg' field of `struct option'. */
91
92 #define no_argument 0
93 #define required_argument 1
94 #define optional_argument 2
95
96 #if defined (__STDC__) && __STDC__
97 #ifdef __GNU_LIBRARY__
98 /* Many other libraries have conflicting prototypes for getopt, with
99 differences in the consts, in stdlib.h. To avoid compilation
100 errors, only prototype getopt for the GNU C library. */
101 extern int getopt (int argc, char *const *argv, const char *shortopts);
102 #else /* not __GNU_LIBRARY__ */
103 extern int getopt ();
104 #endif /* __GNU_LIBRARY__ */
105 extern int getopt_long (int argc, char *const *argv, const char *shortopts,
106 const struct option *longopts, int *longind);
107 extern int getopt_long_only (int argc, char *const *argv,
108 const char *shortopts,
109 const struct option *longopts, int *longind);
110
111 /* Internal only. Users should not call this directly. */
112 extern int _getopt_internal (int argc, char *const *argv,
113 const char *shortopts,
114 const struct option *longopts, int *longind,
115 int long_only);
116 #else /* not __STDC__ */
117 extern int getopt ();
118 extern int getopt_long ();
119 extern int getopt_long_only ();
120
121 extern int _getopt_internal ();
122 #endif /* __STDC__ */
123
124 #ifdef __cplusplus
125 }
126 #endif
127
128 #endif /* _GETOPT_H */
+0
-180
getopt1.c less more
0 /* getopt_long and getopt_long_only entry points for GNU getopt.
1 Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994
2 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 2, or (at your option) any
7 later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #ifdef HAVE_CONFIG_H
19 #include <config.h>
20 #endif
21
22 #include "getopt.h"
23
24 #if !defined (__STDC__) || !__STDC__
25 /* This is a separate conditional since some stdc systems
26 reject `defined (const)'. */
27 #ifndef const
28 #define const
29 #endif
30 #endif
31
32 #include <stdio.h>
33
34 /* Comment out all this code if we are using the GNU C Library, and are not
35 actually compiling the library itself. This code is part of the GNU C
36 Library, but also included in many other GNU distributions. Compiling
37 and linking in this code is a waste when using the GNU C library
38 (especially if it is a shared library). Rather than having every GNU
39 program understand `configure --with-gnu-libc' and omit the object files,
40 it is simpler to just do this in the source for each such file. */
41
42 #if defined (_LIBC) || !defined (__GNU_LIBRARY__)
43
44
45 /* This needs to come after some library #include
46 to get __GNU_LIBRARY__ defined. */
47 #ifdef __GNU_LIBRARY__
48 #include <stdlib.h>
49 #else
50 char *getenv ();
51 #endif
52
53 #ifndef NULL
54 #define NULL 0
55 #endif
56
57 int
58 getopt_long (argc, argv, options, long_options, opt_index)
59 int argc;
60 char *const *argv;
61 const char *options;
62 const struct option *long_options;
63 int *opt_index;
64 {
65 return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
66 }
67
68 /* Like getopt_long, but '-' as well as '--' can indicate a long option.
69 If an option that starts with '-' (not '--') doesn't match a long option,
70 but does match a short option, it is parsed as a short option
71 instead. */
72
73 int
74 getopt_long_only (argc, argv, options, long_options, opt_index)
75 int argc;
76 char *const *argv;
77 const char *options;
78 const struct option *long_options;
79 int *opt_index;
80 {
81 return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
82 }
83
84
85 #endif /* _LIBC or not __GNU_LIBRARY__. */
86
87 #ifdef TEST
88
89 #include <stdio.h>
90
91 int
92 main (argc, argv)
93 int argc;
94 char **argv;
95 {
96 int c;
97 int digit_optind = 0;
98
99 while (1)
100 {
101 int this_option_optind = optind ? optind : 1;
102 int option_index = 0;
103 static struct option long_options[] =
104 {
105 {"add", 1, 0, 0},
106 {"append", 0, 0, 0},
107 {"delete", 1, 0, 0},
108 {"verbose", 0, 0, 0},
109 {"create", 0, 0, 0},
110 {"file", 1, 0, 0},
111 {0, 0, 0, 0}
112 };
113
114 c = getopt_long (argc, argv, "abc:d:0123456789",
115 long_options, &option_index);
116 if (c == EOF)
117 break;
118
119 switch (c)
120 {
121 case 0:
122 printf ("option %s", long_options[option_index].name);
123 if (optarg)
124 printf (" with arg %s", optarg);
125 printf ("\n");
126 break;
127
128 case '0':
129 case '1':
130 case '2':
131 case '3':
132 case '4':
133 case '5':
134 case '6':
135 case '7':
136 case '8':
137 case '9':
138 if (digit_optind != 0 && digit_optind != this_option_optind)
139 printf ("digits occur in two different argv-elements.\n");
140 digit_optind = this_option_optind;
141 printf ("option %c\n", c);
142 break;
143
144 case 'a':
145 printf ("option a\n");
146 break;
147
148 case 'b':
149 printf ("option b\n");
150 break;
151
152 case 'c':
153 printf ("option c with value `%s'\n", optarg);
154 break;
155
156 case 'd':
157 printf ("option d with value `%s'\n", optarg);
158 break;
159
160 case '?':
161 break;
162
163 default:
164 printf ("?? getopt returned character code 0%o ??\n", c);
165 }
166 }
167
168 if (optind < argc)
169 {
170 printf ("non-option ARGV-elements: ");
171 while (optind < argc)
172 printf ("%s ", argv[optind++]);
173 printf ("\n");
174 }
175
176 exit (0);
177 }
178
179 #endif /* TEST */
118118 norm_sw = calloc(stl->stats.number_of_facets, sizeof(char));
119119 if(norm_sw == NULL) perror("stl_fix_normal_directions");
120120
121
122121 facet_num = 0;
122 //If normal vector is not within tolerance and backwards:
123 //Arbitrarily starts at face 0. If this one is wrong, we're screwed. Thankfully, the chances
124 // of it being wrong randomly are low if most of the triangles are right:
123125 if(stl_check_normal_vector(stl, 0, 0) == 2)
124126 stl_reverse_facet(stl, 0);
125127
128 //Say that we've fixed this facet:
126129 norm_sw[facet_num] = 1;
127130 /* edge_num = 0;
128131 vnot = stl->neighbors_start[0].which_vertex_not[0];
132135 for(;;)
133136 {
134137 /* Add neighbors_to_list. */
138 //Add unconnected neighbors to the list:a
135139 for(j = 0; j < 3; j++)
136140 {
137141 /* Reverse the neighboring facets if necessary. */
138142 if(stl->neighbors_start[facet_num].which_vertex_not[j] > 2)
139143 {
144 // If the facet has a neighbor that is -1, it means that edge isn't shared by another
145 // facet.
140146 if(stl->neighbors_start[facet_num].neighbor[j] != -1)
141147 {
142148 stl_reverse_facet
143149 (stl, stl->neighbors_start[facet_num].neighbor[j]);
144150 }
145151 }
152 //If this edge of the facet is connected:
146153 if(stl->neighbors_start[facet_num].neighbor[j] != -1)
147154 {
155 //If we haven't fixed this facet yet, add it to the list:
148156 if(norm_sw[stl->neighbors_start[facet_num].neighbor[j]] != 1)
149157 {
150158 /* Add node to beginning of list. */
169177 head->next = head->next->next;
170178 free(temp);
171179 }
172 else
180 else //if we ran out of facets to fix:
173181 {
174182 /* All of the facets in this part have been fixed. */
175183 stl->stats.number_of_parts += 1;
176184 /* There are (checked-checked_before) facets */
177185 /* in part stl->stats.number_of_parts */
178186 checked_before = checked;
179 if(checked == stl->stats.number_of_facets)
187 if(checked >= stl->stats.number_of_facets)
180188 {
181189 /* All of the facets have been checked. Bail out. */
182190 break;
1818 */
1919
2020 #include <stdlib.h>
21 #include <string.h>
2122
2223 #include "stl.h"
2324
1818 */
1919
2020 #include <stdlib.h>
21 #include <string.h>
2122 #include "stl.h"
23 #include "version.h"
2224
2325 #if !defined(SEEK_SET)
2426 #define SEEK_SET 0
5153 stl_stats_out(stl_file *stl, FILE *file, char *input_file)
5254 {
5355 fprintf(file, "\n\
54 ================= Results produced by ADMesh version 0.95 ================\n");
56 ================= Results produced by ADMesh version %g ================\n",VERSION);
5557 fprintf(file, "\
5658 Input file : %s\n", input_file);
5759 if(stl->stats.type == binary)
131133 if(fp == NULL)
132134 {
133135 error_msg =
134 malloc(81 + strlen(file)); /* Allow 80 chars+file size for message */
136 malloc(81 + strlen(file)); /* Allow 80 chars+file size for message */
135137 sprintf(error_msg, "stl_write_ascii: Couldn't open %s for writing",
136 file);
138 file);
137139 perror(error_msg);
138140 free(error_msg);
139141 exit(1);
196198 stl->neighbors_start[i].neighbor[2],
197199 (int)stl->neighbors_start[i].which_vertex_not[2]);
198200 }
201 fclose(fp);
199202 }
200203
201204 static void
120120
121121 /* Check for binary or ASCII file */
122122 fseek(stl->fp, HEADER_SIZE, SEEK_SET);
123 fread(chtest, sizeof(chtest), 1, stl->fp);
123 size_t retSize = fread(chtest, sizeof(chtest), 1, stl->fp);
124124 stl->stats.type = ascii;
125125 for(i = 0; i < sizeof(chtest); i++)
126126 {
146146 num_facets = (file_size - HEADER_SIZE) / SIZEOF_STL_FACET;
147147
148148 /* Read the header */
149 fread(stl->stats.header, LABEL_SIZE, 1, stl->fp);
150 stl->stats.header[80] = '\0';
151
149 retSize = fread(stl->stats.header, LABEL_SIZE, 1, stl->fp);
150
151 if (retSize>79) {
152 stl->stats.header[80] = '\0';
153 }
154
152155 /* Read the int following the header. This should contain # of facets */
153156 header_num_facets = stl_get_little_int(stl->fp);
154157 if(num_facets != header_num_facets)
203206 if(stl->facet_start == NULL) perror("stl_initialize");
204207 }
205208
209 //This function reads file_to_merge and ADDs the contents of the file to the
210 // already loaded and filled stl.
206211 void
207 stl_open_merge(stl_file *stl, char *file)
208 {
209 int first_facet;
210
211 first_facet = stl->stats.number_of_facets;
212 stl_initialize(stl, file);
212 stl_open_merge(stl_file *stl, char *file_to_merge)
213 {
214 int num_facets_so_far;
215
216 //Record how many facets we have so far from the first file. We will start putting
217 //facets in the next position. Since we're 0-indexed, it'l be the same position.
218 num_facets_so_far = stl->stats.number_of_facets;
219
220 //Record the file type we started with:
221 stl_type origStlType=stl->stats.type;
222 //Record the file pointer too:
223 FILE *origFp=stl->fp;
224
225 //Create an stl_file structure for the file to merge:
226 stl_file stl_to_merge;
227
228 //Initialize the sturucture with zero stats, header info and sizes:
229 stl_initialize(&stl_to_merge, file_to_merge);
230
231 //Copy what we need to into stl so that we can read the file_to_merge directly into it
232 //using stl_read: Save the rest of the valuable info:
233 stl->stats.type=stl_to_merge.stats.type;
234 stl->fp=stl_to_merge.fp;
235
236 //Add the number of facets we already have in stl with what we we found in stl_to_merge but
237 //haven't read yet.
238 stl->stats.number_of_facets=num_facets_so_far+stl_to_merge.stats.number_of_facets;
239
240 //Allocate enough room for stl->stats.number_of_facets facets and neighbors:
213241 stl_reallocate(stl);
214 stl_read(stl, first_facet, 0);
242
243 //Read the file to merge directly into stl, adding it to what we have already.
244 // Start at num_facets_so_far, the index to the first unused facet. Also say
245 // that this isn't our first time so we should augment stats like min and max
246 //instead of erasing them.
247 stl_read(stl, num_facets_so_far, 0);
248
249 //Restore the stl information we overwrote (for stl_read) so that it still accurately
250 // reflects the subject part:
251 stl->stats.type=origStlType;
252 stl->fp=origFp;
215253 }
216254
217255 static void
230268 if(stl->facet_start == NULL) perror("stl_initialize");
231269 }
232270
271 //Reads the contents of the file pointed to by stl->fp into the stl structure,
272 //starting at facet first_facet. The second argument says if it's our first
273 // time running this for the stl and therefore we should reset our max and min stats.
233274 static void
234275 stl_read(stl_file *stl, int first_facet, int first)
235276 {
240281 float diff_z;
241282 float max_diff;
242283
243
244284 if(stl->stats.type == binary)
245285 {
246286 fseek(stl->fp, HEADER_SIZE, SEEK_SET);
274314 }
275315 else
276316 /* Read a single facet from an ASCII .STL file */
277 {
278 fscanf(stl->fp, "%*s %*s %f %f %f\n", &facet.normal.x,
279 &facet.normal.y, &facet.normal.z);
280 fscanf(stl->fp, "%*s %*s");
281 fscanf(stl->fp, "%*s %f %f %f\n", &facet.vertex[0].x,
282 &facet.vertex[0].y, &facet.vertex[0].z);
283 fscanf(stl->fp, "%*s %f %f %f\n", &facet.vertex[1].x,
284 &facet.vertex[1].y, &facet.vertex[1].z);
285 fscanf(stl->fp, "%*s %f %f %f\n", &facet.vertex[2].x,
286 &facet.vertex[2].y, &facet.vertex[2].z);
287 fscanf(stl->fp, "%*s");
288 fscanf(stl->fp, "%*s");
289 }
317 {
318 size_t retSize = fscanf(stl->fp, "%*s %*s %f %f %f\n",
319 &facet.normal.x, &facet.normal.y, &facet.normal.z);
320 retSize = fscanf(stl->fp, "%*s %*s");
321 retSize = fscanf(stl->fp, "%*s %f %f %f\n", &facet.vertex[0].x,
322 &facet.vertex[0].y, &facet.vertex[0].z);
323 retSize = fscanf(stl->fp, "%*s %f %f %f\n", &facet.vertex[1].x,
324 &facet.vertex[1].y, &facet.vertex[1].z);
325 retSize = fscanf(stl->fp, "%*s %f %f %f\n", &facet.vertex[2].x,
326 &facet.vertex[2].y, &facet.vertex[2].z);
327 retSize = fscanf(stl->fp, "%*s");
328 retSize = fscanf(stl->fp, "%*s");
329 }
290330 /* Write the facet into memory. */
291331 stl->facet_start[i] = facet;
292332
7676 }
7777 }
7878
79 //Translates the stl by x,y,z, from wherever it is currently:
7980 void
8081 stl_translate(stl_file *stl, float x, float y, float z)
8182 {
8687 {
8788 for(j = 0; j < 3; j++)
8889 {
89 stl->facet_start[i].vertex[j].x -= (stl->stats.min.x - x);
90 stl->facet_start[i].vertex[j].y -= (stl->stats.min.y - y);
91 stl->facet_start[i].vertex[j].z -= (stl->stats.min.z - z);
92 }
93 }
94 stl->stats.max.x -= (stl->stats.min.x - x);
95 stl->stats.max.y -= (stl->stats.min.y - y);
96 stl->stats.max.z -= (stl->stats.min.z - z);
97 stl->stats.min.x = x;
98 stl->stats.min.y = y;
99 stl->stats.min.z = z;
90 stl->facet_start[i].vertex[j].x += x;
91 stl->facet_start[i].vertex[j].y += y;
92 stl->facet_start[i].vertex[j].z += z;
93 }
94 }
95 stl->stats.max.x += x;
96 stl->stats.max.y += y;
97 stl->stats.max.z += z;
98 stl->stats.min.x += x;
99 stl->stats.min.y += y;
100 stl->stats.min.z += z;
100101 }
101102
102103 void
0 #define VERSION 0.96