EXTERN int asn1D_LatitudeDirectionCodeContentType (OSCTXT* pctxt, LatitudeDirectionCodeContentType *pvalue, ASN1TagType tagging, int length) { int stat = 0; stat = xd_enum (pctxt, (OSINT32*)pvalue, tagging, length); if (stat != 0) return LOG_RTERR (pctxt, stat); if(*pvalue < 0 || *pvalue > 1) return LOG_RTERR (pctxt, RTERR_INVENUM); return (stat); }
xd_t * xd_open (char *fn, int rdwr) { char dn[24]; xd_t *xd; int hd, pp, tt; pp = -1; tt = XDF_FILE; if (fn[0] == '(') { int dd; char *p; if (((fn[1] != 'h') && (fn[1] != 'f')) || (fn[2] != 'd')) return NULL; dd = strtol (fn + 3, &p, 0); if ((dd < 0) || (dd >= MAX_DISKS)) return NULL; if (*p == ',') { pp = strtol (p + 1, &p, 0); if ((pp < 0) || (pp >= MAX_PARTS)) return NULL; } if ((*p != ')') || (*(p + 1) != 0)) return NULL; #if defined(DOS) tt = XDF_DISK; hd = dd; if (fn[1] == 'h') hd += 0x80; goto next; #else tt |= XDF_DISK; if (fn[1] == 'h') { #if defined(WIN32) sprintf (dn, "\\\\.\\PhysicalDrive%d", dd); #elif defined(LINUX) sprintf (dn, "/dev/hd%c", 'a' + dd); #elif defined(FREEBSD) sprintf (dn, "/dev/ad%d", dd); #else return NULL; #endif } else { #if defined(WIN32) if (dd > 1) return NULL; sprintf (dn, "\\\\.\\%c:", 'A' + dd); #elif defined(LINUX) || defined(FREEBSD) sprintf (dn, "/dev/fd%d", dd); #else return NULL; #endif } fn = dn; #endif } #ifdef WIN32 hd = (int) CreateFile (fn, ((rdwr) ? GENERIC_WRITE : 0) | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING, 0); #else hd = open (fn, ((rdwr) ? O_RDWR : O_RDONLY) | O_BINARY); #endif if (hd < 0) return NULL; xd = malloc (sizeof (xd_t)); if (xd == NULL) return NULL; xd->flg = tt; xd->num = hd; xd->ofs = 0; #ifdef DOS if (tt == XDF_DISK) xd16_init (xd); #endif if (pp != -1) { xde_t xe; xe.cur = 0xFF; xe.nxt = pp; if ((xd_enum (xd, &xe)) || (xd_seek (xd, xe.bse))) { xd_close (xd); return NULL; } } return xd; }