home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1999 October / VPR9910A.BIN / OLS / unrar32005 / unrar32005.lzh / src / util.h < prev   
C/C++ Source or Header  |  1998-04-03  |  2KB  |  89 lines

  1. /*
  2.  *   Copyright (c) 1998 T. Kamei (kamei@jsdlab.co.jp)
  3.  *
  4.  *   Permission to use, copy, modify, and distribute this software
  5.  * and its documentation for any purpose is hereby granted provided
  6.  * that the above copyright notice and this permission notice appear
  7.  * in all copies of the software and related documentation.
  8.  *
  9.  *                          NO WARRANTY
  10.  *
  11.  *   THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY WARRANTIES;
  12.  * WITHOUT EVEN THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS
  13.  * FOR A PARTICULAR PURPOSE.
  14.  */
  15.  
  16. #ifndef _util_h_
  17. # define _util_h_
  18.  
  19. #ifndef EXTERN
  20. #define EXTERN extern
  21. #endif
  22.  
  23. EXTERN u_char translate_table[256];
  24. #define translate(c) (translate_table[(c) & 0xff])
  25.  
  26. EXTERN u_char mblead_table[256];
  27. #define iskanji(c) (mblead_table[(c) & 0xff])
  28.  
  29. struct lib_state
  30. {
  31.   HINSTANCE hinst;
  32.   HINSTANCE hrardll;
  33.   int s_bg_mode;
  34.   int s_cursor_mode;
  35.   int s_cursor_interval;
  36.   HWND hwnd_owner;
  37.   LPARCHIVERPROC callback;
  38. };
  39.  
  40. EXTERN lib_state lstate;
  41.  
  42. class cmdline
  43. {
  44.   int cl_ac;
  45.   char **cl_av;
  46.   int cl_max;
  47.  
  48.   static char *copyarg (const u_char *, const u_char *, int);
  49.   void discard ();
  50. public:
  51.   cmdline () : cl_ac (0), cl_av (0), cl_max (0) {}
  52.   ~cmdline () {discard ();}
  53.   int parse (const char *, int, int);
  54.   int parse (const char *s, int r) {return parse (s, s ? strlen (s) : 0, r);}
  55.   int argc () const {return cl_ac;}
  56.   char **argv () const {return cl_av;}
  57. };
  58.  
  59. class glob
  60. {
  61.   int g_npat;
  62.   char **g_pat;
  63.  
  64.   static int match (const char *, const char *);
  65. public:
  66.   glob () : g_npat (0) {}
  67.   int match (const char *, int) const;
  68.   void set_pattern (int ac, char **av) {g_npat = ac; g_pat = av;}
  69. };
  70.  
  71. class ostrbuf
  72. {
  73.   char *os_buf;
  74.   int os_size;
  75. public:
  76.   ostrbuf (char *b, int size) : os_buf (b), os_size (b ? size : 0) {}
  77.   int format (const char *, ...);
  78.   int formatv (const char *, va_list);
  79.   int space () const {return os_size - 1;}
  80. };
  81.  
  82. void init_table ();
  83. char *find_last_slash (const char *);
  84. char *find_slash (const char *);
  85. char *stpcpy (char *, const char *);
  86. char *trim_root (const char *);
  87.  
  88. #endif
  89.