projects
/
debian
/
cpmtools
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix up diskdefs target directory
[debian/cpmtools]
/
fsed.cpm.c
diff --git
a/fsed.cpm.c
b/fsed.cpm.c
index b717bfffc6e8be055151371c8ba68515cbe05e2c..f120b77c4a364749a3cdc119469acd710576a24b 100644
(file)
--- a/
fsed.cpm.c
+++ b/
fsed.cpm.c
@@
-3,13
+3,23
@@
#include <assert.h>
#include <ctype.h>
#include <assert.h>
#include <ctype.h>
+#if NEED_NCURSES
+#if HAVE_NCURSES_NCURSES_H
+#include <ncurses/ncurses.h>
+#else
+#include <ncurses.h>
+#endif
+#else
#include <curses.h>
#include <curses.h>
+#endif
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <time.h>
#include "cpmfs.h"
#include "cpmfs.h"
+#include "getopt_.h"
#ifdef USE_DMALLOC
#include <dmalloc.h>
#ifdef USE_DMALLOC
#include <dmalloc.h>
@@
-25,7
+35,7
@@
static struct tm *cpmtime(char lday, char hday, char hour, char min) /*{{{*/
static struct tm tm;
unsigned long days=(lday&0xff)|((hday&0xff)<<8);
int d;
static struct tm tm;
unsigned long days=(lday&0xff)|((hday&0xff)<<8);
int d;
- int md[12]={31,0,31,30,31,30,31,31,30,31,30,31};
+
unsigned
int md[12]={31,0,31,30,31,30,31,31,30,31,30,31};
tm.tm_sec=0;
tm.tm_min=((min>>4)&0xf)*10+(min&0xf);
tm.tm_sec=0;
tm.tm_min=((min>>4)&0xf)*10+(min&0xf);
@@
-87,7
+97,8
@@
static void map(struct cpmSuperBlock *sb) /*{{{*/
{
const char *msg;
char bmap[18*80];
{
const char *msg;
char bmap[18*80];
- int secmap,pos,sys,directory;
+ int secmap,sys,directory;
+ int pos;
clear();
msg="Data map";
clear();
msg="Data map";
@@
-114,7
+125,7
@@
static void map(struct cpmSuperBlock *sb) /*{{{*/
{
for (i=0; i<16; ++i)
{
{
for (i=0; i<16; ++i)
{
-
unsigned
int sector;
+ int sector;
sector=mapbuf[entry*32+16+i]&0xff;
if (sb->size>=256) sector|=(((mapbuf[entry*32+16+ ++i]&0xff)<<8));
sector=mapbuf[entry*32+16+i]&0xff;
if (sb->size>=256) sector|=(((mapbuf[entry*32+16+ ++i]&0xff)<<8));
@@
-129,7
+140,7
@@
static void map(struct cpmSuperBlock *sb) /*{{{*/
}
}
}
}
- for (pos=0; pos<sizeof(bmap); ++pos)
+ for (pos=0; pos<
(int)
sizeof(bmap); ++pos)
{
move(2+pos%18,pos/18);
addch(bmap[pos]);
{
move(2+pos%18,pos/18);
addch(bmap[pos]);
@@
-143,7
+154,7
@@
static void map(struct cpmSuperBlock *sb) /*{{{*/
static void data(struct cpmSuperBlock *sb, const char *buf, unsigned long int pos) /*{{{*/
{
int offset=(pos%sb->secLength)&~0x7f;
static void data(struct cpmSuperBlock *sb, const char *buf, unsigned long int pos) /*{{{*/
{
int offset=(pos%sb->secLength)&~0x7f;
- int i;
+
unsigned
int i;
for (i=0; i<128; ++i)
{
for (i=0; i<128; ++i)
{
@@
-166,16
+177,17
@@
int main(int argc, char *argv[]) /*{{{*/
const char *err;
struct cpmSuperBlock drive;
struct cpmInode root;
const char *err;
struct cpmSuperBlock drive;
struct cpmInode root;
- const char *format
=FORMAT
;
+ const char *format;
int c,usage=0;
int c,usage=0;
-
unsigned long
pos;
+
off_t
pos;
chtype ch;
int reload;
char *buf;
/*}}}*/
/* parse options */ /*{{{*/
chtype ch;
int reload;
char *buf;
/*}}}*/
/* parse options */ /*{{{*/
- while ((c=getopt(argc,argv,"f:h?"))!=EOF) switch(c)
+ if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT;
+ while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c)
{
case 'f': format=optarg; break;
case 'T': devopts=optarg; break;
{
case 'f': format=optarg; break;
case 'T': devopts=optarg; break;
@@
-195,10
+207,14
@@
int main(int argc, char *argv[]) /*{{{*/
/* open image */ /*{{{*/
if ((err=Device_open(&drive.dev,image,O_RDONLY,devopts)))
{
/* open image */ /*{{{*/
if ((err=Device_open(&drive.dev,image,O_RDONLY,devopts)))
{
- fprintf(stderr,"%s: can not open %s (%s)\n",cmd,image,err);
+ fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err);
+ exit(1);
+ }
+ if (cpmReadSuper(&drive,&root,format)==-1)
+ {
+ fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo);
exit(1);
}
exit(1);
}
- cpmReadSuper(&drive,&root,format);
/*}}}*/
/* alloc sector buffers */ /*{{{*/
if ((buf=malloc(drive.secLength))==(char*)0 || (mapbuf=malloc(drive.secLength))==(char*)0)
/*}}}*/
/* alloc sector buffers */ /*{{{*/
if ((buf=malloc(drive.secLength))==(char*)0 || (mapbuf=malloc(drive.secLength))==(char*)0)
@@
-269,7
+285,7
@@
int main(int argc, char *argv[]) /*{{{*/
{
case 'F': /* next 16 byte */ /*{{{*/
{
{
case 'F': /* next 16 byte */ /*{{{*/
{
- if (pos+16<(drive.sectrk*drive.tracks*(
unsigned long
)drive.secLength))
+ if (pos+16<(drive.sectrk*drive.tracks*(
off_t
)drive.secLength))
{
if (pos/drive.secLength!=(pos+16)/drive.secLength) reload=1;
pos+=16;
{
if (pos/drive.secLength!=(pos+16)/drive.secLength) reload=1;
pos+=16;
@@
-620,7
+636,7
@@
int main(int argc, char *argv[]) /*{{{*/
{
case 'F': /* next entry */ /*{{{*/
{
{
case 'F': /* next entry */ /*{{{*/
{
- if (pos+32<(drive.sectrk*drive.tracks*(
unsigned long
)drive.secLength))
+ if (pos+32<(drive.sectrk*drive.tracks*(
off_t
)drive.secLength))
{
if (pos/drive.secLength!=(pos+32)/drive.secLength) reload=1;
pos+=32;
{
if (pos/drive.secLength!=(pos+32)/drive.secLength) reload=1;
pos+=32;
@@
-656,7
+672,7
@@
int main(int argc, char *argv[]) /*{{{*/
{
case 'n': /* next record */ /*{{{*/
{
{
case 'n': /* next record */ /*{{{*/
{
- if (pos+128<(drive.sectrk*drive.tracks*(
unsigned long
)drive.secLength))
+ if (pos+128<(drive.sectrk*drive.tracks*(
off_t
)drive.secLength))
{
if (pos/drive.secLength!=(pos+128)/drive.secLength) reload=1;
pos+=128;
{
if (pos/drive.secLength!=(pos+128)/drive.secLength) reload=1;
pos+=128;