+/* updateDsStamps -- set time in datestamper file */ /*{{{*/
+static void updateDsStamps(const struct cpmInode *ino, int extent)
+{
+ int yr;
+ struct tm *cpm_time;
+ struct dsDate *stamp;
+
+ if (!S_ISREG(ino->mode)) return;
+ if ( !(ino->sb->type&CPMFS_DS_DATES) ) return;
+
+#ifdef CPMFS_DEBUG
+ fprintf(stderr,"CPMFS: updating ds stamps for inode %d (%d)\n",extent,extent&3);
+#endif
+
+ /* Get datestamp struct */
+ stamp = ino->sb->ds+extent;
+
+ unix2ds_time( ino->mtime, &stamp->modify );
+ unix2ds_time( ino->ctime, &stamp->create );
+ unix2ds_time( ino->atime, &stamp->access );
+
+ ino->sb->dirtyDs = 1;
+}
+/*}}}*/
+/* readTimeStamps -- read CP/M time stamp */ /*{{{*/
+static int readTimeStamps(struct cpmInode *i, int lowestExt)
+{
+ /* variables */ /*{{{*/
+ struct PhysDirectoryEntry *date;
+ int u_days=0,u_hour=0,u_min=0;
+ int ca_days=0,ca_hour=0,ca_min=0;
+ int protectMode=0;
+ /*}}}*/
+
+ if ( (i->sb->type&CPMFS_CPM3_DATES) && (date=i->sb->dir+(lowestExt|3))->status==0x21 )
+ {
+ switch (lowestExt&3)
+ {
+ case 0: /* first entry of the four */ /*{{{*/
+ {
+ ca_days=((unsigned char)date->name[0])+(((unsigned char)date->name[1])<<8);
+ ca_hour=(unsigned char)date->name[2];
+ ca_min=(unsigned char)date->name[3];
+ u_days=((unsigned char)date->name[4])+(((unsigned char)date->name[5])<<8);
+ u_hour=(unsigned char)date->name[6];
+ u_min=(unsigned char)date->name[7];
+ protectMode=(unsigned char)date->ext[0];
+ break;
+ }
+ /*}}}*/
+ case 1: /* second entry */ /*{{{*/
+ {
+ ca_days=((unsigned char)date->ext[2])+(((unsigned char)date->extnol)<<8);
+ ca_hour=(unsigned char)date->lrc;
+ ca_min=(unsigned char)date->extnoh;
+ u_days=((unsigned char)date->blkcnt)+(((unsigned char)date->pointers[0])<<8);
+ u_hour=(unsigned char)date->pointers[1];
+ u_min=(unsigned char)date->pointers[2];
+ protectMode=(unsigned char)date->pointers[3];
+ break;
+ }
+ /*}}}*/
+ case 2: /* third one */ /*{{{*/
+ {
+ ca_days=((unsigned char)date->pointers[5])+(((unsigned char)date->pointers[6])<<8);
+ ca_hour=(unsigned char)date->pointers[7];
+ ca_min=(unsigned char)date->pointers[8];
+ u_days=((unsigned char)date->pointers[9])+(((unsigned char)date->pointers[10])<<8);
+ u_hour=(unsigned char)date->pointers[11];
+ u_min=(unsigned char)date->pointers[12];
+ protectMode=(unsigned char)date->pointers[13];
+ break;
+ }
+ /*}}}*/
+ }
+ if (i->sb->cnotatime)
+ {
+ i->ctime=cpm2unix_time(ca_days,ca_hour,ca_min);
+ i->atime=0;
+ }
+ else
+ {
+ i->ctime=0;
+ i->atime=cpm2unix_time(ca_days,ca_hour,ca_min);
+ }
+ i->mtime=cpm2unix_time(u_days,u_hour,u_min);
+ }
+ else
+ {
+ i->atime=i->mtime=i->ctime=0;
+ protectMode=0;
+ }
+
+ return protectMode;
+}
+/*}}}*/
+/* readDsStamps -- read datestamper time stamp */ /*{{{*/
+static void readDsStamps(struct cpmInode *i, int lowestExt)
+{
+ struct dsDate *stamp;
+
+ if ( !(i->sb->type&CPMFS_DS_DATES) ) return;
+
+ /* Get datestamp */
+ stamp = i->sb->ds+lowestExt;
+
+ i->mtime = ds2unix_time(&stamp->modify);
+ i->ctime = ds2unix_time(&stamp->create);
+ i->atime = ds2unix_time(&stamp->access);
+}
+/*}}}*/
+
+/* match -- match filename against a pattern */ /*{{{*/
+static int recmatch(const char *a, const char *pattern)
+{
+ int first=1;