C Libraries/headers/ctype.h
#include files/ctype.h
C Libraries/headers/errno.h
#include files/errno.h
+3-2
C Libraries/headers/fopenw.h
#include files/fopenw.h
···2424#include "EventMgr.h"
2525#endif
26262727-extern GrafPtr WMgrPort:0x9DE;
2727+#ifndef _MenuMgr_
2828+#include "MenuMgr.h"
2929+#endif
28302931/* This is the Standard Window Options structure (passed in to fopenw) */
3032···111113#define _LEFTEDGE 4 /* margins */
112114#define _TOPEDGE 4
113115114114-extern int MBarHeight:0xBAA;
115116#define _MBARHEIGHT (ROM85==-1?20:MBarHeight)
116117117118#define _TITLEBARHEIGHT 20
C Libraries/headers/io.h
#include files/io.h
-49
C Libraries/headers/math.h
···11-/****************************************************************************
22-33- Standard math library header for LightspeedC.
44-55- (C) Copyright 1986 THINK Technologies, Inc. All rights reserved.
66-77-*****************************************************************************/
88-99-#ifndef _math_
1010-1111- #define _math_ /* show symbols defined */
1212- double acos(double x);
1313- double asin(double x);
1414- double atan(double x);
1515- double atan2(double y, double x);
1616- double ceil(double x);
1717- double cos(double x);
1818- double cosh(double x);
1919- double exp(double x);
2020- double fabs(double x);
2121- double floor(double x);
2222- double fmod(double x, double y);
2323- double frexp(double x, int *i);
2424- long labs(long l);
2525- double ldexp(double x, int n);
2626- double log(double x);
2727- double log10(double x);
2828- double modf(double x, int *i);
2929- double pow(double x, double y);
3030- double sin(double x);
3131- double sinh(double x);
3232- double sqrt(double x);
3333- double tan(double x);
3434- double tanh(double x);
3535-3636- #define PI (3.14159265358979323846)
3737- #define PI2 (1.57079632679489661923)
3838- #define PI4 (0.78539816339744830966)
3939-4040- #define E (2.71828182845904523536)
4141-4242- typedef enum{
4343- EDOM=33,
4444- ERANGE=34
4545- };
4646-4747-extern int errno; /* actually defined in stdio */
4848-4949-#endif
+12-8
C Libraries/headers/proto.h
#include files/proto.h
···93939494/* storage.h */
95959696-char *clalloc(unsigned long count,unsigned long size);
9797-char *calloc(unsigned int count, unsigned int size);
9898-int free(char *ptr);
9999-int cfree(char *ptr);
100100-char *mlalloc(unsigned long size);
101101-char *malloc(unsigned int size);
102102-char *relalloc(char *ptr,unsigned long newsize);
103103-char *realloc(char *ptr,unsigned newsize);
9696+void *clalloc(unsigned long count,unsigned long size);
9797+void *calloc(unsigned int count, unsigned int size);
9898+int free(void *ptr);
9999+int cfree(void *ptr);
100100+void *mlalloc(unsigned long size);
101101+void *malloc(unsigned int size);
102102+void *relalloc(void *ptr,unsigned long newsize);
103103+void *realloc(void *ptr,unsigned newsize);
104104105105/* storageu.h */
106106···218218int getche(void);
219219char *cgets(char *s);
220220221221+/* For 3.0, these are macros.
221222int min(int v1, int v2);
222223int max(int v1, int v2);
224224+*/
223225224226int fclose(FILE *who);
225227FILE *fopen(char *nameptr, char *type);
···273275int getxpos(void);
274276int getypos(void);
275277void putch(char c);
278278+279279+void SetFPU(int IsUsingFPU);
276280277281#ifndef _setjmph_
278282#include "setjmp.h"
+1-1
C Libraries/headers/sane.h
#include files/sane.h
···2828typedef struct
2929 {
3030 short sgn; /* char */
3131- short exp;
3131+ short exponent;
3232 struct
3333 {
3434 unsigned char length; /* was char sig[22] */
C Libraries/headers/setjmp.h
#include files/setjmp.h
C Libraries/headers/signal.h
#include files/signal.h
+7-3
C Libraries/headers/stdio.h
#include files/stdio.h
···2929#define stderr (&_file[STDERRNO])
3030#define _console (&_console_)
31313232+#define MAX(a, b) (a > b ? a : b)
3333+#define MIN(a, b) (a < b ? a : b)
3434+3235typedef struct {
3336 int refnum; /* OS Reference number */
3437 int last_error; /* holds last error on file */
···77807881int _closeall(); /* close all open files */
7982extern int errno;
8080-8383+8184/* Default for these functions are int so they don't need to be declared
8285Boolean StdEvent(); -- this is fine since Booleans become ints
8386cprintf();
···101104isupper();
102105islower();
103106kbhit();
104104-max();
105105-min();
107107+108108+ - max() and min() are now defined as macros in <stdio.h>
109109+106110puts();
107111printf();
108112sprintf();
+6-6
C Libraries/headers/storage.h
#include files/Storage.h
···1111#ifndef _storagech_
1212#define _storagech_
13131414- char *calloc();
1515- char *clalloc();
1414+ void *calloc();
1515+ void *clalloc();
1616/* int cfree(); Default for these functions are int so they don't need to be declared*/
1717/* int free(); */
1818- char *malloc();
1919- char *mlalloc();
2020- char *realloc();
2121- char *relalloc();
1818+ void *malloc();
1919+ void *mlalloc();
2020+ void *realloc();
2121+ void *relalloc();
22222323#endif
C Libraries/headers/storageu.h
#include files/storageu.h
C Libraries/headers/strings.h
#include files/strings.h
C Libraries/headers/time.h
#include files/time.h
C Libraries/headers/types.h
#include files/types.h
+12
C Libraries/headers/unix.h
#include files/unix.h
···1919#include "signal.h"
2020#endif _signalh_
21212222+/* _UnixFPU_ is used to tell stdio whether to work with 80-bit (SANE) doubles
2323+ or with 96-bit (68881) doubles. By default, it's undefined; if you
2424+ are using 68881 code generation and wish to use stdio, uncomment the
2525+ declaration and rebuild stdio and sprintf (there are only two files
2626+ to recompile.
2727+2828+ <stdio.h> has a similar #define in it, called _FPU_, and it will have
2929+ to be changed under the same conditions.
3030+*/
3131+3232+#define _UnixFPU_
3333+2234double atof();
2335long atol();
2436long lseek();
+32-32
C Libraries/sources/math.c
Library Sources/Math.c
···10101111*/
12121313-1313+#include "config.h"
1414#include "math.h"
1515#include "sane.h"
1616···2626static double Pi2 = PI2;
2727static double Log2Ten = 3.321928094887362348;
28282929+static short _Max[] = { 0x7FFE, 0x7FFF, 0xFFFF, 0xFFFF, 0xFFFF };
3030+static short _MinusMax[] = { 0xFFFE, 0x7FFF, 0xFFFF, 0xFFFF, 0xFFFF };
3131+#define Max (* (double *) _Max)
3232+#define MinusMax (* (double *) _MinusMax)
29333034/* seed for pseudo-random number generator */
3135static unsigned long seed = 1;
···40444145/* ---------- error checking ---------- */
42464343-4444-#define ERRORCHECK
4545-4646-/*
4747- Error checking will be suppressed if ERRORCHECK is not #defined.
4848-4949- To conform to standard C, error checking must be enabled. If
5050- the "stdio" library is not included in the project, the integer
5151- variable "errno" must be defined somewhere else.
5252-5353- Without error checking, the math functions will execute somewhat
5454- faster, and no references to "errno" will result.
5555-*/
5656-5757-#ifdef ERRORCHECK
4747+#ifdef _ERRORCHECK_
58485949#define DomainCheck(test, result) if (test) { \
6050 errno = EDOM; \
···6454 errno = ERANGE; \
6555 target = Max; \
6656 }
6767-static short _Max[] = { 0x7FFE, 0x7FFF, 0xFFFF, 0xFFFF, 0xFFFF };
6868-static short _MinusMax[] = { 0xFFFE, 0x7FFF, 0xFFFF, 0xFFFF, 0xFFFF };
6969-#define Max (* (double *) _Max)
7070-#define MinusMax (* (double *) _MinusMax)
71577272-#else ERRORCHECK
5858+#else _ERRORCHECK_
73597460#define ClearExceptions()
7561#define DomainCheck(test, result)
7662#define RangeCheck(target)
77637878-#endif ERRORCHECK
7979-6464+#endif _ERRORCHECK_
80658166/* ---------- environment ---------- */
8267···115100 *
116101 */
117102118118-#ifdef ERRORCHECK
103103+#ifdef _ERRORCHECK_
119104static
120105ClearExceptions()
121106{
···125110 state &= ~ERROR;
126111 SetEnvironment(&state);
127112}
128128-#endif ERRORCHECK
113113+#endif _ERRORCHECK_
129114130115131116/*
···268253double x;
269254{
270255 int state = SetRound(ROUND_UP);
271271-272256 fp68k(&x, FORTI);
273257 SetState(state);
274258 return(x);
···282266283267double cos(x)
284268double x;
285285-{
269269+{
286270 elems68k(&x, FOCOSX);
287271 return(x);
288272}
···363347364348 fp68k(&y, FOABS);
365349 fp68k(&y, &z, FOREM);
350350+366351 if (x > 0 && z < 0)
367352 z += y;
368353 else if (x < 0 && z > 0)
···389374 *nptr = 0;
390375 return(Zero);
391376 }
377377+392378 elems68k(&y, FOLOG2X);
379379+393380 y -= *nptr = y;
381381+394382 elems68k(&y, &z, FOPWRY);
383383+395384 if (z >= One) {
396385 z *= PointFive;
397386 ++*nptr;
···487476double x, y;
488477{
489478 int exactint = 0;
490490-479479+ double z;
480480+491481 ClearExceptions();
492482 if (x == 0) {
493493- DomainCheck(y <= 0, MinusMax);
483483+ if (y <= 0) {
484484+#ifdef _ERRORCHECK_
485485+ errno = EDOM;
486486+#endif
487487+ return (MinusMax);
488488+ }
494489 return(Zero);
495490 }
496491 if (y == 0)
497492 return(One);
498493 if (x < 0) {
499499- DomainCheck(modf(y, &exactint), MinusMax);
494494+ modf(y, &exactint);
495495+ if (exactint != y) {
496496+#ifdef _ERRORCHECK_
497497+ errno = EDOM;
498498+#endif
499499+ return (MinusMax);
500500+ }
500501 x = -x;
501502 }
502503 elems68k(&y, &x, FOPWRY);
504504+503505 RangeCheck(x);
504506 return((exactint & 1) ? -x : x);
505507}
506506-507508508509/*
509510 * rand - pseudo-random number generator (ANSI C standard)
···603604double x;
604605{
605606 double y = MinusTwo * fabs(x);
606606-607607 elems68k(&y, FOEXP1X);
608608 y = -y / (y + Two);
609609 xfersign(x, &y);
C Libraries/sources/stdio .c files/Dec2Str.Lib
This is a binary file and will not be displayed.
C Libraries/sources/stdio .c files/Str2Dec.Lib
This is a binary file and will not be displayed.
C Libraries/sources/stdio .c files/onexit.c
Library Sources/stdio .c files/onexit.c
C Libraries/sources/stdio .c files/printf-1.c
Library Sources/stdio .c files/printf-1.c
C Libraries/sources/stdio .c files/printf-1a.c
Library Sources/stdio .c files/printf-1a.c
+25
C Libraries/sources/stdio .c files/printf-2-w.c
Library Sources/stdio .c files/printf-2-w.c
···17171818/* #define _NonMacScreen_ */
19192020+#include "config.h"
2121+2022#ifndef _stdioh_
2123#include "stdio.h"
2224#endif
···680682 while (--p >= begp) *p = sp;
681683}
682684685685+/* RMS 4/20/88 */
686686+/* procedure to determine if MultiFinder is running by checking for the
687687+existence of the WaitNextEvent() trap */
688688+689689+static int MFIsRunning()
690690+{ /* $8F is for _MFDispatch, $9F is the unimplemented trap */
691691+ return (GetTrapAddress(0x8FL) != GetTrapAddress(0x9FL));
692692+}
683693684694static
685695FILE *fopenwx(titlebar, upper_left, optionsptr, whichfilevar, ourwp)
···755765 maxrow = (screenHeight - upper_left.v - _TOPEDGE - _CONTROLWIDTH - 1 - charheight + 1) /
756766 charheight;
757767768768+ /***************** RMS 4/20/88 ***************
769769+ *
770770+ *
771771+ * If MultiFinder is running, we'll make the console window half-height,
772772+ * so that we can see the contents while running the debugger.
773773+ *
774774+ * As soon as a possible, "MFIsRunning()" will be replaced by a
775775+ * mechanism to see if the debugger is being used.
776776+ *
777777+ **********************************************/
778778+779779+#ifdef _HALFWINDOW_
780780+ if (MFIsRunning()) maxrow = 11; /* half a standard screen */
781781+#endif
782782+758783 if (!maxcol)
759784 maxcol = (screenWidth - upper_left.h - _LEFTEDGE - _CONTROLWIDTH - 1 - _sf.widMax + 1) /
760785 _sf.widMax;
C Libraries/sources/stdio .c files/printf-2.c
Library Sources/stdio .c files/printf-2.c
+66-1
C Libraries/sources/stdio .c files/printf-3.c
Library Sources/stdio .c files/printf-3.c
···99/* comment this out if you don't need floating point numeric support */
1010#define _FORMAT_FP_
11111212+#include "config.h"
1313+1214#ifndef _stdioh_
1315#include "stdio.h"
1416#endif
···23252426#ifndef _setjmph_
2527#include "setjmp.h"
2828+#endif
2929+3030+#ifndef _math_
3131+#include "Math.h"
3232+#endif
3333+3434+#ifdef _MC68881_
3535+/* conversion from 68881 to SANE extended type */
3636+static void x96tox80(x96, x80)
3737+register Extended96 *x96;
3838+register Extended80 *x80;
3939+4040+{
4141+ (*x80).exponent = (*x96).exponent;
4242+ (*x80).mantissa = (*x96).mantissa;
4343+}
4444+4545+#define _tox80() x96tox80(doublep, &x80);
4646+#define _ToDecimal() fp68k(&_decform_, &x80, &_decimal_, FFEXT+FOB2D)
4747+4848+#else
4949+5050+#define _tox80()
5151+#define _ToDecimal() fp68k(&_decform_, doublep, &_decimal_, FFEXT+FOB2D)
5252+2653#endif
27542855/* it turns out that defining min, max, and isdigit as follows works pretty
···182209DecForm _decform_; /* information record for conversion */
183210Decimal _decimal_; /* intermediate record */
184211212212+#ifdef _MC68881_
213213+Extended80 x80;
214214+#endif
215215+216216+ /* convert double to Extended80 (as defined in Math881.h) */
217217+ _tox80();
218218+185219 /* convert binary to decimal record */
186220187221 _decform_.style = style;
188222 _decform_.digits = digits;
189223190190- fp68k(&_decform_, doublep, &_decimal_, FFEXT+FOB2D);
224224+ _ToDecimal();
191225192226 /* decimal record to string */
193227···590624 }
591625 argument += sizeof (int);
592626 break;
627627+628628+ case 'p':
629629+ {register char *char_ptr;
630630+631631+ /* get the length of the string */
632632+ char_ptr = *((char **)argument);
633633+ length = *char_ptr++;
634634+ argument += sizeof(char_ptr);
635635+636636+ /* check for truncation */
637637+ if (do_precision)
638638+ if (length > precision) length = precision;
639639+640640+ /* set width to padding width */
641641+ if ((width -= length) < 0) width = 0;
642642+643643+ if (left_justify)
644644+ {
645645+ while (--length >= 0)
646646+ (*outputx)(*char_ptr++);
647647+648648+ padd(BLANKS, width);
649649+ }
650650+ else
651651+ {
652652+ padd(zero_fill, width);
653653+ while (--length >= 0)
654654+ (*outputx)(*char_ptr++);
655655+ }
656656+ break;
657657+ }
593658594659 case 's':
595660 {register char *char_ptr;
C Libraries/sources/stdio .c files/printf-4.c
Library Sources/stdio .c files/printf-4.c
C Libraries/sources/stdio .c files/scanf1.c
Library Sources/stdio .c files/scanf1.c
+62-8
C Libraries/sources/stdio .c files/scanf2.c
Library Sources/stdio .c files/scanf2.c
···44 (C) Copyright 1986. THINK Technologies, Inc. All rights reserved.
55*/
6677+#include "config.h"
88+79#ifndef _stdioh_
810#include "stdio.h"
911#endif
···2426#include "setjmp.h"
2527#endif
26282929+#ifndef _math_
3030+#include "Math.h"
3131+#endif
3232+3333+#include "pascal.h"
3434+3535+#ifdef _MC68881_
3636+3737+/* conversion from 68881 to SANE extended type */
3838+static void x96tox80(x96, x80)
3939+register Extended96 *x96;
4040+register Extended80 *x80;
4141+4242+{
4343+ (*x80).exponent = (*x96).exponent;
4444+ (*x80).mantissa = (*x96).mantissa;
4545+}
4646+4747+static void x80tox96(x80, x96)
4848+register Extended80 *x80;
4949+register Extended96 *x96;
5050+{
5151+ (*x96).exponent = (*x80).exponent;
5252+ (*x96).reserved = 0;
5353+ (*x96).mantissa = (*x80).mantissa;
5454+}
5555+5656+#define _fromDecimal() fp68k(&_decimal_,&x80,FFEXT|FOD2B)
5757+#define _tox96() x80tox96(&x80, *(double**)argument)
5858+#else
5959+6060+#define _fromDecimal() fp68k(&_decimal_,*(double**)argument,FFEXT|FOD2B)
6161+#define _tox96()
6262+#endif
6363+2764/*----------------------------------------------------------------------------
2865 some global storage to prevent excessive parameter transfer
2966----------------------------------------------------------------------------*/
···3976static
4077int from_memory()
4178{
4242- return(*destination++); /* return next character in memory stream */
7979+ register unsigned char c;
8080+ c = *destination;
8181+ if (c) {
8282+ destination++;
8383+ return(c);
8484+ } else return(EOF);
4385}
44864587static
···4991 destination--;
5092}
51935252-5394#line 0 sscanf
5495int sscanf(dest, fmt)
5596unsigned char *dest; /* pointer to buffer space */
···168209169210 return(c); /* returns character after white space */
170211}
171171-172172-173212int _scanf_scan(fmt)
174213char **fmt; /* pointer to pointer to format string */
175214{
···189228int i; /* counter */
190229register count; /* counter */
191230register int (*_scanf_putbackx)() = _scanf_putback;
231231+232232+#ifdef _MC68881_
233233+Extended80 x80;
234234+#endif
192235193236 if (count=setjmp(_scanf_env)) return (count); /* set up error handler */
194237···351394 }
352395353396 break;
354354-397397+398398+ case 'p':
355399 case 's':
400400+ { char *strStart;
356401 /* first char cannot be EOF after skip_white */
357402358403 (*_scanf_putbackx)(skip_white());
359404360405 loc = (char **)argument;
406406+ strStart = *loc;
361407362408 do
363409 {
364410 if ((curr_char = (*_scanf_input)()) == EOF)
365411 {
366366- if (assign) **(char**) loc = '\0';
412412+ if (assign) {
413413+ **(char**) loc = '\0';
414414+ if (c == 'p') CtoPstr(strStart);
415415+ }
367416 return (count);
368417 }
369418···384433 if (assign)
385434 **(char **)loc = '\0';
386435436436+387437 if (assign)
388438 {
389439 argument += sizeof(long);
440440+ if (c == 'p') CtoPstr(strStart);
390441 count++;
391442 }
392443 break;
444444+ }
393445394446 case '[': neg = false;
395447···500552501553 if (assign)
502554 {
503503- if (its_a_long)
504504- fp68k(&_decimal_,*(double**)argument,FFEXT|FOD2B);
555555+ if (its_a_long) {
556556+ _fromDecimal();
557557+ _tox96();
558558+ }
505559 else
506560 if (its_a_short)
507561 fp68k(&_decimal_,*(short double**)argument,FFDBL|FOD2B);
C Libraries/sources/stdio .c files/std_decode.c
Library Sources/stdio .c files/std_decode.c
C Libraries/sources/stdio .c files/stddata_ctype.c
Library Sources/stdio .c files/stddata_ctype.c
C Libraries/sources/stdio .c files/stddata_file.c
Library Sources/stdio .c files/stddata_file.c
C Libraries/sources/stdio .c files/stdfile_error.c
Library Sources/stdio .c files/stdfile_error.c
C Libraries/sources/stdio .c files/stdfile_pos.c
Library Sources/stdio .c files/stdfile_pos.c
C Libraries/sources/stdio .c files/stdfilebuf.c
Library Sources/stdio .c files/stdfilebuf.c
C Libraries/sources/stdio .c files/stdfwrite.c
Library Sources/stdio .c files/stdfwrite.c
+1-3
C Libraries/sources/stdio .c files/stdget_console.c
Library Sources/stdio .c files/stdget_console.c
···3232int (*_key_int_sig_func_)() = 0;
33333434extern long ATrapHandler : 0x28;
3535-extern long ROMBase : 0x2AE;
3636-extern long Lo3Bytes : 0x31A;
37353838-#define DebuggerIn() ((ATrapHandler & Lo3Bytes) < (ROMBase & Lo3Bytes))
3636+#define DebuggerIn() (((long)ATrapHandler & Lo3Bytes) < (long)((long)ROMBase & Lo3Bytes))
39374038/* pdg - 6/18/86 - completely revised command character handling of the
4139 following function to allow control characters to be
C Libraries/sources/stdio .c files/stdgets.c
Library Sources/stdio .c files/stdgets.c
C Libraries/sources/stdio .c files/stdmax_min.c
Library Sources/stdio .c files/stdmax_min.c
C Libraries/sources/stdio .c files/stdopen.c
Library Sources/stdio .c files/stdopen.c
C Libraries/sources/stdio .c files/stdput_console.c
Library Sources/stdio .c files/stdput_console.c
+9-9
C Libraries/sources/stdio .c files/stdputs.c
Library Sources/stdio .c files/stdputs.c
···4848{
4949 ioParam pb; /* my parameter block for PB's */
50505151+ if (who->StdStream)
5252+ {
5353+ stdwsave(who, &saverec);
5454+ putch(c); /* put char directly to the screen */
5555+ stdwrestore(who, &saverec);
5656+ return(c); /* never an error on fputc(stdout). */
5757+ }
5858+5159 if ((!who)||(!who->InUse)||(!who->wr)) /* error if file not open */
5260 {
5361 if (!who->wr)
···5765 return(EOF);
5866 }
59676060-6161- if (who->StdStream)
6262- {
6363- stdwsave(who, &saverec);
6464- putch(c); /* put char directly to the screen */
6565- stdwrestore(who, &saverec);
6666- return(c); /* never an error on fputc(stdout). */
6767- }
68686969 if (who->fpos>(BUFSIZ-1))
7070 if (write_to_buffer(who))
···8383 register FILE *who;
84848585{
8686- register int c;
8686+ register unsigned char c;
87878888 if ((!who)||(!who->InUse)||(!who->wr)) /* error if file not open */
8989 {
C Libraries/sources/stdio .c files/stdto..x.c
Library Sources/stdio .c files/stdto..x.c
+2-2
C Libraries/sources/stdio .c files/stdver.c
Library Sources/stdio .c files/stdver.c
···1515#line 0 std_ver()
1616char *std_ver()
1717{
1818-static char STDIO_VERSION[] = "LightspeedC Libraries 2.15";
1919-static char copyright[] = "(C) 1986 THINK Technologies, Inc. All rights reserved.";
1818+static char STDIO_VERSION[] = "THINK C Libraries 3.01";
1919+static char copyright[] = "� 1988 Symantec Corp. All rights reserved.";
20202121 return (STDIO_VERSION);
2222}
+11-11
C Libraries/sources/storage .c files/storage.c
Library Sources/storage .c files/storage.c
···11+/*
22+33+ Profile and tracing package for LightspeedC�.
44+55+ (C) Copyright 1986 THINK Technologies, Inc. All rights reserved.
66+77+ */
88+99+1010+#include "stdio.h"
1111+#include "DeviceMgr.h"
1212+1313+1414+typedef unsigned char Bool; /* for size */
1515+1616+typedef void (*address)(); /* address type */
1717+typedef unsigned char byte;
1818+typedef unsigned long time;
1919+2020+typedef struct {
2121+ char *name; /* function name */
2222+ time average; /* average time */
2323+ time maximum; /* largest time */
2424+ time minimum; /* smallest time */
2525+ time total; /* total time */
2626+ unsigned int entries; /* times entered */
2727+ } PROFILE;
2828+2929+typedef struct {
3030+ address user; /* user return address */
3131+ int function; /* index into profiles */
3232+ time correction; /* nested call time */
3333+ time start; /* entry time */
3434+ } STACK;
3535+3636+#define LOCAL static /* local to profiler */
3737+#define MAX_PROFILES 200 /* routines to follow */
3838+#define MAX_STACK 200 /* max nested calls */
3939+#define MAX_TIME 500000L /* max time */
4040+4141+/*
4242+4343+ Select execution/compilation options.
4444+4545+ SINGLE - each routine contains only its time
4646+ TESTING - test profile package without LightspeedC PROFILE option
4747+4848+ */
4949+5050+#define SINGLE /* single routine only */
5151+/* #define TESTING standalone testing */
5252+5353+5454+#ifdef TESTING
5555+#undef LOCAL /* make items visible */
5656+#define LOCAL
5757+#endif
5858+5959+6060+6161+LOCAL int depth = -1;
6262+LOCAL PROFILE profiles[MAX_PROFILES];
6363+LOCAL int profile_count = 0;
6464+LOCAL STACK stack[MAX_STACK];
6565+LOCAL int stack_pointer = -1;
6666+LOCAL time start_time;
6767+6868+int _profile = 1;
6969+int _trace = 0;
7070+7171+void DumpProfile();
7272+extern _profile_exit_();
7373+extern char *CtoPstr();
7474+extern char *PtoCstr();
7575+7676+#define _VIATIMER_ /* if this symbol is defined, the VIA timer now is used
7777+ instead of TickCount -- it provides faster ticks,
7878+ however there is a false precision to the numbers
7979+ and there is a range of + or - 500 ticks since
8080+ the VIAtimer is so fast that interrupts and such
8181+ play a more significant time role.
8282+8383+ NOTE THAT THIS PROFILE OPTION CANNOT BE USED WITH
8484+ ANY PROGRAM THAT MANIPULATES THE #1 VIA timer */
8585+8686+8787+#ifdef _VIATIMER_
8888+8989+/* TickCount() - redefine TickCount trap to be a procedure for determining
9090+ the timing according to the VIA timer */
9191+9292+#define VIAbase (*((unsigned char**)0x01D4))
9393+#define VIAt1lo (*(VIAbase+512*4))
9494+#define VIAt1hi (*(VIAbase+512*5))
9595+#define VIAEnable (*((unsigned char *) ((long)VIA + 0x1C00)))
9696+#define VIAmaxtime ~0
9797+#define ProcAddr(x) (*(ProcPtr *)&((short *)(x))[1])
9898+9999+time timer=0;
100100+ProcPtr savePtr;
101101+unsigned char saveEnable;
102102+103103+pascal void Rollover()
104104+{
105105+ SetUpA5();
106106+ timer += 65536;
107107+ VIAt1hi = VIAmaxtime;
108108+ VIAt1lo = VIAmaxtime;
109109+ RestoreA5();
110110+}
111111+112112+void Remove_Rollover()
113113+{
114114+ if ((saveEnable&0x40)==0) VIAEnable = 0x40;
115115+ Lvl1DT[6] = savePtr;
116116+}
117117+118118+time TickCount()
119119+{
120120+121121+ if (timer > 0)
122122+ {
123123+ /* Use VIA timer #1 (sound driver) and to implement a fine
124124+ resolution counter */
125125+126126+ /* Find delta of VIA #1 */
127127+128128+ timer += VIAmaxtime - (((unsigned short)VIAt1hi<<8)+VIAt1lo);
129129+ }
130130+ else {
131131+ /* initialize profiling interrupt: */
132132+ savePtr = Lvl1DT[6];
133133+ Lvl1DT[6] = ProcAddr(Rollover);
134134+ saveEnable = VIAEnable;
135135+ VIAEnable |= 0x40;
136136+137137+ onexit( Remove_Rollover );
138138+ timer = 1;
139139+ }
140140+141141+ /* Reset VIA counter */
142142+143143+ VIAt1hi = VIAmaxtime;
144144+ VIAt1lo = VIAmaxtime;
145145+146146+ return (timer);
147147+}
148148+149149+#endif _VIATIMER_
150150+151151+152152+/*
153153+154154+ Compare two Pascal strings for equality.
155155+156156+ */
157157+158158+LOCAL Bool pstreq( s1, s2 )
159159+register unsigned char *s1, *s2;
160160+{
161161+ register int n = *s1;
162162+163163+ if ((n = *s1++) != *s2++)
164164+ return( false );
165165+ while (n-- > 0)
166166+ if (*s1++ != *s2++)
167167+ return( false );
168168+ return( true );
169169+}
170170+171171+172172+/*
173173+174174+ Return the time difference caused by the overhead of function entry and
175175+ timer call.
176176+177177+ */
178178+179179+LOCAL time delta( original )
180180+time original;
181181+{
182182+/* return( (time) TickCount() - original ); */
183183+ return(0L);
184184+}
185185+186186+187187+/*
188188+189189+ Lookup a name in the active profile table. For this system, "names" are
190190+ the address of the routine. If the name is found in the table, then the
191191+ index to the table entry is returned. If the name is not found and the
192192+ insert flag is on, then the item is inserted, and the new table index
193193+ is returned (if insert is false, then -1 is returned). If the profile
194194+ table is full, then -1 is returned.
195195+196196+ */
197197+198198+LOCAL int lookup( name, insert )
199199+char *name;
200200+Bool insert;
201201+{
202202+ register int i;
203203+204204+ insert = _profile; /* only insert if profiling is on */
205205+206206+ for (i = 0; i < profile_count; i++)
207207+ if (pstreq( profiles[i].name, name ))
208208+ return( i );
209209+210210+ if ( insert && (profile_count < MAX_PROFILES))
211211+ { /* place in table - i points to correct entry */
212212+ if (++profile_count == 1)
213213+ { /* first time in */
214214+ start_time = (time) TickCount();
215215+ onexit( DumpProfile );
216216+ }
217217+ profiles[i].name = name;
218218+ profiles[i].minimum = MAX_TIME;
219219+ profiles[i].maximum =
220220+ profiles[i].total = NULL;
221221+ profiles[i].entries = 0;
222222+ return( i );
223223+ }
224224+ return( -1 );
225225+}
226226+227227+228228+/*
229229+230230+ Skip over to column 32 from position 'n'.
231231+232232+ */
233233+234234+LOCAL void Skip( n )
235235+register int n;
236236+{
237237+ for (; n < 32; n++)
238238+ putchar( ' ' );
239239+}
240240+241241+242242+/*
243243+244244+ Print the profile table on demand. Output is written to stdout and may
245245+ be redirected with the Unix '>' mechanism to a file. The user should
246246+ call this routine whenever a report is desired. Each time the routine is
247247+ called, the program opens the map file which corresponds to the program
248248+ running. The name of the map file is built by appending ".map" to the name
249249+ of the running program. If the map file cannot be found then the routine
250250+ returns.
251251+252252+ */
253253+254254+void DumpProfile()
255255+{
256256+ Boolean flag; /* save state of _profile */
257257+ int j, k; /* generic loop variables */
258258+ register int i; /* primary loop variable */
259259+ register time duration = 0L; /* time in test regions */
260260+261261+ flag = _profile;
262262+263263+ _profile = 0; /* turn off profiling here */
264264+265265+ for (i = 0; i < profile_count; i++)
266266+ duration += profiles[i].total; /* compute total time */
267267+268268+ printf( "\n\n" );
269269+ printf( "\t\t\t\tRoutine Profiles\n\n" );
270270+ printf( "Routine Address" );
271271+ Skip( 15 );
272272+ printf( " Minimum Maximum Average %% Entries\n" );
273273+274274+ if (duration <= 0.0)
275275+ duration++;
276276+277277+ for (i = 0; i < profile_count; i++)
278278+ { /* for all entries in the profile table */
279279+ if (profiles[i].minimum == MAX_TIME)
280280+ continue; /* routine entry, no exit */
281281+ printf( "%s", PtoCstr( profiles[i].name ) );
282282+ CtoPstr( profiles[i].name );
283283+ Skip( profiles[i].name[0] );
284284+ printf( "%9lu %9lu %9lu %3.0f %7u\n",
285285+ profiles[i].minimum, profiles[i].maximum,
286286+ profiles[i].average,
287287+ ((float) profiles[i].total * 100.0) / (float) duration + 0.05,
288288+ profiles[i].entries );
289289+ }
290290+291291+ _profile = flag; /* restore state of _profile */
292292+}
293293+294294+295295+/*
296296+297297+ Called by assembler exit routine. Compute usage statistics for routine on
298298+ top of profiling stack.
299299+300300+ */
301301+302302+address __profile_exit()
303303+{
304304+ int i;
305305+ time exit_time = (time) TickCount();
306306+307307+ depth--;
308308+ /* end timing for a function */
309309+310310+/* Debugger(); */
311311+ i = stack[stack_pointer].function;
312312+#ifdef SINGLE
313313+ exit_time = exit_time - delta( exit_time ) -
314314+ stack[stack_pointer].start - stack[stack_pointer--].correction;
315315+ if (exit_time > 0x7FFFFFFF)
316316+ exit_time = 0L; /* handle clock rollover */
317317+ profiles[i].total += exit_time;
318318+ if (stack_pointer >= 0)
319319+ stack[stack_pointer].correction += exit_time + stack[stack_pointer + 1].correction;
320320+#else
321321+ exit_time = exit_time - delta( exit_time ) - stack[stack_pointer--].start;
322322+ if (exit_time > 0x7FFFFFFF)
323323+ exit_time = 0L; /* handle clock rollover */
324324+ profiles[i].total += exit_time;
325325+#endif
326326+ if (exit_time > profiles[i].maximum)
327327+ profiles[i].maximum = exit_time;
328328+ if (exit_time < profiles[i].minimum)
329329+ profiles[i].minimum = exit_time;
330330+ if (profiles[i].entries)
331331+ profiles[i].average = profiles[i].total / profiles[i].entries;
332332+ return( stack[stack_pointer + 1].user );
333333+}
334334+335335+336336+/*
337337+338338+ Handle the routine entry profiling. Setup a stack frame and a profile
339339+ table entry if needed.
340340+341341+ */
342342+343343+void __profile( unused, ret, name )
344344+unsigned long *ret;
345345+address unused;
346346+char *name;
347347+348348+{
349349+ register int function, /* index of routine */
350350+ i;
351351+ register time entry_time = (time) TickCount();
352352+ Boolean flag; /* save state of _profile */
353353+ depth++;
354354+ if (_trace)
355355+ {
356356+ flag = _profile; /* save _profile */
357357+ _profile = 0;
358358+359359+ for (i = 0; i < depth; i++)
360360+ putchar( ' ' );
361361+ printf( "%s\n", PtoCstr( name ) );
362362+ CtoPstr( name );
363363+ _profile = flag;
364364+ }
365365+ if (++stack_pointer < MAX_STACK)
366366+ { /* setup for return to PROFILE_EXIT on user exit */
367367+ stack[stack_pointer].user = (address) *ret;
368368+ *ret = (unsigned long) _profile_exit_;
369369+ stack[stack_pointer].correction = NULL;
370370+ }
371371+ else
372372+ {
373373+ depth--;
374374+ return;
375375+ }
376376+377377+ if (_profile && ((function = lookup( name, true )) >= 0))
378378+ { /* process function entry */
379379+ profiles[function].entries++;
380380+ stack[stack_pointer].function = function;
381381+ entry_time = TickCount();
382382+ stack[stack_pointer].start = entry_time - delta( entry_time );
383383+ }
384384+ else
385385+ { /* remove entry from stack */
386386+ *ret = (unsigned long) stack[stack_pointer--].user;
387387+ depth--;
388388+ }
389389+}
+49
Library Sources/profiler/profilehooks.c
···11+/*
22+33+ Profile and tracing package for LightspeedC.
44+55+ (C) Copyright 1986 THINK Technologies, Inc. All rights reserved.
66+77+*/
88+99+extern void __profile();
1010+extern void __profile_exit();
1111+1212+/*
1313+;
1414+; Entry point for profiler. Add another parameter to the stack which is
1515+; a pointer to the return address of the caller of this function.
1616+;
1717+*/
1818+_profile_()
1919+{
2020+2121+ asm
2222+ {
2323+ move.l (a7)+,d0 ; get current return address
2424+ pea 4(a6) ; push pointer to return address
2525+ move.l d0,-(a7) ; push back the return address
2626+ jsr __profile ; call the C profiler
2727+ move.l (a7)+,d0 ; get return address
2828+ move.l d0,(a7) ; write on top of stack and return
2929+ }
3030+}
3131+3232+/*
3333+;
3434+; Exit point for profiler. This calls the end of function timing routine
3535+; and returns to the user.
3636+;
3737+*/
3838+3939+_profile_exit_()
4040+{
4141+ asm
4242+ {
4343+ move.l d0, -(a7) ; save old function result
4444+ jsr __profile_exit ; call end of routine timer
4545+ move.l d0, a0 ; save return address in A0
4646+ move.l (a7)+, d0 ; retrieve old function result
4747+ jmp (a0) ; then return
4848+ }
4949+}
···22/*
33 * Appletalk.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/Color.h
···22/*
33 * Color.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-4
Mac #includes/ColorToolbox.h
···22/*
33 * ColorToolbox.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010···110110pascal MCEntryPtr GetMCEntry();
111111pascal WindowPtr NewCWindow();
112112pascal WindowPtr GetNewCWindow();
113113-pascal RgnHandle GetGrayRgn();
114113115114116115/* low-memory globals */
+3-3
Mac #includes/ControlMgr.h
···22/*
33 * ControlMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/DeskBus.h
···22/*
33 * DeskBus.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/DeskMgr.h
···22/*
33 * DeskMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+9-4
Mac #includes/DeviceMgr.h
···22/*
33 * DeviceMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010···129129 activDev,
130130 deactivDev,
131131 keyEvtDev,
132132- macDev
132132+ macDev,
133133+ undoDev,
134134+ cutDev,
135135+ copyDev,
136136+ pasteDev,
137137+ clearDev
133138};
134139135140/* cdev error codes */
+3-3
Mac #includes/DialogMgr.h
···22/*
33 * DialogMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/DiskDvr.h
···22/*
33 * DiskDvr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/EventMgr.h
···22/*
33 * EventMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/FileMgr.h
···22/*
33 * FileMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+5-5
Mac #includes/FontMgr.h
···22/*
33 * FontMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010···8989 int widMax ;
9090 int kernMax ;
9191 int nDescent ;
9292- int fRectMax ;
9393- int chHeight ;
9292+ int fRectWidth ;
9393+ int fRectHeight ;
9494 int owTLoc ;
9595 int ascent ;
9696 int descent ;
+3-3
Mac #includes/HFS.h
···22/*
33 * HFS.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/IntlPkg.h
···22/*
33 * IntlPkg.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/ListMgr.h
···22/*
33 * ListMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/MacTypes.h
···22/*
33 * MacTypes.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/MemoryMgr.h
···22/*
33 * MemoryMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+5-6
Mac #includes/MenuMgr.h
···22/*
33 * MenuMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010···2727};
28282929/* menu defproc messages */
3030-enum { mDrawMsg, mChooseMsg, mSizeMsg };
3030+enum { mDrawMsg, mChooseMsg, mSizeMsg, mPopUpMsg };
31313232/* MDEF id */
3333#define textMenuProc 0
34343535-/* hierarchical and pop-up menus */
3535+/* hierarchical menus */
3636#define hMenuCmd 0x1B
3737#define hierMenu -1
3838-#define mPopUpMsg 4
393840394140typedef struct
+26-4
Mac #includes/OSUtil.h
···22/*
33 * OSUtil.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010···17171818/* result codes */
1919enum {
2020+ nmTypErr = -299,
2021 prInitErr = -88,
2122 prWrErr,
2223 clkWrErr,
···3435 ioQType,
3536 drvQType,
3637 evType,
3737- fsQType
3838+ fsQType,
3939+ siQType,
4040+ dtQType,
4141+ nmType
3842};
39434044/* machine types */
···169173#define sdOnUnmount 4
170174#define sdOnDrivers 8
171175#define sdRestartOrPower (sdOnRestart+sdOnPowerOff)
176176+177177+178178+/* ---------- Notification Manager ---------- */
179179+180180+181181+typedef struct NMRec {
182182+ QElemPtr qLink;
183183+ short qType;
184184+ short nmFlags;
185185+ long nmPrivate;
186186+ short nmReserved;
187187+ short nmMark;
188188+ Handle nmSIcon;
189189+ Handle nmSound;
190190+ StringPtr nmStr;
191191+ ProcPtr nmResp;
192192+ long nmRefCon;
193193+} NMRec;
172194173195174196/* ---------- */
+3-3
Mac #includes/PackageMgr.h
···22/*
33 * PackageMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/PrintMgr.h
···22/*
33 * PrintMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/Quickdraw.h
···22/*
33 * Quickdraw.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/ResourceMgr.h
···22/*
33 * ResourceMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/SCSIMgr.h
···22/*
33 * SCSIMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/ScrapMgr.h
···22/*
33 * ScrapMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+6-6
Mac #includes/ScriptMgr.h
···22/*
33 * ScriptMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010···242242/* Roman script constants */
243243244244#define romanVers 1
245245-#define romanSysFond $3FFF
245245+#define romanSysFond 0x3FFF
246246#define romanAppFond 3
247247248248/* Script Manager font equates. */
249249250250-#define smFondStart $4000
251251-#define smFondEnd $C000
250250+#define smFondStart 0x4000
251251+#define smFondEnd 0xC000
252252253253254254
+3-3
Mac #includes/SegmentLdr.h
···22/*
33 * SegmentLdr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/SerialDvr.h
···22/*
33 * SerialDvr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+40
Mac #includes/SetUpA4.h
···11+22+/*
33+ * SetUpA4.h
44+ *
55+ * This defines "SetUpA4()" and "RestoreA4()" routines that will work
66+ * in all A4-based projects.
77+ *
88+ * "RememberA4()" or "RememberA0()" must be called in advance to
99+ * store away the value of A4 where it can be found by "SetUpA4()".
1010+ * The matching calls to "RememberA4()" (or "RememberA0()") and
1111+ * "SetUpA4()" *MUST* occur in the same file.
1212+ *
1313+ * Note that "RememberA4()", "RememberA0()" "SetUpA4()", and
1414+ * "RestoreA4()" are not external. Each file that uses them must
1515+ * include its own copy.
1616+ *
1717+ * If this file is used in the main file of a code resource with
1818+ * "Custom Headers", be sure to #include it *AFTER* the custom
1919+ * header! Otherwise, the code resource will begin with the code
2020+ * for the function "__GetA4()", defined below.
2121+ *
2222+ */
2323+2424+2525+static
2626+__GetA4()
2727+{
2828+ asm {
2929+ bsr.s @1
3030+ dc.l 0 ; store A4 here
3131+@1 move.l (sp)+,a1
3232+ }
3333+}
3434+3535+3636+#define RememberA4() __GetA4(); asm { move.l a4,(a1) }
3737+#define RememberA0() __GetA4(); asm { move.l a0,(a1) }
3838+3939+#define SetUpA4() asm { move.l a4,-(sp) } __GetA4(); asm { move.l (a1),a4 }
4040+#define RestoreA4() asm { move.l (sp)+,a4 }
+3-3
Mac #includes/SlotMgr.h
···22/*
33 * SlotMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/SoundDvr.h
···22/*
33 * SoundDvr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/SoundMgr.h
···22/*
33 * SoundMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/StartMgr.h
···22/*
33 * StartMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/StdFilePkg.h
···22/*
33 * StdFilePkg.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+8-3
Mac #includes/TextEdit.h
···22/*
33 * TextEdit.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010···6565#define doColor 8
6666#define doAll 15
6767#define addSize 16
6868+#define doToggle 32
6969+7070+typedef enum {
7171+ intEOLHook, intDrawHook, intWidthHook, intHitTestHook
7272+} TEHook;
687369747075/* avoid having to bring in all of Color Quickdraw */
+3-3
Mac #includes/TimeMgr.h
···22/*
33 * TimeMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/ToolboxUtil.h
···22/*
33 * ToolboxUtil.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+3-3
Mac #includes/VRetraceMgr.h
···22/*
33 * VRetraceMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
+4-3
Mac #includes/WindowMgr.h
···22/*
33 * WindowMgr.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010···105105pascal WindowPtr GetNewWindow();
106106pascal WindowPtr FrontWindow();
107107pascal PicHandle GetWindowPic();
108108+pascal RgnHandle GetGrayRgn();
108109109110/* low-memory globals */
110111extern WindowPeek WindowList : 0x9D6;
+7
Mac #includes/asm.h
···33/* ----- asm.h: definitions useful with inline assembly ----- */
445566+#ifndef __asm__
77+#define __asm__
88+99+610/* trap modifier flags, e.g. "NewHandle SYS+CLEAR" */
711812enum {
···2731/* field offsets, e.g. "move.w d0,OFFSET(Rect,bottom)(a2)" */
28322933#define OFFSET(type, field) ((int) &((type *) 0)->field)
3434+3535+3636+#endif __asm__
+3-3
Mac #includes/nAppletalk.h
···22/*
33 * nAppletalk.h
44 *
55- * Copyright (c) 1986, 1987 THINK Technologies, Inc.
66- * These interfaces are based on information copyrighted
77- * by Apple Computer, Inc., 1985, 1986, 1987.
55+ * Copyright (c) 1988 Symantec Corporation.
66+ * These interfaces are based on material copyrighted
77+ * by Apple Computer, Inc., 1985, 1986, 1987, 1988.
88 *
99 */
1010
···11-/*
Profile and tracing package for LightspeedC.
(C) Copyright 1986 THINK Technologies, Inc. All rights reserved.
*/
#include "stdio.h"
typedef unsigned char Bool; /* for size */
enum{false,true};
typedef void (*address)(); /* address type */
typedef unsigned char byte;
typedef unsigned long time;
typedef struct {
char *name; /* function name */
time average; /* average time */
time maximum; /* largest time */
time minimum; /* smallest time */
time total; /* total time */
unsigned int entries; /* times entered */
} PROFILE;
typedef struct {
address user; /* user return address */
int function; /* index into profiles */
time correction; /* nested call time */
time start; /* entry time */
} STACK;
#define LOCAL static /* local to profiler */
#define MAX_PROFILES 200 /* routines to follow */
#define MAX_STACK 200 /* max nested calls */
#define MAX_TIME 500000L /* max time */
/*
Select execution/compilation options.
SINGLE - each routine contains only its time
TESTING - test profile package without LightspeedC PROFILE option
*/
#define SINGLE /* single routine only */
/* #define TESTING standalone testing */
#ifdef TESTING
#undef LOCAL /* make items visible */
#define LOCAL
#endif
LOCAL int depth = -1;
LOCAL PROFILE profiles[MAX_PROFILES];
LOCAL int profile_count = 0;
LOCAL STACK stack[MAX_STACK];
LOCAL int stack_pointer = -1;
LOCAL time start_time;
int _profile = 1;
int _trace = 0;
void DumpProfile();
extern _profile_exit_();
extern char *CtoPstr();
extern char *PtoCstr();
#define _VIATIMER_ /* if this symbol is defined, the VIA timer now is used
instead of TickCount -- it provides faster ticks,
however there is a false precision to the numbers
and there is a range of + or - 500 ticks since
the VIAtimer is so fast that interrupts and such
play a more significant time role.
NOTE THAT THIS PROFILE OPTION CANNOT BE USED WITH
ANY PROGRAM THAT MANIPULATES THE #1 VIA timer */
#ifdef _VIATIMER_
/* TickCount() - redefine TickCount trap to be a procedure for determining
the timing according to the VIA timer */
#define VIAbase (*((unsigned char**)0x01D4))
#define VIAt1lo (*(VIAbase+512*4))
#define VIAt1hi (*(VIAbase+512*5))
#define VIAmaxtime ~0
time TickCount()
{
static time timer=0;
if (timer > 0)
{
/* Use VIA timer #1 (sound driver) and to implement a fine
resolution counter */
/* Find delta of VIA #1 */
timer += VIAmaxtime - (((unsigned short)VIAt1hi<<8)+VIAt1lo);
}
else
timer = 1;
/* Reset VIA counter */
VIAt1hi = VIAmaxtime;
VIAt1lo = VIAmaxtime;
return (timer);
}
#endif _VIATIMER_
/*
Compare two Pascal strings for equality.
*/
LOCAL Bool pstreq( s1, s2 )
register unsigned char *s1, *s2;
{
register int n = *s1;
if ((n = *s1++) != *s2++)
return( false );
while (n-- > 0)
if (*s1++ != *s2++)
return( false );
return( true );
}
/*
Return the time difference caused by the overhead of function entry and
timer call.
*/
LOCAL time delta( original )
time original;
{
return( (time) TickCount() - original );
}
/*
Lookup a name in the active profile table. For this system, "names" are
the address of the routine. If the name is found in the table, then the
index to the table entry is returned. If the name is not found and the
insert flag is on, then the item is inserted, and the new table index
is returned (if insert is false, then -1 is returned). If the profile
table is full, then -1 is returned.
*/
LOCAL int lookup( name, insert )
char *name;
Bool insert;
{
register int i;
for (i = 0; i < profile_count; i++)
if (pstreq( profiles[i].name, name ))
return( i );
if ( insert && profile_count < MAX_PROFILES)
{ /* place in table - i points to correct entry */
if (++profile_count == 1)
{ /* first time in */
start_time = (time) TickCount();
onexit( DumpProfile );
}
profiles[i].name = name;
profiles[i].minimum = MAX_TIME;
profiles[i].maximum =
profiles[i].total = NULL;
profiles[i].entries = 0;
return( i );
}
return( -1 );
}
/*
Skip over to column 32 from position 'n'.
*/
LOCAL void Skip( n )
register int n;
{
for (; n < 32; n++)
putchar( ' ' );
}
/*
Print the profile table on demand. Output is written to stdout and may
be redirected with the Unix '>' mechanism to a file. The user should
call this routine whenever a report is desired. Each time the routine is
called, the program opens the map file which corresponds to the program
running. The name of the map file is built by appending ".map" to the name
of the running program. If the map file cannot be found then the routine
returns.
*/
void DumpProfile()
{
int j, k; /* generic loop variables */
register int i; /* primary loop variable */
register time duration = 0L; /* time in test regions */
_profile = 0; /* turn off profiling here */
for (i = 0; i < profile_count; i++)
duration += profiles[i].total; /* compute total time */
printf( "\n\n" );
printf( "\t\t\t\tRoutine Profiles\n\n" );
printf( "Routine Address" );
Skip( 15 );
printf( " Minimum Maximum Average %% Entries\n" );
if (duration <= 0.0)
duration++;
for (i = 0; i < profile_count; i++)
{ /* for all entries in the profile table */
if (profiles[i].minimum == MAX_TIME)
continue; /* routine entry, no exit */
printf( "%s", PtoCstr( profiles[i].name ) );
CtoPstr( profiles[i].name );
Skip( profiles[i].name[0] );
printf( "%9lu %9lu %9lu %3.0f %7u\n",
profiles[i].minimum, profiles[i].maximum,
profiles[i].average,
((float) profiles[i].total * 100.0) / (float) duration + 0.05,
profiles[i].entries );
}
_profile = 1; /* re-enable profiling */
}
/*
Called by assembler exit routine. Compute usage statistics for routine on
top of profiling stack.
*/
address __profile_exit()
{
int i;
time exit_time = (time) TickCount();
depth--;
/* end timing for a function */
i = stack[stack_pointer].function;
#ifdef SINGLE
exit_time = exit_time - delta( exit_time ) -
stack[stack_pointer].start - stack[stack_pointer--].correction;
if (exit_time > 0x7FFFFFFF)
exit_time = 0L; /* handle clock rollover */
profiles[i].total += exit_time;
if (stack_pointer >= 0)
stack[stack_pointer].correction += exit_time + stack[stack_pointer + 1].correction;
#else
exit_time = exit_time - delta( exit_time ) - stack[stack_pointer--].start;
if (exit_time > 0x7FFFFFFF)
exit_time = 0L; /* handle clock rollover */
profiles[i].total += exit_time;
#endif
if (exit_time > profiles[i].maximum)
profiles[i].maximum = exit_time;
if (exit_time < profiles[i].minimum)
profiles[i].minimum = exit_time;
if (profiles[i].entries)
profiles[i].average = profiles[i].total / profiles[i].entries;
return( stack[stack_pointer + 1].user );
}
/*
Handle the routine entry profiling. Setup a stack frame and a profile
table entry if needed.
*/
void __profile( unused, ret, name )
unsigned long *ret;
address unused;
char *name;
{
register int function, /* index of routine */
i;
register time entry_time = (time) TickCount();
depth++;
if (_trace)
{
_profile = 0;
for (i = 0; i < depth; i++)
putchar( ' ' );
printf( "%s\n", PtoCstr( name ) );
CtoPstr( name );
_profile = 1;
}
if (++stack_pointer < MAX_STACK)
{ /* setup for return to PROFILE_EXIT on user exit */
stack[stack_pointer].user = (address) *ret;
*ret = (unsigned long) _profile_exit_;
stack[stack_pointer].correction = NULL;
}
else
{
depth--;
return;
}
if ((function = lookup( name, true )) >= 0)
{ /* process function entry */
profiles[function].entries++;
stack[stack_pointer].function = function;
entry_time = TickCount();
stack[stack_pointer].start = entry_time - delta( entry_time );
}
else
{ /* remove entry from stack */
*ret = (unsigned long) stack[stack_pointer--].user;
depth--;
}
}
-1
profiler/profilehooks.c
···11-/*
Profile and tracing package for LightspeedC.
(C) Copyright 1986 THINK Technologies, Inc. All rights reserved.
*/
extern void __profile();
extern void __profile_exit();
/*
;
; Entry point for profiler. Add another parameter to the stack which is
; a pointer to the return address of the caller of this function.
;
*/
_profile_()
{
asm
{
move.l (a7)+,d0 ; get current return address
pea 4(a6) ; push pointer to return address
move.l d0,-(a7) ; push back the return address
jsr __profile ; call the C profiler
move.l (a7)+,d0 ; get return address
move.l d0,(a7) ; write on top of stack and return
}
}
/*
;
; Exit point for profiler. This calls the end of function timing routine
; and returns to the user.
;
*/
_profile_exit_()
{
asm
{
move.l d0, -(a7) ; save old function result
jsr __profile_exit ; call end of routine timer
move.l d0, a0 ; save return address in A0
move.l (a7)+, d0 ; retrieve old function result
jmp (a0) ; then return
}
}
+133
unix main.c
···11+/*************************************************************************
22+ * *
33+ * Module: unix main.c *
44+ * Programmer: Steve Adams *
55+ * *
66+ * (C) Copyright 1985, THINK Technologies, Inc. All rights reserved. *
77+ * *
88+ * Alternate main program to handle Unix command lines under Lightspeed *
99+ * C. The user is prompted for the command line on program entry. The *
1010+ * line is disected and placed in an "argv" array up to a maximum of *
1111+ * MAX_ARGS entries. I/O redirection is also supported, as follows: *
1212+ * *
1313+ * > redirects stdout to following file name *
1414+ * < redirects stdin to following file name *
1515+ * >> redirects stderr to following file name *
1616+ * *
1717+ * File names following a redirection may be immediately after the *
1818+ * redirector, or at what appears to be the next argument. If a file *
1919+ * open error occurs, then the program calls "SysBeep" and exits to the *
2020+ * shell. *
2121+ * *
2222+ * TO USE: change the "main" function in you application to "_main" and *
2323+ * include this file in your project. *
2424+ * *
2525+ *************************************************************************/
2626+2727+2828+#include <stdio.h>
2929+#include <ctype.h>
3030+3131+#define MAX_ARGS 50
3232+3333+#ifndef true
3434+#define true 1
3535+#define false 0
3636+#endif
3737+3838+static int argc = 1; /* final argument count */
3939+static char *argv[MAX_ARGS] = { "" }; /* array of pointers */
4040+static char command[256]; /* input line buffer */
4141+static int filename = false; /* TRUE iff file name */
4242+4343+4444+/*************************************************************************
4545+ * *
4646+ * Local routine to make a "beep" and exit to the shell. *
4747+ * *
4848+ *************************************************************************/
4949+5050+static void punt()
5151+ {
5252+ SysBeep( 5L );
5353+ ExitToShell();
5454+ }
5555+5656+5757+/*************************************************************************
5858+ * *
5959+ * Local routine to open a file in argv[--argc] after closing it's *
6060+ * previous existance. *
6161+ * *
6262+ *************************************************************************/
6363+6464+6565+static void openfile( file, mode )
6666+char *mode; /* mode for file open */
6767+FILE *file; /* file pointer to use */
6868+ {
6969+7070+ if ( (file = freopen( argv[--argc], mode, file ) ) <= (FILE *) NULL)
7171+ punt();
7272+ filename = false;
7373+ }
7474+7575+7676+/*************************************************************************
7777+ * *
7878+ * New main routine. Prompts for command line then calls user's main *
7979+ * now called "_main" with the argument list and redirected I/O. *
8080+ * *
8181+ *************************************************************************/
8282+8383+8484+void main()
8585+ {
8686+ char c; /* temp for EOLN check */
8787+ register char *cp; /* index in command line */
8888+ char *mode; /* local file mode */
8989+ FILE *file; /* file to change */
9090+ int i;
9191+9292+ printf( "Enter Unix command line:\n" );
9393+ gets( &command ); /* allow user to edit */
9494+ cp = &command[0]; /* start of buffer */
9595+ argv[0] = ""; /* program name is NULL */
9696+ while (argc < MAX_ARGS)
9797+ { /* up to MAX_ARGS entries */
9898+ while (isspace( *cp++ ));
9999+ if ( !*--cp )
100100+ break;
101101+ else if ( *cp == '<' )
102102+ { /* redirect stdin */
103103+ cp++;
104104+ file = stdin;
105105+ mode = "r";
106106+ filename = true;
107107+ }
108108+ else if ( *cp == '>' )
109109+ {
110110+ mode = "w";
111111+ filename = true;
112112+ if (*++cp == '>')
113113+ {
114114+ file = stderr;
115115+ cp++;
116116+ }
117117+ else
118118+ file = stdout;
119119+ }
120120+ else
121121+ { /* either an argument or a filename */
122122+ argv[argc++] = cp;
123123+ while ( *++cp && !isspace( *cp ) );
124124+ c = *cp;
125125+ *cp++ = '\0';
126126+ if (filename)
127127+ openfile( file, mode );
128128+ if (!c)
129129+ break;
130130+ }
131131+ }
132132+ _main( argc, argv );
133133+ }