Mapper  0.9.0
API documentation
Functions
types.c File Reference

(f662771 on 7 Mar 2013)

#include <stdlib.h>
#include <string.h>
#include "libocad.h"
Include dependency graph for types.c:

Functions

char * my_strdup (const char *s)
 
int my_round (double x)
 
const s32ocad_point (s32 *buf, const OCADPoint *pt)
 Converts an OCAD point into a triplet of signed integers. More...
 
const s32ocad_point2 (s32 **pbuf, const OCADPoint *pt)
 Converts an OCAD point into a triplet of signed integers like ocad_point(), but advances the buffer pointer by three elements. More...
 
const char * ocad_str (char *buf, const str *ostr)
 Converts an OCAD string (0-255 characters) to a zero-terminated string in the given buffer. More...
 
const char * ocad_str2 (char **pbuf, const str *ostr)
 Converts an OCAD string (0-255 characters) to a zero-terminated string in the given buffer, returns a pointer to the zero-terminated string, and advances the buffer point just beyond the zero byte. More...
 
void ocad_to_real (s32 *from, double *to, u32 count)
 
void dump_bytes (u8 *base, u32 size)
 

Function Documentation

◆ dump_bytes()

void dump_bytes ( u8 base,
u32  size 
)

◆ my_round()

int my_round ( double  x)

◆ my_strdup()

char* my_strdup ( const char *  s)

◆ ocad_point()

const s32* ocad_point ( s32 buf,
const OCADPoint *  pt 
)

Converts an OCAD point into a triplet of signed integers.

The first value is the x-coordinate, second is the y-coordinate, and the third is a set of flags. The buffer should have at least three elements (3 * sizeof(s32)), or 12 bytes. A pointer to the beginning of the buffer is returned.

◆ ocad_point2()

const s32* ocad_point2 ( s32 **  pbuf,
const OCADPoint *  pt 
)

Converts an OCAD point into a triplet of signed integers like ocad_point(), but advances the buffer pointer by three elements.

This allows the caller to accumulate a list of points in a single buffer.

◆ ocad_str()

const char* ocad_str ( char *  buf,
const str ostr 
)

Converts an OCAD string (0-255 characters) to a zero-terminated string in the given buffer.

The buffer must be at least 256 bytes long. A pointer to the zero-terminated string is returned.

◆ ocad_str2()

const char* ocad_str2 ( char **  buf,
const str ostr 
)

Converts an OCAD string (0-255 characters) to a zero-terminated string in the given buffer, returns a pointer to the zero-terminated string, and advances the buffer point just beyond the zero byte.

Subsequent calls to this function can be made to build up a list of zero- terminated strings. This is useful, for example, in printf statements.

char tmp[512], *ptmp = &tmp;
printf("%s %s", ocad_str2(&ptmp, str1), ocad_str2(&ptmp, str2));

Both OCAD strings will be appended to the buffer and separate pointers will be passed to printf. Note that the buffer size must be at least 256 times the number of strings to be converted before ptmp is reset, to prevent the potential for buffer overflow.

◆ ocad_to_real()

void ocad_to_real ( s32 from,
double *  to,
u32  count 
)