home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 4.ddi / C / QYGCOUN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  2.3 KB  |  83 lines

  1. /**
  2. *
  3. * Name        qygcoun -- Get country information from DOS
  4. *
  5. * Synopsis    error = qygcoun(pcountry,pinfo);
  6. *
  7. *        int  error    0 if OK
  8. *                2 if info not available for designated
  9. *                    country (error code is from DOS)
  10. *        unsigned *pcountry
  11. *                Country code.  Let the value be 0
  12. *                    initially to default to current
  13. *                    country.  This is ignored on
  14. *                    DOS 2.x.
  15. *        COUNTRY_INFO *pinfo
  16. *                Pointer to structure to receive info
  17. *
  18. * Description    This function retrieves DOS's table of information about
  19. *        the country for which it is configured and about how to
  20. *        format time, dates, and money for various countries.
  21. *
  22. *        This function is primarily for use with DOS 3.0 and
  23. *        greater.  Earlier versions of DOS return information for
  24. *        the current country only (ignoring *pcountry), and they
  25. *        fill only the "date format" and "currency symbol" fields
  26. *        of the *pinfo structure.
  27. *
  28. *        If the DOS version is 3.0 or greater, you can request
  29. *        information about any country by putting the country
  30. *        code into an unsigned and passing its address as the
  31. *        pcountry argument.  To request information and the
  32. *        country code for the current country, use a country code
  33. *        of 0.  The code of the current country will be returned
  34. *        in *pcountry.
  35. *
  36. * Returns    error        Error code: 0 if OK, 2 if unknown country
  37. *        *pcountry    Country code of requested country
  38. *                (if DOS version 3.0 or greater)
  39. *        *pinfo        Table of information for requested country
  40. *                (only partially valid if DOS version < 3)
  41. *
  42. * Version    3.0 (C)Copyright Blaise Computing Inc.    1986
  43. *
  44. **/
  45.  
  46. #include <bquery.h>
  47.  
  48. int qygcoun(pcountry,pinfo)
  49. unsigned *pcountry;
  50. COUNTRY_INFO *pinfo;
  51. {
  52.     DOSREG regs;
  53.     ADS    buf_ads;
  54.     int    al,error,dosver,minor;
  55.  
  56.     if ((dosver = qydosver(&minor)) < 3)
  57.     al = 0;
  58.     else if (*pcountry < 255)
  59.     al = *pcountry;
  60.     else
  61.     {
  62.     al = 0xff;
  63.     regs.bx = *pcountry;
  64.     }
  65.  
  66.     utabsptr((char *)pinfo,&buf_ads);
  67.     regs.ds = buf_ads.s;
  68.     regs.dx = buf_ads.r;
  69.     regs.ax = utbyword(0x38,al);
  70.  
  71.     error = dos(®s);
  72.  
  73.     if (dosver >= 3)
  74.     *pcountry = regs.bx;
  75.     else
  76.     {                  /* Zero the code pointer in case this   */
  77.     (pinfo->cmap).r =     /* gets passed to casemap().          */
  78.     (pinfo->cmap).s = 0;
  79.     }
  80.  
  81.     return error;
  82. }
  83.