picointernal.h File Reference

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include "picomodel.h"
Include dependency graph for picointernal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  picoParser_s
struct  picoMemStream_s

Defines

#define _pico_stricmp   strcasecmp
#define _pico_strnicmp   strncasecmp
#define PICO_PI   3.14159265358979323846
#define PICO_SEEK_SET   0
#define PICO_SEEK_CUR   1
#define PICO_SEEK_END   2
#define PICO_IOEOF   1
#define PICO_IOERR   2
#define _pico_memstream_eof(_pico_memstream)   ((_pico_memstream)->flag & PICO_IOEOF)
#define _pico_memstream_error(_pico_memstream)   ((_pico_memstream)->flag & PICO_IOERR)

Typedefs

typedef struct picoParser_s picoParser_t
typedef struct picoMemStream_s picoMemStream_t

Functions

void * _pico_alloc (size_t size)
 kludged memory allocation wrapper
void * _pico_calloc (size_t num, size_t size)
 _pico_calloc wrapper
void * _pico_realloc (void **ptr, size_t oldSize, size_t newSize)
 memory reallocation wrapper (note: only grows, but never shrinks or frees)
char * _pico_clone_alloc (const char *str)
 handy function for quick string allocation/copy. it clones the given string and returns a pointer to the new allocated clone (which must be freed by caller of course) or returns NULL on memory alloc or param errors. if 'size' is -1 the length of the input string is used, otherwise 'size' is used as custom clone size (the string is cropped to fit into mem if needed). -sea
void _pico_free (void *ptr)
 wrapper around the free function pointer
void _pico_load_file (char *name, unsigned char **buffer, int *bufSize)
 wrapper around the loadfile function pointer
void _pico_free_file (void *buffer)
 wrapper around the file free function pointer
void _pico_first_token (char *str)
char * _pico_strltrim (char *str)
char * _pico_strrtrim (char *str)
int _pico_strchcount (char *str, int ch)
void _pico_printf (int level, const char *format,...)
 wrapper around the print function pointer -sea
const char * _pico_stristr (const char *str, const char *substr)
void _pico_unixify (char *path)
int _pico_nofname (const char *path, char *dest, int destSize)
const char * _pico_nopath (const char *path)
char * _pico_setfext (char *path, const char *ext)
int _pico_getline (char *buf, int bufsize, char *dest, int destsize)
char * _pico_strlwr (char *str)
void _pico_zero_bounds (picoVec3_t mins, picoVec3_t maxs)
void _pico_expand_bounds (picoVec3_t p, picoVec3_t mins, picoVec3_t maxs)
void _pico_zero_vec (picoVec3_t vec)
void _pico_zero_vec2 (picoVec2_t vec)
void _pico_zero_vec4 (picoVec4_t vec)
void _pico_set_vec (picoVec3_t v, float a, float b, float c)
void _pico_set_vec4 (picoVec4_t v, float a, float b, float c, float d)
void _pico_set_color (picoColor_t c, int r, int g, int b, int a)
void _pico_copy_color (picoColor_t src, picoColor_t dest)
void _pico_copy_vec (picoVec3_t src, picoVec3_t dest)
void _pico_copy_vec2 (picoVec2_t src, picoVec2_t dest)
picoVec_t _pico_normalize_vec (picoVec3_t vec)
void _pico_add_vec (picoVec3_t a, picoVec3_t b, picoVec3_t dest)
void _pico_subtract_vec (picoVec3_t a, picoVec3_t b, picoVec3_t dest)
picoVec_t _pico_dot_vec (picoVec3_t a, picoVec3_t b)
void _pico_cross_vec (picoVec3_t a, picoVec3_t b, picoVec3_t dest)
picoVec_t _pico_calc_plane (picoVec4_t plane, picoVec3_t a, picoVec3_t b, picoVec3_t c)
void _pico_scale_vec (picoVec3_t v, float scale, picoVec3_t dest)
void _pico_scale_vec4 (picoVec4_t v, float scale, picoVec4_t dest)
int _pico_big_long (int src)
short _pico_big_short (short src)
float _pico_big_float (float src)
int _pico_little_long (int src)
short _pico_little_short (short src)
float _pico_little_float (float src)
picoParser_t_pico_new_parser (picoByte_t *buffer, int bufSize)
 allocates a new ascii parser object.
void _pico_free_parser (picoParser_t *p)
 frees an existing pico parser object.
int _pico_parse_ex (picoParser_t *p, int allowLFs, int handleQuoted)
 reads the next token from given pico parser object. if param 'allowLFs' is 1 it will read beyond linefeeds and return 0 when the EOF is reached. if 'allowLFs' is 0 it will return 0 when the EOL is reached. if 'handleQuoted' is 1 the parser function will handle "quoted" strings and return the data between the quotes as token. returns 0 on end/error or 1 on success. -sea
char * _pico_parse_first (picoParser_t *p)
 reads the first token from the next line and returns a pointer to it. returns NULL on EOL or EOF. -sea
char * _pico_parse (picoParser_t *p, int allowLFs)
 reads the next token from the parser and returns a pointer to it. quoted strings are handled as usual. returns NULL on EOL or EOF. -sea
void _pico_parse_skip_rest (picoParser_t *p)
 skips the rest of the current line in parser.
int _pico_parse_skip_braced (picoParser_t *p)
 parses/skips over a braced section. returns 1 on success or 0 on error (when there was no closing bracket and the end of buffer was reached or when the opening bracket was missing).
int _pico_parse_check (picoParser_t *p, int allowLFs, char *str)
int _pico_parse_checki (picoParser_t *p, int allowLFs, char *str)
int _pico_parse_int (picoParser_t *p, int *out)
int _pico_parse_int_def (picoParser_t *p, int *out, int def)
int _pico_parse_float (picoParser_t *p, float *out)
int _pico_parse_float_def (picoParser_t *p, float *out, float def)
int _pico_parse_vec (picoParser_t *p, picoVec3_t out)
int _pico_parse_vec_def (picoParser_t *p, picoVec3_t out, picoVec3_t def)
int _pico_parse_vec2 (picoParser_t *p, picoVec2_t out)
int _pico_parse_vec2_def (picoParser_t *p, picoVec2_t out, picoVec2_t def)
int _pico_parse_vec4 (picoParser_t *p, picoVec4_t out)
int _pico_parse_vec4_def (picoParser_t *p, picoVec4_t out, picoVec4_t def)
picoMemStream_t_pico_new_memstream (picoByte_t *buffer, int bufSize)
 allocates a new memorystream object.
void _pico_free_memstream (picoMemStream_t *s)
 frees an existing pico memorystream object.
int _pico_memstream_read (picoMemStream_t *s, void *buffer, int len)
 reads data from a pico memorystream into a buffer.
int _pico_memstream_getc (picoMemStream_t *s)
 reads a character from a pico memorystream
int _pico_memstream_seek (picoMemStream_t *s, long offset, int origin)
 sets the current read position to a different location
long _pico_memstream_tell (picoMemStream_t *s)
 returns the current read position in the pico memorystream

Variables

const picoModule_tpicoModules []
void *(* _pico_ptr_malloc )(size_t)
void(* _pico_ptr_free )(void *)
void(* _pico_ptr_load_file )(char *, unsigned char **, int *)
void(* _pico_ptr_free_file )(void *)
void(* _pico_ptr_print )(int, const char *)

Define Documentation

#define _pico_memstream_eof ( _pico_memstream   )     ((_pico_memstream)->flag & PICO_IOEOF)

Definition at line 188 of file picointernal.h.

#define _pico_memstream_error ( _pico_memstream   )     ((_pico_memstream)->flag & PICO_IOERR)

Definition at line 189 of file picointernal.h.

#define _pico_stricmp   strcasecmp
#define _pico_strnicmp   strncasecmp

Definition at line 60 of file picointernal.h.

Referenced by _ase_load(), and _pico_stristr().

#define PICO_IOEOF   1

Definition at line 70 of file picointernal.h.

Referenced by _pico_memstream_read().

#define PICO_IOERR   2

Definition at line 71 of file picointernal.h.

#define PICO_PI   3.14159265358979323846

Definition at line 64 of file picointernal.h.

Referenced by _md3_load().

#define PICO_SEEK_CUR   1

Definition at line 67 of file picointernal.h.

Referenced by _pico_memstream_seek().

#define PICO_SEEK_END   2

Definition at line 68 of file picointernal.h.

Referenced by _pico_memstream_seek().

#define PICO_SEEK_SET   0

Definition at line 66 of file picointernal.h.

Referenced by _pico_memstream_seek().


Typedef Documentation

typedef struct picoParser_s picoParser_t

Function Documentation

void _pico_add_vec ( picoVec3_t  a,
picoVec3_t  b,
picoVec3_t  dest 
)
void* _pico_alloc ( size_t  size  ) 
float _pico_big_float ( float  src  ) 

Definition at line 540 of file picointernal.c.

References floatSwapUnion::c, and floatSwapUnion::f.

int _pico_big_long ( int  src  ) 

Definition at line 529 of file picointernal.c.

short _pico_big_short ( short  src  ) 

Definition at line 535 of file picointernal.c.

picoVec_t _pico_calc_plane ( picoVec4_t  plane,
picoVec3_t  a,
picoVec3_t  b,
picoVec3_t  c 
)
void* _pico_calloc ( size_t  num,
size_t  size 
)
char* _pico_clone_alloc ( const char *  str  ) 

handy function for quick string allocation/copy. it clones the given string and returns a pointer to the new allocated clone (which must be freed by caller of course) or returns NULL on memory alloc or param errors. if 'size' is -1 the length of the input string is used, otherwise 'size' is used as custom clone size (the string is cropped to fit into mem if needed). -sea

Definition at line 147 of file picointernal.c.

References _pico_alloc().

Referenced by _obj_default_shader(), PicoSetModelFileName(), PicoSetModelName(), PicoSetShaderMapName(), PicoSetShaderName(), and PicoSetSurfaceName().

void _pico_copy_color ( picoColor_t  src,
picoColor_t  dest 
)

Definition at line 473 of file picointernal.c.

Referenced by PicoAddVertexCombinationToHashTable().

void _pico_copy_vec ( picoVec3_t  src,
picoVec3_t  dest 
)
void _pico_copy_vec2 ( picoVec2_t  src,
picoVec2_t  dest 
)
void _pico_cross_vec ( picoVec3_t  a,
picoVec3_t  b,
picoVec3_t  dest 
)

Definition at line 446 of file picointernal.c.

Referenced by _pico_calc_plane(), and _pico_triangles_generate_weighted_normals().

picoVec_t _pico_dot_vec ( picoVec3_t  a,
picoVec3_t  b 
)

Definition at line 441 of file picointernal.c.

Referenced by _pico_calc_plane(), and _pico_normal_within_tolerance().

void _pico_expand_bounds ( picoVec3_t  p,
picoVec3_t  mins,
picoVec3_t  maxs 
)

Definition at line 334 of file picointernal.c.

References i.

Referenced by PicoSetSurfaceXYZ().

void _pico_first_token ( char *  str  ) 

Definition at line 250 of file picointernal.c.

Referenced by _ase_load().

void _pico_free ( void *  ptr  ) 
void _pico_free_file ( void *  buffer  ) 

wrapper around the file free function pointer

Definition at line 204 of file picointernal.c.

References _pico_ptr_free_file.

Referenced by PicoLoadModel(), and PicoModuleLoadModel().

void _pico_free_memstream ( picoMemStream_t s  ) 

frees an existing pico memorystream object.

Definition at line 1188 of file picointernal.c.

References _pico_free().

void _pico_free_parser ( picoParser_t p  ) 

frees an existing pico parser object.

Definition at line 739 of file picointernal.c.

References _pico_free(), and picoParser_s::token.

Referenced by _ase_canload(), _ase_load(), _obj_canload(), and _obj_load().

int _pico_getline ( char *  buf,
int  bufsize,
char *  dest,
int  destsize 
)

Definition at line 674 of file picointernal.c.

References pos.

float _pico_little_float ( float  src  ) 

Definition at line 524 of file picointernal.c.

Referenced by _md2_load(), and _md3_load().

int _pico_little_long ( int  src  ) 

Definition at line 516 of file picointernal.c.

Referenced by _md2_canload(), _md2_load(), _md3_canload(), and _md3_load().

short _pico_little_short ( short  src  ) 

Definition at line 520 of file picointernal.c.

Referenced by _md2_load(), and _md3_load().

void _pico_load_file ( char *  name,
unsigned char **  buffer,
int *  bufSize 
)

wrapper around the loadfile function pointer

Definition at line 185 of file picointernal.c.

References _pico_ptr_load_file.

Referenced by PicoLoadModel().

int _pico_memstream_getc ( picoMemStream_t s  ) 

reads a character from a pico memorystream

Definition at line 1224 of file picointernal.c.

References _pico_memstream_read().

int _pico_memstream_read ( picoMemStream_t s,
void *  buffer,
int  len 
)

reads data from a pico memorystream into a buffer.

Definition at line 1201 of file picointernal.c.

References picoMemStream_s::buffer, picoMemStream_s::bufSize, picoMemStream_s::curPos, picoMemStream_s::flag, and PICO_IOEOF.

Referenced by _pico_memstream_getc().

int _pico_memstream_seek ( picoMemStream_t s,
long  offset,
int  origin 
)

sets the current read position to a different location

Definition at line 1242 of file picointernal.c.

References picoMemStream_s::buffer, picoMemStream_s::bufSize, picoMemStream_s::curPos, PICO_SEEK_CUR, PICO_SEEK_END, and PICO_SEEK_SET.

long _pico_memstream_tell ( picoMemStream_t s  ) 

returns the current read position in the pico memorystream

Definition at line 1282 of file picointernal.c.

References picoMemStream_s::buffer, and picoMemStream_s::curPos.

picoMemStream_t* _pico_new_memstream ( picoByte_t buffer,
int  bufSize 
)

allocates a new memorystream object.

Definition at line 1161 of file picointernal.c.

References _pico_alloc(), picoMemStream_s::buffer, picoMemStream_s::bufSize, picoMemStream_s::curPos, and picoMemStream_s::flag.

picoParser_t* _pico_new_parser ( picoByte_t buffer,
int  bufSize 
)
int _pico_nofname ( const char *  path,
char *  dest,
int  destSize 
)

Definition at line 589 of file picointernal.c.

References left.

const char* _pico_nopath ( const char *  path  ) 

Definition at line 615 of file picointernal.c.

picoVec_t _pico_normalize_vec ( picoVec3_t  vec  ) 

Definition at line 398 of file picointernal.c.

References len.

Referenced by _pico_calc_plane(), and _pico_normals_normalize().

char* _pico_parse ( picoParser_t p,
int  allowLFs 
)

reads the next token from the parser and returns a pointer to it. quoted strings are handled as usual. returns NULL on EOL or EOF. -sea

Definition at line 844 of file picointernal.c.

References _pico_parse_ex(), and picoParser_s::token.

Referenced by _ase_load(), _obj_load(), _pico_parse_float(), _pico_parse_float_def(), _pico_parse_int(), _pico_parse_int_def(), _pico_parse_vec(), _pico_parse_vec2(), _pico_parse_vec2_def(), _pico_parse_vec4(), _pico_parse_vec4_def(), and _pico_parse_vec_def().

int _pico_parse_check ( picoParser_t p,
int  allowLFs,
char *  str 
)

Definition at line 914 of file picointernal.c.

References _pico_parse_ex(), and picoParser_s::token.

Referenced by _ase_load().

int _pico_parse_checki ( picoParser_t p,
int  allowLFs,
char *  str 
)

Definition at line 923 of file picointernal.c.

References _pico_parse_ex(), _pico_stricmp, and picoParser_s::token.

int _pico_parse_ex ( picoParser_t p,
int  allowLFs,
int  handleQuoted 
)

reads the next token from given pico parser object. if param 'allowLFs' is 1 it will read beyond linefeeds and return 0 when the EOF is reached. if 'allowLFs' is 0 it will return 0 when the EOL is reached. if 'handleQuoted' is 1 the parser function will handle "quoted" strings and return the data between the quotes as token. returns 0 on end/error or 1 on success. -sea

Definition at line 760 of file picointernal.c.

References picoParser_s::buffer, picoParser_s::curLine, picoParser_s::cursor, picoParser_s::max, picoParser_s::token, and picoParser_s::tokenSize.

Referenced by _pico_parse(), _pico_parse_check(), _pico_parse_checki(), _pico_parse_first(), _pico_parse_skip_braced(), and _pico_parse_skip_rest().

char* _pico_parse_first ( picoParser_t p  ) 

reads the first token from the next line and returns a pointer to it. returns NULL on EOL or EOF. -sea

Definition at line 825 of file picointernal.c.

References _pico_parse_ex(), and picoParser_s::token.

Referenced by _ase_canload(), _ase_load(), _obj_canload(), and _obj_load().

int _pico_parse_float ( picoParser_t p,
float *  out 
)

Definition at line 970 of file picointernal.c.

References _pico_parse().

Referenced by _ase_load().

int _pico_parse_float_def ( picoParser_t p,
float *  out,
float  def 
)

Definition at line 989 of file picointernal.c.

References _pico_parse().

int _pico_parse_int ( picoParser_t p,
int *  out 
)

Definition at line 932 of file picointernal.c.

References _pico_parse().

Referenced by _ase_load().

int _pico_parse_int_def ( picoParser_t p,
int *  out,
int  def 
)

Definition at line 951 of file picointernal.c.

References _pico_parse().

int _pico_parse_skip_braced ( picoParser_t p  ) 

parses/skips over a braced section. returns 1 on success or 0 on error (when there was no closing bracket and the end of buffer was reached or when the opening bracket was missing).

Definition at line 872 of file picointernal.c.

References _pico_parse_ex(), level, and picoParser_s::token.

void _pico_parse_skip_rest ( picoParser_t p  ) 

skips the rest of the current line in parser.

Definition at line 861 of file picointernal.c.

References _pico_parse_ex().

Referenced by _ase_load(), _obj_canload(), and _obj_load().

int _pico_parse_vec ( picoParser_t p,
picoVec3_t  out 
)

Definition at line 1008 of file picointernal.c.

References _pico_parse(), _pico_zero_vec(), and i.

Referenced by _ase_load(), and _obj_load().

int _pico_parse_vec2 ( picoParser_t p,
picoVec2_t  out 
)

Definition at line 1058 of file picointernal.c.

References _pico_parse(), _pico_zero_vec2(), and i.

Referenced by _obj_load().

int _pico_parse_vec2_def ( picoParser_t p,
picoVec2_t  out,
picoVec2_t  def 
)

Definition at line 1083 of file picointernal.c.

References _pico_copy_vec2(), _pico_parse(), and i.

int _pico_parse_vec4 ( picoParser_t p,
picoVec4_t  out 
)

Definition at line 1108 of file picointernal.c.

References _pico_parse(), _pico_zero_vec4(), and i.

int _pico_parse_vec4_def ( picoParser_t p,
picoVec4_t  out,
picoVec4_t  def 
)

Definition at line 1133 of file picointernal.c.

References _pico_copy_vec4(), _pico_parse(), and i.

int _pico_parse_vec_def ( picoParser_t p,
picoVec3_t  out,
picoVec3_t  def 
)

Definition at line 1033 of file picointernal.c.

References _pico_copy_vec(), _pico_parse(), and i.

void _pico_printf ( int  level,
const char *  format,
  ... 
)

wrapper around the print function pointer -sea

Definition at line 222 of file picointernal.c.

References _pico_ptr_print.

Referenced by _ase_get_submaterial(), _ase_get_submaterial_or_default(), _ase_load(), _md2_load(), _md3_load(), PicoAddTriangleToModel(), PicoLoadModel(), and PicoModuleLoadModelStream().

void* _pico_realloc ( void **  ptr,
size_t  oldSize,
size_t  newSize 
)

memory reallocation wrapper (note: only grows, but never shrinks or frees)

Definition at line 110 of file picointernal.c.

References _pico_alloc(), _pico_free(), and _pico_ptr_malloc.

Referenced by PicoAdjustModel(), PicoAdjustSurface(), and SizeObjVertexData().

void _pico_scale_vec ( picoVec3_t  v,
float  scale,
picoVec3_t  dest 
)

Definition at line 426 of file picointernal.c.

Referenced by PicoVertexCoordGenerateHash().

void _pico_scale_vec4 ( picoVec4_t  v,
float  scale,
picoVec4_t  dest 
)

Definition at line 433 of file picointernal.c.

void _pico_set_color ( picoColor_t  c,
int  r,
int  g,
int  b,
int  a 
)

Definition at line 465 of file picointernal.c.

Referenced by _md2_load(), _md3_load(), and PicoNewShader().

void _pico_set_vec ( picoVec3_t  v,
float  a,
float  b,
float  c 
)

Definition at line 361 of file picointernal.c.

void _pico_set_vec4 ( picoVec4_t  v,
float  a,
float  b,
float  c,
float  d 
)

Definition at line 368 of file picointernal.c.

char* _pico_setfext ( char *  path,
const char *  ext 
)

Definition at line 637 of file picointernal.c.

Referenced by _md2_load(), _md3_load(), and _obj_default_shader().

int _pico_strchcount ( char *  str,
int  ch 
)

Definition at line 316 of file picointernal.c.

References count.

Referenced by _obj_load().

const char* _pico_stristr ( const char *  str,
const char *  substr 
)

Definition at line 555 of file picointernal.c.

References _pico_strnicmp.

Referenced by _obj_canload().

char* _pico_strltrim ( char *  str  ) 

Definition at line 262 of file picointernal.c.

char* _pico_strlwr ( char *  str  ) 

Definition at line 302 of file picointernal.c.

char* _pico_strrtrim ( char *  str  ) 

Definition at line 277 of file picointernal.c.

void _pico_subtract_vec ( picoVec3_t  a,
picoVec3_t  b,
picoVec3_t  dest 
)

Definition at line 419 of file picointernal.c.

Referenced by _pico_calc_plane(), and _pico_triangles_generate_weighted_normals().

void _pico_unixify ( char *  path  ) 

Definition at line 573 of file picointernal.c.

Referenced by _md2_load(), and _md3_load().

void _pico_zero_bounds ( picoVec3_t  mins,
picoVec3_t  maxs 
)

Definition at line 325 of file picointernal.c.

References i.

Referenced by PicoNewModel().

void _pico_zero_vec ( picoVec3_t  vec  ) 

Definition at line 346 of file picointernal.c.

Referenced by _pico_normals_zero(), and _pico_parse_vec().

void _pico_zero_vec2 ( picoVec2_t  vec  ) 

Definition at line 351 of file picointernal.c.

Referenced by _pico_parse_vec2().

void _pico_zero_vec4 ( picoVec4_t  vec  ) 

Definition at line 356 of file picointernal.c.

Referenced by _pico_parse_vec4().


Variable Documentation

void(* _pico_ptr_free)(void *)

Referenced by _pico_free(), and PicoSetFreeFunc().

void(* _pico_ptr_free_file)(void *)
void(* _pico_ptr_load_file)(char *, unsigned char **, int *)
void*(* _pico_ptr_malloc)(size_t)
Todo:
: fix p->curLine for parser routines. increased twice

Referenced by _pico_alloc(), _pico_calloc(), _pico_realloc(), and PicoSetMallocFunc().

void(* _pico_ptr_print)(int, const char *)

Referenced by _pico_printf(), and PicoSetPrintFunc().

list of all supported file format modules

Definition at line 52 of file picomodules.c.


Generated by  doxygen 1.6.2