| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
#ifndef PICOINTERNAL_H |
|---|
| 39 |
#define PICOINTERNAL_H |
|---|
| 40 |
|
|---|
| 41 |
#ifdef __cplusplus |
|---|
| 42 |
extern "C" |
|---|
| 43 |
{ |
|---|
| 44 |
#endif |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
#include <stdio.h> |
|---|
| 49 |
#include <stdlib.h> |
|---|
| 50 |
#include <stdarg.h> |
|---|
| 51 |
#include <string.h> |
|---|
| 52 |
#include <ctype.h> |
|---|
| 53 |
#include <math.h> |
|---|
| 54 |
|
|---|
| 55 |
#include "picomodel.h" |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
#if WIN32 || _WIN32 |
|---|
| 60 |
#define _pico_stricmp stricmp |
|---|
| 61 |
#define _pico_strnicmp strnicmp |
|---|
| 62 |
#else |
|---|
| 63 |
#define _pico_stricmp strcasecmp |
|---|
| 64 |
#define _pico_strnicmp strncasecmp |
|---|
| 65 |
#endif |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
#define PICO_PI 3.14159265358979323846 |
|---|
| 70 |
|
|---|
| 71 |
#define PICO_SEEK_SET 0 |
|---|
| 72 |
#define PICO_SEEK_CUR 1 |
|---|
| 73 |
#define PICO_SEEK_END 2 |
|---|
| 74 |
|
|---|
| 75 |
#define PICO_IOEOF 1 |
|---|
| 76 |
#define PICO_IOERR 2 |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
typedef struct picoParser_s |
|---|
| 80 |
{ |
|---|
| 81 |
char *buffer; |
|---|
| 82 |
int bufSize; |
|---|
| 83 |
char *token; |
|---|
| 84 |
int tokenSize; |
|---|
| 85 |
int tokenMax; |
|---|
| 86 |
char *cursor; |
|---|
| 87 |
char *max; |
|---|
| 88 |
int curLine; |
|---|
| 89 |
} |
|---|
| 90 |
picoParser_t; |
|---|
| 91 |
|
|---|
| 92 |
typedef struct picoMemStream_s |
|---|
| 93 |
{ |
|---|
| 94 |
picoByte_t *buffer; |
|---|
| 95 |
int bufSize; |
|---|
| 96 |
picoByte_t *curPos; |
|---|
| 97 |
int flag; |
|---|
| 98 |
} |
|---|
| 99 |
picoMemStream_t; |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
extern const picoModule_t *picoModules[]; |
|---|
| 104 |
|
|---|
| 105 |
extern void *(*_pico_ptr_malloc)( size_t ); |
|---|
| 106 |
extern void (*_pico_ptr_free)( void* ); |
|---|
| 107 |
extern void (*_pico_ptr_load_file)( char*, unsigned char**, int* ); |
|---|
| 108 |
extern void (*_pico_ptr_free_file)( void* ); |
|---|
| 109 |
extern void (*_pico_ptr_print)( int, const char* ); |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
void *_pico_alloc( size_t size ); |
|---|
| 117 |
void *_pico_calloc( size_t num, size_t size ); |
|---|
| 118 |
void *_pico_realloc( void **ptr, size_t oldSize, size_t newSize ); |
|---|
| 119 |
char *_pico_clone_alloc( char *str, int size ); |
|---|
| 120 |
void _pico_free( void *ptr ); |
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
void _pico_load_file( char *name, unsigned char **buffer, int *bufSize ); |
|---|
| 124 |
void _pico_free_file( void *buffer ); |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
char *_pico_strltrim( char *str ); |
|---|
| 128 |
char *_pico_strrtrim( char *str ); |
|---|
| 129 |
int _pico_strchcount( char *str, int ch ); |
|---|
| 130 |
void _pico_printf( int level, const char *format, ... ); |
|---|
| 131 |
char *_pico_stristr( char *str, const char *substr ); |
|---|
| 132 |
void _pico_unixify( char *path ); |
|---|
| 133 |
int _pico_nofname( const char *path, char *dest, int destSize ); |
|---|
| 134 |
char *_pico_nopath( const char *path ); |
|---|
| 135 |
char *_pico_setfext( char *path, const char *ext ); |
|---|
| 136 |
int _pico_getline( char *buf, int bufsize, char *dest, int destsize ); |
|---|
| 137 |
char *_pico_strlwr( char *str ); |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
void _pico_zero_bounds( picoVec3_t mins, picoVec3_t maxs ); |
|---|
| 141 |
void _pico_expand_bounds( picoVec3_t p, picoVec3_t mins, picoVec3_t maxs ); |
|---|
| 142 |
void _pico_zero_vec( picoVec3_t vec ); |
|---|
| 143 |
void _pico_zero_vec2( picoVec2_t vec ); |
|---|
| 144 |
void _pico_zero_vec4( picoVec4_t vec ); |
|---|
| 145 |
void _pico_set_vec( picoVec3_t v, float a, float b, float c ); |
|---|
| 146 |
void _pico_set_vec4( picoVec4_t v, float a, float b, float c, float d ); |
|---|
| 147 |
void _pico_set_color( picoColor_t c, int r, int g, int b, int a ); |
|---|
| 148 |
void _pico_copy_color( picoColor_t src, picoColor_t dest ); |
|---|
| 149 |
void _pico_copy_vec( picoVec3_t src, picoVec3_t dest ); |
|---|
| 150 |
void _pico_copy_vec2( picoVec2_t src, picoVec2_t dest ); |
|---|
| 151 |
picoVec_t _pico_normalize_vec( picoVec3_t vec ); |
|---|
| 152 |
void _pico_add_vec( picoVec3_t a, picoVec3_t b, picoVec3_t dest ); |
|---|
| 153 |
void _pico_subtract_vec( picoVec3_t a, picoVec3_t b, picoVec3_t dest ); |
|---|
| 154 |
picoVec_t _pico_dot_vec( picoVec3_t a, picoVec3_t b ); |
|---|
| 155 |
void _pico_cross_vec( picoVec3_t a, picoVec3_t b, picoVec3_t dest ); |
|---|
| 156 |
picoVec_t _pico_calc_plane( picoVec4_t plane, picoVec3_t a, picoVec3_t b, picoVec3_t c ); |
|---|
| 157 |
void _pico_scale_vec( picoVec3_t v, float scale, picoVec3_t dest ); |
|---|
| 158 |
void _pico_scale_vec4( picoVec4_t v, float scale, picoVec4_t dest ); |
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
int _pico_big_long( int src ); |
|---|
| 162 |
short _pico_big_short( short src ); |
|---|
| 163 |
float _pico_big_float( float src ); |
|---|
| 164 |
|
|---|
| 165 |
int _pico_little_long( int src ); |
|---|
| 166 |
short _pico_little_short( short src ); |
|---|
| 167 |
float _pico_little_float( float src ); |
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
picoParser_t *_pico_new_parser( picoByte_t *buffer, int bufSize ); |
|---|
| 171 |
void _pico_free_parser( picoParser_t *p ); |
|---|
| 172 |
int _pico_parse_ex( picoParser_t *p, int allowLFs, int handleQuoted ); |
|---|
| 173 |
char *_pico_parse_first( picoParser_t *p ); |
|---|
| 174 |
char *_pico_parse( picoParser_t *p, int allowLFs ); |
|---|
| 175 |
void _pico_parse_skip_rest( picoParser_t *p ); |
|---|
| 176 |
int _pico_parse_skip_braced( picoParser_t *p ); |
|---|
| 177 |
int _pico_parse_check( picoParser_t *p, int allowLFs, char *str ); |
|---|
| 178 |
int _pico_parse_checki( picoParser_t *p, int allowLFs, char *str ); |
|---|
| 179 |
int _pico_parse_int( picoParser_t *p, int *out ); |
|---|
| 180 |
int _pico_parse_int_def( picoParser_t *p, int *out, int def ); |
|---|
| 181 |
int _pico_parse_float( picoParser_t *p, float *out ); |
|---|
| 182 |
int _pico_parse_float_def( picoParser_t *p, float *out, float def ); |
|---|
| 183 |
int _pico_parse_vec( picoParser_t *p, picoVec3_t out); |
|---|
| 184 |
int _pico_parse_vec_def( picoParser_t *p, picoVec3_t out, picoVec3_t def); |
|---|
| 185 |
int _pico_parse_vec2( picoParser_t *p, picoVec2_t out ); |
|---|
| 186 |
int _pico_parse_vec2_def( picoParser_t *p, picoVec2_t out, picoVec2_t def ); |
|---|
| 187 |
int _pico_parse_vec4( picoParser_t *p, picoVec4_t out); |
|---|
| 188 |
int _pico_parse_vec4_def( picoParser_t *p, picoVec4_t out, picoVec4_t def); |
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
picoMemStream_t *_pico_new_memstream( picoByte_t *buffer, int bufSize ); |
|---|
| 192 |
void _pico_free_memstream( picoMemStream_t *s ); |
|---|
| 193 |
int _pico_memstream_read( picoMemStream_t *s, void *buffer, int len ); |
|---|
| 194 |
int _pico_memstream_getc( picoMemStream_t *s ); |
|---|
| 195 |
int _pico_memstream_seek( picoMemStream_t *s, long offset, int origin ); |
|---|
| 196 |
long _pico_memstream_tell( picoMemStream_t *s ); |
|---|
| 197 |
#define _pico_memstream_eof( _pico_memstream ) ((_pico_memstream)->flag & PICO_IOEOF) |
|---|
| 198 |
#define _pico_memstream_error( _pico_memstream ) ((_pico_memstream)->flag & PICO_IOERR) |
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
#ifdef __cplusplus |
|---|
| 202 |
} |
|---|
| 203 |
#endif |
|---|
| 204 |
|
|---|
| 205 |
#endif |
|---|