1 /*************************************************************************** 2 * Pinfo is a ncurses based lynx style info documentation browser 3 * 4 * Copyright (C) 1999 Przemek Borys <pborys@dione.ids.pl> 5 * Copyright (C) 2005 Bas Zoetekouw <bas@debian.org> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of version 2 of the GNU General Public License as 9 * published by the Free Software Foundation. 10 * 11 * This program is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 19 * USA 20 ***************************************************************************/ 21 22 #ifndef __UTILS_H 23 #define __UTILS_H 24 25 extern char *safe_user; 26 extern char *safe_group; 27 28 #ifndef HAVE_DECL_CURS_SET 29 void curs_set (int a); 30 #endif 31 32 #ifdef ___DONT_USE_REGEXP_SEARCH___ 33 extern char *pinfo_re_pattern; 34 #endif 35 36 /* wrappers for re_comp and re_exec */ 37 int pinfo_re_comp (char *name); 38 int pinfo_re_exec (char *name); 39 40 /* user defined getch, capable of handling ALT keybindings */ 41 int pinfo_getch (); 42 /* free() wrapper */ 43 void xfree (void *ptr); 44 /* malloc() wrapper */ 45 void *xmalloc (size_t size); 46 /* realloc() wrapper */ 47 void *xrealloc (void *ptr, size_t size); 48 /* system(), but return sane error code */ 49 int system_check(const char *command); 50 /* safe, error-checking, command execution */ 51 void xsystem(const char *command); 52 /* initializes GNU locales */ 53 void initlocale (); 54 /* checks if file name does not cause secuirity problems */ 55 void checkfilename (char *filename); 56 /* closes the program, and removes temporary files */ 57 void closeprogram (); 58 /* initializes curses interface */ 59 void init_curses (); 60 /* an interface to gnu readline */ 61 char *getstring (char *prompt); 62 char *getstring_with_completion (char *prompt, const char * const *completions); 63 /* create a completion table from a tag_table */ 64 const char ** completions_from_tag_table(TagTable * table, size_t num); 65 /* for some reasons mvhline does not work quite properly... */ 66 void mymvhline (int y, int x, char ch, int len); 67 /* this one supports color back/foreground */ 68 void myclrtoeol (); 69 /* takes care of the cursor, which is turned off */ 70 void myendwin (); 71 /* ? */ 72 void handlewinch (); 73 /* get offset of "node" in tag_table variable */ 74 int gettagtablepos (char *node); 75 76 /* handle localized `(y/n)' dialog box. */ 77 int yesno (char *prompt, int def); 78 /* copies the first part of string, which is without regexp */ 79 void copy_stripped_from_regexp (char *src, char *dest); 80 81 82 /* Block until something's on STDIN */ 83 void waitforgetch (); 84 85 /* is curses screen open? */ 86 extern int curses_open; 87 88 /* 89 * this functions checks whether the node header node_header 90 * corresponds to node node_name 91 * 92 * returns 0 if node_header does not belong to a node with name node_name 93 * returns -1 if no checking was done (e.g. because node_name was NULL) 94 * returns 1 if check turned out ok 95 */ 96 int 97 check_node_name( const char * const node_name, const char * const node_header); 98 99 100 /* calculate width of string, handling multibyte encodings 101 * correctly */ 102 int 103 width_of_string( const char * const mbs, const int len); 104 105 /* 106 * calculates the length of string between start and end, counting `\t' as 107 * filling up to 8 chars. (i.e. at line 22 tab will increment the counter by 2 108 * [8-(22-int(22/8)*8)] spaces) 109 */ 110 int 111 calculate_len(char *start, char *end); 112 113 /* 114 * * create a temporary file in a safe way, and return its name in a newly 115 * * allocated string 116 * */ 117 char * 118 make_tempfile(); 119 120 121 #endif 122