File: gpiUtility.h

package info (click to toggle)
openmohaa 0.81.1%2Bdfsg-2
  • links: PTS, VCS
  • area: contrib
  • in suites: trixie
  • size: 29,124 kB
  • sloc: ansic: 270,865; cpp: 250,173; sh: 234; asm: 141; xml: 64; makefile: 7
file content (127 lines) | stat: -rw-r--r-- 2,766 bytes parent folder | download | duplicates (2)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
gpiUtility.h
GameSpy Presence SDK 
Dan "Mr. Pants" Schoenblum

Copyright 1999-2007 GameSpy Industries, Inc

devsupport@gamespy.com

***********************************************************************
Please see the GameSpy Presence SDK documentation for more information
**********************************************************************/

#ifndef _GPIUTILITY_H_
#define _GPIUTILITY_H_

//INCLUDES
//////////
#include "gpi.h"

//DEFINES
/////////
// Buffer read size.
////////////////////
#define GPI_READ_SIZE                  (16 * 1024)

//MACROS
////////
#define freeclear(mem)      { gsifree(mem); (mem) = NULL; }

#define Error(connection, result, string)       { gpiSetErrorString(connection, string);\
                                                       return (result);}

#define CallbackError(connection, result, code, string)  { gpiSetError(connection, code, string);\
                                                           gpiCallErrorCallback(connection, result, GP_NON_FATAL);\
                                                           return result;}

#define CallbackFatalError(connection, result, code, string)  { gpiSetError(connection, code, string);\
                                                                 gpiCallErrorCallback(connection, result, GP_FATAL);\
                                                                 return result;}

#define CHECK_RESULT(result)                          { GPResult __result__ = (result);\
                                                        if(__result__ != GP_NO_ERROR){\
                                                          return __result__;}}

//FUNCTIONS
///////////
void
strzcpy(
  char * dest,
  const char * src,
  size_t len  // length of buffer, including space for '\0'
);

void
gpiDebug(
  GPConnection * connection,
  const char * fmt,
  ...
);

GPIBool
gpiValueForKeyWithIndex(
  const char * command,
  const char * key,
  int * index,
  char * value,
  int len
);

GPIBool
gpiValueForKey(
  const char * command,
  const char * key,
  char * value,
  int len
);

char *
gpiValueForKeyAlloc(
  const char * command,
  const char * key
);

GPResult
gpiCheckSocketConnect(
  GPConnection * connection,
  SOCKET sock,
  int * state
);

GPResult
gpiReadKeyAndValue(
  GPConnection * connection,
  const char * buffer,
  int * index,
  char key[512],
  char value[512]
);

GPIBool
gpiCheckForError(
  GPConnection * connection,
  const char * input,
  GPIBool callErrorCallback
);

void
gpiSetError(
  GPConnection * connection,
  GPErrorCode errorCode,
  const char * errorString
);

void
gpiSetErrorString(
  GPConnection * connection,
  const char * errorString
);

void
gpiEncodeString(
  const char * unencodedString,
  char * encodedString
);

#endif