Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba2871aa34 | ||
|
|
edde805980 | ||
|
|
db74d0da32 | ||
|
|
1253330adc | ||
|
|
26e2d7dd5e | ||
|
|
9c3b2e0d9a | ||
|
|
51da6c0e6e | ||
|
|
dbe1779a29 | ||
|
|
c6f46414ed | ||
|
|
552f5ed4c2 | ||
|
|
2d61fa76c3 | ||
|
|
72d7321b45 | ||
|
|
82817c9308 | ||
|
|
c849b8f1f8 | ||
|
|
1febcc5f9f | ||
|
|
7b1d52abff | ||
|
|
2f2d84e6a0 | ||
|
|
6794c38ff4 | ||
|
|
840cd1db8b | ||
|
|
f6602a8a6d | ||
|
|
97dfd3ae89 | ||
|
|
e728e7f25d | ||
|
|
146bae8a98 | ||
|
|
724973121b | ||
|
|
cc59786ed6 | ||
|
|
4c51256273 | ||
|
|
27ddb2eef0 | ||
|
|
c213981071 | ||
|
|
75302a4eec | ||
|
|
2252835438 | ||
|
|
9e2d5993f6 | ||
|
|
a47779d9d6 | ||
|
|
bd9f0208d2 | ||
|
|
4fdec2101b | ||
|
|
9c50b5a97d | ||
|
|
37d1b00b7c | ||
|
|
716151b46f | ||
|
|
8458c9e3c4 | ||
|
|
4e2c809150 | ||
|
|
ef83392732 | ||
|
|
9d5c61e023 | ||
|
|
d5002ad0ac | ||
|
|
00c4bf1ea1 | ||
|
|
9f617eb6fe |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -26,3 +26,4 @@
|
|||||||
*.img
|
*.img
|
||||||
|
|
||||||
Makefile.user
|
Makefile.user
|
||||||
|
TODO
|
||||||
|
|||||||
3
Makefile
3
Makefile
@@ -34,8 +34,9 @@ CONFIG = $(TOPSRC)/tools/configsys/config
|
|||||||
|
|
||||||
all:
|
all:
|
||||||
$(MAKE) -C tools
|
$(MAKE) -C tools
|
||||||
|
$(MAKE) -C src
|
||||||
$(MAKE) -C lib
|
$(MAKE) -C lib
|
||||||
$(MAKE) -C src install
|
$(MAKE) -C install
|
||||||
$(MAKE) kernel
|
$(MAKE) kernel
|
||||||
$(MAKE) fs
|
$(MAKE) fs
|
||||||
|
|
||||||
|
|||||||
8
cross.mk
8
cross.mk
@@ -23,9 +23,13 @@ LDFLAGS =
|
|||||||
LIBS =
|
LIBS =
|
||||||
|
|
||||||
# Add system include path
|
# Add system include path
|
||||||
ifeq (,$(wildcard /usr/include/i386-linux-gnu))
|
ifeq (/usr/include/x86_64-linux-gnu,$(wildcard /usr/include/x86_64-linux-gnu))
|
||||||
CFLAGS += -I/usr/include
|
CFLAGS += -I/usr/include/x86_64-linux-gnu
|
||||||
else
|
else
|
||||||
|
ifeq (/usr/include/i386-linux-gnu,$(wildcard /usr/include/i386-linux-gnu))
|
||||||
CFLAGS += -I/usr/include/i386-linux-gnu
|
CFLAGS += -I/usr/include/i386-linux-gnu
|
||||||
|
else
|
||||||
|
CFLAGS += -I/usr/include
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
CFLAGS += -I$(TOPSRC)/include
|
CFLAGS += -I$(TOPSRC)/include
|
||||||
|
|||||||
@@ -84,17 +84,17 @@ extern WINDOW *stdscr, *curscr;
|
|||||||
int __void__;
|
int __void__;
|
||||||
#define VOID(x) (__void__ = (int) (x))
|
#define VOID(x) (__void__ = (int) (x))
|
||||||
#else
|
#else
|
||||||
#define VOID(x) (x)
|
#define VOID(x) ((void)(x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* psuedo functions for standard screen
|
* psuedo functions for standard screen
|
||||||
*/
|
*/
|
||||||
#define addch(ch) VOID(waddch(stdscr, ch))
|
#define addch(ch) VOID(waddch(stdscr, ch))
|
||||||
#define getch() VOID(wgetch(stdscr))
|
#define getch() wgetch(stdscr)
|
||||||
#define addstr(str) VOID(waddstr(stdscr, str))
|
#define addstr(str) VOID(waddstr(stdscr, str))
|
||||||
#define getstr(str) VOID(wgetstr(stdscr, str))
|
#define getstr(str) VOID(wgetstr(stdscr, str))
|
||||||
#define move(y, x) VOID(wmove(stdscr, y, x))
|
#define move(y, x) wmove(stdscr, y, x)
|
||||||
#define clear() VOID(wclear(stdscr))
|
#define clear() VOID(wclear(stdscr))
|
||||||
#define erase() VOID(werase(stdscr))
|
#define erase() VOID(werase(stdscr))
|
||||||
#define clrtobot() VOID(wclrtobot(stdscr))
|
#define clrtobot() VOID(wclrtobot(stdscr))
|
||||||
@@ -111,7 +111,7 @@ int __void__;
|
|||||||
/*
|
/*
|
||||||
* mv functions
|
* mv functions
|
||||||
*/
|
*/
|
||||||
#define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
|
#define mvwaddch(win,y,x,ch) (wmove(win,y,x) == ERR ? ERR : waddch(win,ch))
|
||||||
#define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
|
#define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
|
||||||
#define mvwaddstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
|
#define mvwaddstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
|
||||||
#define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
|
#define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
|
||||||
|
|||||||
@@ -13,3 +13,5 @@ struct group *getgrgid(gid_t gid);
|
|||||||
void setgrent(void);
|
void setgrent(void);
|
||||||
void endgrent(void);
|
void endgrent(void);
|
||||||
int setgroups(size_t size, const gid_t *list);
|
int setgroups(size_t size, const gid_t *list);
|
||||||
|
int getgrouplist(char *uname, gid_t agroup, gid_t *groups, int *grpcnt);
|
||||||
|
int initgroups(char *uname, int agroup);
|
||||||
|
|||||||
2
include/inttypes.h
Normal file
2
include/inttypes.h
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
7
include/regex.h
Normal file
7
include/regex.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#ifndef _REGEX_H
|
||||||
|
#define _REGEX_H
|
||||||
|
|
||||||
|
char *re_comp(const char *regex);
|
||||||
|
int re_exec(const char *string);
|
||||||
|
|
||||||
|
#endif
|
||||||
37
include/stdbool.h
Normal file
37
include/stdbool.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2000 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#ifndef __bool_true_false_are_defined
|
||||||
|
#define __bool_true_false_are_defined 1
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
|
||||||
|
#define false 0
|
||||||
|
#define true 1
|
||||||
|
|
||||||
|
#define bool _Bool
|
||||||
|
|
||||||
|
#endif /* !__cplusplus */
|
||||||
|
#endif /* __bool_true_false_are_defined */
|
||||||
@@ -5,9 +5,26 @@
|
|||||||
typedef signed char int8_t;
|
typedef signed char int8_t;
|
||||||
typedef short int int16_t;
|
typedef short int int16_t;
|
||||||
typedef int int32_t;
|
typedef int int32_t;
|
||||||
|
typedef long long int64_t;
|
||||||
|
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
typedef unsigned short int uint16_t;
|
typedef unsigned short int uint16_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
|
typedef unsigned long long uint64_t;
|
||||||
|
|
||||||
|
#define INT8_C(x) x
|
||||||
|
#define UINT8_C(x) x##U
|
||||||
|
|
||||||
|
#define INT16_C(x) x
|
||||||
|
#define UINT16_C(x) x##U
|
||||||
|
|
||||||
|
#define INT32_C(x) x
|
||||||
|
#define UINT32_C(x) x##U
|
||||||
|
|
||||||
|
#define INT64_C(x) x##LL
|
||||||
|
#define UINT64_C(x) x##ULL
|
||||||
|
|
||||||
|
#define INTMAX_C(x) x##LL
|
||||||
|
#define UINTMAX_C(x) x##ULL
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -65,17 +65,11 @@ typedef unsigned size_t;
|
|||||||
_flsbuf((unsigned char)(x), p)))
|
_flsbuf((unsigned char)(x), p)))
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#define getchar() getc(stdin)
|
|
||||||
#define putchar(x) putc(x,stdout)
|
|
||||||
#define feof(p) (((p)->_flag&_IOEOF)!=0)
|
|
||||||
#define ferror(p) (((p)->_flag&_IOERR)!=0)
|
|
||||||
#define fileno(p) ((p)->_file)
|
|
||||||
#define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
|
|
||||||
|
|
||||||
FILE *fopen (const char *, const char *);
|
FILE *fopen (const char *, const char *);
|
||||||
FILE *fdopen (int, const char *);
|
FILE *fdopen (int, const char *);
|
||||||
FILE *freopen (const char *, const char *, FILE *);
|
FILE *freopen (const char *, const char *, FILE *);
|
||||||
FILE *popen (const char *, const char *);
|
FILE *popen (const char *, const char *);
|
||||||
|
int pclose(FILE *stream);
|
||||||
FILE *tmpfile (void);
|
FILE *tmpfile (void);
|
||||||
int fclose (FILE *);
|
int fclose (FILE *);
|
||||||
long ftell (FILE *);
|
long ftell (FILE *);
|
||||||
@@ -83,6 +77,7 @@ int fflush (FILE *);
|
|||||||
int fgetc (FILE *);
|
int fgetc (FILE *);
|
||||||
int ungetc (int, FILE *);
|
int ungetc (int, FILE *);
|
||||||
int fputc (int, FILE *);
|
int fputc (int, FILE *);
|
||||||
|
int putchar (int);
|
||||||
int fputs (const char *, FILE *);
|
int fputs (const char *, FILE *);
|
||||||
int puts (const char *);
|
int puts (const char *);
|
||||||
char *fgets (char *, int, FILE *);
|
char *fgets (char *, int, FILE *);
|
||||||
@@ -95,6 +90,7 @@ void setbuffer (FILE *, char *, size_t);
|
|||||||
void setlinebuf (FILE *);
|
void setlinebuf (FILE *);
|
||||||
int setvbuf (FILE *, char *, int, size_t);
|
int setvbuf (FILE *, char *, int, size_t);
|
||||||
int fseek (FILE *, long, int);
|
int fseek (FILE *, long, int);
|
||||||
|
int rename(const char *, const char *);
|
||||||
void rewind (FILE *);
|
void rewind (FILE *);
|
||||||
int remove (const char *);
|
int remove (const char *);
|
||||||
int getw(FILE *stream);
|
int getw(FILE *stream);
|
||||||
@@ -112,6 +108,13 @@ int fscanf (FILE *, const char *, ...);
|
|||||||
int scanf (const char *, ...);
|
int scanf (const char *, ...);
|
||||||
int sscanf (const char *, const char *, ...);
|
int sscanf (const char *, const char *, ...);
|
||||||
|
|
||||||
|
#define getchar() getc(stdin)
|
||||||
|
#define putchar(x) putc(x,stdout)
|
||||||
|
#define feof(p) (((p)->_flag&_IOEOF)!=0)
|
||||||
|
#define ferror(p) (((p)->_flag&_IOERR)!=0)
|
||||||
|
#define fileno(p) ((p)->_file)
|
||||||
|
#define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
|
||||||
|
|
||||||
#ifndef _VA_LIST_
|
#ifndef _VA_LIST_
|
||||||
# ifdef __GNUC__
|
# ifdef __GNUC__
|
||||||
# define va_list __builtin_va_list /* For Gnu C */
|
# define va_list __builtin_va_list /* For Gnu C */
|
||||||
|
|||||||
@@ -57,49 +57,49 @@
|
|||||||
typedef unsigned size_t;
|
typedef unsigned size_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void abort (void);
|
void abort(void);
|
||||||
int abs (int);
|
int abs(int);
|
||||||
int atexit (void (*)(void));
|
int atexit(void (*)(void));
|
||||||
int atoi (const char *);
|
int atoi(const char *);
|
||||||
long atol (const char *);
|
long atol(const char *);
|
||||||
void *calloc (size_t, size_t);
|
void *calloc(size_t, size_t);
|
||||||
void exit (int);
|
void exit(int);
|
||||||
void free (void *);
|
void free(void *);
|
||||||
char *getenv (const char *);
|
char *getenv(const char *);
|
||||||
long labs (long);
|
long labs(long);
|
||||||
void *malloc (size_t);
|
void *malloc(size_t);
|
||||||
char *mktemp (char *);
|
char *mktemp(char *);
|
||||||
int mkstemp (char *);
|
int mkstemp(char *);
|
||||||
void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
|
void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
|
||||||
int rand (void);
|
int rand(void);
|
||||||
void *realloc (void*, size_t);
|
void *realloc(void*, size_t);
|
||||||
void srand (unsigned);
|
void srand(unsigned);
|
||||||
long strtol (const char *, char **, int);
|
long strtol(const char *, char **, int);
|
||||||
unsigned long strtoul (const char *, char **, int);
|
unsigned long strtoul(const char *, char **, int);
|
||||||
int system (const char *);
|
int system(const char *);
|
||||||
|
|
||||||
int putenv (char *string);
|
int putenv(char *string);
|
||||||
int setenv (const char *name, const char *value, int overwrite);
|
int setenv(const char *name, const char *value, int overwrite);
|
||||||
int unsetenv (const char *name);
|
int unsetenv(const char *name);
|
||||||
char *_findenv (const char *name, int *offset);
|
char *_findenv(const char *name, int *offset);
|
||||||
|
|
||||||
void *alloca (size_t size);
|
void *alloca(size_t size);
|
||||||
|
|
||||||
int daemon (int, int);
|
int daemon(int, int);
|
||||||
char *devname (int dev, int type);
|
char *devname(int dev, int type);
|
||||||
int getloadavg (unsigned loadavg[], int nelem);
|
int getloadavg(unsigned loadavg[], int nelem);
|
||||||
|
|
||||||
extern char *suboptarg; /* getsubopt(3) external variable */
|
extern char *suboptarg; /* getsubopt(3) external variable */
|
||||||
int getsubopt (char **, char **, char **);
|
int getsubopt(char **, char **, char **);
|
||||||
|
|
||||||
long random (void);
|
long random(void);
|
||||||
char *setstate (char *);
|
char *setstate(char *);
|
||||||
void srandom (unsigned);
|
void srandom(unsigned);
|
||||||
|
|
||||||
double atof (const char *);
|
double atof(const char *);
|
||||||
double strtod (const char *, char **);
|
double strtod(const char *, char **);
|
||||||
char *ecvt (double, int, int *, int *);
|
char *ecvt(double, int, int *, int *);
|
||||||
char *fcvt (double, int, int *, int *);
|
char *fcvt(double, int, int *, int *);
|
||||||
char *gcvt (double, int, char *);
|
char *gcvt(double, int, char *);
|
||||||
|
|
||||||
#endif /* _STDLIB_H_ */
|
#endif /* _STDLIB_H_ */
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ typedef unsigned size_t;
|
|||||||
|
|
||||||
int bcmp(const void *, const void *, size_t);
|
int bcmp(const void *, const void *, size_t);
|
||||||
void bcopy(const void *, void *, size_t);
|
void bcopy(const void *, void *, size_t);
|
||||||
void bzero(void *, unsigned long);
|
void bzero(void *, unsigned int);
|
||||||
int ffs(int);
|
int ffs(int);
|
||||||
char *index(const char *, int);
|
char *index(const char *, int);
|
||||||
char *rindex(const char *, int);
|
char *rindex(const char *, int);
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ extern int tgetnum(char *);
|
|||||||
extern int tgetflag(char *);
|
extern int tgetflag(char *);
|
||||||
extern char *tgetstr(char *, char **);
|
extern char *tgetstr(char *, char **);
|
||||||
extern char *tgoto(char *, int, int);
|
extern char *tgoto(char *, int, int);
|
||||||
extern int tputs(register char *, int, int (*)());
|
extern int tputs(register char *, int, int (*)(int));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
116
include/unistd.h
116
include/unistd.h
@@ -57,14 +57,16 @@
|
|||||||
#define X_OK 1 /* Test for execute permission. */
|
#define X_OK 1 /* Test for execute permission. */
|
||||||
#define F_OK 0 /* Test for existence. */
|
#define F_OK 0 /* Test for existence. */
|
||||||
|
|
||||||
void _exit (int);
|
void _exit(int);
|
||||||
int access();
|
int access();
|
||||||
unsigned int alarm();
|
unsigned int alarm();
|
||||||
pid_t fork();
|
pid_t fork();
|
||||||
|
pid_t setsid(void);
|
||||||
gid_t getegid();
|
gid_t getegid();
|
||||||
uid_t geteuid();
|
uid_t geteuid();
|
||||||
gid_t getgid();
|
gid_t getgid();
|
||||||
char *getlogin();
|
char *getlogin();
|
||||||
|
int setlogin(const char *name);
|
||||||
pid_t getpgrp();
|
pid_t getpgrp();
|
||||||
pid_t getpid();
|
pid_t getpid();
|
||||||
pid_t getppid();
|
pid_t getppid();
|
||||||
@@ -73,12 +75,12 @@ off_t lseek();
|
|||||||
ssize_t read();
|
ssize_t read();
|
||||||
unsigned int sleep();
|
unsigned int sleep();
|
||||||
char *ttyname();
|
char *ttyname();
|
||||||
ssize_t write (int fd, const void *buf, size_t count);
|
ssize_t write(int fd, const void *buf, size_t count);
|
||||||
int truncate (const char *path, off_t length);
|
int truncate(const char *path, off_t length);
|
||||||
int ftruncate (int fd, off_t length);
|
int ftruncate(int fd, off_t length);
|
||||||
|
|
||||||
void *brk (const void *addr);
|
void *brk(const void *addr);
|
||||||
int _brk (const void *addr);
|
int _brk(const void *addr);
|
||||||
char *crypt();
|
char *crypt();
|
||||||
void endusershell();
|
void endusershell();
|
||||||
long gethostid();
|
long gethostid();
|
||||||
@@ -88,60 +90,74 @@ char *getwd();
|
|||||||
void psignal();
|
void psignal();
|
||||||
extern char *sys_siglist[];
|
extern char *sys_siglist[];
|
||||||
char *re_comp();
|
char *re_comp();
|
||||||
void *sbrk (int incr);
|
void *sbrk(int incr);
|
||||||
int sethostid();
|
int sethostid();
|
||||||
void setusershell();
|
void setusershell();
|
||||||
void sync();
|
void sync(void);
|
||||||
unsigned int ualarm();
|
unsigned int ualarm();
|
||||||
void usleep();
|
void usleep();
|
||||||
int pause (void);
|
int pause(void);
|
||||||
pid_t vfork();
|
pid_t vfork();
|
||||||
|
|
||||||
int pipe (int pipefd[2]);
|
int pipe(int pipefd[2]);
|
||||||
int close (int fd);
|
int close(int fd);
|
||||||
int dup (int oldfd);
|
int dup(int oldfd);
|
||||||
int dup2 (int oldfd, int newfd);
|
int dup2(int oldfd, int newfd);
|
||||||
int unlink (const char *pathname);
|
int unlink(const char *pathname);
|
||||||
int link (const char *oldpath, const char *newpath);
|
int link(const char *oldpath, const char *newpath);
|
||||||
ssize_t readlink (const char *path, char *buf, size_t bufsiz);
|
ssize_t readlink(const char *path, char *buf, size_t bufsiz);
|
||||||
int chown (const char *path, uid_t owner, gid_t group);
|
int chown(const char *path, uid_t owner, gid_t group);
|
||||||
int nice (int inc);
|
int fchown(int fd, uid_t owner, gid_t group);
|
||||||
int setuid (uid_t uid);
|
int nice(int inc);
|
||||||
int setgid (gid_t gid);
|
int setuid(uid_t uid);
|
||||||
int seteuid (uid_t euid);
|
int setgid(gid_t gid);
|
||||||
int setegid (gid_t egid);
|
int seteuid(uid_t euid);
|
||||||
int setreuid (uid_t ruid, uid_t euid);
|
int setegid(gid_t egid);
|
||||||
int setregid (gid_t rgid, gid_t egid);
|
int setreuid(uid_t ruid, uid_t euid);
|
||||||
int isatty (int fd);
|
int setregid(gid_t rgid, gid_t egid);
|
||||||
int chdir (const char *path);
|
int setpgrp(void);
|
||||||
int fchdir (int fd);
|
int isatty(int fd);
|
||||||
int chflags (const char *path, u_long flags);
|
int chdir(const char *path);
|
||||||
int fchflags (int fd, u_long flags);
|
int fchdir(int fd);
|
||||||
int getgroups (int size, gid_t list[]);
|
int chflags(const char *path, u_long flags);
|
||||||
int getdtablesize (void);
|
int fchflags(int fd, u_long flags);
|
||||||
int rmdir (const char *pathname);
|
int getgroups(int size, gid_t list[]);
|
||||||
|
int getdtablesize(void);
|
||||||
|
int rmdir(const char *pathname);
|
||||||
|
|
||||||
struct stat;
|
struct stat;
|
||||||
int stat (const char *path, struct stat *buf);
|
int stat(const char *path, struct stat *buf);
|
||||||
int fstat (int fd, struct stat *buf);
|
int fstat(int fd, struct stat *buf);
|
||||||
int lstat (const char *path, struct stat *buf);
|
int lstat(const char *path, struct stat *buf);
|
||||||
|
|
||||||
int execl (const char *path, const char *arg0, ... /* NULL */);
|
int execl(const char *path, const char *arg0, ... /* NULL */);
|
||||||
int execle (const char *path, const char *arg0, ... /* NULL, char *envp[] */);
|
int execle(const char *path, const char *arg0, ... /* NULL, char *envp[] */);
|
||||||
int execlp (const char *file, const char *arg0, ... /* NULL */);
|
int execlp(const char *file, const char *arg0, ... /* NULL */);
|
||||||
|
|
||||||
int execv (const char *path, char *const argv[]);
|
int execv(const char *path, char *const argv[]);
|
||||||
int execve (const char *path, char *const arg0[], char *const envp[]);
|
int execve(const char *path, char *const arg0[], char *const envp[]);
|
||||||
int execvp (const char *file, char *const argv[]);
|
int execvp(const char *file, char *const argv[]);
|
||||||
|
|
||||||
extern char **environ; /* Environment, from crt0. */
|
extern char **environ; /* Environment, from crt0. */
|
||||||
extern const char *__progname; /* Program name, from crt0. */
|
extern const char *__progname; /* Program name, from crt0. */
|
||||||
|
|
||||||
int getopt (int argc, char * const argv[], const char *optstring);
|
int getopt(int argc, char * const argv[], const char *optstring);
|
||||||
|
|
||||||
extern char *optarg; /* getopt(3) external variables */
|
extern char *optarg; /* getopt(3) external variables */
|
||||||
extern int opterr, optind, optopt;
|
extern int opterr, optind, optopt;
|
||||||
|
|
||||||
|
int gethostname(char *name, int namelen);
|
||||||
|
int sethostname(char *name, int namelen);
|
||||||
|
|
||||||
|
int chroot(const char *path);
|
||||||
|
int fsync(int fd);
|
||||||
|
int getpagesize(void);
|
||||||
|
int symlink(const char *target, const char *linkpath);
|
||||||
|
int vhangup(void);
|
||||||
|
int mknod(const char *, mode_t, dev_t);
|
||||||
|
int reboot(int howto);
|
||||||
|
int ttyslot(void);
|
||||||
|
|
||||||
#ifndef _VA_LIST_
|
#ifndef _VA_LIST_
|
||||||
# ifdef __GNUC__
|
# ifdef __GNUC__
|
||||||
# define va_list __builtin_va_list /* For Gnu C */
|
# define va_list __builtin_va_list /* For Gnu C */
|
||||||
@@ -151,14 +167,14 @@ extern int opterr, optind, optopt;
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void err (int eval, const char *fmt, ...);
|
void err(int eval, const char *fmt, ...);
|
||||||
void errx (int eval, const char *fmt, ...);
|
void errx(int eval, const char *fmt, ...);
|
||||||
void warn (const char *fmt, ...);
|
void warn(const char *fmt, ...);
|
||||||
void warnx (const char *fmt, ...);
|
void warnx(const char *fmt, ...);
|
||||||
void verr (int eval, const char *fmt, va_list ap);
|
void verr(int eval, const char *fmt, va_list ap);
|
||||||
void verrx (int eval, const char *fmt, va_list ap);
|
void verrx(int eval, const char *fmt, va_list ap);
|
||||||
void vwarn (const char *fmt, va_list ap);
|
void vwarn(const char *fmt, va_list ap);
|
||||||
void vwarnx (const char *fmt, va_list ap);
|
void vwarnx(const char *fmt, va_list ap);
|
||||||
|
|
||||||
#ifndef _VA_LIST_
|
#ifndef _VA_LIST_
|
||||||
# undef va_list
|
# undef va_list
|
||||||
|
|||||||
@@ -25,3 +25,5 @@ struct utmp {
|
|||||||
char ut_host[UT_HOSTSIZE];
|
char ut_host[UT_HOSTSIZE];
|
||||||
long ut_time;
|
long ut_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void login(struct utmp *ut);
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ struct vseg { /* structure of a segment in memory */
|
|||||||
/* masks for s_flags */
|
/* masks for s_flags */
|
||||||
#define S_DIRTY 01 /* segment has been modified */
|
#define S_DIRTY 01 /* segment has been modified */
|
||||||
|
|
||||||
long nswaps; /* number of swaps */
|
extern long nswaps; /* number of swaps */
|
||||||
long nmapsegs; /* number of mapseg calls */
|
extern long nmapsegs; /* number of mapseg calls */
|
||||||
|
|
||||||
int vminit(), vmopen();
|
int vminit(), vmopen();
|
||||||
struct vseg *vmmapseg();
|
struct vseg *vmmapseg();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ TOPSRC = $(shell cd ../..; pwd)
|
|||||||
include $(TOPSRC)/target.mk
|
include $(TOPSRC)/target.mk
|
||||||
vpath %.c $(TOPSRC)/src/startup-mips
|
vpath %.c $(TOPSRC)/src/startup-mips
|
||||||
|
|
||||||
CFLAGS = -Os -B$(TOPSRC)/lib/ -Wa,-x $(DEFS)
|
CFLAGS = -Os -B$(TOPSRC)/lib/ -fno-integrated-as -Xassembler -x $(DEFS)
|
||||||
|
|
||||||
OBJS = ../crt0.o
|
OBJS = ../crt0.o
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ SUBDIR += chown chroot disktool fsck getty init \
|
|||||||
mkfs mknod mkpasswd mount pstat \
|
mkfs mknod mkpasswd mount pstat \
|
||||||
reboot shutdown umount update vipw virus
|
reboot shutdown umount update vipw virus
|
||||||
|
|
||||||
# TODO: ccom lex m4 yacc reloc sre pforth
|
# TODO: ccom lex m4 reloc sre pforth
|
||||||
|
|
||||||
# Shell scripts that need only be installed and are never removed.
|
# Shell scripts that need only be installed and are never removed.
|
||||||
#
|
#
|
||||||
@@ -73,7 +73,8 @@ FRC:
|
|||||||
|
|
||||||
# $(STD) $(SETUID) $(KMEM) $(OPERATOR) $(TTY) strip
|
# $(STD) $(SETUID) $(KMEM) $(OPERATOR) $(TTY) strip
|
||||||
%: %.c
|
%: %.c
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@.elf $< $(LIBS)
|
$(CC) $(CFLAGS) -c $<
|
||||||
|
$(LD) $(LDFLAGS) -o $@.elf $@.o $(LIBS)
|
||||||
$(OBJDUMP) -S $@.elf > $@.dis
|
$(OBJDUMP) -S $@.elf > $@.dis
|
||||||
$(SIZE) $@.elf
|
$(SIZE) $@.elf
|
||||||
$(ELF2AOUT) $@.elf $@ && /bin/rm $@.elf
|
$(ELF2AOUT) $@.elf $@ && /bin/rm $@.elf
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ CFLAGS += -DNUM_SYMS_CACHE=50 -Wall -Werror
|
|||||||
all: adb
|
all: adb
|
||||||
|
|
||||||
adb: $(OBJS)
|
adb: $(OBJS)
|
||||||
${CC} ${LDFLAGS} -o adb.elf $(OBJS) ${LIBS}
|
${LD} ${LDFLAGS} -o adb.elf $(OBJS) ${LIBS}
|
||||||
${OBJDUMP} -S adb.elf > adb.dis
|
${OBJDUMP} -S adb.elf > adb.dis
|
||||||
${SIZE} adb.elf
|
${SIZE} adb.elf
|
||||||
${ELF2AOUT} adb.elf $@ && rm adb.elf
|
${ELF2AOUT} adb.elf $@ && rm adb.elf
|
||||||
|
|||||||
@@ -152,68 +152,68 @@ typedef struct reglist REGLIST;
|
|||||||
#define leng(a) ((long)((unsigned)(a)))
|
#define leng(a) ((long)((unsigned)(a)))
|
||||||
#define shorten(a) ((long)a)
|
#define shorten(a) ((long)a)
|
||||||
|
|
||||||
struct sgttyb adbtty, usrtty;
|
extern struct sgttyb adbtty, usrtty;
|
||||||
jmp_buf erradb;
|
extern jmp_buf erradb;
|
||||||
sig_t sigint, sigqit;
|
extern sig_t sigint, sigqit;
|
||||||
|
|
||||||
MAP txtmap;
|
extern MAP txtmap;
|
||||||
MAP datmap;
|
extern MAP datmap;
|
||||||
|
|
||||||
BKPTR bkpthead; /* breakpoints */
|
extern BKPTR bkpthead; /* breakpoints */
|
||||||
|
|
||||||
struct SYMbol *symbol;
|
extern struct SYMbol *symbol;
|
||||||
|
|
||||||
extern u_int *uframe;
|
extern u_int *uframe;
|
||||||
const char *errflg;
|
extern const char *errflg;
|
||||||
char *lp;
|
extern char *lp;
|
||||||
char *myname; /* program name */
|
extern char *myname; /* program name */
|
||||||
char *printptr;
|
extern char *printptr;
|
||||||
extern char *Ipath;
|
extern char *Ipath;
|
||||||
extern char *symfil;
|
extern char *symfil;
|
||||||
extern char *corfil;
|
extern char *corfil;
|
||||||
char printbuf[MAXLIN];
|
extern char printbuf[MAXLIN];
|
||||||
int wtflag;
|
extern int wtflag;
|
||||||
int pid;
|
extern int pid;
|
||||||
int executing;
|
extern int executing;
|
||||||
int fcor;
|
extern int fcor;
|
||||||
int fsym;
|
extern int fsym;
|
||||||
int mkfault;
|
extern int mkfault;
|
||||||
int dotinc;
|
extern int dotinc;
|
||||||
int adrflg;
|
extern int adrflg;
|
||||||
int cntflg;
|
extern int cntflg;
|
||||||
int lastframe;
|
extern int lastframe;
|
||||||
int kernel;
|
extern int kernel;
|
||||||
int callpc;
|
extern int callpc;
|
||||||
int octal;
|
extern int octal;
|
||||||
int localok;
|
extern int localok;
|
||||||
int maxoff;
|
extern int maxoff;
|
||||||
int maxpos;
|
extern int maxpos;
|
||||||
int eof;
|
extern int eof;
|
||||||
int infile;
|
extern int infile;
|
||||||
int argcount;
|
extern int argcount;
|
||||||
int magic;
|
extern int magic;
|
||||||
int signo;
|
extern int signo;
|
||||||
extern int lastc;
|
extern int lastc;
|
||||||
extern int lastcom;
|
extern int lastcom;
|
||||||
extern int outfile;
|
extern int outfile;
|
||||||
long dot;
|
extern long dot;
|
||||||
long ditto;
|
extern long ditto;
|
||||||
long expv;
|
extern long expv;
|
||||||
long adrval;
|
extern long adrval;
|
||||||
long cntval;
|
extern long cntval;
|
||||||
long localval;
|
extern long localval;
|
||||||
long maxfile;
|
extern long maxfile;
|
||||||
long txtsiz;
|
extern long txtsiz;
|
||||||
long datsiz;
|
extern long datsiz;
|
||||||
long datbas;
|
extern long datbas;
|
||||||
long stksiz;
|
extern long stksiz;
|
||||||
long entrypt;
|
extern long entrypt;
|
||||||
long loopcnt;
|
extern long loopcnt;
|
||||||
|
|
||||||
long var[36];
|
extern long var[36];
|
||||||
u_int corhdr [USIZE/sizeof(u_int)];
|
extern u_int corhdr [USIZE/sizeof(u_int)];
|
||||||
|
|
||||||
off_t symoff;
|
extern off_t symoff;
|
||||||
|
|
||||||
extern const REGLIST reglist [];
|
extern const REGLIST reglist [];
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,55 @@ char *Ipath = "/share/adb";
|
|||||||
|
|
||||||
static int exitflg;
|
static int exitflg;
|
||||||
|
|
||||||
|
struct sgttyb adbtty, usrtty;
|
||||||
|
jmp_buf erradb;
|
||||||
|
sig_t sigint, sigqit;
|
||||||
|
MAP txtmap;
|
||||||
|
MAP datmap;
|
||||||
|
BKPTR bkpthead; /* breakpoints */
|
||||||
|
struct SYMbol *symbol;
|
||||||
|
const char *errflg;
|
||||||
|
char *lp;
|
||||||
|
char *myname; /* program name */
|
||||||
|
char printbuf[MAXLIN];
|
||||||
|
int wtflag;
|
||||||
|
int pid;
|
||||||
|
int executing;
|
||||||
|
int fcor;
|
||||||
|
int fsym;
|
||||||
|
int mkfault;
|
||||||
|
int dotinc;
|
||||||
|
int adrflg;
|
||||||
|
int cntflg;
|
||||||
|
int lastframe;
|
||||||
|
int kernel;
|
||||||
|
int callpc;
|
||||||
|
int octal;
|
||||||
|
int localok;
|
||||||
|
int maxoff;
|
||||||
|
int maxpos;
|
||||||
|
int eof;
|
||||||
|
int infile;
|
||||||
|
int argcount;
|
||||||
|
int magic;
|
||||||
|
int signo;
|
||||||
|
long dot;
|
||||||
|
long ditto;
|
||||||
|
long expv;
|
||||||
|
long adrval;
|
||||||
|
long cntval;
|
||||||
|
long localval;
|
||||||
|
long maxfile;
|
||||||
|
long txtsiz;
|
||||||
|
long datsiz;
|
||||||
|
long datbas;
|
||||||
|
long stksiz;
|
||||||
|
long entrypt;
|
||||||
|
long loopcnt;
|
||||||
|
long var[36];
|
||||||
|
u_int corhdr [USIZE/sizeof(u_int)];
|
||||||
|
off_t symoff;
|
||||||
|
|
||||||
long
|
long
|
||||||
roundn(a, b)
|
roundn(a, b)
|
||||||
long a, b;
|
long a, b;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ SRCS = adc-demo.c
|
|||||||
all: adc-demo
|
all: adc-demo
|
||||||
|
|
||||||
adc-demo: ${OBJS}
|
adc-demo: ${OBJS}
|
||||||
${CC} ${LDFLAGS} -o adc-demo.elf ${OBJS} ${LIBS}
|
${LD} ${LDFLAGS} -o adc-demo.elf ${OBJS} ${LIBS}
|
||||||
${OBJDUMP} -S adc-demo.elf > adc-demo.dis
|
${OBJDUMP} -S adc-demo.elf > adc-demo.dis
|
||||||
${SIZE} adc-demo.elf
|
${SIZE} adc-demo.elf
|
||||||
${ELF2AOUT} adc-demo.elf $@
|
${ELF2AOUT} adc-demo.elf $@
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ AOUTOBJS = aout.o mips-dis.o
|
|||||||
all: aout
|
all: aout
|
||||||
|
|
||||||
aout: $(AOUTOBJS)
|
aout: $(AOUTOBJS)
|
||||||
${CC} ${LDFLAGS} -o aout.elf $(AOUTOBJS) ${LIBS}
|
${LD} ${LDFLAGS} -o aout.elf $(AOUTOBJS) ${LIBS}
|
||||||
${OBJDUMP} -S aout.elf > aout.dis
|
${OBJDUMP} -S aout.elf > aout.dis
|
||||||
${SIZE} aout.elf
|
${SIZE} aout.elf
|
||||||
${ELF2AOUT} aout.elf $@ && rm aout.elf
|
${ELF2AOUT} aout.elf $@ && rm aout.elf
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ MANSRC = ar.1 ar.5
|
|||||||
all: ar $(MAN)
|
all: ar $(MAN)
|
||||||
|
|
||||||
ar: ${OBJS}
|
ar: ${OBJS}
|
||||||
${CC} ${LDFLAGS} -o ar.elf ${OBJS} ${LIBS}
|
${LD} ${LDFLAGS} -o ar.elf ${OBJS} ${LIBS}
|
||||||
${OBJDUMP} -S ar.elf > ar.dis
|
${OBJDUMP} -S ar.elf > ar.dis
|
||||||
${SIZE} ar.elf
|
${SIZE} ar.elf
|
||||||
${ELF2AOUT} ar.elf $@ && rm ar.elf
|
${ELF2AOUT} ar.elf $@ && rm ar.elf
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ LDFLAGS +=
|
|||||||
all: as
|
all: as
|
||||||
|
|
||||||
as: as.o
|
as: as.o
|
||||||
${CC} ${LDFLAGS} -o as.elf as.o ${LIBS}
|
${LD} ${LDFLAGS} -o as.elf as.o ${LIBS}
|
||||||
${OBJDUMP} -S as.elf > as.dis
|
${OBJDUMP} -S as.elf > as.dis
|
||||||
${SIZE} as.elf
|
${SIZE} as.elf
|
||||||
${ELF2AOUT} as.elf $@ && rm as.elf
|
${ELF2AOUT} as.elf $@ && rm as.elf
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ SOURCE = awk.def.h awk.g.y awk.lx.l b.c lib.c main.c parse.c \
|
|||||||
proc.c freeze.c run.c tran.c
|
proc.c freeze.c run.c tran.c
|
||||||
|
|
||||||
awk: $(FILES) awk.g.o
|
awk: $(FILES) awk.g.o
|
||||||
${CC} ${LDFLAGS} -o awk.elf $(FILES) awk.g.o ${LIBS}
|
${LD} ${LDFLAGS} -o awk.elf $(FILES) awk.g.o ${LIBS}
|
||||||
${OBJDUMP} -S awk.elf > awk.dis
|
${OBJDUMP} -S awk.elf > awk.dis
|
||||||
${SIZE} awk.elf
|
${SIZE} awk.elf
|
||||||
${ELF2AOUT} awk.elf $@ && rm awk.elf
|
${ELF2AOUT} awk.elf $@ && rm awk.elf
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ typedef struct {
|
|||||||
cell *optr;
|
cell *optr;
|
||||||
} obj;
|
} obj;
|
||||||
|
|
||||||
#define BOTCH 1
|
#define BOTCH 0
|
||||||
struct nd {
|
struct nd {
|
||||||
char ntype;
|
char ntype;
|
||||||
char subtype;
|
char subtype;
|
||||||
@@ -127,9 +127,23 @@ extern int pairstack[], paircnt;
|
|||||||
#define istemp(n) (n.otype == OCELL && n.osub == CTEMP)
|
#define istemp(n) (n.otype == OCELL && n.osub == CTEMP)
|
||||||
#define isfld(n) (!donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval==EMPTY)
|
#define isfld(n) (!donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval==EMPTY)
|
||||||
#define isrec(n) (donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval!=EMPTY)
|
#define isrec(n) (donefld && n.osub==CFLD && n.otype==OCELL && n.optr->nval!=EMPTY)
|
||||||
obj nullproc();
|
obj nullproc(void);
|
||||||
obj relop();
|
obj relop(node **a, int n);
|
||||||
|
|
||||||
#define MAXSYM 50
|
#define MAXSYM 50
|
||||||
#define HAT 0177 /* matches ^ in regular expr */
|
#define HAT 0177 /* matches ^ in regular expr */
|
||||||
/* watch out for mach dep */
|
/* watch out for mach dep */
|
||||||
|
struct fa;
|
||||||
|
void yyerror(char *s);
|
||||||
|
void error(int f, char *s, ...);
|
||||||
|
void syminit(void);
|
||||||
|
int freeze(char *s);
|
||||||
|
int thaw(char *s);
|
||||||
|
void run(void);
|
||||||
|
void recbld(void);
|
||||||
|
int isnumber(char *s);
|
||||||
|
int getrec(void);
|
||||||
|
int member(char c, char *s);
|
||||||
|
void fldbld(void);
|
||||||
|
void freesymtab(cell *ap);
|
||||||
|
int match(struct fa *pfa, char *p);
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
/* awk.g.y 4.1 82/05/07 */
|
/* awk.g.y 4.1 82/05/07 */
|
||||||
|
%code requires {
|
||||||
|
#define YYSTYPE node *
|
||||||
|
#define YYSTYPE_IS_DECLARED 1
|
||||||
|
}
|
||||||
|
|
||||||
%token FIRSTTOKEN /*must be first*/
|
%token FIRSTTOKEN /*must be first*/
|
||||||
%token FINAL FATAL
|
%token FINAL FATAL
|
||||||
@@ -37,6 +41,22 @@
|
|||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
# define PUTS(x)
|
# define PUTS(x)
|
||||||
#endif
|
#endif
|
||||||
|
int yylex(void);
|
||||||
|
node *valtonode(cell *a, int b);
|
||||||
|
node *stat1(int a, node *b);
|
||||||
|
node *stat2(int a, node *b, node *c);
|
||||||
|
node *stat3(int a, node *b, node *c, node *d);
|
||||||
|
node *stat4(int a, node *b, node *c, node *d, node *e);
|
||||||
|
node *op1(int a, node *b);
|
||||||
|
node *op2(int a, node *b, node *c);
|
||||||
|
node *op3(int a, node *b, node *c, node *d);
|
||||||
|
node *genprint(void);
|
||||||
|
node *pa2stat(node *a, node *b, node *c);
|
||||||
|
node *linkum(node *a, node *b);
|
||||||
|
struct fa *makedfa(node *p);
|
||||||
|
char *cclenter(char *p);
|
||||||
|
node *exptostat(node *a);
|
||||||
|
void startreg(void);
|
||||||
%}
|
%}
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@@ -48,13 +68,13 @@ program:
|
|||||||
begin:
|
begin:
|
||||||
XBEGIN '{' stat_list '}' { PUTS("XBEGIN list"); $$ = $3; }
|
XBEGIN '{' stat_list '}' { PUTS("XBEGIN list"); $$ = $3; }
|
||||||
| begin NL
|
| begin NL
|
||||||
| { PUTS("empty XBEGIN"); $$ = (hack)nullstat; }
|
| { PUTS("empty XBEGIN"); $$ = nullstat; }
|
||||||
;
|
;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
XEND '{' stat_list '}' { PUTS("XEND list"); $$ = $3; }
|
XEND '{' stat_list '}' { PUTS("XEND list"); $$ = $3; }
|
||||||
| end NL
|
| end NL
|
||||||
| { PUTS("empty END"); $$ = (hack)nullstat; }
|
| { PUTS("empty END"); $$ = nullstat; }
|
||||||
;
|
;
|
||||||
|
|
||||||
compound_conditional:
|
compound_conditional:
|
||||||
@@ -83,7 +103,7 @@ else:
|
|||||||
;
|
;
|
||||||
|
|
||||||
field:
|
field:
|
||||||
FIELD { PUTS("field"); $$ = valtonode($1, CFLD); }
|
FIELD { PUTS("field"); $$ = valtonode((cell *) $1, CFLD); }
|
||||||
| INDIRECT term { PUTS("ind field"); $$ = op1(INDIRECT, $2); }
|
| INDIRECT term { PUTS("ind field"); $$ = op1(INDIRECT, $2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -92,14 +112,14 @@ if:
|
|||||||
;
|
;
|
||||||
|
|
||||||
lex_expr:
|
lex_expr:
|
||||||
expr MATCHOP regular_expr { PUTS("expr~re"); $$ = op2($2, $1, makedfa($3)); }
|
expr MATCHOP regular_expr { PUTS("expr~re"); $$ = op2((int) $2, $1, (node *) makedfa($3)); }
|
||||||
| '(' lex_expr ')' { PUTS("(lex_expr)"); $$ = $2; }
|
| '(' lex_expr ')' { PUTS("(lex_expr)"); $$ = $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
var:
|
var:
|
||||||
NUMBER {PUTS("number"); $$ = valtonode($1, CCON); }
|
NUMBER {PUTS("number"); $$ = valtonode((cell *) $1, CCON); }
|
||||||
| STRING { PUTS("string"); $$ = valtonode($1, CCON); }
|
| STRING { PUTS("string"); $$ = valtonode((cell *) $1, CCON); }
|
||||||
| VAR { PUTS("var"); $$ = valtonode($1, CVAR); }
|
| VAR { PUTS("var"); $$ = valtonode((cell *) $1, CVAR); }
|
||||||
| VAR '[' expr ']' { PUTS("array[]"); $$ = op2(ARRAY, $1, $3); }
|
| VAR '[' expr ']' { PUTS("array[]"); $$ = op2(ARRAY, $1, $3); }
|
||||||
| field
|
| field
|
||||||
;
|
;
|
||||||
@@ -113,7 +133,7 @@ term:
|
|||||||
$$ = op2(FNCN, $1, valtonode(lookup("$record", symtab, 0), CFLD));
|
$$ = op2(FNCN, $1, valtonode(lookup("$record", symtab, 0), CFLD));
|
||||||
}
|
}
|
||||||
| FNCN '(' expr ')' { PUTS("func(expr)"); $$ = op2(FNCN, $1, $3); }
|
| FNCN '(' expr ')' { PUTS("func(expr)"); $$ = op2(FNCN, $1, $3); }
|
||||||
| SPRINTF print_list { PUTS("sprintf"); $$ = op1($1, $2); }
|
| SPRINTF print_list { PUTS("sprintf"); $$ = op1((int) $1, $2); }
|
||||||
| SUBSTR '(' expr ',' expr ',' expr ')'
|
| SUBSTR '(' expr ',' expr ',' expr ')'
|
||||||
{ PUTS("substr(e,e,e)"); $$ = op3(SUBSTR, $3, $5, $7); }
|
{ PUTS("substr(e,e,e)"); $$ = op3(SUBSTR, $3, $5, $7); }
|
||||||
| SUBSTR '(' expr ',' expr ')'
|
| SUBSTR '(' expr ',' expr ')'
|
||||||
@@ -141,7 +161,7 @@ term:
|
|||||||
expr:
|
expr:
|
||||||
term { PUTS("term"); }
|
term { PUTS("term"); }
|
||||||
| expr term { PUTS("expr term"); $$ = op2(CAT, $1, $2); }
|
| expr term { PUTS("expr term"); $$ = op2(CAT, $1, $2); }
|
||||||
| var ASGNOP expr { PUTS("var=expr"); $$ = stat2($2, $1, $3); }
|
| var ASGNOP expr { PUTS("var=expr"); $$ = stat2((int) $2, $1, $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
optNL:
|
optNL:
|
||||||
@@ -160,13 +180,13 @@ pa_stat:
|
|||||||
|
|
||||||
pa_stats:
|
pa_stats:
|
||||||
pa_stats pa_stat st { PUTS("pa_stats pa_stat"); $$ = linkum($1, $2); }
|
pa_stats pa_stat st { PUTS("pa_stats pa_stat"); $$ = linkum($1, $2); }
|
||||||
| { PUTS("null pa_stat"); $$ = (hack)nullstat; }
|
| { PUTS("null pa_stat"); $$ = nullstat; }
|
||||||
| pa_stats pa_stat {PUTS("pa_stats pa_stat"); $$ = linkum($1, $2); }
|
| pa_stats pa_stat {PUTS("pa_stats pa_stat"); $$ = linkum($1, $2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
pattern:
|
pattern:
|
||||||
regular_expr { PUTS("regex");
|
regular_expr { PUTS("regex");
|
||||||
$$ = op2(MATCH, valtonode(lookup("$record", symtab, 0), CFLD), makedfa($1));
|
$$ = op2(MATCH, valtonode(lookup("$record", symtab, 0), CFLD), (node *) makedfa($1));
|
||||||
}
|
}
|
||||||
| rel_expr { PUTS("relexpr"); }
|
| rel_expr { PUTS("relexpr"); }
|
||||||
| lex_expr { PUTS("lexexpr"); }
|
| lex_expr { PUTS("lexexpr"); }
|
||||||
@@ -199,10 +219,10 @@ regular_expr:
|
|||||||
r:
|
r:
|
||||||
CHAR { PUTS("regex CHAR"); $$ = op2(CHAR, (node *) 0, $1); }
|
CHAR { PUTS("regex CHAR"); $$ = op2(CHAR, (node *) 0, $1); }
|
||||||
| DOT { PUTS("regex DOT"); $$ = op2(DOT, (node *) 0, (node *) 0); }
|
| DOT { PUTS("regex DOT"); $$ = op2(DOT, (node *) 0, (node *) 0); }
|
||||||
| CCL { PUTS("regex CCL"); $$ = op2(CCL, (node *) 0, cclenter($1)); }
|
| CCL { PUTS("regex CCL"); $$ = op2(CCL, (node *) 0, (node *) cclenter((char*)$1)); }
|
||||||
| NCCL { PUTS("regex NCCL"); $$ = op2(NCCL, (node *) 0, cclenter($1)); }
|
| NCCL { PUTS("regex NCCL"); $$ = op2(NCCL, (node *) 0, (node *) cclenter((char*)$1)); }
|
||||||
| '^' { PUTS("regex ^"); $$ = op2(CHAR, (node *) 0, HAT); }
|
| '^' { PUTS("regex ^"); $$ = op2(CHAR, (node *) 0, (node *) HAT); }
|
||||||
| '$' { PUTS("regex $"); $$ = op2(CHAR, (node *) 0 ,(node *) 0); }
|
| '$' { PUTS("regex $"); $$ = op2(CHAR, (node *) 0, (node *) 0); }
|
||||||
| r OR r { PUTS("regex OR"); $$ = op2(OR, $1, $3); }
|
| r OR r { PUTS("regex OR"); $$ = op2(OR, $1, $3); }
|
||||||
| r r %prec CAT
|
| r r %prec CAT
|
||||||
{ PUTS("regex CAT"); $$ = op2(CAT, $1, $2); }
|
{ PUTS("regex CAT"); $$ = op2(CAT, $1, $2); }
|
||||||
@@ -214,7 +234,7 @@ r:
|
|||||||
|
|
||||||
rel_expr:
|
rel_expr:
|
||||||
expr RELOP expr
|
expr RELOP expr
|
||||||
{ PUTS("expr relop expr"); $$ = op2($2, $1, $3); }
|
{ PUTS("expr relop expr"); $$ = op2((int) $2, $1, $3); }
|
||||||
| '(' rel_expr ')'
|
| '(' rel_expr ')'
|
||||||
{ PUTS("(relexpr)"); $$ = $2; }
|
{ PUTS("(relexpr)"); $$ = $2; }
|
||||||
;
|
;
|
||||||
@@ -226,15 +246,15 @@ st:
|
|||||||
|
|
||||||
simple_stat:
|
simple_stat:
|
||||||
PRINT print_list redir expr
|
PRINT print_list redir expr
|
||||||
{ PUTS("print>stat"); $$ = stat3($1, $2, $3, $4); }
|
{ PUTS("print>stat"); $$ = stat3((int) $1, $2, $3, $4); }
|
||||||
| PRINT print_list
|
| PRINT print_list
|
||||||
{ PUTS("print list"); $$ = stat3($1, $2, nullstat, nullstat); }
|
{ PUTS("print list"); $$ = stat3((int) $1, $2, nullstat, nullstat); }
|
||||||
| PRINTF print_list redir expr
|
| PRINTF print_list redir expr
|
||||||
{ PUTS("printf>stat"); $$ = stat3($1, $2, $3, $4); }
|
{ PUTS("printf>stat"); $$ = stat3((int) $1, $2, $3, $4); }
|
||||||
| PRINTF print_list
|
| PRINTF print_list
|
||||||
{ PUTS("printf list"); $$ = stat3($1, $2, nullstat, nullstat); }
|
{ PUTS("printf list"); $$ = stat3((int) $1, $2, nullstat, nullstat); }
|
||||||
| expr { PUTS("expr"); $$ = exptostat($1); }
|
| expr { PUTS("expr"); $$ = exptostat($1); }
|
||||||
| { PUTS("null simple statement"); $$ = (hack)nullstat; }
|
| { PUTS("null simple statement"); $$ = nullstat; }
|
||||||
| error { yyclearin; yyerror("illegal statement"); }
|
| error { yyclearin; yyerror("illegal statement"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -255,7 +275,7 @@ statement:
|
|||||||
|
|
||||||
stat_list:
|
stat_list:
|
||||||
stat_list statement { PUTS("stat_list stat"); $$ = linkum($1, $2); }
|
stat_list statement { PUTS("stat_list stat"); $$ = linkum($1, $2); }
|
||||||
| { PUTS("null stat list"); $$ = (hack)nullstat; }
|
| { PUTS("null stat list"); $$ = nullstat; }
|
||||||
;
|
;
|
||||||
|
|
||||||
while:
|
while:
|
||||||
|
|||||||
@@ -3,17 +3,18 @@
|
|||||||
%Start A str chc sc reg comment
|
%Start A str chc sc reg comment
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "awk.h"
|
|
||||||
#include "awk.def.h"
|
#include "awk.def.h"
|
||||||
|
#include "awk.h"
|
||||||
#define YY_NO_INPUT /* defeat lex */
|
#define YY_NO_INPUT /* defeat lex */
|
||||||
extern int yylval;
|
|
||||||
extern int mustfld;
|
extern int mustfld;
|
||||||
|
|
||||||
int lineno = 1;
|
int lineno = 1;
|
||||||
#define CADD cbuf[clen++]=yytext[0]; if(clen>=CBUFLEN-1) {yyerror("string too long", cbuf); BEGIN A;}
|
#define CADD cbuf[clen++]=yytext[0]; if(clen>=CBUFLEN-1) {yyerror("string too long"); BEGIN A;}
|
||||||
#define CBUFLEN 150
|
#define CBUFLEN 150
|
||||||
char cbuf[CBUFLEN];
|
char cbuf[CBUFLEN];
|
||||||
int clen, cflag;
|
int clen, cflag;
|
||||||
|
|
||||||
|
cell *fieldadr(int n);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
A [a-zA-Z_]
|
A [a-zA-Z_]
|
||||||
@@ -42,36 +43,36 @@ WS [ \t]
|
|||||||
<A>PROGEND return(EOF);
|
<A>PROGEND return(EOF);
|
||||||
<A>"&&" return(AND);
|
<A>"&&" return(AND);
|
||||||
<A>"!" return(NOT);
|
<A>"!" return(NOT);
|
||||||
<A>"!=" { yylval = NE; return(RELOP); }
|
<A>"!=" { yylval = (node *) NE; return(RELOP); }
|
||||||
<A>"~" { yylval = MATCH; return(MATCHOP); }
|
<A>"~" { yylval = (node *) MATCH; return(MATCHOP); }
|
||||||
<A>"!~" { yylval = NOTMATCH; return(MATCHOP); }
|
<A>"!~" { yylval = (node *) NOTMATCH; return(MATCHOP); }
|
||||||
<A>"<" { yylval = LT; return(RELOP); }
|
<A>"<" { yylval = (node *) LT; return(RELOP); }
|
||||||
<A>"<=" { yylval = LE; return(RELOP); }
|
<A>"<=" { yylval = (node *) LE; return(RELOP); }
|
||||||
<A>"==" { yylval = EQ; return(RELOP); }
|
<A>"==" { yylval = (node *) EQ; return(RELOP); }
|
||||||
<A>">=" { yylval = GE; return(RELOP); }
|
<A>">=" { yylval = (node *) GE; return(RELOP); }
|
||||||
<A>">" { yylval = GT; return(RELOP); }
|
<A>">" { yylval = (node *) GT; return(RELOP); }
|
||||||
<A>">>" { yylval = APPEND; return(RELOP); }
|
<A>">>" { yylval = (node *) APPEND; return(RELOP); }
|
||||||
<A>"++" { yylval = INCR; return(INCR); }
|
<A>"++" { yylval = (node *) INCR; return(INCR); }
|
||||||
<A>"--" { yylval = DECR; return(DECR); }
|
<A>"--" { yylval = (node *) DECR; return(DECR); }
|
||||||
<A>"+=" { yylval = ADDEQ; return(ASGNOP); }
|
<A>"+=" { yylval = (node *) ADDEQ; return(ASGNOP); }
|
||||||
<A>"-=" { yylval = SUBEQ; return(ASGNOP); }
|
<A>"-=" { yylval = (node *) SUBEQ; return(ASGNOP); }
|
||||||
<A>"*=" { yylval = MULTEQ; return(ASGNOP); }
|
<A>"*=" { yylval = (node *) MULTEQ; return(ASGNOP); }
|
||||||
<A>"/=" { yylval = DIVEQ; return(ASGNOP); }
|
<A>"/=" { yylval = (node *) DIVEQ; return(ASGNOP); }
|
||||||
<A>"%=" { yylval = MODEQ; return(ASGNOP); }
|
<A>"%=" { yylval = (node *) MODEQ; return(ASGNOP); }
|
||||||
<A>"=" { yylval = ASSIGN; return(ASGNOP); }
|
<A>"=" { yylval = (node *) ASSIGN; return(ASGNOP); }
|
||||||
|
|
||||||
<A>"$"{D}+ { if (atoi(yytext+1)==0) {
|
<A>"$"{D}+ { if (atoi(yytext+1)==0) {
|
||||||
yylval = (hack)lookup("$record", symtab, 0);
|
yylval = (node *) lookup("$record", symtab, 0);
|
||||||
return(STRING);
|
return(STRING);
|
||||||
} else {
|
} else {
|
||||||
yylval = fieldadr(atoi(yytext+1));
|
yylval = (node *) fieldadr(atoi(yytext+1));
|
||||||
return(FIELD);
|
return(FIELD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<A>"$"{WS}* { return(INDIRECT); }
|
<A>"$"{WS}* { return(INDIRECT); }
|
||||||
<A>NF { mustfld=1; yylval = (hack)setsymtab(yytext, EMPTY, 0.0, NUM, symtab); return(VAR); }
|
<A>NF { mustfld=1; yylval = (node *) setsymtab(yytext, EMPTY, 0.0, NUM, symtab); return(VAR); }
|
||||||
<A>({D}+("."?){D}*|"."{D}+)((e|E)("+"|-)?{D}+)? {
|
<A>({D}+("."?){D}*|"."{D}+)((e|E)("+"|-)?{D}+)? {
|
||||||
yylval = (hack)setsymtab(yytext, EMPTY, atof(yytext), CON|NUM, symtab); return(NUMBER); }
|
yylval = (node *) setsymtab(yytext, EMPTY, atof(yytext), CON|NUM, symtab); return(NUMBER); }
|
||||||
<A>"}"{WS}*\n { BEGIN sc; lineno++; return(';'); }
|
<A>"}"{WS}*\n { BEGIN sc; lineno++; return(';'); }
|
||||||
<A>"}" { BEGIN sc; return(';'); }
|
<A>"}" { BEGIN sc; return(';'); }
|
||||||
<A>;\n { lineno++; return(';'); }
|
<A>;\n { lineno++; return(';'); }
|
||||||
@@ -84,27 +85,27 @@ WS [ \t]
|
|||||||
<A>exit return(EXIT);
|
<A>exit return(EXIT);
|
||||||
<A>break return(BREAK);
|
<A>break return(BREAK);
|
||||||
<A>continue return(CONTINUE);
|
<A>continue return(CONTINUE);
|
||||||
<A>print { yylval = PRINT; return(PRINT); }
|
<A>print { yylval = (node *) PRINT; return(PRINT); }
|
||||||
<A>printf { yylval = PRINTF; return(PRINTF); }
|
<A>printf { yylval = (node *) PRINTF; return(PRINTF); }
|
||||||
<A>sprintf { yylval = SPRINTF; return(SPRINTF); }
|
<A>sprintf { yylval = (node *) SPRINTF; return(SPRINTF); }
|
||||||
<A>split { yylval = SPLIT; return(SPLIT); }
|
<A>split { yylval = (node *) SPLIT; return(SPLIT); }
|
||||||
<A>substr return(SUBSTR);
|
<A>substr return(SUBSTR);
|
||||||
<A>index return(INDEX);
|
<A>index return(INDEX);
|
||||||
<A>in return(IN);
|
<A>in return(IN);
|
||||||
<A>getline return(GETLINE);
|
<A>getline return(GETLINE);
|
||||||
<A>length { yylval = FLENGTH; return(FNCN); }
|
<A>length { yylval = (node *) FLENGTH; return(FNCN); }
|
||||||
<A>log { yylval = FLOG; return(FNCN); }
|
<A>log { yylval = (node *) FLOG; return(FNCN); }
|
||||||
<A>int { yylval = FINT; return(FNCN); }
|
<A>int { yylval = (node *) FINT; return(FNCN); }
|
||||||
<A>exp { yylval = FEXP; return(FNCN); }
|
<A>exp { yylval = (node *) FEXP; return(FNCN); }
|
||||||
<A>sqrt { yylval = FSQRT; return(FNCN); }
|
<A>sqrt { yylval = (node *) FSQRT; return(FNCN); }
|
||||||
<A>{A}{B}* { yylval = (hack)setsymtab(yytext, tostring(""), 0.0, STR|NUM, symtab); return(VAR); }
|
<A>{A}{B}* { yylval = (node *) setsymtab(yytext, tostring(""), 0.0, STR|NUM, symtab); return(VAR); }
|
||||||
<A>\" { BEGIN str; clen=0; }
|
<A>\" { BEGIN str; clen=0; }
|
||||||
|
|
||||||
<A># { BEGIN comment; }
|
<A># { BEGIN comment; }
|
||||||
<comment>\n { BEGIN A; lineno++; return(NL); }
|
<comment>\n { BEGIN A; lineno++; return(NL); }
|
||||||
<comment>. ;
|
<comment>. ;
|
||||||
|
|
||||||
<A>. { yylval = yytext[0]; return(yytext[0]); }
|
<A>. { yylval = (node *) (int) yytext[0]; return(yytext[0]); }
|
||||||
|
|
||||||
<reg>"[" { BEGIN chc; clen=0; cflag=0; }
|
<reg>"[" { BEGIN chc; clen=0; cflag=0; }
|
||||||
<reg>"[^" { BEGIN chc; clen=0; cflag=1; }
|
<reg>"[^" { BEGIN chc; clen=0; cflag=1; }
|
||||||
@@ -118,19 +119,19 @@ WS [ \t]
|
|||||||
<reg>")" return(')');
|
<reg>")" return(')');
|
||||||
<reg>"^" return('^');
|
<reg>"^" return('^');
|
||||||
<reg>"$" return('$');
|
<reg>"$" return('$');
|
||||||
<reg>\\{D}{D}{D} { sscanf(yytext+1, "%o", &yylval); return(CHAR); }
|
<reg>\\{D}{D}{D} { sscanf(yytext+1, "%o", (int *) &yylval); return(CHAR); }
|
||||||
<reg>\\. { if (yytext[1]=='n') yylval = '\n';
|
<reg>\\. { if (yytext[1]=='n') yylval = (node *) '\n';
|
||||||
else if (yytext[1] == 't') yylval = '\t';
|
else if (yytext[1] == 't') yylval = (node *) '\t';
|
||||||
else yylval = yytext[1];
|
else yylval = (node *) (int) yytext[1];
|
||||||
return(CHAR);
|
return(CHAR);
|
||||||
}
|
}
|
||||||
<reg>"/" { BEGIN A; unput('/'); }
|
<reg>"/" { BEGIN A; unput('/'); }
|
||||||
<reg>\n { yyerror("newline in regular expression"); lineno++; BEGIN A; }
|
<reg>\n { yyerror("newline in regular expression"); lineno++; BEGIN A; }
|
||||||
<reg>. { yylval = yytext[0]; return(CHAR); }
|
<reg>. { yylval = (node *) (int) yytext[0]; return(CHAR); }
|
||||||
|
|
||||||
<str>\" { char *s; BEGIN A; cbuf[clen]=0; s = tostring(cbuf);
|
<str>\" { char *s; BEGIN A; cbuf[clen]=0; s = tostring(cbuf);
|
||||||
cbuf[clen] = ' '; cbuf[++clen] = 0;
|
cbuf[clen] = ' '; cbuf[++clen] = 0;
|
||||||
yylval = (hack)setsymtab(cbuf, s, 0.0, CON|STR, symtab); return(STRING); }
|
yylval = (node *) setsymtab(cbuf, s, 0.0, CON|STR, symtab); return(STRING); }
|
||||||
<str>\n { yyerror("newline in string"); lineno++; BEGIN A; }
|
<str>\n { yyerror("newline in string"); lineno++; BEGIN A; }
|
||||||
<str>"\\\"" { cbuf[clen++]='"'; }
|
<str>"\\\"" { cbuf[clen++]='"'; }
|
||||||
<str,chc>"\\"n { cbuf[clen++]='\n'; }
|
<str,chc>"\\"n { cbuf[clen++]='\n'; }
|
||||||
@@ -139,7 +140,7 @@ WS [ \t]
|
|||||||
<str>. { CADD; }
|
<str>. { CADD; }
|
||||||
|
|
||||||
<chc>"\\""]" { cbuf[clen++]=']'; }
|
<chc>"\\""]" { cbuf[clen++]=']'; }
|
||||||
<chc>"]" { BEGIN reg; cbuf[clen]=0; yylval = (hack)tostring(cbuf);
|
<chc>"]" { BEGIN reg; cbuf[clen]=0; yylval = (node *) tostring(cbuf);
|
||||||
if (cflag==0) { return(CCL); }
|
if (cflag==0) { return(CCL); }
|
||||||
else { return(NCCL); } }
|
else { return(NCCL); } }
|
||||||
<chc>\n { yyerror("newline in character class"); lineno++; BEGIN A; }
|
<chc>\n { yyerror("newline in character class"); lineno++; BEGIN A; }
|
||||||
@@ -147,9 +148,10 @@ WS [ \t]
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
int
|
||||||
input()
|
input()
|
||||||
{
|
{
|
||||||
register c;
|
int c;
|
||||||
extern char *lexprog;
|
extern char *lexprog;
|
||||||
|
|
||||||
if (yyin == NULL)
|
if (yyin == NULL)
|
||||||
@@ -163,6 +165,7 @@ input()
|
|||||||
return(c);
|
return(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
startreg()
|
startreg()
|
||||||
{
|
{
|
||||||
BEGIN reg;
|
BEGIN reg;
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ node *point[MAXLIN];
|
|||||||
int setcnt;
|
int setcnt;
|
||||||
int line;
|
int line;
|
||||||
|
|
||||||
|
void follow(node *v);
|
||||||
|
int notin(int **array, int n, int *prev);
|
||||||
|
void cfoll(node *v);
|
||||||
|
void overflo(void);
|
||||||
|
void freetr(node *p);
|
||||||
|
void penter(node *p);
|
||||||
|
|
||||||
struct fa *makedfa(p) /* returns dfa for tree pointed to by p */
|
struct fa *makedfa(p) /* returns dfa for tree pointed to by p */
|
||||||
node *p;
|
node *p;
|
||||||
@@ -58,6 +64,7 @@ node *p;
|
|||||||
return(fap);
|
return(fap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
penter(p) /* set up parent pointers and leaf indices */
|
penter(p) /* set up parent pointers and leaf indices */
|
||||||
node *p;
|
node *p;
|
||||||
{
|
{
|
||||||
@@ -83,6 +90,7 @@ node *p;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
freetr(p) /* free parse tree and follow sets */
|
freetr(p) /* free parse tree and follow sets */
|
||||||
node *p;
|
node *p;
|
||||||
{
|
{
|
||||||
@@ -109,7 +117,7 @@ node *p;
|
|||||||
char *cclenter(p)
|
char *cclenter(p)
|
||||||
register char *p;
|
register char *p;
|
||||||
{
|
{
|
||||||
register i, c;
|
int i, c;
|
||||||
char *op;
|
char *op;
|
||||||
|
|
||||||
op = p;
|
op = p;
|
||||||
@@ -137,15 +145,17 @@ register char *p;
|
|||||||
return(tostring(chars));
|
return(tostring(chars));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
overflo()
|
overflo()
|
||||||
{
|
{
|
||||||
error(FATAL, "regular expression too long\n");
|
error(FATAL, "regular expression too long\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
cfoll(v) /* enter follow set of each leaf of vertex v into foll[leaf] */
|
cfoll(v) /* enter follow set of each leaf of vertex v into foll[leaf] */
|
||||||
register node *v;
|
register node *v;
|
||||||
{
|
{
|
||||||
register i;
|
int i;
|
||||||
int prev;
|
int prev;
|
||||||
int *add();
|
int *add();
|
||||||
|
|
||||||
@@ -174,10 +184,11 @@ register node *v;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
first(p) /* collects initially active leaves of p into setvec */
|
first(p) /* collects initially active leaves of p into setvec */
|
||||||
register node *p; /* returns 0 or 1 depending on whether p matches empty string */
|
register node *p; /* returns 0 or 1 depending on whether p matches empty string */
|
||||||
{
|
{
|
||||||
register b;
|
int b;
|
||||||
|
|
||||||
switch(type(p)) {
|
switch(type(p)) {
|
||||||
LEAF
|
LEAF
|
||||||
@@ -208,6 +219,7 @@ register node *p; /* returns 0 or 1 depending on whether p matches empty string
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
follow(v)
|
follow(v)
|
||||||
node *v; /* collects leaves that can follow v into setvec */
|
node *v; /* collects leaves that can follow v into setvec */
|
||||||
{
|
{
|
||||||
@@ -243,8 +255,8 @@ node *v; /* collects leaves that can follow v into setvec */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
member(c, s) /* is c in s? */
|
int
|
||||||
register char c, *s;
|
member(char c, char *s) /* is c in s? */
|
||||||
{
|
{
|
||||||
while (*s)
|
while (*s)
|
||||||
if (c == *s++)
|
if (c == *s++)
|
||||||
@@ -252,10 +264,11 @@ register char c, *s;
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
notin(array, n, prev) /* is setvec in array[0] thru array[n]? */
|
notin(array, n, prev) /* is setvec in array[0] thru array[n]? */
|
||||||
int **array;
|
int **array;
|
||||||
int *prev; {
|
int *prev; {
|
||||||
register i, j;
|
int i, j;
|
||||||
int *ptr;
|
int *ptr;
|
||||||
for (i=0; i<=n; i++) {
|
for (i=0; i<=n; i++) {
|
||||||
ptr = array[i];
|
ptr = array[i];
|
||||||
@@ -272,7 +285,7 @@ int *prev; {
|
|||||||
|
|
||||||
int *add(n) { /* remember setvec */
|
int *add(n) { /* remember setvec */
|
||||||
int *ptr, *p;
|
int *ptr, *p;
|
||||||
register i;
|
int i;
|
||||||
if ((p = ptr = (int *) malloc((n+1)*sizeof(int))) == NULL)
|
if ((p = ptr = (int *) malloc((n+1)*sizeof(int))) == NULL)
|
||||||
overflo();
|
overflo();
|
||||||
*ptr = n;
|
*ptr = n;
|
||||||
@@ -288,8 +301,8 @@ int *add(n) { /* remember setvec */
|
|||||||
|
|
||||||
struct fa *cgotofn()
|
struct fa *cgotofn()
|
||||||
{
|
{
|
||||||
register i, k;
|
int i, k;
|
||||||
register int *ptr;
|
int *ptr;
|
||||||
char c;
|
char c;
|
||||||
char *p;
|
char *p;
|
||||||
node *cp;
|
node *cp;
|
||||||
@@ -505,11 +518,12 @@ struct fa *cgotofn()
|
|||||||
return(where[0]);
|
return(where[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
match(pfa, p)
|
match(pfa, p)
|
||||||
register struct fa *pfa;
|
register struct fa *pfa;
|
||||||
register char *p;
|
register char *p;
|
||||||
{
|
{
|
||||||
register count;
|
int count;
|
||||||
char c;
|
char c;
|
||||||
if (p == 0) return(0);
|
if (p == 0) return(0);
|
||||||
if (pfa->cch == 1) { /* fast test for first character, if possible */
|
if (pfa->cch == 1) { /* fast test for first character, if possible */
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
#include "stdio.h"
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
int
|
||||||
freeze(s)
|
freeze(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
unsigned int *len;
|
size_t len;
|
||||||
|
|
||||||
len = (unsigned int *)sbrk(0);
|
len = (size_t) sbrk(0);
|
||||||
if((fd = creat(s, 0666)) < 0) {
|
if((fd = creat(s, 0666)) < 0) {
|
||||||
perror(s);
|
perror(s);
|
||||||
return(1);
|
return(1);
|
||||||
@@ -17,6 +20,7 @@ freeze(s)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
thaw(s)
|
thaw(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ cell fldtab[MAXFLD] = { /*room for fields */
|
|||||||
};
|
};
|
||||||
int maxfld = 0; /* last used field */
|
int maxfld = 0; /* last used field */
|
||||||
|
|
||||||
|
void setclvar(char *s);
|
||||||
|
|
||||||
void
|
void
|
||||||
error(int f, char *s, ...)
|
error(int f, char *s, ...)
|
||||||
{
|
{
|
||||||
@@ -46,12 +48,13 @@ error(int f, char *s, ...)
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
getrec()
|
getrec()
|
||||||
{
|
{
|
||||||
register char *rr;
|
register char *rr;
|
||||||
extern int svargc;
|
extern int svargc;
|
||||||
extern char **svargv;
|
extern char **svargv;
|
||||||
register c, sep;
|
int c, sep;
|
||||||
|
|
||||||
dprintf("**RS=%o, **FS=%o\n", **RS, **FS, NULL);
|
dprintf("**RS=%o, **FS=%o\n", **RS, **FS, NULL);
|
||||||
donefld = 0;
|
donefld = 0;
|
||||||
@@ -108,6 +111,7 @@ getrec()
|
|||||||
return(0); /* true end of file */
|
return(0); /* true end of file */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
setclvar(s) /* set var=value from s */
|
setclvar(s) /* set var=value from s */
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
@@ -122,6 +126,7 @@ char *s;
|
|||||||
dprintf("command line set %s to |%s|\n", s, p, NULL);
|
dprintf("command line set %s to |%s|\n", s, p, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
fldbld()
|
fldbld()
|
||||||
{
|
{
|
||||||
register char *r, *fr, sep;
|
register char *r, *fr, sep;
|
||||||
@@ -183,6 +188,7 @@ fldbld()
|
|||||||
printf("field %d: |%s|\n", i, fldtab[i].sval);
|
printf("field %d: |%s|\n", i, fldtab[i].sval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
recbld()
|
recbld()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -193,7 +199,7 @@ recbld()
|
|||||||
r = record;
|
r = record;
|
||||||
for (i = 1; i <= *NF; i++) {
|
for (i = 1; i <= *NF; i++) {
|
||||||
p = getsval(&fldtab[i]);
|
p = getsval(&fldtab[i]);
|
||||||
while (*r++ = *p++)
|
while ((*r++ = *p++))
|
||||||
;
|
;
|
||||||
*(r-1) = **OFS;
|
*(r-1) = **OFS;
|
||||||
}
|
}
|
||||||
@@ -215,6 +221,7 @@ cell *fieldadr(n)
|
|||||||
|
|
||||||
int errorflag = 0;
|
int errorflag = 0;
|
||||||
|
|
||||||
|
void
|
||||||
yyerror(s)
|
yyerror(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
@@ -222,6 +229,7 @@ yyerror(s)
|
|||||||
errorflag = 2;
|
errorflag = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
PUTS(s)
|
PUTS(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
@@ -230,10 +238,11 @@ PUTS(s)
|
|||||||
|
|
||||||
#define MAXEXPON 38 /* maximum exponenet for fp number */
|
#define MAXEXPON 38 /* maximum exponenet for fp number */
|
||||||
|
|
||||||
|
int
|
||||||
isnumber(s)
|
isnumber(s)
|
||||||
register char *s;
|
register char *s;
|
||||||
{
|
{
|
||||||
register d1, d2;
|
int d1, d2;
|
||||||
int point;
|
int point;
|
||||||
char *es;
|
char *es;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include "awk.def.h"
|
#include "awk.def.h"
|
||||||
#include "awk.h"
|
#include "awk.h"
|
||||||
|
|
||||||
@@ -13,12 +14,12 @@ int svargc;
|
|||||||
char **svargv, **xargv;
|
char **svargv, **xargv;
|
||||||
extern FILE *yyin; /* lex input file */
|
extern FILE *yyin; /* lex input file */
|
||||||
char *lexprog; /* points to program argument if it exists */
|
char *lexprog; /* points to program argument if it exists */
|
||||||
extern errorflag; /* non-zero if any syntax errors; set by yyerror */
|
|
||||||
|
|
||||||
int filefd, symnum, ansfd;
|
int filefd, symnum, ansfd;
|
||||||
char *filelist;
|
char *filelist;
|
||||||
extern int maxsym, errno;
|
extern int maxsym;
|
||||||
|
|
||||||
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
@@ -29,9 +30,9 @@ main(argc, argv)
|
|||||||
while (argc > 1) {
|
while (argc > 1) {
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
/* this nonsense is because gcos argument handling */
|
/* this nonsense is because gcos argument handling
|
||||||
/* folds -F into -f. accordingly, one checks the next
|
* folds -F into -f. accordingly, one checks the next
|
||||||
/* character after f to see if it's -f file or -Fx.
|
* character after f to see if it's -f file or -Fx.
|
||||||
*/
|
*/
|
||||||
if (argv[0][0] == '-' && TOLOWER(argv[0][1]) == 'f' && argv[0][2] == '\0') {
|
if (argv[0][0] == '-' && TOLOWER(argv[0][1]) == 'f' && argv[0][2] == '\0') {
|
||||||
yyin = fopen(argv[1], "r");
|
yyin = fopen(argv[1], "r");
|
||||||
@@ -92,6 +93,7 @@ main(argc, argv)
|
|||||||
exit(errorflag);
|
exit(errorflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
yywrap()
|
yywrap()
|
||||||
{
|
{
|
||||||
return(1);
|
return(1);
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ node *stat4(a,b,c,d,e) node *b, *c, *d, *e;
|
|||||||
node *valtonode(a, b) cell *a;
|
node *valtonode(a, b) cell *a;
|
||||||
{
|
{
|
||||||
register node *x;
|
register node *x;
|
||||||
x = node0(a);
|
x = node0((int) a);
|
||||||
x->ntype = NVALUE;
|
x->ntype = NVALUE;
|
||||||
x->subtype = b;
|
x->subtype = b;
|
||||||
return(x);
|
return(x);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "awk.def.h"
|
||||||
#include "awk.h"
|
#include "awk.h"
|
||||||
|
|
||||||
struct tok
|
struct tok
|
||||||
@@ -29,7 +30,7 @@ struct xx
|
|||||||
{ INDIRECT, "indirect", "$("},
|
{ INDIRECT, "indirect", "$("},
|
||||||
{ SUBSTR, "substr", "substr"},
|
{ SUBSTR, "substr", "substr"},
|
||||||
{ INDEX, "sindex", "sindex"},
|
{ INDEX, "sindex", "sindex"},
|
||||||
{ SPRINTF, "asprintf", "sprintf "},
|
{ SPRINTF, "awksprintf", "sprintf "},
|
||||||
{ ADD, "arith", " + "},
|
{ ADD, "arith", " + "},
|
||||||
{ MINUS, "arith", " - "},
|
{ MINUS, "arith", " - "},
|
||||||
{ MULT, "arith", " * "},
|
{ MULT, "arith", " * "},
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ static cell nullval = { EMPTY, EMPTY, 0.0, NUM, 0 };
|
|||||||
obj true = { OBOOL, BTRUE, 0 };
|
obj true = { OBOOL, BTRUE, 0 };
|
||||||
obj false = { OBOOL, BFALSE, 0 };
|
obj false = { OBOOL, BFALSE, 0 };
|
||||||
|
|
||||||
|
void redirprint(char *s, int a, node *b);
|
||||||
|
void tempfree(obj a);
|
||||||
|
|
||||||
|
void
|
||||||
run()
|
run()
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
@@ -40,7 +44,7 @@ run()
|
|||||||
/* Wait for children to complete if output to a pipe. */
|
/* Wait for children to complete if output to a pipe. */
|
||||||
for (i=0; i<FILENUM; i++)
|
for (i=0; i<FILENUM; i++)
|
||||||
if (files[i].fp && files[i].type == '|')
|
if (files[i].fp && files[i].type == '|')
|
||||||
pclose(files[i].fp);
|
fclose(files[i].fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj execute(u) node *u;
|
obj execute(u) node *u;
|
||||||
@@ -152,7 +156,7 @@ obj matchop(a,n) node **a;
|
|||||||
if (isstr(x)) s = x.optr->sval;
|
if (isstr(x)) s = x.optr->sval;
|
||||||
else s = getsval(x.optr);
|
else s = getsval(x.optr);
|
||||||
tempfree(x);
|
tempfree(x);
|
||||||
i = match(a[1], s);
|
i = match((struct fa*) a[1], s);
|
||||||
if (n==MATCH && i==1 || n==NOTMATCH && i==0)
|
if (n==MATCH && i==1 || n==NOTMATCH && i==0)
|
||||||
return(true);
|
return(true);
|
||||||
else
|
else
|
||||||
@@ -224,6 +228,7 @@ obj relop(a,n) node **a;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
tempfree(a) obj a;
|
tempfree(a) obj a;
|
||||||
{
|
{
|
||||||
if (!istemp(a)) return;
|
if (!istemp(a)) return;
|
||||||
@@ -397,7 +402,7 @@ char *format(s,a) char *s; node *a;
|
|||||||
return(buf);
|
return(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj asprintf(a,n) node **a;
|
obj awksprintf(a,n) node **a;
|
||||||
{
|
{
|
||||||
obj x;
|
obj x;
|
||||||
node *y;
|
node *y;
|
||||||
@@ -592,7 +597,7 @@ obj aprintf(a,n) node **a;
|
|||||||
{
|
{
|
||||||
obj x;
|
obj x;
|
||||||
|
|
||||||
x = asprintf(a,n);
|
x = awksprintf(a,n);
|
||||||
if (a[1]==NULL) {
|
if (a[1]==NULL) {
|
||||||
printf("%s", x.optr->sval);
|
printf("%s", x.optr->sval);
|
||||||
tempfree(x);
|
tempfree(x);
|
||||||
@@ -840,7 +845,11 @@ obj print(a,n) node **a;
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj nullproc() {}
|
obj nullproc()
|
||||||
|
{
|
||||||
|
static const obj zero;
|
||||||
|
return zero;
|
||||||
|
}
|
||||||
|
|
||||||
obj nodetoobj(a) node *a;
|
obj nodetoobj(a) node *a;
|
||||||
{
|
{
|
||||||
@@ -853,6 +862,7 @@ obj nodetoobj(a) node *a;
|
|||||||
return(x);
|
return(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
redirprint(s, a, b) char *s; node *b;
|
redirprint(s, a, b) char *s; node *b;
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
e y.tab.h
|
e y.tab.h
|
||||||
1,$g!/#define /d
|
1,$g!/#define /d
|
||||||
|
1,$g/YYSTYPE/d
|
||||||
1,$s/# *define *//
|
1,$s/# *define *//
|
||||||
1,$s/^/{"/
|
1,$s/^/{"/
|
||||||
1,$s/ /", /
|
1,$s/ /", /
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ cell *recloc; /* location of record */
|
|||||||
cell *nrloc; /* NR */
|
cell *nrloc; /* NR */
|
||||||
cell *nfloc; /* NF */
|
cell *nfloc; /* NF */
|
||||||
|
|
||||||
|
void checkval(cell *vp);
|
||||||
|
int hash(char *s);
|
||||||
|
|
||||||
|
void
|
||||||
syminit()
|
syminit()
|
||||||
{
|
{
|
||||||
setsymtab("0", tostring("0"), 0.0, NUM|STR|CON|FLD, symtab);
|
setsymtab("0", tostring("0"), 0.0, NUM|STR|CON|FLD, symtab);
|
||||||
@@ -51,6 +55,7 @@ cell **makesymtab()
|
|||||||
return(cp);
|
return(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
freesymtab(ap) /* free symbol table */
|
freesymtab(ap) /* free symbol table */
|
||||||
cell *ap;
|
cell *ap;
|
||||||
{
|
{
|
||||||
@@ -76,7 +81,7 @@ awkfloat f;
|
|||||||
unsigned t;
|
unsigned t;
|
||||||
cell **tab;
|
cell **tab;
|
||||||
{
|
{
|
||||||
register h;
|
int h;
|
||||||
register cell *p;
|
register cell *p;
|
||||||
cell *lookup();
|
cell *lookup();
|
||||||
|
|
||||||
@@ -101,13 +106,14 @@ cell **tab;
|
|||||||
return(p);
|
return(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
hash(s) /* form hash value for string s */
|
hash(s) /* form hash value for string s */
|
||||||
register unsigned char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
register int hashval;
|
register int hashval;
|
||||||
|
|
||||||
for (hashval = 0; *s != '\0'; )
|
for (hashval = 0; *s != '\0'; )
|
||||||
hashval += *s++;
|
hashval += (unsigned char) *s++;
|
||||||
return(hashval % MAXSYM);
|
return(hashval % MAXSYM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +212,7 @@ register cell *vp;
|
|||||||
return(vp->sval);
|
return(vp->sval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
checkval(vp)
|
checkval(vp)
|
||||||
register cell *vp;
|
register cell *vp;
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
main(argc, argv)
|
int main(argc, argv)
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
register char *p1, *p2, *p3;
|
register char *p1, *p2, *p3;
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ LIBS = -lcurses -ltermcap -lm -lc
|
|||||||
all: basic renumber
|
all: basic renumber
|
||||||
|
|
||||||
basic: ${OBJS}
|
basic: ${OBJS}
|
||||||
${CC} ${LDFLAGS} -o basic.elf ${OBJS} ${LIBS}
|
${LD} ${LDFLAGS} -o basic.elf ${OBJS} ${LIBS}
|
||||||
${OBJDUMP} -S basic.elf > basic.dis
|
${OBJDUMP} -S basic.elf > basic.dis
|
||||||
${SIZE} basic.elf
|
${SIZE} basic.elf
|
||||||
${ELF2AOUT} basic.elf $@ && rm basic.elf
|
${ELF2AOUT} basic.elf $@ && rm basic.elf
|
||||||
|
|
||||||
renumber: renumber.o
|
renumber: renumber.o
|
||||||
${CC} ${LDFLAGS} -o renumber.elf $< ${LIBS}
|
${LD} ${LDFLAGS} -o renumber.elf $< ${LIBS}
|
||||||
${OBJDUMP} -S renumber.elf > renumber.dis
|
${OBJDUMP} -S renumber.elf > renumber.dis
|
||||||
${SIZE} renumber.elf
|
${SIZE} renumber.elf
|
||||||
${ELF2AOUT} renumber.elf $@ && rm renumber.elf
|
${ELF2AOUT} renumber.elf $@ && rm renumber.elf
|
||||||
|
|||||||
111
src/cmd/bc.y
111
src/cmd/bc.y
@@ -1,5 +1,8 @@
|
|||||||
%{
|
%{
|
||||||
int *getout();
|
int *getout(void);
|
||||||
|
int getch(void);
|
||||||
|
int cpeek(int c, int yes, int no);
|
||||||
|
void yyerror(char *s);
|
||||||
%}
|
%}
|
||||||
%right '='
|
%right '='
|
||||||
%left '+' '-'
|
%left '+' '-'
|
||||||
@@ -39,12 +42,12 @@ int *pre, *post;
|
|||||||
%%
|
%%
|
||||||
start :
|
start :
|
||||||
| start stat tail
|
| start stat tail
|
||||||
= output( $2 );
|
= output( (int*) $2 );
|
||||||
| start def dargs ')' '{' dlist slist '}'
|
| start def dargs ')' '{' dlist slist '}'
|
||||||
={ bundle( 6,pre, $7, post ,"0",numb[lev],"Q");
|
={ bundle(6, pre, $7, post, "0", numb[lev], "Q");
|
||||||
conout( $$, $2 );
|
conout( (int*) $$, (char*) $2 );
|
||||||
rcrs = crs;
|
rcrs = crs;
|
||||||
output( "" );
|
output( (int*) "" );
|
||||||
lev = bindx = 0;
|
lev = bindx = 0;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@@ -62,11 +65,11 @@ stat : e
|
|||||||
| LETTER '=' e
|
| LETTER '=' e
|
||||||
={ bundle(3, $3, "s", $1 ); }
|
={ bundle(3, $3, "s", $1 ); }
|
||||||
| LETTER '[' e ']' '=' e
|
| LETTER '[' e ']' '=' e
|
||||||
={ bundle(4, $6, $3, ":", geta($1)); }
|
={ bundle(4, $6, $3, ":", geta((char*) $1)); }
|
||||||
| LETTER EQOP e
|
| LETTER EQOP e
|
||||||
={ bundle(6, "l", $1, $3, $2, "s", $1 ); }
|
={ bundle(6, "l", $1, $3, $2, "s", $1 ); }
|
||||||
| LETTER '[' e ']' EQOP e
|
| LETTER '[' e ']' EQOP e
|
||||||
={ bundle(8,$3, ";", geta($1), $6, $5, $3, ":", geta($1));}
|
={ bundle(8,$3, ";", geta((char*) $1), $6, $5, $3, ":", geta((char*) $1));}
|
||||||
| _BREAK
|
| _BREAK
|
||||||
={ bundle(2, numb[lev-bstack[bindx-1]], "Q" ); }
|
={ bundle(2, numb[lev-bstack[bindx-1]], "Q" ); }
|
||||||
| _RETURN '(' e ')'
|
| _RETURN '(' e ')'
|
||||||
@@ -94,17 +97,17 @@ stat : e
|
|||||||
| error
|
| error
|
||||||
={ bundle(1,"c"); }
|
={ bundle(1,"c"); }
|
||||||
| _IF CRS BLEV '(' re ')' stat
|
| _IF CRS BLEV '(' re ')' stat
|
||||||
={ conout( $7, $2 );
|
={ conout( (int*) $7, (char*) $2 );
|
||||||
bundle(3, $5, $2, " " );
|
bundle(3, $5, $2, " " );
|
||||||
}
|
}
|
||||||
| _WHILE CRS '(' re ')' stat BLEV
|
| _WHILE CRS '(' re ')' stat BLEV
|
||||||
={ bundle(3, $6, $4, $2 );
|
={ bundle(3, $6, $4, $2 );
|
||||||
conout( $$, $2 );
|
conout( (int*) $$, (char*) $2 );
|
||||||
bundle(3, $4, $2, " " );
|
bundle(3, $4, $2, " " );
|
||||||
}
|
}
|
||||||
| fprefix CRS re ';' e ')' stat BLEV
|
| fprefix CRS re ';' e ')' stat BLEV
|
||||||
={ bundle(5, $7, $5, "s.", $3, $2 );
|
={ bundle(5, $7, $5, "s.", $3, $2 );
|
||||||
conout( $$, $2 );
|
conout( (int*) $$, (char*) $2 );
|
||||||
bundle(5, $1, "s.", $3, $2, " " );
|
bundle(5, $1, "s.", $3, $2, " " );
|
||||||
}
|
}
|
||||||
| '~' LETTER '=' e
|
| '~' LETTER '=' e
|
||||||
@@ -174,7 +177,7 @@ e : e '+' e
|
|||||||
| e '^' e
|
| e '^' e
|
||||||
= bundle(3, $1, $3, "^" );
|
= bundle(3, $1, $3, "^" );
|
||||||
| LETTER '[' e ']'
|
| LETTER '[' e ']'
|
||||||
={ bundle(3,$3, ";", geta($1)); }
|
={ bundle(3,$3, ";", geta((char*) $1)); }
|
||||||
| LETTER INCR
|
| LETTER INCR
|
||||||
= bundle(4, "l", $1, "d1+s", $1 );
|
= bundle(4, "l", $1, "d1+s", $1 );
|
||||||
| INCR LETTER
|
| INCR LETTER
|
||||||
@@ -184,13 +187,13 @@ e : e '+' e
|
|||||||
| LETTER DECR
|
| LETTER DECR
|
||||||
= bundle(4, "l", $1, "d1-s", $1 );
|
= bundle(4, "l", $1, "d1-s", $1 );
|
||||||
| LETTER '[' e ']' INCR
|
| LETTER '[' e ']' INCR
|
||||||
= bundle(7,$3,";",geta($1),"d1+",$3,":",geta($1));
|
= bundle(7,$3,";",geta((char*) $1),"d1+",$3,":",geta((char*) $1));
|
||||||
| INCR LETTER '[' e ']'
|
| INCR LETTER '[' e ']'
|
||||||
= bundle(7,$4,";",geta($2),"1+d",$4,":",geta($2));
|
= bundle(7,$4,";",geta((char*) $2),"1+d",$4,":",geta((char*) $2));
|
||||||
| LETTER '[' e ']' DECR
|
| LETTER '[' e ']' DECR
|
||||||
= bundle(7,$3,";",geta($1),"d1-",$3,":",geta($1));
|
= bundle(7,$3,";",geta((char*) $1),"d1-",$3,":",geta((char*) $1));
|
||||||
| DECR LETTER '[' e ']'
|
| DECR LETTER '[' e ']'
|
||||||
= bundle(7,$4,";",geta($2),"1-d",$4,":",geta($2));
|
= bundle(7,$4,";",geta((char*) $2),"1-d",$4,":",geta((char*) $2));
|
||||||
| SCALE INCR
|
| SCALE INCR
|
||||||
= bundle(1,"Kd1+k");
|
= bundle(1,"Kd1+k");
|
||||||
| INCR SCALE
|
| INCR SCALE
|
||||||
@@ -216,9 +219,9 @@ e : e '+' e
|
|||||||
| DECR OBASE
|
| DECR OBASE
|
||||||
= bundle(1,"O1-do");
|
= bundle(1,"O1-do");
|
||||||
| LETTER '(' cargs ')'
|
| LETTER '(' cargs ')'
|
||||||
= bundle(4, $3, "l", getf($1), "x" );
|
= bundle(4, $3, "l", getf((char*) $1), "x" );
|
||||||
| LETTER '(' ')'
|
| LETTER '(' ')'
|
||||||
= bundle(3, "l", getf($1), "x" );
|
= bundle(3, "l", getf((char*) $1), "x" );
|
||||||
| cons
|
| cons
|
||||||
={ bundle(2, " ", $1 ); }
|
={ bundle(2, " ", $1 ); }
|
||||||
| DOT cons
|
| DOT cons
|
||||||
@@ -236,9 +239,9 @@ e : e '+' e
|
|||||||
| LETTER EQOP e %prec '='
|
| LETTER EQOP e %prec '='
|
||||||
={ bundle(6, "l", $1, $3, $2, "ds", $1 ); }
|
={ bundle(6, "l", $1, $3, $2, "ds", $1 ); }
|
||||||
| LETTER '[' e ']' '=' e
|
| LETTER '[' e ']' '=' e
|
||||||
= { bundle(5,$6,"d",$3,":",geta($1)); }
|
= { bundle(5,$6,"d",$3,":",geta((char*) $1)); }
|
||||||
| LETTER '[' e ']' EQOP e
|
| LETTER '[' e ']' EQOP e
|
||||||
= { bundle(9,$3,";",geta($1),$6,$5,"d",$3,":",geta($1)); }
|
= { bundle(9,$3,";",geta((char*) $1),$6,$5,"d",$3,":",geta((char*) $1)); }
|
||||||
| LENGTH '(' e ')'
|
| LENGTH '(' e ')'
|
||||||
= bundle(2,$3,"Z");
|
= bundle(2,$3,"Z");
|
||||||
| SCALE '(' e ')'
|
| SCALE '(' e ')'
|
||||||
@@ -277,7 +280,7 @@ cargs : eora
|
|||||||
;
|
;
|
||||||
eora: e
|
eora: e
|
||||||
| LETTER '[' ']'
|
| LETTER '[' ']'
|
||||||
=bundle(2,"l",geta($1));
|
=bundle(2,"l",geta((char*) $1));
|
||||||
;
|
;
|
||||||
|
|
||||||
cons : constant
|
cons : constant
|
||||||
@@ -303,7 +306,7 @@ CRS :
|
|||||||
;
|
;
|
||||||
|
|
||||||
def : _DEFINE LETTER '('
|
def : _DEFINE LETTER '('
|
||||||
={ $$ = (int) getf($2);
|
={ $$ = (int) getf((char*) $2);
|
||||||
pre = (int*) "";
|
pre = (int*) "";
|
||||||
post = (int*) "";
|
post = (int*) "";
|
||||||
lev = 1;
|
lev = 1;
|
||||||
@@ -313,19 +316,19 @@ def : _DEFINE LETTER '('
|
|||||||
|
|
||||||
dargs :
|
dargs :
|
||||||
| lora
|
| lora
|
||||||
={ pp( $1 ); }
|
={ pp((char*) $1); }
|
||||||
| dargs ',' lora
|
| dargs ',' lora
|
||||||
={ pp( $3 ); }
|
={ pp((char*) $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
dlets : lora
|
dlets : lora
|
||||||
={ tp($1); }
|
={ tp((char*) $1); }
|
||||||
| dlets ',' lora
|
| dlets ',' lora
|
||||||
={ tp($3); }
|
={ tp((char*) $3); }
|
||||||
;
|
;
|
||||||
lora : LETTER
|
lora : LETTER
|
||||||
| LETTER '[' ']'
|
| LETTER '[' ']'
|
||||||
={ $$ = (int) geta($1); }
|
={ $$ = (int) geta((char*) $1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@@ -348,7 +351,9 @@ char *letr[26] = {
|
|||||||
"k","l","m","n","o","p","q","r","s","t",
|
"k","l","m","n","o","p","q","r","s","t",
|
||||||
"u","v","w","x","y","z" } ;
|
"u","v","w","x","y","z" } ;
|
||||||
char *dot = { "." };
|
char *dot = { "." };
|
||||||
yylex(){
|
|
||||||
|
int yylex()
|
||||||
|
{
|
||||||
int c, ch;
|
int c, ch;
|
||||||
restart:
|
restart:
|
||||||
c = getch();
|
c = getch();
|
||||||
@@ -445,7 +450,8 @@ restart:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cpeek( c, yes, no ){
|
int cpeek(int c, int yes, int no)
|
||||||
|
{
|
||||||
if( (peekc=getch()) != c ) return( no );
|
if( (peekc=getch()) != c ) return( no );
|
||||||
else {
|
else {
|
||||||
peekc = -1;
|
peekc = -1;
|
||||||
@@ -453,7 +459,8 @@ cpeek( c, yes, no ){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getch(){
|
int getch()
|
||||||
|
{
|
||||||
int ch;
|
int ch;
|
||||||
loop:
|
loop:
|
||||||
ch = (peekc < 0) ? getc(in) : peekc;
|
ch = (peekc < 0) ? getc(in) : peekc;
|
||||||
@@ -472,13 +479,18 @@ loop:
|
|||||||
goto loop;
|
goto loop;
|
||||||
}
|
}
|
||||||
yyerror("cannot open input file");
|
yyerror("cannot open input file");
|
||||||
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
# define b_sp_max 3000
|
# define b_sp_max 3000
|
||||||
|
|
||||||
int b_space [ b_sp_max ];
|
int b_space [ b_sp_max ];
|
||||||
int * b_sp_nxt = { b_space };
|
int * b_sp_nxt = { b_space };
|
||||||
|
|
||||||
int bdebug = 0;
|
int bdebug = 0;
|
||||||
bundle(a){
|
|
||||||
|
int bundle(int a, ...)
|
||||||
|
{
|
||||||
int i, *p, *q;
|
int i, *p, *q;
|
||||||
|
|
||||||
p = &a;
|
p = &a;
|
||||||
@@ -494,16 +506,18 @@ bundle(a){
|
|||||||
return( (int) q );
|
return( (int) q );
|
||||||
}
|
}
|
||||||
|
|
||||||
routput(p) int *p; {
|
void routput(int *p)
|
||||||
|
{
|
||||||
if( bdebug ) printf("routput(%p)\n", p );
|
if( bdebug ) printf("routput(%p)\n", p );
|
||||||
if( p >= &b_space[0] && p < &b_space[b_sp_max]){
|
if( p >= &b_space[0] && p < &b_space[b_sp_max]){
|
||||||
/* part of a bundle */
|
/* part of a bundle */
|
||||||
while( *p != 0 ) routput( *p++ );
|
while( *p != 0 ) routput( (int*) *p++ );
|
||||||
}
|
}
|
||||||
else printf( "%s", (char*) p ); /* character string */
|
else printf( "%s", (char*) p ); /* character string */
|
||||||
}
|
}
|
||||||
|
|
||||||
output( p ) int *p; {
|
void output(int *p)
|
||||||
|
{
|
||||||
routput( p );
|
routput( p );
|
||||||
b_sp_nxt = & b_space[0];
|
b_sp_nxt = & b_space[0];
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
@@ -512,7 +526,8 @@ output( p ) int *p; {
|
|||||||
crs = rcrs;
|
crs = rcrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
conout( p, s ) int *p; char *s; {
|
void conout(int *p, char *s)
|
||||||
|
{
|
||||||
printf("[");
|
printf("[");
|
||||||
routput( p );
|
routput( p );
|
||||||
printf("]s%s\n", s );
|
printf("]s%s\n", s );
|
||||||
@@ -520,7 +535,8 @@ conout( p, s ) int *p; char *s; {
|
|||||||
lev--;
|
lev--;
|
||||||
}
|
}
|
||||||
|
|
||||||
yyerror( s ) char *s; {
|
void yyerror(char *s)
|
||||||
|
{
|
||||||
if(ifile > sargc)ss="teletype";
|
if(ifile > sargc)ss="teletype";
|
||||||
printf("c[%s on line %d, %s]pc\n", s ,ln+1,ss);
|
printf("c[%s on line %d, %s]pc\n", s ,ln+1,ss);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@@ -531,7 +547,8 @@ yyerror( s ) char *s; {
|
|||||||
b_sp_nxt = &b_space[0];
|
b_sp_nxt = &b_space[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
pp( s ) char *s; {
|
void pp(char *s)
|
||||||
|
{
|
||||||
/* puts the relevant stuff on pre and post for the letter s */
|
/* puts the relevant stuff on pre and post for the letter s */
|
||||||
|
|
||||||
bundle(3, "S", s, pre );
|
bundle(3, "S", s, pre );
|
||||||
@@ -540,14 +557,17 @@ pp( s ) char *s; {
|
|||||||
post = (int*) yyval;
|
post = (int*) yyval;
|
||||||
}
|
}
|
||||||
|
|
||||||
tp( s ) char *s; { /* same as pp, but for temps */
|
/* same as pp, but for temps */
|
||||||
|
void tp(char *s)
|
||||||
|
{
|
||||||
bundle(3, "0S", s, pre );
|
bundle(3, "0S", s, pre );
|
||||||
pre = (int*) yyval;
|
pre = (int*) yyval;
|
||||||
bundle(4, post, "L", s, "s." );
|
bundle(4, post, "L", s, "s." );
|
||||||
post = (int*) yyval;
|
post = (int*) yyval;
|
||||||
}
|
}
|
||||||
|
|
||||||
yyinit(argc,argv) int argc; char *argv[];{
|
void yyinit(int argc, char *argv[])
|
||||||
|
{
|
||||||
signal( 2, SIG_IGN ); /* ignore all interrupts */
|
signal( 2, SIG_IGN ); /* ignore all interrupts */
|
||||||
sargv=argv;
|
sargv=argv;
|
||||||
sargc= -- argc;
|
sargc= -- argc;
|
||||||
@@ -560,24 +580,25 @@ yyinit(argc,argv) int argc; char *argv[];{
|
|||||||
ln = 0;
|
ln = 0;
|
||||||
ss = sargv[1];
|
ss = sargv[1];
|
||||||
}
|
}
|
||||||
int *getout(){
|
|
||||||
|
int *getout()
|
||||||
|
{
|
||||||
printf("q");
|
printf("q");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int *
|
int *getf(char *p)
|
||||||
getf(p) char *p;{
|
{
|
||||||
return (int*) &funtab[2 * (*p - 0141)];
|
return (int*) &funtab[2 * (*p - 0141)];
|
||||||
}
|
}
|
||||||
|
|
||||||
int *
|
int *geta(char *p)
|
||||||
geta(p) char *p;{
|
{
|
||||||
return (int*) &atab[2 * (*p - 0141)];
|
return (int*) &atab[2 * (*p - 0141)];
|
||||||
}
|
}
|
||||||
|
|
||||||
main(argc, argv)
|
int main(int argc, char **argv)
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
int p[2];
|
int p[2];
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ char *smon[]= {
|
|||||||
};
|
};
|
||||||
char string[432];
|
char string[432];
|
||||||
|
|
||||||
main(argc, argv)
|
static int number(char *str);
|
||||||
|
static void cal(int m, int y, char *p, int w);
|
||||||
|
static void pstr(char *str, int n);
|
||||||
|
static int jan1(int yr);
|
||||||
|
|
||||||
|
int main(argc, argv)
|
||||||
char *argv[];
|
char *argv[];
|
||||||
{
|
{
|
||||||
register y, i, j;
|
int y, i, j, m;
|
||||||
int m;
|
|
||||||
|
|
||||||
if(argc < 2) {
|
if(argc < 2) {
|
||||||
printf("usage: cal [month] year\n");
|
printf("usage: cal [month] year\n");
|
||||||
@@ -24,10 +28,9 @@ char *argv[];
|
|||||||
if(argc == 2)
|
if(argc == 2)
|
||||||
goto xlong;
|
goto xlong;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print out just month
|
* print out just month
|
||||||
*/
|
*/
|
||||||
|
|
||||||
m = number(argv[1]);
|
m = number(argv[1]);
|
||||||
if(m<1 || m>12)
|
if(m<1 || m>12)
|
||||||
goto badarg;
|
goto badarg;
|
||||||
@@ -41,10 +44,9 @@ char *argv[];
|
|||||||
pstr(string+i, 24);
|
pstr(string+i, 24);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print out complete year
|
* print out complete year
|
||||||
*/
|
*/
|
||||||
|
|
||||||
xlong:
|
xlong:
|
||||||
y = number(argv[1]);
|
y = number(argv[1]);
|
||||||
if(y<1 || y>9999)
|
if(y<1 || y>9999)
|
||||||
@@ -72,15 +74,15 @@ badarg:
|
|||||||
printf("Bad argument\n");
|
printf("Bad argument\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
number(str)
|
int number(str)
|
||||||
char *str;
|
char *str;
|
||||||
{
|
{
|
||||||
register n, c;
|
int n, c;
|
||||||
register char *s;
|
char *s;
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
s = str;
|
s = str;
|
||||||
while(c = *s++) {
|
while ((c = *s++)) {
|
||||||
if(c<'0' || c>'9')
|
if(c<'0' || c>'9')
|
||||||
return(0);
|
return(0);
|
||||||
n = n*10 + c-'0';
|
n = n*10 + c-'0';
|
||||||
@@ -88,11 +90,11 @@ char *str;
|
|||||||
return(n);
|
return(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
pstr(str, n)
|
void pstr(str, n)
|
||||||
char *str;
|
char *str;
|
||||||
{
|
{
|
||||||
register i;
|
int i;
|
||||||
register char *s;
|
char *s;
|
||||||
|
|
||||||
s = str;
|
s = str;
|
||||||
i = n;
|
i = n;
|
||||||
@@ -114,11 +116,11 @@ char mon[] = {
|
|||||||
30, 31, 30, 31,
|
30, 31, 30, 31,
|
||||||
};
|
};
|
||||||
|
|
||||||
cal(m, y, p, w)
|
void cal(m, y, p, w)
|
||||||
char *p;
|
char *p;
|
||||||
{
|
{
|
||||||
register d, i;
|
int d, i;
|
||||||
register char *s;
|
char *s;
|
||||||
|
|
||||||
s = p;
|
s = p;
|
||||||
d = jan1(y);
|
d = jan1(y);
|
||||||
@@ -173,36 +175,32 @@ char *p;
|
|||||||
* return day of the week
|
* return day of the week
|
||||||
* of jan 1 of given year
|
* of jan 1 of given year
|
||||||
*/
|
*/
|
||||||
|
int jan1(yr)
|
||||||
jan1(yr)
|
|
||||||
{
|
{
|
||||||
register y, d;
|
int y, d;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* normal gregorian calendar
|
* normal gregorian calendar
|
||||||
* one extra day per four years
|
* one extra day per four years
|
||||||
*/
|
*/
|
||||||
|
|
||||||
y = yr;
|
y = yr;
|
||||||
d = 4+y+(y+3)/4;
|
d = 4+y+(y+3)/4;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* julian calendar
|
* julian calendar
|
||||||
* regular gregorian
|
* regular gregorian
|
||||||
* less three days per 400
|
* less three days per 400
|
||||||
*/
|
*/
|
||||||
|
if (y > 1800) {
|
||||||
if(y > 1800) {
|
|
||||||
d -= (y-1701)/100;
|
d -= (y-1701)/100;
|
||||||
d += (y-1601)/400;
|
d += (y-1601)/400;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* great calendar changeover instant
|
* great calendar changeover instant
|
||||||
*/
|
*/
|
||||||
|
if (y > 1752)
|
||||||
if(y > 1752)
|
|
||||||
d += 3;
|
d += 3;
|
||||||
|
|
||||||
return(d%7);
|
return d % 7;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ MANSRC = calendar.1
|
|||||||
all: calendar $(MAN)
|
all: calendar $(MAN)
|
||||||
|
|
||||||
calendar: ${OBJS}
|
calendar: ${OBJS}
|
||||||
${CC} ${LDFLAGS} -o calendar.elf ${OBJS} ${LIBS}
|
${LD} ${LDFLAGS} -o calendar.elf ${OBJS} ${LIBS}
|
||||||
${OBJDUMP} -S calendar.elf > calendar.dis
|
${OBJDUMP} -S calendar.elf > calendar.dis
|
||||||
${SIZE} calendar.elf
|
${SIZE} calendar.elf
|
||||||
${ELF2AOUT} calendar.elf $@ && rm calendar.elf
|
${ELF2AOUT} calendar.elf $@ && rm calendar.elf
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ static char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94";
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <tzfile.h>
|
#include <tzfile.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
|
|
||||||
|
|||||||
@@ -9,20 +9,24 @@
|
|||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
/* #define OPTSIZE BUFSIZ /* define this only if not 4.2 BSD or beyond */
|
// #define OPTSIZE BUFSIZ /* define this only if not 4.2 BSD or beyond */
|
||||||
|
|
||||||
int bflg, eflg, nflg, sflg, tflg, uflg, vflg;
|
int bflg, eflg, nflg, sflg, tflg, uflg, vflg;
|
||||||
int spaced, col, lno, inlin, ibsize, obsize;
|
int spaced, col, lno, inlin, ibsize, obsize;
|
||||||
|
|
||||||
main(argc, argv)
|
static void copyopt(FILE *f);
|
||||||
|
static int fastcat(int fd);
|
||||||
|
|
||||||
|
int main(argc, argv)
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
int fflg = 0;
|
int fflg = 0;
|
||||||
register FILE *fi;
|
FILE *fi;
|
||||||
register c;
|
int c;
|
||||||
int dev, ino = -1;
|
int dev, ino = -1;
|
||||||
struct stat statb;
|
struct stat statb;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
@@ -121,10 +125,10 @@ char **argv;
|
|||||||
exit(retval);
|
exit(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyopt(f)
|
void copyopt(f)
|
||||||
register FILE *f;
|
FILE *f;
|
||||||
{
|
{
|
||||||
register int c;
|
int c;
|
||||||
|
|
||||||
top:
|
top:
|
||||||
c = getc(f);
|
c = getc(f);
|
||||||
@@ -168,11 +172,11 @@ top:
|
|||||||
goto top;
|
goto top;
|
||||||
}
|
}
|
||||||
|
|
||||||
fastcat(fd)
|
int fastcat(fd)
|
||||||
register int fd;
|
int fd;
|
||||||
{
|
{
|
||||||
register int buffsize, n, nwritten, offset;
|
int buffsize, n, nwritten, offset;
|
||||||
register char *buff;
|
char *buff;
|
||||||
struct stat statbuff;
|
struct stat statbuff;
|
||||||
|
|
||||||
#ifndef OPTSIZE
|
#ifndef OPTSIZE
|
||||||
|
|||||||
244
src/cmd/cb.c
244
src/cmd/cb.c
@@ -9,26 +9,20 @@ int sifflg[10];
|
|||||||
int iflev = 0;
|
int iflev = 0;
|
||||||
int ifflg = -1;
|
int ifflg = -1;
|
||||||
int level = 0;
|
int level = 0;
|
||||||
int ind[10] = {
|
int ind[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
0,0,0,0,0,0,0,0,0,0 };
|
|
||||||
int eflg = 0;
|
int eflg = 0;
|
||||||
int paren = 0;
|
int paren = 0;
|
||||||
int pflg[10] = {
|
int pflg[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
0,0,0,0,0,0,0,0,0,0 };
|
|
||||||
char lchar;
|
char lchar;
|
||||||
char pchar;
|
char pchar;
|
||||||
int aflg = 0;
|
int aflg = 0;
|
||||||
int ct;
|
int ct;
|
||||||
int stabs[20][10];
|
int stabs[20][10];
|
||||||
int qflg = 0;
|
int qflg = 0;
|
||||||
char *wif[] = {
|
char *wif[] = { "if", 0 };
|
||||||
"if",0};
|
char *welse[] = { "else", 0 };
|
||||||
char *welse[] = {
|
char *wfor[] = { "for", 0 };
|
||||||
"else",0};
|
char *wds[] = { "case", "default", 0 };
|
||||||
char *wfor[] = {
|
|
||||||
"for",0};
|
|
||||||
char *wds[] = {
|
|
||||||
"case","default",0};
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
char string[200];
|
char string[200];
|
||||||
char cc;
|
char cc;
|
||||||
@@ -37,68 +31,77 @@ int peek = -1;
|
|||||||
int tabs = 0;
|
int tabs = 0;
|
||||||
int lastchar;
|
int lastchar;
|
||||||
int c;
|
int c;
|
||||||
int getstr();
|
|
||||||
|
|
||||||
putstr()
|
static void ptabs(void);
|
||||||
|
static int getch(void);
|
||||||
|
static int lookup(char *tab[]);
|
||||||
|
static void gotelse(void);
|
||||||
|
static int getnl(void);
|
||||||
|
static void comment(void);
|
||||||
|
static int getstr(void);
|
||||||
|
|
||||||
|
void putstr()
|
||||||
{
|
{
|
||||||
if(j > 0){
|
if (j > 0) {
|
||||||
if(sflg != 0){
|
if (sflg != 0) {
|
||||||
ptabs();
|
ptabs();
|
||||||
sflg = 0;
|
sflg = 0;
|
||||||
if(aflg == 1){
|
if (aflg == 1) {
|
||||||
aflg = 0;
|
aflg = 0;
|
||||||
if(tabs > 0)printf(" ");
|
if (tabs > 0)
|
||||||
|
printf(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string[j] = '\0';
|
string[j] = '\0';
|
||||||
printf("%s",string);
|
printf("%s", string);
|
||||||
j = 0;
|
j = 0;
|
||||||
}
|
} else {
|
||||||
else{
|
if (sflg != 0) {
|
||||||
if(sflg != 0){
|
|
||||||
sflg = 0;
|
sflg = 0;
|
||||||
aflg = 0;
|
aflg = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main(argc, argv)
|
int main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char argv[];
|
char *argv[];
|
||||||
{
|
{
|
||||||
while((c = getch()) != EOF){
|
while ((c = getch()) != EOF) {
|
||||||
switch(c){
|
switch (c) {
|
||||||
case ' ':
|
case ' ':
|
||||||
case '\t':
|
case '\t':
|
||||||
if(lookup(welse) == 1){
|
if (lookup(welse) == 1) {
|
||||||
gotelse();
|
gotelse();
|
||||||
if(sflg == 0 || j > 0)string[j++] = c;
|
if (sflg == 0 || j > 0)
|
||||||
|
string[j++] = c;
|
||||||
putstr();
|
putstr();
|
||||||
sflg = 0;
|
sflg = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(sflg == 0 || j > 0)string[j++] = c;
|
if (sflg == 0 || j > 0)
|
||||||
|
string[j++] = c;
|
||||||
continue;
|
continue;
|
||||||
case '\n':
|
case '\n':
|
||||||
if((eflg = lookup(welse)) == 1)gotelse();
|
if ((eflg = lookup(welse)) == 1)
|
||||||
|
gotelse();
|
||||||
putstr();
|
putstr();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
sflg = 1;
|
sflg = 1;
|
||||||
if(eflg == 1){
|
if (eflg == 1) {
|
||||||
pflg[level]++;
|
pflg[level]++;
|
||||||
tabs++;
|
tabs++;
|
||||||
}
|
} else if (pchar == lchar)
|
||||||
else
|
|
||||||
if(pchar == lchar)
|
|
||||||
aflg = 1;
|
aflg = 1;
|
||||||
continue;
|
continue;
|
||||||
case '{':
|
case '{':
|
||||||
if(lookup(welse) == 1)gotelse();
|
if (lookup(welse) == 1)
|
||||||
|
gotelse();
|
||||||
siflev[clevel] = iflev;
|
siflev[clevel] = iflev;
|
||||||
sifflg[clevel] = ifflg;
|
sifflg[clevel] = ifflg;
|
||||||
iflev = ifflg = 0;
|
iflev = ifflg = 0;
|
||||||
clevel++;
|
clevel++;
|
||||||
if(sflg == 1 && pflg[level] != 0){
|
if (sflg == 1 && pflg[level] != 0) {
|
||||||
pflg[level]--;
|
pflg[level]--;
|
||||||
tabs--;
|
tabs--;
|
||||||
}
|
}
|
||||||
@@ -109,7 +112,7 @@ main(argc, argv)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
tabs++;
|
tabs++;
|
||||||
sflg = 1;
|
sflg = 1;
|
||||||
if(pflg[level] > 0){
|
if (pflg[level] > 0) {
|
||||||
ind[level] = 1;
|
ind[level] = 1;
|
||||||
level++;
|
level++;
|
||||||
slevel[level] = clevel;
|
slevel[level] = clevel;
|
||||||
@@ -117,26 +120,29 @@ main(argc, argv)
|
|||||||
continue;
|
continue;
|
||||||
case '}':
|
case '}':
|
||||||
clevel--;
|
clevel--;
|
||||||
if((iflev = siflev[clevel]-1) < 0)iflev = 0;
|
if ((iflev = siflev[clevel] - 1) < 0)
|
||||||
|
iflev = 0;
|
||||||
ifflg = sifflg[clevel];
|
ifflg = sifflg[clevel];
|
||||||
if(pflg[level] >0 && ind[level] == 0){
|
if (pflg[level] > 0 && ind[level] == 0) {
|
||||||
tabs -= pflg[level];
|
tabs -= pflg[level];
|
||||||
pflg[level] = 0;
|
pflg[level] = 0;
|
||||||
}
|
}
|
||||||
putstr();
|
putstr();
|
||||||
tabs--;
|
tabs--;
|
||||||
ptabs();
|
ptabs();
|
||||||
if((peek = getch()) == ';'){
|
if ((peek = getch()) == ';') {
|
||||||
printf("%c;",c);
|
printf("%c;", c);
|
||||||
peek = -1;
|
peek = -1;
|
||||||
}
|
} else
|
||||||
else printf("%c",c);
|
printf("%c", c);
|
||||||
getnl();
|
getnl();
|
||||||
putstr();
|
putstr();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
sflg = 1;
|
sflg = 1;
|
||||||
if(clevel < slevel[level])if(level > 0)level--;
|
if (clevel < slevel[level])
|
||||||
if(ind[level] != 0){
|
if (level > 0)
|
||||||
|
level--;
|
||||||
|
if (ind[level] != 0) {
|
||||||
tabs -= pflg[level];
|
tabs -= pflg[level];
|
||||||
pflg[level] = 0;
|
pflg[level] = 0;
|
||||||
ind[level] = 0;
|
ind[level] = 0;
|
||||||
@@ -145,18 +151,18 @@ main(argc, argv)
|
|||||||
case '"':
|
case '"':
|
||||||
case '\'':
|
case '\'':
|
||||||
string[j++] = c;
|
string[j++] = c;
|
||||||
while((cc = getch()) != c){
|
while ((cc = getch()) != c) {
|
||||||
string[j++] = cc;
|
string[j++] = cc;
|
||||||
if(cc == '\\'){
|
if (cc == '\\') {
|
||||||
string[j++] = getch();
|
string[j++] = getch();
|
||||||
}
|
}
|
||||||
if(cc == '\n'){
|
if (cc == '\n') {
|
||||||
putstr();
|
putstr();
|
||||||
sflg = 1;
|
sflg = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string[j++] = cc;
|
string[j++] = cc;
|
||||||
if(getnl() == 1){
|
if (getnl() == 1) {
|
||||||
lchar = cc;
|
lchar = cc;
|
||||||
peek = '\n';
|
peek = '\n';
|
||||||
}
|
}
|
||||||
@@ -164,7 +170,7 @@ main(argc, argv)
|
|||||||
case ';':
|
case ';':
|
||||||
string[j++] = c;
|
string[j++] = c;
|
||||||
putstr();
|
putstr();
|
||||||
if(pflg[level] > 0 && ind[level] == 0){
|
if (pflg[level] > 0 && ind[level] == 0) {
|
||||||
tabs -= pflg[level];
|
tabs -= pflg[level];
|
||||||
pflg[level] = 0;
|
pflg[level] = 0;
|
||||||
}
|
}
|
||||||
@@ -172,11 +178,14 @@ main(argc, argv)
|
|||||||
putstr();
|
putstr();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
sflg = 1;
|
sflg = 1;
|
||||||
if(iflev > 0)
|
if (iflev > 0) {
|
||||||
if(ifflg == 1){iflev--;
|
if (ifflg == 1) {
|
||||||
|
iflev--;
|
||||||
ifflg = 0;
|
ifflg = 0;
|
||||||
|
} else {
|
||||||
|
iflev = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else iflev = 0;
|
|
||||||
continue;
|
continue;
|
||||||
case '\\':
|
case '\\':
|
||||||
string[j++] = c;
|
string[j++] = c;
|
||||||
@@ -188,20 +197,19 @@ main(argc, argv)
|
|||||||
continue;
|
continue;
|
||||||
case ':':
|
case ':':
|
||||||
string[j++] = c;
|
string[j++] = c;
|
||||||
if(qflg == 1){
|
if (qflg == 1) {
|
||||||
qflg = 0;
|
qflg = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(lookup(wds) == 0){
|
if (lookup(wds) == 0) {
|
||||||
sflg = 0;
|
sflg = 0;
|
||||||
putstr();
|
putstr();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
tabs--;
|
tabs--;
|
||||||
putstr();
|
putstr();
|
||||||
tabs++;
|
tabs++;
|
||||||
}
|
}
|
||||||
if((peek = getch()) == ';'){
|
if ((peek = getch()) == ';') {
|
||||||
printf(";");
|
printf(";");
|
||||||
peek = -1;
|
peek = -1;
|
||||||
}
|
}
|
||||||
@@ -212,7 +220,8 @@ main(argc, argv)
|
|||||||
continue;
|
continue;
|
||||||
case '/':
|
case '/':
|
||||||
string[j++] = c;
|
string[j++] = c;
|
||||||
if((peek = getch()) != '*')continue;
|
if ((peek = getch()) != '*')
|
||||||
|
continue;
|
||||||
string[j++] = peek;
|
string[j++] = peek;
|
||||||
peek = -1;
|
peek = -1;
|
||||||
comment();
|
comment();
|
||||||
@@ -221,10 +230,11 @@ main(argc, argv)
|
|||||||
paren--;
|
paren--;
|
||||||
string[j++] = c;
|
string[j++] = c;
|
||||||
putstr();
|
putstr();
|
||||||
if(getnl() == 1){
|
if (getnl() == 1) {
|
||||||
peek = '\n';
|
peek = '\n';
|
||||||
if(paren != 0)aflg = 1;
|
if (paren != 0)
|
||||||
else if(tabs > 0){
|
aflg = 1;
|
||||||
|
else if (tabs > 0) {
|
||||||
pflg[level]++;
|
pflg[level]++;
|
||||||
tabs++;
|
tabs++;
|
||||||
ind[level] = 0;
|
ind[level] = 0;
|
||||||
@@ -233,7 +243,8 @@ main(argc, argv)
|
|||||||
continue;
|
continue;
|
||||||
case '#':
|
case '#':
|
||||||
string[j++] = c;
|
string[j++] = c;
|
||||||
while((cc = getch()) != '\n')string[j++] = cc;
|
while ((cc = getch()) != '\n')
|
||||||
|
string[j++] = cc;
|
||||||
string[j++] = cc;
|
string[j++] = cc;
|
||||||
sflg = 0;
|
sflg = 0;
|
||||||
putstr();
|
putstr();
|
||||||
@@ -242,20 +253,22 @@ main(argc, argv)
|
|||||||
case '(':
|
case '(':
|
||||||
string[j++] = c;
|
string[j++] = c;
|
||||||
paren++;
|
paren++;
|
||||||
if(lookup(wfor) == 1){
|
if (lookup(wfor) == 1) {
|
||||||
while((c = getstr()) != ';');
|
while ((c = getstr()) != ';')
|
||||||
ct=0;
|
;
|
||||||
cont:
|
ct = 0;
|
||||||
while((c = getstr()) != ')'){
|
cont:
|
||||||
if(c == '(') ct++;
|
while ((c = getstr()) != ')') {
|
||||||
|
if (c == '(')
|
||||||
|
ct++;
|
||||||
}
|
}
|
||||||
if(ct != 0){
|
if (ct != 0) {
|
||||||
ct--;
|
ct--;
|
||||||
goto cont;
|
goto cont;
|
||||||
}
|
}
|
||||||
paren--;
|
paren--;
|
||||||
putstr();
|
putstr();
|
||||||
if(getnl() == 1){
|
if (getnl() == 1) {
|
||||||
peek = '\n';
|
peek = '\n';
|
||||||
pflg[level]++;
|
pflg[level]++;
|
||||||
tabs++;
|
tabs++;
|
||||||
@@ -263,7 +276,7 @@ cont:
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(lookup(wif) == 1){
|
if (lookup(wif) == 1) {
|
||||||
putstr();
|
putstr();
|
||||||
stabs[clevel][iflev] = tabs;
|
stabs[clevel][iflev] = tabs;
|
||||||
spflg[clevel][iflev] = pflg[level];
|
spflg[clevel][iflev] = pflg[level];
|
||||||
@@ -274,62 +287,71 @@ cont:
|
|||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
string[j++] = c;
|
string[j++] = c;
|
||||||
if(c != ',')lchar = c;
|
if (c != ',')
|
||||||
|
lchar = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ptabs()
|
void ptabs()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i < tabs; i++)printf("\t");
|
for (i = 0; i < tabs; i++)
|
||||||
|
printf("\t");
|
||||||
}
|
}
|
||||||
|
|
||||||
getch()
|
int getch()
|
||||||
{
|
{
|
||||||
if(peek < 0 && lastchar != ' ' && lastchar != '\t')pchar = lastchar;
|
if (peek < 0 && lastchar != ' ' && lastchar != '\t')
|
||||||
lastchar = (peek<0) ? getc(stdin):peek;
|
pchar = lastchar;
|
||||||
|
lastchar = (peek < 0) ? getc(stdin) : peek;
|
||||||
peek = -1;
|
peek = -1;
|
||||||
return(lastchar);
|
return (lastchar);
|
||||||
}
|
}
|
||||||
|
|
||||||
lookup(tab)
|
int lookup(tab)
|
||||||
char *tab[];
|
char *tab[];
|
||||||
{
|
{
|
||||||
char r;
|
char r;
|
||||||
int l,kk,k,i;
|
int l, kk, k, i;
|
||||||
if(j < 1)return(0);
|
if (j < 1)
|
||||||
kk=0;
|
return (0);
|
||||||
while(string[kk] == ' ')kk++;
|
kk = 0;
|
||||||
for(i=0; tab[i] != 0; i++){
|
while (string[kk] == ' ')
|
||||||
l=0;
|
kk++;
|
||||||
for(k=kk;(r = tab[i][l++]) == string[k] && r != '\0';k++);
|
for (i = 0; tab[i] != 0; i++) {
|
||||||
if(r == '\0' && (string[k] < 'a' || string[k] > 'z' || k >= j))return(1);
|
l = 0;
|
||||||
|
for (k = kk; (r = tab[i][l++]) == string[k] && r != '\0'; k++)
|
||||||
|
;
|
||||||
|
if (r == '\0' && (string[k] < 'a' || string[k] > 'z' || k >= j))
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
getstr()
|
int getstr()
|
||||||
{
|
{
|
||||||
char ch;
|
char ch;
|
||||||
beg:
|
beg:
|
||||||
if((ch = string[j++] = getch()) == '\\'){
|
if ((ch = string[j++] = getch()) == '\\') {
|
||||||
string[j++] = getch();
|
string[j++] = getch();
|
||||||
goto beg;
|
goto beg;
|
||||||
}
|
}
|
||||||
if(ch == '\'' || ch == '"'){
|
if (ch == '\'' || ch == '"') {
|
||||||
while((cc = string[j++] = getch()) != ch)if(cc == '\\')string[j++] = getch();
|
while ((cc = string[j++] = getch()) != ch)
|
||||||
|
if (cc == '\\')
|
||||||
|
string[j++] = getch();
|
||||||
goto beg;
|
goto beg;
|
||||||
}
|
}
|
||||||
if(ch == '\n'){
|
if (ch == '\n') {
|
||||||
putstr();
|
putstr();
|
||||||
aflg = 1;
|
aflg = 1;
|
||||||
goto beg;
|
goto beg;
|
||||||
}
|
} else
|
||||||
else return(ch);
|
return (ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
gotelse()
|
void gotelse()
|
||||||
{
|
{
|
||||||
tabs = stabs[clevel][iflev];
|
tabs = stabs[clevel][iflev];
|
||||||
pflg[level] = spflg[clevel][iflev];
|
pflg[level] = spflg[clevel][iflev];
|
||||||
@@ -337,38 +359,38 @@ gotelse()
|
|||||||
ifflg = 1;
|
ifflg = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
getnl()
|
int getnl()
|
||||||
{
|
{
|
||||||
while((peek = getch()) == '\t' || peek == ' '){
|
while ((peek = getch()) == '\t' || peek == ' ') {
|
||||||
string[j++] = peek;
|
string[j++] = peek;
|
||||||
peek = -1;
|
peek = -1;
|
||||||
}
|
}
|
||||||
if((peek = getch()) == '/'){
|
if ((peek = getch()) == '/') {
|
||||||
peek = -1;
|
peek = -1;
|
||||||
if((peek = getch()) == '*'){
|
if ((peek = getch()) == '*') {
|
||||||
string[j++] = '/';
|
string[j++] = '/';
|
||||||
string[j++] = '*';
|
string[j++] = '*';
|
||||||
peek = -1;
|
peek = -1;
|
||||||
comment();
|
comment();
|
||||||
|
} else
|
||||||
|
string[j++] = '/';
|
||||||
}
|
}
|
||||||
else string[j++] = '/';
|
if ((peek = getch()) == '\n') {
|
||||||
}
|
|
||||||
if((peek = getch()) == '\n'){
|
|
||||||
peek = -1;
|
peek = -1;
|
||||||
return(1);
|
return (1);
|
||||||
}
|
}
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
comment()
|
void comment()
|
||||||
{
|
{
|
||||||
int i = j;
|
int i = j;
|
||||||
|
|
||||||
while ((c = getch()) != EOF) {
|
while ((c = getch()) != EOF) {
|
||||||
string[j++] = c;
|
string[j++] = c;
|
||||||
switch(c) {
|
switch (c) {
|
||||||
case '/':
|
case '/':
|
||||||
if (j > i + 1 && string[j-2] == '*')
|
if (j > i + 1 && string[j - 2] == '*')
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ CFLAGS += -DVERSSTR=\"1.0\" \
|
|||||||
all: cc
|
all: cc
|
||||||
|
|
||||||
cc: $(OBJS)
|
cc: $(OBJS)
|
||||||
${CC} ${LDFLAGS} -o cc.elf $(OBJS) ${LIBS}
|
${LD} ${LDFLAGS} -o cc.elf $(OBJS) ${LIBS}
|
||||||
${OBJDUMP} -S cc.elf > cc.dis
|
${OBJDUMP} -S cc.elf > cc.dis
|
||||||
${SIZE} cc.elf
|
${SIZE} cc.elf
|
||||||
${ELF2AOUT} cc.elf $@ && rm cc.elf
|
${ELF2AOUT} cc.elf $@ && rm cc.elf
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ MANSRC = ccom.1
|
|||||||
all: ccom $(MAN)
|
all: ccom $(MAN)
|
||||||
|
|
||||||
ccom: ${OBJS}
|
ccom: ${OBJS}
|
||||||
${CC} ${LDFLAGS} -o ccom.elf ${OBJS} ${LIBS}
|
${LD} ${LDFLAGS} -o ccom.elf ${OBJS} ${LIBS}
|
||||||
${OBJDUMP} -S ccom.elf > ccom.dis
|
${OBJDUMP} -S ccom.elf > ccom.dis
|
||||||
${SIZE} ccom.elf
|
${SIZE} ccom.elf
|
||||||
${ELF2AOUT} ccom.elf $@ && rm ccom.elf
|
${ELF2AOUT} ccom.elf $@ && rm ccom.elf
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ MANSRC = chflags.1
|
|||||||
all: chflags chflags.0
|
all: chflags chflags.0
|
||||||
|
|
||||||
chflags: ${OBJS}
|
chflags: ${OBJS}
|
||||||
${CC} ${LDFLAGS} -o chflags.elf ${OBJS} ${LIBS}
|
${LD} ${LDFLAGS} -o chflags.elf ${OBJS} ${LIBS}
|
||||||
${OBJDUMP} -S chflags.elf > chflags.dis
|
${OBJDUMP} -S chflags.elf > chflags.dis
|
||||||
${SIZE} chflags.elf
|
${SIZE} chflags.elf
|
||||||
${ELF2AOUT} chflags.elf $@ && rm chflags.elf
|
${ELF2AOUT} chflags.elf $@ && rm chflags.elf
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <sys/dir.h>
|
#include <sys/dir.h>
|
||||||
|
|
||||||
struct group *gr;
|
struct group *gr;
|
||||||
@@ -27,12 +30,18 @@ int status;
|
|||||||
int fflag, rflag;
|
int fflag, rflag;
|
||||||
static char *fchdirmsg = "Can't fchdir() back to starting directory";
|
static char *fchdirmsg = "Can't fchdir() back to starting directory";
|
||||||
|
|
||||||
main(argc, argv)
|
static void fatal(int status, char *fmt, ...);
|
||||||
|
static int isnumber(char *s);
|
||||||
|
static int Perror(char *s);
|
||||||
|
static int error(char *fmt, ...);
|
||||||
|
static int chownr(char *dir, uid_t uid, gid_t gid, int savedir);
|
||||||
|
|
||||||
|
int main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
{
|
{
|
||||||
register c, i;
|
int c, i;
|
||||||
register char *cp;
|
char *cp;
|
||||||
int fcurdir;
|
int fcurdir;
|
||||||
|
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
@@ -107,25 +116,25 @@ ok:
|
|||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
isnumber(s)
|
int isnumber(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
register int c;
|
int c;
|
||||||
|
|
||||||
while (c = *s++)
|
while ((c = *s++))
|
||||||
if (!isdigit(c))
|
if (!isdigit(c))
|
||||||
return (0);
|
return (0);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
chownr(dir, uid, gid, savedir)
|
int chownr(dir, uid, gid, savedir)
|
||||||
char *dir;
|
char *dir;
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
gid_t gid;
|
gid_t gid;
|
||||||
int savedir;
|
int savedir;
|
||||||
{
|
{
|
||||||
register DIR *dirp;
|
DIR *dirp;
|
||||||
register struct direct *dp;
|
struct direct *dp;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int ecode;
|
int ecode;
|
||||||
|
|
||||||
@@ -173,33 +182,37 @@ chownr(dir, uid, gid, savedir)
|
|||||||
return (ecode);
|
return (ecode);
|
||||||
}
|
}
|
||||||
|
|
||||||
error(fmt, a)
|
int verror(char *fmt, va_list args)
|
||||||
char *fmt, *a;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!fflag) {
|
if (!fflag) {
|
||||||
fprintf(stderr, "chgrp: ");
|
fprintf(stderr, "chgrp: ");
|
||||||
fprintf(stderr, fmt, a);
|
vfprintf(stderr, fmt, args);
|
||||||
putc('\n', stderr);
|
putc('\n', stderr);
|
||||||
}
|
}
|
||||||
return (!fflag);
|
return (!fflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* VARARGS */
|
int error(char *fmt, ...)
|
||||||
fatal(status, fmt, a)
|
|
||||||
int status;
|
|
||||||
char *fmt, *a;
|
|
||||||
{
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
int status = verror(fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fatal(int status, char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
fflag = 0;
|
fflag = 0;
|
||||||
(void) error(fmt, a);
|
verror(fmt, args);
|
||||||
|
va_end(args);
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
Perror(s)
|
int Perror(char *s)
|
||||||
char *s;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!fflag) {
|
if (!fflag) {
|
||||||
fprintf(stderr, "chgrp: ");
|
fprintf(stderr, "chgrp: ");
|
||||||
perror(s);
|
perror(s);
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -24,11 +27,21 @@ int status;
|
|||||||
int fflag;
|
int fflag;
|
||||||
int rflag;
|
int rflag;
|
||||||
|
|
||||||
main(argc, argv)
|
static void fatal(int status, char *fmt, ...);
|
||||||
|
static int Perror(char *s);
|
||||||
|
static int error(char *fmt, ...);
|
||||||
|
static int newmode(unsigned nm);
|
||||||
|
static int chmodr(char *dir, int mode, int savedir);
|
||||||
|
static int abss(void);
|
||||||
|
static int who(void);
|
||||||
|
static int what(void);
|
||||||
|
static int where(int om);
|
||||||
|
|
||||||
|
int main(argc, argv)
|
||||||
char *argv[];
|
char *argv[];
|
||||||
{
|
{
|
||||||
register char *p, *flags;
|
char *p, *flags;
|
||||||
register int i;
|
int i;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int fcurdir;
|
int fcurdir;
|
||||||
|
|
||||||
@@ -89,13 +102,13 @@ done:
|
|||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
chmodr(dir, mode, savedir)
|
int chmodr(dir, mode, savedir)
|
||||||
char *dir;
|
char *dir;
|
||||||
int mode;
|
int mode;
|
||||||
int savedir;
|
int savedir;
|
||||||
{
|
{
|
||||||
register DIR *dirp;
|
DIR *dirp;
|
||||||
register struct direct *dp;
|
struct direct *dp;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int ecode;
|
int ecode;
|
||||||
|
|
||||||
@@ -140,32 +153,37 @@ chmodr(dir, mode, savedir)
|
|||||||
return (ecode);
|
return (ecode);
|
||||||
}
|
}
|
||||||
|
|
||||||
error(fmt, a)
|
int verror(char *fmt, va_list args)
|
||||||
char *fmt, *a;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!fflag) {
|
if (!fflag) {
|
||||||
fprintf(stderr, "chmod: ");
|
fprintf(stderr, "chmod: ");
|
||||||
fprintf(stderr, fmt, a);
|
vfprintf(stderr, fmt, args);
|
||||||
putc('\n', stderr);
|
putc('\n', stderr);
|
||||||
}
|
}
|
||||||
return (!fflag);
|
return (!fflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal(status, fmt, a)
|
int error(char *fmt, ...)
|
||||||
int status;
|
|
||||||
char *fmt, *a;
|
|
||||||
{
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
int status = verror(fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fatal(int status, char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
fflag = 0;
|
fflag = 0;
|
||||||
(void) error(fmt, a);
|
verror(fmt, args);
|
||||||
|
va_end(args);
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
Perror(s)
|
int Perror(char *s)
|
||||||
char *s;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!fflag) {
|
if (!fflag) {
|
||||||
fprintf(stderr, "chmod: ");
|
fprintf(stderr, "chmod: ");
|
||||||
perror(s);
|
perror(s);
|
||||||
@@ -173,10 +191,10 @@ Perror(s)
|
|||||||
return (!fflag);
|
return (!fflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
newmode(nm)
|
int newmode(nm)
|
||||||
unsigned nm;
|
unsigned nm;
|
||||||
{
|
{
|
||||||
register o, m, b;
|
int o, m, b;
|
||||||
int savem;
|
int savem;
|
||||||
|
|
||||||
ms = modestring;
|
ms = modestring;
|
||||||
@@ -186,7 +204,7 @@ newmode(nm)
|
|||||||
return (m);
|
return (m);
|
||||||
do {
|
do {
|
||||||
m = who();
|
m = who();
|
||||||
while (o = what()) {
|
while ((o = what())) {
|
||||||
b = where(nm);
|
b = where(nm);
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case '+':
|
case '+':
|
||||||
@@ -207,9 +225,9 @@ newmode(nm)
|
|||||||
return (nm);
|
return (nm);
|
||||||
}
|
}
|
||||||
|
|
||||||
abss()
|
int abss()
|
||||||
{
|
{
|
||||||
register c, i;
|
int c, i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((c = *ms++) >= '0' && c <= '7')
|
while ((c = *ms++) >= '0' && c <= '7')
|
||||||
@@ -229,9 +247,9 @@ abss()
|
|||||||
#define SETID 06000 /* set[ug]id */
|
#define SETID 06000 /* set[ug]id */
|
||||||
#define STICKY 01000 /* sticky bit */
|
#define STICKY 01000 /* sticky bit */
|
||||||
|
|
||||||
who()
|
int who()
|
||||||
{
|
{
|
||||||
register m;
|
int m;
|
||||||
|
|
||||||
m = 0;
|
m = 0;
|
||||||
for (;;) switch (*ms++) {
|
for (;;) switch (*ms++) {
|
||||||
@@ -255,7 +273,7 @@ who()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
what()
|
int what()
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (*ms) {
|
switch (*ms) {
|
||||||
@@ -267,10 +285,10 @@ what()
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
where(om)
|
int where(om)
|
||||||
register om;
|
int om;
|
||||||
{
|
{
|
||||||
register m;
|
int m;
|
||||||
|
|
||||||
m = 0;
|
m = 0;
|
||||||
switch (*ms) {
|
switch (*ms) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
TOPSRC = $(shell cd ../../..; pwd)
|
TOPSRC = $(shell cd ../../..; pwd)
|
||||||
include $(TOPSRC)/target.mk
|
include $(TOPSRC)/target.mk
|
||||||
|
|
||||||
CFLAGS = -O
|
CFLAGS = -O -Werror
|
||||||
SRCS = chown.c
|
SRCS = chown.c
|
||||||
OBJS = chown.o
|
OBJS = chown.o
|
||||||
MAN = chown.0
|
MAN = chown.0
|
||||||
@@ -10,7 +10,7 @@ MANSRC = chown.8
|
|||||||
all: chown $(MAN)
|
all: chown $(MAN)
|
||||||
|
|
||||||
chown: ${OBJS}
|
chown: ${OBJS}
|
||||||
${CC} ${LDFLAGS} -o chown.elf ${OBJS} ${LIBS}
|
${LD} ${LDFLAGS} -o chown.elf ${OBJS} ${LIBS}
|
||||||
${OBJDUMP} -S chown.elf > chown.dis
|
${OBJDUMP} -S chown.elf > chown.dis
|
||||||
${SIZE} chown.elf
|
${SIZE} chown.elf
|
||||||
${ELF2AOUT} chown.elf $@ && rm chown.elf
|
${ELF2AOUT} chown.elf $@ && rm chown.elf
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#include <sys/dir.h>
|
#include <sys/dir.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
static char *fchdirmsg = "Can't fchdir() back to starting directory";
|
static char *fchdirmsg = "Can't fchdir() back to starting directory";
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
@@ -27,88 +29,52 @@ int status;
|
|||||||
int fflag;
|
int fflag;
|
||||||
int rflag;
|
int rflag;
|
||||||
|
|
||||||
main(argc, argv)
|
int
|
||||||
char *argv[];
|
|
||||||
{
|
|
||||||
register int c;
|
|
||||||
register gid_t gid;
|
|
||||||
register char *cp, *group;
|
|
||||||
struct group *grp;
|
|
||||||
int fcurdir;
|
|
||||||
|
|
||||||
argc--, argv++;
|
|
||||||
while (argc > 0 && argv[0][0] == '-') {
|
|
||||||
for (cp = &argv[0][1]; *cp; cp++) switch (*cp) {
|
|
||||||
|
|
||||||
case 'f':
|
|
||||||
fflag++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'R':
|
|
||||||
rflag++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
fatal(255, "unknown option: %c", *cp);
|
|
||||||
}
|
|
||||||
argv++, argc--;
|
|
||||||
}
|
|
||||||
if (argc < 2) {
|
|
||||||
fprintf(stderr, "usage: chown [-fR] owner[.group] file ...\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
gid = -1;
|
|
||||||
group = index(argv[0], '.');
|
|
||||||
if (group != NULL) {
|
|
||||||
*group++ = '\0';
|
|
||||||
if (!isnumber(group)) {
|
|
||||||
if ((grp = getgrnam(group)) == NULL)
|
|
||||||
fatal(255, "unknown group: %s",group);
|
|
||||||
gid = grp -> gr_gid;
|
|
||||||
(void) endgrent();
|
|
||||||
} else if (*group != '\0')
|
|
||||||
gid = atoi(group);
|
|
||||||
}
|
|
||||||
if (!isnumber(argv[0])) {
|
|
||||||
if ((pwd = getpwnam(argv[0])) == NULL)
|
|
||||||
fatal(255, "unknown user id: %s",argv[0]);
|
|
||||||
uid = pwd->pw_uid;
|
|
||||||
} else
|
|
||||||
uid = atoi(argv[0]);
|
|
||||||
|
|
||||||
fcurdir = open(".", O_RDONLY);
|
|
||||||
if (fcurdir < 0)
|
|
||||||
fatal(255, "Can't open .");
|
|
||||||
|
|
||||||
for (c = 1; c < argc; c++) {
|
|
||||||
/* do stat for directory arguments */
|
|
||||||
if (lstat(argv[c], &stbuf) < 0) {
|
|
||||||
status += Perror(argv[c]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (rflag && ((stbuf.st_mode&S_IFMT) == S_IFDIR)) {
|
|
||||||
status += chownr(argv[c], uid, gid, fcurdir);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (chown(argv[c], uid, gid)) {
|
|
||||||
status += Perror(argv[c]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exit(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
isnumber(s)
|
isnumber(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
register c;
|
int c;
|
||||||
|
|
||||||
while(c = *s++)
|
while ((c = *s++))
|
||||||
if (!isdigit(c))
|
if (!isdigit(c))
|
||||||
return (0);
|
return (0);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Perror(s)
|
||||||
|
char *s;
|
||||||
|
{
|
||||||
|
if (!fflag) {
|
||||||
|
fprintf(stderr, "chown: ");
|
||||||
|
perror(s);
|
||||||
|
}
|
||||||
|
return (!fflag);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
error(fmt, a)
|
||||||
|
char *fmt, *a;
|
||||||
|
{
|
||||||
|
if (!fflag) {
|
||||||
|
fprintf(stderr, "chown: ");
|
||||||
|
fprintf(stderr, fmt, a);
|
||||||
|
putc('\n', stderr);
|
||||||
|
}
|
||||||
|
return (!fflag);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fatal(status, fmt, a)
|
||||||
|
int status;
|
||||||
|
char *fmt, *a;
|
||||||
|
{
|
||||||
|
fflag = 0;
|
||||||
|
(void) error(fmt, a);
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
chownr(dir, uid, gid, savedir)
|
chownr(dir, uid, gid, savedir)
|
||||||
char *dir;
|
char *dir;
|
||||||
{
|
{
|
||||||
@@ -151,40 +117,79 @@ chownr(dir, uid, gid, savedir)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fchdir(savedir) < 0)
|
if (fchdir(savedir) < 0)
|
||||||
fatal(255, fchdirmsg);
|
fatal(255, fchdirmsg, "");
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
return (ecode);
|
return (ecode);
|
||||||
}
|
}
|
||||||
|
|
||||||
error(fmt, a)
|
int
|
||||||
char *fmt, *a;
|
main(argc, argv)
|
||||||
|
char *argv[];
|
||||||
{
|
{
|
||||||
|
register int c;
|
||||||
|
register gid_t gid;
|
||||||
|
register char *cp, *group;
|
||||||
|
struct group *grp;
|
||||||
|
int fcurdir;
|
||||||
|
|
||||||
if (!fflag) {
|
argc--, argv++;
|
||||||
fprintf(stderr, "chown: ");
|
while (argc > 0 && argv[0][0] == '-') {
|
||||||
fprintf(stderr, fmt, a);
|
for (cp = &argv[0][1]; *cp; cp++) switch (*cp) {
|
||||||
putc('\n', stderr);
|
|
||||||
|
case 'f':
|
||||||
|
fflag++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'R':
|
||||||
|
rflag++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fatal(255, "unknown option: %c", (char*)(int)*cp);
|
||||||
}
|
}
|
||||||
return (!fflag);
|
argv++, argc--;
|
||||||
}
|
}
|
||||||
|
if (argc < 2) {
|
||||||
|
fprintf(stderr, "usage: chown [-fR] owner[.group] file ...\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
gid = -1;
|
||||||
|
group = index(argv[0], '.');
|
||||||
|
if (group != NULL) {
|
||||||
|
*group++ = '\0';
|
||||||
|
if (!isnumber(group)) {
|
||||||
|
if ((grp = getgrnam(group)) == NULL)
|
||||||
|
fatal(255, "unknown group: %s", group);
|
||||||
|
gid = grp -> gr_gid;
|
||||||
|
(void) endgrent();
|
||||||
|
} else if (*group != '\0')
|
||||||
|
gid = atoi(group);
|
||||||
|
}
|
||||||
|
if (!isnumber(argv[0])) {
|
||||||
|
if ((pwd = getpwnam(argv[0])) == NULL)
|
||||||
|
fatal(255, "unknown user id: %s", argv[0]);
|
||||||
|
uid = pwd->pw_uid;
|
||||||
|
} else
|
||||||
|
uid = atoi(argv[0]);
|
||||||
|
|
||||||
fatal(status, fmt, a)
|
fcurdir = open(".", O_RDONLY);
|
||||||
int status;
|
if (fcurdir < 0)
|
||||||
char *fmt, *a;
|
fatal(255, "Can't open .", "");
|
||||||
{
|
|
||||||
|
|
||||||
fflag = 0;
|
for (c = 1; c < argc; c++) {
|
||||||
(void) error(fmt, a);
|
/* do stat for directory arguments */
|
||||||
|
if (lstat(argv[c], &stbuf) < 0) {
|
||||||
|
status += Perror(argv[c]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (rflag && ((stbuf.st_mode&S_IFMT) == S_IFDIR)) {
|
||||||
|
status += chownr(argv[c], uid, gid, fcurdir);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (chown(argv[c], uid, gid)) {
|
||||||
|
status += Perror(argv[c]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
Perror(s)
|
|
||||||
char *s;
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!fflag) {
|
|
||||||
fprintf(stderr, "chown: ");
|
|
||||||
perror(s);
|
|
||||||
}
|
|
||||||
return (!fflag);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ MANSRC = chpass.1
|
|||||||
all: chpass chpass.0
|
all: chpass chpass.0
|
||||||
|
|
||||||
chpass: ${OBJS}
|
chpass: ${OBJS}
|
||||||
${CC} ${LDFLAGS} -o chpass.elf ${OBJS} ${LIBS}
|
${LD} ${LDFLAGS} -o chpass.elf ${OBJS} ${LIBS}
|
||||||
${OBJDUMP} -S chpass.elf > chpass.dis
|
${OBJDUMP} -S chpass.elf > chpass.dis
|
||||||
${SIZE} chpass.elf
|
${SIZE} chpass.elf
|
||||||
${ELF2AOUT} chpass.elf $@ && rm chpass.elf
|
${ELF2AOUT} chpass.elf $@ && rm chpass.elf
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -29,6 +30,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include "chpass.h"
|
#include "chpass.h"
|
||||||
|
|
||||||
char e1[] = ": ";
|
char e1[] = ": ";
|
||||||
@@ -57,6 +59,16 @@ struct entry list[] = {
|
|||||||
|
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
|
|
||||||
|
void loadpw(char *arg, struct passwd *pw);
|
||||||
|
void usage(void);
|
||||||
|
int info(struct passwd *pw);
|
||||||
|
int copy(struct passwd *pw, FILE *fp);
|
||||||
|
int makedb(char *file);
|
||||||
|
int edit(char *file);
|
||||||
|
int check(FILE *fp, struct passwd *pw);
|
||||||
|
int prompt(void);
|
||||||
|
|
||||||
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
@@ -70,7 +82,6 @@ main(argc, argv)
|
|||||||
int aflag, ch, fd;
|
int aflag, ch, fd;
|
||||||
char *fend, *passwd, *temp, *tend;
|
char *fend, *passwd, *temp, *tend;
|
||||||
char from[MAXPATHLEN], to[MAXPATHLEN];
|
char from[MAXPATHLEN], to[MAXPATHLEN];
|
||||||
char *getusershell();
|
|
||||||
|
|
||||||
uid = getuid();
|
uid = getuid();
|
||||||
aflag = 0;
|
aflag = 0;
|
||||||
@@ -220,6 +231,7 @@ bad: (void)fprintf(stderr, "%s unchanged.\n", _PATH_SHADOW);
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
info(pw)
|
info(pw)
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
{
|
{
|
||||||
@@ -268,6 +280,7 @@ info(pw)
|
|||||||
return(rval);
|
return(rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
check(fp, pw)
|
check(fp, pw)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
@@ -331,6 +344,7 @@ check(fp, pw)
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
copy(pw, fp)
|
copy(pw, fp)
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@@ -371,6 +385,7 @@ copy(pw, fp)
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
makedb(file)
|
makedb(file)
|
||||||
char *file;
|
char *file;
|
||||||
{
|
{
|
||||||
@@ -384,14 +399,17 @@ makedb(file)
|
|||||||
return(w == -1 || status);
|
return(w == -1 || status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
edit(file)
|
edit(file)
|
||||||
char *file;
|
char *file;
|
||||||
{
|
{
|
||||||
int status, pid, w;
|
int status, pid, w;
|
||||||
char *p, *editor, *getenv();
|
char *p, *editor, *getenv();
|
||||||
|
|
||||||
if (editor = getenv("EDITOR")) {
|
editor = getenv("EDITOR");
|
||||||
if (p = rindex(editor, '/'))
|
if (editor) {
|
||||||
|
p = rindex(editor, '/');
|
||||||
|
if (p)
|
||||||
++p;
|
++p;
|
||||||
else
|
else
|
||||||
p = editor;
|
p = editor;
|
||||||
@@ -408,6 +426,7 @@ edit(file)
|
|||||||
return(w == -1 || status);
|
return(w == -1 || status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
loadpw(arg, pw)
|
loadpw(arg, pw)
|
||||||
char *arg;
|
char *arg;
|
||||||
register struct passwd *pw;
|
register struct passwd *pw;
|
||||||
@@ -432,6 +451,7 @@ bad: (void)fprintf(stderr, "chpass: bad password list.\n");
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
prompt()
|
prompt()
|
||||||
{
|
{
|
||||||
register int c;
|
register int c;
|
||||||
@@ -447,6 +467,7 @@ prompt()
|
|||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr, "usage: chpass [-a list] [user]\n");
|
(void)fprintf(stderr, "usage: chpass [-a list] [user]\n");
|
||||||
|
|||||||
@@ -22,3 +22,5 @@ struct entry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern uid_t uid;
|
extern uid_t uid;
|
||||||
|
|
||||||
|
void print(FILE *fp, struct passwd *pw);
|
||||||
|
|||||||
@@ -23,9 +23,12 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include "chpass.h"
|
#include "chpass.h"
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
|
int
|
||||||
p_login(p, pw, ep)
|
p_login(p, pw, ep)
|
||||||
char *p;
|
char *p;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
@@ -57,6 +60,7 @@ p_login(p, pw, ep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
|
int
|
||||||
p_passwd(p, pw, ep)
|
p_passwd(p, pw, ep)
|
||||||
char *p;
|
char *p;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
@@ -73,6 +77,7 @@ p_passwd(p, pw, ep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
|
int
|
||||||
p_uid(p, pw, ep)
|
p_uid(p, pw, ep)
|
||||||
register char *p;
|
register char *p;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
@@ -99,6 +104,7 @@ p_uid(p, pw, ep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
|
int
|
||||||
p_gid(p, pw, ep)
|
p_gid(p, pw, ep)
|
||||||
register char *p;
|
register char *p;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
@@ -131,6 +137,7 @@ p_gid(p, pw, ep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
|
int
|
||||||
p_gecos(p, pw, ep)
|
p_gecos(p, pw, ep)
|
||||||
char *p;
|
char *p;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
@@ -146,6 +153,7 @@ p_gecos(p, pw, ep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
|
int
|
||||||
p_hdir(p, pw, ep)
|
p_hdir(p, pw, ep)
|
||||||
char *p;
|
char *p;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
@@ -163,13 +171,13 @@ p_hdir(p, pw, ep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
|
int
|
||||||
p_shell(p, pw, ep)
|
p_shell(p, pw, ep)
|
||||||
register char *p;
|
register char *p;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
struct entry *ep;
|
struct entry *ep;
|
||||||
{
|
{
|
||||||
register char *sh, *t;
|
register char *sh, *t;
|
||||||
char *getusershell();
|
|
||||||
|
|
||||||
if (!*p) {
|
if (!*p) {
|
||||||
pw->pw_shell = _PATH_BSHELL;
|
pw->pw_shell = _PATH_BSHELL;
|
||||||
|
|||||||
@@ -19,7 +19,10 @@
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include "chpass.h"
|
#include "chpass.h"
|
||||||
|
|
||||||
@@ -46,6 +49,7 @@ ttoa(tval)
|
|||||||
return(tbuf);
|
return(tbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
atot(p, store)
|
atot(p, store)
|
||||||
char *p;
|
char *p;
|
||||||
time_t *store;
|
time_t *store;
|
||||||
@@ -109,13 +113,13 @@ bad: return(1);
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
print(fp, pw)
|
print(fp, pw)
|
||||||
register FILE *fp;
|
register FILE *fp;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
{
|
{
|
||||||
register char *p;
|
register char *p;
|
||||||
char *bp;
|
char *bp;
|
||||||
char *getusershell(), *ttoa();
|
|
||||||
|
|
||||||
fprintf(fp, "#Changing user database information for %s.\n",
|
fprintf(fp, "#Changing user database information for %s.\n",
|
||||||
pw->pw_name);
|
pw->pw_name);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ MANSRC = chroot.8
|
|||||||
all: chroot ${MAN}
|
all: chroot ${MAN}
|
||||||
|
|
||||||
chroot: ${OBJS}
|
chroot: ${OBJS}
|
||||||
${CC} ${LDFLAGS} -o chroot.elf ${OBJS} ${LIBS}
|
${LD} ${LDFLAGS} -o chroot.elf ${OBJS} ${LIBS}
|
||||||
${OBJDUMP} -S chroot.elf > chroot.dis
|
${OBJDUMP} -S chroot.elf > chroot.dis
|
||||||
${SIZE} chroot.elf
|
${SIZE} chroot.elf
|
||||||
${ELF2AOUT} chroot.elf $@ && rm chroot.elf
|
${ELF2AOUT} chroot.elf $@ && rm chroot.elf
|
||||||
|
|||||||
@@ -18,8 +18,18 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
main(argc, argv)
|
void fatal(msg)
|
||||||
|
char *msg;
|
||||||
|
{
|
||||||
|
extern int errno;
|
||||||
|
|
||||||
|
fprintf(stderr, "chroot: %s: %s\n", msg, strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
@@ -43,12 +53,3 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal(msg)
|
|
||||||
char *msg;
|
|
||||||
{
|
|
||||||
extern int errno;
|
|
||||||
|
|
||||||
fprintf(stderr, "chroot: %s: %s\n", msg, strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,13 +9,17 @@
|
|||||||
* software without specific written prior permission. This software
|
* software without specific written prior permission. This software
|
||||||
* is provided ``as is'' without express or implied warranty.
|
* is provided ``as is'' without express or implied warranty.
|
||||||
*/
|
*/
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/file.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define DIFF 1 /* found differences */
|
#define DIFF 1 /* found differences */
|
||||||
#define ERR 2 /* error during run */
|
#define ERR 2 /* error during run */
|
||||||
@@ -34,9 +38,7 @@ static char *file1, *file2; /* file names */
|
|||||||
* error --
|
* error --
|
||||||
* print I/O error message and die
|
* print I/O error message and die
|
||||||
*/
|
*/
|
||||||
static
|
static void error(char *filename)
|
||||||
error(filename)
|
|
||||||
char *filename;
|
|
||||||
{
|
{
|
||||||
extern int errno;
|
extern int errno;
|
||||||
int sverrno;
|
int sverrno;
|
||||||
@@ -54,9 +56,7 @@ error(filename)
|
|||||||
* endoffile --
|
* endoffile --
|
||||||
* print end-of-file message and exit indicating the files were different
|
* print end-of-file message and exit indicating the files were different
|
||||||
*/
|
*/
|
||||||
static
|
static void endoffile(char *filename)
|
||||||
endoffile(filename)
|
|
||||||
char *filename;
|
|
||||||
{
|
{
|
||||||
/* 32V put this message on stdout, S5 does it on stderr. */
|
/* 32V put this message on stdout, S5 does it on stderr. */
|
||||||
if (!silent)
|
if (!silent)
|
||||||
@@ -68,11 +68,10 @@ endoffile(filename)
|
|||||||
* skip --
|
* skip --
|
||||||
* skip first part of file
|
* skip first part of file
|
||||||
*/
|
*/
|
||||||
static
|
static void skip(
|
||||||
skip(dist, fd, fname)
|
u_long dist, /* length in bytes, to skip */
|
||||||
register u_long dist; /* length in bytes, to skip */
|
int fd, /* file descriptor */
|
||||||
register int fd; /* file descriptor */
|
char *fname) /* file name for error */
|
||||||
char *fname; /* file name for error */
|
|
||||||
{
|
{
|
||||||
register int rlen; /* read length */
|
register int rlen; /* read length */
|
||||||
register int nread;
|
register int nread;
|
||||||
@@ -88,8 +87,7 @@ skip(dist, fd, fname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void cmp()
|
||||||
cmp()
|
|
||||||
{
|
{
|
||||||
register u_char *C1, *C2; /* traveling pointers */
|
register u_char *C1, *C2; /* traveling pointers */
|
||||||
register int cnt, /* counter */
|
register int cnt, /* counter */
|
||||||
@@ -99,7 +97,7 @@ cmp()
|
|||||||
short dfound = NO; /* if difference found */
|
short dfound = NO; /* if difference found */
|
||||||
|
|
||||||
for (byte = 0, line = 1;;) {
|
for (byte = 0, line = 1;;) {
|
||||||
switch(len1 = read(fd1, buf1, MAXBSIZE)) {
|
switch (len1 = read(fd1, buf1, MAXBSIZE)) {
|
||||||
case -1:
|
case -1:
|
||||||
error(file1);
|
error(file1);
|
||||||
case 0:
|
case 0:
|
||||||
@@ -107,7 +105,7 @@ cmp()
|
|||||||
* read of file 1 just failed, find out
|
* read of file 1 just failed, find out
|
||||||
* if there's anything left in file 2
|
* if there's anything left in file 2
|
||||||
*/
|
*/
|
||||||
switch(read(fd2, buf2, 1)) {
|
switch (read(fd2, buf2, 1)) {
|
||||||
case -1:
|
case -1:
|
||||||
error(file2);
|
error(file2);
|
||||||
case 0:
|
case 0:
|
||||||
@@ -133,8 +131,8 @@ cmp()
|
|||||||
if (*C1 != *C2)
|
if (*C1 != *C2)
|
||||||
printf("%6ld %3o %3o\n", byte, *C1, *C2);
|
printf("%6ld %3o %3o\n", byte, *C1, *C2);
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else for (C1 = buf1, C2 = buf2;; ++C1, ++C2) {
|
for (C1 = buf1, C2 = buf2;; ++C1, ++C2) {
|
||||||
++byte;
|
++byte;
|
||||||
if (*C1 != *C2) {
|
if (*C1 != *C2) {
|
||||||
printf("%s %s differ: char %ld, line %ld\n", file1, file2, byte, line);
|
printf("%s %s differ: char %ld, line %ld\n", file1, file2, byte, line);
|
||||||
@@ -143,8 +141,7 @@ cmp()
|
|||||||
if (*C1 == '\n')
|
if (*C1 == '\n')
|
||||||
++line;
|
++line;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
byte += len2;
|
byte += len2;
|
||||||
/*
|
/*
|
||||||
* here's the real performance problem, we've got to
|
* here's the real performance problem, we've got to
|
||||||
@@ -171,9 +168,7 @@ cmp()
|
|||||||
* otoi --
|
* otoi --
|
||||||
* octal/decimal string to u_long
|
* octal/decimal string to u_long
|
||||||
*/
|
*/
|
||||||
static u_long
|
static u_long otoi(char *C)
|
||||||
otoi(C)
|
|
||||||
register char *C; /* argument string */
|
|
||||||
{
|
{
|
||||||
register u_long val; /* return value */
|
register u_long val; /* return value */
|
||||||
register int base; /* number base */
|
register int base; /* number base */
|
||||||
@@ -181,30 +176,25 @@ otoi(C)
|
|||||||
base = (*C == '0') ? 8 : 10;
|
base = (*C == '0') ? 8 : 10;
|
||||||
for (val = 0; isdigit(*C); ++C)
|
for (val = 0; isdigit(*C); ++C)
|
||||||
val = val * base + *C - '0';
|
val = val * base + *C - '0';
|
||||||
return(val);
|
return (val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* usage --
|
* usage --
|
||||||
* print usage and die
|
* print usage and die
|
||||||
*/
|
*/
|
||||||
static
|
static void usage()
|
||||||
usage()
|
|
||||||
{
|
{
|
||||||
fputs("usage: cmp [-ls] file1 file2 [skip1] [skip2]\n", stderr);
|
fputs("usage: cmp [-ls] file1 file2 [skip1] [skip2]\n", stderr);
|
||||||
exit(ERR);
|
exit(ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
main(argc, argv)
|
int main(int argc, char **argv)
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
extern char *optarg;
|
|
||||||
extern int optind;
|
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "ls")) != EOF)
|
while ((ch = getopt(argc, argv, "ls")) != EOF)
|
||||||
switch(ch) {
|
switch (ch) {
|
||||||
case 'l': /* print all differences */
|
case 'l': /* print all differences */
|
||||||
all = YES;
|
all = YES;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -18,23 +18,27 @@ int cp, lp;
|
|||||||
int ll, llh, mustwr;
|
int ll, llh, mustwr;
|
||||||
int pcp = 0;
|
int pcp = 0;
|
||||||
char *pgmname;
|
char *pgmname;
|
||||||
char *strcpy();
|
|
||||||
|
|
||||||
main (argc, argv)
|
static void incr(void);
|
||||||
|
static void decr(void);
|
||||||
|
static void outc(char c);
|
||||||
|
static void emit(char *s, int lineno);
|
||||||
|
|
||||||
|
int main(argc, argv)
|
||||||
int argc; char **argv;
|
int argc; char **argv;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int greek;
|
int greek;
|
||||||
register int c;
|
int c;
|
||||||
|
|
||||||
pgmname = argv[0];
|
pgmname = argv[0];
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
register char *p;
|
char *p;
|
||||||
if (*argv[i] != '-') {
|
if (*argv[i] != '-') {
|
||||||
fprintf (stderr, "%s: bad option %s\n",
|
fprintf(stderr, "%s: bad option %s\n",
|
||||||
pgmname, argv[i]);
|
pgmname, argv[i]);
|
||||||
exit (2);
|
exit(2);
|
||||||
}
|
}
|
||||||
for (p = argv[i]+1; *p; p++) {
|
for (p = argv[i]+1; *p; p++) {
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
@@ -51,9 +55,9 @@ main (argc, argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "%s: bad option letter %c\n",
|
fprintf(stderr, "%s: bad option letter %c\n",
|
||||||
pgmname, *p);
|
pgmname, *p);
|
||||||
exit (2);
|
exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,13 +158,12 @@ main (argc, argv)
|
|||||||
|
|
||||||
for (i=0; i<PL; i++)
|
for (i=0; i<PL; i++)
|
||||||
if (page[(mustwr+i)%PL] != 0)
|
if (page[(mustwr+i)%PL] != 0)
|
||||||
emit (page[(mustwr+i) % PL], mustwr+i-PL);
|
emit(page[(mustwr+i) % PL], mustwr+i-PL);
|
||||||
emit (" ", (llh + 1) & -2);
|
emit(" ", (llh + 1) & -2);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
outc (c)
|
void outc(char c)
|
||||||
register char c;
|
|
||||||
{
|
{
|
||||||
if (lp > cp) {
|
if (lp > cp) {
|
||||||
line = lbuff;
|
line = lbuff;
|
||||||
@@ -189,7 +192,7 @@ outc (c)
|
|||||||
if (bflag || *line == '\0' || *line == ' ')
|
if (bflag || *line == '\0' || *line == ' ')
|
||||||
*line = c;
|
*line = c;
|
||||||
else {
|
else {
|
||||||
register char c1, c2, c3;
|
char c1, c2, c3;
|
||||||
c1 = *++line;
|
c1 = *++line;
|
||||||
*line++ = '\b';
|
*line++ = '\b';
|
||||||
c2 = *line;
|
c2 = *line;
|
||||||
@@ -205,22 +208,22 @@ outc (c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
store (lno)
|
void store(lno)
|
||||||
{
|
{
|
||||||
lno %= PL;
|
lno %= PL;
|
||||||
if (page[lno] != 0)
|
if (page[lno] != 0)
|
||||||
free (page[lno]);
|
free(page[lno]);
|
||||||
page[lno] = malloc((unsigned)strlen(lbuff) + 2);
|
page[lno] = malloc((unsigned)strlen(lbuff) + 2);
|
||||||
if (page[lno] == 0) {
|
if (page[lno] == 0) {
|
||||||
fprintf (stderr, "%s: no storage\n", pgmname);
|
fprintf(stderr, "%s: no storage\n", pgmname);
|
||||||
exit (2);
|
exit(2);
|
||||||
}
|
}
|
||||||
strcpy (page[lno],lbuff);
|
strcpy(page[lno],lbuff);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch(lno)
|
void fetch(lno)
|
||||||
{
|
{
|
||||||
register char *p;
|
char *p;
|
||||||
|
|
||||||
lno %= PL;
|
lno %= PL;
|
||||||
p = lbuff;
|
p = lbuff;
|
||||||
@@ -229,30 +232,31 @@ fetch(lno)
|
|||||||
line = lbuff;
|
line = lbuff;
|
||||||
lp = 0;
|
lp = 0;
|
||||||
if (page[lno])
|
if (page[lno])
|
||||||
strcpy (line, page[lno]);
|
strcpy(line, page[lno]);
|
||||||
}
|
}
|
||||||
emit (s, lineno)
|
|
||||||
|
void emit(s, lineno)
|
||||||
char *s;
|
char *s;
|
||||||
int lineno;
|
int lineno;
|
||||||
{
|
{
|
||||||
static int cline = 0;
|
static int cline = 0;
|
||||||
register int ncp;
|
int ncp;
|
||||||
register char *p;
|
char *p;
|
||||||
static int gflag = 0;
|
static int gflag = 0;
|
||||||
|
|
||||||
if (*s) {
|
if (*s) {
|
||||||
while (cline < lineno - 1) {
|
while (cline < lineno - 1) {
|
||||||
putchar ('\n');
|
putchar('\n');
|
||||||
pcp = 0;
|
pcp = 0;
|
||||||
cline += 2;
|
cline += 2;
|
||||||
}
|
}
|
||||||
if (cline != lineno) {
|
if (cline != lineno) {
|
||||||
putchar (ESC);
|
putchar(ESC);
|
||||||
putchar ('9');
|
putchar('9');
|
||||||
cline++;
|
cline++;
|
||||||
}
|
}
|
||||||
if (pcp)
|
if (pcp)
|
||||||
putchar ('\r');
|
putchar('\r');
|
||||||
pcp = 0;
|
pcp = 0;
|
||||||
p = s;
|
p = s;
|
||||||
while (*p) {
|
while (*p) {
|
||||||
@@ -260,23 +264,23 @@ emit (s, lineno)
|
|||||||
while (*p++ == ' ') {
|
while (*p++ == ' ') {
|
||||||
if ((++ncp & 7) == 0 && hflag) {
|
if ((++ncp & 7) == 0 && hflag) {
|
||||||
pcp = ncp;
|
pcp = ncp;
|
||||||
putchar ('\t');
|
putchar('\t');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!*--p)
|
if (!*--p)
|
||||||
break;
|
break;
|
||||||
while (pcp < ncp) {
|
while (pcp < ncp) {
|
||||||
putchar (' ');
|
putchar(' ');
|
||||||
pcp++;
|
pcp++;
|
||||||
}
|
}
|
||||||
if (gflag != (*p & GREEK) && *p != '\b') {
|
if (gflag != (*p & GREEK) && *p != '\b') {
|
||||||
if (gflag)
|
if (gflag)
|
||||||
putchar (SI);
|
putchar(SI);
|
||||||
else
|
else
|
||||||
putchar (SO);
|
putchar(SO);
|
||||||
gflag ^= GREEK;
|
gflag ^= GREEK;
|
||||||
}
|
}
|
||||||
putchar (*p & ~GREEK);
|
putchar(*p & ~GREEK);
|
||||||
if (*p++ == '\b')
|
if (*p++ == '\b')
|
||||||
pcp--;
|
pcp--;
|
||||||
else
|
else
|
||||||
@@ -285,24 +289,24 @@ emit (s, lineno)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
incr()
|
void incr()
|
||||||
{
|
{
|
||||||
store (ll++);
|
store(ll++);
|
||||||
if (ll > llh)
|
if (ll > llh)
|
||||||
llh = ll;
|
llh = ll;
|
||||||
if (ll >= mustwr && page[ll%PL]) {
|
if (ll >= mustwr && page[ll%PL]) {
|
||||||
emit (page[ll%PL], ll - PL);
|
emit(page[ll%PL], ll - PL);
|
||||||
mustwr++;
|
mustwr++;
|
||||||
free (page[ll%PL]);
|
free(page[ll%PL]);
|
||||||
page[ll%PL] = 0;
|
page[ll%PL] = 0;
|
||||||
}
|
}
|
||||||
fetch (ll);
|
fetch(ll);
|
||||||
}
|
}
|
||||||
|
|
||||||
decr()
|
void decr()
|
||||||
{
|
{
|
||||||
if (ll > mustwr - PL) {
|
if (ll > mustwr - PL) {
|
||||||
store (ll--);
|
store(ll--);
|
||||||
fetch (ll);
|
fetch(ll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
140
src/cmd/comm.c
140
src/cmd/comm.c
@@ -11,30 +11,34 @@ char *ldr[3];
|
|||||||
|
|
||||||
FILE *ib1;
|
FILE *ib1;
|
||||||
FILE *ib2;
|
FILE *ib2;
|
||||||
FILE *openfil();
|
|
||||||
main(argc,argv)
|
static FILE *openfil(char *s);
|
||||||
char *argv[];
|
static int rd(FILE *file, char *buf);
|
||||||
|
static void wr(char *str, int n);
|
||||||
|
static void copy(FILE *ibuf, char *lbuf, int n);
|
||||||
|
static int compare(char *a, char *b);
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int l;
|
int l;
|
||||||
char lb1[LB],lb2[LB];
|
char lb1[LB], lb2[LB];
|
||||||
|
|
||||||
ldr[0] = "";
|
ldr[0] = "";
|
||||||
ldr[1] = "\t";
|
ldr[1] = "\t";
|
||||||
ldr[2] = "\t\t";
|
ldr[2] = "\t\t";
|
||||||
if(argc > 1) {
|
if (argc > 1) {
|
||||||
if(*argv[1] == '-' && argv[1][1] != 0) {
|
if (*argv[1] == '-' && argv[1][1] != 0) {
|
||||||
l = 1;
|
l = 1;
|
||||||
while(*++argv[1]) {
|
while (*++argv[1]) {
|
||||||
switch(*argv[1]) {
|
switch (*argv[1]) {
|
||||||
case'1':
|
case '1':
|
||||||
if(!one) {
|
if (!one) {
|
||||||
one = 1;
|
one = 1;
|
||||||
ldr[1][0] =
|
ldr[1][0] = ldr[2][l--] = '\0';
|
||||||
ldr[2][l--] = '\0';
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
if(!two) {
|
if (!two) {
|
||||||
two = 1;
|
two = 1;
|
||||||
ldr[2][l--] = '\0';
|
ldr[2][l--] = '\0';
|
||||||
}
|
}
|
||||||
@@ -43,7 +47,7 @@ char *argv[];
|
|||||||
three = 1;
|
three = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"comm: illegal flag\n");
|
fprintf(stderr, "comm: illegal flag\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,118 +56,118 @@ char *argv[];
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(argc < 3) {
|
if (argc < 3) {
|
||||||
fprintf(stderr,"comm: arg count\n");
|
fprintf(stderr, "comm: arg count\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ib1 = openfil(argv[1]);
|
ib1 = openfil(argv[1]);
|
||||||
ib2 = openfil(argv[2]);
|
ib2 = openfil(argv[2]);
|
||||||
|
|
||||||
|
if (rd(ib1, lb1) < 0) {
|
||||||
if(rd(ib1,lb1) < 0) {
|
if (rd(ib2, lb2) < 0)
|
||||||
if(rd(ib2,lb2) < 0) exit(0);
|
exit(0);
|
||||||
copy(ib2,lb2,2);
|
copy(ib2, lb2, 2);
|
||||||
}
|
}
|
||||||
if(rd(ib2,lb2) < 0) copy(ib1,lb1,1);
|
if (rd(ib2, lb2) < 0)
|
||||||
|
copy(ib1, lb1, 1);
|
||||||
while(1) {
|
|
||||||
|
|
||||||
switch(compare(lb1,lb2)) {
|
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
switch (compare(lb1, lb2)) {
|
||||||
case 0:
|
case 0:
|
||||||
wr(lb1,3);
|
wr(lb1, 3);
|
||||||
if(rd(ib1,lb1) < 0) {
|
if (rd(ib1, lb1) < 0) {
|
||||||
if(rd(ib2,lb2) < 0) exit(0);
|
if (rd(ib2, lb2) < 0)
|
||||||
copy(ib2,lb2,2);
|
exit(0);
|
||||||
|
copy(ib2, lb2, 2);
|
||||||
}
|
}
|
||||||
if(rd(ib2,lb2) < 0) copy(ib1,lb1,1);
|
if (rd(ib2, lb2) < 0)
|
||||||
|
copy(ib1, lb1, 1);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
wr(lb1,1);
|
wr(lb1, 1);
|
||||||
if(rd(ib1,lb1) < 0) copy(ib2,lb2,2);
|
if (rd(ib1, lb1) < 0)
|
||||||
|
copy(ib2, lb2, 2);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
wr(lb2,2);
|
wr(lb2, 2);
|
||||||
if(rd(ib2,lb2) < 0) copy(ib1,lb1,1);
|
if (rd(ib2, lb2) < 0)
|
||||||
|
copy(ib1, lb1, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rd(file,buf)
|
int rd(FILE *file, char *buf)
|
||||||
FILE *file;
|
|
||||||
char *buf;
|
|
||||||
{
|
{
|
||||||
|
int i, c;
|
||||||
|
|
||||||
register int i, c;
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while((c = getc(file)) != EOF) {
|
while ((c = getc(file)) != EOF) {
|
||||||
*buf = c;
|
*buf = c;
|
||||||
if(c == '\n' || i > LB-2) {
|
if (c == '\n' || i > LB - 2) {
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
buf++;
|
buf++;
|
||||||
}
|
}
|
||||||
return(-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
wr(str,n)
|
void wr(char *str, int n)
|
||||||
char *str;
|
|
||||||
{
|
{
|
||||||
|
switch (n) {
|
||||||
switch(n) {
|
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if(one) return;
|
if (one)
|
||||||
|
return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if(two) return;
|
if (two)
|
||||||
|
return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if(three) return;
|
if (three)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
printf("%s%s\n",ldr[n-1],str);
|
printf("%s%s\n", ldr[n - 1], str);
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(ibuf,lbuf,n)
|
void copy(FILE *ibuf, char *lbuf, int n)
|
||||||
FILE *ibuf;
|
|
||||||
char *lbuf;
|
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
wr(lbuf,n);
|
wr(lbuf, n);
|
||||||
} while(rd(ibuf,lbuf) >= 0);
|
} while (rd(ibuf, lbuf) >= 0);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
compare(a,b)
|
int compare(char *a, char *b)
|
||||||
char *a,*b;
|
|
||||||
{
|
{
|
||||||
register char *ra,*rb;
|
char *ra, *rb;
|
||||||
|
|
||||||
ra = --a;
|
ra = --a;
|
||||||
rb = --b;
|
rb = --b;
|
||||||
while(*++ra == *++rb)
|
while (*++ra == *++rb)
|
||||||
if(*ra == '\0') return(0);
|
if (*ra == '\0')
|
||||||
if(*ra < *rb) return(1);
|
return (0);
|
||||||
return(2);
|
if (*ra < *rb)
|
||||||
|
return (1);
|
||||||
|
return (2);
|
||||||
}
|
}
|
||||||
FILE *openfil(s)
|
|
||||||
char *s;
|
FILE *openfil(char *s)
|
||||||
{
|
{
|
||||||
FILE *b;
|
FILE *b;
|
||||||
if(s[0]=='-' && s[1]==0)
|
if (s[0] == '-' && s[1] == 0)
|
||||||
b = stdin;
|
b = stdin;
|
||||||
else if((b=fopen(s,"r")) == NULL) {
|
else if ((b = fopen(s, "r")) == NULL) {
|
||||||
perror(s);
|
perror(s);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return(b);
|
return (b);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ OBJS = compress.o
|
|||||||
CFLAGS += -DUSERMEM=1024 -Wall -Werror
|
CFLAGS += -DUSERMEM=1024 -Wall -Werror
|
||||||
|
|
||||||
compress: $(OBJS)
|
compress: $(OBJS)
|
||||||
${CC} ${LDFLAGS} -o $@.elf ${OBJS} ${LIBS}
|
${LD} ${LDFLAGS} -o $@.elf ${OBJS} ${LIBS}
|
||||||
${OBJDUMP} -S $@.elf > $@.dis
|
${OBJDUMP} -S $@.elf > $@.dis
|
||||||
${SIZE} $@.elf
|
${SIZE} $@.elf
|
||||||
${ELF2AOUT} $@.elf $@
|
${ELF2AOUT} $@.elf $@
|
||||||
|
|||||||
15
src/cmd/cp.c
15
src/cmd/cp.c
@@ -11,6 +11,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/dir.h>
|
#include <sys/dir.h>
|
||||||
@@ -20,7 +22,12 @@ int iflag;
|
|||||||
int rflag;
|
int rflag;
|
||||||
int pflag;
|
int pflag;
|
||||||
|
|
||||||
main(argc, argv)
|
static void Perror(char *s);
|
||||||
|
static int copy(char *from, char *to);
|
||||||
|
static int rcopy(char *from, char *to);
|
||||||
|
static int setimes(char *path, struct stat *statp);
|
||||||
|
|
||||||
|
int main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
@@ -67,7 +74,7 @@ usage:
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(from, to)
|
int copy(from, to)
|
||||||
char *from, *to;
|
char *from, *to;
|
||||||
{
|
{
|
||||||
int fold, fnew, n, exists;
|
int fold, fnew, n, exists;
|
||||||
@@ -172,7 +179,7 @@ copy(from, to)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
rcopy(from, to)
|
int rcopy(from, to)
|
||||||
char *from, *to;
|
char *from, *to;
|
||||||
{
|
{
|
||||||
DIR *fold = opendir(from);
|
DIR *fold = opendir(from);
|
||||||
@@ -225,7 +232,7 @@ setimes(path, statp)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Perror(s)
|
void Perror(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
fprintf(stderr, "cp: ");
|
fprintf(stderr, "cp: ");
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ CFLAGS += -DGCC_COMPAT -DHAVE_CPP_VARARG_MACRO_GCC
|
|||||||
all: cpp $(MAN)
|
all: cpp $(MAN)
|
||||||
|
|
||||||
cpp: $(OBJS)
|
cpp: $(OBJS)
|
||||||
${CC} ${LDFLAGS} -o cpp.elf $(OBJS) ${LIBS}
|
${LD} ${LDFLAGS} -o cpp.elf $(OBJS) ${LIBS}
|
||||||
${OBJDUMP} -S cpp.elf > cpp.dis
|
${OBJDUMP} -S cpp.elf > cpp.dis
|
||||||
${SIZE} cpp.elf
|
${SIZE} cpp.elf
|
||||||
${ELF2AOUT} cpp.elf $@ && rm cpp.elf
|
${ELF2AOUT} cpp.elf $@ && rm cpp.elf
|
||||||
|
|||||||
4
src/cmd/cron/Makefile
Executable file → Normal file
4
src/cmd/cron/Makefile
Executable file → Normal file
@@ -84,13 +84,13 @@ lint:
|
|||||||
|grep -v "constant argument to NOT" 2>&1
|
|grep -v "constant argument to NOT" 2>&1
|
||||||
|
|
||||||
cron: $(CRON_OBJ)
|
cron: $(CRON_OBJ)
|
||||||
${CC} ${LDFLAGS} -o $@.elf ${CRON_OBJ} ${LIBS}
|
${LD} ${LDFLAGS} -o $@.elf ${CRON_OBJ} ${LIBS}
|
||||||
${OBJDUMP} -S $@.elf > $@.dis
|
${OBJDUMP} -S $@.elf > $@.dis
|
||||||
${SIZE} $@.elf
|
${SIZE} $@.elf
|
||||||
${ELF2AOUT} $@.elf $@
|
${ELF2AOUT} $@.elf $@
|
||||||
|
|
||||||
crontab: $(CRONTAB_OBJ)
|
crontab: $(CRONTAB_OBJ)
|
||||||
${CC} ${LDFLAGS} -o $@.elf ${CRONTAB_OBJ} ${LIBS}
|
${LD} ${LDFLAGS} -o $@.elf ${CRONTAB_OBJ} ${LIBS}
|
||||||
${OBJDUMP} -S $@.elf > $@.dis
|
${OBJDUMP} -S $@.elf > $@.dis
|
||||||
${SIZE} $@.elf
|
${SIZE} $@.elf
|
||||||
${ELF2AOUT} $@.elf $@
|
${ELF2AOUT} $@.elf $@
|
||||||
|
|||||||
0
src/cmd/cron/README
Executable file → Normal file
0
src/cmd/cron/README
Executable file → Normal file
0
src/cmd/cron/README.2BSD
Executable file → Normal file
0
src/cmd/cron/README.2BSD
Executable file → Normal file
0
src/cmd/cron/bitstring.3
Executable file → Normal file
0
src/cmd/cron/bitstring.3
Executable file → Normal file
0
src/cmd/cron/bitstring.h
Executable file → Normal file
0
src/cmd/cron/bitstring.h
Executable file → Normal file
15
src/cmd/cron/compat.c
Executable file → Normal file
15
src/cmd/cron/compat.c
Executable file → Normal file
@@ -15,15 +15,9 @@
|
|||||||
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(lint) && !defined(LINT)
|
|
||||||
static char rcsid[] = "$Id: compat.c,v 1.6 1994/01/15 20:43:43 vixie Exp $";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* vix 30dec93 [broke this out of misc.c - see RCS log for history]
|
/* vix 30dec93 [broke this out of misc.c - see RCS log for history]
|
||||||
* vix 15jan87 [added TIOCNOTTY, thanks csg@pyramid]
|
* vix 15jan87 [added TIOCNOTTY, thanks csg@pyramid]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "cron.h"
|
#include "cron.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -40,14 +34,13 @@ setsid()
|
|||||||
int newpgrp;
|
int newpgrp;
|
||||||
register int fd;
|
register int fd;
|
||||||
|
|
||||||
newpgrp = setpgrp(0, getpid());
|
newpgrp = setpgrp();
|
||||||
if ((fd = open(_PATH_TTY, 2)) >= 0)
|
|
||||||
{
|
if ((fd = open(_PATH_TTY, 2)) >= 0) {
|
||||||
(void) ioctl(fd, TIOCNOTTY, (char*)0);
|
(void) ioctl(fd, TIOCNOTTY, (char*)0);
|
||||||
(void) close(fd);
|
(void) close(fd);
|
||||||
}
|
}
|
||||||
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1)
|
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
|
||||||
{
|
|
||||||
(void)dup2(fd, 0);
|
(void)dup2(fd, 0);
|
||||||
(void)dup2(fd, 1);
|
(void)dup2(fd, 1);
|
||||||
(void)dup2(fd, 2);
|
(void)dup2(fd, 2);
|
||||||
|
|||||||
6
src/cmd/cron/compat.h
Executable file → Normal file
6
src/cmd/cron/compat.h
Executable file → Normal file
@@ -15,13 +15,9 @@
|
|||||||
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* $Id: compat.h,v 1.8 1994/01/15 20:43:43 vixie Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __P
|
#ifndef __P
|
||||||
#define __P(x) ()
|
#define __P(x) ()
|
||||||
#define const
|
//#define const
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
|
|||||||
16
src/cmd/cron/config.h
Executable file → Normal file
16
src/cmd/cron/config.h
Executable file → Normal file
@@ -20,10 +20,6 @@
|
|||||||
* $Id: config.h,v 2.6 1994/01/15 20:43:43 vixie Exp $
|
* $Id: config.h,v 2.6 1994/01/15 20:43:43 vixie Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(_PATH_SENDMAIL)
|
|
||||||
# define _PATH_SENDMAIL "/usr/lib/sendmail"
|
|
||||||
#endif /*SENDMAIL*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* these are site-dependent
|
* these are site-dependent
|
||||||
*/
|
*/
|
||||||
@@ -49,15 +45,15 @@
|
|||||||
* -or0s = Option Readtimeout -- don't time out
|
* -or0s = Option Readtimeout -- don't time out
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* #define MAILCMD "/bin/mail" /*-*/
|
// #define MAILCMD "/bin/mail" /*-*/
|
||||||
/* #define MAILARGS "%s -d %s" /*-*/
|
// #define MAILARGS "%s -d %s" /*-*/
|
||||||
/* -d = undocumented but common flag: deliver locally?
|
/* -d = undocumented but common flag: deliver locally?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* #define MAILCMD "/usr/mmdf/bin/submit" /*-*/
|
// #define MAILCMD "/usr/mmdf/bin/submit" /*-*/
|
||||||
/* #define MAILARGS "%s -mlrxto %s" /*-*/
|
// #define MAILARGS "%s -mlrxto %s" /*-*/
|
||||||
|
|
||||||
/* #define MAIL_DATE /*-*/
|
// #define MAIL_DATE /*-*/
|
||||||
/* should we include an ersatz Date: header in
|
/* should we include an ersatz Date: header in
|
||||||
* generated mail? if you are using sendmail
|
* generated mail? if you are using sendmail
|
||||||
* for MAILCMD, it is better to let sendmail
|
* for MAILCMD, it is better to let sendmail
|
||||||
@@ -68,7 +64,7 @@
|
|||||||
* defined but neither exists, should crontab(1) be
|
* defined but neither exists, should crontab(1) be
|
||||||
* usable only by root?
|
* usable only by root?
|
||||||
*/
|
*/
|
||||||
/*#define ALLOW_ONLY_ROOT /*-*/
|
//#define ALLOW_ONLY_ROOT /*-*/
|
||||||
|
|
||||||
/* if you want to use syslog(3) instead of appending
|
/* if you want to use syslog(3) instead of appending
|
||||||
* to CRONDIR/LOG_FILE (/var/cron/log, e.g.), define
|
* to CRONDIR/LOG_FILE (/var/cron/log, e.g.), define
|
||||||
|
|||||||
0
src/cmd/cron/cron.8
Executable file → Normal file
0
src/cmd/cron/cron.8
Executable file → Normal file
5
src/cmd/cron/cron.c
Executable file → Normal file
5
src/cmd/cron/cron.c
Executable file → Normal file
@@ -14,11 +14,6 @@
|
|||||||
* I'll try to keep a version up to date. I can be reached as follows:
|
* I'll try to keep a version up to date. I can be reached as follows:
|
||||||
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(lint) && defined(DOSCCS)
|
|
||||||
static char sccsid[] = "@(#)cron.c 2.11.1 (2.11BSD) 1999/08/05";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAIN_PROGRAM
|
#define MAIN_PROGRAM
|
||||||
|
|
||||||
#include "cron.h"
|
#include "cron.h"
|
||||||
|
|||||||
4
src/cmd/cron/cron.h
Executable file → Normal file
4
src/cmd/cron/cron.h
Executable file → Normal file
@@ -150,7 +150,7 @@ typedef struct _entry {
|
|||||||
char **envp;
|
char **envp;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
bitstr_t bit_decl(minute, MINUTE_COUNT);
|
bitstr_t bit_decl(minute, MINUTE_COUNT);
|
||||||
bitstr_t bit_decl(hour, HOUR_COUNT);
|
bitstr_t bit_decl(hour, HOUR_COUNT+1);
|
||||||
bitstr_t bit_decl(dom, DOM_COUNT);
|
bitstr_t bit_decl(dom, DOM_COUNT);
|
||||||
bitstr_t bit_decl(month, MONTH_COUNT);
|
bitstr_t bit_decl(month, MONTH_COUNT);
|
||||||
bitstr_t bit_decl(dow, DOW_COUNT);
|
bitstr_t bit_decl(dow, DOW_COUNT);
|
||||||
@@ -273,3 +273,5 @@ extern int DebugFlags;
|
|||||||
extern char *DebugFlagNames[];
|
extern char *DebugFlagNames[];
|
||||||
# endif /* DEBUGGING */
|
# endif /* DEBUGGING */
|
||||||
#endif /*MAIN_PROGRAM*/
|
#endif /*MAIN_PROGRAM*/
|
||||||
|
|
||||||
|
int swap_uids_back(void);
|
||||||
|
|||||||
0
src/cmd/cron/crontab.1
Executable file → Normal file
0
src/cmd/cron/crontab.1
Executable file → Normal file
0
src/cmd/cron/crontab.5
Executable file → Normal file
0
src/cmd/cron/crontab.5
Executable file → Normal file
2
src/cmd/cron/crontab.c
Executable file → Normal file
2
src/cmd/cron/crontab.c
Executable file → Normal file
@@ -21,7 +21,6 @@ static char sccsid[] = "@(#) crontab.c 2.13.1 (2.11BSD) 1999/8/9";
|
|||||||
* vix 02may87 [RCS has the rest of the log]
|
* vix 02may87 [RCS has the rest of the log]
|
||||||
* vix 26jan87 [original]
|
* vix 26jan87 [original]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAIN_PROGRAM
|
#define MAIN_PROGRAM
|
||||||
|
|
||||||
#include "cron.h"
|
#include "cron.h"
|
||||||
@@ -96,6 +95,7 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
exitstatus = OK_EXIT;
|
exitstatus = OK_EXIT;
|
||||||
switch (Option) {
|
switch (Option) {
|
||||||
|
case opt_unknown: break;
|
||||||
case opt_list: list_cmd();
|
case opt_list: list_cmd();
|
||||||
break;
|
break;
|
||||||
case opt_delete: delete_cmd();
|
case opt_delete: delete_cmd();
|
||||||
|
|||||||
6
src/cmd/cron/database.c
Executable file → Normal file
6
src/cmd/cron/database.c
Executable file → Normal file
@@ -15,14 +15,8 @@
|
|||||||
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(lint) && !defined(LINT)
|
|
||||||
static char rcsid[] = "$Id: database.c,v 2.8 1994/01/15 20:43:43 vixie Exp $";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* vix 26jan87 [RCS has the log]
|
/* vix 26jan87 [RCS has the log]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "cron.h"
|
#include "cron.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|||||||
12
src/cmd/cron/do_command.c
Executable file → Normal file
12
src/cmd/cron/do_command.c
Executable file → Normal file
@@ -14,13 +14,9 @@
|
|||||||
* I'll try to keep a version up to date. I can be reached as follows:
|
* I'll try to keep a version up to date. I can be reached as follows:
|
||||||
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(lint) && !defined(LINT)
|
|
||||||
static char rcsid[] = "$Id: do_command.c,v 2.12 1994/01/15 20:43:43 vixie Exp $";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cron.h"
|
#include "cron.h"
|
||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
|
#include <grp.h>
|
||||||
#if defined(SYSLOG)
|
#if defined(SYSLOG)
|
||||||
# include <syslog.h>
|
# include <syslog.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -77,7 +73,7 @@ child_process(e, u)
|
|||||||
/* mark ourselves as different to PS command watchers by upshifting
|
/* mark ourselves as different to PS command watchers by upshifting
|
||||||
* our program name. This has no effect on some kernels.
|
* our program name. This has no effect on some kernels.
|
||||||
*/
|
*/
|
||||||
for (input_data = ProgramName; ch = *input_data; input_data++)
|
for (input_data = ProgramName; (ch = *input_data); input_data++)
|
||||||
*input_data = (islower(ch) ? toupper(ch) : ch);
|
*input_data = (islower(ch) ? toupper(ch) : ch);
|
||||||
|
|
||||||
/* discover some useful and important environment settings
|
/* discover some useful and important environment settings
|
||||||
@@ -106,7 +102,7 @@ child_process(e, u)
|
|||||||
* but that happens later.
|
* but that happens later.
|
||||||
*/
|
*/
|
||||||
escaped = FALSE;
|
escaped = FALSE;
|
||||||
for (input_data = e->cmd; ch = *input_data; input_data++) {
|
for (input_data = e->cmd; (ch = *input_data); input_data++) {
|
||||||
if (escaped) {
|
if (escaped) {
|
||||||
escaped = FALSE;
|
escaped = FALSE;
|
||||||
continue;
|
continue;
|
||||||
@@ -251,7 +247,7 @@ child_process(e, u)
|
|||||||
* % -> \n
|
* % -> \n
|
||||||
* \x -> \x for all x != %
|
* \x -> \x for all x != %
|
||||||
*/
|
*/
|
||||||
while (ch = *input_data++) {
|
while ((ch = *input_data++)) {
|
||||||
if (escaped) {
|
if (escaped) {
|
||||||
if (ch != '%')
|
if (ch != '%')
|
||||||
putc('\\', out);
|
putc('\\', out);
|
||||||
|
|||||||
5
src/cmd/cron/entry.c
Executable file → Normal file
5
src/cmd/cron/entry.c
Executable file → Normal file
@@ -15,10 +15,6 @@
|
|||||||
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(lint) && defined(DOSCCS)
|
|
||||||
static char sccsid[] = "@(#)entry.c 2.12.2 (2.11BSD) 1999/08/05";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* vix 26jan87 [RCS'd; rest of log is in RCS file]
|
/* vix 26jan87 [RCS'd; rest of log is in RCS file]
|
||||||
* vix 01jan87 [added line-level error recovery]
|
* vix 01jan87 [added line-level error recovery]
|
||||||
* vix 31dec86 [added /step to the from-to range, per bob@acornrc]
|
* vix 31dec86 [added /step to the from-to range, per bob@acornrc]
|
||||||
@@ -26,6 +22,7 @@ static char sccsid[] = "@(#)entry.c 2.12.2 (2.11BSD) 1999/08/05";
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cron.h"
|
#include "cron.h"
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
typedef enum ecode {
|
typedef enum ecode {
|
||||||
e_none, e_minute, e_hour, e_dom, e_month, e_dow,
|
e_none, e_minute, e_hour, e_dom, e_month, e_dow,
|
||||||
|
|||||||
9
src/cmd/cron/env.c
Executable file → Normal file
9
src/cmd/cron/env.c
Executable file → Normal file
@@ -14,15 +14,8 @@
|
|||||||
* I'll try to keep a version up to date. I can be reached as follows:
|
* I'll try to keep a version up to date. I can be reached as follows:
|
||||||
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(lint) && !defined(LINT)
|
|
||||||
static char rcsid[] = "$Id: env.c,v 2.7 1994/01/26 02:25:50 vixie Exp vixie $";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include "cron.h"
|
#include "cron.h"
|
||||||
|
|
||||||
|
|
||||||
char **
|
char **
|
||||||
env_init()
|
env_init()
|
||||||
{
|
{
|
||||||
@@ -168,7 +161,7 @@ env_get(name, envp)
|
|||||||
register int len = strlen(name);
|
register int len = strlen(name);
|
||||||
register char *p, *q;
|
register char *p, *q;
|
||||||
|
|
||||||
while (p = *envp++) {
|
while ((p = *envp++)) {
|
||||||
if (!(q = strchr(p, '=')))
|
if (!(q = strchr(p, '=')))
|
||||||
continue;
|
continue;
|
||||||
if ((q - p) == len && !strncmp(p, name, len))
|
if ((q - p) == len && !strncmp(p, name, len))
|
||||||
|
|||||||
6
src/cmd/cron/externs.h
Executable file → Normal file
6
src/cmd/cron/externs.h
Executable file → Normal file
@@ -14,15 +14,9 @@
|
|||||||
* I'll try to keep a version up to date. I can be reached as follows:
|
* I'll try to keep a version up to date. I can be reached as follows:
|
||||||
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/dir.h>
|
#include <sys/dir.h>
|
||||||
|
|
||||||
#define DIR_T struct direct
|
#define DIR_T struct direct
|
||||||
//#define WEXITSTATUS(x) ((x).w_retcode)
|
|
||||||
//#define WTERMSIG(x) ((x).w_termsig)
|
|
||||||
//#define WCOREDUMP(x) ((x).w_coredump)
|
|
||||||
|
|
||||||
extern int setsid __P((void));
|
|
||||||
|
|||||||
0
src/cmd/cron/grot/CHANGES
Executable file → Normal file
0
src/cmd/cron/grot/CHANGES
Executable file → Normal file
0
src/cmd/cron/grot/CONVERSION
Executable file → Normal file
0
src/cmd/cron/grot/CONVERSION
Executable file → Normal file
0
src/cmd/cron/grot/FEATURES
Executable file → Normal file
0
src/cmd/cron/grot/FEATURES
Executable file → Normal file
0
src/cmd/cron/grot/INSTALL
Executable file → Normal file
0
src/cmd/cron/grot/INSTALL
Executable file → Normal file
0
src/cmd/cron/grot/MAIL
Executable file → Normal file
0
src/cmd/cron/grot/MAIL
Executable file → Normal file
0
src/cmd/cron/grot/MANIFEST
Executable file → Normal file
0
src/cmd/cron/grot/MANIFEST
Executable file → Normal file
0
src/cmd/cron/grot/THANKS
Executable file → Normal file
0
src/cmd/cron/grot/THANKS
Executable file → Normal file
0
src/cmd/cron/grot/diffs
Executable file → Normal file
0
src/cmd/cron/grot/diffs
Executable file → Normal file
7
src/cmd/cron/job.c
Executable file → Normal file
7
src/cmd/cron/job.c
Executable file → Normal file
@@ -14,15 +14,8 @@
|
|||||||
* I'll try to keep a version up to date. I can be reached as follows:
|
* I'll try to keep a version up to date. I can be reached as follows:
|
||||||
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(lint) && !defined(LINT)
|
|
||||||
static char rcsid[] = "$Id: job.c,v 1.6 1994/01/15 20:43:43 vixie Exp $";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include "cron.h"
|
#include "cron.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct _job {
|
typedef struct _job {
|
||||||
struct _job *next;
|
struct _job *next;
|
||||||
entry *e;
|
entry *e;
|
||||||
|
|||||||
6
src/cmd/cron/misc.c
Executable file → Normal file
6
src/cmd/cron/misc.c
Executable file → Normal file
@@ -15,15 +15,9 @@
|
|||||||
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(lint) && !defined(LINT)
|
|
||||||
static char rcsid[] = "$Id: misc.c,v 2.9 1994/01/15 20:43:43 vixie Exp $";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* vix 26jan87 [RCS has the rest of the log]
|
/* vix 26jan87 [RCS has the rest of the log]
|
||||||
* vix 30dec86 [written]
|
* vix 30dec86 [written]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "cron.h"
|
#include "cron.h"
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
|||||||
0
src/cmd/cron/pathnames.h
Executable file → Normal file
0
src/cmd/cron/pathnames.h
Executable file → Normal file
5
src/cmd/cron/popen.c
Executable file → Normal file
5
src/cmd/cron/popen.c
Executable file → Normal file
@@ -22,11 +22,6 @@
|
|||||||
/* this came out of the ftpd sources; it's been modified to avoid the
|
/* this came out of the ftpd sources; it's been modified to avoid the
|
||||||
* globbing stuff since we don't need it. also execvp instead of execv.
|
* globbing stuff since we don't need it. also execvp instead of execv.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(lint) && defined(DOSCCS)
|
|
||||||
static char sccsid[] = "@(#)popen.c 5.7.2 (2.11BSD) 1999/08/05";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cron.h"
|
#include "cron.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
|
|||||||
0
src/cmd/cron/putman.sh
Executable file → Normal file
0
src/cmd/cron/putman.sh
Executable file → Normal file
7
src/cmd/cron/user.c
Executable file → Normal file
7
src/cmd/cron/user.c
Executable file → Normal file
@@ -15,17 +15,10 @@
|
|||||||
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(lint) && !defined(LINT)
|
|
||||||
static char rcsid[] = "$Id: user.c,v 2.8 1994/01/15 20:43:43 vixie Exp $";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* vix 26jan87 [log is in RCS file]
|
/* vix 26jan87 [log is in RCS file]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "cron.h"
|
#include "cron.h"
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
free_user(u)
|
free_user(u)
|
||||||
user *u;
|
user *u;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ OBJS = alloc.o printf.o sh.char.o sh.dir.o sh.dol.o \
|
|||||||
all: csh
|
all: csh
|
||||||
|
|
||||||
csh: ${OBJS}
|
csh: ${OBJS}
|
||||||
${CC} ${LDFLAGS} -o csh.elf ${OBJS} ${LIBS}
|
${LD} ${LDFLAGS} -o csh.elf ${OBJS} ${LIBS}
|
||||||
${OBJDUMP} -S csh.elf > csh.dis
|
${OBJDUMP} -S csh.elf > csh.dis
|
||||||
${SIZE} csh.elf
|
${SIZE} csh.elf
|
||||||
${ELF2AOUT} csh.elf $@ && rm csh.elf
|
${ELF2AOUT} csh.elf $@ && rm csh.elf
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user