home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / rdf / src / nlcstore.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.4 KB  |  112 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef    _RDF_NLCSTORE_H_
  20. #define    _RDF_NLCSTORE_H_
  21.  
  22.  
  23. #include "rdf-int.h"
  24. #include "rdf.h"
  25. #include "xp.h"
  26. #include "mcom_ndbm.h"
  27. #include "xpassert.h"
  28.  
  29.  
  30. #if !defined(IS_LITTLE_ENDIAN) && !defined(IS_BIG_ENDIAN)
  31. #error Must have a byte order
  32. #endif
  33.  
  34. #ifdef IS_LITTLE_ENDIAN
  35. #define COPY_INT16(_a,_b)  XP_MEMCPY(_a, _b, sizeof(uint16));
  36. #else
  37. #define    COPY_INT16(_a,_b)                \
  38.     do {                        \
  39.     ((char *)(_a))[0] = ((char *)(_b))[1];        \
  40.     ((char *)(_a))[1] = ((char *)(_b))[0];        \
  41.     } while(0)
  42. #endif
  43. #if !defined(XP_MAC) && !defined(COPY_INT16)
  44.     #define COPY_INT16(_a,_b)  XP_MEMCPY(_a, _b, sizeof(int16));
  45. #endif
  46.  
  47.  
  48.  
  49. /* nlcstore.c data structures and defines */
  50.  
  51. typedef struct _DBMAsStruct {
  52.   uint8 size[3];
  53.   char tag;
  54.   char *data;
  55. } DBMAsStruct;
  56.  
  57. typedef DBMAsStruct* DBMAs;
  58.  
  59. typedef struct _DBMRDFStruct {
  60.   DB *propDB;
  61.   DB *invPropDB;
  62.   DB *nameDB;
  63.   DB *childrenDB;
  64. } *DBMRDF;
  65.  
  66.  
  67. #define dataOfDBMAs(dbmas) ((char*)((char*)dbmas + 4))
  68. #define dbmasSize(dbmas) ((size_t)(((1 << 16) * dbmas->size[0]) + ((1 << 8) * dbmas->size[1]) + dbmas->size[2]))
  69. #define nthdbmas(data, n) ((DBMAs)((char*)data + n))
  70. #define valueTypeOfAs(nas) ((RDF_ValueType) ((*(((unsigned char *)nas)+3)) & 0x0F))
  71. #define tvOfAs(nas) ((PRBool)((nas->tag & 0x10) != 0))
  72. #define valueEqual(type, v1, v2) (((type == RDF_RESOURCE_TYPE) && stringEquals((char*)v1, resourceID((RDF_Resource)v2))) || \
  73.       ((type == RDF_INT_TYPE) && (compareUnalignedUINT32Ptrs(v1,v2))) || \
  74.       ((type == RDF_STRING_TYPE) && stringEquals((char*)v1, (char*)v2)))
  75.  
  76.  
  77.  
  78. /* nlcstore.c function prototypes */
  79.  
  80. XP_BEGIN_PROTOS
  81.  
  82. PRBool        compareUnalignedUINT32Ptrs(void *v1, void *v2);
  83. char *        makeRDFDBURL(char* directory, char* name);
  84. void        readInBookmarksOnInit(RDFFile f);
  85. void        DBM_OpenDBMStore (DBMRDF store, char* directory);
  86. RDF_Error    DBM_CloseRDFDBMStore (RDFT r);
  87. char *        makeUSKey (RDF_Resource u, RDF_Resource s, PRBool inversep, size_t *size);
  88. DB *        getUSDB (RDFT r, RDF_Resource u, RDF_Resource s, PRBool inversep);
  89. void        freeKey (char* keyData, RDF_Resource u, RDF_Resource s, PRBool inversep);
  90. DBMAs *        DBM_GetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep, size_t *size);
  91. void        DBM_PutSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep, void* value, size_t size);
  92. PRBool        nlocalStoreHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
  93. void *        nlocalStoreGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
  94. RDF_Cursor    nlocalStoreGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
  95. void *        nlocalStoreNextValue (RDFT rdf, RDF_Cursor c);
  96. RDF_Error    nlocalStoreDisposeCursor (RDFT rdf, RDF_Cursor c);
  97. DBMAs        makeAsBlock (void* v, RDF_ValueType type, PRBool tv,  size_t *size);
  98. PRBool        nlocalStoreAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
  99. PRBool        nlocalStoreAssert1 (RDFFile f, RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
  100. PRBool        nlocalStoreUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
  101. void        addSlotsHere (RDFT rdf, RDF_Resource u, RDF_Resource s);
  102. void        deleteSlotsHere (RDFT rdf, RDF_Resource u, RDF_Resource s);
  103. void        addSlotsIn (RDFT rdf, RDF_Resource u, RDF_Resource s);
  104. void        deleteSlotsIn (RDFT rdf, RDF_Resource u, RDF_Resource s);
  105. void        nlclStoreKill (RDFT rdf, RDF_Resource u);
  106. PRBool        nlocalStoreAddChildAt(RDFT rdf, RDF_Resource parent, RDF_Resource ref, RDF_Resource new, PRBool beforep);
  107. RDFT        MakeLocalStore (char* url);
  108.  
  109. XP_END_PROTOS
  110.  
  111. #endif
  112.