Diff for /np2/generic/hostdrvs.c between versions 1.1 and 1.16

version 1.1, 2004/01/09 04:36:02 version 1.16, 2005/05/20 14:32:01
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
   
   #if defined(SUPPORT_HOSTDRV)
   
   #if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2)
   #include        "oemtext.h"
   #endif
 #include        "dosio.h"  #include        "dosio.h"
 #include        "pccore.h"  #include        "pccore.h"
 #include        "hostdrv.h"  #include        "hostdrv.h"
 #include        "hostdrvs.h"  #include        "hostdrvs.h"
   
   
 static const HDRVDIR hddroot = {"           ", 0, 0x10};  static const HDRVDIR hddroot = {"           ", 0, 0, 0, 0x10, {0}, {0}};
   
 static const BYTE dospathchr[] = {  static const UINT8 dospathchr[] = {
                         0xfa, 0x23,             // '&%$#"!  /.-,+*)(                          0xfa, 0x23,             // '&%$#"!  /.-,+*)(
                         0xff, 0x03,             // 76543210 ?>=<;:98                          0xff, 0x03,             // 76543210 ?>=<;:98
                         0xff, 0xff,             // GFEDCBA@ ONMLKJIH                          0xff, 0xff,             // GFEDCBA@ ONMLKJIH
Line 15  static const BYTE dospathchr[] = { Line 21  static const BYTE dospathchr[] = {
                         0x01, 0x00,             // gfedcba` onmlkjih                          0x01, 0x00,             // gfedcba` onmlkjih
                         0x00, 0x40};    // wvutsrqp ~}|{zyx                           0x00, 0x40};    // wvutsrqp ~}|{zyx 
   
 static void rcnvfcb(char *dst, UINT dlen, char *src, UINT slen) {  
   static void rcnvfcb(char *dst, UINT dlen, const char *src) {
   
         REG8    c;          REG8    c;
   
         while((slen) && (dlen)) {          while(dlen) {
                 slen--;  
                 c = (UINT8)*src++;                  c = (UINT8)*src++;
                 if (c == 0) {                  if (c == 0) {
                         break;                          break;
                 }                  }
   #if defined(OSLANG_SJIS) || defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2)
                 if ((((c ^ 0x20) - 0xa1) & 0xff) < 0x3c) {                  if ((((c ^ 0x20) - 0xa1) & 0xff) < 0x3c) {
                         if ((!slen) || (src[0] == '\0')) {                          if (src[0] == '\0') {
                                 break;                                  break;
                         }                          }
                         if (dlen < 2) {                          if (dlen < 2) {
Line 37  static void rcnvfcb(char *dst, UINT dlen Line 44  static void rcnvfcb(char *dst, UINT dlen
                         dst += 2;                          dst += 2;
                         dlen -= 2;                          dlen -= 2;
                 }                  }
                 else {                  else if (((c - 0x20) & 0xff) < 0x60) {
                           if (((c - 'a') & 0xff) < 26) {
                                   c -= 0x20;
                           }
                           if (dospathchr[(c >> 3) - (0x20 >> 3)] & (1 << (c & 7))) {
                                   *dst++ = c;
                                   dlen--;
                           }
                   }
                   else if (((c - 0xa0) & 0xff) < 0x40) {
                           *dst++ = c;
                           dlen--;
                   }
   #else
                   if (((c - 0x20) & 0xff) < 0x60) {
                         if (((c - 'a') & 0xff) < 26) {                          if (((c - 'a') & 0xff) < 26) {
                                 c -= 0x20;                                  c -= 0x20;
                         }                          }
                         if ((c >= 0x20) && (c < 0x80) &&                          if (dospathchr[(c >> 3) - (0x20 >> 3)] & (1 << (c & 7))) {
                                 (dospathchr[(c >> 3) - (0x20 >> 3)] & (1 << (c & 7)))) {  
                                 *dst++ = c;                                  *dst++ = c;
                                 dlen--;                                  dlen--;
                         }                          }
                 }                  }
                   else if (c >= 0x80) {
                           *dst++ = c;
                           dlen--;
                   }
   #endif
         }          }
 }  }
   
 static BOOL realname2fcb(char *fcbname, FLINFO *fli) {  static BRESULT realname2fcb(char *fcbname, const FLINFO *fli) {
   
         char    *realname;          OEMCHAR *ext;
         char    *ext;  #if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2)
           char    sjis[MAX_PATH];
   #endif
           OEMCHAR filename[MAX_PATH];
   
         realname = fli->path;  
         FillMemory(fcbname, 11, ' ');          FillMemory(fcbname, 11, ' ');
         ext = file_getext(realname);  
         rcnvfcb(fcbname+0, 8, realname, ext - realname);          ext = file_getext(fli->path);
         rcnvfcb(fcbname+8, 3, ext, (UINT)-1);  #if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2)
           oemtext_oemtosjis(sjis, sizeof(sjis), ext, (UINT)-1);
           rcnvfcb(fcbname+8, 3, sjis);
   #else
           rcnvfcb(fcbname+8, 3, ext);
   #endif
   
           file_cpyname(filename, fli->path, NELEMENTS(filename));
           file_cutext(filename);
   #if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2)
           oemtext_oemtosjis(sjis, sizeof(sjis), filename, (UINT)-1);
           rcnvfcb(fcbname+0, 8, sjis);
   #else
           rcnvfcb(fcbname+0, 8, filename);
   #endif
         return(SUCCESS);          return(SUCCESS);
 }  }
   
Line 71  static BOOL hddsea(void *vpItem, void *v Line 112  static BOOL hddsea(void *vpItem, void *v
         return(FALSE);          return(FALSE);
 }  }
   
 LISTARRAY hostdrvs_getpathlist(const char *realpath) {  static BOOL hddseadir(void *vpItem, void *vpArg) {
   
           if ((((HDRVLST)vpItem)->di.attr & 0x10) &&
                   (!memcmp(((HDRVLST)vpItem)->di.fcbname, vpArg, 11))) {
                   return(TRUE);
           }
           return(FALSE);
   }
   
   LISTARRAY hostdrvs_getpathlist(const OEMCHAR *realpath) {
   
         FLISTH          flh;          FLISTH          flh;
         FLINFO          fli;          FLINFO          fli;
Line 96  LISTARRAY hostdrvs_getpathlist(const cha Line 146  LISTARRAY hostdrvs_getpathlist(const cha
                                 break;                                  break;
                         }                          }
                         CopyMemory(hdd->di.fcbname, fcbname, 11);                          CopyMemory(hdd->di.fcbname, fcbname, 11);
                           hdd->di.exist = 1;
                           hdd->di.caps = fli.caps;
                         hdd->di.size = fli.size;                          hdd->di.size = fli.size;
                         hdd->di.attr = fli.attr;                          hdd->di.attr = fli.attr;
                         milstr_ncpy(hdd->realname, fli.path, sizeof(hdd->realname));                          hdd->di.date = fli.date;
                           hdd->di.time = fli.time;
                           file_cpyname(hdd->realname, fli.path, NELEMENTS(hdd->realname));
   //                      TRACEOUT(("%s -> %11s", fli.path, fcbname));
                 }                  }
         } while(file_listnext(flh, &fli) == SUCCESS);          } while(file_listnext(flh, &fli) == SUCCESS);
         if (listarray_getitems(ret) == 0) {          if (listarray_getitems(ret) == 0) {
Line 163  static char *dospath2fcb(char *fcbname,  Line 218  static char *dospath2fcb(char *fcbname, 
   
 BOOL hostdrvs_getrealpath(HDRVPATH *hdp, char *dospath) {  BOOL hostdrvs_getrealpath(HDRVPATH *hdp, char *dospath) {
   
         BOOL            ret;          OEMCHAR         path[MAX_PATH];
         char            path[MAX_PATH];  
         LISTARRAY       lst;          LISTARRAY       lst;
 const HDRVDIR   *di;  const HDRVDIR   *di;
         HDRVLST         hdl;          HDRVLST         hdl;
         char            fcbname[11];          char            fcbname[11];
   
         ret = SUCCESS;          file_cpyname(path, np2cfg.hdrvroot, NELEMENTS(path));
         file_cpyname(path, np2cfg.hdrvroot, sizeof(path));  
         lst = NULL;          lst = NULL;
         di = &hddroot;          di = &hddroot;
         while(dospath[0] != '\0') {          while(dospath[0] != '\0') {
                 if ((dospath[0] != '\\') || (!(di->attr & 0x10))) {                  if ((dospath[0] != '\\') || (!(di->attr & 0x10))) {
                         goto hdsgrp_err;                          goto hdsgrp_err;
                 }                  }
                 file_setseparator(path, sizeof(path));                  file_setseparator(path, NELEMENTS(path));
                 dospath++;                  dospath++;
                 if (dospath[0] == '\0') {                  if (dospath[0] == '\0') {
                         di = &hddroot;                          di = &hddroot;
Line 191  const HDRVDIR  *di; Line 244  const HDRVDIR  *di;
                 if (hdl == NULL) {                  if (hdl == NULL) {
                         goto hdsgrp_err;                          goto hdsgrp_err;
                 }                  }
                 file_catname(path, hdl->realname, sizeof(path));                  file_catname(path, hdl->realname, NELEMENTS(path));
                 di = &hdl->di;                  di = &hdl->di;
         }          }
         if (hdl) {          if (hdp) {
                 CopyMemory(&hdp->di, di, sizeof(HDRVDIR));                  CopyMemory(&hdp->di, di, sizeof(HDRVDIR));
                 file_cpyname(hdp->path, path, sizeof(hdp->path));                  file_cpyname(hdp->path, path, NELEMENTS(hdp->path));
         }          }
         listarray_destroy(lst);          listarray_destroy(lst);
         return(SUCCESS);          return(SUCCESS);
Line 206  hdsgrp_err: Line 259  hdsgrp_err:
         return(FAILURE);          return(FAILURE);
 }  }
   
   BOOL hostdrvs_getrealdir(OEMCHAR *path, int size, char *fcb, char *dospath) {
   
 // ----          LISTARRAY       lst;
           HDRVLST         hdl;
   
 void hostdrvs_fhdlreopen(LISTARRAY fhdl) {          file_cpyname(path, np2cfg.hdrvroot, size);
           if (dospath[0] == '\\') {
                   file_setseparator(path, size);
                   dospath++;
           }
           else if (dospath[0] != '\0') {
                   goto hdsgrd_err;
           }
           while(1) {
                   dospath = dospath2fcb(fcb, dospath);
                   if (dospath[0] != '\\') {
                           break;
                   }
                   lst = hostdrvs_getpathlist(path);
                   hdl = (HDRVLST)listarray_enum(lst, hddseadir, fcb);
                   if (hdl != NULL) {
                           file_catname(path, hdl->realname, size);
                   }
                   listarray_destroy(lst);
                   if (hdl == NULL) {
                           goto hdsgrd_err;
                   }
                   file_setseparator(path, size);
                   dospath++;
           }
           if (dospath[0] != '\0') {
                   goto hdsgrd_err;
           }
           return(SUCCESS);
   
         (void)fhdl;  hdsgrd_err:
           return(FAILURE);
 }  }
   
   BOOL hostdrvs_newrealpath(HDRVPATH *hdp, char *dospath) {
   
           OEMCHAR         path[MAX_PATH];
           char            fcb[11];
           LISTARRAY       lst;
           HDRVLST         hdl;
           char            dosname[16];
           UINT            i;
           char            *p;
   #if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2)
           OEMCHAR         oemname[64];
   #endif
   
           if ((hostdrvs_getrealdir(path, NELEMENTS(path), fcb, dospath)
                                                                                                                           != SUCCESS) ||
                   (fcb[0] == ' ')) {
                   return(FAILURE);
           }
           lst = hostdrvs_getpathlist(path);
           hdl = (HDRVLST)listarray_enum(lst, hddsea, fcb);
           if (hdl != NULL) {
                   file_catname(path, hdl->realname, NELEMENTS(path));
                   if (hdp) {
                           CopyMemory(&hdp->di, &hdl->di, sizeof(HDRVDIR));
                           file_cpyname(hdp->path, path, NELEMENTS(hdp->path));
                   }
           }
           else {
                   p = dosname;
                   for (i=0; (i<8) && (fcb[i] != ' '); i++) {
                           *p++ = fcb[i];
                   }
                   if (fcb[8] != ' ') {
                           *p++ = '.';
                           for (i=8; (i<11) && (fcb[i] != ' '); i++) {
                                   *p++ = fcb[i];
                           }
                   }
                   *p = '\0';
                   // ここで SJIS->OEMコードに未変換!
   #if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2)
                   oemtext_sjistooem(oemname, NELEMENTS(oemname), dosname, (UINT)-1);
                   file_catname(path, oemname, NELEMENTS(path));
   #else
                   file_catname(path, dosname, NELEMENTS(path));
   #endif
                   if (hdp) {
                           ZeroMemory(&hdp->di, sizeof(hdp->di));
                           CopyMemory(hdp->di.fcbname, fcb, 11);
                           file_cpyname(hdp->path, path, NELEMENTS(hdp->path));
                   }
           }
           listarray_destroy(lst);
           return(SUCCESS);
   }
   
   
   // ----
   
 static BOOL fhdlallclose(void *vpItem, void *vpArg) {  static BOOL fhdlallclose(void *vpItem, void *vpArg) {
   
         long    fh;          long    fh;
Line 258  HDRVFILE hostdrvs_fhdlsea(LISTARRAY fhdl Line 401  HDRVFILE hostdrvs_fhdlsea(LISTARRAY fhdl
         return(ret);          return(ret);
 }  }
   
   #endif
   

Removed from v.1.1  
changed lines
  Added in v.1.16


RetroPC.NET-CVS <cvs@retropc.net>