home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
gnuish
/
cpio11.arc
/
patches
< prev
next >
Wrap
Text File
|
1990-09-24
|
37KB
|
1,270 lines
*** e:\tmp/RCSt1006704 Sun Sep 23 23:41:22 1990
--- copyin.c Sun Sep 23 23:24:32 1990
***************
*** 15,20 ****
--- 15,32 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/cpio/RCS/copyin.c 1.1.0.2 90/09/23 23:10:58 tho Exp $
+ */
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
***************
*** 22,34 ****
--- 34,52 ----
#define lstat stat
#endif
#include <errno.h>
+ #ifndef MSDOS /* sigh, it's `volatile' !!! */
extern int errno;
+ #endif
#include <fcntl.h>
+ #ifndef MSDOS
#include <sys/file.h>
+ #endif
#ifdef USG
#include <time.h>
#include <string.h>
+ #ifndef MSDOS
#include <sys/sysmacros.h>
+ #endif
#else
#include <sys/time.h>
#include <strings.h>
***************
*** 37,43 ****
--- 55,79 ----
#include "dstring.h"
#include "extern.h"
+ #ifdef MSDOS
+ extern int mkdir (char *, int); /* we're cheating! */
+ #define major(dev) (((dev) >> 8) & 0xff)
+ #define minor(dev) ((dev) & 0xff)
+ extern int glob_match (char *pattern, char *text, int dot_special);
+ extern void read_in_header (struct cpio_header *file_hdr, int in_des);
+ static void read_in_ascii (struct cpio_header *file_hdr, int in_des);
+ static void read_in_binary (struct cpio_header *file_hdr, int in_des);
+ extern void swab_array (short *ptr, int count);
+ extern void mode_string (unsigned short mode, char *str);
+ extern void print_name_with_quoting (char *p);
+ #endif /* MSDOS */
+
+
+ #ifdef MSDOS
+ #define bcopy(s, d, n) memmove ((d), (s), (n)) /* more efficient */
+ #else
void bcopy ();
+ #endif
void read_in_ascii ();
void read_in_binary ();
***************
*** 138,147 ****
--- 174,191 ----
swab_array ((short *) file_hdr, 13);
}
+ #ifdef MSDOS
+ file_hdr->h_mtime = (long) file_hdr->h_mtimes[0] << 16
+ | file_hdr->h_mtimes[1];
+
+ file_hdr->h_filesize = (long) file_hdr->h_filesizes[0] << 16
+ | file_hdr->h_filesizes[1];
+ #else /* not MSDOS */
file_hdr->h_mtime = file_hdr->h_mtimes[0] << 16 | file_hdr->h_mtimes[1];
file_hdr->h_filesize = file_hdr->h_filesizes[0] << 16
| file_hdr->h_filesizes[1];
+ #endif /* not MSDOS */
/* Read file name from input. */
if (file_hdr->h_name != NULL)
***************
*** 191,200 ****
--- 235,252 ----
struct cpio_header file_hdr; /* Output header information. */
int out_file_des; /* Output file descriptor. */
int in_file_des; /* Input file descriptor. */
+ #ifdef MSDOS
+ int skip_file; /* Shut up the compiler. */
+ #else
char skip_file; /* Flag for use with patterns. */
+ #endif
int i; /* Loop index variable. */
char *link_name = NULL; /* Name of hard and symbolic links. */
+ #ifdef MSDOS
+ setmode (fileno (stdin), O_BINARY);
+ #endif
+
/* Initialize copy in. */
file_hdr.h_name = NULL;
ds_init (&new_name, 128);
***************
*** 202,207 ****
--- 254,267 ----
/* Open interactive file pair for rename operation. */
if (rename_flag)
{
+ #ifdef MSDOS
+ tty_in = fopen ("con", "r");
+ if (tty_in == NULL)
+ error (2, errno, "/dev/tty");
+ tty_out = fopen ("con", "w");
+ if (tty_out == NULL)
+ error (2, errno, "/dev/tty");
+ #else /* not MSDOS */
tty_in = fopen ("/dev/tty", "r");
if (tty_in == NULL)
error (2, errno, "/dev/tty");
***************
*** 208,213 ****
--- 268,274 ----
tty_out = fopen ("/dev/tty", "w");
if (tty_out == NULL)
error (2, errno, "/dev/tty");
+ #endif /* not MSDOS */
}
/* Get date and time if needed for processing the table option. */
***************
*** 218,225 ****
--- 279,290 ----
in_file_des = fileno (stdin);
if (fstat (in_file_des, &file_stat))
error (1, errno, "standard input is closed");
+ #ifdef S_IFBLK
input_is_special = ((file_stat.st_mode & S_IFMT) == S_IFCHR
|| (file_stat.st_mode & S_IFMT) == S_IFBLK);
+ #else /* not S_IFBLK */
+ input_is_special = ((file_stat.st_mode & S_IFMT) == S_IFCHR);
+ #endif /* not S_IFBLK */
input_is_seekable = ((file_stat.st_mode & S_IFMT) == S_IFREG);
output_is_seekable = TRUE;
***************
*** 325,330 ****
--- 390,398 ----
{
case S_IFREG:
/* Can the current file be linked to a previously copied file? */
+ #ifdef MSDOS
+ link_name = NULL;
+ #else /* not MSDOS */
if (file_hdr.h_nlink > 1)
{
link_name = find_inode_file (file_hdr.h_ino);
***************
*** 349,365 ****
--- 417,445 ----
link_name = NULL;
}
}
+ #endif /* not MSDOS */
/* If not linked, copy the contents of the file. */
if (link_name == NULL)
{
+ #ifdef MSDOS
out_file_des = open (file_hdr.h_name,
+ O_CREAT | O_WRONLY | O_BINARY, 0600);
+ #else
+ out_file_des = open (file_hdr.h_name,
O_CREAT | O_WRONLY, 0600);
+ #endif
if (out_file_des < 0 && create_dir_flag)
{
create_all_directories (file_hdr.h_name);
+ #ifdef MSDOS
+ out_file_des = open (file_hdr.h_name,
+ O_CREAT | O_WRONLY | O_BINARY,
+ 0600);
+ #else
out_file_des = open (file_hdr.h_name,
O_CREAT | O_WRONLY, 0600);
+ #endif
}
if (out_file_des < 0)
{
***************
*** 376,385 ****
--- 456,467 ----
/* File is now copied; set attributes. */
if (chmod (file_hdr.h_name, file_hdr.h_mode) < 0)
error (0, errno, "%s", file_hdr.h_name);
+ #ifndef MSDOS
if (chown (file_hdr.h_name, file_hdr.h_uid,
file_hdr.h_gid) < 0
&& errno != EPERM)
error (0, errno, "%s", file_hdr.h_name);
+ #endif /* not MSDOS */
if (retain_time_flag)
{
times[0] = times[1] = file_hdr.h_mtime;
***************
*** 401,414 ****
--- 483,500 ----
error (0, errno, "%s", file_hdr.h_name);
continue;
}
+ #ifndef MSDOS
if (chown (file_hdr.h_name, file_hdr.h_uid,
file_hdr.h_gid) < 0
&& errno != EPERM)
error (0, errno, "%s", file_hdr.h_name);
+ #endif /* not MSDOS */
break;
case S_IFCHR:
+ #ifdef S_IFBLK
case S_IFBLK:
+ #endif
#ifdef S_IFSOCK
case S_IFSOCK:
#endif
***************
*** 415,420 ****
--- 501,507 ----
#ifdef S_IFIFO
case S_IFIFO:
#endif
+ #ifndef MSDOS
res = mknod (file_hdr.h_name, file_hdr.h_mode, file_hdr.h_rdev);
if (res < 0 && create_dir_flag)
{
***************
*** 431,436 ****
--- 518,524 ----
file_hdr.h_gid) < 0
&& errno != EPERM)
error (0, errno, "%s", file_hdr.h_name);
+ #endif /* not MSDOS */
break;
#ifdef S_IFLNK
***************
*** 466,472 ****
--- 554,564 ----
fprintf (stderr, "%s\n", file_hdr.h_name);
}
}
+ #ifdef MSDOS
+ res = (int) ((input_bytes + io_block_size - 1) / io_block_size);
+ #else
res = (input_bytes + io_block_size - 1) / io_block_size;
+ #endif
if (res == 1)
fprintf (stderr, "1 block\n");
else
***************
*** 509,520 ****
--- 601,620 ----
printf ("%-8.8s %-8.8s ", getuser (file_hdr->h_uid),
getgroup (file_hdr->h_gid));
+ #ifdef S_IFBLK
if ((file_hdr->h_mode & S_IFMT) == S_IFCHR
|| (file_hdr->h_mode & S_IFMT) == S_IFBLK)
+ #else /* not S_IFBLK */
+ if ((file_hdr->h_mode & S_IFMT) == S_IFCHR)
+ #endif /* not S_IFBLK */
printf ("%3u, %3u ", major (file_hdr->h_rdev),
minor (file_hdr->h_rdev));
else
+ #ifdef MSDOS
+ printf ("%8lu ", file_hdr->h_filesize);
+ #else
printf ("%8u ", file_hdr->h_filesize);
+ #endif
printf ("%s ", tbuf + 4);
*** e:\tmp/RCSt1006704 Sun Sep 23 23:41:24 1990
--- copyout.c Sun Sep 23 23:34:08 1990
***************
*** 15,20 ****
--- 15,32 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/cpio/RCS/copyout.c 1.1.0.2 90/09/23 23:33:23 tho Exp $
+ */
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
***************
*** 22,30 ****
--- 34,46 ----
#define lstat stat
#endif
#include <errno.h>
+ #ifndef MSDOS /* sigh, it's `volatile' !!! */
extern int errno;
+ #endif
#include <fcntl.h>
+ #ifndef MSDOS
#include <sys/file.h>
+ #endif
#ifdef USG
#include <time.h>
#include <string.h>
***************
*** 48,55 ****
--- 64,76 ----
{
char ascii_header[78];
+
sprintf (ascii_header,
+ #ifdef MSDOS
+ "%06ho%06ho%06ho%06ho%06ho%06ho%06ho%06ho%011lo%06ho%011lo",
+ #else
"%06o%06o%06o%06o%06o%06o%06o%06o%011o%06o%011o",
+ #endif
file_hdr->h_magic & 0xFFFF, file_hdr->h_dev & 0xFFFF,
file_hdr->h_ino & 0xFFFF, file_hdr->h_mode & 0xFFFF,
file_hdr->h_uid & 0xFFFF, file_hdr->h_gid & 0xFFFF,
***************
*** 67,77 ****
--- 88,108 ----
if (output_size & 1)
copy_buf_out ("", out_des, 1);
+ #ifdef MSDOS
+ file_hdr->h_mtimes[0] = (unsigned int) (file_hdr->h_mtime >> 16);
+ file_hdr->h_mtimes[1] = (unsigned int) (file_hdr->h_mtime & 0xFFFF);
+
+ file_hdr->h_filesizes[0]
+ = (unsigned int) (file_hdr->h_filesize >> 16);
+ file_hdr->h_filesizes[1]
+ = (unsigned int) (file_hdr->h_filesize & 0xFFFF);
+ #else /* not MSDOS */
file_hdr->h_mtimes[0] = file_hdr->h_mtime >> 16;
file_hdr->h_mtimes[1] = file_hdr->h_mtime & 0xFFFF;
file_hdr->h_filesizes[0] = file_hdr->h_filesize >> 16;
file_hdr->h_filesizes[1] = file_hdr->h_filesize & 0xFFFF;
+ #endif /* not MSDOS */
/* Output the file header. */
copy_buf_out ((char *) file_hdr, out_des, 26);
***************
*** 100,105 ****
--- 131,140 ----
int in_file_des; /* Source file descriptor. */
int out_file_des; /* Output file descriptor. */
+ #ifdef MSDOS
+ setmode (fileno (stdout), O_BINARY);
+ #endif
+
/* Initialize copy out. */
ds_init (&input_name, 128);
file_hdr.h_magic = 070707;
***************
*** 108,115 ****
--- 143,154 ----
out_file_des = fileno (stdout);
if (fstat (out_file_des, &file_stat))
error (1, errno, "standard output is closed");
+ #ifdef S_IFBLK
output_is_special = ((file_stat.st_mode & S_IFMT) == S_IFCHR
|| (file_stat.st_mode & S_IFMT) == S_IFBLK);
+ #else /* not S_IFBLK */
+ output_is_special = ((file_stat.st_mode & S_IFMT) == S_IFCHR);
+ #endif /* not S_IFBLK */
output_is_seekable = ((file_stat.st_mode & S_IFMT) == S_IFREG);
/* Copy files with names read from stdin. */
***************
*** 144,150 ****
--- 183,194 ----
switch (file_hdr.h_mode & S_IFMT)
{
case S_IFREG:
+ #ifdef MSDOS
+ in_file_des = open (input_name.ds_string,
+ O_RDONLY | O_BINARY, 0);
+ #else
in_file_des = open (input_name.ds_string, O_RDONLY, 0);
+ #endif
if (in_file_des < 0)
{
error (0, errno, "%s", input_name.ds_string);
***************
*** 169,175 ****
--- 213,221 ----
break;
case S_IFCHR:
+ #ifdef S_IFBLK
case S_IFBLK:
+ #endif
#ifdef S_IFSOCK
case S_IFSOCK:
#endif
***************
*** 223,229 ****
--- 269,279 ----
}
empty_output_buffer (out_file_des);
finish_output_file ("standard output", out_file_des);
+ #ifdef MSDOS
+ res = (int) (output_bytes / io_block_size);
+ #else
res = output_bytes / io_block_size;
+ #endif
if (res == 1)
fprintf (stderr, "1 block\n");
else
*** e:\tmp/RCSt1006704 Sun Sep 23 23:41:26 1990
--- copypass.c Sun Sep 23 23:29:26 1990
***************
*** 15,20 ****
--- 15,32 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/cpio/RCS/copypass.c 1.1.0.2 90/09/23 23:11:03 tho Exp $
+ */
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
***************
*** 22,30 ****
--- 34,46 ----
#define lstat stat
#endif
#include <errno.h>
+ #ifndef MSDOS /* sigh, it's `volatile' !!! */
extern int errno;
+ #endif
#include <fcntl.h>
+ #ifndef MSDOS
#include <sys/file.h>
+ #endif
#ifdef USG
#include <time.h>
#include <string.h>
***************
*** 36,41 ****
--- 52,61 ----
#include "dstring.h"
#include "extern.h"
+ #ifdef MSDOS
+ extern int mkdir (char *, int); /* we're cheating! */
+ #endif
+
/* Copy files listed on the standard input into directory `directory_name'.
If `link_flag', link instead of copying. */
***************
*** 114,119 ****
--- 134,142 ----
case S_IFREG:
/* Can the current file be linked to a another file?
Set link_name to the original file name. */
+ #ifdef MSDOS
+ link_name = NULL;
+ #else /* not MSDOS */
if (link_flag)
{
/* User said to link it if possible. */
***************
*** 154,176 ****
--- 177,215 ----
link_name = NULL;
}
}
+ #endif /* not MSDOS */
/* If the file was not linked, copy contents of file. */
if (link_name == NULL)
{
+ #ifdef MSDOS
+ in_file_des = open (input_name.ds_string,
+ O_RDONLY | O_BINARY, 0);
+ #else
in_file_des = open (input_name.ds_string, O_RDONLY, 0);
+ #endif
if (in_file_des < 0)
{
error (0, errno, "%s", input_name.ds_string);
continue;
}
+ #ifdef MSDOS
out_file_des = open (output_name.ds_string,
+ O_CREAT | O_WRONLY | O_BINARY, 0600);
+ #else
+ out_file_des = open (output_name.ds_string,
O_CREAT | O_WRONLY, 0600);
+ #endif
if (out_file_des < 0 && create_dir_flag)
{
create_all_directories (output_name.ds_string);
+ #ifdef MSDOS
+ out_file_des = open (output_name.ds_string,
+ O_CREAT | O_WRONLY | O_BINARY, 0600);
+ #else
out_file_des = open (output_name.ds_string,
O_CREAT | O_WRONLY, 0600);
+ #endif
}
if (out_file_des < 0)
{
***************
*** 188,197 ****
--- 227,238 ----
/* Set the attributes of the new file. */
if (chmod (output_name.ds_string, in_file_stat.st_mode) < 0)
error (0, errno, "%s", output_name.ds_string);
+ #ifndef MSDOS
if (chown (output_name.ds_string, in_file_stat.st_uid,
in_file_stat.st_gid) < 0
&& errno != EPERM)
error (0, errno, "%s", output_name.ds_string);
+ #endif /* not MSDOS */
if (reset_time_flag)
{
times[0] = in_file_stat.st_atime;
***************
*** 216,229 ****
--- 257,274 ----
error (0, errno, "%s", output_name.ds_string);
continue;
}
+ #ifndef MSDOS
if (chown (output_name.ds_string, in_file_stat.st_uid,
in_file_stat.st_gid) < 0
&& errno != EPERM)
error (0, errno, "%s", output_name.ds_string);
+ #endif /* not MSDOS */
break;
case S_IFCHR:
+ #ifdef S_IFBLK
case S_IFBLK:
+ #endif
#ifdef S_IFIFO
case S_IFIFO:
#endif
***************
*** 230,235 ****
--- 275,281 ----
#ifdef S_IFSOCK
case S_IFSOCK:
#endif
+ #ifndef MSDOS
res = mknod (output_name.ds_string, in_file_stat.st_mode,
in_file_stat.st_rdev);
if (res < 0 && create_dir_flag)
***************
*** 247,252 ****
--- 293,299 ----
in_file_stat.st_gid) < 0
&& errno != EPERM)
error (0, errno, "%s", output_name.ds_string);
+ #endif /* not MSDOS */
break;
#ifdef S_IFLNK
***************
*** 286,292 ****
--- 333,343 ----
fprintf (stderr, "%s\n", output_name.ds_string);
}
+ #ifdef MSDOS
+ res = (int) (output_bytes / io_block_size);
+ #else
res = output_bytes / io_block_size;
+ #endif
if (res == 1)
fprintf (stderr, "1 block\n");
else
*** e:\tmp/RCSt1006704 Sun Sep 23 23:41:30 1990
--- dstring.c Sun Sep 23 23:29:48 1990
***************
*** 15,20 ****
--- 15,32 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/cpio/RCS/dstring.c 1.1.0.2 90/09/23 23:11:06 tho Exp $
+ */
+
#include <stdio.h>
#ifdef USG
#include <string.h>
***************
*** 23,30 ****
--- 35,47 ----
#endif
#include "dstring.h"
+ #ifdef MSDOS
+ extern char *xmalloc (unsigned int size);
+ extern char *xrealloc (char *ptr, unsigned int size);
+ #else /* not MSDOS */
char *xmalloc ();
char *xrealloc ();
+ #endif /* not MSDOS */
/* Initialiaze dynamic string STRING with space for SIZE characters. */
*** e:\tmp/RCSt1006704 Sun Sep 23 23:41:30 1990
--- dstring.h Sun Sep 23 23:24:38 1990
***************
*** 15,20 ****
--- 15,38 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/cpio/RCS/dstring.h 1.1.0.2 90/09/23 23:11:17 tho Exp $
+ */
+
+ #ifdef MSDOS
+ #ifndef FILE
+ #include <stdio.h>
+ #endif
+ #endif
+
#ifndef NULL
#define NULL 0
#endif
***************
*** 42,47 ****
--- 60,71 ----
#define ds_index(s, c) index ((s)->ds_string, c)
#define ds_rindex(s, c) rindex ((s)->ds_string, c)
+ #ifdef MSDOS
+ extern void ds_init (dynamic_string *string, int size);
+ extern void ds_resize (dynamic_string *string, int size);
+ extern char *ds_fgets (FILE *f, dynamic_string *s);
+ #else /* not MSDOS */
void ds_init ();
void ds_resize ();
char *ds_fgets ();
+ #endif /* not MSDOS */
*** e:\tmp/RCSt1006704 Sun Sep 23 23:41:32 1990
--- extern.h Sun Sep 23 23:24:42 1990
***************
*** 15,20 ****
--- 15,38 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/cpio/RCS/extern.h 1.1.0.2 90/09/23 23:11:18 tho Exp $
+ */
+
+ #ifdef MSDOS
+ #define LONG long
+ #else
+ #define LONG int
+ #endif
+
extern int reset_time_flag;
extern int io_block_size;
extern int binary_flag;
***************
*** 31,49 ****
extern char *input_buffer, *output_buffer;
extern char *in_buff, *out_buff;
! extern int input_size, output_size;
! extern int input_bytes, output_bytes;
extern char *directory_name;
extern char **save_patterns;
extern int num_patterns;
extern char input_is_special;
extern char output_is_special;
extern char input_is_seekable;
extern char output_is_seekable;
extern char *program_name;
extern int (*xstat) ();
extern void (*copy_function) ();
long lseek ();
char *malloc ();
char *realloc ();
--- 49,111 ----
extern char *input_buffer, *output_buffer;
extern char *in_buff, *out_buff;
! extern LONG input_size, output_size;
! extern LONG input_bytes, output_bytes;
extern char *directory_name;
extern char **save_patterns;
extern int num_patterns;
+ #ifdef MSDOS /* shut up the compiler */
+ extern int input_is_special;
+ extern int output_is_special;
+ extern int input_is_seekable;
+ extern int output_is_seekable;
+ #else /* not MSDOS */
extern char input_is_special;
extern char output_is_special;
extern char input_is_seekable;
extern char output_is_seekable;
+ #endif /* not MSDOS */
extern char *program_name;
+
+ #ifdef MSDOS
+ extern int (*xstat) (char *name, struct stat *statb);
+ extern void (*copy_function) (void);
+ #else
extern int (*xstat) ();
extern void (*copy_function) ();
+ #endif
+
+ #ifdef MSDOS
+ #include <stdlib.h>
+ #include <io.h>
+
+ extern int utime (char *, long *); /* we're cheating... */
+
+ extern char *copystring (char *string);
+ extern char *find_inode_file (unsigned int node_num);
+ extern char *getgroup (int gid);
+ extern char *getuser (int uid);
+ extern char *xmalloc (unsigned int size);
+ extern void add_inode (unsigned short node_num, char *file_name);
+ extern void copy_buf_out (char *in_buf, int out_des, LONG num_bytes);
+ extern void copy_files (int in_des, int out_des, LONG num_bytes);
+ extern void copy_in_buf (char *in_buf, int in_des, LONG num_bytes);
+ extern void create_all_directories (char *name);
+ extern void empty_output_buffer (int out_des);
+ extern void error (int status, int errnum, char *message, ...);
+ extern void finish_output_file (char *path, int out_des);
+ extern void get_next_reel (int tape_des);
+ extern void hash_insert (struct inode_val *new_value);
+ extern void long_format (struct cpio_header *file_hdr, char *link_name);
+ extern void process_copy_in (void);
+ extern void process_copy_out (void);
+ extern void process_copy_pass (void);
+ extern void toss_input (int in_des, LONG num_bytes);
+ extern void write_out_header (struct cpio_header *file_hdr, int out_des);
+
+ #else /* not MSDOS */
+
long lseek ();
char *malloc ();
char *realloc ();
***************
*** 70,72 ****
--- 132,136 ----
void protection ();
void toss_input ();
void write_out_header ();
+
+ #endif /* not MSDOS */
*** e:\tmp/RCSt1006704 Sun Sep 23 23:41:34 1990
--- filemode.c Sun Sep 23 23:31:36 1990
***************
*** 14,19 ****
--- 14,31 ----
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/cpio/RCS/filemode.c 1.1.0.2 90/09/23 23:11:07 tho Exp $
+ */
#include <sys/types.h>
#include <sys/stat.h>
***************
*** 23,32 ****
--- 35,52 ----
#define S_IEXEC S_IXUSR
#endif
+ #ifdef MSDOS
+ extern void filemodestring (struct stat *statp, char *str);
+ extern void mode_string (unsigned short mode, char *str);
+ static char ftypelet (unsigned short bits);
+ static void rwx (unsigned short bits, char *chars);
+ static void setst (unsigned short bits, char *chars);
+ #else /* not MSDOS */
void mode_string ();
static char ftypelet ();
static void rwx ();
static void setst ();
+ #endif /* not MSDOS */
/* filemodestring - fill in string STR with an ls-style ASCII
representation of the st_mode field of file stats block STATP.
*** e:\tmp/RCSt1006704 Sun Sep 23 23:41:34 1990
--- global.c Sun Sep 23 23:30:02 1990
***************
*** 15,23 ****
--- 15,39 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/cpio/RCS/global.c 1.1.0.2 90/09/23 23:11:09 tho Exp $
+ */
+
#include "cpio.h"
#include "dstring.h"
+ #ifdef MSDOS
+ #include "extern.h"
+ #endif
+
/* If TRUE, reset access times after reading files (-a). */
int reset_time_flag = FALSE;
***************
*** 67,76 ****
char *in_buff, *out_buff;
/* Current number of bytes stored at `input_buff' and `output_buff'. */
! int input_size, output_size;
/* Total number of bytes read and written for all files. */
! int input_bytes, output_bytes;
/* Saving of argument values for later reference. */
char *directory_name;
--- 83,92 ----
char *in_buff, *out_buff;
/* Current number of bytes stored at `input_buff' and `output_buff'. */
! LONG input_size, output_size;
/* Total number of bytes read and written for all files. */
! LONG input_bytes, output_bytes;
/* Saving of argument values for later reference. */
char *directory_name;
***************
*** 78,91 ****
--- 94,120 ----
int num_patterns;
/* TRUE if input (cpio -i) or output (cpio -o) is a device node. */
+ #ifdef MSDOS /* shut up the compiler */
+ int input_is_special = FALSE;
+ int output_is_special = FALSE;
+ #else
char input_is_special = FALSE;
char output_is_special = FALSE;
+ #endif
/* TRUE if lseek works on the input. */
+ #ifdef MSDOS /* shut up the compiler */
+ int input_is_seekable = FALSE;
+ #else
char input_is_seekable = FALSE;
+ #endif
/* TRUE if lseek works on the output. */
+ #ifdef MSDOS /* shut up the compiler */
+ int output_is_seekable = FALSE;
+ #else
char output_is_seekable = FALSE;
+ #endif
/* The name this program was run with. */
char *program_name;
***************
*** 92,98 ****
--- 121,135 ----
/* A pointer to either lstat or stat, depending on whether
dereferencing of symlinks is done for input files. */
+ #ifdef MSDOS
+ int (*xstat) (char *name, struct stat *statb);
+ #else
int (*xstat) ();
+ #endif
/* Which copy operation to perform. (-i, -o, -p) */
+ #ifdef MSDOS
+ void (*copy_function) (void) = 0;
+ #else
void (*copy_function) () = 0;
+ #endif
*** e:\tmp/RCSt1006704 Sun Sep 23 23:41:36 1990
--- main.c Sun Sep 23 23:30:16 1990
***************
*** 17,22 ****
--- 17,34 ----
/* Written by Philip A. Nelson and David MacKenzie. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/cpio/RCS/main.c 1.1.0.2 90/09/23 23:11:10 tho Exp $
+ */
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
***************
*** 35,40 ****
--- 47,59 ----
int lstat ();
int stat ();
+
+ #ifdef MSDOS
+ extern void usage (void);
+ extern void main (int argc, char **argv);
+ extern void process_args (int argc, char **argv);
+ extern void initialize_buffers (void);
+ #endif /* MSDOS */
struct option long_opts[] =
{
*** e:\tmp/RCSt1006704 Sun Sep 23 23:41:38 1990
--- util.c Sun Sep 23 23:30:52 1990
***************
*** 15,28 ****
--- 15,44 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/cpio/RCS/util.c 1.1.0.2 90/09/23 23:11:12 tho Exp $
+ */
+
#include <stdio.h>
#include <pwd.h>
+ #ifndef MSDOS
#include <grp.h>
+ #endif
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
+ #ifndef MSDOS /* sigh, it's `volatile' !!! */
extern int errno;
#include <sys/ioctl.h>
+ #endif
#ifdef USG
#include <string.h>
#else
***************
*** 34,39 ****
--- 50,63 ----
#include "cpio.h"
#include "extern.h"
+ #ifdef MSDOS
+ #include <assert.h>
+ extern int mkdir (char *, int); /* we're cheating! */
+ extern void fill_input_buffer (int in_des, int num_bytes);
+ extern void tape_offline (int tape_des);
+ extern char *xrealloc (char *ptr, unsigned int size);
+ #endif /* MSDOS */
+
/* TRUE if the last buffer written by `empty_output_buffer' was a block
of zeros spaced forward with lseek. */
static char last_write_made_hole;
***************
*** 46,52 ****
empty_output_buffer (out_des)
int out_des;
{
! int bytes_written;
char *cp;
int *ip;
--- 70,76 ----
empty_output_buffer (out_des)
int out_des;
{
! LONG bytes_written;
char *cp;
int *ip;
***************
*** 76,82 ****
--- 100,111 ----
}
if (last_write_made_hole == FALSE)
{
+ #ifdef MSDOS
+ assert (output_size < 0xffffL);
+ bytes_written = write (out_des, output_buffer, (size_t) output_size);
+ #else
bytes_written = write (out_des, output_buffer, output_size);
+ #endif
if (bytes_written != output_size)
{
error (0, errno, "write error");
***************
*** 83,89 ****
--- 112,123 ----
if (bytes_written == 0 && output_is_special)
{
get_next_reel (out_des);
+ #ifdef MSDOS
+ bytes_written = write (out_des, output_buffer,
+ (size_t) output_size);
+ #else
bytes_written = write (out_des, output_buffer, output_size);
+ #endif
}
if (bytes_written != output_size)
exit (1);
***************
*** 151,157 ****
copy_buf_out (in_buf, out_des, num_bytes)
char *in_buf;
int out_des;
! int num_bytes;
{
/* Copy the bytes one at a time, and empty the output buffer
when it is full. */
--- 185,191 ----
copy_buf_out (in_buf, out_des, num_bytes)
char *in_buf;
int out_des;
! LONG num_bytes;
{
/* Copy the bytes one at a time, and empty the output buffer
when it is full. */
***************
*** 172,178 ****
copy_in_buf (in_buf, in_des, num_bytes)
char *in_buf;
int in_des;
! int num_bytes;
{
while (num_bytes-- > 0)
{
--- 206,212 ----
copy_in_buf (in_buf, in_des, num_bytes)
char *in_buf;
int in_des;
! LONG num_bytes;
{
while (num_bytes-- > 0)
{
***************
*** 190,196 ****
void
toss_input (in_des, num_bytes)
int in_des;
! int num_bytes;
{
int num_toss; /* Number of io_block_size blocks to toss. */
int i; /* Index for loop. */
--- 224,230 ----
void
toss_input (in_des, num_bytes)
int in_des;
! LONG num_bytes;
{
int num_toss; /* Number of io_block_size blocks to toss. */
int i; /* Index for loop. */
***************
*** 202,212 ****
--- 236,254 ----
them or read them from tape. The last partial block is then read
and prepared for a toss of less than one full block. */
num_bytes -= input_size;
+ #ifdef MSDOS
+ num_toss = (int) (num_bytes / io_block_size);
+ #else
num_toss = num_bytes / io_block_size;
+ #endif
if (input_is_seekable)
{
/* We can seek past the blocks, saving input disk reads. */
+ #ifdef MSDOS
+ if (lseek (in_des, (long) num_toss * (long) io_block_size, 1) < 0L)
+ #else
if (lseek (in_des, (long) (num_toss * io_block_size), 1) < 0L)
+ #endif
error (1, errno, "cannot seek on input");
input_bytes += num_toss * io_block_size;
}
***************
*** 216,222 ****
--- 258,268 ----
for (i = 1; i <= num_toss; i++)
fill_input_buffer (in_des, io_block_size);
}
+ #ifdef MSDOS
+ num_bytes -= (long) num_toss * (long) io_block_size;
+ #else
num_bytes -= num_toss * io_block_size;
+ #endif
/* Get next block containing last "few" bytes to toss. */
fill_input_buffer (in_des, io_block_size);
}
***************
*** 238,246 ****
copy_files (in_des, out_des, num_bytes)
int in_des;
int out_des;
! int num_bytes;
{
! int size;
while (num_bytes > 0)
{
--- 284,292 ----
copy_files (in_des, out_des, num_bytes)
int in_des;
int out_des;
! LONG num_bytes;
{
! LONG size;
while (num_bytes > 0)
{
***************
*** 555,560 ****
--- 601,614 ----
int c;
/* Open files for interactive communication. */
+ #ifdef MSDOS
+ tty_in = fopen ("con", "r");
+ if (tty_in == NULL)
+ error (2, errno, "/dev/tty");
+ tty_out = fopen ("con", "w");
+ if (tty_out == NULL)
+ error (2, errno, "/dev/tty");
+ #else /* not MSDOS */
tty_in = fopen ("/dev/tty", "r");
if (tty_in == NULL)
error (2, errno, "/dev/tty");
***************
*** 561,566 ****
--- 615,621 ----
tty_out = fopen ("/dev/tty", "w");
if (tty_out == NULL)
error (2, errno, "/dev/tty");
+ #endif /* not MSDOS */
/* Give message and wait for carrage return. User should hit carrage return
only after loading the next tape. */
*** e:\tmp/RCSt1006704 Sun Sep 23 23:41:40 1990
--- version.c Sun Sep 23 23:31:52 1990
***************
*** 15,18 ****
--- 15,37 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ /* MS-DOS port (c) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
+ This port is also distributed under the terms of the
+ GNU General Public License as published by the
+ Free Software Foundation.
+
+ Please note that this file is not identical to the
+ original GNU release, you should have received this
+ code as patch to the official release.
+
+ $Header: e:/gnu/cpio/RCS/version.c 1.1.0.2 90/09/23 23:11:16 tho Exp $
+ */
+
+ #ifdef MSDOS
+ char *version_string =
+ "GNU cpio version 1.1 (compiled " __DATE__ " " __TIME__ " for MS-DOS)\n";
+ #else
char *version_string = "GNU cpio version 1.1\n";
+ #endif
+
+