Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

common.h

Go to the documentation of this file.
00001 
00005 #ifndef FISH_COMMON_H
00006 
00009 #define FISH_COMMON_H
00010 
00011 #include <stdlib.h>
00012 #include <stdio.h>
00013 #include <wchar.h>
00014 #include <termios.h>
00015 
00016 #include "util.h"
00017 
00021 #define MAX_UTF8_BYTES 6
00022 
00026 #define ENCODE_DIRECT_BASE 0xf100
00027 
00031 #define ASCII_MAX 127u
00032 
00036 #define UCS2_MAX 0xffffu
00037 
00041 #define BYTE_MAX 0xffu
00042 
00043 /*
00044   Escape special fish syntax characters liek the semicolon
00045  */
00046 #define UNESCAPE_SPECIAL 1
00047 /*
00048   Allow incomplete escape sequences
00049  */
00050 #define UNESCAPE_INCOMPLETE 2
00051 
00055 #define ESCAPE_ALL 1
00056 
00059 #define ESCAPE_NO_QUOTED 2
00060 
00061 
00065 extern struct termios shell_modes;      
00066 
00071 extern wchar_t ellipsis_char;
00072 
00077 extern int debug_level;
00078 
00082 extern char *profile;
00083 
00088 extern wchar_t *program_name;
00089 
00096 #define CHECK( arg, retval )                                                                                    \
00097         if( !(arg) )                                                                                                            \
00098         {                                                                                                                                       \
00099                 debug( 0,                                                                                                               \
00100                            _( L"function %s called with null value for argument %s. " ), \
00101                            __func__,                                                                                            \
00102                            #arg );                                                                                                      \
00103                 bugreport();                                                                                                    \
00104                 show_stackframe();                                                                                              \
00105                 return retval;                                                                                                  \
00106         }
00107 
00111 #define FATAL_EXIT()                                                    \
00112         {                                                                                       \
00113                 char c;                                                                 \
00114                 show_stackframe();                                              \
00115                 read( 0, &c, 1 );                                               \
00116                 exit( 1 );                                                              \
00117         }                                                                                       \
00118                 
00119 
00123 #define DIE_MEM()                                                                                                               \
00124         {                                                                                                                                       \
00125                 fwprintf( stderr,                                                                                               \
00126                                   L"fish: Out of memory on line %d of file %s, shutting down fish\n", \
00127                                   __LINE__,                                                                                             \
00128                                   __FILE__ );                                                                                   \
00129                 FATAL_EXIT();                                                                                                           \
00130         }
00131 
00136 #define CHECK_BLOCK( retval )                                                                                   \
00137         if( signal_is_blocked() )                                                                                       \
00138         {                                                                                                                                       \
00139                 debug( 0,                                                                                                               \
00140                            _( L"function %s called while blocking signals. " ),         \
00141                            __func__);                                                                                           \
00142                 bugreport();                                                                                                    \
00143                 show_stackframe();                                                                                              \
00144                 return retval;                                                                                                  \
00145         }
00146                 
00150 #define _(wstr) wgettext(wstr)
00151 
00156 #define N_(wstr) wstr
00157 
00158 #define contains( str,... ) contains_internal( str, __VA_ARGS__, (void *)0 )
00159 #define wcsdupcat( str,... ) wcsdupcat_internal( str, __VA_ARGS__, (void *)0 )
00160 
00161 /*
00162   Print a stack trace to stderr
00163 */
00164 void show_stackframe();
00165 
00171 wchar_t **list_to_char_arr( array_list_t *l );
00172 
00184 int fgetws2( wchar_t **buff, int *len, FILE *f );
00185 
00190 void sort_list( array_list_t *comp );
00191 
00199 wchar_t *str2wcs( const char *in );
00200 
00209 wchar_t *str2wcs_internal( const char *in, wchar_t *out );
00210 
00218 char *wcs2str( const wchar_t *in );
00219 
00228 char *wcs2str_internal( const wchar_t *in, char *out );
00229 
00234 char **wcsv2strv( const wchar_t **in );
00235 
00239 wchar_t **strv2wcsv( const char **in );
00240 
00241 
00246 __sentinel wchar_t *wcsdupcat_internal( const wchar_t *a, ... );
00247 
00259 wchar_t *wcsvarname( const wchar_t *str );
00260 
00261 
00268 wchar_t *wcsfuncname( const wchar_t *str );
00269 
00276 int wcsvarchr( wchar_t chr );
00277 
00278 
00282 int my_wcswidth( const wchar_t *c );
00283 
00291 wchar_t *quote_end( const wchar_t *in );
00292 
00301 void error_reset();
00302 
00309 const wchar_t *wsetlocale( int category, const wchar_t *locale );
00310 
00318 __sentinel int contains_internal( const wchar_t *needle, ... );
00319 
00325 int read_blocked(int fd, void *buf, size_t count);
00326 
00327 
00346 void debug( int level, const wchar_t *msg, ... );
00347 
00357 wchar_t *escape( const wchar_t *in, int escape_all );
00358 
00370 wchar_t *unescape( const wchar_t * in, 
00371                                    int escape_special );
00372 
00382 int acquire_lock_file( const char *lockfile, const int timeout, int force );
00383 
00391 int common_get_width();
00399 int common_get_height();
00400 
00406 void common_handle_winch( int signal );
00407 
00412 void write_screen( const wchar_t *msg, string_buffer_t *buff );
00413 
00422 void tokenize_variable_array( const wchar_t *val, array_list_t *out );
00423 
00430 int create_directory( wchar_t *d );
00431 
00435 void bugreport();
00436 
00440 void sb_format_size( string_buffer_t *sb,
00441                      long long sz );
00442 
00443 #endif
00444 

Generated on Sun Jan 13 02:52:28 2008 for fish by  doxygen 1.4.4