Annotation of parser3/src/include/pa_common.h, revision 1.19

1.15      paf         1: /** @file
1.16      paf         2:        Parser: commonly used functions.
                      3: 
1.4       paf         4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.16      paf         5: 
1.5       paf         6:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.4       paf         7: 
1.19    ! paf         8:        $Id: pa_common.h,v 1.18 2001/03/20 06:45:18 paf Exp $
1.1       paf         9: */
                     10: 
                     11: #ifndef PA_COMMON_H
                     12: #define PA_COMMON_H
                     13: 
1.14      paf        14: #ifdef HAVE_CONFIG_H
                     15: #      include "pa_config.h"
                     16: #endif
1.11      paf        17: 
1.17      paf        18: #ifdef WIN32
                     19: #      include <sys/locking.h>
                     20: #endif
                     21: 
                     22: #include <stdio.h>
1.1       paf        23: #include <stdarg.h>
1.2       paf        24: #include "pa_pool.h"
1.1       paf        25: 
1.14      paf        26: class String;
                     27: class Value;
1.11      paf        28: 
1.1       paf        29: #ifdef WIN32
1.12      paf        30: 
                     31: #define open _open
                     32: #define close _close
                     33: #define read _read
                     34: #define stat _stat
                     35: 
1.1       paf        36: #define vsnprintf __vsnprintf 
                     37: #define snprintf __snprintf
                     38: 
                     39: int __vsnprintf(char *, size_t, const char *, va_list);
                     40: int __snprintf(char *, size_t, const char *, ...);
1.11      paf        41: 
1.17      paf        42: //flock
                     43: #define LOCK_EX _LK_NBLCK
                     44: #define LOCK_UN _LK_UNLCK
                     45: void flock(int fd, int operation);
                     46: 
                     47: //access
                     48: #define F_OK 0
                     49: #define X_OK 1
                     50: #define W_OK 2
                     51: #define R_OK 4
                     52: 
                     53: #define strcasecmp _stricmp
                     54: #define strncasecmp _strnicmp
                     55: #define mkdir(path, mode) _mkdir(path)
                     56: 
                     57: #define putenv _putenv
                     58: 
1.1       paf        59: #endif
1.2       paf        60: 
1.17      paf        61: /// @todo define it
                     62: #ifdef SUN
                     63: //flock
                     64: #define LOCK_EX F_LOCK
                     65: #define LOCK_UN F_ULOCK
                     66: void flock(int fd, int operation);
                     67: #endif
                     68: 
                     69: /// @todo use somewhere
                     70: void lock(FILE *f, long position);
                     71: /// @todo use somewhere
                     72: void unlock(FILE *f);
                     73: 
1.15      paf        74: /**
1.19    ! paf        75:        read specified text file using pool, 
1.15      paf        76:        if fail_on_read_problem is true[default] throws an exception
                     77: */
1.19    ! paf        78: char *file_read_text(Pool& pool, 
        !            79:                                         const char *fname, 
        !            80:                                         bool fail_on_read_problem=true);
1.17      paf        81: 
                     82: /**
                     83:        write data to specified file using pool, 
                     84:        throws an exception in case of problems
                     85: */
                     86: void file_write(Pool& pool, 
                     87:                                const char *fname,
                     88:                                const char *data, size_t size, 
1.19    ! paf        89:                                bool as_text,
1.17      paf        90:                                bool exclusive=false);
1.15      paf        91: 
                     92: /**
1.18      paf        93:        scans for @a delim[default \n] in @a *row_ref, 
                     94:        @return piece of line before it or end of string, if no @a delim found
                     95:        assigns @a *row_ref to point right after delimiter if there were one
                     96:        or to zero if no @a delim were found.
1.15      paf        97: */
1.7       paf        98: char *getrow(char **row_ref,char delim='\n');
                     99: //char *lsplit(char *,char);
                    100: char *lsplit(char **string_ref,char delim);
1.8       paf       101: char *rsplit(char *string, char delim);
1.9       paf       102: char *format(Pool& pool, double value, char *fmt);
1.10      paf       103: 
                    104: #ifndef max
                    105: inline int max(int a,int b) { return a>b?a:b; }
                    106: inline int min(int a,int b){ return a<b?a:b; }
                    107: #endif
                    108: 
1.13      paf       109: size_t stdout_write(const char *buf, size_t size);
1.14      paf       110: 
                    111: const char *unescape_chars(Pool& pool, const char *cp, int len);
                    112: 
                    113: const String& attributed_meaning_string(Value *meaning);
1.1       paf       114: 
                    115: #endif

E-mail: