Subversion Repositories SvarDOS

Rev

Rev 1744 | Rev 1960 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1744 Rev 1745
Line 71... Line 71...
71
/*  char fname[13]; */
71
/*  char fname[13]; */
72
  char fname[12];
72
  char fname[12];
73
};
73
};
74
 
74
 
75
 
75
 
76
/* returns current COUNTRY id (1=USA, 7=RU, 33=FR, 48=PL, 49=DE, etc) */
-
 
77
static unsigned short dir_cur_country(void) {
-
 
78
  _Packed struct { /* Extended Country Info Block */
-
 
79
    unsigned char bRecID;   /* Information ID */
-
 
80
    unsigned short wRecLen; /* size of information */
-
 
81
    unsigned short wCountryID; /* country code */
-
 
82
    unsigned short wCodePgID;  /* code page */
-
 
83
    /* the block structure is much larger, but I only need the fields above */
-
 
84
  } buff;
-
 
85
  void *buffptr = &buff;
-
 
86
 
-
 
87
  _asm {
-
 
88
    push ax
-
 
89
    push bx
-
 
90
    push cx
-
 
91
    push dx
-
 
92
    push es
-
 
93
    push di
-
 
94
 
-
 
95
    mov ax, 0x6501  /* DOS 3.3+ - Get Extended Country Information */
-
 
96
    mov bx, 0xffff  /* code page (FFFFh = current) */
-
 
97
    mov cx, 7       /* sizeof(buff) */
-
 
98
    mov dx, bx      /* country code (FFFFh = current) */
-
 
99
    push ds
-
 
100
    pop es
-
 
101
    mov di, buffptr
-
 
102
    int 0x21
-
 
103
 
-
 
104
    pop di
-
 
105
    pop es
-
 
106
    pop dx
-
 
107
    pop cx
-
 
108
    pop bx
-
 
109
    pop ax
-
 
110
  }
-
 
111
 
-
 
112
  return(buff.wCountryID);
-
 
113
}
-
 
114
 
-
 
115
 
-
 
116
/* fills freebytes with free bytes for drv (A=0, B=1, etc)
76
/* fills freebytes with free bytes for drv (A=0, B=1, etc)
117
 * returns DOS ERR code on failure */
77
 * returns DOS ERR code on failure */
118
static unsigned short cmd_dir_df(unsigned long *freebytes, unsigned char drv) {
78
static unsigned short cmd_dir_df(unsigned long *freebytes, unsigned char drv) {
119
  unsigned short res = 0;
79
  unsigned short res = 0;
120
  unsigned short sects_per_clust = 0, avail_clusts = 0, bytes_per_sect = 0;
80
  unsigned short sects_per_clust = 0, avail_clusts = 0, bytes_per_sect = 0;
Line 520... Line 480...
520
    if ((i >= 'A') && (i <= 'Z')) glob_sortcmp_dat.sortownia[i] |= 32;
480
    if ((i >= 'A') && (i <= 'Z')) glob_sortcmp_dat.sortownia[i] |= 32;
521
  }
481
  }
522
 
482
 
523
  /* try to replace (or complement) my naive collation table with an NLS-aware
483
  /* try to replace (or complement) my naive collation table with an NLS-aware
524
   * version provided by the kernel (or NLSFUNC)
484
   * version provided by the kernel (or NLSFUNC)
525
   * do this ONLY for COUNTRY codes that are higher than 1, because zero is
-
 
526
   * invalid and value 1 can mean either "USA" or "undefined".
-
 
527
   * ref: https://github.com/SvarDOS/bugz/issues/68 */
485
   * see https://github.com/SvarDOS/bugz/issues/68 for some thoughts */
528
  if (dir_cur_country() > 1) {
486
  {
529
    _Packed struct nlsseqtab {
487
    _Packed struct nlsseqtab {
530
      unsigned char id;
488
      unsigned char id;
531
      unsigned short taboff;
489
      unsigned short taboff;
532
      unsigned short tabseg;
490
      unsigned short tabseg;
533
    } collat;
491
    } collat;
Line 563... Line 521...
563
    }
521
    }
564
 
522
 
565
    if ((errflag == 0) && (collat.id == 6)) {
523
    if ((errflag == 0) && (collat.id == 6)) {
566
      unsigned char far *ptr = MK_FP(collat.tabseg, collat.taboff);
524
      unsigned char far *ptr = MK_FP(collat.tabseg, collat.taboff);
567
      unsigned short count = *(unsigned short far *)ptr;
525
      unsigned short count = *(unsigned short far *)ptr;
-
 
526
#ifdef DIR_DUMPNLSCOLLATE
568
      /* printf("NLS AT %04X:%04X (%u elements)\n", collat.tabseg, collat.taboff, count); */
527
      printf("NLS AT %04X:%04X (%u elements)\n", collat.tabseg, collat.taboff, count);
-
 
528
#endif
569
      if (count <= 256) { /* you never know */
529
      if (count <= 256) { /* you never know */
570
        ptr += 2; /* skip the count header */
530
        ptr += 2; /* skip the count header */
571
        for (i = 0; i < count; i++) {
531
        for (i = 0; i < count; i++) {
572
          glob_sortcmp_dat.sortownia[i] = ptr[i];
532
          glob_sortcmp_dat.sortownia[i] = ptr[i];
-
 
533
#ifdef DIR_DUMPNLSCOLLATE
-
 
534
          printf(" %03u", ptr[i]);
-
 
535
          if ((i & 15) == 15) {
-
 
536
            printf("\n");
-
 
537
            fflush(stdout);
-
 
538
          }
-
 
539
#endif
573
        }
540
        }
574
      }
541
      }
575
    }
542
    }
576
  }
543
  }
577
 
544