/usr/include/meanwhile/mw_common.h is in libmeanwhile-dev 1.0.2-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | /*
Meanwhile - Unofficial Lotus Sametime Community Client Library
Copyright (C) 2004 Christopher (siege) O'Brien
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _MW_COMMON_H
#define _MW_COMMON_H
/** @file mw_common.h
Common data types and functions for handling those types.
Functions in this file all fit into similar naming conventions of
<code>TYPE_ACTION</code> as per the activity they perform. The
following actions are available:
<code>void TYPE_put(struct mwPutBuffer *b, TYPE *val)</code>
- marshalls val onto the buffer b. The buffer will grow as necessary
to fit all the data put into it. For guint16, guint32, and
gboolean, <code>TYPE val</code> is used instead of <code>TYPE
\*val</code>.
<code>void TYPE_get(struct mwGetBuffer *b, TYPE *val)</code>
- unmarshals val from the buffer b. Failure (due to lack of
insufficient remaining buffer) is indicated in the buffer's error
field. A call to a _get function with a buffer in an error state
has to effect.
<code>void TYPE_clear(TYPE *val)</code>
- zeros and frees internal members of val, but does not free val
itself. Needs to be called before free-ing any complex types which
have been unmarshalled from a TYPE_get or populated from a
TYPE_clone call to prevent memory leaks.
<code>void TYPE_clone(TYPE *to, TYPE *from)</code>
- copies/clones members of from into to. May result in memory
allocation for some types. Note that to is not cleared
before-hand, it must already be in a pristine condition.
<code>gboolean TYPE_equal(TYPE *y, TYPE *z)</code>
- simple equality test.
*/
#include <glib.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @struct mwPutBuffer
buffer to be written to */
struct mwPutBuffer;
/** @struct mwGetBuffer
buffer to be read from */
struct mwGetBuffer;
/** A length of binary data, not null-terminated. */
struct mwOpaque {
gsize len; /**< length of data. */
guchar *data; /**< data, normally with no NULL termination */
};
/* 8.3.6 Login Types */
/** The type of login. Normally meaning the type of client code being
used to login with.
If you know of any additional client identifiers, please add them
below or submit an RFE to the meanwhile tracker.
*/
enum mwLoginType {
mwLogin_LIB = 0x1000, /**< official Lotus binary library */
mwLogin_JAVA_WEB = 0x1001, /**< official Lotus Java applet */
mwLogin_BINARY = 0x1002, /**< official Lotus binary application */
mwLogin_JAVA_APP = 0x1003, /**< official Lotus Java application */
mwLogin_LINKS = 0x100a, /**< official Sametime Links toolkit */
/* now we're getting crazy */
mwLogin_NOTES_6_5 = 0x1200,
mwLogin_NOTES_6_5_3 = 0x1203,
mwLogin_NOTES_7_0_beta = 0x1210,
mwLogin_NOTES_7_0 = 0x1214,
mwLogin_ICT = 0x1300,
mwLogin_ICT_1_7_8_2 = 0x1302,
mwLogin_ICT_SIP = 0x1303,
mwLogin_NOTESBUDDY_4_14 = 0x1400, /**< 0xff00 mask? */
mwLogin_NOTESBUDDY_4_15 = 0x1405,
mwLogin_NOTESBUDDY_4_16 = 0x1406,
mwLogin_SANITY = 0x1600,
mwLogin_ST_PERL = 0x1625,
mwLogin_PMR_ALERT = 0x1650,
mwLogin_TRILLIAN = 0x16aa, /**< http://sf.net/st-plugin/ */
mwLogin_TRILLIAN_IBM = 0x16bb,
mwLogin_MEANWHILE = 0x1700, /**< Meanwhile library */
};
/* 8.2 Common Structures */
/* 8.2.1 Login Info block */
struct mwLoginInfo {
char *login_id; /**< community-unique ID of the login */
guint16 type; /**< @see mwLoginType */
char *user_id; /**< community-unique ID of the user */
char *user_name; /**< name of user (nick name, full name, etc) */
char *community; /**< community name (usually domain name) */
gboolean full; /**< if FALSE, following fields non-existant */
char *desc; /**< implementation defined description */
guint32 ip_addr; /**< ip addr of the login */
char *server_id; /**< unique ID of login's server */
};
/* 8.2.2 Private Info Block */
struct mwUserItem {
gboolean full; /**< if FALSE, don't include name */
char *id; /**< user id */
char *community; /**< community */
char *name; /**< user name */
};
struct mwPrivacyInfo {
gboolean deny; /**< deny (true) or allow (false) users */
guint32 count; /**< count of users */
struct mwUserItem *users; /**< the users list */
};
/* 8.3.5 User Status Types */
enum mwStatusType {
mwStatus_ACTIVE = 0x0020,
mwStatus_IDLE = 0x0040,
mwStatus_AWAY = 0x0060,
mwStatus_BUSY = 0x0080,
};
/* 8.2.3 User Status Block */
struct mwUserStatus {
guint16 status; /**< @see mwStatusType */
guint32 time; /**< last status change time in seconds */
char *desc; /**< status description */
};
/* 8.2.4 ID Block */
struct mwIdBlock {
char *user; /**< user id (login id or empty for some services) */
char *community; /**< community id (NULL for same community) */
};
/* 8.3.8.2 Awareness Presence Types */
/* @todo move mwAwareType, mwAwareIdBlock and mwAwareSnapshot into the
aware service and out of common */
/** type codes for mwAwareIdBlock */
enum mwAwareType {
mwAware_USER = 0x0002, /**< a single user */
mwAware_GROUP = 0x0003, /**< a group */
mwAware_SERVER = 0x0008, /**< a server */
};
/* 8.4.2 Awareness Messages */
/* 8.4.2.1 Awareness ID Block */
struct mwAwareIdBlock {
guint16 type; /**< @see mwAwareType */
char *user; /**< user id */
char *community; /**< community id (NULL for same community) */
};
/* 8.4.2.4 Snapshot */
struct mwAwareSnapshot {
struct mwAwareIdBlock id;
char *group; /**< group this id belongs to */
gboolean online; /**< is this user online? */
char *alt_id; /**< alternate ID, often same as id.user */
struct mwUserStatus status; /**< status of this user */
char *name; /**< Formatted version of ID */
};
/** encryption blocks */
struct mwEncryptItem {
guint16 id; /**< cipher identifier */
struct mwOpaque info; /**< cipher information */
};
/** @name buffer utility functions */
/*@{*/
/** allocate a new empty buffer */
struct mwPutBuffer *mwPutBuffer_new();
/** write raw data to the put buffer */
void mwPutBuffer_write(struct mwPutBuffer *b, gpointer data, gsize len);
/** destroy the buffer */
void mwPutBuffer_free(struct mwPutBuffer *b);
/** move the buffer's data into an opaque, destroy the buffer */
void mwPutBuffer_finalize(struct mwOpaque *to, struct mwPutBuffer *from);
/** allocate a new buffer with a copy of the given data */
struct mwGetBuffer *mwGetBuffer_new(struct mwOpaque *data);
/** read len bytes of raw data from the get buffer into mem. If len is
greater than the count of bytes remaining in the buffer, the
buffer's error flag will NOT be set.
@returns count of bytes successfully copied to mem */
gsize mwGetBuffer_read(struct mwGetBuffer *b, gpointer mem, gsize len);
/** skip len bytes in the get buffer. If len is greater than the count
of bytes remaining in the buffer, the buffer's error flag will NOT
be set.
@returns count of bytes successfully skipped */
gsize mwGetBuffer_advance(struct mwGetBuffer *b, gsize len);
/** allocate a new buffer backed by the given data. Calling
mwGetBuffer_free will not result in the underlying data being
freed */
struct mwGetBuffer *mwGetBuffer_wrap(const struct mwOpaque *data);
/** destroy the buffer */
void mwGetBuffer_free(struct mwGetBuffer *b);
/** reset the buffer to the very beginning. Also clears the buffer's
error flag. */
void mwGetBuffer_reset(struct mwGetBuffer *b);
/** count of remaining available bytes */
gsize mwGetBuffer_remaining(struct mwGetBuffer *b);
/** TRUE if an error occurred while reading a basic type from this
buffer */
gboolean mwGetBuffer_error(struct mwGetBuffer *b);
/*@}*/
/** @name Basic Data Types
The basic types are combined to construct the compound types.
*/
/*@{*/
void guint16_put(struct mwPutBuffer *b, guint16 val);
void guint16_get(struct mwGetBuffer *b, guint16 *val);
guint16 guint16_peek(struct mwGetBuffer *b);
void guint32_put(struct mwPutBuffer *b, guint32 val);
void guint32_get(struct mwGetBuffer *b, guint32 *val);
guint32 guint32_peek(struct mwGetBuffer *b);
void gboolean_put(struct mwPutBuffer *b, gboolean val);
void gboolean_get(struct mwGetBuffer *b, gboolean *val);
gboolean gboolean_peek(struct mwGetBuffer *b);
void mwString_put(struct mwPutBuffer *b, const char *str);
void mwString_get(struct mwGetBuffer *b, char **str);
void mwOpaque_put(struct mwPutBuffer *b, const struct mwOpaque *o);
void mwOpaque_get(struct mwGetBuffer *b, struct mwOpaque *o);
void mwOpaque_clear(struct mwOpaque *o);
void mwOpaque_free(struct mwOpaque *o);
void mwOpaque_clone(struct mwOpaque *to, const struct mwOpaque *from);
/*@}*/
/** @name Compound Data Types */
/*@{*/
void mwLoginInfo_put(struct mwPutBuffer *b, const struct mwLoginInfo *info);
void mwLoginInfo_get(struct mwGetBuffer *b, struct mwLoginInfo *info);
void mwLoginInfo_clear(struct mwLoginInfo *info);
void mwLoginInfo_clone(struct mwLoginInfo *to, const struct mwLoginInfo *from);
void mwUserItem_put(struct mwPutBuffer *b, const struct mwUserItem *user);
void mwUserItem_get(struct mwGetBuffer *b, struct mwUserItem *user);
void mwUserItem_clear(struct mwUserItem *user);
void mwUserItem_clone(struct mwUserItem *to, const struct mwUserItem *from);
void mwPrivacyInfo_put(struct mwPutBuffer *b,
const struct mwPrivacyInfo *info);
void mwPrivacyInfo_get(struct mwGetBuffer *b, struct mwPrivacyInfo *info);
void mwPrivacyInfo_clear(struct mwPrivacyInfo *info);
void mwPrivacyInfo_clone(struct mwPrivacyInfo *to,
const struct mwPrivacyInfo *from);
void mwUserStatus_put(struct mwPutBuffer *b,
const struct mwUserStatus *stat);
void mwUserStatus_get(struct mwGetBuffer *b, struct mwUserStatus *stat);
void mwUserStatus_clear(struct mwUserStatus *stat);
void mwUserStatus_clone(struct mwUserStatus *to,
const struct mwUserStatus *from);
void mwIdBlock_put(struct mwPutBuffer *b, const struct mwIdBlock *id);
void mwIdBlock_get(struct mwGetBuffer *b, struct mwIdBlock *id);
void mwIdBlock_clear(struct mwIdBlock *id);
void mwIdBlock_clone(struct mwIdBlock *to,
const struct mwIdBlock *from);
guint mwIdBlock_hash(const struct mwIdBlock *idb);
gboolean mwIdBlock_equal(const struct mwIdBlock *a,
const struct mwIdBlock *b);
void mwAwareIdBlock_put(struct mwPutBuffer *b,
const struct mwAwareIdBlock *idb);
void mwAwareIdBlock_get(struct mwGetBuffer *b, struct mwAwareIdBlock *idb);
void mwAwareIdBlock_clear(struct mwAwareIdBlock *idb);
void mwAwareIdBlock_clone(struct mwAwareIdBlock *to,
const struct mwAwareIdBlock *from);
guint mwAwareIdBlock_hash(const struct mwAwareIdBlock *a);
gboolean mwAwareIdBlock_equal(const struct mwAwareIdBlock *a,
const struct mwAwareIdBlock *b);
void mwAwareSnapshot_get(struct mwGetBuffer *b,
struct mwAwareSnapshot *idb);
void mwAwareSnapshot_clear(struct mwAwareSnapshot *idb);
void mwAwareSnapshot_clone(struct mwAwareSnapshot *to,
const struct mwAwareSnapshot *from);
void mwEncryptItem_put(struct mwPutBuffer *b,
const struct mwEncryptItem *item);
void mwEncryptItem_get(struct mwGetBuffer *b, struct mwEncryptItem *item);
void mwEncryptItem_clear(struct mwEncryptItem *item);
void mwEncryptItem_free(struct mwEncryptItem *item);
/*@}*/
#ifdef __cplusplus
}
#endif
#endif /* _MW_COMMON_H */
|