home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1999 October
/
VPR9910A.BIN
/
OLS
/
unrar32005
/
unrar32005.lzh
/
src
/
util.h
< prev
Wrap
C/C++ Source or Header
|
1998-04-03
|
2KB
|
89 lines
/*
* Copyright (c) 1998 T. Kamei (kamei@jsdlab.co.jp)
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for any purpose is hereby granted provided
* that the above copyright notice and this permission notice appear
* in all copies of the software and related documentation.
*
* NO WARRANTY
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY WARRANTIES;
* WITHOUT EVEN THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS
* FOR A PARTICULAR PURPOSE.
*/
#ifndef _util_h_
# define _util_h_
#ifndef EXTERN
#define EXTERN extern
#endif
EXTERN u_char translate_table[256];
#define translate(c) (translate_table[(c) & 0xff])
EXTERN u_char mblead_table[256];
#define iskanji(c) (mblead_table[(c) & 0xff])
struct lib_state
{
HINSTANCE hinst;
HINSTANCE hrardll;
int s_bg_mode;
int s_cursor_mode;
int s_cursor_interval;
HWND hwnd_owner;
LPARCHIVERPROC callback;
};
EXTERN lib_state lstate;
class cmdline
{
int cl_ac;
char **cl_av;
int cl_max;
static char *copyarg (const u_char *, const u_char *, int);
void discard ();
public:
cmdline () : cl_ac (0), cl_av (0), cl_max (0) {}
~cmdline () {discard ();}
int parse (const char *, int, int);
int parse (const char *s, int r) {return parse (s, s ? strlen (s) : 0, r);}
int argc () const {return cl_ac;}
char **argv () const {return cl_av;}
};
class glob
{
int g_npat;
char **g_pat;
static int match (const char *, const char *);
public:
glob () : g_npat (0) {}
int match (const char *, int) const;
void set_pattern (int ac, char **av) {g_npat = ac; g_pat = av;}
};
class ostrbuf
{
char *os_buf;
int os_size;
public:
ostrbuf (char *b, int size) : os_buf (b), os_size (b ? size : 0) {}
int format (const char *, ...);
int formatv (const char *, va_list);
int space () const {return os_size - 1;}
};
void init_table ();
char *find_last_slash (const char *);
char *find_slash (const char *);
char *stpcpy (char *, const char *);
char *trim_root (const char *);
#endif