home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 December (Special) / DOSV2002_12.iso / utility / tcl230ja95.lzh / source.lzh / dll / format.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-05  |  14.9 KB  |  675 lines

  1. //---[s]--- For InternetTime 99/03/16@211 M.Takemura -----
  2.  
  3. /*-----------------------------------------------------
  4.     format.c
  5.     to make a string to display in the clock
  6.     KAZUBON 1997-1998
  7. -------------------------------------------------------*/
  8.  
  9. #include "tcdll.h"
  10.  
  11. int codepage = CP_ACP;
  12. static char DayOfWeekShort[11], DayOfWeekLong[31];
  13. static char MonthShort[11], MonthLong[31];
  14. static char *DayOfWeekEng[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
  15. static char *MonthEng[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  16.     "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
  17. static char AM[11], PM[11], SDate[5], STime[5];
  18. static char EraStr[11];
  19. static int AltYear;
  20.  
  21. extern BOOL bHour12, bHourZero;
  22. extern BOOL bWin95, bWin2000;
  23.  
  24. extern int iFreeRes[3], iCPUUsage, iBatteryLife;
  25. extern char sAvailPhysK[], sAvailPhysM[];
  26.  
  27. /*------------------------------------------------
  28.   GetLocaleInfo() for 95/NT
  29. --------------------------------------------------*/
  30. int GetLocaleInfoWA(WORD wLanguageID, LCTYPE LCType, char* dst, int n)
  31. {
  32.     int r;
  33.     LCID Locale;
  34.     
  35.     *dst = 0;
  36.     Locale = MAKELCID(wLanguageID, SORT_DEFAULT);
  37.     if(GetVersion() & 0x80000000) // 95
  38.         r = GetLocaleInfoA(Locale, LCType, dst, n);
  39.     else  // NT
  40.     {
  41.         WCHAR* pw;
  42.         pw = (WCHAR*)GlobalAllocPtr(GHND, sizeof(WCHAR)*(n+1));
  43.         *pw = 0;
  44.         r = GetLocaleInfoW(Locale, LCType, pw, n);
  45.         if(r)
  46.             WideCharToMultiByte(codepage, 0, pw, -1, dst, n,
  47.                 NULL, NULL);
  48.         GlobalFreePtr(pw);
  49.     }
  50.     return r;
  51. }
  52.  
  53. /*------------------------------------------------
  54.   GetDateFormat() for 95/NT
  55. --------------------------------------------------*/
  56. int GetDateFormatWA(WORD wLanguageID, DWORD dwFlags, CONST SYSTEMTIME *t,
  57.     char* fmt, char* dst, int n)
  58. {
  59.     int r;
  60.     LCID Locale;
  61.     
  62.     *dst = 0;
  63.     Locale = MAKELCID(wLanguageID, SORT_DEFAULT);
  64.     if(GetVersion() & 0x80000000) // 95
  65.         r = GetDateFormatA(Locale, dwFlags, t, fmt, dst, n);
  66.     
  67.     else  // NT
  68.     {
  69.         WCHAR* pw1, *pw2;
  70.         pw1 = NULL;
  71.         if(fmt)
  72.         {
  73.             pw1 = (WCHAR*)GlobalAllocPtr(GHND,
  74.                 sizeof(WCHAR)*(strlen(fmt)+1));
  75.             MultiByteToWideChar(CP_ACP, 0, fmt, -1,
  76.                 pw1, strlen(fmt));
  77.         }
  78.         pw2 = (WCHAR*)GlobalAllocPtr(GHND, sizeof(WCHAR)*(n+1));
  79.         r = GetDateFormatW(Locale, dwFlags, t, pw1, pw2, n);
  80.         if(r)
  81.             WideCharToMultiByte(CP_ACP, 0, pw2, -1, dst, n,
  82.                 NULL, NULL);
  83.         if(pw1) GlobalFreePtr(pw1);
  84.         GlobalFreePtr(pw2);
  85.     }
  86.     return r;
  87. }
  88.  
  89. /*------------------------------------------------
  90.   GetTimeFormat() for 95/NT
  91. --------------------------------------------------*/
  92. int GetTimeFormatWA(WORD wLanguageID, DWORD dwFlags, CONST SYSTEMTIME *t,
  93.     char* fmt, char* dst, int n)
  94. {
  95.     int r;
  96.     LCID Locale;
  97.     
  98.     *dst = 0;
  99.     Locale = MAKELCID(wLanguageID, SORT_DEFAULT);
  100.     if(GetVersion() & 0x80000000) // 95
  101.         r = GetTimeFormatA(Locale, dwFlags, t, fmt, dst, n);
  102.     
  103.     else  // NT
  104.     {
  105.         WCHAR* pw1, *pw2;
  106.         pw1 = NULL;
  107.         if(fmt)
  108.         {
  109.             pw1 = (WCHAR*)GlobalAllocPtr(GHND,
  110.                 sizeof(WCHAR)*(strlen(fmt)+1));
  111.             MultiByteToWideChar(CP_ACP, 0, fmt, -1,
  112.                 pw1, strlen(fmt));
  113.         }
  114.         pw2 = (WCHAR*)GlobalAllocPtr(GHND, sizeof(WCHAR)*(n+1));
  115.         r = GetTimeFormatW(Locale, dwFlags, t, pw1, pw2, n);
  116.         if(r)
  117.             WideCharToMultiByte(CP_ACP, 0, pw2, -1, dst, n,
  118.                 NULL, NULL);
  119.         if(pw1) GlobalFreePtr(pw1);
  120.         GlobalFreePtr(pw2);
  121.     }
  122.     return r;
  123. }
  124.  
  125. /*------------------------------------------------
  126.   load strings of day, month
  127. --------------------------------------------------*/
  128. void InitFormat(SYSTEMTIME* lt)
  129. {
  130.     char s[80], *p;
  131.     int i, ilang, ioptcal;
  132.     
  133.     ilang = GetMyRegLong(NULL, "Locale", (int)GetUserDefaultLangID());
  134.     
  135.     codepage = CP_ACP;
  136.     if(GetLocaleInfoWA((WORD)ilang, LOCALE_IDEFAULTANSICODEPAGE,
  137.         s, 10) > 0)
  138.     {
  139.         p = s; codepage = 0;
  140.         while('0' <= *p && *p <= '9')
  141.             codepage = codepage * 10 + *p++ - '0';
  142.         if(!IsValidCodePage(codepage)) codepage = CP_ACP;
  143.     }
  144.     
  145.     i = lt->wDayOfWeek; i--; if(i < 0) i = 6;
  146.     GetLocaleInfoWA((WORD)ilang, LOCALE_SABBREVDAYNAME1 + i,
  147.         DayOfWeekShort, 10);
  148.     GetLocaleInfoWA((WORD)ilang, LOCALE_SDAYNAME1 + i,
  149.         DayOfWeekLong, 30);
  150.     i = lt->wMonth; i--;
  151.     GetLocaleInfoWA((WORD)ilang, LOCALE_SABBREVMONTHNAME1 + i,
  152.         MonthShort, 10);
  153.     GetLocaleInfoWA((WORD)ilang, LOCALE_SMONTHNAME1 + i,
  154.         MonthLong, 30);
  155.     
  156.     GetLocaleInfoWA((WORD)ilang, LOCALE_S1159, AM, 10);
  157.     GetMyRegStr(NULL, "AMsymbol", s, 80, AM);
  158.     if(s[0] == 0) strcpy(s, "AM");
  159.     strcpy(AM, s);
  160.     GetLocaleInfoWA((WORD)ilang, LOCALE_S2359, PM, 10);
  161.     GetMyRegStr(NULL, "PMsymbol", s, 80, PM);
  162.     if(s[0] == 0) strcpy(s, "PM");
  163.     strcpy(PM, s);
  164.     
  165.     GetLocaleInfoWA((WORD)ilang, LOCALE_SDATE, SDate, 4);
  166.     GetLocaleInfoWA((WORD)ilang, LOCALE_STIME, STime, 4);
  167.     
  168.     EraStr[0] = 0;
  169.     AltYear = -1;
  170.     
  171.     ioptcal = 0;
  172.     if(GetLocaleInfoWA((WORD)ilang, LOCALE_IOPTIONALCALENDAR,
  173.         s, 10))
  174.     {
  175.         ioptcal = 0;
  176.         p = s;
  177.         while('0' <= *p && *p <= '9')
  178.             ioptcal = ioptcal * 10 + *p++ - '0';
  179.     }
  180.     if(ioptcal < 3) ilang = LANG_USER_DEFAULT;
  181.     
  182.     if(GetDateFormatWA((WORD)ilang,
  183.         DATE_USE_ALT_CALENDAR, lt, "gg", s, 12) != 0);
  184.         strcpy(EraStr, s);
  185.     
  186.     if(GetDateFormatWA((WORD)ilang,
  187.         DATE_USE_ALT_CALENDAR, lt, "yyyy", s, 6) != 0)
  188.     {
  189.         if(s[0])
  190.         {
  191.             p = s;
  192.             AltYear = 0;
  193.             while('0' <= *p && *p <= '9')
  194.                 AltYear = AltYear * 10 + *p++ - '0';
  195.         }
  196.     }
  197. }
  198.  
  199. /*------------------------------------------------
  200.    make a string from date and time format
  201. --------------------------------------------------*/
  202. void MakeFormat(char* s, SYSTEMTIME* pt, int beat100, char* fmt)
  203. {
  204.     char *sp, *dp, *p;
  205.     
  206.     sp = fmt; dp = s;
  207.     while(*sp)
  208.     {
  209.         if(*sp == '\"')
  210.         {
  211.             sp++;
  212.             while(*sp != '\"' && *sp)
  213.             {
  214.                 p = CharNext(sp);
  215.                 while(sp != p) *dp++ = *sp++;
  216.             }
  217.             if(*sp == '\"') sp++;
  218.         }
  219.         else if(*sp == '/')
  220.         {
  221.             p = SDate; while(*p) *dp++ = *p++;
  222.             sp++;
  223.         }
  224.         else if(*sp == ':')
  225.         {
  226.             p = STime; while(*p) *dp++ = *p++;
  227.             sp++;
  228.         }
  229.         
  230.         // for testing
  231.         else if(*sp == 'S' && *(sp + 1) == 'S' && *(sp + 2) == 'S')
  232.         {
  233.             *dp++ = (char)(((int)pt->wMilliseconds % 1000) / 100) + '0';
  234.             *dp++ = (char)(((int)pt->wMilliseconds % 100) / 10) + '0';
  235.             *dp++ = (char)((int)pt->wMilliseconds % 10) + '0';
  236.             sp += 3;
  237.         }
  238.         
  239.         else if(*sp == 'y' && *(sp + 1) == 'y')
  240.         {
  241.             if(*(sp + 2) == 'y' && *(sp + 3) == 'y')
  242.             {
  243.                 *dp++ = (char)((int)pt->wYear / 1000) + '0';
  244.                 *dp++ = (char)(((int)pt->wYear % 1000) / 100) + '0';
  245.                 sp += 2;
  246.             }
  247.             *dp++ = (char)(((int)pt->wYear % 100) / 10) + '0';
  248.             *dp++ = (char)((int)pt->wYear % 10) + '0';
  249.             sp += 2;
  250.         }
  251.         else if(*sp == 'm')
  252.         {
  253.             if(*(sp + 1) == 'm' && *(sp + 2) == 'e')
  254.             {
  255.                 *dp++ = MonthEng[pt->wMonth-1][0];
  256.                 *dp++ = MonthEng[pt->wMonth-1][1];
  257.                 *dp++ = MonthEng[pt->wMonth-1][2];
  258.                 sp += 3;
  259.             }
  260.             else if(*(sp + 1) == 'm' && *(sp + 2) == 'm')
  261.             {
  262.                 if(*(sp + 3) == 'm')
  263.                 {
  264.                     p = MonthLong;
  265.                     while(*p) *dp++ = *p++;
  266.                     sp += 4;
  267.                 }
  268.                 else
  269.                 {
  270.                     p = MonthShort;
  271.                     while(*p) *dp++ = *p++;
  272.                     sp += 3;
  273.                 }
  274.             }
  275.             else
  276.             {
  277.                 if(*(sp + 1) == 'm')
  278.                 {
  279.                     *dp++ = (char)((int)pt->wMonth / 10) + '0';
  280.                     sp += 2;
  281.                 }
  282.                 else
  283.                 {
  284.                     if(pt->wMonth > 9)
  285.                         *dp++ = (char)((int)pt->wMonth / 10) + '0';
  286.                     sp++;
  287.                 }
  288.                 *dp++ = (char)((int)pt->wMonth % 10) + '0';
  289.             }
  290.         }
  291.         else if(*sp == 'a' && *(sp + 1) == 'a' && *(sp + 2) == 'a')
  292.         {
  293.             if(*(sp + 3) == 'a')
  294.             {
  295.                 p = DayOfWeekLong;
  296.                 while(*p) *dp++ = *p++;
  297.                 sp += 4;
  298.             }
  299.             else
  300.             {
  301.                 p = DayOfWeekShort;
  302.                 while(*p) *dp++ = *p++;
  303.                 sp += 3;
  304.             }
  305.         }
  306.         else if(*sp == 'd')
  307.         {
  308.             if(*(sp + 1) == 'd' && *(sp + 2) == 'e')
  309.             {
  310.                 p = DayOfWeekEng[pt->wDayOfWeek];
  311.                 while(*p) *dp++ = *p++;
  312.                 sp += 3;
  313.             }
  314.             else if(*(sp + 1) == 'd' && *(sp + 2) == 'd')
  315.             {
  316.                 if(*(sp + 3) == 'd')
  317.                 {
  318.                     p = DayOfWeekLong;
  319.                     while(*p) *dp++ = *p++;
  320.                     sp += 4;
  321.                 }
  322.                 else
  323.                 {
  324.                     p = DayOfWeekShort;
  325.                     while(*p) *dp++ = *p++;
  326.                     sp += 3;
  327.                 }
  328.             }
  329.             else
  330.             {
  331.                 if(*(sp + 1) == 'd')
  332.                 {
  333.                     *dp++ = (char)((int)pt->wDay / 10) + '0';
  334.                     sp += 2;
  335.                 }
  336.                 else
  337.                 {
  338.                     if(pt->wDay > 9)
  339.                         *dp++ = (char)((int)pt->wDay / 10) + '0';
  340.                     sp++;
  341.                 }
  342.                 *dp++ = (char)((int)pt->wDay % 10) + '0';
  343.             }
  344.         }
  345.         else if(*sp == 'h')
  346.         {
  347.             int hour;
  348.             hour = pt->wHour;
  349.             if(bHour12)
  350.             {
  351.                 if(hour > 12) hour -= 12;
  352.                 else if(hour == 0) hour = 12;
  353.                 if(hour == 12 && bHourZero) hour = 0;
  354.             }
  355.             if(*(sp + 1) == 'h')
  356.             {
  357.                 *dp++ = (char)(hour / 10) + '0';
  358.                 sp += 2;
  359.             }
  360.             else
  361.             {
  362.                 if(hour > 9)
  363.                     *dp++ = (char)(hour / 10) + '0';
  364.                 sp++;
  365.             }
  366.             *dp++ = (char)(hour % 10) + '0';
  367.         }
  368.         else if(*sp == 'n')
  369.         {
  370.             if(*(sp + 1) == 'n')
  371.             {
  372.                 *dp++ = (char)((int)pt->wMinute / 10) + '0';
  373.                 sp += 2;
  374.             }
  375.             else
  376.             {
  377.                 if(pt->wMinute > 9)
  378.                     *dp++ = (char)((int)pt->wMinute / 10) + '0';
  379.                 sp++;
  380.             }
  381.             *dp++ = (char)((int)pt->wMinute % 10) + '0';
  382.         }
  383.         else if(*sp == 's')
  384.         {
  385.             if(*(sp + 1) == 's')
  386.             {
  387.                 *dp++ = (char)((int)pt->wSecond / 10) + '0';
  388.                 sp += 2;
  389.             }
  390.             else
  391.             {
  392.                 if(pt->wSecond > 9)
  393.                     *dp++ = (char)((int)pt->wSecond / 10) + '0';
  394.                 sp++;
  395.             }
  396.             *dp++ = (char)((int)pt->wSecond % 10) + '0';
  397.         }
  398.         else if(*sp == 't' && *(sp + 1) == 't')
  399.         {
  400.             if(pt->wHour < 12) p = AM; else p = PM;
  401.             while(*p) *dp++ = *p++;
  402.             sp += 2;
  403.         }
  404.         else if(*sp == 'A' && *(sp + 1) == 'M')
  405.         {
  406.             if(*(sp + 2) == '/' &&
  407.                 *(sp + 3) == 'P' && *(sp + 4) == 'M')
  408.             {
  409.                 if(pt->wHour < 12) *dp++ = 'A';
  410.                 else *dp++ = 'P';
  411.                 *dp++ = 'M'; sp += 5;
  412.             }
  413.             else if(*(sp + 2) == 'P' && *(sp + 3) == 'M')
  414.             {
  415.                 if(pt->wHour < 12) p = AM; else p = PM;
  416.                 while(*p) *dp++ = *p++;
  417.                 sp += 4;
  418.             }
  419.         }
  420.         else if(*sp == 'a' && *(sp + 1) == 'm' && *(sp + 2) == '/' &&
  421.             *(sp + 3) == 'p' && *(sp + 4) == 'm')
  422.         {
  423.             if(pt->wHour < 12) *dp++ = 'a';
  424.             else *dp++ = 'p';
  425.             *dp++ = 'm'; sp += 5;
  426.         }
  427.         else if(*sp == '\\' && *(sp + 1) == 'n')
  428.         {
  429.             *dp++ = 0x0d; *dp++ = 0x0a;
  430.             sp += 2;
  431.         }
  432.         // internet time
  433.         else if (*sp == '@' && *(sp + 1) == '@' && *(sp + 2) == '@')
  434.         {
  435.             *dp++ = '@';
  436.             *dp++ = beat100 / 10000 + '0';
  437.             *dp++ = (beat100 % 10000) / 1000 + '0';
  438.             *dp++ = (beat100 % 1000) / 100 + '0';
  439.             sp += 3;
  440.             if(*sp == '.' && *(sp + 1) == '@')
  441.             {
  442.                 *dp++ = '.';
  443.                 *dp++ = (beat100 % 100) / 10 + '0';
  444.                 sp += 2;
  445.             }
  446.         }
  447.         // alternate calendar
  448.         else if(*sp == 'Y' && AltYear > -1)
  449.         {
  450.             int n = 1;
  451.             while(*sp == 'Y') { n *= 10; sp++; }
  452.             if(n < AltYear)
  453.             {
  454.                 n = 1; while(n < AltYear) n *= 10;
  455.             }
  456.             while(1)
  457.             {
  458.                 *dp++ = (AltYear % n) / (n/10) + '0';
  459.                 if(n == 10) break;
  460.                 n /= 10;
  461.             }
  462.         }
  463.         else if(*sp == 'g')
  464.         {
  465.             char *p2;
  466.             p = EraStr;
  467.             while(*p && *sp == 'g')
  468.             {
  469.                 p2 = CharNextExA((WORD)codepage, p, 0);
  470.                 while(p != p2) *dp++ = *p++;
  471.                 sp++;
  472.             }
  473.             while(*sp == 'g') sp++;
  474.         }
  475.         else if(*sp == 'R') // System Resources
  476.         {
  477.             int i, per;
  478.             i = 3;
  479.             if(*(sp + 1) == 'S') i = 0;
  480.             else if(*(sp + 1) == 'G') i = 1;
  481.             else if(*(sp + 1) == 'U') i = 2;
  482.             if(i < 3 && bWin95)
  483.             {
  484.                 per = iFreeRes[i];
  485.                 if(per > 99) *dp++ = (char)((per / 100) + '0');
  486.                 if(per > 9)  *dp++ = (char)((per % 100) / 10 + '0');
  487.                 *dp++ = (char)((per % 10) + '0');
  488.                 sp += 2;
  489.             }
  490.             else *dp++ = *sp++;
  491.         }
  492.         else if(*sp == 'C') // CPU Usage
  493.         {
  494.             if(bWin95 && *(sp + 1) == 'U')
  495.             {
  496.                 if(iCPUUsage > 99)
  497.                     *dp++ = (char)((iCPUUsage % 1000) / 100 + '0');
  498.                 *dp++ = (char)((iCPUUsage % 100) / 10 + '0');
  499.                 *dp++ = (char)((iCPUUsage % 10) + '0');
  500.                 sp += 2;
  501.             }
  502.             else *dp++ = *sp++;
  503.         }
  504.         else if(*sp == 'B' && *(sp + 1) == 'L') // Battery Life Percentage
  505.         {
  506.             if(bWin95 || bWin2000)
  507.             {
  508.                 if(iBatteryLife <= 100)
  509.                 {
  510.                     if(iBatteryLife > 99)
  511.                         *dp++ = (char)((iBatteryLife % 1000) / 100 + '0');
  512.                     *dp++ = (char)((iBatteryLife % 100) / 10 + '0');
  513.                     *dp++ = (char)((iBatteryLife % 10) + '0');
  514.                 }
  515.             }
  516.             sp += 2;
  517.         }
  518.         else if(*sp == 'M') // Available Physical Memory
  519.         {
  520.             char *p;
  521.             p = NULL;
  522.             if(*(sp + 1) == 'K')      { p = sAvailPhysK; sp += 2; }
  523.             else if(*(sp + 1) == 'M') { p = sAvailPhysM; sp += 2; }
  524.             else *dp++ = *sp++;
  525.             if(p) { while(*p) *dp++ = *p++; }
  526.         }
  527.         else if(*sp == 'L' && _strncmp(sp, "LDATE", 5) == 0)
  528.         {
  529.             char s[80], *p;
  530.             GetDateFormatWA(MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
  531.                 DATE_LONGDATE, pt, NULL, s, 80);
  532.             p = s;
  533.             while(*p) *dp++ = *p++;
  534.             sp += 5;
  535.         }
  536.         else if(*sp == 'D' && _strncmp(sp, "DATE", 4) == 0)
  537.         {
  538.             char s[80], *p;
  539.             GetDateFormatWA(MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
  540.                 DATE_SHORTDATE, pt, NULL, s, 80);
  541.             p = s;
  542.             while(*p) *dp++ = *p++;
  543.             sp += 4;
  544.         }
  545.         else if(*sp == 'T' && _strncmp(sp, "TIME", 4) == 0)
  546.         {
  547.             char s[80], *p;
  548.             GetTimeFormatWA(MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
  549.                 TIME_FORCE24HOURFORMAT, pt, NULL, s, 80);
  550.             p = s;
  551.             while(*p) *dp++ = *p++;
  552.             sp += 4;
  553.         }
  554.         else
  555.         {
  556.             p = CharNext(sp);
  557.             while(sp != p) *dp++ = *sp++;
  558.         }
  559.     }
  560.     *dp = 0;
  561. }
  562.  
  563. /*------------------------------------------------
  564.   check format
  565. --------------------------------------------------*/
  566. BOOL FindFormatStr(const char* fmt, const char *tofind)
  567. {
  568.     const char *sp;
  569.     
  570.     sp = fmt;
  571.     while(*sp)
  572.     {
  573.         if(*sp == '\"')
  574.         {
  575.             sp++;
  576.             while(*sp != '\"' && *sp) sp++;
  577.             if(*sp == '\"') sp++;
  578.         }
  579.         else if(*sp == *tofind)
  580.         {
  581.             while(*tofind)
  582.             {
  583.                 if(*sp != *tofind) break;
  584.                 sp++; tofind++;
  585.             }
  586.             if(*tofind == 0) return TRUE;
  587.         }
  588.         else sp = CharNext(sp);
  589.     }
  590.     return FALSE;
  591. }
  592.  
  593. /*------------------------------------------------
  594.   need to display second?
  595. --------------------------------------------------*/
  596. BOOL IsDispSecond(char* fmt)
  597. {
  598.     char *sp;
  599.     
  600.     sp = fmt;
  601.     while(*sp)
  602.     {
  603.         if(*sp == '\"')
  604.         {
  605.             sp++;
  606.             while(*sp != '\"' && *sp) sp++;
  607.             if(*sp == '\"') sp++;
  608.         }
  609.         else if(*sp == 's')
  610.         {
  611.             return TRUE;
  612.         }
  613.         else sp = CharNext(sp);
  614.     }
  615.     return FALSE;
  616. }
  617.  
  618. /*------------------------------------------------
  619.   need to display system information?
  620. --------------------------------------------------*/
  621. BOOL IsDispSysInfo(char* fmt)
  622. {
  623.     char *sp;
  624.     
  625.     sp = fmt;
  626.     while(*sp)
  627.     {
  628.         if(*sp == '\"')
  629.         {
  630.             sp++;
  631.             while(*sp != '\"' && *sp) sp++;
  632.             if(*sp == '\"') sp++;
  633.         }
  634.         else if(*sp == 'R' && 
  635.             (*(sp + 1) == 'S' || *(sp + 1) == 'G' || *(sp + 1) == 'U') )
  636.         {
  637.             return TRUE;
  638.         }
  639.         else if(*sp == 'C' && *(sp + 1) == 'U')
  640.         {
  641.             return TRUE;
  642.         }
  643.         else sp = CharNext(sp);
  644.     }
  645.     return FALSE;
  646. }
  647.  
  648. /*------------------------------------------------
  649.   need to display beats?
  650. --------------------------------------------------*/
  651. int IsDispBeat(char* fmt)
  652. {
  653.     char *sp;
  654.     
  655.     sp = fmt;
  656.     while(*sp)
  657.     {
  658.         if(*sp == '\"')
  659.         {
  660.             sp++;
  661.             while(*sp != '\"' && *sp) sp++;
  662.             if(*sp == '\"') sp++;
  663.         }
  664.         else if (*sp == '@' && *(sp + 1) == '@' && *(sp + 2) == '@')
  665.         {
  666.             sp += 3;
  667.             if(*sp == '.' && *(sp + 1) == '@')
  668.                 return 2;
  669.             return 1;
  670.         }
  671.         else sp = CharNext(sp);
  672.     }
  673.     return 0;
  674. }
  675.