evas@euraiv1.UUCP (10/02/87)
Here is part 3 of 9: Eelco van Asperen. # This is a shar archive. Extract with sh, not csh. # This archive ends with exit, so do not worry about trailing junk. # --------------------------- cut here -------------------------- PATH=/bin:/usr/bin if test -f lib then echo Removing lib rm lib fi if test -d lib then : else echo Creating lib mkdir lib fi echo Extracting lib/catchsig.asm sed 's/^X//' > lib/catchsig.asm << '+ END-OF-FILE 'lib/catchsig.asm Xtitle catchsig - C86 version; now TurboC version [EVAS] Xpage,132 X Xinclude prologue.h X X_DATA segment para public 'DATA' X X extrn _vectab:word, _M:word X X dummy DW 0 X X_DATA ends X X X_TEXT segment byte public 'CODE' X X assume CS:_TEXT,DS:DGROUP X X public _begsig X X XMTYPE = 2 ; M+mtype = &M.m_type X X_begsig proc near X X push ax ; after interrupt, save all regs X push bx X push cx X push dx X push si X push di X push bp X push ds X push es X X mov bp,sp X mov bx,18[bp] ; bx = signal number X dec bx ; vectab[0] is for sig 1 X add bx,bx ; pointers are two bytes on 8088 X mov bx,_vectab[bx] ; bx = address of routine to call X push _M+mtype ; push status of last system call X push ax ; func called with signal number as arg X call bx Xback: X pop ax ; get signal number off stack X pop _M+mtype ; restore status of previous system call X pop es ; signal handling finished X pop ds X pop bp X pop di X pop si X pop dx X pop cx X pop bx X pop ax X pop dummy ; remove signal number from stack X X iret X X_begsig endp X X_TEXT ends X X X END ; end of assembly-file + END-OF-FILE lib/catchsig.asm chmod u=rw,g=r,o=r lib/catchsig.asm set `sum lib/catchsig.asm` sum=$1 case $sum in 18236) :;; *) echo 'Bad sum in 'lib/catchsig.asm >&2 esac echo Extracting lib/crtso.asm sed 's/^X//' > lib/crtso.asm << '+ END-OF-FILE 'lib/crtso.asm XTitle $MAIN C-86 run-time start-off for Minix; Now for Turbo C [EVAS] Xpage,132 X X X PAGE 60,132 X;[]------------------------------------------------------------[] X;| start-up module for using Turbo C under MINIX; | X;| derived from: | X;| | X;| C0.ASM -- Start Up Code | X;| | X;| Turbo-C Run Time Library version 1.0 | X;| | X;| Copyright (c) 1987 by Borland International Inc. | X;| All Rights Reserved. | X;[]------------------------------------------------------------[] X Xinclude prologue.h X X ASSUME CS:_TEXT, DS:DGROUP X X; External References X X XPUBLIC __end, _brksize, edata, $main, _environ, kamikaze X X XSTACKSIZE EQU 2560 ; default stack is 5 Kb (2K words) X X_DATA segment para public 'DATA' X X_brksize DW offset dgroup:__end+2 ; dynamic changeable end of bss X_environ DW 0 ; save environment pointer here X X_DATA ends X X X_DATAEND segment para public 'DATA' X X; _DATAEND holds nothing. The label just tells us where X; the initialized data (.data) ends. X Xedata label byte X X_DATAEND ENDS X X_BSSEND SEGMENT BYTE PUBLIC 'BSS' X X; _BSSEND holds nothing. The label in the segment just tells X; us where the data+bss ends. X X__end label byte X X_BSSEND ENDS X X X@STACK SEGMENT BYTE STACK 'STACK' X DW STACKSIZE dup(?) ; add stack segment to bss X@STACK ENDS X X X_TEXT segment byte public 'CODE' X ASSUME CS:_TEXT,DS:DGROUP X XEXTRN _main:NEAR, _exit:NEAR X X; This is the C run-time start-off routine. It's job is to take the X; arguments as put on the stack by EXEC, and to parse them and set them up the X; way main expects them. X; X X$main: X mov ax,DGROUP ; force relocation of data & bss X mov bx,sp ; set stackframe pointer (ds=ss) X mov cx,[bx] ; get argc X add bx,2 ; point at next parameter X mov ax,cx X inc ax ; calculate envp X shl ax,1 X add ax,bx X mov _environ,ax ; save envp X push ax ; stack envp X push bx ; stack argv X push cx ; stack argc X X call _main ; call _main(arc,argv,envp) X X add sp,6 X push ax ; stack program-termination status X call _exit ; this will never return X X ; DEBUG from here on X Xkamikaze: int 3 X ret X X_TEXT ENDS X X X END $main ; program entry-point (could be anywhere) + END-OF-FILE lib/crtso.asm chmod u=rw,g=r,o=r lib/crtso.asm set `sum lib/crtso.asm` sum=$1 case $sum in 30524) :;; *) echo 'Bad sum in 'lib/crtso.asm >&2 esac echo Extracting lib/crypt.c sed 's/^X//' > lib/crypt.c << '+ END-OF-FILE 'lib/crypt.c X/* From Andy Tanenbaum's book "Computer Networks", X rewritten in C X*/ X Xstruct block { X unsigned char b_data[64]; X}; X Xstruct ordering { X unsigned char o_data[64]; X}; X Xstatic struct block key; X Xstatic struct ordering InitialTr = { X 58,50,42,34,26,18,10, 2,60,52,44,36,28,20,12, 4, X 62,54,46,38,30,22,14, 6,64,56,48,40,32,24,16, 8, X 57,49,41,33,25,17, 9, 1,59,51,43,35,27,19,11, 3, X 61,53,45,37,29,21,13, 5,63,55,47,39,31,23,15, 7, X}; X Xstatic struct ordering FinalTr = { X 40, 8,48,16,56,24,64,32,39, 7,47,15,55,23,63,31, X 38, 6,46,14,54,22,62,30,37, 5,45,13,53,21,61,29, X 36, 4,44,12,52,20,60,28,35, 3,43,11,51,19,59,27, X 34, 2,42,10,50,18,58,26,33, 1,41, 9,49,17,57,25, X}; X Xstatic struct ordering swap = { X 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48, X 49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64, X 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, X 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, X}; X Xstatic struct ordering KeyTr1 = { X 57,49,41,33,25,17, 9, 1,58,50,42,34,26,18, X 10, 2,59,51,43,35,27,19,11, 3,60,52,44,36, X 63,55,47,39,31,23,15, 7,62,54,46,38,30,22, X 14, 6,61,53,45,37,29,21,13, 5,28,20,12, 4, X}; X Xstatic struct ordering KeyTr2 = { X 14,17,11,24, 1, 5, 3,28,15, 6,21,10, X 23,19,12, 4,26, 8,16, 7,27,20,13, 2, X 41,52,31,37,47,55,30,40,51,45,33,48, X 44,49,39,56,34,53,46,42,50,36,29,32, X}; X Xstatic struct ordering etr = { X 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, X 8, 9,10,11,12,13,12,13,14,15,16,17, X 16,17,18,19,20,21,20,21,22,23,24,25, X 24,25,26,27,28,29,28,29,30,31,32, 1, X}; X Xstatic struct ordering ptr = { X 16, 7,20,21,29,12,28,17, 1,15,23,26, 5,18,31,10, X 2, 8,24,14,32,27, 3, 9,19,13,30, 6,22,11, 4,25, X}; X Xstatic unsigned char s_boxes[8][64] = { X{ 14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7, X 0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8, X 4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0, X 15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13, X}, X X{ 15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10, X 3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5, X 0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15, X 13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9, X}, X X{ 10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8, X 13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1, X 13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7, X 1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12, X}, X X{ 7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15, X 13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9, X 10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4, X 3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14, X}, X X{ 2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9, X 14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6, X 4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14, X 11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3, X}, X X{ 12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11, X 10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8, X 9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6, X 4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13, X}, X X{ 4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1, X 13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6, X 1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2, X 6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12, X}, X X{ 13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7, X 1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2, X 7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8, X 2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11, X}, X}; X Xstatic int rots[] = { X 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1, X}; X Xstatic Xtranspose(data, t, n) X register struct block *data; X register struct ordering *t; X register int n; X{ X struct block x; X X x = *data; X X while (n-- > 0) { X data->b_data[n] = x.b_data[t->o_data[n] - 1]; X } X} X Xstatic Xrotate(key) X register struct block *key; X{ X register unsigned char *p = key->b_data; X register unsigned char *ep = &(key->b_data[55]); X int data0 = key->b_data[0], data28 = key->b_data[28]; X X while (p++ < ep) *(p-1) = *p; X key->b_data[27] = data0; X key->b_data[55] = data28; X} X Xstatic struct ordering *EP = &etr; X Xstatic Xf(i, key, a, x) X struct block *key, *a; X register struct block *x; X{ X struct block e, ikey, y; X int k; X register unsigned char *p, *q, *r; X X e = *a; X transpose(&e, EP, 48); X for (k = rots[i]; k; k--) rotate(key); X ikey = *key; X transpose(&ikey, &KeyTr2, 48); X p = &(y.b_data[48]); X q = &(e.b_data[48]); X r = &(ikey.b_data[48]); X while (p > y.b_data) { X *--p = *--q ^ *--r; X } X q = x->b_data; X for (k = 0; k < 8; k++) { X register int xb, r; X X r = *p++ << 5; X r += *p++ << 3; X r += *p++ << 2; X r += *p++ << 1; X r += *p++; X r += *p++ << 4; X X xb = s_boxes[k][r]; X X *q++ = (xb >> 3) & 1; X *q++ = (xb>>2) & 1; X *q++ = (xb>>1) & 1; X *q++ = (xb & 1); X } X transpose(x, &ptr, 32); X} X Xsetkey(k) X register char *k; X{ X X key = *((struct block *) k); X transpose(&key, &KeyTr1, 56); X} X Xencrypt(blck, edflag) X char *blck; X{ X register struct block *p = (struct block *) blck; X register int i; X X transpose(p, &InitialTr, 64); X for (i = 15; i>= 0; i--) { X int j = edflag ? i : 15 - i; X register int k; X struct block b, x; X X b = *p; X for (k = 31; k >= 0; k--) { X p->b_data[k] = b.b_data[k + 32]; X } X f(j, &key, p, &x); X for (k = 31; k >= 0; k--) { X p->b_data[k+32] = b.b_data[k] ^ x.b_data[k]; X } X } X transpose(p, &swap, 64); X transpose(p, &FinalTr, 64); X} X Xchar * Xcrypt(pw,salt) X register char *pw; X char *salt; X{ X /* Unfortunately, I had to look at the sources of V7 crypt. X There was no other way to find out what this routine X actually does. X */ X X char pwb[66]; X static char result[16]; X register char *p = pwb; X struct ordering new_etr; X register int i; X X while (*pw && p < &pwb[64]) { X register int j = 7; X X while (j--) { X *p++ = (*pw >> j) & 01; X } X pw++; X *p++ = 0; X } X while (p < &pwb[64]) *p++ = 0; X X setkey(p = pwb); X X while (p < &pwb[66]) *p++ = 0; X X new_etr = etr; X EP = &new_etr; X for (i = 0; i < 2; i++) { X register char c = *salt++; X register int j; X X result[i] = c; X if ( c > 'Z') c -= 6 + 7 + '.'; /* c was a lower case letter */ X else if ( c > '9') c -= 7 + '.';/* c was upper case letter */ X else c -= '.'; /* c was digit, '.' or '/'. */ X /* now, 0 <= c <= 63 */ X for (j = 0; j < 6; j++) { X if ((c >> j) & 01) { X int t = 6*i + j; X int temp = new_etr.o_data[t]; X new_etr.o_data[t] = new_etr.o_data[t+24]; X new_etr.o_data[t+24] = temp; X } X } X } X X if (result[1] == 0) result[1] = result[0]; X X for (i = 0; i < 25; i++) encrypt(pwb,0); X EP = &etr; X X p = pwb; X pw = result+2; X while (p < &pwb[66]) { X register int c = 0; X register int j = 6; X X while (j--) { X c <<= 1; X c |= *p++; X } X c += '.'; /* becomes >= '.' */ X if (c > '9') c += 7; /* not in [./0-9], becomes upper */ X if (c > 'Z') c += 6; /* not in [A-Z], becomes lower */ X *pw++ = c; X } X *pw = 0; X return result; X} + END-OF-FILE lib/crypt.c chmod u=rw,g=r,o=r lib/crypt.c set `sum lib/crypt.c` sum=$1 case $sum in 12245) :;; *) echo 'Bad sum in 'lib/crypt.c >&2 esac echo Extracting lib/ctime.c sed 's/^X//' > lib/ctime.c << '+ END-OF-FILE 'lib/ctime.c Xstruct tm { X int tm_sec; X int tm_min; X int tm_hour; X int tm_mday; X int tm_mon; X int tm_year; X int tm_wday; X int tm_yday; X int tm_isdst; X}; X Xstruct timeb { X long time; X unsigned short millitm; X short timezone; X short dstflag; X}; X Xextern struct tm *localtime(); Xextern char *asctime(); X Xchar *ctime(clock) X long *clock; X{ X return asctime(localtime(clock)); X} X Xstatic int monthsize[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; X X#define SECS_DAY (24*60L*60L) X#define YEARSIZE(year) ((year) % 4 ? 365 : 366) X Xstruct tm * Xgmtime(clock) X long *clock; X{ X long cl = *clock; X long dayclock, dayno; X static struct tm tm_buf; X register struct tm *pbuf = &tm_buf; X register int *months = monthsize; X int year = 1970; X X dayclock = cl % SECS_DAY; X dayno = cl / SECS_DAY; X X pbuf->tm_sec = dayclock % 60; X pbuf->tm_min = (dayclock % 3600) / 60; X pbuf->tm_hour = dayclock / 3600; X pbuf->tm_wday = (dayno + 4) % 7; /* day 0 was a thursday */ X while (dayno >= YEARSIZE(year)) { X dayno -= YEARSIZE(year); X year++; X } X pbuf->tm_year = year - 1900; X pbuf->tm_yday = dayno; X pbuf->tm_isdst = 0; X if (YEARSIZE(year) == 366) monthsize[1] = 29; X while (dayno - *months >= 0) dayno -= *months++; X pbuf->tm_mday = dayno + 1; X pbuf->tm_mon = months - monthsize; X monthsize[1] = 28; X return pbuf; X} X X#define FIRSTSUNDAY(t) (((t)->tm_yday - (t)->tm_wday + 420) % 7) X#define SUNDAY(day, t) ((day) < 58 ? \ X ((day) < FIRSTSUNDAY(t) ? FIRSTSUNDAY(t) : Xstatic int Xlast_sunday(d, t) X register int d; X register struct tm *t; X{ X int first = FIRSTSUNDAY(t); X X if (d >= 58 && YEARSIZE(t->tm_year)) d++; X if (d < first) return first; X return d - (d - first) % 7; X} X Xextern struct tm *gmtime(); X Xstruct tm * Xlocaltime(clock) X long *clock; X{ X register struct tm *gmt; X long cl; X int begindst, enddst; X extern int __daylight; X extern long __timezone; X X tzset(); X cl = *clock - __timezone; X gmt = gmtime(&cl); X if (__daylight) { X /* daylight saving time. X Unfortunately, rules differ for different countries. X Implemented here are heuristics that got it right X in Holland, over the last couple of years. X Of course, there is no algorithm. It is all X politics ... X */ X begindst = last_sunday(89, gmt); /* last Sun before Apr */ X enddst = last_sunday(272, gmt); /* last Sun in Sep */ X if ((gmt->tm_yday>begindst || X (gmt->tm_yday==begindst && gmt->tm_hour>=2)) && X (gmt->tm_yday<enddst || X (gmt->tm_yday==enddst && gmt->tm_hour<3))) { X /* it all happens between 2 and 3 */ X cl += 1*60*60; X gmt = gmtime(&cl); X gmt->tm_isdst++; X } X } X return gmt; X} X#ifdef BSD4_2 X#else X#ifndef USG X#endif X#endif X X#ifdef USG Xlong timezone = -1 * 60; Xint daylight = 1; Xchar *tzname[] = {"MET", "MDT",}; X#endif X Xlong __timezone = -1 * 60; Xint __daylight = 1; Xchar *__tzname[] = {"MET", "MDT", }; X Xtzset() X{ X#ifdef BSD4_2 X struct timeval tval; X struct timezone tzon; X X gettimeofday(&tval, &tzon); X __timezone = tzon.tz_minuteswest * 60L; X __daylight = tzon.tz_dsttime; X#else X#ifndef USG X struct timeb time; X X ftime(&time); X __timezone = time.timezone*60L; X __daylight = time.dstflag; X#endif X#endif X X { X extern char *getenv(); X register char *p = getenv("TZ"); X X if (p && *p) { X register int n = 0; X int sign = 1; X X strncpy(__tzname[0], p, 3); X p += 3; X if (*(p += 3) == '-') { X sign = -1; X p++; X } X X while(*p >= '0' && *p <= '9') X n = 10 * n + (*p++ - '0'); X n *= sign; X __timezone = ((long)(n * 60)) * 60; X __daylight = (*p != '\0'); X strncpy(__tzname[1], p, 3); X } X } X#ifdef USG X timezone = __timezone; X daylight = __daylight; X tzname[0] = __tzname[0]; X tzname[1] = __tzname[1]; X#endif X} + END-OF-FILE lib/ctime.c chmod u=rw,g=r,o=r lib/ctime.c set `sum lib/ctime.c` sum=$1 case $sum in 16379) :;; *) echo 'Bad sum in 'lib/ctime.c >&2 esac echo Extracting lib/getenv.dif sed 's/^X//' > lib/getenv.dif << '+ END-OF-FILE 'lib/getenv.dif X1d0 X< #define NULL (char *) 0 X8,18c7,14 X< while ((p = *v) != NULL) { X< q = name; X< while (*p++ == *q) X< if (*q++ == 0) X< continue; X< if (*(p - 1) != '=') X< continue; X< return(p); X< } X< return(0); X< } X--- X> while ((p = *v++) != 0) { X> q = name; X> while (*q && *q++ == *p++) /* nothing */ ; X> if (*q || *p != '=') continue; X> return(p+1); X> } X> return(0); X> } + END-OF-FILE lib/getenv.dif chmod u=rw,g=r,o=r lib/getenv.dif set `sum lib/getenv.dif` sum=$1 case $sum in 23900) :;; *) echo 'Bad sum in 'lib/getenv.dif >&2 esac echo Extracting lib/getpwent.dif sed 's/^X//' > lib/getpwent.dif << '+ END-OF-FILE 'lib/getpwent.dif X73c73 X< struct passwd *getpwent () X--- X> struct passwd *getpwent () X78,90c78,90 X< pwd.name = _buf; X< skip_period (); X< pwd.passwd = _buf; X< skip_period (); X< pwd.uid = atoi (_buf); X< skip_period (); X< pwd.gid = atoi (_buf); X< skip_period (); X< pwd.gecos = _buf; X< skip_period (); X< pwd.dir = _buf; X< skip_period (); X< pwd.shell = _buf; X--- X> pwd.pw_name = _buf; X> skip_period (); X> pwd.pw_passwd = _buf; X> skip_period (); X> pwd.pw_uid = atoi (_buf); X> skip_period (); X> pwd.pw_gid = atoi (_buf); X> skip_period (); X> pwd.pw_gecos = _buf; X> skip_period (); X> pwd.pw_dir = _buf; X> skip_period (); X> pwd.pw_shell = _buf; X102c102 X< if (!strcmp (pwd -> name, name)) X--- X> if (!strcmp (pwd -> pw_name, name)) X118c118 X< if (pwd -> uid == uid) X--- X> if (pwd -> pw_uid == uid) + END-OF-FILE lib/getpwent.dif chmod u=rw,g=r,o=r lib/getpwent.dif set `sum lib/getpwent.dif` sum=$1 case $sum in 60392) :;; *) echo 'Bad sum in 'lib/getpwent.dif >&2 esac echo Extracting lib/getutil.asm sed 's/^X//' > lib/getutil.asm << '+ END-OF-FILE 'lib/getutil.asm Xtitle GetUtil - C86 version; now for Turbo C [EVAS] Xpage,132 X Xinclude prologue.h X X PUBLIC _get_base, _get_size, _get_tot_mem X X EXTRN __end:byte X X X_TEXT SEGMENT byte public 'CODE' X X ASSUME CS:_TEXT,DS:DGROUP X X;======================================================================== X; utilities X;======================================================================== X X_get_base: ; return click at which prog starts X mov ax,ds X ret X X_get_size: ; return prog size in bytes [text+data+bss] X mov ax,offset dgroup:__end ; end is label at end of bss X ret X X; Find out how much memory the machine has, including vectors, kernel MM, etc. X_get_tot_mem: X cli X push es X push di X mov ax,8192 ; start search at 128K [8192 clicks] X sub di,di Xy1: mov es,ax X mov es:[di],0A5A4h ; write random bit pattern to memory X xor bx,bx X mov bx,es:[di] ; read back pattern just written X cmp bx,0A5A4h ; compare with expected value X jne y2 ; if different, no memory present X add ax,4096 ; advance counter by 64K X cmp ax,0A000h ; stop seaching at 640K X jne y1 Xy2: pop di X pop es X sti X ret X X_TEXT ENDS X X END ; end of assembly-file + END-OF-FILE lib/getutil.asm chmod u=rw,g=r,o=r lib/getutil.asm set `sum lib/getutil.asm` sum=$1 case $sum in 24012) :;; *) echo 'Bad sum in 'lib/getutil.asm >&2 esac echo Extracting lib/head.asm sed 's/^X//' > lib/head.asm << '+ END-OF-FILE 'lib/head.asm Xtitle Head - Start-off for initt, mm and fs (C86-compiler); now for Turbo C [EVAS] Xpage ,132 X Xinclude prologue.h X XEXTRN _main:NEAR XPUBLIC $main, _data_org, brksize, sp_limit, __end XEXTRN _stackpt:word X X X_TEXT SEGMENT byte public 'CODE' X X assume cs:_TEXT,ds:DGROUP X X$main: jmp short L0 X X ORG 10h ; kernel uses this area as stack for inital IRET XL0: mov sp,dgroup:_stackpt X call _main XL1: jmp L1 ; this will never be executed X mov ax,DGROUP ; force relocation for dos2out (never executed) X X_TEXT ENDS X X X_DATA SEGMENT X ; fs needs to know where build stuffed table X_data_org DW 0DADAh ; 0xDADA is magic number for build X DW 7 dup(0) ; first 8 words of MM, FS, INIT are for stack Xbrksize DW offset dgroup:__end ; first free memory Xsp_limit DW 0 X X_DATA ENDS X X_BSSEND SEGMENT X X; _BSSEND holds nothing. The label in the segment just tells X; us where the data+bss ends. X X__end label byte X X_BSSEND ENDS X X X@STACK SEGMENT BYTE STACK 'STACK' X@STACK ENDS ; Add stack to satisfy DOS-linker X X END $main ; end of assembly & entry-point X + END-OF-FILE lib/head.asm chmod u=rw,g=r,o=r lib/head.asm set `sum lib/head.asm` sum=$1 case $sum in 17073) :;; *) echo 'Bad sum in 'lib/head.asm >&2 esac echo Extracting lib/makefile sed 's/^X//' > lib/makefile << '+ END-OF-FILE 'lib/makefile XCCOPTS=-A -mt -I..\include -Di8088 -DTURBO -G -O XCC=tcc X XOBJASM=crtso.obj head.obj getutil.obj sendrec.obj setjmp.obj catchsig.obj X XOBJ1= ABORT.OBJ ABS.OBJ ACCESS.OBJ ALARM.OBJ ATOI.OBJ ATOL.OBJ \ X BCOPY.OBJ BRK.OBJ BRK2.OBJ CALL.OBJ CHDIR.OBJ CHMOD.OBJ \ X CHOWN.OBJ CHROOT.OBJ CLEANUP.OBJ CLOSE.OBJ CREAT.OBJ CRYPT.OBJ \ X CTYPE.OBJ DOPRINTF.OBJ DUP.OBJ DUP2.OBJ EXEC.OBJ \ X EXIT.OBJ FCLOSE.OBJ FFLUSH.OBJ FGETS.OBJ FOPEN.OBJ \ X FORK.OBJ FPRINTF.OBJ FPUTS.OBJ FREAD.OBJ FREOPEN.OBJ \ X FSEEK.OBJ FSTAT.OBJ FTELL.OBJ FWRITE.OBJ GETC.OBJ \ X GETEGID.OBJ GETENV.OBJ GETEUID.OBJ GETGID.OBJ GETGRENT.OBJ \ X GETPASS.OBJ GETPID.OBJ GETPWENT.OBJ GETS.OBJ GETUID.OBJ \ X INDEX.OBJ IOCTL.OBJ ISATTY.OBJ ITOA.OBJ KILL.OBJ LINK.OBJ \ X LSEEK.OBJ MALLOC.OBJ MESSAGE.OBJ MKNOD.OBJ MKTEMP.OBJ X XOBJ2= MOUNT.OBJ OPEN.OBJ PAUSE.OBJ PERROR.OBJ PIPE.OBJ \ X PRINTDAT.OBJ PRINTK.OBJ PRINTS.OBJ PROLOGUE.H PUTC.OBJ \ X RAND.OBJ READ.OBJ REGEXP.OBJ REGSUB.OBJ RINDEX.OBJ \ X SCANF.OBJ SETBUF.OBJ SETGID.OBJ SETUID.OBJ \ X SIGNAL.OBJ SLEEP.OBJ SPRINTF.OBJ STAT.OBJ STB.OBJ \ X STDERR.OBJ STIME.OBJ STRCAT.OBJ STRCMP.OBJ STRCPY.OBJ \ X STRLEN.OBJ STRNCAT.OBJ STRNCMP.OBJ STRNCPY.OBJ SYNC.OBJ \ X SYSLIB.OBJ TIME.OBJ TIMES.OBJ UMASK.OBJ UMOUNT.OBJ \ X UNGETC.OBJ UNLINK.OBJ UTIME.OBJ \ X WAIT.OBJ WRITE.OBJ \ X ctime.obj popen.obj system.obj puts.obj qsort.obj X X.c.obj: X $(CC) $(CCOPTS) -c $< X X.asm.obj: X masm /mx $<,,nul,nul X Xfast: *.c X $(CC) $(CCOPTS) -c *.c X Xall: dummy1 dummy2 $(OBJASM) X copy head.obj ..\mlib X copy crtso.obj ..\mlib X -rm /f ..\mlib\minix.lib X lib @..\mlib\libfile X Xdummy1: $(OBJ1) X Xdummy2: $(OBJ2) X X$(OBJASM): prologue.h X + END-OF-FILE lib/makefile chmod u=rw,g=r,o=r lib/makefile set `sum lib/makefile` sum=$1 case $sum in 45586) :;; *) echo 'Bad sum in 'lib/makefile >&2 esac echo Extracting lib/malloc.dif sed 's/^X//' > lib/malloc.dif << '+ END-OF-FILE 'lib/malloc.dif X84,88c84,105 X< free(p) X< char *p; X< { X< * (vir_bytes *) (p - sizeof(char *)) &= ~BUSY; X< } X--- X> char *calloc(m,size) X> unsigned m,size; X> { X> char *malloc(); X> char *cp; X> register int i; X> register char *temp; X> X> i = m*size; X> if ((cp=malloc(i))==(char *)0) return (char *)0; X> X> /* malloc succeeded--clear allocated memory */ X> for (temp = cp ; i-- ; ) *temp++ = '\0'; X> return cp; X> } X> X> X> free(p) X> char *p; X> { X> * (vir_bytes *) (p - sizeof(char *)) &= ~BUSY; X> } + END-OF-FILE lib/malloc.dif chmod u=rw,g=r,o=r lib/malloc.dif set `sum lib/malloc.dif` sum=$1 case $sum in 35425) :;; *) echo 'Bad sum in 'lib/malloc.dif >&2 esac echo Extracting lib/popen.c sed 's/^X//' > lib/popen.c << '+ END-OF-FILE 'lib/popen.c X#include <stdio.h> X#include <signal.h> X Xstatic int pids[20]; X XFILE * Xpopen(command, type) X char *command, *type; X{ X int piped[2]; X int Xtype = *type == 'r' ? 0 : *type == 'w' ? 1 : 2; X int pid; X X if (Xtype == 2 || X pipe(piped) < 0 || X (pid = fork()) < 0) return 0; X X if (pid == 0) { X /* child */ X register int *p; X X for (p = pids; p < &pids[20]; p++) { X if (*p) close(p - pids); X } X close(piped[Xtype]); X dup2(piped[!Xtype], !Xtype); X close(piped[!Xtype]); X execl("/bin/sh", "sh", "-c", command, (char *) 0); X _exit(127); /* like system() ??? */ X } X X pids[piped[Xtype]] = pid; X close(piped[!Xtype]); X return fdopen(piped[Xtype], type); X} X Xpclose(iop) X FILE *iop; X{ X int fd = fileno(iop); X int status, wret; X int (*intsave)() = signal(SIGINT, SIG_IGN); X int (*quitsave)() = signal(SIGQUIT, SIG_IGN); X X fclose(iop); X while ((wret = wait(&status)) != -1) { X if (wret == pids[fd]) break; X } X if (wret == -1) status = -1; X signal(SIGINT, intsave); X signal(SIGQUIT, quitsave); X pids[fd] = 0; X return status; X} + END-OF-FILE lib/popen.c chmod u=rw,g=r,o=r lib/popen.c set `sum lib/popen.c` sum=$1 case $sum in 11243) :;; *) echo 'Bad sum in 'lib/popen.c >&2 esac echo Extracting lib/printk.dif sed 's/^X//' > lib/printk.dif << '+ END-OF-FILE 'lib/printk.dif X2c2 X< * system itself, and should never be included in user programs. The name X--- X> * system itself, and should never be included in user programs. The name X15a16 X> char **pp; X33a35 X> pp = (char **) valp; X43c45 X< case 's': p = (char *) *valp++; X--- X> case 's': p = *pp++; valp = (int *) pp; + END-OF-FILE lib/printk.dif chmod u=rw,g=r,o=r lib/printk.dif set `sum lib/printk.dif` sum=$1 case $sum in 23032) :;; *) echo 'Bad sum in 'lib/printk.dif >&2 esac echo Extracting lib/prologue.h sed 's/^X//' > lib/prologue.h << '+ END-OF-FILE 'lib/prologue.h X X; Segment and Group declarations X X_TEXT SEGMENT BYTE PUBLIC 'CODE' X_TEXT ENDS X_DATABEG SEGMENT PARA PUBLIC 'DATA' X_DATABEG ENDS X_DATA SEGMENT PARA PUBLIC 'DATA' X_DATA ENDS X_DATAEND SEGMENT PARA PUBLIC 'DATA' X_DATAEND ENDS X_BSS SEGMENT WORD PUBLIC 'BSS' X_BSS ENDS X_BSSEND SEGMENT BYTE PUBLIC 'BSS' X_BSSEND ENDS X_STACK SEGMENT STACK 'STACK' X_STACK ENDS X XDGROUP GROUP _DATABEG,_DATA, _DATAEND, _BSS, _BSSEND, _STACK X + END-OF-FILE lib/prologue.h chmod u=rw,g=r,o=r lib/prologue.h set `sum lib/prologue.h` sum=$1 case $sum in 27968) :;; *) echo 'Bad sum in 'lib/prologue.h >&2 esac echo Extracting lib/putc.dif sed 's/^X//' > lib/putc.dif << '+ END-OF-FILE 'lib/putc.dif X41,43c41,43 X< return(0); X< } X< X--- X> return(ch & CMASK); X> } X> + END-OF-FILE lib/putc.dif chmod u=rw,g=r,o=r lib/putc.dif set `sum lib/putc.dif` sum=$1 case $sum in 3980) :;; *) echo 'Bad sum in 'lib/putc.dif >&2 esac echo Extracting lib/puts.c sed 's/^X//' > lib/puts.c << '+ END-OF-FILE 'lib/puts.c X#include "stdio.h" X Xint puts(s) Xchar *s; X{ X char c; X X c = fputs(s,stdout); X putchar('\n'); X return(c); X} + END-OF-FILE lib/puts.c chmod u=rw,g=r,o=r lib/puts.c set `sum lib/puts.c` sum=$1 case $sum in 8577) :;; *) echo 'Bad sum in 'lib/puts.c >&2 esac exit 0