diff options
Diffstat (limited to 'os2')
-rw-r--r-- | os2/.cvsignore | 3 | ||||
-rw-r--r-- | os2/ChangeLog | 1012 | ||||
-rw-r--r-- | os2/Makefile | 357 | ||||
-rw-r--r-- | os2/Makefile.in | 357 | ||||
-rw-r--r-- | os2/README | 50 | ||||
-rw-r--r-- | os2/config.h | 514 | ||||
-rw-r--r-- | os2/dirent.c | 180 | ||||
-rw-r--r-- | os2/dirent.h | 50 | ||||
-rw-r--r-- | os2/filesubr.c | 946 | ||||
-rw-r--r-- | os2/getpass.c | 63 | ||||
-rw-r--r-- | os2/mkdir.c | 17 | ||||
-rw-r--r-- | os2/os2inc.h | 22 | ||||
-rw-r--r-- | os2/popen.c | 385 | ||||
-rw-r--r-- | os2/popen.h | 6 | ||||
-rw-r--r-- | os2/porttcp.c | 227 | ||||
-rw-r--r-- | os2/pwd.c | 198 | ||||
-rw-r--r-- | os2/pwd.h | 70 | ||||
-rw-r--r-- | os2/rcmd.c | 76 | ||||
-rw-r--r-- | os2/rcmd.h | 40 | ||||
-rw-r--r-- | os2/run.c | 611 | ||||
-rw-r--r-- | os2/tcpip.h | 131 | ||||
-rw-r--r-- | os2/test-makefile | 40 | ||||
-rw-r--r-- | os2/waitpid.c | 36 | ||||
-rw-r--r-- | os2/watcom.mak | 153 |
24 files changed, 5544 insertions, 0 deletions
diff --git a/os2/.cvsignore b/os2/.cvsignore new file mode 100644 index 0000000..fc6daa1 --- /dev/null +++ b/os2/.cvsignore @@ -0,0 +1,3 @@ +Makefile +cvs.exe +icc.in diff --git a/os2/ChangeLog b/os2/ChangeLog new file mode 100644 index 0000000..3a2a035 --- /dev/null +++ b/os2/ChangeLog @@ -0,0 +1,1012 @@ +2005-09-01 Derek Price <derek@ximbiot.com> + + * README: Update bug-cvs email. + +2005-03-16 Derek Price <derek@ximbiot.com> + + * filesubr.c (open_file): Remove this function. + +2005-03-01 Derek Price <derek@ximbiot.com> + + * config.h: Remove obsolete timeb cruft. + +2004-10-07 Derek Price <derek@ximbiot.com> + + * Makefile.in (LIB_SOURCES): Remove stripslash.c. + (OS2_OBJECTS): Remove stripslash.obj. + +2004-09-17 Derek Price <derek@ximbiot.com> + + * stripslash.c: Remove file. + +2004-04-04 Derek Price <derek@ximbiot.com> + + * filesubr.c (isabsolute): Remove this function. + * config.h (ISABSOLUTE): Define. + +2004-02-17 Derek Price <derek@ximbiot.com> + + * run.c (quote, run_setup): Probably broke this, but not by much. + Initially changed the wrong file but left it there in case somebody + wanted to finish. Most likely only the run_add_arg function needs + to be fiddled with - the quoting has changed. + +2003-11-10 Mark D. Baushke <mdb@cvshome.org> + + * filesubr.c (xresolvepath): New function. + +2003-08-07 Derek Price <derek@ximbiot.com> + + * Makefile.in (pdf ps): New recursive targets to be ignored for + Automake's benefit. + +2003-07-16 Derek Price <derek@ximbiot.com> + + * config.h (PROTOTYPES): Remove definition. + * filesubr.c: s/PROTO//. + * run.c: Ditto. + +2002-05-28 Derek Price <derek@ximbiot.com> + + * config.h: Use standard PROTOTYPES symbol instead of non-standard + USE_PROTOTYPES. + (Patch from Alexey Mahotkin <alexm@hsys.msk.ru>.) + +2002-03-21 Derek Price <derek@ximbiot.com> + + * Makefile.in: Remove unecessary dependence on $(srcdir) to + fix the dist target. + (distdir): Use new automake generated target (copied from src). + +2003-03-19 Mark D. Baushke <mdb@cvshome.org> + + * config.h (RSH_DFLT): Default to "rsh". + +2002-12-19 Derek Price <derek@ximbiot.com> + + * Makefile.in: Remove reference to options.h. + * options.h: Remove file and move relevant content... + * config.h: ...here. + +2002-12-06 Derek Price <derek@ximbiot.com> + + * dirent.c: Replace call to realloc with a call to xrealloc and calls + to malloc with calls to xmalloc. + * popen.c: Ditto. + * pwd.c: Ditto. + * run.c: Ditto. + (Reported by Dan Peterson <dbpete@aol.com>.) + +2002-09-24 Derek Price <derek@ximbiot.com> + + * options.h: Remove prototype of STDC exit(). Move prototype of + getpass()... + * config.h: here. + +2002-08-24 Larry Jones <lawrence.jones@eds.com> + + * options.h: Remove PATCH_PROGRAM. + +2002-08-16 Derek Price <derek@ximbiot.com> + + * options.h: Remove RELATIVE_REPOS & move CVS_BADROOT... + * config.h: ...here. + +2001-09-04 Derek Price <dprice@collab.net> + + * Makefile.in: Regenerated with automake 1.5. + +2001-03-14 Derek Price <derek.price@openavenue.com> + + * Makefile.in (installcheck): New target. + +2001-02-14 Larry Jones <larry.jones@sdrc.com> + + * Makefile.in: Remove references to rtag.c & rtag.obj. + +2000-12-21 Derek Price <derek.price@openavenue.com> + + * Makefile.in: Added support for Automake targets + +1999-02-26 Jim Kingdon <http://www.cyclic.com> + + * options.h: Make RELATIVE_REPOS the default, as in + ../src/options.h.in. + Remove CVS_DIFFDATE; removed from CVS on 27 Jun 1996. + +1998-12-29 Jim Kingdon <http://www.cyclic.com> + + * Makefile.in: Use the getdate.c in ../lib rather than the one + here. I don't know whether it compiles with Watcom and/or IBM's + compiler, but having a copy of getdate.c in this directory has + proven to be unworkable (the version I am removing still had Y2K + bugs which were fixed in lib/getdate.c, for example). + * getdate.c: Removed. + +1998-04-09 Jim Kingdon <kingdon@harvey.cyclic.com> + + * filesubr.c (link_file): Remove; no longer used. + +Tue Feb 17 02:31:15 1998 Noel Cragg <noel@swish.red-bean.com> + + * filesubr.c (last_component): return the top-level directory when + asked about the top-level directory. + +Tue Jan 13 13:17:33 1998 Jim Kingdon <kingdon@harvey.cyclic.com> + + * run.c: Adjust run_setup for new calling convention. + + * config.h (DIFF): Remove; no longer used. + * options.h (DIFF, RCSBIN_DFLT): Remove; no longer used. + +Wed Dec 31 10:56:39 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * config.h, filesubr.c (convert_file): Remove; no longer used + (except for BROKEN_READWRITE_CONVERSION which doesn't apply). + +Sat Dec 27 16:57:41 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * options.h (HAVE_RCS5): Remove; no longer used. + + * config.h (LINES_CRLF_TERMINATED): Remove; no longer used. + +Tue Dec 23 08:28:44 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * README: Change bug-cvs address from prep.ai.mit.edu to gnu.org + per email from Martin Hamilton. + +Sun Nov 30 18:03:02 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * run.c (run_args): Remove; nowhere used. + +Sat Nov 29 22:21:19 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * options.h: Remove declaration of getwd; see lib/ChangeLog for + rationale. + +Sun Aug 10 20:42:51 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * pwd.c, pwd.h: Remove $Header; we decided to get rid of these + some time ago. + +Wed Jul 30 19:15:41 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * filesubr.c (os2_chdir): If ENODEV is not defined, return ENOENT. + + * README: Talk about srcdir, top_srcdir, and rule to generate + "Makefile". + * Makefile.in: Add comment about Makefile rule. + +Mon Jun 16 13:49:39 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * config.h, rcmd.h, rcmd.c: Add "copyright" notice. + +Sun Jun 8 23:41:56 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * config.h (HAVE_MKFIFO): Remove; not used anywhere. + +Wed Apr 30 12:45:50 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * icc.compilation-errors: Removed; it was the error messages from + trying to compile CVS on OS/2, way out of date. + +Wed Mar 12 16:10:01 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * config.h (HAVE_SETVBUF): Removed; no longer used. + +Mon Feb 10 20:01:20 1997 Ullrich von Bassewitz <uz@musoftware.com> + + * filesubr.c: Add an OS/2 specific chdir function that will not + only change the path but will also make the drive current that + is given in the argument string. + config.h: #define the macro CVS_CHDIR to os2_chdir so cvs will + use the os2_chdir function instead of chdir. + +Mon Feb 10 18:29:04 1997 Ullrich von Bassewitz <uz@musoftware.com> + + * config.h: Define VA_LIST_IS_ARRAY so that vasprintf will work + correctly with the watcom compiler. + +Sun Feb 9 20:17:41 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * README: Most of the compiler warnings are gone. + +1997-02-09 Jim Kingdon <kingdon@cyclic.com> + + * popen.h: Arguments to popen are const char * not char *. + +Wed Jan 29 18:27:11 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * options.h, config.h (GREP): Remove; no longer used. + +Tue Jan 28 18:29:03 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * config.h: Remove SIZEOF_INT and SIZEOF_LONG; no longer needed + with lib/md5.c changes. + +Wed Jan 15 23:56:12 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * watcom.mak (OS2_OBJECTS): Remove strippath. + + * Makefile.in (DISTFILES): Add os2inc.h and watcom.mak. + +Thu Jan 2 13:30:56 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * filesubr.c, pwd.c, pwd.h, run.c, stripslash.c: + Remove "675" paragraph; see ../ChangeLog for rationale. + +Wed Jan 1 22:50:31 1997 Jim Kingdon <kingdon@harvey.cyclic.com> + + * options.h: Reword comment for TMPDIR_DFLT to make it clear that + this isn't specific to the pserver server. + +Wed Dec 18 10:51:38 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * Makefile.in (CFLAGS): Specify -Gd- not -Gd+. The documentation + says this causes a static link, although it hasn't yet been + verified whether this option is sufficient to make the binary work + on a system without the compiler's DLL. + +Fri Dec 6 11:00:49 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * os2inc.h, watcom.mak: Add GPL notice. + +1996-11-24 Ullrich von Bassewitz <uz@wuschel.ibb.schwaben.com> + + Changes for Watcom C: + * README: Describe watcom port. + * config.h: Include stdio.h and errno.h. + * config.h: If EACCES is not defined, define it to EACCESS. + * filesubr.c: Use EACCES not EACCESS. + * config.h [__WATCOMC__]: Define _setmode and _cwait. + Don't define HAVE_DIRENT_H. Don't declare getpid. Don't + define NEED_DECOY_PERMISSIONS. Don't define R_OK and friends. + * os2inc.h: New file; includes os2.h but protected against + multiple inclusion. + * config.h: Include os2inc.h before defining sleep. + * filesubr.c, getpass.c, popen.c, run.c: Include os2inc.h rather than + trying to go through the right contortions to include os2.h + ourselves. + * popen.c (popen) [__WATCOMC__]: Use _hdopen together with fdopen. + (popenRW): Change pid from PID to int. + * tcpip.h [__WATCOMC__]: Work around errno value conflict + between the TCP/IP header and errno.h. + * watcom.mak: New file. + +Sat Nov 23 18:36:11 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * README: Try to clarify status vis-a-vis client vs. local. + +Tue Nov 19 17:21:52 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * Makefile.in (OS2_SOURCES): Remove strippath.c + (OS2_OBJECTS): Remove strippath.obj. + * strippath.c: Removed. + +Fri Nov 8 14:28:19 1996 Ullrich von Bassewitz <uz@wuschel.ibb.schwaben.com> + + * filesubr.c (expand_wild): Check for ERROR_NO_MORE_FILES from + DosFindFirst instead of ERROR_FILE_NOT_FOUND; that is what the + function actually returns. Cope with the fact that DosFindFirst + and DosFindNext return only the name of the file itself, not any + directory names. + +Fri Nov 08 11:46:50 1996 Jim Kingdon + + IBM ICC (OS/2) lint: + * filesubr.c: Cast from const char * to char * before passing to + various system functions. + (xchmod): Print error message instead of trying to return ENOENT. + (unlink_file): Only call xchmod if the file exists. + + * Makefile.in (CFLAGS): Don't specify -Wpro; there is no way + that we could prototype getopt, for example. + Don't specify -Wuse. The EDC0805 warning ("Automatic + variable line_allocated is set but not referenced.") warns + about unavoidable constructs like line_allocated in + client.c (send_file_names). + +Sat Oct 26 16:21:26 1996 Jim Blandy <jimb@totoro.cyclic.com> + + * config.h (HAVE_TZSET): Add a #definition for this. + +Tue Oct 8 12:37:35 1996 Ian Lance Taylor <ian@cygnus.com> + + * options.h (HAD_RCS4): Remove; no longer used. + +Thu Sep 26 14:15:55 1996 Jim Kingdon <kingdon@cyclic.com> + + * filesubr.c (mkdir_if_needed): mkdir only takes one + argument on OS/2. + +Wed Sep 25 14:31:51 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * options.h (TMPDIR_DFLT): Change from c:\temp to c:\\temp. + +Tue Sep 24 14:39:40 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * options.h: Add TMPDIR_DFLT. + +Mon Aug 26 12:31:10 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * filesubr.c (mkdir_if_needed): Added. + +Fri Aug 16 16:05:29 1996 Norbert Kiesel <nk@col.sw-ley.de> + + * Makefile.in (installdirs): new (empty) target + +Mon Aug 12 22:59:40 1996 Jim Kingdon (unknown@beezley) + + * filesubr.c (fncmp): Fix typo (n1 -> n2) which had caused the + function to always return 0. + + * Makefile.in (COMMON_OBJECTS): Add buffer.obj. + (COMMON_SOURCES): Add buffer.c. + (zlib_srcdir,ZLIB_OBJECTS): Added. + (cvs.exe): Also link with ZLIB_OBJECTS. + (OBJECTS): Add ZLIB_OBJECTS. + (LIB_OBJECTS): Add valloc.obj. + (COMMON_OBJECTS): Add zlib.obj. + +Mon Aug 12 16:25:32 1996 Steffen Siebert <siebert@susan.logware.de> + and Jim Kingdon (unknown@beezley) + + * Makefile.in (cvs.exe): Use subst so that we link with \ + and compile with / without needing to mess with SL. + * README: Adjust accordingly. + +Mon Jul 15 22:32:13 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * config.h: Remove EXECUTE_PERMISSION_LOSES; it is no longer used + anywhere (superceded by CHMOD_BROKEN). + +Fri Jun 7 13:07:37 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * config.h: Change INITIALIZE_SOCKET_SUBSYSTEM to + SYSTEM_INITIALIZE to reflect change in ../src/main.c. + +Tue May 14 13:38:51 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * filesubr.c (cvs_temp_name): New function. + +Tue May 7 10:50:13 MET DST 1996 Norbert Kiesel <nk@col.sw-ley.de> + + * filesubr.c (expand_wild): Real implementation (like + Windows-NT) for expanding. + +Thu Apr 25 09:28:10 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * README: Add note about LF vs. CRLF in makefile. + +Tue Apr 23 20:43:01 1996 Jim Kingdon <kingdon@cyclic.com> + + * filesubr.c (get_homedir, expand_wild): New functions. + +Wed Feb 28 11:08:06 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * options.h: Remove AUTH_SERVER_SUPPORT; no longer should be + defined in options.h. + + * config.h: Remove C_ALLOCA, CRAY_STACKSEG_END, HAVE_ALLOCA, + HAVE_ALLOCA_H, and STACK_DIRECTION to reflect alloca removal. + +Mon Feb 19 00:35:24 1996 Karl Fogel <kfogel@floss.red-bean.com> + + * Makefile.in: deal with new objects `mkmodules' and `vasprintf'. + + * getpass.c (EchoOn, EchoOff): new funcs. + (getpass): use above new funcs to avoid echoing the password to + the screen. + +Mon Feb 12 16:09:55 1996 Norbert Kiesel <nk@col.sw-ley.de> + + * run.c (run_popen): Changed more Popen() to run_popen() + +Mon Feb 12 03:33:27 1996 Benjamin J. Lee <benjamin@cyclic.com> + + * run.c: Changed Popen() to run_popen() for the benefit of + case-insensitive linkers (VMS) which confuse Popen() with popen() + +Mon Feb 12 03:14:36 1996 Karl Fogel <kfogel@floss.red-bean.com> + + * options.h (PATCH_PROGRAM): "cvspatch" (see comment). + +Fri Feb 9 22:10:12 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * config.h: Remove SYSTEM_COMMENT_TABLE. + +Thu Feb 1 15:07:13 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * options.h: Remove RM; no longer used. + + * filesubr.c: Remove rcsid. + +Sun Jan 28 12:31:03 1996 Jim Kingdon (kingdon@beezley) + + * filesubr.c (unlink_file): Use xchmod, not chmod, to make the + file read-write. + (xchmod): Translate / to \ in file name. If file doesn't exist, + return ENOENT rather than passing it to attrib (which will print an + error message). + +Sun Jan 28 01:51:27 1996 Jim Kingdon (kingdon@beezley) + + * config.h: Fix unclosed comment. + +Sun Jan 28 00:16:58 1996 Karl Fogel (kfogel@floss.cyclic.com) + + * filesubr.c (xchmod): rewritten for OS/2. + +Sat Jan 27 16:18:20 1996 Karl Fogel (kfogel@floss.cyclic.com) + + * config.h (CHMOD_BROKEN): define to 1. + + * filesubr.c (rename_file): rename() returns non-zero error codes, + not necessarily negative. + +Fri Jan 26 00:52:12 1996 unknown (unknown@beezley) + + * filesubr.c (copy_file): Open the file we are writing, not + just the one we are reading, in binary mode. + +Thu Jan 18 14:53:58 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * Makefile.in (CFLAGS): Don't use +=. This makefile must be + portable because it is used on all platforms (e.g. for "make dist"). + +Thu Jan 11 12:04:42 1996 Norbert Kiesel <nk@col.sw-ley.de> + + * options.h: remove CVS_NOADMIN + +Wed Jan 10 15:56:46 1996 Karl Fogel <kfogel@floss.red-bean.com> + + * options.h, config.h: moved NO_SOCKET_TO_FD definition from + options.h to config.h, which is where it belongs. + +Tue Jan 9 16:43:15 1996 Karl Fogel <kfogel@floss.red-bean.com> + + * run.c (sleep): commented out this definition. + * config.h: #define sleep() in terms of DosSleep(), unless sleep() + is defined already. Normally it's defined in + tcpip/include/utils.h, however on beezley that definition is + commented out for some reason. + Don't prototype sleep(). + +Tue Jan 9 16:22:35 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * .cvsignore: Add cvs.exe and icc.in. + +Tue Jan 09 16:43:59 1996 Jim Kingdon (kingdon@beezley.cyclic.com) + + * filesubr.c (link_file): New function (copied from + ../windows-NT/filesubr.c) + +Fri Jan 5 17:03:09 1996 Karl Fogel <kfogel@floss.red-bean.com> + + * Makefile.in: "lib_dir", not "libdir", to avoid conflict with + top-level Makefile. + +Mon Jan 1 22:59:46 1996 Jim Kingdon <kingdon@harvey.cyclic.com> + + * Makefile.in (DISTFILES): Makefile is not in srcdir. + +Sat Dec 23 23:08:43 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * README: adjust for below change. + + * Makefile.in (install-cvs): replaces `install', which must remain + a dummy rule so it will work under Unix. + +Wed Dec 20 15:18:06 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in: build scramble.obj. + +Mon Dec 18 22:49:28 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Reverted all changes between Mon Dec 18 14:54:04 1995 and + present, non-inclusive. + +Mon Dec 18 21:59:07 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * getpass.c: removed -- getpass() lives in os2/login.c now. + + * cvslogin.c: filled in. + + * login.c: new file. + + * Makefile.in: moved login.c and login.obj from COMMON to OS2 + section. + +Mon Dec 18 19:55:43 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * cvslogin.c: added long explanatory comment. + +Mon Dec 18 18:13:57 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in (DISTFILES): include cvslogin.c. + +Mon Dec 18 18:07:26 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * README: updated. + + * Makefile.in (cvslogin.exe): new rule. + (install): new rule. + (install_dir): new var. + + * cvslogin.c: new file. + +Mon Dec 18 14:54:04 1995 Karl Fogel (kfogel@floss.cyclic.com) + + * getpass.c (getpass): removed debugging garbage. + + * options.h (NO_SOCKET_TO_FD): fixed comment (Windows 95, not NT, + has this problem). + (AUTH_CLIENT_SUPPORT): on by default. + + * porttcp.c (SockStrError): fixed typo. + (IbmSockSend): `Buffer' arg is const void * again. + (IbmSockRecv): `Buffer' arg is const void * again. + + * tcpip.h (send): move send/recv redef section farther down to + avoid type conflicts with the real send() and recv(). + (IbmSockSend, IbmSockRecv): adjust prototype. + +Mon Dec 18 12:31:22 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * tcpip.h: reformatted. + (send, recv): redefine to IbmSockSend and IbmSockRecv. + + * porttcp.c: reformatted. + +Mon Dec 18 04:59:52 1995 Karl Fogel (kfogel@floss.cyclic.com) + + * tcpip.h (send, recv): don't define these to be anything else. + + * porttcp.c (IbmSockSend, IbmSockRecv): make `Buffer' argument + char * instead of void *, to evade an over-eager compiler. + +Sun Dec 17 21:16:17 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * options.h (NO_SOCKET_TO_FD): define to 1. + +Sat Dec 16 21:31:02 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * run.c: mark unimplemented routines more clearly. Hopefully I'll + get time to implement them soon. + +Fri Dec 15 17:50:17 1995 Karl Fogel (kfogel@floss.cyclic.com) + + * tcpip.h, porttcp.c: new files. + + * makefile.in: added new files (for the "cvs watch" and "cvs edit" + commands just checked in by Jim Kingdon). + +Thu Dec 14 12:18:20 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * config.h (RSH_NEEDS_BINARY_FLAG): define to 1. + + * run.c (filter_stream_through_program): die, rather than return + -1, if spawn failed. + + * options.h (AUTH_CLIENT_SUPPORT): leave unset by default. + +Wed Dec 13 21:31:10 1995 Karl Fogel (kfogel@floss.cyclic.com) + + * waitpid.c (waitpid): Don't deal specially with statusp after all. + The problem lies elsewhere. + +Wed Dec 13 20:58:12 1995 Karl Fogel (kfogel@floss.cyclic.com) + + * waitpid.c (waitpid): oops, make sure there is storage for + local_statusp. + Don't assign to *statusp if statusp is NULL. + +Wed Dec 13 19:52:08 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * waitpid.c (waitpid): be more careful about child's exit status, + and about return status of this function. + +Wed Dec 13 20:10:50 1995 Karl Fogel (kfogel@floss.cyclic.com) + + * makefile.in (clean): pass /NOE to the linker, to avoid duplicate + symbols when linking with setargv.obj. + +Wed Dec 13 18:44:47 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in (ARGVLIB): new lib, link with this so command-line + wildcard expansion works. No, I'm not making this up. + +Tue Dec 12 20:43:56 1995 Karl Fogel (kfogel@floss.cyclic.com) + + * getpass.c (getpass): new file and function. + + * options.h: prototype getpass() for OS/2. + + * makefile.in: include new file getpass.c. + +Tue Dec 12 19:21:05 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * options.h (RCSBIN_DFLT): expand comment. + (AUTH_CLIENT_SUPPORT, AUTH_SERVER_SUPPORT): replace obsolete + CVS_AUTH_CLIENT_SUPPORT and CVS_AUTH_SERVER_SUPPORT. + +Mon Dec 11 16:03:01 1995 Karl Fogel (kfogel@beezley.cyclic.com) + + * makefile.in: removed various and sundry cruft... + +Mon Dec 11 15:57:03 1995 Karl Fogel (kfogel@beezley.cyclic.com) + + * Removed cvs.exe; we don't need to keep the binary in the + repository, now that binary file handling has been tested. + +Mon Dec 11 15:53:51 1995 Karl Fogel (kfogel@beezley.cyclic.com) + + * rcmd.c (init_sockets): use sock_init(), not SockInit(). + +Mon Dec 11 12:43:35 1995 Adam Glass <adamg@microsoft.com> + + * config.h: Remove NEED_CALL_SOCKINIT macro in favor of the more + generic INITIALIZE_SOCKET_SUBSYSTEM. + * rcmd.c: Move old NEED_CALL_SOCKINIT code here and wrap it in a + function, i.e init_sockets() + +Sat Dec 09 21:16:09 1995 Karl Fogel (kfogel@beezley.cyclic.com) + + * Added cvs.exe, mainly to test binary file handling. Once we + know it works, we can remove it. + +Sat Dec 09 15:29:16 1995 Karl Fogel (kfogel@beezley.cyclic.com) + + * options.h (DIFF, GREP): don't expect autoconf to help us out. + +Sat Dec 09 15:05:41 1995 Karl Fogel (kfogel@beezley.cyclic.com) + + * makefile.in (libdir): Fixed. + + * options.h: define CVS_AUTH_CLIENT_SUPPORT and + CVS_AUTH_SERVER_SUPPORT, instead of CVS_LOGIN. + +Thu Dec 7 14:49:16 1995 Jim Meyering (meyering@comco.com) + + * filesubr.c (isaccessible): Rename from isaccessable. + +Mon Dec 4 11:28:10 1995 Norbert Kiesel <nk@col.sw-ley.de> + + * Makefile.in (DISTFILES): prefix all filenames with + ${srcdir}${PS} + (dist-dir): remove ${srcdir}${PS} (some files already had this + prefix, now all have it) + +Fri Dec 1 14:29:44 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in (srcdir, libdir, cvs_srcdir): use autoconf vars. + (dist-dir): use above vars now that they are autoconf-friendly. + (clean): same. + +Thu Nov 30 18:09:50 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * waitpid.c (waitpid): if _cwait() returns -1, test errno. If + ECHILD, then just return pid, else return -1. This is for OS/2, + which doesn't have zombie processes, or any other way of + remembering a child process after it exits, as far as I can tell. + + * run.c (close_on_exec): don't error, just silently do nothing. + + * Makefile.in: use src/client.c, not os2/client.c. + + * config.h (EXECUTE_PERMISSION_LOSES): define to 1 (see + src/client.c for why). + (START_RSH_WITH_POPEN_RW): define to 1 (see src/client.c). + +Wed Nov 29 16:34:34 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * client.c (start_server): declare pipes[] as int, not FILE *. + Kinda nice that it worked anyway, but scary. Ugh. + +Wed Nov 22 11:29:11 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * config.h (KFF_DEBUG): expand to nothing; we don't want to print + out debugging messages in a production copy. + +Tue Nov 21 17:36:16 1995 unknown (unknown@beezley) + + * popen.c: #include <fcntl.h>. + +Tue Nov 21 16:18:37 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * popen.h (popenRW): prototype popenRW()... why wasn't I doing + this before? + + * client.c (start_server): set tofd and fromfd with popenRW, now + that it handles int file descriptors. + Log to a file if asked, now that we have + filter_stream_through_program(). + + * popen.c (popenRW): put int file descriptors into the `pipes' + array, not FILE *'s. We'll fdopen in start_server, just like + the good old days. + +Tue Nov 21 16:34:37 1995 unknown (unknown@beezley) + + * run.c (filter_stream_through_program): defined for OS/2. + + * client.c (start_server): pass a char **argv to popenRW and get a + pid in return (instead of a return code). + + * popen.c (popenRW): use a char **argv and spawnvp(), instead of a + char *command and DosExecPgm(). + +Mon Nov 20 23:31:54 1995 unknown (unknown@beezley) + + * filesubr.c (convert_file): pass (S_IREAD | S_IWRITE) to open(); + we need it if O_CREAT, and it won't hurt if not. + +Sun Nov 19 13:43:02 1995 unknown (unknown@beezley) + + * makefile.in (clean): remove obj files in src/ and lib/ dirs too. + +Sun Nov 19 12:35:08 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * client.c (start_server): took out old debug statements. + + * dirent.c, dirent.h: took out ^M's. + +Sat Nov 18 13:39:06 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * client.c (start_server): took out debug statements. + + * filesubr.c (make_directories): compare errno to EACCESS, not + EEXIST, to see if the dir already exists. + + * client.c, filesubr.c: Use new macro `existence_error', instead + of comparing errno to ENOENT directly. + + * popen.c (popenRW): fixed misleading comment. + + * client.c: + (rsh_pid): no more need for this var; the handle-to-PID library in + popen.c manages PID's for us now. + (start_rsh_server): removed this func, since we don't use it -- we + do use `rsh', but we call it directly from popenRW(). + (get_responses_and_close): removed cruft that doesn't apply to + this port -- i.e., blocks conditional on HAVE_KERBEROS or + RSH_NOT_TRANSPARENT. + (start_server): Just check return code, instead of recording + rsh_pid. + +Fri Nov 17 21:13:22 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * client.c (call_in_directory): Ask EACCESS even though we're + looking for EEXIST. That's just The Way Things Are Done here, + apparently. Ick. + + * getdate.c: took out some cruft that the more portable versions + need. + + * Makefile.in: use getdate.c from os2/ subdir, not lib/. + We don't use startserver.c anymore, so don't build it. + + * client.c (change_mode): never set anything executable, until we + understand what that means in OS/2. + + * config.h (NEED_DECOY_PERMISSIONS): define to 1 (& see + system.h). + +Fri Nov 17 15:02:05 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * client.c: fixed up more error codes. + + * client.c: (send_repository): take into account the cornucopia of + error codes so generously offered by OS/2. + +Fri Nov 17 14:53:22 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * client.c, client.h: new files, copied from ../src/. + + * config.h (HAVE_POPEN_RW): don't define this anymore, since we'll + just be using our own version of client.c. + + * Makefile.in: reflect the fact that os2/client.c is now used + instead of src/client.c. + +Thu Nov 16 21:47:22 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * startserver.c: removed. We don't need this anymore. + + * config.h (RSH_NOT_TRANSPARENT): undef this. We have a + transparent rsh. + (HAVE_POPEN_RW): define to 1. + + * popen.c (popenRW): open writing and reading streams in binary + mode (i.e., "wb" and "rb"). + + * Makefile.in (clean): use `rm' not `del' to remove files. + +Wed Nov 15 15:21:53 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * config.h: don't prototype gethostname() here anymore. + (USE_OWN_TCPIP_H): define to 1. + (NEED_CALL_SOCKINIT): define to 1. + (KFF_DEBUG): debugging macro. + +Tue Nov 14 12:20:22 1995 Greg A. Woods <woods@most.weird.com> + + * .cvsignore: "Makefile" generated by ../configure + +Mon Nov 13 13:21:43 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in (PS): note to maintainers about this var. + +Mon Nov 13 07:28:04 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * README: updated. + + * rcmd.c: #include <stdio.h>. + + * Makefile.in: Include lib/regex, lib/getdate, strippath. + (PS): default to "/", since we always "make dist" on Unix + systems. + Ahem, "save-cwd" with a hyphen, not an underscore. Oops. + + * strippath.c: new file. + + * popen.c: set DIAGNOSTIC off. Reformat for readability. + + * popen.h: new file. + + * config.h (USE_OWN_POPEN): define to 1. + + * run.c (Popen): make this work now that we have popen(). + +Mon Nov 13 01:23:27 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in: + (cvs.exe): broke up OBJECTS into components to create icc.in in + more steps. OBJECTS had gotten so big that it formed too long a + command line all by itself. Sheesh. + Include stripslash (see below), lib/save_cwd, lib/sighandle, + lib/yesno, startserver (see below), rcmd (see below), lib/xgetwd, + lib/md5, waitpid (see below), lib/fnmatch, popen (see below). + + * popen.c, rcmd.c, rcmd.h, startserver.c, stripslash.c, waitpid.c: + New files. + + * run.c (close_on_exec): new func (skeleton). + (sleep): new func (OS/2 doesn't seem to have this). + + * pwd.c (getlogin): Don't call win32getlogin(), obviously. + + * config.h (W_OK, R_OK, X_OK, F_OK): define masks for access(). + Include <process.h> for getpid(). + + * filesubr.c (isaccessable): define. Don't know why I left it out + before. For that matter, I don't know how the Windows NT port + gets along without it. Hmmm. + +Sat Nov 11 15:00:01 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in: Use backslashes in pathnames, so ICC doesn't + mistake them for options. + + * run.c (run_setup): cleared away Windows NT stuff, left skeleton + functions that just complain and die for now. + (run_exec): correctly check return of spawn under OS/2; return + child's exit status. + (run_args): declare as returning void, in agreement with cvs.h. + +Fri Nov 10 14:21:14 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in (COMMON_SOURCES, COMMON_OBJECTS): removed filesubr + and run, since we have OS/2-specific versions of them now. + (DISTFILES): Include Makefile in distribution, since people won't + be running configure on their OS/2 systems. + (LIB_SOURCES, LIB_OBJECTS): new vars; we'll just build stuff in + the lib directory and link it in directly. + Made rules for compiling objects and for the full executable. + (SHELL): got rid of this var, no need for it here. + Use a pattern rule for obj files. + Some other minor tweaks for OS/2. + + * threads.c: new file. + +Wed Nov 8 11:14:46 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * run.c: include <stdarg.h> and <stdio.h>. + Change all VA_START to va_start. + Don't ask HAVE_VPRINTF -- this is an OS/2-specific file and we can + take things for granted. + Started simplifying old NT `HANDLE' code. + + * Makefile.in (OS2_SOURCES): added run.c. + + * run.c: new file, copied from ../windows-NT/run.c. Started + making changes for OS/2. + + * test-makefile (all): don't bother to echo $CFLAGS; we can just + read the compilation command. + + * filesubr.c (unlink_file): make this work on OS/2. + (unlink_file_dir): don't ask if errno == EISDIR. We ain't + got EISDIR in OS/2. + (deep_remove_dir): use EACCESS to determine if directory + nonempty. We ain't got ENOTEMPTY in OS/2. + (that_swing): removed references. We ain't got that_swing in + OS/2. + (rename_file): just use unlink_file(); move to after definition of + unlink_file() so we don't have to deal with IBM C/C++'s strange + prototyping rituals. + (link_file): removed this function -- no one uses it anymore. + It still exists in src/filesubr.c, though. + (OS2_filename_classes): new table (well, old table, new name). + All references changed. + + * config.h (HAVE_SYS_UTIME_H): define to 1. + + * options.h: undef SETXID_SUPPORT, to correspond with Norbert + Kiesel's recent change to ../src/options.h.in, etc. + +Mon Nov 6 16:29:00 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * test-makefile (CFLAGS): -DHAVE_CONFIG_H -- this turns out to be + important for stuff in lib/. + Other trivial changes. + + * config.h (HAVE_DIRENT_H): define to 1, now that we have our own + dirent.h and dirent.c. + + * Makefile.in (OS2_SOURCES): added filesubr.c; this may not be + permanent. + +Sun Nov 5 16:17:33 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in (OS2_HEADERS, OS2_SOURCES): added dirent.h and + dirent.c, respectively. + + * dirent.c, dirent.h: new files. + +Sat Oct 28 14:41:38 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in (DISTFILES): include `test-makefile'. + + * test-makefile: new file; to be removed when the port is done. + +Fri Oct 27 13:03:28 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in (OS2_HEADERS, OS2_SOURCES): adjust as necessary for + below changes. + + * config.h: oops, don't forget second argument, MODE. + + * mkdir.c (os2_mkdir): new file, new function. + Can probably be merged with wnt_mkdir at some point. + + * config.h (ALLOCA_IN_STDLIB): new #define. + + * pwd.h, pwd.c: new files (for now, copied from ../windows-NT + directory. We'll modify/merge them as necessary.) + + * config.h: don't use __stdcall in declaration of gethostname(). + + * Makefile.in (DISTFILES): include config.h and options.h. + +Wed Oct 25 12:52:54 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * config.h: new file; will maintain by hand. + Made first pass through to cast it into OS/2-ish condition. + + * Makefile.in: started adding lots of OS/2 gunk. + Took out autoconf stuff; just don't want to fool around with that + until after it compiles on beezley. + (cvs.exe): moved this rule to bottom. + +Tue Oct 24 13:51:05 1995 Norbert Kiesel <nk@col.sw-ley.de> + + * Makefile.in: add autoconf variables + + * Makefile.in (dist): use $(srcdir) + +Mon Oct 23 17:37:36 1995 Karl Fogel <kfogel@floss.cyclic.com> + + * Makefile.in (clean): new rule. + + * init os2 directory. Made dummy Makefile.in, README. diff --git a/os2/Makefile b/os2/Makefile new file mode 100644 index 0000000..4288067 --- /dev/null +++ b/os2/Makefile @@ -0,0 +1,357 @@ +# Makefile for OS/2. Generated from Makefile.in when CVS is +# configured for a dist-build. Configure never gets run on OS/2, so +# we must include the generated Makefile in the distribution. See the +# `dist-dir' rule. + +project: cvs.exe +# .SUFFIXES .c .obj .exe + +# path slash. This was introduced so that it can be set to \ +# instead of / for linking, but now that the cvs.exe rule uses +# subst to produce \, it should be possible to nuke SL. +# FIXME - nuke SL +SL = / + +# Directory in which to install executables. +install_dir = s:${SL}gnu${SL}util + +# srcdir is usually "." +srcdir = . + +# top_srcdir is usually ".." +top_srcdir = .. + + +subdir = os2 + +lib_dir = ..${SL}lib +cvs_srcdir = ..${SL}src + +zlib_dir = ${top_srcdir}/zlib + +# Do we need these? +# prefix = /usr/local +# exec_prefix = ${prefix} + +# taken straight from the example project +LIB = s:${SL}ibmcpp${SL}lib;s:${SL}toolkt21${SL}os2lib; +CINC = -Is:${SL}ibmcpp${SL}include -Is:${SL}toolkt21${SL}c${SL}os2h +# This says we are building an object file, not a full executable. +OBJ_CFLAGS = -C+ +CFLAGS = -W3 -Wrea+tru+ -Ti+ -Ss+ -Gd- -Gm+ -G4 -Q+ -Sm ${CINC} \ + -I${srcdir} -I${lib_dir} -I${cvs_srcdir} -I${zlib_dir} \ + -DIBM_CPP -DHAVE_CONFIG_H \ + -DTCPIP_IBM -Is:${SL}ibmtcpip${SL}include + +# needed to make command-line wildcard expansion work right. That's +# right, DOS-descendants handle this from the program, not the shell. +ARGVLIB = s:${SL}ibmcpp${SL}lib${SL}setargv.obj + +# TCP/IP stuff +TCPIPLIB = s:${SL}ibmtcpip${SL}lib${SL}tcp32dll.lib s:${SL}ibmtcpip${SL}lib${SL}so32dll.lib + + +# headers specific to OS/2 + +# We list OS2_HEADERS so we know what to include when we make dist-dir +# here. +OS2_HEADERS = \ + tcpip.h \ + config.h \ + pwd.h \ + dirent.h \ + rcmd.h \ + popen.h + +# headers we use from the common src dir, ..${SL}src +COMMON_HEADERS = \ + ${cvs_srcdir}${SL}client.h \ + ${cvs_srcdir}${SL}cvs.h \ + ${cvs_srcdir}${SL}rcs.h \ + ${cvs_srcdir}${SL}hash.h \ + ${cvs_srcdir}${SL}myndbm.h \ + ${cvs_srcdir}${SL}patchlevel.h \ + ${cvs_srcdir}${SL}update.h \ + ${cvs_srcdir}${SL}server.h \ + ${cvs_srcdir}${SL}error.h + +# sources specific to OS/2 +OS2_SOURCES = \ + mkdir.c \ + pwd.c \ + filesubr.c \ + dirent.c \ + run.c \ + rcmd.c \ + waitpid.c \ + popen.c \ + porttcp.c \ + getpass.c + +# sources we use from the common src dir, ..${SL}src +# FIXME: Is this used anywhere? I don't think it is. +COMMON_SOURCES = \ + ${cvs_srcdir}${SL}add.c \ + ${cvs_srcdir}${SL}admin.c \ + ${cvs_srcdir}${SL}buffer.c \ + ${cvs_srcdir}${SL}checkin.c \ + ${cvs_srcdir}${SL}checkout.c \ + ${cvs_srcdir}${SL}classify.c \ + ${cvs_srcdir}${SL}client.c \ + ${cvs_srcdir}${SL}commit.c \ + ${cvs_srcdir}${SL}create_adm.c \ + ${cvs_srcdir}${SL}cvsrc.c \ + ${cvs_srcdir}${SL}diff.c \ + ${cvs_srcdir}${SL}edit.c \ + ${cvs_srcdir}${SL}entries.c \ + ${cvs_srcdir}${SL}error.c \ + ${cvs_srcdir}${SL}expand_path.c \ + ${cvs_srcdir}${SL}fileattr.c \ + ${cvs_srcdir}${SL}find_names.c \ + ${cvs_srcdir}${SL}hash.c \ + ${cvs_srcdir}${SL}history.c \ + ${cvs_srcdir}${SL}ignore.c \ + ${cvs_srcdir}${SL}import.c \ + ${cvs_srcdir}${SL}lock.c \ + ${cvs_srcdir}${SL}log.c \ + ${cvs_srcdir}${SL}login.c \ + ${cvs_srcdir}${SL}logmsg.c \ + ${cvs_srcdir}${SL}main.c \ + ${cvs_srcdir}${SL}mkmodules.c \ + ${cvs_srcdir}${SL}modules.c \ + ${cvs_srcdir}${SL}myndbm.c \ + ${cvs_srcdir}${SL}no_diff.c \ + ${cvs_srcdir}${SL}parseinfo.c \ + ${cvs_srcdir}${SL}patch.c \ + ${cvs_srcdir}${SL}rcs.c \ + ${cvs_srcdir}${SL}rcscmds.c \ + ${cvs_srcdir}${SL}recurse.c \ + ${cvs_srcdir}${SL}release.c \ + ${cvs_srcdir}${SL}remove.c \ + ${cvs_srcdir}${SL}repos.c \ + ${cvs_srcdir}${SL}root.c \ + ${cvs_srcdir}${SL}scramble.c \ + ${cvs_srcdir}${SL}server.c \ + ${cvs_srcdir}${SL}status.c \ + ${cvs_srcdir}${SL}subr.c \ + ${cvs_srcdir}${SL}tag.c \ + ${cvs_srcdir}${SL}update.c \ + ${cvs_srcdir}${SL}watch.c \ + ${cvs_srcdir}${SL}wrapper.c \ + ${cvs_srcdir}${SL}vers_ts.c \ + ${cvs_srcdir}${SL}version.c +# end of $COMMON_SOURCES + +# sources from ..${SL}lib +# FIXME: Is this used anywhere? I don't think it is. +LIB_SOURCES = \ + ${lib_dir}${SL}getdate.c \ + ${lib_dir}${SL}getopt.c \ + ${lib_dir}${SL}getopt1.c \ + ${lib_dir}${SL}getline.c \ + ${lib_dir}${SL}getwd.c \ + ${lib_dir}${SL}savecwd.c \ + ${lib_dir}${SL}sighandle.c \ + ${lib_dir}${SL}yesno.c \ + ${lib_dir}${SL}vasprintf.c \ + ${lib_dir}${SL}xgetwd.c \ + ${lib_dir}${SL}md5.c \ + ${lib_dir}${SL}fnmatch.c \ + ${lib_dir}${SL}regex.c + +# object files from OS/2 sources +OS2_OBJECTS = \ + ${srcdir}${SL}mkdir.obj \ + ${srcdir}${SL}pwd.obj \ + ${srcdir}${SL}filesubr.obj \ + ${srcdir}${SL}dirent.obj \ + ${srcdir}${SL}run.obj \ + ${srcdir}${SL}rcmd.obj \ + ${srcdir}${SL}waitpid.obj \ + ${srcdir}${SL}popen.obj \ + ${srcdir}${SL}porttcp.obj \ + ${srcdir}${SL}getpass.obj + +# object files from ..${SL}src +COMMON_OBJECTS = \ + ${cvs_srcdir}${SL}add.obj \ + ${cvs_srcdir}${SL}admin.obj \ + ${cvs_srcdir}${SL}buffer.obj \ + ${cvs_srcdir}${SL}checkin.obj \ + ${cvs_srcdir}${SL}checkout.obj \ + ${cvs_srcdir}${SL}classify.obj \ + ${cvs_srcdir}${SL}client.obj \ + ${cvs_srcdir}${SL}commit.obj \ + ${cvs_srcdir}${SL}create_adm.obj \ + ${cvs_srcdir}${SL}cvsrc.obj \ + ${cvs_srcdir}${SL}diff.obj \ + ${cvs_srcdir}${SL}edit.obj \ + ${cvs_srcdir}${SL}entries.obj \ + ${cvs_srcdir}${SL}error.obj \ + ${cvs_srcdir}${SL}expand_path.obj \ + ${cvs_srcdir}${SL}fileattr.obj \ + ${cvs_srcdir}${SL}find_names.obj \ + ${cvs_srcdir}${SL}hash.obj \ + ${cvs_srcdir}${SL}history.obj \ + ${cvs_srcdir}${SL}ignore.obj \ + ${cvs_srcdir}${SL}import.obj \ + ${cvs_srcdir}${SL}lock.obj \ + ${cvs_srcdir}${SL}log.obj \ + ${cvs_srcdir}${SL}login.obj \ + ${cvs_srcdir}${SL}logmsg.obj \ + ${cvs_srcdir}${SL}main.obj \ + ${cvs_srcdir}${SL}mkmodules.obj \ + ${cvs_srcdir}${SL}modules.obj \ + ${cvs_srcdir}${SL}myndbm.obj \ + ${cvs_srcdir}${SL}no_diff.obj \ + ${cvs_srcdir}${SL}parseinfo.obj \ + ${cvs_srcdir}${SL}patch.obj \ + ${cvs_srcdir}${SL}rcs.obj \ + ${cvs_srcdir}${SL}rcscmds.obj \ + ${cvs_srcdir}${SL}recurse.obj \ + ${cvs_srcdir}${SL}release.obj \ + ${cvs_srcdir}${SL}remove.obj \ + ${cvs_srcdir}${SL}repos.obj \ + ${cvs_srcdir}${SL}root.obj \ + ${cvs_srcdir}${SL}scramble.obj \ + ${cvs_srcdir}${SL}server.obj \ + ${cvs_srcdir}${SL}status.obj \ + ${cvs_srcdir}${SL}subr.obj \ + ${cvs_srcdir}${SL}tag.obj \ + ${cvs_srcdir}${SL}update.obj \ + ${cvs_srcdir}${SL}watch.obj \ + ${cvs_srcdir}${SL}wrapper.obj \ + ${cvs_srcdir}${SL}vers_ts.obj \ + ${cvs_srcdir}${SL}version.obj \ + ${cvs_srcdir}/zlib.obj +# end of $COMMON_OBJECTS + +# objects from ..${SL}lib +LIB_OBJECTS = \ + ${lib_dir}${SL}getdate.obj \ + ${lib_dir}${SL}getopt.obj \ + ${lib_dir}${SL}getopt1.obj \ + ${lib_dir}${SL}getline.obj \ + ${lib_dir}${SL}getwd.obj \ + ${lib_dir}${SL}savecwd.obj \ + ${lib_dir}${SL}sighandle.obj \ + ${lib_dir}${SL}yesno.obj \ + ${lib_dir}${SL}vasprintf.obj \ + ${lib_dir}${SL}xgetwd.obj \ + ${lib_dir}${SL}md5.obj \ + ${lib_dir}${SL}fnmatch.obj \ + ${lib_dir}${SL}regex.obj \ + ${lib_dir}/valloc.obj + +ZLIB_OBJECTS = ${zlib_dir}/adler32.obj \ + ${zlib_dir}/compress.obj \ + ${zlib_dir}/crc32.obj \ + ${zlib_dir}/uncompr.obj \ + ${zlib_dir}/deflate.obj \ + ${zlib_dir}/trees.obj \ + ${zlib_dir}/zutil.obj \ + ${zlib_dir}/inflate.obj \ + ${zlib_dir}/infblock.obj \ + ${zlib_dir}/inftrees.obj \ + ${zlib_dir}/infcodes.obj \ + ${zlib_dir}/infutil.obj \ + ${zlib_dir}/inffast.obj + +SOURCES = ${COMMON_SOURCES} ${LIB_SOURCES} ${OS2_SOURCES} +HEADERS = ${COMMON_HEADERS} ${OS2_HEADERS} +OBJECTS = ${COMMON_OBJECTS} ${LIB_OBJECTS} ${OS2_OBJECTS} ${ZLIB_OBJECTS} + +DISTFILES = ${OS2_HEADERS} ${OS2_SOURCES} \ + README ChangeLog \ + Makefile.in .cvsignore \ + test-makefile Makefile os2inc.h \ + watcom.mak + +all: + +.PHONY: all install uninstall +all install uninstall: + +# Remove targets for Automake +dvi info pdf ps: +.PHONY: dvi info pdf ps +check installcheck: +.PHONY: check installcheck +installdirs: +lint: +tags TAGS: +.PHONY: installdirs lint tags TAGS + +# distdir added for compatibility with CVS automake. +top_distdir = .. +PACKAGE = cvs +VERSION = 1.12.13 +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @list='$(DISTFILES)'; for file in $$list; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +.PHONY: distdir + +# We don't have a real distclean or anything like that, but at least +# we can get rid of the obj files and cvs.exe. +.PHONY: clean distclean realclean mostlyclean maintainer-clean +clean distclean realclean maintainer-clean mostlyclean: + rm -f cvs.exe + rm -f ${srcdir}${SL}*.obj + rm -f ${lib_dir}${SL}*.obj + rm -f ${cvs_srcdir}${SL}*.obj + +install-cvs: cvs.exe + cp ${srcdir}${SL}cvs.exe ${install_dir}${SL}cvs.exe + +%.obj: %.c + icc ${OBJ_CFLAGS} ${CFLAGS} /Fo$@ $*.c + +# There seems to be no ICC option for specifying library locations, so +# we must `set' the path in the compilation environment. Urgkle. +# +# I'm having some weird problem with "\" vs. "/". If I build +# with "\" as the path separator in the makefile, the compiler dumps +# core. Go figure. If I build with "/" as the path separator, the +# object files compile fine but the linker thinks the "/" is indicating +# options and gets all confused (though at least it doesn't dump core). +# So, use subst to compile with "/" and link with "\". +cvs.exe: ${OBJECTS} + echo Creating icc.in... + echo -Q+ -Ti+ -Fe$@ -B"/batch" -B"/NOE" > icc.in + echo $(subst /,\,$(OS2_OBJECTS)) >> icc.in + echo $(subst /,\,$(LIB_OBJECTS)) >> icc.in + echo $(subst /,\,$(COMMON_OBJECTS)) >> icc.in + echo $(subst /,\,$(ZLIB_OBJECTS)) >> icc.in + echo $(subst /,\,$(TCPIPLIB)) >> icc.in + echo $(subst /,\,$(ARGVLIB)) >> icc.in + echo Creating icc.in... done. + set LIB=$(subst /,\,$(LIB)) & icc @icc.in + +# cvs.obj: ${OBJECTS} ${SOURCES} ${HEADERS} + +# Hmm. This rule wants to exist on unix, so that "make dist" works. +# And it doesn't want to exist on OS/2, because configure doesn't +# run on OS/2 and so ../config.status won't exist. For now we just +# say, in emx/README, that people will need to comment it out. +Makefile: ../config.status $(srcdir)/Makefile.in + cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status diff --git a/os2/Makefile.in b/os2/Makefile.in new file mode 100644 index 0000000..4f2278b --- /dev/null +++ b/os2/Makefile.in @@ -0,0 +1,357 @@ +# Makefile for OS/2. Generated from Makefile.in when CVS is +# configured for a dist-build. Configure never gets run on OS/2, so +# we must include the generated Makefile in the distribution. See the +# `dist-dir' rule. + +project: cvs.exe +# .SUFFIXES .c .obj .exe + +# path slash. This was introduced so that it can be set to \ +# instead of / for linking, but now that the cvs.exe rule uses +# subst to produce \, it should be possible to nuke SL. +# FIXME - nuke SL +SL = / + +# Directory in which to install executables. +install_dir = s:${SL}gnu${SL}util + +# srcdir is usually "." +srcdir = @srcdir@ + +# top_srcdir is usually ".." +top_srcdir = @top_srcdir@ + +VPATH = @srcdir@ +subdir = os2 + +lib_dir = @top_srcdir@${SL}lib +cvs_srcdir = @top_srcdir@${SL}src + +zlib_dir = ${top_srcdir}/zlib + +# Do we need these? +# prefix = /usr/local +# exec_prefix = ${prefix} + +# taken straight from the example project +LIB = s:${SL}ibmcpp${SL}lib;s:${SL}toolkt21${SL}os2lib; +CINC = -Is:${SL}ibmcpp${SL}include -Is:${SL}toolkt21${SL}c${SL}os2h +# This says we are building an object file, not a full executable. +OBJ_CFLAGS = -C+ +CFLAGS = -W3 -Wrea+tru+ -Ti+ -Ss+ -Gd- -Gm+ -G4 -Q+ -Sm ${CINC} \ + -I${srcdir} -I${lib_dir} -I${cvs_srcdir} -I${zlib_dir} \ + -DIBM_CPP -DHAVE_CONFIG_H \ + -DTCPIP_IBM -Is:${SL}ibmtcpip${SL}include + +# needed to make command-line wildcard expansion work right. That's +# right, DOS-descendants handle this from the program, not the shell. +ARGVLIB = s:${SL}ibmcpp${SL}lib${SL}setargv.obj + +# TCP/IP stuff +TCPIPLIB = s:${SL}ibmtcpip${SL}lib${SL}tcp32dll.lib s:${SL}ibmtcpip${SL}lib${SL}so32dll.lib + + +# headers specific to OS/2 + +# We list OS2_HEADERS so we know what to include when we make dist-dir +# here. +OS2_HEADERS = \ + tcpip.h \ + config.h \ + pwd.h \ + dirent.h \ + rcmd.h \ + popen.h + +# headers we use from the common src dir, ..${SL}src +COMMON_HEADERS = \ + ${cvs_srcdir}${SL}client.h \ + ${cvs_srcdir}${SL}cvs.h \ + ${cvs_srcdir}${SL}rcs.h \ + ${cvs_srcdir}${SL}hash.h \ + ${cvs_srcdir}${SL}myndbm.h \ + ${cvs_srcdir}${SL}patchlevel.h \ + ${cvs_srcdir}${SL}update.h \ + ${cvs_srcdir}${SL}server.h \ + ${cvs_srcdir}${SL}error.h + +# sources specific to OS/2 +OS2_SOURCES = \ + mkdir.c \ + pwd.c \ + filesubr.c \ + dirent.c \ + run.c \ + rcmd.c \ + waitpid.c \ + popen.c \ + porttcp.c \ + getpass.c + +# sources we use from the common src dir, ..${SL}src +# FIXME: Is this used anywhere? I don't think it is. +COMMON_SOURCES = \ + ${cvs_srcdir}${SL}add.c \ + ${cvs_srcdir}${SL}admin.c \ + ${cvs_srcdir}${SL}buffer.c \ + ${cvs_srcdir}${SL}checkin.c \ + ${cvs_srcdir}${SL}checkout.c \ + ${cvs_srcdir}${SL}classify.c \ + ${cvs_srcdir}${SL}client.c \ + ${cvs_srcdir}${SL}commit.c \ + ${cvs_srcdir}${SL}create_adm.c \ + ${cvs_srcdir}${SL}cvsrc.c \ + ${cvs_srcdir}${SL}diff.c \ + ${cvs_srcdir}${SL}edit.c \ + ${cvs_srcdir}${SL}entries.c \ + ${cvs_srcdir}${SL}error.c \ + ${cvs_srcdir}${SL}expand_path.c \ + ${cvs_srcdir}${SL}fileattr.c \ + ${cvs_srcdir}${SL}find_names.c \ + ${cvs_srcdir}${SL}hash.c \ + ${cvs_srcdir}${SL}history.c \ + ${cvs_srcdir}${SL}ignore.c \ + ${cvs_srcdir}${SL}import.c \ + ${cvs_srcdir}${SL}lock.c \ + ${cvs_srcdir}${SL}log.c \ + ${cvs_srcdir}${SL}login.c \ + ${cvs_srcdir}${SL}logmsg.c \ + ${cvs_srcdir}${SL}main.c \ + ${cvs_srcdir}${SL}mkmodules.c \ + ${cvs_srcdir}${SL}modules.c \ + ${cvs_srcdir}${SL}myndbm.c \ + ${cvs_srcdir}${SL}no_diff.c \ + ${cvs_srcdir}${SL}parseinfo.c \ + ${cvs_srcdir}${SL}patch.c \ + ${cvs_srcdir}${SL}rcs.c \ + ${cvs_srcdir}${SL}rcscmds.c \ + ${cvs_srcdir}${SL}recurse.c \ + ${cvs_srcdir}${SL}release.c \ + ${cvs_srcdir}${SL}remove.c \ + ${cvs_srcdir}${SL}repos.c \ + ${cvs_srcdir}${SL}root.c \ + ${cvs_srcdir}${SL}scramble.c \ + ${cvs_srcdir}${SL}server.c \ + ${cvs_srcdir}${SL}status.c \ + ${cvs_srcdir}${SL}subr.c \ + ${cvs_srcdir}${SL}tag.c \ + ${cvs_srcdir}${SL}update.c \ + ${cvs_srcdir}${SL}watch.c \ + ${cvs_srcdir}${SL}wrapper.c \ + ${cvs_srcdir}${SL}vers_ts.c \ + ${cvs_srcdir}${SL}version.c +# end of $COMMON_SOURCES + +# sources from ..${SL}lib +# FIXME: Is this used anywhere? I don't think it is. +LIB_SOURCES = \ + ${lib_dir}${SL}getdate.c \ + ${lib_dir}${SL}getopt.c \ + ${lib_dir}${SL}getopt1.c \ + ${lib_dir}${SL}getline.c \ + ${lib_dir}${SL}getwd.c \ + ${lib_dir}${SL}savecwd.c \ + ${lib_dir}${SL}sighandle.c \ + ${lib_dir}${SL}yesno.c \ + ${lib_dir}${SL}vasprintf.c \ + ${lib_dir}${SL}xgetwd.c \ + ${lib_dir}${SL}md5.c \ + ${lib_dir}${SL}fnmatch.c \ + ${lib_dir}${SL}regex.c + +# object files from OS/2 sources +OS2_OBJECTS = \ + ${srcdir}${SL}mkdir.obj \ + ${srcdir}${SL}pwd.obj \ + ${srcdir}${SL}filesubr.obj \ + ${srcdir}${SL}dirent.obj \ + ${srcdir}${SL}run.obj \ + ${srcdir}${SL}rcmd.obj \ + ${srcdir}${SL}waitpid.obj \ + ${srcdir}${SL}popen.obj \ + ${srcdir}${SL}porttcp.obj \ + ${srcdir}${SL}getpass.obj + +# object files from ..${SL}src +COMMON_OBJECTS = \ + ${cvs_srcdir}${SL}add.obj \ + ${cvs_srcdir}${SL}admin.obj \ + ${cvs_srcdir}${SL}buffer.obj \ + ${cvs_srcdir}${SL}checkin.obj \ + ${cvs_srcdir}${SL}checkout.obj \ + ${cvs_srcdir}${SL}classify.obj \ + ${cvs_srcdir}${SL}client.obj \ + ${cvs_srcdir}${SL}commit.obj \ + ${cvs_srcdir}${SL}create_adm.obj \ + ${cvs_srcdir}${SL}cvsrc.obj \ + ${cvs_srcdir}${SL}diff.obj \ + ${cvs_srcdir}${SL}edit.obj \ + ${cvs_srcdir}${SL}entries.obj \ + ${cvs_srcdir}${SL}error.obj \ + ${cvs_srcdir}${SL}expand_path.obj \ + ${cvs_srcdir}${SL}fileattr.obj \ + ${cvs_srcdir}${SL}find_names.obj \ + ${cvs_srcdir}${SL}hash.obj \ + ${cvs_srcdir}${SL}history.obj \ + ${cvs_srcdir}${SL}ignore.obj \ + ${cvs_srcdir}${SL}import.obj \ + ${cvs_srcdir}${SL}lock.obj \ + ${cvs_srcdir}${SL}log.obj \ + ${cvs_srcdir}${SL}login.obj \ + ${cvs_srcdir}${SL}logmsg.obj \ + ${cvs_srcdir}${SL}main.obj \ + ${cvs_srcdir}${SL}mkmodules.obj \ + ${cvs_srcdir}${SL}modules.obj \ + ${cvs_srcdir}${SL}myndbm.obj \ + ${cvs_srcdir}${SL}no_diff.obj \ + ${cvs_srcdir}${SL}parseinfo.obj \ + ${cvs_srcdir}${SL}patch.obj \ + ${cvs_srcdir}${SL}rcs.obj \ + ${cvs_srcdir}${SL}rcscmds.obj \ + ${cvs_srcdir}${SL}recurse.obj \ + ${cvs_srcdir}${SL}release.obj \ + ${cvs_srcdir}${SL}remove.obj \ + ${cvs_srcdir}${SL}repos.obj \ + ${cvs_srcdir}${SL}root.obj \ + ${cvs_srcdir}${SL}scramble.obj \ + ${cvs_srcdir}${SL}server.obj \ + ${cvs_srcdir}${SL}status.obj \ + ${cvs_srcdir}${SL}subr.obj \ + ${cvs_srcdir}${SL}tag.obj \ + ${cvs_srcdir}${SL}update.obj \ + ${cvs_srcdir}${SL}watch.obj \ + ${cvs_srcdir}${SL}wrapper.obj \ + ${cvs_srcdir}${SL}vers_ts.obj \ + ${cvs_srcdir}${SL}version.obj \ + ${cvs_srcdir}/zlib.obj +# end of $COMMON_OBJECTS + +# objects from ..${SL}lib +LIB_OBJECTS = \ + ${lib_dir}${SL}getdate.obj \ + ${lib_dir}${SL}getopt.obj \ + ${lib_dir}${SL}getopt1.obj \ + ${lib_dir}${SL}getline.obj \ + ${lib_dir}${SL}getwd.obj \ + ${lib_dir}${SL}savecwd.obj \ + ${lib_dir}${SL}sighandle.obj \ + ${lib_dir}${SL}yesno.obj \ + ${lib_dir}${SL}vasprintf.obj \ + ${lib_dir}${SL}xgetwd.obj \ + ${lib_dir}${SL}md5.obj \ + ${lib_dir}${SL}fnmatch.obj \ + ${lib_dir}${SL}regex.obj \ + ${lib_dir}/valloc.obj + +ZLIB_OBJECTS = ${zlib_dir}/adler32.obj \ + ${zlib_dir}/compress.obj \ + ${zlib_dir}/crc32.obj \ + ${zlib_dir}/uncompr.obj \ + ${zlib_dir}/deflate.obj \ + ${zlib_dir}/trees.obj \ + ${zlib_dir}/zutil.obj \ + ${zlib_dir}/inflate.obj \ + ${zlib_dir}/infblock.obj \ + ${zlib_dir}/inftrees.obj \ + ${zlib_dir}/infcodes.obj \ + ${zlib_dir}/infutil.obj \ + ${zlib_dir}/inffast.obj + +SOURCES = ${COMMON_SOURCES} ${LIB_SOURCES} ${OS2_SOURCES} +HEADERS = ${COMMON_HEADERS} ${OS2_HEADERS} +OBJECTS = ${COMMON_OBJECTS} ${LIB_OBJECTS} ${OS2_OBJECTS} ${ZLIB_OBJECTS} + +DISTFILES = ${OS2_HEADERS} ${OS2_SOURCES} \ + README ChangeLog \ + Makefile.in .cvsignore \ + test-makefile Makefile os2inc.h \ + watcom.mak + +all: + +.PHONY: all install uninstall +all install uninstall: + +# Remove targets for Automake +dvi info pdf ps: +.PHONY: dvi info pdf ps +check installcheck: +.PHONY: check installcheck +installdirs: +lint: +tags TAGS: +.PHONY: installdirs lint tags TAGS + +# distdir added for compatibility with CVS automake. +top_distdir = .. +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @list='$(DISTFILES)'; for file in $$list; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +.PHONY: distdir + +# We don't have a real distclean or anything like that, but at least +# we can get rid of the obj files and cvs.exe. +.PHONY: clean distclean realclean mostlyclean maintainer-clean +clean distclean realclean maintainer-clean mostlyclean: + rm -f cvs.exe + rm -f ${srcdir}${SL}*.obj + rm -f ${lib_dir}${SL}*.obj + rm -f ${cvs_srcdir}${SL}*.obj + +install-cvs: cvs.exe + cp ${srcdir}${SL}cvs.exe ${install_dir}${SL}cvs.exe + +%.obj: %.c + icc ${OBJ_CFLAGS} ${CFLAGS} /Fo$@ $*.c + +# There seems to be no ICC option for specifying library locations, so +# we must `set' the path in the compilation environment. Urgkle. +# +# I'm having some weird problem with "\" vs. "/". If I build +# with "\" as the path separator in the makefile, the compiler dumps +# core. Go figure. If I build with "/" as the path separator, the +# object files compile fine but the linker thinks the "/" is indicating +# options and gets all confused (though at least it doesn't dump core). +# So, use subst to compile with "/" and link with "\". +cvs.exe: ${OBJECTS} + echo Creating icc.in... + echo -Q+ -Ti+ -Fe$@ -B"/batch" -B"/NOE" > icc.in + echo $(subst /,\,$(OS2_OBJECTS)) >> icc.in + echo $(subst /,\,$(LIB_OBJECTS)) >> icc.in + echo $(subst /,\,$(COMMON_OBJECTS)) >> icc.in + echo $(subst /,\,$(ZLIB_OBJECTS)) >> icc.in + echo $(subst /,\,$(TCPIPLIB)) >> icc.in + echo $(subst /,\,$(ARGVLIB)) >> icc.in + echo Creating icc.in... done. + set LIB=$(subst /,\,$(LIB)) & icc @icc.in + +# cvs.obj: ${OBJECTS} ${SOURCES} ${HEADERS} + +# Hmm. This rule wants to exist on unix, so that "make dist" works. +# And it doesn't want to exist on OS/2, because configure doesn't +# run on OS/2 and so ../config.status won't exist. For now we just +# say, in emx/README, that people will need to comment it out. +Makefile: ../config.status $(srcdir)/Makefile.in + cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status diff --git a/os2/README b/os2/README new file mode 100644 index 0000000..c7d6906 --- /dev/null +++ b/os2/README @@ -0,0 +1,50 @@ + This port requires IBM C/C++ and the IBM TCPIP library. It +has probably only been tested with the CVS client. Local CVS might or +might not work, and the server would definitely not work. You'll need +to edit the makefile to reflect your system's paths (unless you're our +customer for this port, in which case the paths are correct because we +did the port on your machine. :-) ). You also may need to comment out +the "Makefile" rule in emx/Makefile to avoid a complaint about +../config.status not existing. You also might need to edit srcdir to +be "." and top_srcdir to be "..". + + That should be all -- edit the makefile, do "make" and get +os2\cvs.exe. Assuming you have edited the `install_dir' variable in +the Makefile, you may type "make install-cvs" to put cvs.exe in the +right place. + + If the makefile has linefeeds only at the end of lines, make +(at least the port of GNU make that I have) will interpret it +differently. This is (IMHO) a bizarre behavior, but you need to +convert the linefeeds to CRLF pairs (editing the file with an editor +such as emacs will generally do this). + + There are two compiler warnings in os2/popen.c which we haven't +figured out the cause of. Other than that there probably aren't a whole +lot of warnings (but there might be a few). +Report bugs to <bug-cvs@nongnu.org>. + + + +Some notes on the watcom port: +------------------------------ + +You need the OS/2 TCPIP developers toolkit to translate the sources. +This is not as bad as it sounds, since the toolkit is on your OS/2 +CD. + +To compile the sources, enter + + wmake -f watcom.mak + +at the OS/2 prompt. + +The executable created by the watcom compiler does *not* need a runtime +DLL. + + + Uz (uz@musoftware.com) + +Credits: + +Original port in 1995 by Karl Fogel <kfogel@cyclic.com>. diff --git a/os2/config.h b/os2/config.h new file mode 100644 index 0000000..f5b5cfe --- /dev/null +++ b/os2/config.h @@ -0,0 +1,514 @@ +/* config.h --- configuration file for OS/2 + Karl Fogel <kfogel@cyclic.com> --- Oct 1995 */ + +/* This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. */ + +/* This file lives in the os2/ subdirectory, which is only included + * in your header search path if you're working under IBM C++, + * and use os2/makefile (with GNU make for OS/2). Thus, this is the + * right place to put configuration information for OS/2. + */ + + +/* We need some system header files here since we evaluate values from + * these files below. + */ +#include <stdio.h> +#include <errno.h> + + + +#ifndef __STDC__ +/* You bet! */ +#define __STDC__ 1 +#endif + +/* The IBM compiler uses the (non-standard) error code EACCESS instead of + EACCES (note: one 'S'). Define EACCESS to be EACCES and use the standard + name in the code. */ +#ifndef EACCES +#define EACCES EACCESS +#endif + +/* Handle some other name differences between the IBM and the Watcom + * compiler. + */ +#ifdef __WATCOMC__ +#define _setmode setmode +#define _cwait cwait +#endif + +/* Some more WATCOM stuff: The watcom compiler defines va_list as an array, + * not as a pointer, which will make the vasprintf code break without the + * following define: + */ +#ifdef __WATCOMC__ +#define VA_LIST_IS_ARRAY +#endif + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#undef _ALL_SOURCE + +/* Define to empty if the keyword does not work. */ +/* Const is working. */ +#undef const + +/* Define to `int' if <sys/types.h> doesn't define. */ +/* OS/2 doesn't have gid_t. It doesn't even really have group + numbers, I think. This will take more thought to get right, but + let's get it running first. */ +#define gid_t int + +/* Define if you support file names longer than 14 characters. */ +/* We support long file names, but not long corporate acronyms. */ +#define HAVE_LONG_FILE_NAMES 1 + +/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */ +/* If POSIX.1 requires this, why doesn't WNT have it? */ +/* Maybe POSIX only says that if it is present, it must behave a + certain way, but that it can simply be not present too. I + dunno. */ +/* Anyway, OS/2 ain't got it. */ +#undef HAVE_SYS_WAIT_H + +/* Define if utime(file, NULL) sets file's timestamp to the present. */ +/* Documentation says yup; haven't verified experimentally. */ +#define HAVE_UTIME_NULL 1 + +/* Define if on MINIX. */ +/* Hah. */ +#undef _MINIX + +/* Define to `int' if <sys/types.h> doesn't define. */ +#define mode_t int + +/* Define to `int' if <sys/types.h> doesn't define. */ +#define pid_t int + +/* Define if the system does not provide POSIX.1 features except + with this defined. */ +/* This string doesn't appear anywhere in the system header files, + so I assume it's irrelevant. */ +#undef _POSIX_1_SOURCE + +/* Define if you need to in order for stat and other things to work. */ +/* Same as for _POSIX_1_SOURCE, above. */ +#undef _POSIX_SOURCE + +/* Define as the return type of signal handlers (int or void). */ +/* IBMCPP manual indicates they are void. */ +#define RETSIGTYPE void + +/* The default remote shell to use, if one does not specify the CVS_RSH + environment variable. */ +#define RSH_DFLT "rsh" + +/* Define to `unsigned' if <sys/types.h> doesn't define. */ +/* sys/types.h doesn't define it, but stdio.h does, which cvs.h + #includes, so things should be okay. */ +/* #undef size_t */ + +/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */ +/* sys/stat.h apparently doesn't even have them; setting this will let + ../lib/system.h define them. */ +#define STAT_MACROS_BROKEN 1 + +/* Define if you have the ANSI C header files. */ +/* We have at least a reasonable facsimile thereof. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both <sys/time.h> and <time.h>. */ +/* We don't have <sys/time.h> at all. Why isn't there a definition + for HAVE_SYS_TIME_H anywhere in config.h.in? */ +#undef TIME_WITH_SYS_TIME + +/* Define to `int' if <sys/types.h> doesn't define. */ +#define uid_t int + +/* Define if you have MIT Kerberos version 4 available. */ +/* We don't. */ +#undef HAVE_KERBEROS + +/* Define if you want CVS to be able to be a remote repository client. */ +/* That's all we want. */ +#define CLIENT_SUPPORT + +/* Define if you want CVS to be able to serve repositories to remote + clients. */ +/* No server support yet. Note that you don't have to define + CLIENT_SUPPORT or SERVER_SUPPORT to enable the non-remote code; + that's always there. */ +#undef SERVER_SUPPORT + +/* Define if you have the connect function. */ +/* Not used? */ +/* It appears to be used in client.c now... don't know yet it OS/2 has it. */ +#define HAVE_CONNECT + +/* Define if you have the fchdir function. */ +#undef HAVE_FCHDIR + +/* Define if you have the fchmod function. */ +#undef HAVE_FCHMOD + +/* Define if you have the fsync function. */ +#undef HAVE_FSYNC + +/* Define if you have the ftime function. */ +#define HAVE_FTIME 1 + +/* Define if you have the ftruncate function. */ +#undef HAVE_FTRUNCATE + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the krb_get_err_text function. */ +#undef HAVE_KRB_GET_ERR_TEXT + +/* Define if you have the putenv function. */ +#define HAVE_PUTENV 1 + +/* Define if you have the sigaction function. */ +#undef HAVE_SIGACTION + +/* Define if you have the sigblock function. */ +#undef HAVE_SIGBLOCK + +/* Define if you have the sigprocmask function. */ +#undef HAVE_SIGPROCMASK + +/* Define if you have the sigsetmask function. */ +#undef HAVE_SIGSETMASK + +/* Define if you have the sigvec function. */ +#undef HAVE_SIGVEC + +/* Define if you have the timezone function. */ +/* Hmm, I actually rather think it's an extern long + variable; that message was mechanically generated + by autoconf. And I don't see any actual uses of + this function in the code anyway, hmm. */ +#undef HAVE_TIMEZONE + +/* Define if you have the tzset function. */ +#define HAVE_TZSET 1 + +/* Define if you have the vfork function. */ +#undef HAVE_VFORK + +/* Define if you have the vprintf function. */ +#define HAVE_VPRINTF 1 + +/* Define if you have the <direct.h> header file. */ +#define HAVE_DIRECT_H 1 + +/* Define if you have the <dirent.h> header file. */ +/* We have our own dirent.h and dirent.c. */ +#ifdef __WATCOMC__ +#undef HAVE_DIRENT_H +#else +#define HAVE_DIRENT_H 1 +#endif + +/* Define if you have the <errno.h> header file. */ +#define HAVE_ERRNO_H 1 + +/* Define if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the <io.h> header file. */ +/* Low-level Unix I/O routines like open, creat, etc. */ +#define HAVE_IO_H 1 + +/* Define if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if you have the <ndbm.h> header file. */ +#undef HAVE_NDBM_H + +/* Define if you have the <ndir.h> header file. */ +#undef HAVE_NDIR_H + +/* Define if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the <sys/bsdtypes.h> header file. */ +#undef HAVE_SYS_BSDTYPES_H + +/* Define if you have the <sys/dir.h> header file. */ +#undef HAVE_SYS_DIR_H + +/* Define if you have the <sys/ndir.h> header file. */ +#undef HAVE_SYS_NDIR_H + +/* Define if you have the <sys/param.h> header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define if you have the <sys/select.h> header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define if you have the <sys/time.h> header file. */ +#undef HAVE_SYS_TIME_H + +/* Define if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the <utime.h> header file. */ +#undef HAVE_UTIME_H + +/* Define if you have the <sys/utime.h> header file. */ +#define HAVE_SYS_UTIME_H 1 + +/* Define if you have the inet library (-linet). */ +#undef HAVE_LIBINET + +/* Define if you have the nsl library (-lnsl). */ +/* This is not used anywhere in the source code. */ +#undef HAVE_LIBNSL + +/* Define if you have the nsl_s library (-lnsl_s). */ +#undef HAVE_LIBNSL_S + +/* Define if you have the socket library (-lsocket). */ +/* This isn't ever used either. */ +#undef HAVE_LIBSOCKET + +/* Under OS/2, mkdir only takes one argument. */ +#define CVS_MKDIR os2_mkdir +extern int os2_mkdir (const char *PATH, int MODE); + +/* OS/2 needs a special chdir functions that handles drives */ +#define CVS_CHDIR os2_chdir +extern int os2_chdir (const char *Dir); + +/* This function doesn't exist under OS/2; we provide a stub. */ +extern int readlink (char *path, char *buf, int buf_size); + +/* This is just a call to GetCurrentProcessID. */ +#ifndef __WATCOMC__ +extern pid_t getpid (void); +#endif + +/* Under OS/2, filenames are case-insensitive, and both / and \ + are path component separators. */ +#define FOLD_FN_CHAR(c) (OS2_filename_classes[(unsigned char) (c)]) +extern unsigned char OS2_filename_classes[]; + +/* Is the character C a path name separator? Under OS/2, you can use + either / or \. */ +#define ISDIRSEP(c) (FOLD_FN_CHAR(c) == '/') + +/* Like strcmp, but with the appropriate tweaks for file names. + Under OS/2, filenames are case-insensitive but case-preserving, + and both \ and / are path element separators. */ +extern int fncmp (const char *n1, const char *n2); + +/* Fold characters in FILENAME to their canonical forms. + If FOLD_FN_CHAR is not #defined, the system provides a default + definition for this. */ +extern void fnfold (char *FILENAME); + +/* This is where old bits go to die under OS/2 as well as WinNT. */ +#define DEVNULL "nul" + +/* Make sure that we don't try to perform operations on RCS files on the + local machine. I think I neglected to apply some changes from + MHI's port in that area of code, or found some issues I didn't want + to deal with. */ +#define CLIENT_ONLY + +/* We actually do have a transparent rsh, whew. */ +#undef RSH_NOT_TRANSPARENT +/* But it won't be transparent unless we ask it nicely! */ +#define RSH_NEEDS_BINARY_FLAG 1 + +/* OS/2 doesn't really have user/group permissions, at least not + according to the C library manual pages. So we'll make decoys. + (This was partly introduced for an obsolete reason, now taken care + of by CHMOD_BROKEN, but I haven't carefully looked at every case + (in particular mode_to_string), so it might still be needed). + We do not need that for the watcom compiler since watcom already + all those permission bits defined. It would probably be better to + include the necessary system header files in system.h, and then make + each permission define only if it is not already defined. +*/ +#ifndef __WATCOMC__ +#define NEED_DECOY_PERMISSIONS 1 /* see system.h */ +#endif + + + +/* For the access() function, for which IBM OS/2 compiler has no pre-defined + mnemonic masks. */ +#ifndef __WATCOMC__ +#define R_OK 04 +#define W_OK 02 +#define F_OK 00 +#define X_OK R_OK /* I think this is right for OS/2. */ +#endif + +/* For getpid() */ +#include <process.h> + +/* So "tcpip.h" gets included in lib/system.h: */ +#define USE_OWN_TCPIP_H 1 +/* The IBM TCP/IP library gets initialized in main(): */ +#define SYSTEM_INITIALIZE(pargc,pargv) init_sockets() +extern void init_sockets(); + +/* Under OS/2, we have our own popen() and pclose()... */ +#define USE_OWN_POPEN 1 +/* ... and we use popenRW to start the rsh server. */ +#define START_RSH_WITH_POPEN_RW 1 + +/* + * This tells the client that it must use send()/recv() to talk to the + * server if it is connected to the server via a socket. Sigh. + * Windows 95 and VMS cannot convert sockets to file descriptors either, + * apparently. + */ +#define NO_SOCKET_TO_FD 1 + +/* chmod() doesn't seem to work -- IBM's own example program does not + * behave as its documentation claims, in fact! I suspect that + * DosSetPathInfo is the way to go, but can't seem to make that work + * either. For now, we can deal with some cases by invoking the DOS + * "attrib" command via system(). */ +#define CHMOD_BROKEN 1 + +/* Rule Number 1 of OS/2 Programming: If the function you're looking + for doesn't exist, try putting "Dos" in front of it. + Do not forget to include the os2 header file if we use DosSleep. */ +#ifndef sleep +#include "os2inc.h" +#define sleep(x) DosSleep(((long)(x))*1000L) +#endif /* sleep */ + +/* Set to 1 for some debugging messages. */ +#if 0 +#define KFF_DEBUG(call) printf("*** %s:%d: ", __FILE__, __LINE__); \ + call; fflush(stdout); +#else +#define KFF_DEBUG(call) +#endif + +/* + * The following configuration options used to be defined in options.h. + */ + +/* + * When committing a permanent change, CVS and RCS make a log entry of + * who committed the change. If you are committing the change logged in + * as "root" (not under "su" or other root-priv giving program), CVS/RCS + * cannot determine who is actually making the change. + * + * As such, by default, CVS disallows changes to be committed by users + * logged in as "root". You can disable this option by commenting + * out the lines below. + * + * Under Windows NT, privileges are associated with groups, not users, + * so the case in which someone has logged in as root does not occur. + * Thus, there is no need for this hack. + * + * todo: I don't know about OS/2 yet. -kff + */ +#undef CVS_BADROOT + +/* This prototype is unique to OS2 */ +#ifdef AUTH_CLIENT_SUPPORT +char *getpass (char *passbuf); +#endif /* AUTH_CLIENT_SUPPORT */ + +/* + * For portability and heterogeneity reasons, CVS is shipped by default using + * my own text-file version of the ndbm database library in the src/myndbm.c + * file. If you want better performance and are not concerned about + * heterogeneous hosts accessing your modules file, turn this option off. + */ +#ifndef MY_NDBM +#define MY_NDBM +#endif + +/* Directory used for storing temporary files, if not overridden by + environment variables or the -T global option. There should be little + need to change this (-T is a better mechanism if you need to use a + different directory for temporary files). */ +#ifndef TMPDIR_DFLT +#define TMPDIR_DFLT "c:\\temp" +#endif + +/* + * The default editor to use, if one does not specify the "-e" option to cvs, + * or does not have an EDITOR environment variable. I set this to just "vi", + * and use the shell to find where "vi" actually is. This allows sites with + * /usr/bin/vi or /usr/ucb/vi to work equally well (assuming that your PATH + * is reasonable). + * + * The notepad program seems to be Windows NT's bare-bones text editor. + */ +#ifndef EDITOR_DFLT +#define EDITOR_DFLT "notepad" +#endif + +/* + * The default umask to use when creating or otherwise setting file or + * directory permissions in the repository. Must be a value in the + * range of 0 through 0777. For example, a value of 002 allows group + * rwx access and world rx access; a value of 007 allows group rwx + * access but no world access. This value is overridden by the value + * of the CVSUMASK environment variable, which is interpreted as an + * octal number. + */ +#ifndef UMASK_DFLT +#define UMASK_DFLT 002 +#endif + +/* + * The cvs admin command is restricted to the members of the group + * CVS_ADMIN_GROUP. If this group does not exist, all users are + * allowed to run cvs admin. To disable the cvs admin for all users, + * create an empty group CVS_ADMIN_GROUP. To disable access control for + * cvs admin, comment out the define below. + * + * Under Windows NT and OS/2, this must not be used because it tries + * to include <grp.h>. + */ +#ifdef CVS_ADMIN_GROUP +/* #define CVS_ADMIN_GROUP "cvsadmin" */ +#endif + +/* + * When committing or importing files, you must enter a log message. + * Normally, you can do this either via the -m flag on the command line or an + * editor will be started for you. If you like to use logging templates (the + * rcsinfo file within the $CVSROOT/CVSROOT directory), you might want to + * force people to use the editor even if they specify a message with -m. + * Enabling FORCE_USE_EDITOR will cause the -m message to be appended to the + * temp file when the editor is started. + */ +#ifndef FORCE_USE_EDITOR +/* #define FORCE_USE_EDITOR */ +#endif + +/* + * Under OS/2, we build the authenticated client by default. + */ +#define AUTH_CLIENT_SUPPORT 1 + +/* End of CVS options.h section */ + +/* FIXME: This is the same definition used for WOE32 in lib/system.h. It + * should be consolidated. + */ +#define ISABSOLUTE(s) (ISDIRSEP(s[0]) || FOLD_FN_CHAR(s[0]) >= 'a' && FOLD_FN_CHAR(s[0]) <= 'z' && s[1] == ':' && ISDIRSEP(s[2])) diff --git a/os2/dirent.c b/os2/dirent.c new file mode 100644 index 0000000..f835cb5 --- /dev/null +++ b/os2/dirent.c @@ -0,0 +1,180 @@ +/* + * Author: Bob Withers + * Copyright (c) 1993, All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + +#include <stdlib.h> +#include <string.h> + +#define INCL_DOSFILEMGR +#define INCL_DOSERRORS +#include <os2.h> + +#include "dirent.h" + + +#define DIRENT_INCR 25 + + +DIR *opendir(char *filename) +{ + auto size_t len; + auto DIR *dirp; + auto char *p; + auto HDIR hdir; + +#ifdef OS2_16 + auto USHORT rc; /* for 16 bit OS/2 */ + auto FILEFINDBUF ff; + auto USHORT cnt; +#else + auto APIRET rc; /* for 32 bit OS/2 */ + auto FILEFINDBUF3 ff; + auto ULONG cnt; +#endif /* OS2_16 */ + + if (NULL == filename || '\0' == filename[0]) + filename = "."; + + dirp = xmalloc(sizeof(*dirp)); + if (NULL == dirp) + return(NULL); + + len = strlen(filename); + dirp->dirname = xmalloc(len + 5); + if (NULL == dirp->dirname) + { + free(dirp); + return(NULL); + } + + dirp->max_ent = 0; + dirp->tot_ent = 0; + dirp->cur_ent = 0; + dirp->entp = NULL; + strcpy(dirp->dirname, filename); + for (p = dirp->dirname; *p; ++p) + { + if ('/' == *p) + *p = '\\'; + } + + if ('\\' != dirp->dirname[len - 1]) + strcat(dirp->dirname, "\\"); + + strcat(dirp->dirname, "*.*"); + + hdir = HDIR_SYSTEM; + cnt = 1; + rc = DosFindFirst(dirp->dirname, &hdir, + FILE_NORMAL | FILE_READONLY | FILE_HIDDEN | + FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED, + &ff, sizeof(ff), &cnt, FIL_STANDARD); + + while (NO_ERROR == rc) + { + auto struct dirent *entp; + + if (dirp->tot_ent >= dirp->max_ent) + { + auto struct dirent **p; + + dirp->max_ent += DIRENT_INCR; + p = xrealloc(dirp->entp, dirp->max_ent * sizeof(entp)); + if (NULL == p) + { + rc = ERROR_NOT_ENOUGH_MEMORY; + break; + } + + dirp->entp = p; + } + + entp = xmalloc(sizeof(*entp) + (size_t) ff.cchName); + if (NULL == entp) + { + rc = ERROR_NOT_ENOUGH_MEMORY; + break; + } + + entp->d_ino = 0; + entp->d_off = dirp->tot_ent; + entp->d_namlen = (unsigned short) ff.cchName; + memcpy(entp->d_name, ff.achName, entp->d_namlen); + entp->d_name[entp->d_namlen] = '\0'; + dirp->entp[dirp->tot_ent++] = entp; + + cnt = 1; + rc = DosFindNext(hdir, &ff, sizeof(ff), &cnt); + } + + DosFindClose(hdir); + if (ERROR_NO_MORE_FILES == rc) + return(dirp); + + closedir(dirp); + return(NULL); +} + + +struct dirent *readdir(DIR *dirp) +{ + if (dirp->cur_ent < 0 || dirp->cur_ent >= dirp->tot_ent) + return(NULL); + + return(dirp->entp[dirp->cur_ent++]); +} + + +long telldir(DIR *dirp) +{ + return((long) dirp->cur_ent); +} + + +void seekdir(DIR *dirp, long loc) +{ + dirp->cur_ent = (int) loc; + return; +} + + +void rewinddir(DIR *dirp) +{ + dirp->cur_ent = 0; + return; +} + + +void closedir(DIR *dirp) +{ + if (dirp) + { + if (dirp->dirname) + free(dirp->dirname); + + if (dirp->entp) + { + register int i; + + for (i = 0; i < dirp->tot_ent; ++i) + free(dirp->entp[i]); + + free(dirp->entp); + } + } + + return; +} diff --git a/os2/dirent.h b/os2/dirent.h new file mode 100644 index 0000000..bc218b5 --- /dev/null +++ b/os2/dirent.h @@ -0,0 +1,50 @@ +/* + * Author: Bob Withers + * Copyright (c) 1993, All Rights Reserved + * + * NOTICE + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * The author makes no representations about the suitability of this + * software for any purpose. This software is provided ``as is'' + * without express or implied warranty. + */ + +#ifndef DIRENT_H +#define DIRENT_H + +/* Unix style directory(3C) support for OS/2 V2.x */ + +struct dirent +{ + long d_ino; /* not used in this implementation */ + long d_off; /* not used in this implementation */ + unsigned short d_namlen; + char d_name[1]; +}; + + +struct S_Dir +{ + char *dirname; + int max_ent; + int tot_ent; + int cur_ent; + struct dirent **entp; +}; +typedef struct S_Dir DIR; + + +DIR * opendir(char *filename); +struct dirent * readdir(DIR *dirp); +long telldir(DIR *dirp); +void seekdir(DIR *dirp, long loc); +void rewinddir(DIR *dirp); +void closedir(DIR *dirp); + +#endif /* DIRENT_H */ diff --git a/os2/filesubr.c b/os2/filesubr.c new file mode 100644 index 0000000..e70f4ec --- /dev/null +++ b/os2/filesubr.c @@ -0,0 +1,946 @@ +/* filesubr.c --- subroutines for dealing with files under OS/2 + Jim Blandy <jimb@cyclic.com> and Karl Fogel <kfogel@cyclic.com> + + This file is part of GNU CVS. + + GNU CVS is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. */ + +/* These functions were moved out of subr.c because they need different + definitions under operating systems (like, say, Windows NT) with different + file system semantics. */ + +#include <io.h> + +#include "os2inc.h" +#include "cvs.h" + +static int deep_remove_dir( const char *path ); + +/* + * Copies "from" to "to". + */ +void +copy_file (from, to) + const char *from; + const char *to; +{ + struct stat sb; + struct utimbuf t; + int fdin, fdout; + + if (trace) +#ifdef SERVER_SUPPORT + (void) fprintf (stderr, "%c-> copy(%s,%s)\n", + (server_active) ? 'S' : ' ', from, to); +#else + (void) fprintf (stderr, "-> copy(%s,%s)\n", from, to); +#endif + if (noexec) + return; + + if ((fdin = open (from, O_RDONLY | O_BINARY)) < 0) + error (1, errno, "cannot open %s for copying", from); + if (fstat (fdin, &sb) < 0) + error (1, errno, "cannot fstat %s", from); + if ((fdout = open (to, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, + (int) sb.st_mode & 07777)) < 0) + error (1, errno, "cannot create %s for copying", to); + if (sb.st_size > 0) + { + char buf[BUFSIZ]; + int n; + + for (;;) + { + n = read (fdin, buf, sizeof(buf)); + if (n == -1) + { +#ifdef EINTR + if (errno == EINTR) + continue; +#endif + error (1, errno, "cannot read file %s for copying", from); + } + else if (n == 0) + break; + + if (write(fdout, buf, n) != n) { + error (1, errno, "cannot write file %s for copying", to); + } + } + +#ifdef HAVE_FSYNC + if (fsync (fdout)) + error (1, errno, "cannot fsync file %s after copying", to); +#endif + } + + if (close (fdin) < 0) + error (0, errno, "cannot close %s", from); + if (close (fdout) < 0) + error (1, errno, "cannot close %s", to); + + /* now, set the times for the copied file to match those of the original */ + memset ((char *) &t, 0, sizeof (t)); + t.actime = sb.st_atime; + t.modtime = sb.st_mtime; + (void) utime ((char *)to, &t); +} + +/* FIXME-krp: these functions would benefit from caching the char * & + stat buf. */ + +/* + * Returns non-zero if the argument file is a directory, or is a symbolic + * link which points to a directory. + */ +int +isdir (file) + const char *file; +{ + struct stat sb; + + if (stat (file, &sb) < 0) + return (0); + return (S_ISDIR (sb.st_mode)); +} + +/* + * Returns non-zero if the argument file is a symbolic link. + */ +int +islink (file) + const char *file; +{ +#ifdef S_ISLNK + struct stat sb; + + if (lstat (file, &sb) < 0) + return (0); + return (S_ISLNK (sb.st_mode)); +#else + return (0); +#endif +} + +/* + * Returns non-zero if the argument file exists. + */ +int +isfile (file) + const char *file; +{ + struct stat sb; + + if (stat (file, &sb) < 0) + return (0); + return (1); +} + +/* + * Returns non-zero if the argument file is readable. + * XXX - must be careful if "cvs" is ever made setuid! + */ +int +isreadable (file) + const char *file; +{ + return (access (file, R_OK) != -1); +} + +/* + * Returns non-zero if the argument file is writable + * XXX - muct be careful if "cvs" is ever made setuid! + */ +int +iswritable (file) + const char *file; +{ + return (access (file, W_OK) != -1); +} + +/* + * Returns non-zero if the argument file is accessable according to + * mode. If compiled with SETXID_SUPPORT also works if cvs has setxid + * bits set. + */ +int +isaccessible (file, mode) + const char *file; + const int mode; +{ + return access(file, mode) == 0; +} + + + +/* + * Make a directory and die if it fails + */ +void +make_directory (name) + const char *name; +{ + struct stat buf; + + if (stat (name, &buf) == 0 && (!S_ISDIR (buf.st_mode))) + error (0, 0, "%s already exists but is not a directory", name); + if (!noexec && mkdir ((char *)name) < 0) + error (1, errno, "cannot make directory %s", name); +} + +/* + * Make a path to the argument directory, printing a message if something + * goes wrong. + */ +void +make_directories (name) + const char *name; +{ + char *cp; + + if (noexec) + return; + + if (mkdir ((char *)name) == 0 || errno == EACCES) + return; + if (! existence_error (errno)) + { + error (0, errno, "cannot make path to %s", name); + return; + } + if ((cp = strrchr (name, '/')) == NULL) + return; + *cp = '\0'; + make_directories (name); + *cp++ = '/'; + if (*cp == '\0') + return; + (void) mkdir ((char *)name); +} + +/* Create directory NAME if it does not already exist; fatal error for + other errors. Returns 0 if directory was created; 1 if it already + existed. */ +int +mkdir_if_needed (name) + char *name; +{ + if (mkdir (name) < 0) + { + /* Now, let me get this straight. In IBM C/C++ + under OS/2, the error string for EEXIST is: + + "The file already exists", + + and the error string for EACCES is: + + "The file or directory specified is read-only". + + Nonetheless, mkdir() will set EACCES if the + directory *exists*, according both to the + documentation and its actual behavior. + + I'm sure that this made sense, to someone, + somewhere, sometime. Just not me, here, now. */ + if (errno != EEXIST +#ifdef EACCES + && errno != EACCES +#endif + ) + error (1, errno, "cannot make directory %s", name); + return 1; + } + return 0; +} + +/* + * Change the mode of a file, either adding write permissions, or removing + * all write permissions. Adding write permissions honors the current umask + * setting. + */ +void +xchmod (fname, writable) + char *fname; + int writable; +{ + char *attrib_cmd; + char *attrib_option; + char *whole_cmd; + char *p; + char *q; + + if (!isfile (fname)) + { + error (0, 0, "cannot change mode of file %s; it does not exist", + fname); + return; + } + + attrib_cmd = "attrib "; /* No, really? */ + + if (writable) + attrib_option = "-r "; /* make writeable */ + else + attrib_option = "+r "; /* make read-only */ + + whole_cmd = xmalloc (strlen (attrib_cmd) + + strlen (attrib_option) + + strlen (fname) + + 1); + + strcpy (whole_cmd, attrib_cmd); + strcat (whole_cmd, attrib_option); + + /* Copy fname to the end of whole_cmd, translating / to \. + Attrib doesn't take / but many parts of CVS rely + on being able to use it. */ + p = whole_cmd + strlen (whole_cmd); + q = fname; + while (*q) + { + if (*q == '/') + *p++ = '\\'; + else + *p++ = *q; + ++q; + } + *p = '\0'; + + system (whole_cmd); + free (whole_cmd); +} + + +/* Read the value of a symbolic link. + Under OS/2, this function always returns EINVAL. */ +int +readlink (char *path, char *buf, int buf_size) +{ + errno = EINVAL; + return -1; +} + +/* + * unlink a file, if possible. + */ +int +unlink_file (f) + const char *f; +{ + if (trace) +#ifdef SERVER_SUPPORT + (void) fprintf (stderr, "%c-> unlink(%s)\n", + (server_active) ? 'S' : ' ', f); +#else + (void) fprintf (stderr, "-> unlink(%s)\n", f); +#endif + if (noexec) + return (0); + + /* Win32 unlink is stupid - it fails if the file is read-only. + * OS/2 is similarly stupid. It does have a remove() function, + * but the documentation does not make clear why remove() is or + * isn't preferable to unlink(). I'll use unlink() because the + * name is closer to our interface, what the heck. Also, we know + * unlink()'s error code when trying to remove a directory. + */ + if (isfile (f)) + xchmod ((char *)f, 1); + return (unlink (f)); +} + +/* + * Unlink a file or dir, if possible. If it is a directory do a deep + * removal of all of the files in the directory. Return -1 on error + * (in which case errno is set). + */ +int +unlink_file_dir (f) + const char *f; +{ + if (trace) +#ifdef SERVER_SUPPORT + (void) fprintf (stderr, "%c-> unlink_file_dir(%s)\n", + (server_active) ? 'S' : ' ', f); +#else + (void) fprintf (stderr, "-> unlink_file_dir(%s)\n", f); +#endif + if (noexec) + return (0); + + if (unlink_file (f) != 0) + { + /* under OS/2, unlink returns EACCES if the path + is a directory. */ + if (errno == EACCES) + return deep_remove_dir (f); + else + /* The file wasn't a directory and some other + * error occured + */ + return -1; + } + /* We were able to remove the file from the disk */ + return 0; +} + +/* Remove a directory and everything it contains. Returns 0 for + * success, -1 for failure (in which case errno is set). + */ + +static int +deep_remove_dir (path) + const char *path; +{ + DIR *dirp; + struct dirent *dp; + char buf[PATH_MAX]; + + if (rmdir ((char *)path) != 0 && errno == EACCES) + { + if ((dirp = opendir ((char *)path)) == NULL) + /* If unable to open the directory return + * an error + */ + return -1; + + while ((dp = readdir (dirp)) != NULL) + { + if (strcmp (dp->d_name, ".") == 0 || + strcmp (dp->d_name, "..") == 0) + continue; + + sprintf (buf, "%s/%s", path, dp->d_name); + + if (unlink_file (buf) != 0 ) + { + if (errno == EACCES) + { + if (deep_remove_dir (buf)) + { + closedir (dirp); + return -1; + } + } + else + { + /* buf isn't a directory, or there are + * some sort of permision problems + */ + closedir (dirp); + return -1; + } + } + } + closedir (dirp); + return rmdir ((char *)path); + } + /* Was able to remove the directory return 0 */ + return 0; +} + + +/* + * Rename a file and die if it fails + */ +void +rename_file (from, to) + const char *from; + const char *to; +{ + if (trace) +#ifdef SERVER_SUPPORT + (void) fprintf (stderr, "%c-> rename(%s,%s)\n", + (server_active) ? 'S' : ' ', from, to); +#else + (void) fprintf (stderr, "-> rename(%s,%s)\n", from, to); +#endif + if (noexec) + return; + + unlink_file (to); + if (rename (from, to) != 0) + error (1, errno, "cannot rename file %s to %s", from, to); +} + + +/* Read NCHARS bytes from descriptor FD into BUF. + Return the number of characters successfully read. + The number returned is always NCHARS unless end-of-file or error. */ +static size_t +block_read (fd, buf, nchars) + int fd; + char *buf; + size_t nchars; +{ + char *bp = buf; + size_t nread; + + do + { + nread = read (fd, bp, nchars); + if (nread == (size_t)-1) + { +#ifdef EINTR + if (errno == EINTR) + continue; +#endif + return (size_t)-1; + } + + if (nread == 0) + break; + + bp += nread; + nchars -= nread; + } while (nchars != 0); + + return bp - buf; +} + + +/* + * Compare "file1" to "file2". Return non-zero if they don't compare exactly. + */ +int +xcmp (file1, file2) + const char *file1; + const char *file2; +{ + char *buf1, *buf2; + struct stat sb1, sb2; + int fd1, fd2; + int ret; + + if ((fd1 = open (file1, O_RDONLY | O_BINARY)) < 0) + error (1, errno, "cannot open file %s for comparing", file1); + if ((fd2 = open (file2, O_RDONLY | O_BINARY)) < 0) + error (1, errno, "cannot open file %s for comparing", file2); + if (fstat (fd1, &sb1) < 0) + error (1, errno, "cannot fstat %s", file1); + if (fstat (fd2, &sb2) < 0) + error (1, errno, "cannot fstat %s", file2); + + /* A generic file compare routine might compare st_dev & st_ino here + to see if the two files being compared are actually the same file. + But that won't happen in CVS, so we won't bother. */ + + if (sb1.st_size != sb2.st_size) + ret = 1; + else if (sb1.st_size == 0) + ret = 0; + else + { + /* FIXME: compute the optimal buffer size by computing the least + common multiple of the files st_blocks field */ + size_t buf_size = 8 * 1024; + size_t read1; + size_t read2; + + buf1 = xmalloc (buf_size); + buf2 = xmalloc (buf_size); + + do + { + read1 = block_read (fd1, buf1, buf_size); + if (read1 == (size_t)-1) + error (1, errno, "cannot read file %s for comparing", file1); + + read2 = block_read (fd2, buf2, buf_size); + if (read2 == (size_t)-1) + error (1, errno, "cannot read file %s for comparing", file2); + + /* assert (read1 == read2); */ + + ret = memcmp(buf1, buf2, read1); + } while (ret == 0 && read1 == buf_size); + + free (buf1); + free (buf2); + } + + (void) close (fd1); + (void) close (fd2); + return (ret); +} + + +/* The equivalence class mapping for filenames. + OS/2 filenames are case-insensitive, but case-preserving. Both / + and \ are path element separators. + Thus, this table maps both upper and lower case to lower case, and + both / and \ to /. + + Much thanks to Jim Blandy, who already invented this wheel in the + Windows NT port. */ + +#if 0 +main () +{ + int c; + + for (c = 0; c < 256; c++) + { + int t; + + if (c == '\\') + t = '/'; + else + t = tolower (c); + + if ((c & 0x7) == 0x0) + printf (" "); + printf ("0x%02x,", t); + if ((c & 0x7) == 0x7) + putchar ('\n'); + else if ((c & 0x7) == 0x3) + putchar (' '); + } +} +#endif + + +unsigned char +OS2_filename_classes[] = +{ + 0x00,0x01,0x02,0x03, 0x04,0x05,0x06,0x07, + 0x08,0x09,0x0a,0x0b, 0x0c,0x0d,0x0e,0x0f, + 0x10,0x11,0x12,0x13, 0x14,0x15,0x16,0x17, + 0x18,0x19,0x1a,0x1b, 0x1c,0x1d,0x1e,0x1f, + 0x20,0x21,0x22,0x23, 0x24,0x25,0x26,0x27, + 0x28,0x29,0x2a,0x2b, 0x2c,0x2d,0x2e,0x2f, + 0x30,0x31,0x32,0x33, 0x34,0x35,0x36,0x37, + 0x38,0x39,0x3a,0x3b, 0x3c,0x3d,0x3e,0x3f, + 0x40,0x61,0x62,0x63, 0x64,0x65,0x66,0x67, + 0x68,0x69,0x6a,0x6b, 0x6c,0x6d,0x6e,0x6f, + 0x70,0x71,0x72,0x73, 0x74,0x75,0x76,0x77, + 0x78,0x79,0x7a,0x5b, 0x2f,0x5d,0x5e,0x5f, + 0x60,0x61,0x62,0x63, 0x64,0x65,0x66,0x67, + 0x68,0x69,0x6a,0x6b, 0x6c,0x6d,0x6e,0x6f, + 0x70,0x71,0x72,0x73, 0x74,0x75,0x76,0x77, + 0x78,0x79,0x7a,0x7b, 0x7c,0x7d,0x7e,0x7f, + 0x80,0x81,0x82,0x83, 0x84,0x85,0x86,0x87, + 0x88,0x89,0x8a,0x8b, 0x8c,0x8d,0x8e,0x8f, + 0x90,0x91,0x92,0x93, 0x94,0x95,0x96,0x97, + 0x98,0x99,0x9a,0x9b, 0x9c,0x9d,0x9e,0x9f, + 0xa0,0xa1,0xa2,0xa3, 0xa4,0xa5,0xa6,0xa7, + 0xa8,0xa9,0xaa,0xab, 0xac,0xad,0xae,0xaf, + 0xb0,0xb1,0xb2,0xb3, 0xb4,0xb5,0xb6,0xb7, + 0xb8,0xb9,0xba,0xbb, 0xbc,0xbd,0xbe,0xbf, + 0xc0,0xc1,0xc2,0xc3, 0xc4,0xc5,0xc6,0xc7, + 0xc8,0xc9,0xca,0xcb, 0xcc,0xcd,0xce,0xcf, + 0xd0,0xd1,0xd2,0xd3, 0xd4,0xd5,0xd6,0xd7, + 0xd8,0xd9,0xda,0xdb, 0xdc,0xdd,0xde,0xdf, + 0xe0,0xe1,0xe2,0xe3, 0xe4,0xe5,0xe6,0xe7, + 0xe8,0xe9,0xea,0xeb, 0xec,0xed,0xee,0xef, + 0xf0,0xf1,0xf2,0xf3, 0xf4,0xf5,0xf6,0xf7, + 0xf8,0xf9,0xfa,0xfb, 0xfc,0xfd,0xfe,0xff, +}; + +/* Like strcmp, but with the appropriate tweaks for file names. + Under OS/2, filenames are case-insensitive but case-preserving, and + both \ and / are path element separators. */ +int +fncmp (const char *n1, const char *n2) +{ + while (*n1 && *n2 + && (OS2_filename_classes[(unsigned char) *n1] + == OS2_filename_classes[(unsigned char) *n2])) + n1++, n2++; + return (OS2_filename_classes[(unsigned char) *n1] + - OS2_filename_classes[(unsigned char) *n2]); +} + +/* Fold characters in FILENAME to their canonical forms. + If FOLD_FN_CHAR is not #defined, the system provides a default + definition for this. */ +void +fnfold (char *filename) +{ + while (*filename) + { + *filename = FOLD_FN_CHAR (*filename); + filename++; + } +} + + +/* Generate a unique temporary filename. Returns a pointer to a newly + malloc'd string containing the name. Returns successfully or not at + all. */ +char * +cvs_temp_name () +{ + char value[L_tmpnam + 1]; + char *retval; + + /* FIXME: Does OS/2 have some equivalent to TMPDIR? */ + retval = tmpnam (value); + if (retval == NULL) + error (1, errno, "cannot generate temporary filename"); + return xstrdup (retval); +} + + + +/* char * + * xresolvepath ( const char *path ) + * + * Like xreadlink(), but resolve all links in a path. + * + * INPUTS + * path The original path. + * + * RETURNS + * The path with any symbolic links expanded. + * + * ERRORS + * This function exits with a fatal error if it fails to read the link for + * any reason. + */ +char * +xresolvepath ( path ) + const char *path; +{ + char *hardpath; + char *owd; + + /* assert ( isdir ( path ) ); */ + + /* FIXME - If HAVE_READLINK is defined, we should probably walk the path + * bit by bit calling xreadlink(). + */ + + owd = xgetwd(); + if ( CVS_CHDIR ( path ) < 0) + error ( 1, errno, "cannot chdir to %s", path ); + if ( ( hardpath = xgetwd() ) == NULL ) + error (1, errno, "cannot readlink %s", hardpath); + if ( CVS_CHDIR ( owd ) < 0) + error ( 1, errno, "cannot chdir to %s", owd ); + free (owd); + return hardpath; +} + +/* Return a pointer into PATH's last component. */ +char * +last_component (char *path) +{ + char *scan; + char *last = 0; + + for (scan = path; *scan; scan++) + if (ISDIRSEP (*scan)) + last = scan; + + if (last && (last != path)) + return last + 1; + else + return path; +} + + +/* Return the home directory. Returns a pointer to storage + managed by this function or its callees (currently getenv). */ +char * +get_homedir () +{ + return getenv ("HOME"); +} + +/* See cvs.h for description. */ +void +expand_wild (argc, argv, pargc, pargv) + int argc; + char **argv; + int *pargc; + char ***pargv; +{ + int i; + int new_argc; + char **new_argv; + /* Allocated size of new_argv. We arrange it so there is always room for + one more element. */ + int max_new_argc; + + new_argc = 0; + /* Add one so this is never zero. */ + max_new_argc = argc + 1; + new_argv = (char **) xmalloc (max_new_argc * sizeof (char *)); + for (i = 0; i < argc; ++i) + { + HDIR FindHandle = 0x0001; + FILEFINDBUF3 FindBuffer; + ULONG FindCount = 1; + APIRET rc; /* Return code */ +#define ALL_FILES (FILE_ARCHIVED|FILE_DIRECTORY|FILE_SYSTEM|FILE_HIDDEN|FILE_READONLY) + + /* DosFindFirst, called with a string like 'dir/file' will return + * *only* the file part. So what we have to do here is to save the + * directory part, and add it later to the returned filename. + */ + + /* Path + name */ + char *PathName = argv [i]; + + /* Path only, including slash */ + char *Path = NULL; + + /* Name without path */ + char *Name = last_component (PathName); + + if (Name > PathName) + { + /* We have a path component, save it */ + Path = xmalloc (Name - PathName + 1); + memcpy (Path, PathName, Name - PathName); + Path [Name - PathName] = '\0'; + } + + rc = DosFindFirst(PathName, /* File pattern */ + &FindHandle, /* Directory search handle */ + ALL_FILES, /* Search attribute */ + (PVOID) &FindBuffer, /* Result buffer */ + sizeof(FindBuffer), /* Result buffer length */ + &FindCount, /* Number of entries to find */ + FIL_STANDARD); /* Return level 1 file info */ + + if (rc != 0) + { + if (rc == ERROR_NO_MORE_FILES) + { + /* No match. The file specified didn't contain a wildcard (in which case + we clearly should return it unchanged), or it contained a wildcard which + didn't match (in which case it might be better for it to be an error, + but we don't try to do that). */ + new_argv [new_argc++] = xstrdup (argv[i]); + if (new_argc == max_new_argc) + { + max_new_argc *= 2; + new_argv = xrealloc (new_argv, max_new_argc * sizeof (char *)); + } + } + else + { + error (1, rc, "cannot find %s", PathName); + } + } + else + { + while (1) + { + /* + * Don't match ".", "..", and files starting with '.' + * (unless pattern also starts with '.'). This is + * (more or less) what standard Unix globbing does. + */ + if ((strcmp(FindBuffer.achName, ".") != 0) && + (strcmp(FindBuffer.achName, "..") != 0) && + ((argv[i][0] == '.') || (FindBuffer.achName[0] != '.'))) + { + /* Be sure to add the path if needed */ + char *NewArg; + if (Path) + { + unsigned Len = + strlen (Path) + strlen (FindBuffer.achName) + 1; + NewArg = xmalloc (Len); + strcpy (NewArg, Path); + strcat (NewArg, FindBuffer.achName); + } + else + { + NewArg = xstrdup (FindBuffer.achName); + } + new_argv [new_argc++] = NewArg; + if (new_argc == max_new_argc) + { + max_new_argc *= 2; + new_argv = xrealloc (new_argv, max_new_argc * sizeof (char *)); + } + } + + rc = DosFindNext (FindHandle, + (PVOID) &FindBuffer, + sizeof(FindBuffer), + &FindCount); + if (rc == ERROR_NO_MORE_FILES) + break; + else if (rc != NO_ERROR) + error (1, rc, "cannot find %s", argv[i]); + } + rc = DosFindClose(FindHandle); + if (rc != 0) + error (1, rc, "cannot close %s", argv[i]); + } + if (Path != NULL) + free (Path); + } + *pargc = new_argc; + *pargv = new_argv; +} + +/* Change drive and directory to path DIR. */ + +int +os2_chdir (const char *Dir) +{ + /* If the path includes a drive, change the current drive to the one + given. */ + if (strlen (Dir) >= 2 && Dir [1] == ':') + { + /* A drive is given in Dir. Extract the drive from the string, then + * remove the drive from Dir by incrementing it. + */ + int Drive = Dir [0]; + Dir += 2; + + /* Check if the given drive is valid, convert to a drive number + * (A: == 1, B: == 2, etc.). The compare below assumes ascii, but + * that is not a problem with OS/2. + */ + if (Drive >= 'a' && Drive <= 'z') + { + Drive -= 'a' - 1; + } + else if (Drive >= 'A' && Drive <= 'Z') + { + Drive -= 'A' - 1; + } + else + { + /* An invalid drive letter. Set errno and return an error */ + errno = EACCES; + return -1; + } + + /* We have a valid drive given, so change the drive now */ + if (DosSetDefaultDisk (Drive) != 0) + { + /* We had an error. Assume that the drive does not exist */ +#ifdef ENODEV + errno = ENODEV; +#else + /* IBM C/C++ Tools 2.01 seems to lack ENODEV. */ + errno = ENOENT; +#endif + return -1; + } + + } + + /* Now we have a path without a drive left. Make it the current dir */ + return chdir (Dir); +} + + + diff --git a/os2/getpass.c b/os2/getpass.c new file mode 100644 index 0000000..e9ceb22 --- /dev/null +++ b/os2/getpass.c @@ -0,0 +1,63 @@ +#include <stdio.h> +#include <string.h> +#include "cvs.h" +#include "os2inc.h" + +/* Only define this if you're testing and want to compile this file + standalone. */ +/* #define DIAGNOSTIC */ + +/* Turn off keyboard echo. Does not check error returns. */ +static void +EchoOff (void) +{ + KBDINFO KbdInfo; + + KbdGetStatus (&KbdInfo, 0); + KbdInfo.fsMask = (KbdInfo.fsMask & ~KEYBOARD_ECHO_ON) | KEYBOARD_ECHO_OFF; + KbdSetStatus (&KbdInfo, 0); +} + +/* Turn on keyboard echo. Does not check error returns. */ +static void +EchoOn( void ) +{ + KBDINFO KbdInfo; + + KbdGetStatus (&KbdInfo, 0); + KbdInfo.fsMask = (KbdInfo.fsMask & ~KEYBOARD_ECHO_OFF) | KEYBOARD_ECHO_ON; + KbdSetStatus (&KbdInfo, 0); +} + +char * +getpass (char *prompt) +{ + static char Buf[80]; + STRINGINBUF StringInBuf; + + printf ("%s", prompt); + fflush (stdout); + + EchoOff (); + + StringInBuf.cb = sizeof (Buf) - 1; + StringInBuf.cchIn = 0; + KbdStringIn ((PSZ) Buf, &StringInBuf, IO_WAIT, 0); + Buf[StringInBuf.cchIn] = '\0'; + + EchoOn (); + + return Buf; +} + + +#ifdef DIAGNOSTIC +main() +{ + char *s; + s = getpass ("Input password (no echo): "); + printf ("String was \"%s\"\n", s); + fflush (stdout); +} +#endif /* DIAGNOSTIC */ + diff --git a/os2/mkdir.c b/os2/mkdir.c new file mode 100644 index 0000000..2c9df54 --- /dev/null +++ b/os2/mkdir.c @@ -0,0 +1,17 @@ +/* mkdir.c --- mkdir for OS/2 + Karl Fogel <kfogel@cyclic.com> --- October 1995 */ + +#include <assert.h> + +#include "cvs.h" + +int +os2_mkdir (const char *path, int mode) +{ + /* This is true for all extant calls to CVS_MKDIR. If + someone adds a call that uses something else later, + we should tweak this function to handle that. */ + assert (mode == 0777); + + return mkdir (path); +} diff --git a/os2/os2inc.h b/os2/os2inc.h new file mode 100644 index 0000000..ba348a1 --- /dev/null +++ b/os2/os2inc.h @@ -0,0 +1,22 @@ +/* This file is used to make the os/2 header files idempotent. + Written 11/96 by Ullrich von Bassewitz (uz@musoftware.com) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. */ + +#ifndef IN_OS2INC_H +#define IN_OS2INC_H + +#define INCL_BASE +#define INCL_SUB +#define INCL_KBD +#include <os2.h> + +#endif diff --git a/os2/popen.c b/os2/popen.c new file mode 100644 index 0000000..12de183 --- /dev/null +++ b/os2/popen.c @@ -0,0 +1,385 @@ +/* popen.c -- popen/pclose for OS/2. */ + +/* Set to 0 for distribution. + Search for "DIAGNOSTIC" in the code to see what it's for. */ +#define DIAGNOSTIC 0 + +#include <process.h> + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <ctype.h> +#include <string.h> +#include <fcntl.h> + +#include "config.h" +#include "os2inc.h" + +#define LL_VAL ULONG +#define LL_KEY PID /* also ULONG, really */ + +#define STDIN 0 +#define STDOUT 1 +#define STDERR 2 + +/* ********************************************************************* * + * * + * First, a little linked-list library to help keep track of pipes: * + * * + * ********************************************************************* */ + +/* Map integer PID's onto integer termination codes. */ +struct pid_list +{ + HFILE pid; /* key */ + ULONG term_code; /* val */ + struct pid_list *next; /* duh */ +}; + +static struct pid_list *pid_ll = (struct pid_list *) NULL; + +/* The ll_*() functions all make use of the global var `pid_ll'. */ + +void +ll_insert (HFILE key, ULONG val) +{ + struct pid_list *new; + new = (struct pid_list *) xmalloc (sizeof (*new)); + + new->pid = key; + new->term_code = val; + new->next = pid_ll; + + pid_ll = new; +} + + +void +ll_delete (int key) +{ + struct pid_list *this, *last; + + this = pid_ll; + last = (struct pid_list *) NULL; + + while (this) + { + if (this->pid == key) + { + /* Delete this node and leave. */ + if (last) + last->next = this->next; + else + pid_ll = this->next; + free (this); + return; + } + + /* Else no match, so try the next one. */ + last = this; + this = this->next; + } +} + +ULONG +ll_lookup (HFILE key) +{ + struct pid_list *this = pid_ll; + + while (this) + { + if (this->pid == key) + return this->term_code; + + /* Else no match, so try the next one. */ + this = this->next; + } + + /* Zero is special in this context anyway. */ + return 0; +} + +#if DIAGNOSTIC +ULONG +ll_length () +{ + struct pid_list *this = pid_ll; + unsigned long int len; + + for (len = 0; this; len++) + this = this->next; + + return len; +} + +ULONG +ll_print () +{ + struct pid_list *this = pid_ll; + unsigned long int i; + + for (i = 0; this; i++) + { + printf ("pid_ll[%d] == (%5d --> %5d)\n", + i, this->pid, this->term_code); + this = this->next; + } + + if (i == 0) + printf ("No entries.\n"); + + return i; +} +#endif /* DIAGNOSTIC */ + +/* ********************************************************************* * + * * + * End of linked-list library, beginning of popen/pclose: * + * * + * ********************************************************************* */ + +/* + * Routine: popen + * Returns: FILE pointer to pipe. + * Action : Exec program connected via pipe, connect a FILE * to the + * pipe and return it. + * Params : Command - Program to run + * Mode - Mode to open pipe. "r" implies pipe is connected + * to the programs stdout, "w" connects to stdin. + */ +FILE * +popen (const char *Command, const char *Mode) +{ + HFILE End1, End2, Std, Old1, Old2, Tmp; + + FILE *File; + + char Fail[256], + *Args, + CmdLine[256], + *CmdExe; + + RESULTCODES + Result; + + int Rc; + + if (DosCreatePipe (&End1, &End2, 4096)) + return NULL; + + Std = (*Mode == 'w') ? STDIN : STDOUT ; + if (Std == STDIN) + { + Tmp = End1; End1 = End2; End2 = Tmp; + } + + Old1 = -1; /* save stdin or stdout */ + DosDupHandle (Std, &Old1); + DosSetFHState (Old1, OPEN_FLAGS_NOINHERIT); + Tmp = Std; /* redirect stdin or stdout */ + DosDupHandle (End2, &Tmp); + + if (Std == 1) + { + Old2 = -1; /* save stderr */ + DosDupHandle (STDERR, &Old2); + DosSetFHState (Old2, OPEN_FLAGS_NOINHERIT); + Tmp = STDERR; + DosDupHandle (End2, &Tmp); + } + + DosClose (End2); + DosSetFHState (End1, OPEN_FLAGS_NOINHERIT); + + if ((CmdExe = getenv ("COMSPEC")) == NULL ) + CmdExe = "cmd.exe"; + + strcpy (CmdLine, CmdExe); + Args = CmdLine + strlen (CmdLine) + 1; /* skip zero */ + strcpy (Args, "/c "); + strcat (Args, Command); + Args[strlen (Args) + 1] = '\0'; /* two zeroes */ + Rc = DosExecPgm (Fail, sizeof (Fail), EXEC_ASYNCRESULT, + (unsigned char *) CmdLine, 0, &Result, + (unsigned char *) CmdExe); + + Tmp = Std; /* restore stdin or stdout */ + DosDupHandle (Old1, &Tmp); + DosClose (Old1); + + if (Std == STDOUT) + { + Tmp = STDERR; /* restore stderr */ + DosDupHandle (Old2, &Tmp); + DosClose (Old2); + } + + if (Rc) + { + DosClose (End1); + return NULL; + } + +#ifdef __WATCOMC__ + /* Watcom does not allow mixing operating system handles and + * C library handles, so we have to convert. + */ + File = fdopen (_hdopen (End1, *Mode == 'w'? O_WRONLY : O_RDONLY), Mode); +#else + File = fdopen (End1, Mode); +#endif + ll_insert ((LL_KEY) End1, (LL_VAL) Result.codeTerminate); + + return File; +} + + +/* + * Routine: popenRW + * Returns: PID of child process + * Action : Exec program connected via pipe, connect int fd's to + * both the stdin and stdout of the process. + * Params : Command - Program to run + * Pipes - Array of 2 ints to store the pipe descriptors + * Pipe[0] writes to child's stdin, + * Pipe[1] reads from child's stdout/stderr + */ +int +popenRW (const char **argv, int *pipes) +{ + HFILE Out1, Out2, In1, In2; + HFILE Old0 = -1, Old1 = -1, Old2 = -1, Tmp; + + int pid; + + if (DosCreatePipe (&Out2, &Out1, 4096)) + return FALSE; + + if (DosCreatePipe (&In1, &In2, 4096)) + { + DosClose (Out1); + DosClose (Out2); + return FALSE; + } + + /* Save std{in,out,err} */ + DosDupHandle (STDIN, &Old0); + DosSetFHState (Old1, OPEN_FLAGS_NOINHERIT); + DosDupHandle (STDOUT, &Old1); + DosSetFHState (Old2, OPEN_FLAGS_NOINHERIT); + DosDupHandle (STDERR, &Old2); + DosSetFHState (Old2, OPEN_FLAGS_NOINHERIT); + + /* Redirect std{in,out,err} */ + Tmp = STDIN; + DosDupHandle (In1, &Tmp); + Tmp = STDOUT; + DosDupHandle (Out1, &Tmp); + Tmp = STDERR; + DosDupHandle (Out1, &Tmp); + + /* Close file handles not needed in child */ + + DosClose (In1); + DosClose (Out1); + DosSetFHState (In2, OPEN_FLAGS_NOINHERIT); + DosSetFHState (Out2, OPEN_FLAGS_NOINHERIT); + + /* Spawn we now our hoary brood. */ + pid = spawnvp (P_NOWAIT, argv[0], argv); + + /* Restore std{in,out,err} */ + Tmp = STDIN; + DosDupHandle (Old0, &Tmp); + DosClose (Old0); + Tmp = STDOUT; + DosDupHandle (Old1, &Tmp); + DosClose (Old1); + Tmp = STDERR; + DosDupHandle (Old2, &Tmp); + DosClose (Old2); + + if(pid < 0) + { + DosClose (In2); + DosClose (Out2); + return -1; + } + + pipes[0] = In2; + _setmode (pipes[0], O_BINARY); + pipes[1] = Out2; + _setmode (pipes[1], O_BINARY); + + /* Save ID of write-to-child pipe for pclose() */ + ll_insert ((LL_KEY) In2, (LL_VAL) pid); + + return pid; +} + + +/* + * Routine: pclose + * Returns: TRUE on success + * Action : Close a pipe opened with popen(); + * Params : Pipe - pipe to close + */ +int +pclose (FILE *Pipe) +{ + RESULTCODES rc; + PID pid, pid1; + int Handle = fileno (Pipe); + + fclose (Pipe); + + rc.codeTerminate = -1; + + pid1 = (PID) ll_lookup ((LL_KEY) Handle); + /* if pid1 is zero, something's seriously wrong */ + if (pid1 != 0) + { + DosWaitChild (DCWA_PROCESSTREE, DCWW_WAIT, &rc, &pid, pid1); + ll_delete ((LL_KEY) Handle); + } + return rc.codeTerminate == 0 ? rc.codeResult : -1; +} + + +#if DIAGNOSTIC +void +main () +{ + FILE *fp1, *fp2, *fp3; + int c; + + ll_print (); + fp1 = popen ("gcc --version", "r"); + ll_print (); + fp2 = popen ("link386 /?", "r"); + ll_print (); + fp3 = popen ("dir", "r"); + ll_print (); + + while ((c = getc (fp1)) != EOF) + printf ("%c", c); + + while ((c = getc (fp2)) != EOF) + printf ("%c", c); + + while ((c = getc (fp3)) != EOF) + printf ("%c", c); + + pclose (fp1); + ll_print (); + pclose (fp2); + ll_print (); + pclose (fp3); + ll_print (); + + return; +} + +#endif /* DIAGNOSTIC */ diff --git a/os2/popen.h b/os2/popen.h new file mode 100644 index 0000000..fec94e0 --- /dev/null +++ b/os2/popen.h @@ -0,0 +1,6 @@ +/* We roll our own popen()/pclose() in OS/2. + Thanks, Glenn Gribble! */ + +FILE *popen (const char *cmd, const char *mode); +int popenRW (char **cmd, int *pipes); +int pclose (FILE *stream); diff --git a/os2/porttcp.c b/os2/porttcp.c new file mode 100644 index 0000000..a64b511 --- /dev/null +++ b/os2/porttcp.c @@ -0,0 +1,227 @@ +/**************************************************************** +** +** PORTTCP.C - Support for portable TCP/IP +** +****************************************************************/ + +#define TCPIP_IBM_NOHIDE +#include <stdio.h> +#include "tcpip.h" + +/* + * Common unknown error buffer + */ +static char ErrUnknownBuf[36]; + +#ifndef SockStrError + +/**************************************************************** + * Routine: SockStrError + * Returns: Pointer to static buffer + * Action : Convert SOCK_ERRNO into error text + ****************************************************************/ + +const char * +SockStrError(int SockErrno) +{ +#if defined (TCPIP_IBM) && defined (IBM_CPP) + switch (SockErrno) + { + case SOCEPERM: return "Not owner"; + case SOCESRCH: return "No such process"; + case SOCEINTR: return "Interrupted system call"; + case SOCENXIO: return "No such device or address"; + case SOCEBADF: return "Bad file number"; + case SOCEACCES: return "Permission denied"; + case SOCEFAULT: return "Bad address"; + case SOCEINVAL: return "Invalid argument"; + case SOCEMFILE: return "Too many open files"; + case SOCEPIPE: return "Broken pipe"; + case SOCEOS2ERR: return "OS/2 Error"; + case SOCEWOULDBLOCK: return "Operation would block"; + case SOCEINPROGRESS: return "Operation now in progress"; + case SOCEALREADY: return "Operation already in progress"; + case SOCENOTSOCK: return "Socket operation on non-socket"; + case SOCEDESTADDRREQ: return "Destination address required"; + case SOCEMSGSIZE: return "Message too long"; + case SOCEPROTOTYPE: return "Protocol wrong type for socket"; + case SOCENOPROTOOPT: return "Protocol not available"; + case SOCEPROTONOSUPPORT: return "Protocol not supported"; + case SOCESOCKTNOSUPPORT: return "Socket type not supported"; + case SOCEOPNOTSUPP: return "Operation not supported on socket"; + case SOCEPFNOSUPPORT: return "Protocol family not supported"; + case SOCEAFNOSUPPORT: + return "Address family not supported by protocol family"; + case SOCEADDRINUSE: return "Address already in use"; + case SOCEADDRNOTAVAIL: return "Can't assign requested address"; + case SOCENETDOWN: return "Network is down"; + case SOCENETUNREACH: return "Network is unreachable"; + case SOCENETRESET: return "Network dropped connection on reset"; + case SOCECONNABORTED: return "Software caused connection abort"; + case SOCECONNRESET: return "Connection reset by peer"; + case SOCENOBUFS: return "No buffer space available"; + case SOCEISCONN: return "Socket is already connected"; + case SOCENOTCONN: return "Socket is not connected"; + case SOCESHUTDOWN: return "Can't send after socket shutdown"; + case SOCETOOMANYREFS: return "Too many references: can't splice"; + case SOCETIMEDOUT: return "Connection timed out"; + case SOCECONNREFUSED: return "Connection refused"; + case SOCELOOP: return "Too many levels of symbolic links"; + case SOCENAMETOOLONG: return "File name too long"; + case SOCEHOSTDOWN: return "Host is down"; + case SOCEHOSTUNREACH: return "No route to host"; + case SOCENOTEMPTY: return "Directory not empty"; + + default: + sprintf( ErrUnknownBuf, "SockStrErrno( %d ) unknown", SockErrno ); + return ErrUnknownBuf; + } +#else +#error SockStrError not supported for this OS +#endif +} + +#endif /* SockStrError */ + + +/**************************************************************** + * Routine: HostStrError + * Returns: Pointer to static buffer + * Action : Convert HOST_ERRNO into error text + ****************************************************************/ + +const char * +HostStrError(int HostErrno) +{ + switch (HostErrno) + { + case HOST_NOT_FOUND: + return "Host not found"; + case TRY_AGAIN: + return "Host not found (suggest try again)"; + case NO_RECOVERY: + return "Non-recoverable error: FORMERR, REFUSED, NOTIMP"; + case NO_DATA: + return "No Data (valid name, but no record of requested type)"; + + default: + sprintf( ErrUnknownBuf, "HostStrErrno( %d ) unknown", HostErrno ); + return ErrUnknownBuf; + } +} + + +#if defined( TCPIP_IBM ) +/**************************************************************** + * Routine: IbmSockSend + * Returns: same as send + * Action : Do the right thing for IBM TCP/IP which includes + * the following two stupidities: + * 1) Never try to send more than 32K + * 2) Never pass a buffer that crosses a 64K boundary + * If Flags is non-zero, this function only attempts + * to deal with condition (1) above. + ****************************************************************/ + +int +IbmSockSend (int Socket, const void *Buffer, int Len, int Flags) +{ + int Sent, ToSend, TotalSent = 0; + + const char *Tmp = Buffer; + + /* + * If Flags have been passed in, the 64K boundary optimization + * can not be performed. For example, MSG_PEEK would not work + * correctly. + */ + if (Flags) + return send (Socket, (char *) Buffer, min (0x7FFF, Len), Flags); + + do + { + /* Never send across a 64K boundary */ + ToSend = min (Len, (int) (0x10000 - (0xFFFF & (long) Tmp))); + + /* Never send more than 32K */ + if (ToSend > 0x7FFF) + ToSend = 0x7FFF; + + Sent = send (Socket, (char *) Tmp, ToSend, 0); + if (Sent < 0) + { + if ((TotalSent > 0) && (SOCK_ERRNO == EWOULDBLOCK)) + return TotalSent; + if (SOCK_ERRNO == EINTR) + continue; + return Sent; + } + if (Sent < ToSend) + return TotalSent + Sent; + + Tmp += Sent; + TotalSent += Sent; + Len -= Sent; + } while (Len > 0); + + return TotalSent; +} + + + +/**************************************************************** + * Routine: IbmSockRecv + * Returns: same as recv + * Action : Do the right thing for IBM TCP/IP which includes + * the following two stupidities: + * 1) Never try to recv more than 32K + * 2) Never pass a buffer that crosses a 64K boundary + * If Flags is non-zero, this function only attempts + * to deal with condition (1) above. + ****************************************************************/ + +int +IbmSockRecv (int Socket, const void *Buffer, int Len, int Flags) +{ + int Recvd, ToRecv, TotalRecvd = 0; + + char *Tmp = Buffer; + + /* If Flags have been passed in, the 64K boundary optimization + probably can not be performed. */ + + if (Flags) + return recv (Socket, Buffer, min (0x7FFF, Len), Flags); + + do + { + /* Never send across a 64K boundary */ + ToRecv = min( Len, (int)( 0x10000 - ( 0xFFFF & (long)Tmp ))); + + /* Never send more than 32K */ + if( ToRecv > 0x7FFF ) + ToRecv = 0x7FFF; + + Recvd = recv (Socket, Tmp, ToRecv, 0); + if (Recvd <= 0) + { + if ((TotalRecvd > 0) + && (Recvd == 0 || (SOCK_ERRNO == EWOULDBLOCK ))) + return TotalRecvd; + if (SOCK_ERRNO == EINTR) + continue; + + return Recvd; + } + if (Recvd < ToRecv) + return TotalRecvd + Recvd; + + Tmp += Recvd; + TotalRecvd += Recvd; + Len -= Recvd; + } while (Len > 0); + + return TotalRecvd; +} +#endif /* defined( TCPIP_IBM ) */ + diff --git a/os2/pwd.c b/os2/pwd.c new file mode 100644 index 0000000..7235f28 --- /dev/null +++ b/os2/pwd.c @@ -0,0 +1,198 @@ +/* pwd.c - Try to approximate UN*X's getuser...() functions under MS-DOS. + Copyright (C) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. */ + +/* This 'implementation' is conjectured from the use of this functions in + the RCS and BASH distributions. Of course these functions don't do too + much useful things under MS-DOS, but using them avoids many "#ifdef + MSDOS" in ported UN*X code ... */ + + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <pwd.h> + +static char *lookup_env (char **); + +/* where people might scribble their name into the environment ... */ + +static char *login_strings[] = +{ + "LOGIN", "USER", "MAILNAME", (char *) 0 +}; + +static char *group_strings[] = +{ + "GROUP", (char *) 0 +}; + + +static char *anonymous = "anonymous"; /* if all else fails ... */ + +static char *home_dir = "."; /* we feel (no|every)where at home */ +static char *login_shell = "not cmd.exe!"; + +static char *login = (char *) 0;/* cache the names here */ +static char *group = (char *) 0; + +static struct passwd pw; /* should we return a malloc()'d structure */ +static struct group gr; /* instead of pointers to static structures? */ + +/* return something like a username in a (butchered!) passwd structure. */ +struct passwd * +getpwuid (int uid) +{ + pw.pw_name = getlogin (); + pw.pw_dir = home_dir; + pw.pw_shell = login_shell; + pw.pw_uid = 0; + + return &pw; +} + +struct passwd * +getpwnam (char *name) +{ + return (struct passwd *) 0; +} + +/* return something like a groupname in a (butchered!) group structure. */ +struct group * +getgrgid (int uid) +{ + gr.gr_name = getgr_name (); + gr.gr_gid = 0; + + return &gr; +} + +struct group * +getgrnam (char *name) +{ + return (struct group *) 0; +} + +/* return something like a username. */ +char * +getlogin () +{ + if (!login) /* have we been called before? */ + login = lookup_env (login_strings); + + if (!login) /* have we been successful? */ + login = anonymous; + + return login; +} + +/* return something like a group. */ +char * +getgr_name () +{ + if (!group) /* have we been called before? */ + group = lookup_env (group_strings); + + if (!group) /* have we been successful? */ + group = anonymous; + + return group; +} + +/* return something like a uid. */ +int +getuid () +{ + return 0; /* every user is a super user ... */ +} + +int +getgid () +{ + return 0; +} + +int +geteuid () +{ + return 0; +} + +int +getegid () +{ + return 0; +} + +struct passwd * +getpwent () +{ + return (struct passwd *) 0; +} + +void +setpwent () +{ +} + +void +endpwent () +{ +} + +void +endgrent () +{ +} + +/* return groups. */ +int +getgroups (int ngroups, int *groups) +{ + *groups = 0; + return 1; +} + +/* lookup environment. */ +static char * +lookup_env (char *table[]) +{ + char *ptr; + char *entry; + size_t len; + + while (*table && !(ptr = getenv (*table++))) ; /* scan table */ + + if (!ptr) + return (char *) 0; + + len = strcspn (ptr, " \n\t\n\r"); /* any WS? */ + if (!(entry = xmalloc (len + 1))) + { + fprintf (stderr, "Out of memory.\nStop."); + exit (-1); + } + + strncpy (entry, ptr, len); + entry[len] = '\0'; + + return entry; + +} + +/* + * Local Variables: + * mode:C + * ChangeLog:ChangeLog + * compile-command:make + * End: + */ diff --git a/os2/pwd.h b/os2/pwd.h new file mode 100644 index 0000000..ad225a1 --- /dev/null +++ b/os2/pwd.h @@ -0,0 +1,70 @@ +/* pwd.h - Try to approximate UN*X's getuser...() functions under MS-DOS. + Copyright (C) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. */ + +/* This 'implementation' is conjectured from the use of this functions in + the RCS and BASH distributions. Of course these functions don't do too + much useful things under MS-DOS, but using them avoids many "#ifdef + MSDOS" in ported UN*X code ... */ + +#if 0 +/* This is taken care of in Windows-NT/config.h. */ +typedef int uid_t; +#endif + +struct passwd +{ + /* ... */ + /* missing stuff */ + /* ... */ + char *pw_name; /* login user id */ + char *pw_dir; /* home directory */ + char *pw_shell; /* login shell */ + int pw_uid; +}; + +struct group +{ + /* ... */ + /* missing stuff */ + /* ... */ + char *gr_name; /* login user id */ + int gr_gid; +}; + +extern struct passwd *getpwuid (int); +extern struct passwd *getpwnam (char *); +extern struct group *getgrgid (int); +extern struct group *getgrnam (char *); +extern char *getlogin (void); +extern char *getgr_name (void); +extern int getuid (void); +extern int getgid (void); +extern int geteuid (void); +extern int getegid (void); + +extern int *groups; +extern int ngroups; +extern int getgroups (int, int *); + +extern struct passwd *getpwent (void); +extern void setpwent (void); +extern void endpwent (void); +extern void endgrent (void); + +/* + * Local Variables: + * mode:C + * ChangeLog:ChangeLog + * compile-command:make + * End: + */ diff --git a/os2/rcmd.c b/os2/rcmd.c new file mode 100644 index 0000000..2996e49 --- /dev/null +++ b/os2/rcmd.c @@ -0,0 +1,76 @@ +/* rcmd.c --- execute a command on a remote host from OS/2 + Karl Fogel <kfogel@cyclic.com> --- November 1995 */ + +/* This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. */ + +#include <io.h> +#include <stdio.h> +#include <fcntl.h> +#include <malloc.h> +#include <errno.h> +/* <sys/socket.h> wants `off_t': */ +#include <sys/types.h> +/* This should get us ibmtcpip\include\sys\socket.h: */ +#include <sys/socket.h> +#include <assert.h> + +#include "rcmd.h" + +void +init_sockets () +{ + int rc; + + rc = sock_init (); + if (rc != 0) + { + fprintf (stderr, "sock_init() failed -- returned %d!\n", rc); + exit (1); + } +} + + +static int +resolve_address (const char **ahost, struct sockaddr_in *sai) +{ + fprintf (stderr, + "Error: resolve_address() doesn't work.\n"); + exit (1); +} + +static int +bind_and_connect (struct sockaddr_in *server_sai) +{ + fprintf (stderr, + "Error: bind_and_connect() doesn't work.\n"); + exit (1); +} + +static int +rcmd_authenticate (int fd, char *locuser, char *remuser, char *command) +{ + fprintf (stderr, + "Error: rcmd_authenticate() doesn't work.\n"); + exit (1); +} + +int +rcmd (const char **ahost, + unsigned short inport, + char *locuser, + char *remuser, + char *cmd, + int *fd2p) +{ + fprintf (stderr, + "Error: rcmd() doesn't work.\n"); + exit (1); +} diff --git a/os2/rcmd.h b/os2/rcmd.h new file mode 100644 index 0000000..2c84d5b --- /dev/null +++ b/os2/rcmd.h @@ -0,0 +1,40 @@ +/* rcmd.h --- interface to executing commands on remote hosts + Karl Fogel <kfogel@cyclic.com> --- November 1995 */ + +/* This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. */ + +/* Run the command CMD on the host *AHOST, and return a file descriptor for + a bidirectional stream socket connected to the command's standard input + and output. + + rcmd looks up *AHOST using gethostbyname, and sets *AHOST to the host's + canonical name. If *AHOST is not found, rcmd returns -1. + + rcmd connects to the remote host at TCP port INPORT. This should + probably be the "shell" service, port 514. + + LOCUSER is the name of the user on the local machine, and REMUSER is + the name of the user on the remote machine; the remote machine uses this, + along with the source address of the TCP connection, to authenticate + the connection. + + CMD is the command to execute. The remote host will tokenize it any way + it damn well pleases. Welcome to Unix. + + FD2P is a feature we don't support, but there's no point in making mindless + deviations from the interface. Callers should always pass this argument + as zero. */ +extern int rcmd (const char **AHOST, + unsigned short INPORT, + char *LOCUSER, + char *REMUSER, + char *CMD, + int *fd2p); diff --git a/os2/run.c b/os2/run.c new file mode 100644 index 0000000..6a4179b --- /dev/null +++ b/os2/run.c @@ -0,0 +1,611 @@ +/* run.c --- routines for executing subprocesses under OS/2. + + This file is part of GNU CVS. + + GNU CVS is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. */ + +#include "cvs.h" + +#include "os2inc.h" + +#include <process.h> + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <io.h> + +#define STDIN 0 +#define STDOUT 1 +#define STDERR 2 + +static void run_add_arg( const char *s ); +static void run_init_prog( void ); + +extern char *strtok (); + +/* + * To exec a program under CVS, first call run_setup() to setup any initial + * arguments. The options to run_setup are essentially like printf(). The + * arguments will be parsed into whitespace separated words and added to the + * global run_argv list. + * + * Then, optionally call run_arg() for each additional argument that you'd like + * to pass to the executed program. + * + * Finally, call run_exec() to execute the program with the specified + * arguments. + * The execvp() syscall will be used, so that the PATH is searched correctly. + * File redirections can be performed in the call to run_exec(). + */ +static char **run_argv; +static int run_argc; +static int run_argc_allocated; + +void +run_setup (const char *prog) +{ + int i; + char *run_prog; + char *buf, *d, *s; + size_t length; + size_t doff; + char inquotes; + int dolastarg; + + /* clean out any malloc'ed values from run_argv */ + for (i = 0; i < run_argc; i++) + { + if (run_argv[i]) + { + free (run_argv[i]); + run_argv[i] = (char *) 0; + } + } + run_argc = 0; + + run_prog = xstrdup (prog); + + s = run_prog; + d = buf = NULL; + length = 0; + dolastarg = 1; + inquotes = '\0'; + doff = d - buf; + expand_string(&buf, &length, doff + 1); + d = buf + doff; + while (*d = *s++) + { + switch (*d) + { + case '\\': + if (*s) *d = *s++; + d++; + break; + case '"': + case '\'': + if (inquotes == *d) inquotes = '\0'; + else inquotes = *d; + break; + case ' ': + case '\t': + if (inquotes) d++; + else + { + *d = '\0'; + run_add_arg (buf); + d = buf; + while (isspace(*s)) s++; + if (!*s) dolastarg = 0; + } + break; + default: + d++; + break; + } + doff = d - buf; + expand_string(&buf, &length, doff + 1); + d = buf + doff; + } + if (dolastarg) run_add_arg (buf); + /* put each word into run_argv, allocating it as we go */ + if (buf) free (buf); + free (run_prog); + + free (run_prog); + if (buf) free (buf); +} + +void +run_arg (s) + const char *s; +{ + run_add_arg (s); +} + +/* Return a malloc'd copy of s, with double quotes around it. */ +/* FIXME - this should replace " with \" as it copies. or something. + * depends where it's used, I would suppose. + */ +static char * +quote (const char *s) +{ + size_t s_len = strlen (s); + char *copy = xmalloc (s_len + 3); + char *scan = copy; + + *scan++ = '"'; + strcpy (scan, s); + scan += s_len; + *scan++ = '"'; + *scan++ = '\0'; + + return copy; +} + +static void +run_add_arg (s) + const char *s; +{ + /* allocate more argv entries if we've run out */ + if (run_argc >= run_argc_allocated) + { + run_argc_allocated += 50; + run_argv = (char **) xrealloc ((char *) run_argv, + run_argc_allocated * sizeof (char **)); + } + + if (s) + { + run_argv[run_argc] = (run_argc ? quote (s) : xstrdup (s)); + run_argc++; + } + else + /* not post-incremented on purpose! */ + run_argv[run_argc] = (char *) 0; +} + +int +run_exec (stin, stout, sterr, flags) + char *stin; + char *stout; + char *sterr; + int flags; +{ + int shin, shout, sherr; + int sain, saout, saerr; /* saved handles */ + int mode_out, mode_err; + int status = -1; + int rerrno = 0; + int rval = -1; + void (*old_sigint) (int); + + if (trace) /* if in trace mode */ + { + (void) fprintf (stderr, "-> system("); + run_print (stderr); + (void) fprintf (stderr, ")\n"); + } + if (noexec && (flags & RUN_REALLY) == 0) /* if in noexec mode */ + return (0); + + /* + * start the engine and take off + */ + + /* make sure that we are null terminated, since we didn't calloc */ + run_add_arg ((char *) 0); + + /* setup default file descriptor numbers */ + shin = 0; + shout = 1; + sherr = 2; + + /* set the file modes for stdout and stderr */ + mode_out = mode_err = O_WRONLY | O_CREAT; + mode_out |= ((flags & RUN_STDOUT_APPEND) ? O_APPEND : O_TRUNC); + mode_err |= ((flags & RUN_STDERR_APPEND) ? O_APPEND : O_TRUNC); + + /* open the files as required, shXX are shadows of stdin... */ + if (stin && (shin = open (stin, O_RDONLY)) == -1) + { + rerrno = errno; + error (0, errno, "cannot open %s for reading (prog %s)", + stin, run_argv[0]); + goto out0; + } + if (stout && (shout = open (stout, mode_out, 0666)) == -1) + { + rerrno = errno; + error (0, errno, "cannot open %s for writing (prog %s)", + stout, run_argv[0]); + goto out1; + } + if (sterr && (flags & RUN_COMBINED) == 0) + { + if ((sherr = open (sterr, mode_err, 0666)) == -1) + { + rerrno = errno; + error (0, errno, "cannot open %s for writing (prog %s)", + sterr, run_argv[0]); + goto out2; + } + } + /* now save the standard handles */ + sain = saout = saerr = -1; + sain = dup( 0); /* dup stdin */ + saout = dup( 1); /* dup stdout */ + saerr = dup( 2); /* dup stderr */ + + /* the new handles will be dup'd to the standard handles + * for the spawn. + */ + + if (shin != 0) + { + (void) dup2 (shin, 0); + (void) close (shin); + } + if (shout != 1) + { + (void) dup2 (shout, 1); + (void) close (shout); + } + if (flags & RUN_COMBINED) + (void) dup2 (1, 2); + else if (sherr != 2) + { + (void) dup2 (sherr, 2); + (void) close (sherr); + } + + /* Ignore signals while we're running this. */ + old_sigint = signal (SIGINT, SIG_IGN); + + /* dup'ing is done. try to run it now */ + rval = spawnvp ( P_WAIT, run_argv[0], run_argv); + + /* Restore signal handling. */ + signal (SIGINT, old_sigint); + + /* restore the original file handles */ + if (sain != -1) { + (void) dup2( sain, 0); /* re-connect stdin */ + (void) close( sain); + } + if (saout != -1) { + (void) dup2( saout, 1); /* re-connect stdout */ + (void) close( saout); + } + if (saerr != -1) { + (void) dup2( saerr, 2); /* re-connect stderr */ + (void) close( saerr); + } + + /* Recognize the return code for a failed subprocess. */ + if (rval == -1) + return 2; + else + return rval; /* return child's exit status */ + + /* error cases */ + /* cleanup the open file descriptors */ + out2: + if (stout) + (void) close (shout); + out1: + if (stin) + (void) close (shin); + + out0: + if (rerrno) + errno = rerrno; + return (status); +} + + +void +run_print (fp) + FILE *fp; +{ + int i; + + for (i = 0; i < run_argc; i++) + { + (void) fprintf (fp, "'%s'", run_argv[i]); + if (i != run_argc - 1) + (void) fprintf (fp, " "); + } +} + +static char * +requote (const char *cmd) +{ + char *requoted = xmalloc (strlen (cmd) + 1); + char *p = requoted; + + strcpy (requoted, cmd); + while ((p = strchr (p, '\'')) != NULL) + { + *p++ = '"'; + } + + return requoted; +} + +FILE * +run_popen (cmd, mode) + const char *cmd; + const char *mode; +{ + TRACE( TRACE_FUNCTION, "run_popen(%s,%s)", cmd, mode ); + + if (noexec) + return (NULL); + + /* If the command string uses single quotes, turn them into + double quotes. */ + { + char *requoted = requote (cmd); + TRACE( TRACE_DATA, "Executing popen(%s,%s)", requoted, mode ); + FILE *result = popen (requoted, mode); + free (requoted); + return result; + } +} + + +/* Running children with pipes connected to them. */ + +/* Create a pipe. Set READWRITE[0] to its reading end, and + READWRITE[1] to its writing end. */ + +static int +my_pipe (int *readwrite) +{ + fprintf (stderr, + "Error: my_pipe() is unimplemented.\n"); + exit (1); +} + + +/* Create a child process running COMMAND with IN as its standard input, + and OUT as its standard output. Return a handle to the child, or + INVALID_HANDLE_VALUE. */ +static int +start_child (char *command, int in, int out) +{ + fprintf (stderr, + "Error: start_child() is unimplemented.\n"); + exit (1); +} + + +/* Given an array of arguments that one might pass to spawnv, + construct a command line that one might pass to CreateProcess. + Try to quote things appropriately. */ +static char * +build_command (char **argv) +{ + int len; + + /* Compute the total length the command will have. */ + { + int i; + + len = 0; + for (i = 0; argv[i]; i++) + { + char *p; + + len += 2; /* for the double quotes */ + + for (p = argv[i]; *p; p++) + { + if (*p == '"') + len += 2; + else + len++; + } + } + len++; /* for the space or the '\0' */ + } + + { + char *command = (char *) xmalloc (len); + int i; + char *p; + + if (! command) + { + errno = ENOMEM; + return command; + } + + p = command; + /* copy each element of argv to command, putting each command + in double quotes, and backslashing any quotes that appear + within an argument. */ + for (i = 0; argv[i]; i++) + { + char *a; + *p++ = '"'; + for (a = argv[i]; *a; a++) + { + if (*a == '"') + *p++ = '\\', *p++ = '"'; + else + *p++ = *a; + } + *p++ = '"'; + *p++ = ' '; + } + p[-1] = '\0'; + + return command; + } +} + + +/* Create an asynchronous child process executing ARGV, + with its standard input and output connected to the + parent with pipes. Set *TO to the file descriptor on + which one writes data for the child; set *FROM to + the file descriptor from which one reads data from the child. + Return the handle of the child process (this is what + _cwait and waitpid expect). */ +int +piped_child (char **argv, int *to, int *from) +{ + fprintf (stderr, + "Error: piped_child() is unimplemented.\n"); + exit (1); +} + +/* + * dir = 0 : main proc writes to new proc, which writes to oldfd + * dir = 1 : main proc reads from new proc, which reads from oldfd + * + * If this returns at all, then it was successful and the return value + * is a file descriptor; else it errors and exits. + */ +int +filter_stream_through_program (int oldfd, int dir, + char **prog, int *pidp) +{ + int newfd; /* Gets set to one end of the pipe and returned. */ + HFILE from, to; + HFILE Old0 = -1, Old1 = -1, Old2 = -1, Tmp; + + if (DosCreatePipe (&from, &to, 4096)) + return FALSE; + + /* Save std{in,out,err} */ + DosDupHandle (STDIN, &Old0); + DosSetFHState (Old1, OPEN_FLAGS_NOINHERIT); + DosDupHandle (STDOUT, &Old1); + DosSetFHState (Old2, OPEN_FLAGS_NOINHERIT); + DosDupHandle (STDERR, &Old2); + DosSetFHState (Old2, OPEN_FLAGS_NOINHERIT); + + /* Redirect std{in,out,err} */ + if (dir) /* Who goes where? */ + { + Tmp = STDIN; + DosDupHandle (oldfd, &Tmp); + Tmp = STDOUT; + DosDupHandle (to, &Tmp); + Tmp = STDERR; + DosDupHandle (to, &Tmp); + + newfd = from; + _setmode (newfd, O_BINARY); + + DosClose (oldfd); + DosClose (to); + DosSetFHState (from, OPEN_FLAGS_NOINHERIT); + } + else + { + Tmp = STDIN; + DosDupHandle (from, &Tmp); + Tmp = STDOUT; + DosDupHandle (oldfd, &Tmp); + Tmp = STDERR; + DosDupHandle (oldfd, &Tmp); + + newfd = to; + _setmode (newfd, O_BINARY); + + DosClose (oldfd); + DosClose (from); + DosSetFHState (to, OPEN_FLAGS_NOINHERIT); + } + + /* Spawn we now our hoary brood. */ + *pidp = spawnvp (P_NOWAIT, prog[0], prog); + + /* Restore std{in,out,err} */ + Tmp = STDIN; + DosDupHandle (Old0, &Tmp); + DosClose (Old0); + Tmp = STDOUT; + DosDupHandle (Old1, &Tmp); + DosClose (Old1); + Tmp = STDERR; + DosDupHandle (Old2, &Tmp); + DosClose (Old2); + + if(*pidp < 0) + { + DosClose (from); + DosClose (to); + error (1, 0, "error spawning %s", prog[0]); + } + + return newfd; +} + + +int +pipe (int *filedesc) +{ + /* todo: actually, we can use DosCreatePipe(). Fix this. */ + fprintf (stderr, + "Error: pipe() should not have been called in client.\n"); + exit (1); +} + + +void +close_on_exec (int fd) +{ + /* Just does nothing for now... */ + + /* Actually, we probably *can* implement this one. Let's see... */ + /* Nope. OS/2 has <fcntl.h>, but no fcntl() ! Wow. */ + /* Well, I'll leave this stuff in for future reference. */ +} + + +/* Actually, we #define sleep() in config.h now. */ +#ifndef sleep +unsigned int +sleep (unsigned int seconds) +{ + /* I don't want to interfere with alarm signals, so I'm going to do + this the nasty way. */ + + time_t base; + time_t tick; + int i; + + /* Init. */ + time (&base); + time (&tick); + + /* Loop until time has passed. */ + while (difftime (tick, base) < seconds) + { + /* This might be more civilized than calling time over and over + again. */ + for (i = 0; i < 10000; i++) + ; + time (&tick); + } + + return 0; +} +#endif /* sleep */ diff --git a/os2/tcpip.h b/os2/tcpip.h new file mode 100644 index 0000000..4f3e58f --- /dev/null +++ b/os2/tcpip.h @@ -0,0 +1,131 @@ +/**************************************************************** + * + * TCPIP.H - Portable TCP/IP header file + * + * TCP/IP on OS/2 is an add-on and thus is not fully integrated + * with the operating system. To ensure portability, follow + * these rules: + * + * * Always call SockInit() at the beginning of your program + * and check that it returns TRUE. + * + * * Use SockSend() & SockRecv() instead of read(), write(), + * send(), or recv() when working with sockets. + * + * * Use SockClose() instead of close() with sockets. + * + * * Use SOCK_ERRNO when using functions that use or return + * sockets, such as SockSend() or accept(). + * + * * Use HOST_ERRNO when using gethostbyname() or gethostbyaddr() + * functions. + * + * * As far as I can tell, getservbyname() and related functions + * never set any error variable. + * + * * Use SockStrError() & HostStrError() to convert SOCK_ERRNO + * and HOST_ERRNO to error strings. + * + * * In .MAK files, include $(TCPIP_MAK) & use $(TCPIPLIB) + * when linking applications using TCP/IP. + * + ****************************************************************/ + +#if !defined( IN_TCPIP_H ) +#define IN_TCPIP_H + +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <netinet/in.h> +#include <netdb.h> +#include <errno.h> + +#if defined( TCPIP_IBM ) +/* Here comes some ugly stuff: The watcom compiler and the IBM TCPIP + * toolkit do not work together very well. The return codes for the + * socket calls are not integrated into the usual error codes, there + * are separate values instead. This results in a crash for two values. + * Since these values are not needed for socket access as far as I can + * see, I will save those values and redefine them after including + * nerrno.h (types.h will include nerrno.h, so this is needed here). + */ +# ifdef __WATCOMC__ + /* First check the numeric values */ +# if ENAMETOOLONG != 35 +# error "ENAMETOOLONG: value unknown" +# endif +# if ENOTEMPTY != 39 +# error "ENOTEMPTY: value unknown" +# endif +# undef ENAMETOOLONG +# undef ENOTEMPTY +# include <nerrno.h> +# undef ENAMETOOLONG +# undef ENOTEMPTY +# define ENAMETOOLONG 35 +# define ENOTEMPTY 39 +# endif +# include <types.h> +# if !defined( TCPIP_IBM_NOHIDE ) +# define send IbmSockSend +# define recv IbmSockRecv +# endif +#endif + +#if defined( TCPIP_IBM ) +# define BSD_SELECT +# include <sys/select.h> +# include <sys/time.h> +# include <nerrno.h> +# include <utils.h> +# if defined( MICROSOFT ) +# define SOCK_ERRNO (tcperrno()) +# else +# define SOCK_ERRNO (sock_errno()) +# endif +# define HOST_ERRNO (h_errno) +# define SockClose(S) soclose(S) +# define SockInit() (!sock_init()) +# define SockSend IbmSockSend +# define SockRecv IbmSockRecv + +const char *HostStrError(int HostErrno); +const char *SockStrError(int SockErrno); + +int IbmSockSend (int Socket, const void *Buffer, int Len, int Flags); +int IbmSockRecv (int Socket, const void *Buffer, int Len, int Flags); + +#if !defined( h_errno ) +extern int h_errno; /* IBM forgot to declare this in current header files */ +#endif + +#elif defined( __unix ) +# if defined( sgi ) /* SGI incorrectly defines FD_ZERO in sys/select.h */ +# include <bstring.h> +# endif +# if defined( sunos ) +extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +# else +# include <sys/select.h> +# endif +# include <sys/time.h> +# include <errno.h> +# include <arpa/inet.h> +# define SOCK_ERRNO errno +# define HOST_ERRNO h_errno +# define SockClose(S) close(S) +# define SockInit() TRUE +# define SockSend send +# define SockRecv recv +# define SockStrError(E) strerror(E) + +const char *HostStrError( int HostErrno ); + +#else +# error Undefined version of TCP/IP specified + +#endif + +#endif diff --git a/os2/test-makefile b/os2/test-makefile new file mode 100644 index 0000000..d6179ee --- /dev/null +++ b/os2/test-makefile @@ -0,0 +1,40 @@ +# I use this for single compilation while porting; once the port is +# done it can be removed. + +THIS_BASENAME = ../src/add + +CC = icc + +LIB = s:\ibmcpp\lib;s:\toolkt21\os2lib; +CINC = -Is:/ibmcpp/include -Is:/toolkt21/c/os2h +CFLAGS = -C+ +CFLAGS += -W3 -Wpro+rea+tru+use+ -Ti+ -Ss+ -Gd+ -Gm+ -G4 -Q+ -Sm ${CINC} +CFLAGS += -DIBM_CPP -DHAVE_CONFIG_H + +# translation of most important CFLAGS -- others are trivial +# ICC sez -C+ -W3 -Ti+ ${CINC} +# GCC sez -c -Wall -g ${CINC} + +# "-I../os2" below ought to be equivalent to "-I." +CFLAGS += -I../os2 -I../lib -I../src + +# Preprocesses to stdout. +# CFLAGS += -Pd+ + +# TCP/IP stuff +TCPIPLIB = s:\ibmtcpip\lib\tcp32dll.lib s:\ibmtcpip\lib\so32dll.lib porttcp.obj + +# We probably don't need these. +# RPCLIB = s:\ibmtcpip\lib\rpc32dll.lib +# FTPLIB = s:\ibmtcpip\lib\ftpapi.lib + +CFLAGS += -DTCPIP_IBM -Is:\ibmtcpip\include + +all: ${THIS_BASENAME}.obj +# all: ${THIS_BASENAME}.exe + +${THIS_BASENAME}.obj: ${THIS_BASENAME}.c + ${CC} ${CFLAGS} /Fo${THIS_BASENAME}.obj ${THIS_BASENAME}.c + +${THIS_BASENAME}.exe: ${THIS_BASENAME}.c + ${CC} ${CFLAGS} /Fe${THIS_BASENAME}.exe ${THIS_BASENAME}.c diff --git a/os2/waitpid.c b/os2/waitpid.c new file mode 100644 index 0000000..2b64f5d --- /dev/null +++ b/os2/waitpid.c @@ -0,0 +1,36 @@ +/* waitpid.c --- waiting for process termination, under OS/2 + Karl Fogel <kfogel@cyclic.com> --- November 1995 */ + +#include <assert.h> +#include <stdio.h> +#include <process.h> +#include <errno.h> + +#include "config.h" + +/* Wait for the process PID to exit. Put the return status in *statusp. + OPTIONS is not supported yet under OS/2. We hope it's always zero. */ +pid_t waitpid (pid, statusp, options) + pid_t pid; + int *statusp; + int options; +{ + pid_t rc; + + /* We don't know how to deal with any options yet. */ + assert (options == 0); + + rc = _cwait (statusp, pid, WAIT_CHILD); + + if (rc == -1) + { + if (errno == ECHILD) + return pid; + else + return -1; + } + else if (rc == pid) + return pid; + else + return -1; +} diff --git a/os2/watcom.mak b/os2/watcom.mak new file mode 100644 index 0000000..1d79c2a --- /dev/null +++ b/os2/watcom.mak @@ -0,0 +1,153 @@ +# Makefile for OS/2 (Watcom-C) for use with the watcom make. +# Written 11/96 by Ullrich von Bassewitz (uz@musoftware.com) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# The directory, where the IBM TCP/IP developers toolkit is installed. As far +# as I remember, c:\mptn is the default location. If it is not, it is still +# a good choice :-) +tcpip_dir = c:\mptn +tcpip_libdir = $(tcpip_dir)\lib +tcpip_incdir = $(tcpip_dir)\inc + +# Directory for source files and objects +srcdir = . +top_srcdir = .. +lib_dir = $(top_srcdir)\lib +cvs_srcdir = $(top_srcdir)\src +zlib_dir = $(top_srcdir)\zlib + +# Define the stuff used for building the executable +CC = WCC386 +LD = WLINK +CFLAGS = -bm -bt=OS2 -I$(srcdir) -I$(lib_dir) -I$(cvs_srcdir) -I$(zlib_dir) & + -DIBM_CPP -DHAVE_CONFIG_H -DTCPIP_IBM -d1 -onatx -zp4 -5s -fpi87 -zq & + -w2 -ze -I$(tcpip_incdir) + +# Tell the make where the C files are located +.c: $(srcdir);$(lib_dir);$(cvs_srcdir);$(zlib_dir) + +# Somewhat modified generic rule for .obj files. Don't put the .obj file into +# the current directory, use the source directory instead. +.c.obj: .AUTODEPEND + $(CC) $(CFLAGS) -fo=$*.obj $^* + +# object files from OS/2 sources +OS2_OBJECTS = & + $(srcdir)\mkdir.obj & + $(srcdir)\pwd.obj & + $(srcdir)\filesubr.obj & + $(srcdir)\run.obj & + $(srcdir)\stripslash.obj & + $(srcdir)\rcmd.obj & + $(srcdir)\waitpid.obj & + $(srcdir)\popen.obj & + $(srcdir)\porttcp.obj & + $(srcdir)\getpass.obj + +# object files from ..\src +COMMON_OBJECTS = & + $(cvs_srcdir)\add.obj & + $(cvs_srcdir)\admin.obj & + $(cvs_srcdir)\buffer.obj & + $(cvs_srcdir)\checkin.obj & + $(cvs_srcdir)\checkout.obj & + $(cvs_srcdir)\classify.obj & + $(cvs_srcdir)\client.obj & + $(cvs_srcdir)\commit.obj & + $(cvs_srcdir)\create_adm.obj & + $(cvs_srcdir)\cvsrc.obj & + $(cvs_srcdir)\diff.obj & + $(cvs_srcdir)\edit.obj & + $(cvs_srcdir)\entries.obj & + $(cvs_srcdir)\error.obj & + $(cvs_srcdir)\expand_path.obj & + $(cvs_srcdir)\fileattr.obj & + $(cvs_srcdir)\find_names.obj & + $(cvs_srcdir)\hash.obj & + $(cvs_srcdir)\history.obj & + $(cvs_srcdir)\ignore.obj & + $(cvs_srcdir)\import.obj & + $(cvs_srcdir)\lock.obj & + $(cvs_srcdir)\log.obj & + $(cvs_srcdir)\login.obj & + $(cvs_srcdir)\logmsg.obj & + $(cvs_srcdir)\main.obj & + $(cvs_srcdir)\mkmodules.obj & + $(cvs_srcdir)\modules.obj & + $(cvs_srcdir)\myndbm.obj & + $(cvs_srcdir)\no_diff.obj & + $(cvs_srcdir)\parseinfo.obj & + $(cvs_srcdir)\patch.obj & + $(cvs_srcdir)\rcs.obj & + $(cvs_srcdir)\rcscmds.obj & + $(cvs_srcdir)\recurse.obj & + $(cvs_srcdir)\release.obj & + $(cvs_srcdir)\remove.obj & + $(cvs_srcdir)\repos.obj & + $(cvs_srcdir)\root.obj & + $(cvs_srcdir)\rtag.obj & + $(cvs_srcdir)\scramble.obj & + $(cvs_srcdir)\server.obj & + $(cvs_srcdir)\status.obj & + $(cvs_srcdir)\subr.obj & + $(cvs_srcdir)\tag.obj & + $(cvs_srcdir)\update.obj & + $(cvs_srcdir)\watch.obj & + $(cvs_srcdir)\wrapper.obj & + $(cvs_srcdir)\vers_ts.obj & + $(cvs_srcdir)\version.obj & + $(cvs_srcdir)\zlib.obj +# end of $COMMON_OBJECTS + +# objects from ..\lib +LIB_OBJECTS = & + $(lib_dir)\getopt.obj & + $(lib_dir)\getopt1.obj & + $(lib_dir)\getline.obj & + $(lib_dir)\getwd.obj & + $(lib_dir)\savecwd.obj & + $(lib_dir)\sighandle.obj & + $(lib_dir)\yesno.obj & + $(lib_dir)\vasprintf.obj & + $(lib_dir)\xgetwd.obj & + $(lib_dir)\md5.obj & + $(lib_dir)\fnmatch.obj & + $(lib_dir)\regex.obj & + $(lib_dir)\getdate.obj & + $(lib_dir)\valloc.obj + +ZLIB_OBJECTS = & + $(zlib_dir)\adler32.obj & + $(zlib_dir)\compress.obj & + $(zlib_dir)\crc32.obj & + $(zlib_dir)\uncompr.obj & + $(zlib_dir)\deflate.obj & + $(zlib_dir)\trees.obj & + $(zlib_dir)\zutil.obj & + $(zlib_dir)\inflate.obj & + $(zlib_dir)\infblock.obj & + $(zlib_dir)\inftrees.obj & + $(zlib_dir)\infcodes.obj & + $(zlib_dir)\infutil.obj & + $(zlib_dir)\inffast.obj + +OBJECTS = $(COMMON_OBJECTS) $(LIB_OBJECTS) $(OS2_OBJECTS) $(ZLIB_OBJECTS) + +cvs.exe: $(OBJECTS) + $(LD) SYSTEM os2v2 DEBUG all NAME cvs.exe OPTION dosseg & + OPTION stack=32K FILE $(cvs_srcdir)\*.obj,$(lib_dir)\*.obj, & + $(srcdir)\*.obj,$(zlib_dir)\*.obj & + LIBRARY $(tcpip_libdir)\tcp32dll.lib, & + $(tcpip_libdir)\so32dll.lib + +strip: cvs.exe .SYMBOLIC + -wstrip cvs.exe |