indep.h (2842B)
1 /* $Id$ */ 2 #ifndef INDEP_H 3 #define INDEP_H 4 #include <gc.h> 5 #include "Str.h" 6 #include "config.h" 7 8 #ifndef TRUE 9 #define TRUE 1 10 #endif /* TRUE */ 11 #ifndef FALSE 12 #define FALSE 0 13 #endif /* FALSE */ 14 15 #define RAW_MODE 0 16 #define PAGER_MODE 1 17 #define HTML_MODE 2 18 #define HEADER_MODE 3 19 20 extern unsigned char QUOTE_MAP[]; 21 extern char *HTML_QUOTE_MAP[]; 22 #define HTML_QUOTE_MASK 0x07 /* &, <, >, " */ 23 #define SHELL_UNSAFE_MASK 0x08 /* [^A-Za-z0-9_./:\200-\377] */ 24 #define URL_QUOTE_MASK 0x10 /* [\0- \177-\377] */ 25 #define FILE_QUOTE_MASK 0x30 /* [\0- #%&+:?\177-\377] */ 26 #define URL_UNSAFE_MASK 0x70 /* [^A-Za-z0-9_$\-.] */ 27 #define GET_QUOTE_TYPE(c) QUOTE_MAP[(int)(unsigned char)(c)] 28 #define is_html_quote(c) (GET_QUOTE_TYPE(c) & HTML_QUOTE_MASK) 29 #define is_shell_unsafe(c) (GET_QUOTE_TYPE(c) & SHELL_UNSAFE_MASK) 30 #define is_url_quote(c) (GET_QUOTE_TYPE(c) & URL_QUOTE_MASK) 31 #define is_file_quote(c) (GET_QUOTE_TYPE(c) & FILE_QUOTE_MASK) 32 #define is_url_unsafe(c) (GET_QUOTE_TYPE(c) & URL_UNSAFE_MASK) 33 #define html_quote_char(c) HTML_QUOTE_MAP[(int)is_html_quote(c)] 34 35 extern clen_t strtoclen(const char *s); 36 extern char *conv_entity(unsigned int ch); 37 extern int getescapechar(char **s); 38 extern char *getescapecmd(char **s); 39 extern char *allocStr(const char *s, int len); 40 extern int strCmp(const void *s1, const void *s2); 41 extern char *currentdir(void); 42 extern char *cleanupName(char *name); 43 extern char *expandPath(char *name); 44 #ifndef HAVE_STRCHR 45 extern char *strchr(const char *s, int c); 46 #endif /* not HAVE_STRCHR */ 47 #ifndef HAVE_STRCASECMP 48 extern int strcasecmp(const char *s1, const char *s2); 49 extern int strncasecmp(const char *s1, const char *s2, size_t n); 50 #endif /* not HAVE_STRCASECMP */ 51 #ifndef HAVE_STRCASESTR 52 extern char *strcasestr(const char *s1, const char *s2); 53 #endif 54 extern int strcasemstr(char *str, char *srch[], char **ret_ptr); 55 extern char *remove_space(char *str); 56 extern int non_null(char *s); 57 extern void cleanup_line(Str s, int mode); 58 extern char *html_quote(char *str); 59 extern char *html_unquote(char *str); 60 extern char *file_quote(char *str); 61 extern char *file_unquote(char *str); 62 extern char *url_quote(char *str); 63 extern Str Str_url_unquote(Str x, int is_form, int safe); 64 extern Str Str_form_quote(Str x); 65 #define Str_form_unquote(x) Str_url_unquote((x), TRUE, FALSE) 66 extern char *shell_quote(char *str); 67 68 extern char *w3m_auxbin_dir(); 69 extern char *w3m_lib_dir(); 70 extern char *w3m_etc_dir(); 71 extern char *w3m_conf_dir(); 72 extern char *w3m_help_dir(); 73 74 #define New(type) ((type*)GC_MALLOC(sizeof(type))) 75 #define NewAtom(type) ((type*)GC_MALLOC_ATOMIC(sizeof(type))) 76 #define New_N(type,n) ((type*)GC_MALLOC((n)*sizeof(type))) 77 #define NewAtom_N(type,n) ((type*)GC_MALLOC_ATOMIC((n)*sizeof(type))) 78 #define New_Reuse(type,ptr,n) ((type*)GC_REALLOC((ptr),(n)*sizeof(type))) 79 80 #endif /* INDEP_H */