#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>
+#endif
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <time.h>
#include "cpmfs.h"
+#include "getopt_.h"
#ifdef USE_DMALLOC
#include <dmalloc.h>
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);
{
const char *msg;
char bmap[18*80];
- int secmap,pos,sys,directory;
+ int secmap,sys,directory;
+ int pos;
clear();
msg="Data map";
{
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));
}
}
- for (pos=0; pos<sizeof(bmap); ++pos)
+ for (pos=0; pos<(int)sizeof(bmap); ++pos)
{
move(2+pos%18,pos/18);
addch(bmap[pos]);
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)
{
const char *err;
struct cpmSuperBlock drive;
struct cpmInode root;
- const char *format=FORMAT;
+ const char *format;
int c,usage=0;
- unsigned long pos;
+ off_t pos;
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;
/* 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);
}
- cpmReadSuper(&drive,&root,format);
/*}}}*/
/* alloc sector buffers */ /*{{{*/
if ((buf=malloc(drive.secLength))==(char*)0 || (mapbuf=malloc(drive.secLength))==(char*)0)
{
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;
{
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;
{
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;