summaryrefslogtreecommitdiff
path: root/web/funnelweb/0stoppress/fw_p_next_patch.mes
blob: 4c9d895fb95b127a4e5ab7ab7a0d46520b3519b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
           ___      ___

|\/|  /\  /    |__|  |  |\ |     |__|

|  | /--\ \___ |  | _|_ | \|  .  |  |



/*##############################################################################

FUNNNELWEB COPYRIGHT
====================
FunnelWeb is a literate-programming macro preprocessor.

Copyright (C) 1992 Ross N. Williams.

   Ross N. Williams
   ross@spam.adelaide.edu.au
   16 Lerwick Avenue, Hazelwood Park 5066, Australia.

This program is free software; you can redistribute it and/or modify
it under the terms of Version 2 of the GNU General Public License as
published by the Free Software Foundation.

This program is distributed WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See Version 2 of the GNU General Public License for more details.

You should have received a copy of Version 2 of the GNU General Public
License along with this program. If not, you can FTP the license from
prep.ai.mit.edu/pub/gnu/COPYING-2 or write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Section 2a of the license requires that all changes to this file be
recorded prominently in this file. Please record all changes here.

Programmers:
   RNW  Ross N. Williams  ross@spam.adelaide.edu.au

Changes:
   07-May-1992  RNW  Program prepared for release under GNU GPL V2.

##############################################################################*/


/******************************************************************************/
/*                                    MACHIN.H                                */
/******************************************************************************/
/*                                                                            */
/* WARNING: DO NOT ADD ANY PROGRAM DEPENDENT DEFINITIONS.                     */
/*                                                                            */
/* This module (machin.h and machin.c) contains definitions and objects       */
/* whose values depends directly on the compilation and execution             */
/* environment, but are otherwise independent from any particular computer    */
/* program.                                                                   */
/*                                                                            */
/* The only difference between the purpose of this module and the "environ"   */
/* module is that the "environ" module contains the "essentials" whereas this */
/* module contains extra machine specific definitions and objects that will   */
/* not be required by most user modules.                                      */
/*                                                                            */
/******************************************************************************/

/* Ensure that the body of this header file is included at most once.         */
#ifndef DONE_FWMACHIN
#define DONE_FWMACHIN

/******************************************************************************/

#include <time.h>
#include "style.h"

/******************************************************************************/

/* Machine Alignment Constraints                                              */
/* -----------------------------                                              */
/* Some machines require that objects of particular lengths be aligned in     */
/* memory. For example, the 68000 will trap any attempt to access a word      */
/* (16 bits or an int in THINK C) at an odd address. It is important that C   */
/* programs that deal with memory at a low level be aware of such             */
/* constraints. As the constraints are always at a power of two, we defined   */
/* ALIGN_POWER to be the minimum power of two at which it is both safe and    */
/* efficient to operate.                                                      */

/* The Macintosh requires words and longs to be aligned on word boundaries.   */
/* The PC is not fussy about alignment, but operates more efficiently at word */
/* boundaries.                                                                */
#if MAC | PC | NEXT
#define ALIGN_POWER (1L)
#endif

/* The Sun requires objects to be aligned on longword boundaries (=2^2).      */
/* The VMS VAX doesn't care about alignment, but operates more efficiently on */
/* longword boundaries.                                                       */
#if SUN | VMS
#define ALIGN_POWER (2L)
#endif

/******************************************************************************/

/* Filenames                                                                  */
/* ---------                                                                  */
/* The length and structure of filenames varies from machine to machine. The  */
/* differences addressed here are:                                            */
/*    1) The character used to separate directory specs from filenames.       */
/*    2) The maximum length of a filename.                                    */

/* FN_DELIM must contain the character that separates directory specs from    */
/* filenames. Notice that in the VMS case, it is "]", not "."                 */

#if MAC
#define FN_DELIM ':'
#endif

#if SUN | NEXT
#define FN_DELIM '/'
#endif

#if VAX
#define FN_DELIM ']'
#endif

#if PC
#define FN_DELIM '\\'
#endif

/* The rest of this section shouldn't have to be changed, unless you          */
/* encounter a funny with your system's definition of FILENAME_MAX.           */

/* FILENAME_MAX tells the maximum number of characters allowed in a filename  */
/* on the target machine. This symbol is supposed to be defined in stdio.h    */
/* (ANSI S7.9.1) so we don't want to override that. However, if it isn't, we  */
/* need to define a safe default length.                                      */
#ifndef FILENAME_MAX
#define FILENAME_MAX 300
#endif

/* Some VAX compilers define FILENAME_MAX to be 39, which is the maximum      */
/* length of the NAME part of a VMS filename. This is not appropriate, so we  */
/* override it.                                                               */
#if VMS
#undef FILENAME_MAX
#define FILENAME_MAX 255        /* Should really be NAM$C_MAXRSS              */
#endif

/* Now we can use the constant to define a filename type.                     */
/* Note: For a while I defined "typedef fn_t *p_fn_t". However, this is a     */
/* pointer to an array rather than (char *) and it caused no end of problems. */
typedef char fn_t[FILENAME_MAX+1];
typedef char *p_fn_t;

/******************************************************************************/

/* Command Lines                                                              */
/* -------------                                                              */
/* The maximum length of command line varies from machine to machine and we   */
/* define symbols to reflect this. The reason why we don't just set this to a */
/* high value and forget about it is that FunnelWeb sometimes places          */
/* command line variables on the stack, and some machines (e.g. MAC under     */
/* THINK-C don't provide much stack space. So we have to minimize this        */
/* variable on those machines.                                                */

/* We choose a small maximum command line on the Macintosh so as to avoid     */
/* chewing up stack space when command lines have to be pushed.               */
#if MAC
#define COMLINE_MAX 300
#endif

/* On the Sun, 1024 is a normal command line and 2048 is safe. */
#if SUN
#define COMLINE_MAX 2048
#endif

/* On the NeXT, 1024 seems like a decent guess. */
#if NEXT
#define COMLINE_MAX 1024
#endif

/* On the VMS, 1024 is usually adequate. */
#if VMS
#define COMLINE_MAX 1024
#endif

/* On a PC, we assume this is enough. */
#if PC
#define COMLINE_MAX 300
#endif

/* Make sure that the value is not too low. */
/* The value 300 is guaranteed by the command interpreter. */
#if COMLINE_MAX < 300
   #error COMLINE_MAX must be at least 300.
#endif

/* Now define a type for command lines.                                       */
/* Note: For a while I defined "typedef cl_t *p_cl_t". However, this is a     */
/* pointer to an array rather than (char *) and it caused no end of problems. */
typedef char cl_t[COMLINE_MAX+1];
typedef char *p_cl_t;

/******************************************************************************/

/* Line Termination                                                           */
/* ----------------                                                           */

/* FunnelWeb has special-case code to make reading input files faster on      */
/* machines where the format of text files corresponds to the internal C      */
/* text stream model. The UNIX_EOL #define should be activated if and only    */
/* the host environment has text files consisting of a stream of bytes with   */
/* a single LF (ASCII,decimal-10,hex-0A) character being used to terminate    */
/* each line, and no special character to indicate end of file.               */
/* This is the same format as is used in the Unix operating system.           */
/* If you are in doubt about this, play it safe and define your environment   */
/* to be non-Unix, as non-Unix will work on ALL systems (including Unix).     */

#if MAC | VMS | PC
/* These systems do NOT use Unix EOLs. */
#define UNIX_EOL 0
#endif

#if SUN | NEXT
/* This should really be 1 on a SUN, but I haven't got around to debugging    */
/* FunnelWeb with UNIX_EOL==1.                                                */
#define UNIX_EOL 0
#endif

/******************************************************************************/

/* MIssing Prototypes                                                         */
/* ----------------                                                           */
/* Compilers that are fussy about prototypes sometimes complain about calls   */
/* to the standard libraries. These declarations solve this problem.          */

#if SUN
int     fclose  P_((FILE *stream));
int     fputs   P_((const char *s, FILE *stream));
int     fputc   P_((int c, FILE *stream));
int     fflush  P_((FILE *stream));
int     remove  P_((const char *filename));
int     rename  P_((const char *oldname, const char *newname));
int     toupper P_((int));
int     sscanf  P_(());
int     fprintf P_(());
int     _filbuf P_(());
void    *memcpy P_((void *s1, void *s2, size_t n));
void    *memset P_((void *s,     int c, size_t n));
int     memcmp  P_((void *s1, void *s2, size_t n));
size_t  fread   P_((void *ptr, size_t size, size_t nobj, FILE *stream));
size_t  fwrite  P_((const void *ptr, size_t size, size_t nobj, FILE *stream));
clock_t clock   P_((void));
time_t  time    P_((time_t *tp));
int     printf  P_(());
#endif

/******************************************************************************/

EXPORT void fn_ins P_((p_fn_t,char *));
/* - The name stands for FileName INSert.                                     */
/* - The first argument must be a pointer to an object of type fn_t           */
/*   (containing an ordinary C character string).                             */
/* - The second argument must be a pointer to an ordinary C character string. */
/* - Both arguments must contain a full, partial, or empty filename spec.     */
/* - We will refer to the arguments as f1 and f2.                             */
/* - If there is a syntax error in either spec, fn_ins does nothing.          */
/* - Otherwise, it:                                                           */
/*      1. Analyses the two filename specifications into filename field .     */
/*      2. Replaces each field in f1 by the corresponding field in f2, but    */
/*         only if the corresponding field in f2 is non-empty.                */
/*      3. Optionally [concession to VMS] it may then replace blank fields    */
/*         in the resulting file spec in f1 by fields from the current        */
/*         global "default" directory spec.                                   */
/* The structure and fields of filenames will vary from machine to machine    */
/* and so this is not important. However, every implementation must structure */
/* the filename so that it will at least RECOGNISE a file extension           */
/* (e.g. ".lis") field.                                                       */

/******************************************************************************/

EXPORT void getcline P_((int,char **,char *));
/* Operating system environments vary a lot in the way in which their command */
/* language interfaces are set up. The approach taken in FunnelWeb is to      */
/* define a "standard" Unix-like command line syntax and then insist that     */
/* other environments deliver such a command line as a single string.         */
/* This function getcline must extract such a standard command line from its  */
/* environment and copy it as a single string of not more than COMLINE_MAX    */
/* characters into its third argument. A description of the "standard"        */
/* command line can be found in the options package.                          */
/* The first  argument is given to getcline and is argc from main().          */
/* The second argument is given to getcline and is argv from main().          */
/* These two arguments are given in case getcline needs them to assemble the  */
/* command line (as opposed to calling e.g. VMS CLI routines).                */
/* The third argument is the string into which the result should be placed.   */

/******************************************************************************/

EXPORT float tim_real P_((void));
/* Returns the number of seconds between the present and an unspecified, but  */
/* statically fixed time in the past.                                         */
/* Returns 0.0 if this information is unavailable                             */

EXPORT float tim_cpu P_((void));
/* Returns the number of CPU seconds consumed between the present and an      */
/* unspecified, but statically fixed time in the past.                        */
/* Returns 0.0 if this information is unavailable                             */

/******************************************************************************/

/* For #ifndef preventing multiple inclusion of the body of this header file. */
#endif

/******************************************************************************/
/*                                End of MACHIN.H                             */
/******************************************************************************/







           ___      ___           ___

|\/|  /\  /    |__|  |  |\ |     /

|  | /--\ \___ |  | _|_ | \|  .  \___




/*##############################################################################

FUNNNELWEB COPYRIGHT
====================
FunnelWeb is a literate-programming macro preprocessor.

Copyright (C) 1992 Ross N. Williams.

   Ross N. Williams
   ross@spam.adelaide.edu.au
   16 Lerwick Avenue, Hazelwood Park 5066, Australia.

This program is free software; you can redistribute it and/or modify
it under the terms of Version 2 of the GNU General Public License as
published by the Free Software Foundation.

This program is distributed WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See Version 2 of the GNU General Public License for more details.

You should have received a copy of Version 2 of the GNU General Public
License along with this program. If not, you can FTP the license from
prep.ai.mit.edu/pub/gnu/COPYING-2 or write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Section 2a of the license requires that all changes to this file be
recorded prominently in this file. Please record all changes here.

Programmers:
   RNW  Ross N. Williams  ross@spam.adelaide.edu.au

Changes:
   07-May-1992  RNW  Program prepared for release under GNU GPL V2.

##############################################################################*/


/******************************************************************************/
/*                                    MACHIN.C                                */
/******************************************************************************/
/*                                                                            */
/* WARNING: DO NOT ADD ANY PROGRAM DEPENDENT DEFINITIONS.                     */
/*                                                                            */
/* This file contains machine-dependent, program-independent stuff that       */
/* implements the functionality promised in MACHIN.H.                         */
/*                                                                            */
/* Note: As usual, the full definitions of functions in the .H file are not   */
/*       repeated here.                                                       */
/*                                                                            */
/******************************************************************************/

#include <time.h>
#include "style.h"

#include "as.h"
#include "machin.h"

/* The Macintosh's doesn't have a command language, and so we have to prompt  */
/* for a command line. This requires a special package.                       */
#if MAC
#include <console.h>
#endif

/* Under VMS, we need RMS to get at stuff to do with filenames.               */
#if VMS
#include RMS
#endif

/******************************************************************************/
/*                           LOCAL FUNCTIONS                                  */
/******************************************************************************/

LOCAL void mconcat P_((int,char **,char *));
LOCAL void mconcat(argc,argv,result)
/* Given argc and argv, as passed to main(), this function appends all the    */
/* arguments together (separated by spaces) into the string "result".         */
/* This function assists in reconstructing the command line.                  */
/* This function is actually portable, so you shouldn't have to change it.    */
/* Note: "mconcat" stands for Multiple CONCATenation.                         */
int    argc;
char **argv;
char *result;
{
 uword i;
 strcpy(&result[0],argv[0]);
 for (i=1;i<argc;i++)
   {
    strcat(&result[0]," "    );
    strcat(&result[0],argv[i]);
   }
}

/******************************************************************************/

#if MAC | SUN | PC | NEXT
LOCAL void fn_split P_((p_fn_t,p_fn_t,p_fn_t,p_fn_t));
LOCAL void fn_split(p_fn,p_path,p_name,p_ext)
/* Accepts a filename in p_fn and writes the path, name, and extension        */
/* components of the filename to the strings p_path, p_name, and p_ext.       */
p_fn_t p_fn;
p_fn_t p_path;
p_fn_t p_name;
p_fn_t p_ext;
{
 char *p,*q;

 /* Make sure that the input filename is a sensible length. */
 as_cold(strlen(p_fn)<=FILENAME_MAX,"fn_split: Filename is too long.");

 /* Extract the path from the input string by searching for the last */
 /* occurrance of the special character used for directories.        */

 /* Find the last directory/filename separator. */
 p=strrchr(p_fn,FN_DELIM);
 if (p==NULL)
   {strcpy(p_path,""); p=p_fn;}
 else
   {
    memcpy(p_path,p_fn,(size_t) (p-p_fn+1));
    p_path[(size_t) (p-p_fn+1)]=EOS;
    p++;
   }

 /* Assert: p now points to the first character of the name field. */

 /* Now locate the file extension. */
 q=strrchr(p_fn,'.');
 if (q==NULL)
   {strcpy(p_ext,""); q = &p_fn[strlen(p_fn)];}
 else
   {strcpy(p_ext,q);}

 /* Assert: q now points to the '.' preceding the extension field. */

 /* Now anything between p and q must be the filename proper. */
 for (;p<q;p++)
    *p_name++ = *p;
 *p_name=EOS;
}
#endif

/******************************************************************************/

#if MAC | SUN | PC | NEXT
LOCAL void fn_join P_((p_fn_t,p_fn_t,p_fn_t,p_fn_t));
LOCAL void fn_join(p_fn,p_path,p_name,p_ext)
/* This function sets p_fn to the empty string and then successively appends  */
/* p_path, p_name, and p_ext. Before doing this, it checks to make sure that  */
/* there will be enough room and bombs the program if there isn't.            */
p_fn_t p_fn;
p_fn_t p_path;
p_fn_t p_name;
p_fn_t p_ext;
{
 as_cold(strlen(p_path)+strlen(p_name)+strlen(p_ext) <= FILENAME_MAX,
         "fn_join: Constructed filename is too long.");
 strcpy(p_fn,p_path);
 strcat(p_fn,p_name);
 strcat(p_fn,p_ext);
}
#endif

/******************************************************************************/
/*                              EXPORTED FUNCTIONS                            */
/******************************************************************************/

#if MAC | SUN | PC | NEXT
EXPORT void fn_ins(p_cur,p_add)
p_fn_t p_cur;
p_fn_t p_add;
{
 fn_t cur_path, add_path;
 fn_t cur_name, add_name;
 fn_t cur_extn, add_extn;

 /* Split the argument file names into their component parts. */
 fn_split(p_cur,cur_path,cur_name,cur_extn);
 fn_split(p_add,add_path,add_name,add_extn);

 /* Perform the inheriting on a field by field basis. */
 if (strlen(add_path) > 0) strcpy(cur_path,add_path);
 if (strlen(add_name) > 0) strcpy(cur_name,add_name);
 if (strlen(add_extn) > 0) strcpy(cur_extn,add_extn);

 /* Put the fields back together again to yield the final result. */
 fn_join(p_cur,cur_path,cur_name,cur_extn);
}
#endif

#if VMS
EXPORT void fn_ins(p_cur,p_add)
/* This VMS version of fn_ins was written with the assistance of:             */
/*    Jeremy Begg (jeremy@vsm.com.au) of VSM Software Services. Thanks!       */
/* The VMS version is messy because VMS has highly structured filenames and   */
/* highly ingrained rituals for manipulating them.                            */
p_fn_t p_cur;
p_fn_t p_add;
{
 struct FAB cur_fab;   /* FAB    for SYS$PARSE */
 struct NAM cur_nam;   /* NAM    for SYS$PARSE */
 fn_t expanded;        /* Result of  SYS$PARSE */
 long rms_status;      /* Status of  SYS$PARSE */

 /*
 printf("\nTRACE: Call of fn_ins(...).\n");
 printf("   Current spec = \"%s\".\n",p_cur);
 printf("   Add     spec = \"%s\".\n",p_add);
 */

 /* Initialize the FAB and NAM block to something sensible. */
 cur_fab = cc$rms_fab;
 cur_nam = cc$rms_nam;

 /* (fna,fns) is address and size of input file spec in FAB block. */
 cur_fab.fab$l_fna = p_add;
 cur_fab.fab$b_fns = strlen(p_add);

 /* (dna,dns) is address and size of default file spec in FAB block. */
 cur_fab.fab$l_dna = p_cur;
 cur_fab.fab$b_dns = strlen(p_cur);

 /* Connect the NAM block to the FAB block. */
 cur_fab.fab$l_nam = &cur_nam;

 /* Point the NAM block's target name fields to the target namechar array. */
 cur_nam.nam$l_esa = &expanded;
 cur_nam.nam$b_ess = FILENAME_MAX;  /* Reserve last char for NULL terminator */

 /* PWD => put the password from a DECnet Access Control String in the filespec
  * SYNCHK => check syntax only, don't search for the file on disk
  */
 cur_nam.nam$b_nop = NAM$M_PWD + NAM$M_SYNCHK;

 /* Perform the parse. */
 rms_status = sys$parse(&cur_fab);
 if (rms_status & 1)
   {
    expanded[cur_nam.nam$b_esl]=EOS; /* Terminate VMS string. */
    strcpy(p_cur,expanded);
   }
 else
   {
    printf("Note: RMS parse failed. Could be a syntax error, could be a bug!\n");
   }

 /* TRACE printf("   Result  spec = \"%s\".",p_cur); */
}
#endif

/******************************************************************************/

EXPORT void getcline(argc,argv,p_comline)
/* Given, argc and argv, writes a command line string in p_comline.           */
/* See machin.h for a thorough definition of this function.                   */
int   argc;
char **argv;
char *p_comline;
{
 int    argc2;
 char **argv2;

#if MAC
 /* On the Macintosh there is no command language and therefore no command    */
 /* line. Therefore we cannot trust the argc and argv handed to us by main()  */
 /* and have to obtain a command line from other sources.                     */
 /* The "ccommand" function comes from <console.h> of the THINK C libraries.  */
 argc2=ccommand(&argv2);
#endif

/* The other systems work like Unix. */
#if SUN | VMS | PC | NEXT
argc2=argc;
argv2=argv;
#endif

 /* The command line is currently in pieces. Reassemble it. That's all!       */
 mconcat(argc2,argv2,p_comline);
}

/******************************************************************************/

EXPORT float tim_real()
{
 STAVAR bool   init=FALSE;
 STAVAR time_t base;

 /* The first time this routine is called, we establish a base real time      */
 /* from which real time differences are calculated. There are two reasons    */
 /* for doing this. The first is that difftime seems to be the only way to    */
 /* get ANSI C to hand over a calibrated arithmetic type holding the real     */
 /* time. The second is that we don't want to have to deal with large         */
 /* absolute times anyway.                                                    */
 if (!init)
   {
    /* Returns -1 if the time is not available (ANSI 7.12.2.4). */
    base=time(NULL);
    init=TRUE;
   }

 /* Return the elapsed time since the base time. */

/* Macintosh, VMS, and PC have difftime. */
#if MAC | VMS | PC
 if (base == -1)
    return 0.0;
 else
    return (float) difftime(time(NULL),base);
#endif

/* Sun and NeXT do not have difftime. */
#if SUN | NEXT
 return 0.0;
#endif

/* The timing functions are only used to generate performance statistics and  */
/* are not critical to FunnelWeb. There is not much harm in returning 0.0.    */
}

/******************************************************************************/

EXPORT float tim_cpu()
{
 clock_t t=clock();

/* Make sure that we have a definition for CLOCKS_PER_SEC. */
#ifndef CLOCKS_PER_SEC
#ifdef CLK_TCK
#define CLOCKS_PER_SEC CLK_TCK
#else
/* Assume one million ticks per second. */
#define CLOCKS_PER_SEC (1000000L)
#endif
#endif

 /* The clock() function returns -1 if the CPU time is not available. */
 /* Otherwise it returns the number of "clocks" since power-up.       */
 if (t == -1)
    return 0.0;
 else
    return ((float) t) / ((float) CLOCKS_PER_SEC);
}

/******************************************************************************/
/*                              End of MACHIN.C                               */
/******************************************************************************/







 ___           ___ __   _

|__  |\ | \  /  |  |_) / \ |\ |     |__|

|___ | \|  \/  _|_ | \ \_/ | \|  .  |  |




/*##############################################################################

FUNNNELWEB COPYRIGHT
====================
FunnelWeb is a literate-programming macro preprocessor.

Copyright (C) 1992 Ross N. Williams.

   Ross N. Williams
   ross@spam.adelaide.edu.au
   16 Lerwick Avenue, Hazelwood Park 5066, Australia.

This program is free software; you can redistribute it and/or modify
it under the terms of Version 2 of the GNU General Public License as
published by the Free Software Foundation.

This program is distributed WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See Version 2 of the GNU General Public License for more details.

You should have received a copy of Version 2 of the GNU General Public
License along with this program. If not, you can FTP the license from
prep.ai.mit.edu/pub/gnu/COPYING-2 or write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Section 2a of the license requires that all changes to this file be
recorded prominently in this file. Please record all changes here.

Programmers:
   RNW  Ross N. Williams  ross@spam.adelaide.edu.au

Changes:
   07-May-1992  RNW  Program prepared for release under GNU GPL V2.

##############################################################################*/


/******************************************************************************/
/*                                   ENVIRON.H                                */
/******************************************************************************/
/*                                                                            */
/* WARNING: DO NOT ADD ANY PROGRAM-DEPENDENT DEFINITIONS.                     */
/*                                                                            */
/* This header file environ.h contains definitions and objects whose values   */
/* depends directly on the compilation and execution environment, but are     */
/* otherwise independent of any particular computer program.                  */
/*                                                                            */
/* This is one of two machine-dependent, program-independent modules. The     */
/* other module is machin (machin.h,machin.c). This "environ" module contains */
/* definitions and objects that are considered essential. The "machin" module */
/* contains less essential definitions. Motivation for the division came from */
/* the fact that style.h (used by almost every module) includes environ.h     */
/* (this file), and from the need for the stuff in style.h by some            */
/* environment-dependent definitions.                                         */
/*                                                                            */
/* There seems to be two ways to organize a module such as this one. The      */
/* first is to have a different version of this module for each target        */
/* environment. The second is to have a single file that uses #defines and    */
/* #ifs to select between code for each target environment. I have chosen the */
/* latter method as this allows many different environments to share the same */
/* definitions.                                                               */
/*                                                                            */
/******************************************************************************/

/* Ensure that the body of this header file is included at most once.         */
#ifndef DONE_ENVIRON
#define DONE_ENVIRON

/******************************************************************************/

/* Select An Environment                                                      */
/* ---------------------                                                      */
/* Choose the environment in which the program will be compiled and executed. */
/* This may be the only change you need to make to get FunnelWeb to compile.  */
/*                                                                            */
/* If your exact environment is not listed, try one that is close.            */
/* If problems arise, an attempt should be made to solve them                 */
/* without creating a new environment definition.  However, if this is not    */
/* possible, define a new environment below and "implement" it by going       */
/* through environ.h and machin.h and machin.c and adding appropriate         */
/* definitions.                                                               */
/*                                                                            */
/* The following table lists real/defined environment pairs under which       */
/* FunnelWeb is known to compile cleanly.                                     */
/*                                                                            */
/* Symbol = Processor  Machine       OS            Compiler                   */
/* ------   ---------  -------       --            --------                   */
/*    MAC = 68000      Macintosh-SE  Mac           THINK-C V4.0.5             */
/*    SUN = SPARC      SUN ELC       Unix(SunOS)   GNUC                       */
/*    VMS = VAX        VAXStation    VMS           VAXC                       */
/*     PC = 386        IBM PC Clone  MSDOS5.0      Borland C++                */
/*   NEXT = 68000      NeXTstation   Unix(BSD4.3)  GNUC                       */
/*                                                                            */
/* Set exactly one of the following environments to 1, the others to 0.       */

#define MAC  0
#define SUN  0
#define VMS  0
#define PC   0
#define NEXT 1

/* Ensure that exactly one environment has been selected.                     */
#if MAC+SUN+VMS+PC+NEXT != 1
   #error Error: You must choose exactly one machine in ENVIRON.H.
#endif

/******************************************************************************/

/* Establish Presence or Absence of __STDC__                                  */
/* -----------------------------------------                                  */
/* The __STDC__ symbol is very useful for determining if the compiler is      */
/* ANSI. However, some "nearly ANSI" compilers don't set this symbol, and     */
/* experience shows that things turn out better if it is set.                 */
/* This section decides if __STDC__ should be defined.                        */

/* The Macintosh THINK C compiler seems to be ANSI standard but, strangely    */
/* does not define the standard preprocessor symbol __STDC__ that indicates   */
/* this. Instead it defines THINK_C. Here, we execute the link manually.      */
/* For more information see the THINK C User's Manual, Chapter 57: "Language  */
/* Reference", Section 12.10, p.442.                                          */
#ifdef THINK_C
#define __STDC__ 1
#endif

/* The problem seems to exist with VAX C too. */
#if VMS
#define __STDC__ 1
#endif

/******************************************************************************/

/* Switch From Definedness to Boolean Symbols                                 */
/* ------------------------------------------                                 */
/* Use of the definedness of a preprocessor symbol to detect a condition is   */
/* convenient if it is desired that only one condition be tested at a time.   */
/* However, if we want to OR conditions, it is more convenient to use defined */
/* symbols that are either 0 or 1. This section contains ifdefs that do this. */

#ifdef __STDC__
#define STDC 1
#else
#define STDC 0
#endif

/* Note: If THINK_C is predefined, it is predefined to be 1. */
#ifndef THINK_C
#define THINK_C 0
#endif

/******************************************************************************/

/* Void                                                                       */
/* ----                                                                       */
/* Define void if necessary and define pointer to void.                       */
/* This idea from the book "Portable C", p.41.                                */
/* If necessary, add a boolean condition to cover your environment.           */
/* Note: The "| SUN" is a last minute desperate hack.                         */
#if STDC | SUN
typedef void   *p_void;
#else
typedef int       void;
typedef char   *p_void;
#endif

/* The following function is here solely to act as a first tripping point for */
/* environments with no "void" so that the users trying to port this code     */
/* will look here first instead of starting to delete voids in the program.   */
extern void test_void();

/******************************************************************************/

/* Const                                                                      */
/* -----                                                                      */
/* It's useful to be able to specify that certain objects are constants.      */
/* Unfortunately, the "const" construct is only available in ANSI C and so we */
/* have to have a macro so as to cope with non-ANSI compilers.                */
/* Note: THINK-C is nearly ANSI, but does not support "const".                */
#if STDC & !THINK_C
#define CONST const
#else
#define CONST
#endif

/******************************************************************************/

/* Prototypes                                                                 */
/* ----------                                                                 */
/* Define a macro to wrap around prototype parameter lists so as to support   */
/* compilers with and without prototypes.                                     */
/* This idea came from the book "Portable C", S3.1, p.32.                     */
#if STDC
#define P_(A) A
#else
#define P_(A) ()
#endif

/******************************************************************************/

/* Structure Assignments                                                      */
/* ---------------------                                                      */
/* Structure assignments are not supported on some of the older compilers and */
/* so we use a macro to perform such operations.                              */
/* This idea came from the book "Portable C", S8.2.2, p.184.                  */
#if STDC
#define ASSIGN(a,b) ((a)=(b))
#else
#define ASSIGN(a,b) (memcpy((char *)&(a),(char *)&(b),sizeof(a)))
#endif

/******************************************************************************/

/* VMS EXIT STATUS */
/* --------------- */
/* The VAX C compiler I used doesn't seem to be ANSI. This means that the    */
/* exit symbols aren't set up properly. Furthermore, the sensible defaults   */
/* in the style.h file don't work for VMS. The upshot is that we have to do  */
/* a special case. Note: The top bit set in a VMS exit status means suppress */
/* diagnostic message. Even status means failure. Odd means success.         */
#if VMS
#undef  EXIT_SUCCESS
#undef  EXIT_FAILURE
#define EXIT_SUCCESS 1
#define EXIT_FAILURE (0x10000002)
#endif

/******************************************************************************/

/* For #ifndef preventing multiple inclusion of the body of this header file. */
#endif

/******************************************************************************/
/*                                End of ENVIRON.H                            */
/******************************************************************************/