mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-12-26 09:29:18 +00:00
Initial checkin; these sources should correspond to those used to
build the GNO v2.0.4 version of this util.
This commit is contained in:
parent
35a4a5a916
commit
fdf0d8d918
5
bin/time/Makefile
Normal file
5
bin/time/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
time.a: time.c
|
||||
compile time.c keep=time
|
||||
|
||||
time: time.a
|
||||
link time keep=time
|
32
bin/time/time.c
Normal file
32
bin/time/time.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* time.c
|
||||
* return process execution time of command
|
||||
* 1.1 5/7/92 modified to use times() for higher accuracy
|
||||
* 1.0 jb
|
||||
*/
|
||||
|
||||
#pragma optimize -1
|
||||
#pragma stacksize 1024
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/times.h>
|
||||
#include <orca.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct tms t;
|
||||
time_t start,end;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr,"usage: time [command]\n\r");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
start = time(NULL);
|
||||
system(commandline()+strlen(argv[0])+1);
|
||||
end = time(NULL);
|
||||
times(&t);
|
||||
fprintf(stderr," %8ld real %7.2f user %7.2f sys\n",
|
||||
end-start,t.tms_cutime/60.0,t.tms_cstime/60.0);
|
||||
}
|
126
bin/touch/touch.c
Normal file
126
bin/touch/touch.c
Normal file
@ -0,0 +1,126 @@
|
||||
/* Touch - GS version of UNIX touch. If file exists, sets mod. date to
|
||||
current date. If file does not exist, creates a text file with that name.
|
||||
|
||||
Copyright 1993 by Leslie M. Barstow III.
|
||||
Placed in the Public Domain with the following condition:
|
||||
Please maintain original Copyright in source, program, and manpage.
|
||||
*/
|
||||
|
||||
#pragma debug 0
|
||||
#pragma optimize -1
|
||||
#pragma stacksize 1024
|
||||
|
||||
#include <types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <orca.h>
|
||||
|
||||
typedef struct GSString {
|
||||
Word length;
|
||||
char string[1];
|
||||
} GSString;
|
||||
|
||||
typedef struct FileInfoRecGS {
|
||||
Word pCount;
|
||||
GSString *pathname;
|
||||
Word access;
|
||||
Word fileType;
|
||||
LongWord auxType;
|
||||
Word storageType; /* must be 0 for SetFileInfo */
|
||||
TimeRec createDateTime;
|
||||
TimeRec modDateTime;
|
||||
} FileInfoRecGS;
|
||||
|
||||
typedef struct CreateRecGS {
|
||||
Word pCount;
|
||||
GSString *pathname;
|
||||
Word access;
|
||||
Word fileType;
|
||||
} CreateRecGS;
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0L
|
||||
#endif
|
||||
|
||||
extern TimeRec ReadTimeHex();
|
||||
|
||||
#ifndef stackEntry
|
||||
#define stackEntry 0xE100B0
|
||||
#endif
|
||||
|
||||
#ifndef PDosInt
|
||||
extern pascal void PDosInt();
|
||||
#endif
|
||||
|
||||
#define GetFileInfoGS(pBlockPtr) PDosInt(0x2006,pBlockPtr)
|
||||
#define SetFileInfoGS(pBlockPtr) PDosInt(0x2005,pBlockPtr)
|
||||
#define CreateGS(pBlockPtr) PDosInt(0x2001,pBlockPtr)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{int i,j;
|
||||
GSString *filnam=(GSString *)NULL;
|
||||
CreateRecGS crtspace;
|
||||
FileInfoRecGS infospace;
|
||||
|
||||
infospace.pCount = 7;
|
||||
crtspace.pCount = 3;
|
||||
crtspace.access = 0x00e3;
|
||||
crtspace.fileType = 0x0004;
|
||||
|
||||
if (argc == 1)
|
||||
{fputs("Usage: touch file1 [file2 ...]\n", stdout);
|
||||
fputs("GS touch: Copyright 1993 by Leslie M. Barstow III\n",stdout);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for(i = 1; i < argc; i++)
|
||||
{j=strlen(argv[i]);
|
||||
if ((filnam=(GSString *)malloc(3+j)) == (GSString *)NULL)
|
||||
{fputs("touch - Error allocating string memory\n", stdout);
|
||||
return(-1);
|
||||
}
|
||||
filnam->length = j;
|
||||
strcpy(filnam->string,argv[i]);
|
||||
infospace.pathname=filnam;
|
||||
GetFileInfoGS(&infospace);
|
||||
if (j = toolerror())
|
||||
{switch (j)
|
||||
{case 0x46: crtspace.pathname = filnam;
|
||||
CreateGS(&crtspace);
|
||||
if (j = toolerror())
|
||||
{fputs("touch - unable to create file: ", stdout);
|
||||
fputs(argv[i], stdout);
|
||||
fputs(".\n", stdout);
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
case 0x40:
|
||||
case 0x44:
|
||||
case 0x45:
|
||||
case 0x52:
|
||||
case 0x58: fputs("touch - Invalid filename:", stdout);
|
||||
fputs(argv[i], stdout);
|
||||
fputs(".\n", stdout);
|
||||
exit(-1);
|
||||
break;
|
||||
case 0x27: fputs("touch - Disk I/O Error for file: ", stdout);
|
||||
fputs(argv[i], stdout);
|
||||
fputs(".\n", stdout);
|
||||
exit(-1);
|
||||
break;
|
||||
default: fputs("touch - internal error.\n", stdout);
|
||||
exit(-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{infospace.modDateTime = ReadTimeHex();
|
||||
infospace.storageType = 0;
|
||||
infospace.access |=0x20;
|
||||
infospace.modDateTime.extra = (Byte)0;
|
||||
SetFileInfoGS(&infospace);
|
||||
}
|
||||
free(filnam);
|
||||
}
|
||||
}
|
41
bin/touch/touch.man
Normal file
41
bin/touch/touch.man
Normal file
@ -0,0 +1,41 @@
|
||||
TOUCH(1) TOUCH(1)
|
||||
|
||||
|
||||
NAME
|
||||
|
||||
touch - update modification date of existing file or create new file.
|
||||
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
touch file1 [file2 ...]
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
touch checks each file in the argument list and processes each as follows:
|
||||
|
||||
o If the file exists, touch sets the modification time and date to
|
||||
the current time/date. It also sets the backup-needed flag.
|
||||
|
||||
o If the file does not exist, it creates an empty text file of that
|
||||
name. The file is unlocked, with the backup-needed flag set.
|
||||
|
||||
Wildcard expansion is not supported outside of GNO/ME, which does its own.
|
||||
|
||||
Invalid filenames cause touch to exit with return code -1, printing the
|
||||
offending filename before exitting.
|
||||
|
||||
|
||||
CAVEATS
|
||||
|
||||
The ORCA editor does not seem to like files with length 0. It appears to
|
||||
attempt to re-create the file, which already exists and is open. Use vi or
|
||||
echo " " > filename. Otherwise, the file may be manipulated normally.
|
||||
|
||||
|
||||
OTHER
|
||||
|
||||
This program is Copyright 1993 by Leslie M. Barstow III.
|
||||
It may be distributed freely, provided this manpage accompanies it.
|
||||
touch uses routines from the ORCA libraries, Copyright by ByteWorks, Inc.
|
Loading…
Reference in New Issue
Block a user