00001
00002
00003
00004
00005
00006
00007 #ifndef V_Vlib_h
00008 #define V_Vlib_h 1
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <X11/Xfuncproto.h>
00027
00028
00029 #include <stddef.h>
00030
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034
00035
00036
00037
00038
00039
00040 #ifndef FALSE
00041 #define FALSE 0
00042 #define TRUE 1
00043 #endif
00044
00045
00046
00047
00048
00049
00050
00051
00052 typedef char VBit;
00053 typedef double VDouble;
00054 typedef float VFloat;
00055
00056
00057 typedef int VLong;
00058
00059 #if __STDC__
00060 typedef signed char VSByte;
00061 #else
00062 typedef char VSByte;
00063 #endif
00064 typedef short VShort;
00065 typedef unsigned char VUByte;
00066
00067
00068
00069 #define VBitConst(c) (c)
00070 #define VUByteConst(c) (c)
00071 #define VSByteConst(c) (c)
00072 #define VShortConst(c) (c)
00073 #define VLongConst(c) (c ## l)
00074 #if __STDC__
00075 #define VFloatConst(c) (c ## f)
00076 #define VDoubleConst(c) (c)
00077 #else
00078 #define VFloatConst(c) ((VFloat) c)
00079 #define VDoubleConst(c) ((VDouble) c)
00080 #endif
00081
00082
00083
00084 typedef char VBoolean;
00085 #if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
00086 typedef void *VPointer;
00087 typedef const char *VStringConst;
00088 #else
00089 typedef char *VPointer;
00090 typedef char *VStringConst;
00091 #endif
00092 typedef char *VString;
00093
00094
00095
00096 typedef int VBitPromoted;
00097 typedef int VBooleanPromoted;
00098 typedef double VDoublePromoted;
00099 typedef double VFloatPromoted;
00100 typedef long VLongPromoted;
00101 typedef int VSBytePromoted;
00102 typedef int VShortPromoted;
00103 typedef unsigned int VUBytePromoted;
00104
00105
00106 typedef struct V_EdgesRec *VEdges;
00107 typedef struct V_ImageRec *VImage;
00108 typedef struct V_VolumesRec *Volumes;
00109
00110
00111 typedef enum {
00112 VUnknownRepn,
00113
00114
00115 VBitRepn,
00116 VUByteRepn,
00117 VSByteRepn,
00118 VShortRepn,
00119 VLongRepn,
00120
00121
00122 VFloatRepn,
00123 VDoubleRepn,
00124
00125
00126 VAttrListRepn,
00127 VBooleanRepn,
00128 VBundleRepn,
00129 VListRepn,
00130 VPointerRepn,
00131 VStringRepn,
00132
00133
00134 VEdgesRepn,
00135 VImageRepn,
00136
00137
00138 VGraphRepn,
00139 VolumesRepn,
00140 VNRepnKinds
00141 } VRepnKind;
00142
00143
00144
00145
00146
00147
00148
00149 typedef struct V_AttrRec {
00150 struct V_AttrRec *next;
00151 struct V_AttrRec *prev;
00152 VRepnKind repn;
00153 VPointer value;
00154 char name[1];
00155 } VAttrRec;
00156
00157
00158 typedef VAttrRec *VAttrList;
00159
00160
00161 #define VAttrListEmpty(l) ((l) == NULL || (l)->next == NULL)
00162
00163
00164 typedef struct {
00165 VAttrList list;
00166 struct V_AttrRec *ptr;
00167 } VAttrListPosn;
00168
00169
00170 #define VFirstAttr(l,p) ((void) ((p)->list = (l), (p)->ptr = (l)->next))
00171 #define VLastAttr(l,p) ((void) ((p)->list = (l), (p)->ptr = (l)->prev))
00172 #define VAttrExists(p) ((p)->ptr != NULL)
00173 #define VNextAttr(p) ((void) ((p)->ptr = (p)->ptr ? (p)->ptr->next : NULL))
00174 #define VPrevAttr(p) ((void) ((p)->ptr = (p)->ptr ? (p)->ptr->prev : NULL))
00175
00176
00177 #define VGetAttrName(p) ((p)->ptr->name)
00178 #define VGetAttrRepn(p) ((p)->ptr->repn)
00179
00180
00181 typedef enum {
00182 VAttrFound,
00183 VAttrMissing,
00184 VAttrBadValue
00185 } VGetAttrResult;
00186
00187
00188 #define VCommentAttr "comment"
00189 #define VDataAttr "data"
00190 #define VHistoryAttr "history"
00191 #define VLengthAttr "length"
00192 #define VNameAttr "name"
00193 #define VNColumnsAttr "ncolumns"
00194 #define VNRowsAttr "nrows"
00195 #define VRepnAttr "repn"
00196
00197
00198 typedef struct {
00199 VAttrList list;
00200 size_t length;
00201 VPointer data;
00202 char type_name[1];
00203 } VBundleRec, *VBundle;
00204
00205
00206
00207
00208
00209
00210
00211 typedef VPointer VCopyMethod (
00212 #if NeedFunctionPrototypes
00213 VPointer
00214 #endif
00215 );
00216
00217
00218 typedef void VDestroyMethod (
00219 #if NeedFunctionPrototypes
00220 VPointer
00221 #endif
00222 );
00223
00224
00225 typedef VPointer VDecodeMethod (
00226 #if NeedFunctionPrototypes
00227 VStringConst ,
00228 VBundle
00229 #endif
00230 );
00231
00232
00233 typedef VAttrList VEncodeAttrMethod (
00234 #if NeedFunctionPrototypes
00235 VPointer ,
00236 size_t *
00237 #endif
00238 );
00239
00240
00241 typedef VPointer VEncodeDataMethod (
00242 #if NeedFunctionPrototypes
00243 VPointer ,
00244 VAttrList ,
00245 size_t ,
00246 VBoolean *
00247 #endif
00248 );
00249
00250
00251 typedef struct {
00252 VCopyMethod *copy;
00253 VDestroyMethod *destroy;
00254 VDecodeMethod *decode;
00255 VEncodeAttrMethod *encode_attr;
00256 VEncodeDataMethod *encode_data;
00257 } VTypeMethods;
00258
00259
00260 typedef struct {
00261 VStringConst name;
00262 size_t size;
00263 int precision;
00264 VDouble min_value;
00265 VDouble max_value;
00266 VTypeMethods *methods;
00267 } VRepnInfoRec;
00268
00269
00270 extern VRepnInfoRec *VRepnInfo;
00271
00272
00273 #define VRepnSize(repn) (VRepnInfo[repn].size)
00274 #define VRepnPrecision(repn) (VRepnInfo[repn].precision)
00275 #define VRepnName(repn) (VRepnInfo[repn].name)
00276 #define VRepnMinValue(repn) (VRepnInfo[repn].min_value)
00277 #define VRepnMaxValue(repn) (VRepnInfo[repn].max_value)
00278 #define VRepnMethods(repn) (VRepnInfo[repn].methods)
00279
00280 #define VIsIntegerRepn(repn) ((repn) >= VBitRepn && (repn) <= VLongRepn)
00281 #define VIsFloatPtRepn(repn) ((repn) == VFloatRepn || (repn) == VDoubleRepn)
00282
00283
00284
00285
00286
00287
00288
00289 typedef struct {
00290
00291
00292 VStringConst keyword;
00293 VLong ivalue;
00294 VStringConst svalue;
00295
00296
00297 VBoolean icached;
00298 VBoolean fcached;
00299 VDouble fvalue;
00300 } VDictEntry;
00301
00302
00303 extern VDictEntry VBooleanDict[];
00304 extern VDictEntry VNumericRepnDict[];
00305
00306
00307
00308
00309
00310
00311
00312 typedef enum { VLsbFirst, VMsbFirst } VPackOrder;
00313
00314
00315
00316
00317
00318
00319
00320
00321 extern VPointer VCalloc (
00322 #if NeedFunctionPrototypes
00323 size_t ,
00324 size_t
00325 #endif
00326 );
00327
00328 extern void VFree (
00329 #if NeedFunctionPrototypes
00330 VPointer
00331 #endif
00332 );
00333
00334 extern VPointer VMalloc (
00335 #if NeedFunctionPrototypes
00336 size_t
00337 #endif
00338 );
00339
00340 extern VPointer VRealloc (
00341 #if NeedFunctionPrototypes
00342 VPointer ,
00343 size_t
00344 #endif
00345 );
00346
00347
00348
00349 extern void VAppendAttr (
00350 #if NeedVarargsPrototypes
00351 VAttrList ,
00352 VStringConst ,
00353 VDictEntry * ,
00354 VRepnKind ,
00355 ...
00356 #endif
00357 );
00358
00359 extern VAttrList VCopyAttrList (
00360 #if NeedFunctionPrototypes
00361 VAttrList
00362 #endif
00363 );
00364
00365 extern VAttrList VCreateAttrList (
00366 #if NeedFunctionPrototypes
00367 void
00368 #endif
00369 );
00370
00371 extern VBundle VCreateBundle (
00372 #if NeedFunctionPrototypes
00373 VStringConst ,
00374 VAttrList ,
00375 size_t ,
00376 VPointer
00377 #endif
00378 );
00379
00380 extern VBoolean VDecodeAttrValue (
00381 #if NeedFunctionPrototypes
00382 VStringConst ,
00383 VDictEntry * ,
00384 VRepnKind ,
00385 VPointer
00386 #endif
00387 );
00388
00389 extern void VDeleteAttr (
00390 #if NeedFunctionPrototypes
00391 VAttrListPosn *
00392 #endif
00393 );
00394
00395 extern void VDestroyAttrList (
00396 #if NeedFunctionPrototypes
00397 VAttrList
00398 #endif
00399 );
00400
00401 extern void VDestroyBundle (
00402 #if NeedFunctionPrototypes
00403 VBundle
00404 #endif
00405 );
00406
00407 extern VStringConst VEncodeAttrValue (
00408 #if NeedVarargsPrototypes
00409 VDictEntry * ,
00410 VRepnKind ,
00411 ...
00412 #endif
00413 );
00414
00415 extern VBoolean VExtractAttr (
00416 #if NeedFunctionPrototypes
00417 VAttrList ,
00418 VStringConst ,
00419 VDictEntry * ,
00420 VRepnKind ,
00421 VPointer ,
00422 VBooleanPromoted
00423 #endif
00424 );
00425
00426 extern VGetAttrResult VGetAttr (
00427 #if NeedFunctionPrototypes
00428 VAttrList ,
00429 VStringConst ,
00430 VDictEntry * ,
00431 VRepnKind ,
00432 VPointer
00433 #endif
00434 );
00435
00436 extern VBoolean VGetAttrValue (
00437 #if NeedFunctionPrototypes
00438 VAttrListPosn * ,
00439 VDictEntry * ,
00440 VRepnKind ,
00441 VPointer
00442 #endif
00443 );
00444
00445 extern void VInsertAttr (
00446 #if NeedVarargsPrototypes
00447 VAttrListPosn * ,
00448 VBooleanPromoted ,
00449 VStringConst ,
00450 VDictEntry * ,
00451 VRepnKind ,
00452 ...
00453 #endif
00454 );
00455
00456 extern VBoolean VLookupAttr (
00457 #if NeedFunctionPrototypes
00458 VAttrList ,
00459 VStringConst ,
00460 VAttrListPosn *
00461 #endif
00462 );
00463
00464 extern void VPrependAttr (
00465 #if NeedVarargsPrototypes
00466 VAttrList ,
00467 VStringConst ,
00468 VDictEntry * ,
00469 VRepnKind ,
00470 ...
00471 #endif
00472 );
00473
00474 extern void VSetAttr (
00475 #if NeedVarargsPrototypes
00476 VAttrList ,
00477 VStringConst ,
00478 VDictEntry * ,
00479 VRepnKind ,
00480 ...
00481 #endif
00482 );
00483
00484 extern void VSetAttrValue (
00485 #if NeedVarargsPrototypes
00486 VAttrListPosn * ,
00487 VDictEntry * ,
00488 VRepnKind ,
00489 ...
00490 #endif
00491 );
00492
00493
00494
00495 extern VDictEntry *VLookupDictKeyword (
00496 #if NeedFunctionPrototypes
00497 VDictEntry * ,
00498 VStringConst
00499 #endif
00500 );
00501
00502 extern VDictEntry *VLookupDictValue (
00503 #if NeedVarargsPrototypes
00504 VDictEntry * ,
00505 VRepnKind ,
00506 ...
00507 #endif
00508 );
00509
00510
00511
00512 typedef void VErrorHandler (
00513 #if NeedFunctionPrototypes
00514 VStringConst
00515 #endif
00516 );
00517
00518 typedef void VWarningHandler (
00519 #if NeedFunctionPrototypes
00520 VStringConst
00521 #endif
00522 );
00523
00524 extern void VSetErrorHandler (
00525 #if NeedFunctionPrototypes
00526 VErrorHandler *
00527 #endif
00528 );
00529
00530 extern void VSetWarningHandler (
00531 #if NeedFunctionPrototypes
00532 VWarningHandler *
00533 #endif
00534 );
00535
00536 extern void VSetProgramName (
00537 #if NeedFunctionPrototypes
00538 VStringConst
00539 #endif
00540 );
00541
00542 extern void VError (
00543 #if NeedVarargsPrototypes
00544 VStringConst ,
00545 ...
00546 #endif
00547 );
00548
00549 extern void VWarning (
00550 #if NeedVarargsPrototypes
00551 VStringConst ,
00552 ...
00553 #endif
00554 );
00555
00556 extern void VSystemError (
00557 #if NeedVarargsPrototypes
00558 VStringConst ,
00559 ...
00560 #endif
00561 );
00562
00563 extern void VSystemWarning (
00564 #if NeedVarargsPrototypes
00565 VStringConst ,
00566 ...
00567 #endif
00568 );
00569
00570 extern void VDefaultError (
00571 #if NeedFunctionPrototypes
00572 VStringConst
00573 #endif
00574 );
00575
00576 extern void VDefaultWarning (
00577 #if NeedFunctionPrototypes
00578 VStringConst
00579 #endif
00580 );
00581
00582
00583
00584 VBoolean VPackData (
00585 #if NeedFunctionPrototypes
00586 VRepnKind ,
00587 size_t ,
00588 VPointer ,
00589 VPackOrder ,
00590 size_t * ,
00591 VPointer * ,
00592 VBoolean *
00593 #endif
00594 );
00595
00596 VBoolean VUnpackData (
00597 #if NeedFunctionPrototypes
00598 VRepnKind ,
00599 size_t ,
00600 VPointer ,
00601 VPackOrder ,
00602 size_t * ,
00603 VPointer * ,
00604 VBoolean *
00605 #endif
00606 );
00607
00608 void VPackBits (
00609 #if NeedFunctionPrototypes
00610 size_t ,
00611 VPackOrder ,
00612 VBit * ,
00613 char *
00614 #endif
00615 );
00616
00617 void VUnpackBits (
00618 #if NeedFunctionPrototypes
00619 size_t ,
00620 VPackOrder ,
00621 char * ,
00622 VBit *
00623 #endif
00624 );
00625
00626
00627
00628 VRepnKind VRegisterType (
00629 #if NeedFunctionPrototypes
00630 VStringConst ,
00631 VTypeMethods *
00632 #endif
00633 );
00634
00635 VRepnKind VLookupType (
00636 #if NeedFunctionPrototypes
00637 VStringConst
00638 #endif
00639 );
00640
00641 #ifdef __cplusplus
00642 }
00643 #endif
00644
00645 #endif