new
This commit is contained in:
parent
a09266b339
commit
2939db38f5
|
|
@ -0,0 +1,89 @@
|
||||||
|
/**************************************************************************
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
W E G A - Quelle (C) TU KMSt / ZFT/KEAW Abt. WAE - 1988
|
||||||
|
Programm: doscat.c
|
||||||
|
|
||||||
|
Bearbeiter : P. Hoge
|
||||||
|
Datum : 24.11.89
|
||||||
|
Version : 1.3
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
Kopieren von DOS-Dateien auf die Standardausgabe
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include "dos.h"
|
||||||
|
|
||||||
|
main(argc,argv)
|
||||||
|
register char **argv;
|
||||||
|
{
|
||||||
|
register char *arg0 = argv[0];
|
||||||
|
int conv = 1; /* Newlinekonvertierung */
|
||||||
|
register int status = 0,res;
|
||||||
|
char upath[LMAX],dpath[LMAX];
|
||||||
|
struct dosdisc dos;
|
||||||
|
struct dostat dstat;
|
||||||
|
|
||||||
|
argc--;
|
||||||
|
for (; argc > 0 && argv[1][0] == '-';argc--,argv++)
|
||||||
|
switch (argv[1][1]) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
conv--; /* keine Newlinekonv. */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr,"%s: falsche Option %c\n",arg0,argv[1][1]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (argc == 0) {
|
||||||
|
fprintf(stderr,"usage: doscat [-r] dosdev:filename [dosdev:filename] [...]\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
while (argc-- > 0) {
|
||||||
|
if (dosplit(*++argv,upath,dpath) < 0) {
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*dpath == '\0') {
|
||||||
|
strcpy(dpath, "/bin/cat ");
|
||||||
|
strcat(dpath, upath);
|
||||||
|
status = system(dpath);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (dosdev(upath,0,&dos) < 0) {
|
||||||
|
fprintf(stderr,"%s: Fehler in %s\n",arg0,upath);
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
res = dosopn(dpath,&dos,&dstat);
|
||||||
|
if (res == 0) {
|
||||||
|
fprintf(stderr,"%s: %s nicht gefunden\n",arg0,dpath);
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (res < 0) {
|
||||||
|
fprintf(stderr,"%s: %s - Lesefehler\n",arg0,upath);
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
res = dosout(&dstat,1,&dos,conv);
|
||||||
|
switch (res) {
|
||||||
|
case -1:
|
||||||
|
fprintf(stderr,"%s: %s - Lesefehler\n",arg0,upath);
|
||||||
|
status = 2;
|
||||||
|
break;
|
||||||
|
case -2:
|
||||||
|
fprintf(stderr,"%s: Fehler bei der Standardausgabe\n",arg0);
|
||||||
|
status = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,190 @@
|
||||||
|
/**************************************************************************
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
W E G A - Quelle (C) TU KMSt / ZFT/KEAW Abt. WAE - 1988
|
||||||
|
Programm: dosdir.c
|
||||||
|
|
||||||
|
Bearbeiter : P. Hoge
|
||||||
|
Datum : 24.11.89
|
||||||
|
Version : 1.3
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
Listet DCP-Dateien und -Verzeichnisse im DCP-Format auf
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include "dos.h"
|
||||||
|
|
||||||
|
main(argc,argv)
|
||||||
|
register char **argv;
|
||||||
|
{
|
||||||
|
register char *arg0 = argv[0];
|
||||||
|
register int status = 0,res;
|
||||||
|
int z=1,i,j,dcnt;
|
||||||
|
unsigned char upath[LMAX],dpath[LMAX];
|
||||||
|
char label[12];
|
||||||
|
struct dosdisc dos;
|
||||||
|
struct dostat dstat,estat;
|
||||||
|
long adr;
|
||||||
|
unsigned dnum,dosnxt(),nxt;
|
||||||
|
|
||||||
|
argc--;
|
||||||
|
if(argc == 0) {
|
||||||
|
fprintf(stderr,"usage: dosdir dosdev:[dirname] [dosdev:[dirname]] [...]\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
while (argc-- > 0) {
|
||||||
|
dcnt = 0;
|
||||||
|
label[0] = '\0';
|
||||||
|
if ((res=dosplit(*++argv,upath,dpath)) < 0) {
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (res == 2) {
|
||||||
|
strcpy(dpath, "/bin/ls ");
|
||||||
|
strcat(dpath, upath);
|
||||||
|
status = system(dpath);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (dosdev(upath,0,&dos) < 0) {
|
||||||
|
fprintf(stderr,"%s: Fehler in %s\n",arg0,upath);
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
adr = dos.maindir;
|
||||||
|
dnum = dos.dirnum;
|
||||||
|
lseek(dos.fd,adr,0);
|
||||||
|
|
||||||
|
nxt = dstat.first;
|
||||||
|
j = 1;
|
||||||
|
while (j++ <= dnum && (getde(dos.fd,&estat)) > 0)
|
||||||
|
if (estat.name[0] != 0xe5 && (estat.attr&VOLUME_LABEL) != 0) {
|
||||||
|
strcpy(label,estat.name);
|
||||||
|
}
|
||||||
|
if (*dpath != '\0') {
|
||||||
|
/* Es handelt sich nicht um das Stammverzeichnis */
|
||||||
|
res=dosopn(dpath,&dos,&dstat);
|
||||||
|
if (res == 0) {
|
||||||
|
fprintf(stderr,"%s: %s nicht gefunden\n",arg0,dpath);
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (res < 0) {
|
||||||
|
fprintf(stderr,"%s: %s - Lesefehler\n",arg0,upath);
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (dstat.mode == _FILE) {
|
||||||
|
pkopf(upath,dpath,label);
|
||||||
|
pdir(&dstat);
|
||||||
|
bytefree(1,&dos);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (dstat.mode == _SDIR) {
|
||||||
|
pkopf(upath,dpath,label);
|
||||||
|
adr = DOSADR(dstat.first,dos.clustsiz)+dos.data;
|
||||||
|
/* Bestimmen Anzahl von Verzeichniseintraegen */
|
||||||
|
nxt = dstat.first;
|
||||||
|
while((nxt=dosnxt(dos.fd,nxt,dos.fat1,dos.fatlen)) > 0)
|
||||||
|
z++;
|
||||||
|
dnum = dos.clustsiz/32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { /* Ausgabe des Stammverzeichnisses */
|
||||||
|
pkopf(upath, '\0', label);
|
||||||
|
adr = dos.maindir;
|
||||||
|
dnum = dos.dirnum;
|
||||||
|
}
|
||||||
|
lseek(dos.fd,adr,0);
|
||||||
|
|
||||||
|
/* Ausgabe aller gueltigen Eintraege */
|
||||||
|
nxt = dstat.first;
|
||||||
|
for (i=0; i<z; i++) {
|
||||||
|
j = 1;
|
||||||
|
while (j++ <= dnum && (res=getde(dos.fd,&estat)) > 0)
|
||||||
|
if (estat.name[0] != 0xe5 && (estat.attr&VOLUME_LABEL) == 0) {
|
||||||
|
pdir(&estat);
|
||||||
|
dcnt++;
|
||||||
|
}
|
||||||
|
if ((nxt=dosnxt(dos.fd,nxt,dos.fat1,dos.fatlen)) < 1)
|
||||||
|
break;
|
||||||
|
/* Naechsten Cluster bereitstellen */
|
||||||
|
adr = DOSADR(nxt,dos.clustsiz)+dos.data;
|
||||||
|
lseek(dos.fd,adr,0);
|
||||||
|
}
|
||||||
|
bytefree(dcnt,&dos);
|
||||||
|
|
||||||
|
} /* while */
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
pkopf(lw,dpath, label)
|
||||||
|
char *lw,*dpath, *label;
|
||||||
|
{
|
||||||
|
printf("\nVolume in %s hat Label: %s\n",lw, label);
|
||||||
|
if (dpath != '\0')
|
||||||
|
printf("Verzeichnis von %s:/%s\n\n",lw,dpath);
|
||||||
|
else
|
||||||
|
printf("Verzeichnis von %s:/\n\n",lw);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pdir(pstat)
|
||||||
|
register struct dostat *pstat;
|
||||||
|
{
|
||||||
|
if (pstat->mode == _SDIR) {
|
||||||
|
printf("%8.8s%3.3s ",pstat->name, &pstat->name[8]);
|
||||||
|
printf(" <DIR> ");
|
||||||
|
} else {
|
||||||
|
printf("%8.8s %3.3s",pstat->name, &pstat->name[8]);
|
||||||
|
printf("%9ld ",pstat->dim);
|
||||||
|
}
|
||||||
|
printf("%2d-%02d-%2d ",pstat->date.month,pstat->date.day,pstat->date.year-1900);
|
||||||
|
printf("%2d:%2d\n",pstat->time.hour,pstat->time.min);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* bytefree
|
||||||
|
* Summiert alle FAT-Eintraege groesser Null
|
||||||
|
* und gibt die so ermittelte Anzahl freier
|
||||||
|
* Byte auf dem Bildschirm aus
|
||||||
|
*/
|
||||||
|
bytefree(dcnt,dp)
|
||||||
|
int dcnt; /* Anz. Dateien im Verzeichnis */
|
||||||
|
register struct dosdisc *dp;
|
||||||
|
{
|
||||||
|
register FILE *fp;
|
||||||
|
register nclust, used=0;
|
||||||
|
unsigned char n[3];
|
||||||
|
long free;
|
||||||
|
|
||||||
|
fp = fdopen(dp->fd, "r");
|
||||||
|
nclust = dp->nclust;
|
||||||
|
|
||||||
|
if (dp->fatlen == 12) {
|
||||||
|
fseek(fp,dp->fat1+3,0);
|
||||||
|
while ((nclust -=2) > 0) {
|
||||||
|
if (fread(n, sizeof(*n),3,fp) != 3)
|
||||||
|
return;
|
||||||
|
if (n[0] || (n[1]&0x0f))
|
||||||
|
used++;
|
||||||
|
if ((n[1]&0xf0) || n[2])
|
||||||
|
used++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fseek(fp,dp->fat1+4,0);
|
||||||
|
while (nclust--) {
|
||||||
|
if (fread(n, sizeof(*n),2,fp) != 2)
|
||||||
|
return;
|
||||||
|
if (n[0] || n[1])
|
||||||
|
used++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free = (long)(dp->nclust-used) * dp->clustsiz;
|
||||||
|
printf(" %d Datei(en) %ld Bytes frei\n",dcnt, free);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,253 @@
|
||||||
|
/**************************************************************************
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
W E G A - Quelle (C) ZFT/KEAW Abt. Basissoftware - 1989
|
||||||
|
Programm: dosformat.c
|
||||||
|
|
||||||
|
Bearbeiter : P. Hoge
|
||||||
|
Datum : 6.1.89
|
||||||
|
Version : 1.1
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
Formatieren von DCP-Disketten
|
||||||
|
Syntax: dosformat [[-96ds15|96ds9|48ds9] dosdev]
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include "dos.h"
|
||||||
|
|
||||||
|
char *arg0;
|
||||||
|
int fd;
|
||||||
|
char upath[LMAX],dpath[LMAX];
|
||||||
|
char buf[512];
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------
|
||||||
|
device format sectors sides cluster blocks dirs FAT-secs
|
||||||
|
------------------------------------------------------------------
|
||||||
|
48ss8 0xfe 8 1 1 320 64 1
|
||||||
|
48ss9 0xfc 9 1 1 360 64 1
|
||||||
|
48ds8 0xff 8 2 2 640 112 2
|
||||||
|
48ds9 0xfd 9 2 2 720 112 2
|
||||||
|
96ds9 0xf9 9 2 2 1440 112 3
|
||||||
|
96ds15 0xf9 15 2 1 2400 224 7
|
||||||
|
-----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
char f48ss9[31] = {
|
||||||
|
0xeb, 0x34, 0x90, /* JMP BOOT */
|
||||||
|
'W','E','G','A','-','D','O','S',/* System id */
|
||||||
|
00, 2, /* bytes per sector */
|
||||||
|
2, /* sectors per cluster */
|
||||||
|
01, 0, /* reserved sectors at beginning */
|
||||||
|
2, /* fat-copies */
|
||||||
|
64, 0, /* directory entries */
|
||||||
|
360%256, 360/256, /* number of all sectors */
|
||||||
|
0xfc, /* format id */
|
||||||
|
2,0, /* sectors per fat */
|
||||||
|
9,0, /* sectors per track */
|
||||||
|
1,0, /* number of sides */
|
||||||
|
0,0, /* special reserved sectors */
|
||||||
|
0xf0, /* 1. byte fat */
|
||||||
|
};
|
||||||
|
char f48ds9[31] = {
|
||||||
|
0xeb, 0x34, 0x90, /* JMP BOOT */
|
||||||
|
'W','E','G','A','-','D','O','S',/* System id */
|
||||||
|
00, 2, /* bytes per sector */
|
||||||
|
2, /* sectors per cluster */
|
||||||
|
01, 0, /* reserved sectors at beginning */
|
||||||
|
2, /* fat-copies */
|
||||||
|
112, 0, /* directory entries */
|
||||||
|
720%256, 720/256, /* number of all sectors */
|
||||||
|
0xfd, /* format id */
|
||||||
|
2,0, /* sectors per fat */
|
||||||
|
9,0, /* sectors per track */
|
||||||
|
2,0, /* number of sides */
|
||||||
|
0,0, /* special reserved sectors */
|
||||||
|
0xf9 /* 1. byte fat */
|
||||||
|
};
|
||||||
|
char f96ds9[31] = {
|
||||||
|
0xeb, 0x34, 0x90, /* JMP BOOT */
|
||||||
|
'W','E','G','A','-','D','O','S',/* System id */
|
||||||
|
00, 2, /* bytes per sector */
|
||||||
|
2, /* sectors per cluster */
|
||||||
|
01, 0, /* reserved sectors at beginning */
|
||||||
|
2, /* fat-copies */
|
||||||
|
112, 0, /* directory entries */
|
||||||
|
1440%256, 1440/256, /* number of all sectors */
|
||||||
|
0xf9, /* format id */
|
||||||
|
3,0, /* sectors per fat */
|
||||||
|
9,0, /* sectors per track */
|
||||||
|
2,0, /* number of sides */
|
||||||
|
0,0, /* special reserved sectors */
|
||||||
|
0xf9 /* 1. byte fat */
|
||||||
|
};
|
||||||
|
char f96ds15[31] = {
|
||||||
|
0xeb, 0x34, 0x90, /* JMP BOOT */
|
||||||
|
'W','E','G','A','-','D','O','S',/* System id */
|
||||||
|
00, 2, /* bytes per sector */
|
||||||
|
1, /* sectors per cluster */
|
||||||
|
01, 0, /* reserved sectors at beginning */
|
||||||
|
2, /* fat-copies */
|
||||||
|
224, 0, /* directory entries */
|
||||||
|
2400%256, 2400/256, /* number of all sectors */
|
||||||
|
0xf9, /* format id */
|
||||||
|
7,0, /* sectors per fat */
|
||||||
|
15,0, /* sectors per track */
|
||||||
|
2,0, /* number of sides */
|
||||||
|
0,0, /* special reserved sectors */
|
||||||
|
0xf9 /* 1. byte fat */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
main(argc,argv)
|
||||||
|
register char **argv;
|
||||||
|
{
|
||||||
|
register char *fdname;
|
||||||
|
register char *fdtyp;
|
||||||
|
int dev = 0;
|
||||||
|
struct stat mstat;
|
||||||
|
char *pboot;
|
||||||
|
|
||||||
|
arg0 = argv[0];
|
||||||
|
switch(argc) {
|
||||||
|
case 1:
|
||||||
|
fdtyp = "-96ds9";
|
||||||
|
fdname = "/dev/rfd196ds9";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
fdtyp = "-96ds9";
|
||||||
|
fdname = argv[1];
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
fdtyp = argv[1];
|
||||||
|
fdname = argv[2];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error:
|
||||||
|
fprintf(stderr,"usage: dosformat [[-96ds15|-96ds9|-48ds9] dosdev]\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (fdtyp[0] != '-' || fdname[0] == '-')
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (dosplit(fdname,upath,dpath) < 0)
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
if (stat(upath, &mstat) == 0) {
|
||||||
|
if (mstat.st_mode & (S_IFBLK | S_IFCHR)) {
|
||||||
|
dev++; /* echte Floppy */
|
||||||
|
fdtyp = upath; /* Option ignorieren */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cmp(upath, "/dev/") && dev == 0)
|
||||||
|
goto error;
|
||||||
|
if (cmp(fdtyp, "48ss9") != 0 && dev)
|
||||||
|
pboot = f48ss9;
|
||||||
|
else if (cmp(fdtyp, "48ds9") != 0)
|
||||||
|
pboot = f48ds9;
|
||||||
|
else if (cmp(fdtyp, "96ds9") != 0)
|
||||||
|
pboot = f96ds9;
|
||||||
|
else if (cmp(fdtyp, "96ds15") != 0)
|
||||||
|
pboot = f96ds15;
|
||||||
|
else if (dev && cmp(fdtyp, "ss") == 0 && cmp(fdtyp, "ds") == 0) {
|
||||||
|
pboot = f96ds9;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "%s: falsches DCP-Format\n", arg0);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dev) {
|
||||||
|
strcpy(buf, "format "); /* physisch Formatieren */
|
||||||
|
strcat(buf, upath);
|
||||||
|
if (system(buf))
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((fd = open(upath, O_RDWR|O_CREAT|O_TRUNC, 0664)) < 0) {
|
||||||
|
fprintf(stderr, "%s: kann %s nicht oeffnen\n", arg0, upath);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
putdata(pboot);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
putsect()
|
||||||
|
{
|
||||||
|
if (write(fd, buf, 512) != 512) {
|
||||||
|
fprintf(stderr, "%s: Schreibfehler in %s\n", arg0, upath);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
putdata(p)
|
||||||
|
register char *p;
|
||||||
|
{
|
||||||
|
register i, j;
|
||||||
|
|
||||||
|
clear_buf(); /* write boot sector */
|
||||||
|
for (i = 0; i < 30; i++)
|
||||||
|
buf[i] = p[i];
|
||||||
|
buf[0x2f] = p[24]; /* sectors/track */
|
||||||
|
buf[0x1fe] = 0x55;
|
||||||
|
buf[0x1ff] = 0xaa;
|
||||||
|
putsect();
|
||||||
|
/* write fat's */
|
||||||
|
i = p[16]; /* number of fats */
|
||||||
|
while (i--) {
|
||||||
|
clear_buf();
|
||||||
|
buf[0] = p[30]; /* 1. byte fat */
|
||||||
|
buf[1] = 0xff;
|
||||||
|
buf[2] = 0xff;
|
||||||
|
j = p[22]; /* number of fat sectors */
|
||||||
|
while (j--) {
|
||||||
|
putsect();
|
||||||
|
clear_buf();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* write directory */
|
||||||
|
i = ((p[17]&0x00ff) * 32)/512; /* number of directory sectors */
|
||||||
|
while (i--)
|
||||||
|
putsect();
|
||||||
|
}
|
||||||
|
|
||||||
|
clear_buf()
|
||||||
|
{
|
||||||
|
register i = sizeof(buf);
|
||||||
|
register char *s = buf;
|
||||||
|
|
||||||
|
while (i--)
|
||||||
|
*s++ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmp(s1, s2)
|
||||||
|
register char *s1, *s2;
|
||||||
|
{
|
||||||
|
register char *s3;
|
||||||
|
|
||||||
|
s3 = s2;
|
||||||
|
while (1) {
|
||||||
|
if (*s1 == 0)
|
||||||
|
return(0);
|
||||||
|
if (*s1 != *s2) {
|
||||||
|
s1++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
loop:
|
||||||
|
if (*s2 == 0)
|
||||||
|
return(1);
|
||||||
|
if (*s1 != *s2) {
|
||||||
|
s2 = s3;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
s1++;
|
||||||
|
s2++;
|
||||||
|
goto loop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
/**************************************************************************
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
W E G A - Quelle (C) TU KMSt / ZFT/KEAW Abt. WAE - 1988
|
||||||
|
Programm: dosls.c
|
||||||
|
|
||||||
|
Bearbeiter : P. Hoge
|
||||||
|
Datum : 24.11.89
|
||||||
|
Version : 1.3
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
Listet DCP-Dateien und -Verzeichnisse im WEGA-Format auf
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include "dos.h"
|
||||||
|
|
||||||
|
main(argc,argv)
|
||||||
|
register char **argv;
|
||||||
|
{
|
||||||
|
register char *arg0 = argv[0];
|
||||||
|
register int status = 0,res;
|
||||||
|
int z=1,i,j;
|
||||||
|
unsigned char upath[LMAX],dpath[LMAX];
|
||||||
|
struct dosdisc dos;
|
||||||
|
struct dostat dstat;
|
||||||
|
long adr;
|
||||||
|
unsigned dnum,dosnxt(),nxt;
|
||||||
|
|
||||||
|
argc--;
|
||||||
|
if(argc == 0) {
|
||||||
|
fprintf(stderr,"usage: dosls dosdev:[dirname] [dosdev:[dirname]] [...]\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
while (argc-- > 0) {
|
||||||
|
if ((res=dosplit(*++argv,upath,dpath)) < 0) {
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (res == 2) {
|
||||||
|
strcpy(dpath, "/bin/ls -l ");
|
||||||
|
strcat(dpath, upath);
|
||||||
|
status = system(dpath);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (dosdev(upath,0,&dos) < 0) {
|
||||||
|
fprintf(stderr,"%s: Fehler in %s\n",arg0,upath);
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*dpath != '\0') {
|
||||||
|
/* Es handelt sich nicht um das Stammverzeichnis */
|
||||||
|
res = dosopn(dpath,&dos,&dstat);
|
||||||
|
if (res == 0) {
|
||||||
|
fprintf(stderr,"%s: %s nicht gefunden\n",arg0,dpath);
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (res < 0) {
|
||||||
|
fprintf(stderr,"%s: %s - Lesefehler\n",arg0,upath);
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (dstat.mode == _FILE) {
|
||||||
|
pls(&dstat);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (dstat.mode == _SDIR) {
|
||||||
|
printf("\n%s:/%s\n",upath,dpath);
|
||||||
|
adr = DOSADR(dstat.first,dos.clustsiz)+dos.data;
|
||||||
|
/* Bestimmen Anzahl von Verzeichniseintraegen */
|
||||||
|
nxt = dstat.first;
|
||||||
|
while ((nxt=dosnxt(dos.fd,nxt,dos.fat1,dos.fatlen)) > 0)
|
||||||
|
z++;
|
||||||
|
dnum = dos.clustsiz/32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { /* Ausgabe des Stammverzeichnisses */
|
||||||
|
printf("\n%s:/\n",upath);
|
||||||
|
adr = dos.maindir;
|
||||||
|
dnum = dos.dirnum;
|
||||||
|
}
|
||||||
|
lseek(dos.fd,adr,0);
|
||||||
|
/* Ausgabe aller gueltigen Eintraege */
|
||||||
|
nxt = dstat.first;
|
||||||
|
for (i=0;i<z;i++) {
|
||||||
|
j = 1;
|
||||||
|
while(j++ <= dnum && (getde(dos.fd,&dstat)) > 0)
|
||||||
|
if (dstat.name[0] != 0xe5)
|
||||||
|
pls(&dstat);
|
||||||
|
if ((nxt=dosnxt(dos.fd,nxt,dos.fat1,dos.fatlen)) < 1)
|
||||||
|
break;
|
||||||
|
else { /* Naechsten Cluster bereitstellen */
|
||||||
|
adr = DOSADR(nxt,dos.clustsiz)+dos.data;
|
||||||
|
lseek(dos.fd,adr,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* while */
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
pls(pstat)
|
||||||
|
register struct dostat *pstat;
|
||||||
|
{
|
||||||
|
if (pstat->mode == _SDIR)
|
||||||
|
printf("d");
|
||||||
|
else
|
||||||
|
printf("-");
|
||||||
|
if (pstat->attr & READ_ONLY)
|
||||||
|
printf("r--r--r-");
|
||||||
|
else
|
||||||
|
printf("rw-rw-rw");
|
||||||
|
printf("- 1 dpath ");
|
||||||
|
printf("%6ld ",pstat->dim);
|
||||||
|
printf("%2d %2d %2d:%2d ",pstat->date.month,pstat->date.day,pstat->time.hour,pstat->time.min);
|
||||||
|
printf("%8.8s %3.3s\n",pstat->name, &pstat->name[8]);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,312 @@
|
||||||
|
/**************************************************************************
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
W E G A - Quelle (C) TU KMSt / ZFT/KEAW Abt. WAE - 1988
|
||||||
|
Programm: dosmkdir.c
|
||||||
|
|
||||||
|
Bearbeiter : P. Hoge
|
||||||
|
Datum : 24.1.89
|
||||||
|
Version : 1.3
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
Erzeugen von DCP-Verzeichnissen
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include "dos.h"
|
||||||
|
|
||||||
|
main(argc,argv)
|
||||||
|
register char **argv;
|
||||||
|
{
|
||||||
|
register char *arg0 = argv[0];
|
||||||
|
register int status = 0,res;
|
||||||
|
char upath[LMAX],dpath[LMAX];
|
||||||
|
struct dosdisc dos;
|
||||||
|
struct dostat dstat;
|
||||||
|
|
||||||
|
argc--;
|
||||||
|
if (argc == 0) {
|
||||||
|
fprintf(stderr,"usage: dosmkdir dosdev:dirname\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
while (argc-- > 0) {
|
||||||
|
if ((res=dosplit(*++argv,upath,dpath)) < 0) {
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (res == 2) {
|
||||||
|
strcpy(dpath, "/bin/mkdir ");
|
||||||
|
strcat(dpath, upath);
|
||||||
|
status = system(dpath);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*dpath == '\0') {
|
||||||
|
fprintf(stderr,"%s: kein DCP-Pfad angegeben\n",arg0);
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (dosdev(upath,2,&dos) < 0) {
|
||||||
|
fprintf(stderr,"%s: Fehler in %s\n",arg0,upath);
|
||||||
|
status = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
res = msubdir(dpath,&dos);
|
||||||
|
switch (res) {
|
||||||
|
case 0:
|
||||||
|
fprintf(stderr,"%s: uebergeordnetes Verzeichnis fehlt\n",arg0);
|
||||||
|
status = 2;
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
fprintf(stderr,"%s: %s - existiert bereits\n",arg0,dpath);
|
||||||
|
status = 2;
|
||||||
|
break;
|
||||||
|
case -2:
|
||||||
|
fprintf(stderr,"%s: %s - Schreibfehler\n",arg0,upath);
|
||||||
|
status = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* msubdir
|
||||||
|
* Traegt das Unterverzeichnis subdir
|
||||||
|
* auf dem Datentraeger dp ein.
|
||||||
|
* Liefert 0 falls das uebergeordnete
|
||||||
|
* Verzeichnis nicht existiert ,
|
||||||
|
* -1 falls subdir bereits existiert und
|
||||||
|
* -2 bei Schreibfehler
|
||||||
|
*/
|
||||||
|
msubdir(subdir,dp)
|
||||||
|
register char *subdir;
|
||||||
|
register struct dosdisc *dp;
|
||||||
|
{
|
||||||
|
struct dostat fnrec,dirrec,pkt,dpkt;
|
||||||
|
int res,z=1,i,j,io=1;
|
||||||
|
char *p,*file;
|
||||||
|
char *strchr();
|
||||||
|
long adr,depos,time(),zeit;
|
||||||
|
unsigned dnum,nxt,dosnxt(),dpktfirst;
|
||||||
|
unsigned char c,buf[512];
|
||||||
|
struct tm *sttime,*localtime();
|
||||||
|
register int free;
|
||||||
|
int dmax,dcnt=0;
|
||||||
|
|
||||||
|
if ((res=dosopn(subdir,dp,&fnrec)) < 0)
|
||||||
|
return(-2);
|
||||||
|
if (res > 0)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
file = subdir;
|
||||||
|
while ((p=strchr(file,'/')) != 0)
|
||||||
|
file = ++p;
|
||||||
|
|
||||||
|
subdir[strlen(subdir)-strlen(file)-1] = '\0';
|
||||||
|
|
||||||
|
if (file == subdir) {
|
||||||
|
dmax = dnum = dp->dirnum;
|
||||||
|
adr = dp->maindir;
|
||||||
|
dpktfirst = nxt = 0;
|
||||||
|
}
|
||||||
|
else { /* Das uebergeordnete Verzeichnis ist nicht das
|
||||||
|
* Stammverzeichnis !
|
||||||
|
*/
|
||||||
|
if ((res=dosopn(subdir,dp,&dirrec)) < 1)
|
||||||
|
return(res);
|
||||||
|
if (dirrec.mode != _SDIR)
|
||||||
|
return(0);
|
||||||
|
dpktfirst = dirrec.first;
|
||||||
|
adr = DOSADR(dirrec.first,dp->clustsiz)+dp->data;
|
||||||
|
|
||||||
|
/* Bestimmen der Anzahl von Verzeichniseintraegen */
|
||||||
|
nxt = dirrec.first;
|
||||||
|
while ((nxt=dosnxt(dp->fd,nxt,dp->fat1,dp->fatlen)) > 0)
|
||||||
|
z++;
|
||||||
|
dnum = dp->clustsiz/32;
|
||||||
|
dmax = z*dnum;
|
||||||
|
nxt = dirrec.first;
|
||||||
|
}
|
||||||
|
lseek(dp->fd,adr,0);
|
||||||
|
/* Suche des ersten freien Eintrages */
|
||||||
|
for (i=0;i<z;i++) {
|
||||||
|
j = 1;
|
||||||
|
while (j++ <= dnum && (res=getde(dp->fd,&fnrec)) > 0) {
|
||||||
|
dcnt++;
|
||||||
|
if (fnrec.name[0] == 0xe5) {
|
||||||
|
i = z;
|
||||||
|
depos = lseek(dp->fd,(long)-32,1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res == 0) {
|
||||||
|
depos = lseek(dp->fd,(long)-32,1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nxt != 0) {
|
||||||
|
if ((nxt=dosnxt(dp->fd,nxt,dp->fat1,dp->fatlen)) < 1)
|
||||||
|
break;
|
||||||
|
else { /* Naechsten Cluster lesen */
|
||||||
|
adr = DOSADR(nxt,dp->clustsiz)+dp->data;
|
||||||
|
lseek(dp->fd,adr,0);
|
||||||
|
dirrec.first = nxt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res < 0)
|
||||||
|
return(-2);
|
||||||
|
if (subdir == file && dcnt >= dmax)
|
||||||
|
return(-2); /* Stammverzeichnis voll */
|
||||||
|
if (dcnt >= dmax) { /* Verzeichniscluster voll */
|
||||||
|
if ((free=fatfree(dp)) < 0)
|
||||||
|
return(-2);
|
||||||
|
if (fatput(dirrec.first,free,dp) < 0)
|
||||||
|
return(-2);
|
||||||
|
if (fatput(free,0xffff,dp) < 0)
|
||||||
|
return(-2);
|
||||||
|
adr = DOSADR(free,dp->clustsiz)+dp->data;
|
||||||
|
for (i=0;i<512;i++)
|
||||||
|
buf[i] = 0x00;
|
||||||
|
lseek(dp->fd,adr,0);
|
||||||
|
z = dp->clustsiz/512;
|
||||||
|
for (i=0;i<z;i++)
|
||||||
|
if (write(dp->fd,buf,512) != 512)
|
||||||
|
return(-2);
|
||||||
|
/* depos zeigt auf den zu belegenden Eintrag */
|
||||||
|
depos = lseek(dp->fd,adr,0);
|
||||||
|
}
|
||||||
|
/* fnrec wird mit Werten von subdir belegt */
|
||||||
|
if ((p=strchr(file,'.')) != 0) {
|
||||||
|
p++;
|
||||||
|
file[strlen(file)-strlen(p)-1] = '\0';
|
||||||
|
for (i=0;i<8;i++)
|
||||||
|
if (i >= strlen(file))
|
||||||
|
fnrec.name[i] = 0x20;
|
||||||
|
else
|
||||||
|
fnrec.name[i] = file[i];
|
||||||
|
for (i=8;i<11;i++)
|
||||||
|
if (i-7 > strlen(p))
|
||||||
|
fnrec.name[i] = 0x20;
|
||||||
|
else
|
||||||
|
fnrec.name[i] = p[i-8];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (i=0;i<11;i++)
|
||||||
|
if (i >= strlen(file) || i > 7)
|
||||||
|
fnrec.name[i] = 0x20;
|
||||||
|
else
|
||||||
|
fnrec.name[i] = file[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
fnrec.mode = _SDIR;
|
||||||
|
fnrec.flag = RW;
|
||||||
|
zeit = time(0);
|
||||||
|
sttime = localtime(&zeit);
|
||||||
|
|
||||||
|
fnrec.time.sec = sttime->tm_sec;
|
||||||
|
fnrec.time.min = sttime->tm_min;
|
||||||
|
fnrec.time.hour = sttime->tm_hour;
|
||||||
|
|
||||||
|
fnrec.date.day = sttime->tm_mday;
|
||||||
|
fnrec.date.month = sttime->tm_mon+1;
|
||||||
|
fnrec.date.year = sttime->tm_year;
|
||||||
|
|
||||||
|
if ((free = fatfree(dp)) < 0)
|
||||||
|
return(-2);
|
||||||
|
fnrec.first = free;
|
||||||
|
fatput(free,0xffff,dp);
|
||||||
|
fnrec.dim = 0;
|
||||||
|
|
||||||
|
/* Uebernehmen der Eintraege . und .. */
|
||||||
|
adr = DOSADR(free,dp->clustsiz)+dp->data;
|
||||||
|
for (i=0;i<11;i++)
|
||||||
|
if (i == 0)
|
||||||
|
pkt.name[i] = 0x2e;
|
||||||
|
else
|
||||||
|
pkt.name[i] = 0x20;
|
||||||
|
pkt.name[11] = '\0';
|
||||||
|
pkt.mode = _SDIR;
|
||||||
|
pkt.flag = RW;
|
||||||
|
dpkt.time.sec = pkt.time.sec = fnrec.time.sec;
|
||||||
|
dpkt.time.min = pkt.time.min = fnrec.time.min;
|
||||||
|
dpkt.time.hour = pkt.time.hour = fnrec.time.hour;
|
||||||
|
dpkt.date.day = pkt.date.day = fnrec.date.day;
|
||||||
|
dpkt.date.month = pkt.date.month = fnrec.date.month;
|
||||||
|
dpkt.date.year = pkt.date.year = pkt.date.year;
|
||||||
|
pkt.dim = 0;
|
||||||
|
pkt.first = fnrec.first;
|
||||||
|
|
||||||
|
dpkt.name[0] = 0x2e;
|
||||||
|
dpkt.name[1] = 0x2e;
|
||||||
|
for (i=2;i<11;i++)
|
||||||
|
dpkt.name[i] = 0x20;
|
||||||
|
dpkt.name[11] = '\0';
|
||||||
|
dpkt.mode = _SDIR;
|
||||||
|
dpkt.flag = RW;
|
||||||
|
dpkt.dim = 0;
|
||||||
|
dpkt.first = dpktfirst;
|
||||||
|
|
||||||
|
lseek(dp->fd,adr,0);
|
||||||
|
for (i=0;i<512;i++)
|
||||||
|
buf[i] = 0x00;
|
||||||
|
z = dp->clustsiz/512;
|
||||||
|
for (i=0;i<z;i++)
|
||||||
|
if (write(dp->fd,buf,512) != 512)
|
||||||
|
return(-2);
|
||||||
|
|
||||||
|
lseek(dp->fd,adr,0);
|
||||||
|
if (putdir(&pkt,dp) < 0)
|
||||||
|
io--;
|
||||||
|
if (io)
|
||||||
|
if (putdir(&dpkt,dp) < 0)
|
||||||
|
io--;
|
||||||
|
if (!io) {
|
||||||
|
fatdel(&fnrec,dp);
|
||||||
|
return(-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Schreiben des Verzeichniseintrages subdir */
|
||||||
|
lseek(dp->fd,depos,0);
|
||||||
|
if (putdir(&fnrec,dp) < 0)
|
||||||
|
return(-2);
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
putdir(stp,dp)
|
||||||
|
register struct dostat *stp;
|
||||||
|
register struct dosdisc *dp;
|
||||||
|
{
|
||||||
|
register int res,i;
|
||||||
|
unsigned char attrib=0x10,*h,buf[32];
|
||||||
|
unsigned tv;
|
||||||
|
|
||||||
|
for (i=0;i<11;i++)
|
||||||
|
buf[i] = stp->name[i];
|
||||||
|
buf[11] = attrib;
|
||||||
|
for (i=12;i<22;i++)
|
||||||
|
buf[i] = '\0';
|
||||||
|
|
||||||
|
tv = stp->time.hour*2045 + stp->time.min*32 + stp->time.sec/2;
|
||||||
|
buf[22] = tv % 256;
|
||||||
|
buf[23] = tv / 256;
|
||||||
|
|
||||||
|
tv = (stp->date.year-80)*512 + stp->date.month*32 + stp->date.day;
|
||||||
|
buf[24] = tv % 256;
|
||||||
|
buf[25] = tv / 256;
|
||||||
|
buf[26] = stp->first % 256;
|
||||||
|
buf[27] = stp->first / 256;
|
||||||
|
buf[28] = stp->dim % 256;
|
||||||
|
buf[29] = (stp->dim % 65536) / 256;
|
||||||
|
buf[30] = (stp->dim % 16777216) / 65536;
|
||||||
|
buf[31] = (stp->dim / 16777216);
|
||||||
|
|
||||||
|
if (write(dp->fd,buf,32) != 32)
|
||||||
|
return(-2);
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue