| 1 | #ifndef EASYFC2_H |
|---|
| 2 | #define EASYFC2_H |
|---|
| 3 | |
|---|
| 4 | /* ---------------------------------------------------------------- EASYFC.H */ |
|---|
| 5 | |
|---|
| 6 | /* ----------------------------------------------------------------- defines */ |
|---|
| 7 | #ifndef BOOLEAN |
|---|
| 8 | #define BOOLEAN int |
|---|
| 9 | #endif |
|---|
| 10 | |
|---|
| 11 | #ifndef TRUE |
|---|
| 12 | #define TRUE 1 |
|---|
| 13 | #endif |
|---|
| 14 | |
|---|
| 15 | #ifndef FALSE |
|---|
| 16 | #define FALSE 0 |
|---|
| 17 | #endif |
|---|
| 18 | |
|---|
| 19 | #ifndef O_TEXT |
|---|
| 20 | #define O_TEXT 0 |
|---|
| 21 | #endif |
|---|
| 22 | |
|---|
| 23 | #ifndef O_BINARY |
|---|
| 24 | #define O_BINARY 0 |
|---|
| 25 | #endif |
|---|
| 26 | |
|---|
| 27 | /* File access modes used with open() and fcntl() */ |
|---|
| 28 | /* Copy of fcntl.h */ |
|---|
| 29 | #ifndef O_RDONLY |
|---|
| 30 | #define O_RDONLY 0000000 /* Open for reading only */ |
|---|
| 31 | #endif |
|---|
| 32 | #ifndef O_WRONLY |
|---|
| 33 | #define O_WRONLY 0000001 /* Open for writing only */ |
|---|
| 34 | #endif |
|---|
| 35 | #ifndef O_RDWR |
|---|
| 36 | #define O_RDWR 0000002 /* Open for reading or writing */ |
|---|
| 37 | #endif |
|---|
| 38 | #ifndef O_ACCMODE |
|---|
| 39 | #define O_ACCMODE 0000003 /* Mask for file access modes */ |
|---|
| 40 | #endif |
|---|
| 41 | |
|---|
| 42 | #ifndef O_DENYNONE |
|---|
| 43 | #define O_DENYNONE 0 |
|---|
| 44 | #endif |
|---|
| 45 | |
|---|
| 46 | #ifndef KBYTE |
|---|
| 47 | #define KBYTE 1024L |
|---|
| 48 | #endif |
|---|
| 49 | |
|---|
| 50 | #ifndef EFC_ERROR_INFO_MAX |
|---|
| 51 | #define EFC_ERROR_INFO_MAX 60 |
|---|
| 52 | #endif |
|---|
| 53 | /* ------------------------------------------------------------- enumaration */ |
|---|
| 54 | typedef enum { |
|---|
| 55 | FILE_ERROR_EMPTY, |
|---|
| 56 | FILE_ERROR_SIZE, |
|---|
| 57 | FILE_ERROR_OPEN, |
|---|
| 58 | FILE_ERROR_ALLOC, |
|---|
| 59 | FILE_ERROR_READ, |
|---|
| 60 | FILE_ERROR_LIST_QTT |
|---|
| 61 | } EFC_FILE_ERROR_LIST; /* file error */ |
|---|
| 62 | |
|---|
| 63 | typedef enum { |
|---|
| 64 | COPYFILE_ERROR_OK, |
|---|
| 65 | COPYFILE_ERROR_IN_OPEN, |
|---|
| 66 | COPYFILE_ERROR_OUT_OPEN, |
|---|
| 67 | COPYFILE_ERROR_LIST_QTT |
|---|
| 68 | } COPYFILE_ERROR; /* file copy error */ |
|---|
| 69 | |
|---|
| 70 | typedef enum { |
|---|
| 71 | NUMBERLIST_ERROR_OK, |
|---|
| 72 | NUMBERLIST_ERROR_ALLOC, |
|---|
| 73 | NUMBERLIST_ERROR_LIST_QTT |
|---|
| 74 | } EFC_NUMBERLIST_ERROR_LIST; /* number list error */ |
|---|
| 75 | /* --------------------------------------------------------------- structure */ |
|---|
| 76 | typedef struct { |
|---|
| 77 | int code; |
|---|
| 78 | char info[EFC_ERROR_INFO_MAX+1]; |
|---|
| 79 | } EFC_ERROR; /* error */ |
|---|
| 80 | |
|---|
| 81 | typedef struct { |
|---|
| 82 | char *text; |
|---|
| 83 | } EFC_LINE; |
|---|
| 84 | |
|---|
| 85 | typedef struct { |
|---|
| 86 | long qtt; |
|---|
| 87 | EFC_LINE *list; |
|---|
| 88 | } EFC_SPLIT_LINES; |
|---|
| 89 | |
|---|
| 90 | typedef struct { |
|---|
| 91 | long qtt; |
|---|
| 92 | long *list; |
|---|
| 93 | } EFC_NUMBER_LIST; |
|---|
| 94 | |
|---|
| 95 | typedef struct { |
|---|
| 96 | char fname[160]; |
|---|
| 97 | char *buffer; |
|---|
| 98 | } EFC_BUFFER; |
|---|
| 99 | |
|---|
| 100 | /* --------------------------------------------------------------- prototype */ |
|---|
| 101 | |
|---|
| 102 | long efc_filesize(int handle); |
|---|
| 103 | |
|---|
| 104 | char *efc_filecontents_return(char *buff, /* return buffer */ |
|---|
| 105 | long *qttbytes, /* file size in bytes on success, negative code on error */ |
|---|
| 106 | int error_code); /* error code */ |
|---|
| 107 | |
|---|
| 108 | void *efc_free(void *buff); /* original string buffer */ |
|---|
| 109 | |
|---|
| 110 | void *efc_new(long mem_size); /* buffer size, in bytes */ |
|---|
| 111 | |
|---|
| 112 | long efc_split_lines_char(EFC_SPLIT_LINES *split_lines, /* split lines structure */ |
|---|
| 113 | char *text, /* text to be splited */ |
|---|
| 114 | char char_sep); /* separator character */ |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | long efc_split_lines_char(EFC_SPLIT_LINES *split_lines, /* split lines structure */ |
|---|
| 118 | char *text, /* text to be splited */ |
|---|
| 119 | char char_sep); /* separator character */ |
|---|
| 120 | |
|---|
| 121 | void efc_split_lines_free(EFC_SPLIT_LINES *split_lines); /* split lines structure */ |
|---|
| 122 | |
|---|
| 123 | long efc_numberList(EFC_ERROR *err, /* error structure */ |
|---|
| 124 | EFC_NUMBER_LIST *numberList, /* store number list */ |
|---|
| 125 | char *text); /* text to be splited */ |
|---|
| 126 | |
|---|
| 127 | void efc_numberListFree(EFC_NUMBER_LIST *numberList); /* number list */ |
|---|
| 128 | |
|---|
| 129 | char *efc_std_filecontent(EFC_ERROR *err, /* error structure */ |
|---|
| 130 | char *file_name); /* file name */ |
|---|
| 131 | |
|---|
| 132 | char *efc_strrepl(char *old, /* current string buffer content */ |
|---|
| 133 | char *from); /* new string buffer content */ |
|---|
| 134 | |
|---|
| 135 | char *efc_trim_right (); |
|---|
| 136 | COPYFILE_ERROR efc_copyFile(); |
|---|
| 137 | |
|---|
| 138 | char *efc_trim_right(char *buff); /* string buffer to be trimed */ |
|---|
| 139 | |
|---|
| 140 | COPYFILE_ERROR efc_copyFile(unsigned char *fileNameIn, |
|---|
| 141 | unsigned char *fileNameOut); |
|---|
| 142 | |
|---|
| 143 | long efc_split_lines(EFC_SPLIT_LINES *split_lines, /* split lines structure */ |
|---|
| 144 | char *text); /* text to be splited */ |
|---|
| 145 | |
|---|
| 146 | #ifdef XIS_SERVER |
|---|
| 147 | char * efc_load_buffer(char *fileName, |
|---|
| 148 | long *qttbytes); |
|---|
| 149 | |
|---|
| 150 | void efc_delete_buffer(); |
|---|
| 151 | #endif |
|---|
| 152 | |
|---|
| 153 | #endif /* EASYFC2_H */ |
|---|