1 /*****************************************************************************
2 * This is the main header file for gtools.  nauty version 2.7.               *
3 * Subject to the copyright notice in nauty.h.                                *
4 * gtools.h.  Generated from gtools-h.in by configure.
5 *****************************************************************************/
6 
7 /* The parts between the ==== lines are modified by configure when
8 creating gtools.h out of gtools-h.in.  If configure is not being
9 used, it is necessary to check they are correct.
10 ====================================================================*/
11 
12 #ifndef  _GTOOLS_H_    /* only process this file once */
13 #define  _GTOOLS_H_
14 
15 #define HAVE_ERRNO_H  1      /* <errno.h> exists */
16 #define HAVE_PERROR  1          /* perror() exists */
17 #define HAVE_PIPE  1          /* pipe() exists */
18 #define HAVE_WAIT  1          /* wait() exists */
19 #define HAVE_WAIT_H  1     /* <sys/wait.h> exists */
20 #define HAVE_POPEN  1          /* popen() and pclose() exist */
21 #define POPEN_DEC  1         /* popen() is declared */
22 #define FTELL_DEC  1         /* ftell() is declared */
23 #define FDOPEN_DEC  1        /* fdopen() is declared */
24 #define SORTPROG  "sort"         /* name of sort program */
25 #define SORT_NEWKEY 1  /* if -k is supported */
26 #define HAVE_PID_T 1    /* pid_t is defined */
27 #define PUTENV_DEC 1   /* putenv() is declared */
28 #define SETENV_DEC 1   /* setenv() is declared */
29 #define HAVE_PUTENV 1   /* putenv() exists */
30 #define HAVE_SETENV 1   /* setenv() exists */
31 #define HAVE_FORK 1   /* fork() exists */
32 #define HAVE_PTHREADS 0   /* Posix threads exist */
33 #define HAVE_PTHREAD_H  1      /* <pthread.h> exists */
34 #define HAVE_SIGNAL_H  1      /* <signal.h> exists */
35 #define HAVE_FSEEKO 1  /* fseeko() and ftello() exist */
36 #define HAVE_SIGACTION 1  /* sigaction() exists */
37 #define HAVE_SIGPROCMASK 1  /* sigprocmask() exists */
38 #define ALLOW_INTERRUPT 1 /* no --disable-interrupt */
39 
40 /* ++++++ This file is automatically generated, don't edit it by hand! ++++++ */
41 
42 /*==================================================================*/
43 
44 #ifndef MAXN
45 #define MAXN  0
46 #endif
47 
48 #define SIZELEN(n) ((n)<=SMALLN?1:((n)<=SMALLISHN?4:8))
49 	/* length of size code in bytes */
50 #define G6BODYLEN(n) \
51    (((size_t)(n)/12)*((size_t)(n)-1) + (((size_t)(n)%12)*((size_t)(n)-1)+11)/12)
52 #define G6LEN(n) (SIZELEN(n) + G6BODYLEN(n))
53   /* exact graph6 string length excluding \n\0
54      This twisted expression works up to n=227023 in 32-bit arithmetic
55      and for larger n if size_t has 64 bits.  */
56 #define D6BODYLEN(n) \
57    ((n)*(size_t)((n)/6) + (((n)*(size_t)((n)%6)+5)/6))
58 #define D6LEN(n) (1 + SIZELEN(n) + D6BODYLEN(n))
59   /* exact digraph6 string length excluding \n\0
60      This twisted expression works up to n=160529 in 32-bit arithmetic
61      and for larger n if size_t has 64 bits.  */
62 
63 #include "naututil.h"      /* which includes stdio.h */
64 #include "nausparse.h"
65 
66 #if HAVE_ERRNO_H
67 #include <errno.h>
68 #else
69 extern int errno;
70 #endif
71 
72 #if HAVE_WAIT_H && !defined(AVOID_SYS_WAIT_H)
73 #include <sys/wait.h>
74 #endif
75 
76 #if HAVE_SIGNAL_H
77 #include <signal.h>
78 #endif
79 
80 #if HAVE_PERROR
81 #define ABORT(msg) do {if (errno != 0) perror(msg); exit(1);} while(0)
82 #else
83 #define ABORT(msg) do {exit(1);} while(0)
84 #endif
85 
86 /* Here we set environment variables that determine the sorting order
87    for the shortg program.  Older docs for sort say that it uses
88    LC_COLLATE, but the POSIX description of locales says that the
89    LC_ALL variable takes precedence over LC_COLLATE.  To be safe,
90    we will define both.  Also, define this to be nothing if the
91    variable KEEP_SORT_LOCALE is defined. */
92 #ifdef KEEP_SORT_LOCALE
93 #define SET_C_COLLATION
94 #else
95 #if PUTENV_DEC && HAVE_PUTENV
96 #define SET_C_COLLATION putenv("LC_ALL=C"); putenv("LC_COLLATE=C")
97 #elif SETENV_DEC && HAVE_SETENV
98 #define SET_C_COLLATION setenv("LC_ALL","C",1); setenv("LC_COLLATE","C",1)
99 #elif HAVE_PUTENV
100 int putenv(char*);
101 #define SET_C_COLLATION putenv("LC_ALL=C"); putenv("LC_COLLATE=C")
102 #elif HAVE_SETENV
103 int setenv(const char*,const char*,int);
104 #define SET_C_COLLATION setenv("LC_ALL","C",1); setenv("LC_COLLATE","C",1)
105 #else
106 #define SET_C_COLLATION
107 #endif
108 #endif
109 
110 #if HAS_STDIO_UNLOCK && !defined(NAUTY_IN_MAGMA) && !defined(IS_JAVA)
111 #define FLOCKFILE(f) flockfile(f)
112 #define FUNLOCKFILE(f) funlockfile(f)
113 #define GETC(f) getc_unlocked(f)
114 #undef PUTC
115 #define PUTC(c,f) putc_unlocked(c,f)
116 #else
117 #define FLOCKFILE(f)
118 #define FUNLOCKFILE(f)
119 #define GETC(f) getc(f)
120 #undef PUTC
121 #define PUTC(c,f) putc(c,f)
122 #endif
123 
124 #define BIAS6 63
125 #define MAXBYTE 126
126 #define SMALLN 62
127 #define SMALLISHN 258047
128 #define TOPBIT6 32
129 #define C6MASK 63
130 
131 #define GRAPH6_HEADER ">>graph6<<"
132 #define SPARSE6_HEADER ">>sparse6<<"
133 #define DIGRAPH6_HEADER ">>digraph6<<"
134 #define PLANARCODE_HEADER ">>planar_code<<"
135 #define PLANARCODELE_HEADER ">>planar_code le<<"
136 #define PLANARCODEBE_HEADER ">>planar_code be<<"
137 #define EDGECODE_HEADER ">>edge_code<<"
138 
139 #define GRAPH6         1
140 #define SPARSE6        2
141 #define PLANARCODE     4
142 #define PLANARCODELE   8
143 #define PLANARCODEBE  16
144 #define EDGECODE      32
145 #define INCSPARSE6    64
146 #define PLANARCODEANY (PLANARCODE|PLANARCODELE|PLANARCODEBE)
147 #define DIGRAPH6     128
148 #define UNKNOWN_TYPE 256
149 #define HAS_HEADER   512
150 
151 #define NODIGRAPHSYET(code) if (((code)&DIGRAPH6)) \
152   gt_abort(">E Sorry, this program doesn't support digraphs yet.\n")
153 
154 #define ARG_OK 0
155 #define ARG_MISSING 1
156 #define ARG_TOOBIG 2
157 #define ARG_ILLEGAL 3
158 
159 #define MAXARG 2000000000L
160 #define NOLIMIT (MAXARG+31L)
161 
162 #define SWBOOLEAN(c,boool) if (sw==c) boool=TRUE;
163 #define SWCOUNT(c,count) if (sw==c) ++count;
164 #define SWINT(c,boool,val,id) if (sw==c) \
165         {boool=TRUE;arg_int(&arg,&val,id);}
166 #define SWLONG(c,boool,val,id) if (sw==c) \
167         {boool=TRUE;arg_long(&arg,&val,id);}
168 #define SWRANGE(c,sep,boool,val1,val2,id) if (sw==c) \
169 	{boool=TRUE;arg_range(&arg,sep,&val1,&val2,id);}
170 #define SWREAL(c,boool,val,id) if (sw==c) \
171         {boool=TRUE;arg_double(&arg,&val,id);}
172 #define SWREALRANGE(c,sep,boool,val1,val2,id) if (sw==c) \
173 	{boool=TRUE;arg_doublerange(&arg,sep,&val1,&val2,id);}
174 #define SWSEQUENCE(c,sep,boool,val,maxvals,numvals,id) if (sw==c) \
175         {boool=TRUE;arg_sequence(&arg,sep,val,maxvals,&numvals,id);}
176 #define SWSEQUENCEMIN(c,sep,boool,val,minvals,maxvals,numvals,id) if (sw==c) \
177         {boool=TRUE;arg_sequence_min(&arg,sep,val,minvals,maxvals,&numvals,id);}
178 
179 #ifdef HELPUSECMD
180 #ifdef HELPTEXT2
181 #define PUTHELPTEXT printf("\nUsage: %s %s\n\n%s",argv[0],USAGE,HELPTEXT1);\
182 		    printf("%s",HELPTEXT2);
183 #else
184 #define PUTHELPTEXT printf("\nUsage: %s %s\n\n%s",argv[0],USAGE,HELPTEXT)
185 #endif
186 #else
187 #ifdef HELPTEXT2
188 #define PUTHELPTEXT printf("\nUsage: %s\n\n%s",USAGE,HELPTEXT1);\
189 		    printf("%s",HELPTEXT2);
190 #else
191 #define PUTHELPTEXT printf("\nUsage: %s\n\n%s",USAGE,HELPTEXT)
192 #endif
193 #endif
194 
195 #define HELP if (argc > 1 && (strcmp(argv[1],"-help")==0 \
196 			   || strcmp(argv[1],"/?")==0 \
197 			   || strcmp(argv[1],"--help")==0)) \
198        { PUTHELPTEXT; return 0; }
199 
200 #define PUTVERSION if (argc > 1 && (strcmp(argv[1],"-version")==0 \
201 			   || strcmp(argv[1],"--version")==0)) \
202        { printf("Nauty&Traces version %.4f (%d bits)\n",\
203        NAUTYVERSIONID/10000.0,WORDSIZE); return 0; }
204 
205 #define GETHELP \
206 fprintf(stderr,"   Use %s -help to see more detailed instructions.\n",argv[0])
207 
208 #define alloc_error gt_abort
209 
210 #define CATMSG0(fmt) sprintf(msg+strlen(msg),fmt)
211 #define CATMSG1(fmt,x1) sprintf(msg+strlen(msg),fmt,x1)
212 #define CATMSG2(fmt,x1,x2) sprintf(msg+strlen(msg),fmt,x1,x2)
213 #define CATMSG3(fmt,x1,x2,x3) sprintf(msg+strlen(msg),fmt,x1,x2,x3)
214 #define CATMSG4(fmt,x1,x2,x3,x4) sprintf(msg+strlen(msg),fmt,x1,x2,x3,x4)
215 #define CATMSG5(fmt,x1,x2,x3,x4,x5) sprintf(msg+strlen(msg),fmt,x1,x2,x3,x4,x5)
216 #define CATMSG6(fmt,x1,x2,x3,x4,x5,x6) \
217 		sprintf(msg+strlen(msg),fmt,x1,x2,x3,x4,x5,x6)
218 
219 /************************************************************************/
220 
221 /* ++++++ This file is automatically generated, don't edit it by hand! ++++++ */
222 
223 #ifdef __cplusplus
224 extern "C" {
225 #endif
226 
227 extern void gtools_check(int,int,int,int);
228 extern FILE *opengraphfile(char*,int*,boolean,long);
229 extern void writeline(FILE*,char*);
230 extern char *gtools_getline(FILE*);     /* formerly getline() */
231 extern int graphsize(char*);
232 extern void encodegraphsize(int,char**);
233 extern void stringcounts(char*,int*,size_t*);
234 extern void stringtograph(char*,graph*,int);
235 extern void stringtograph_inc(char*,graph*,int,graph*,int);
236 extern size_t edgecount(char*);
237 extern int checkgline(char*);
238 extern graph *readgg(FILE*,graph*,int,int*,int*,boolean*);
239 extern graph *readg(FILE*,graph*,int,int*,int*);
240 extern graph *readgg_inc(FILE*,graph*,int,int*,int*,graph*,int,int,boolean*);
241 extern graph *readg_inc(FILE*,graph*,int,int*,int*,graph*,int,int);
242 extern char *ntog6(graph*,int,int);
243 extern char *ntos6(graph*,int,int);
244 extern char *ntod6(graph*,int,int);
245 extern char *sgtos6(sparsegraph*);
246 extern char *sgtog6(sparsegraph*);
247 extern char *sgtod6(sparsegraph*);
248 extern void writeg6(FILE*,graph*,int,int);
249 extern void writed6(FILE*,graph*,int,int);
250 extern void writes6(FILE*,graph*,int,int);
251 extern void writeg6_sg(FILE*,sparsegraph*);
252 extern void writes6_sg(FILE*,sparsegraph*);
253 extern void writed6_sg(FILE*,sparsegraph*);
254 extern char *ntois6(graph*,graph*,int,int);
255 extern void writeis6(FILE*,graph*,graph*,int,int);
256 extern void writepc_sg(FILE*,sparsegraph*);
257 extern void stringtosparsegraph(char*,sparsegraph*,int*);
258 extern sparsegraph *read_sg(FILE*,sparsegraph*);
259 extern sparsegraph *read_sg_loops(FILE*,sparsegraph*,int*);
260 extern sparsegraph *read_sgg_loops(FILE*,sparsegraph*,int*,boolean*);
261 extern sparsegraph *readpc_sg(FILE*,sparsegraph*);
262 extern sparsegraph *readpcle_sg(FILE*,sparsegraph*);
263 extern char *getecline(FILE*);
264 extern void writelast(FILE*);
265 extern int longval(char**,long*);
266 extern void arg_int(char**,int*,char*);
267 extern void arg_long(char**,long*,char*);
268 extern void arg_range(char**,char*,long*,long*,char*);
269 extern int doublevalue(char**,double*);
270 extern void arg_double(char**,double*,char*);
271 extern void arg_doublerange(char**,char*,double*,double*,char*);
272 extern void arg_sequence(char**,char*,long*,int,int*,char*);
273 extern void arg_sequence_min(char**,char*,long*,int,int,int*,char*);
274 
275 extern void writerange(FILE*,int,long,long);
276 extern void gt_abort(const char*);
277 extern char *stringcopy(char*);
278 extern boolean strhaschar(char*,int);
279 
280 extern void fcanonise(graph*,int,int,graph*,char*,boolean);
281 extern void fcanonise_inv
282              (graph*,int,int,graph*,char*,void(*)(graph*,int*,int*,int,
283                int,int,int*,int,boolean,int,int),int,int,int,boolean);
284 extern void fcanonise_inv_sg
285            (sparsegraph*,int,int,sparsegraph*,char*,void(*)(graph*,int*,int*,
286              int,int,int,int*,int,boolean,int,int),int,int,int,boolean);
287 extern void setlabptn(int*,int*,int*,int);
288 extern void fgroup(graph*,int,int,char*,int*,int*);
289 extern void fgroup_inv
290 	     (graph*,int,int,char*,int*,int*,void(*)(graph*,int*,int*,int,
291                 int,int,int*,int,boolean,int,int),int,int,int);
292 extern int istransitive(graph*,int,int,graph*);
293 extern void tg_canonise(graph*,graph*,int,int);
294 
295 extern TLS_ATTR int readg_code;
296 extern TLS_ATTR char *readg_line;
297 extern TLS_ATTR size_t ogf_linelen;
298 extern TLS_ATTR boolean is_pipe;
299 
300 #ifdef __cplusplus
301 }
302 #endif
303 
304 #ifdef CPUDEFS
305 CPUDEFS
306 #endif
307 
308 /* ++++++ This file is automatically generated, don't edit it by hand! ++++++ */
309 
310 #endif /* _GTOOLS_H_  */
311