home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / rdf / src / rdfht.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.5 KB  |  158 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. /* 
  20.    This file implements high level support for the rdf data model.
  21.    For more information on this file, contact rjc or guha 
  22.    For more information on RDF, look at the RDF section of www.mozilla.org
  23. */
  24.  
  25. #include "rdf-int.h"
  26. #include "xpassert.h"
  27. #include "glue.h"
  28. #include "vocab.h"
  29. #include "vocabint.h"
  30. #include "bmk2mcf.h"
  31. #include "ht.h"
  32. #include "mcf.h"
  33.  
  34.  
  35.     /* externs */
  36. extern    char    *profileDirURL;
  37. extern    char    *gBookmarkURL;
  38. extern    RDF    gNCDB ;
  39. extern    char    *gGlobalHistoryURL;
  40.  
  41. static PRBool sRDFInitedB = PR_FALSE;
  42.  
  43.  
  44.  
  45. char * gNavCenterDataSources[15] = 
  46. {"rdf:localStore", "rdf:remoteStore", "rdf:history",
  47.  /* "rdf:ldap", */
  48.  "rdf:esftp",
  49.  "rdf:lfs",
  50.  "rdf:columns",  NULL
  51. };
  52.  
  53.  
  54.  
  55. RDF
  56. newNavCenterDB()
  57. {
  58.     return  RDF_GetDB((char**)gNavCenterDataSources);
  59. }
  60.  
  61.  
  62.  
  63. PR_PUBLIC_API(RDF_Error)
  64. RDF_Init(RDF_InitParams params)
  65. {
  66.   char* navCenterURL;
  67.   if ( sRDFInitedB )
  68.     return -1;
  69.   resourceHash = PL_NewHashTable(500, PL_HashString, PL_CompareStrings, PL_CompareValues,  
  70.                  NULL, NULL);
  71.   RDFglueInitialize();
  72.   createVocabs();
  73.   sRDFInitedB = PR_TRUE;
  74.  
  75.   XP_ASSERT(params->profileURL != NULL);
  76.   XP_ASSERT(params->bookmarksURL != NULL);
  77.   XP_ASSERT(params->globalHistoryURL != NULL);
  78.  
  79.   profileDirURL     = copyString(params->profileURL);
  80.   gBookmarkURL      = copyString(params->bookmarksURL);
  81.   gGlobalHistoryURL = copyString(params->globalHistoryURL);
  82.  
  83.   PREF_SetDefaultCharPref("browser.NavCenter", "http://rdf.netscape.com/navcntr.rdf");
  84.   PREF_CopyCharPref("browser.NavCenter", &navCenterURL);
  85.   *(gNavCenterDataSources + 1) = copyString(navCenterURL);
  86.   gNCDB = newNavCenterDB();
  87.   freeMem(navCenterURL);
  88.  
  89.   HT_Startup();
  90.  
  91.   return 0;
  92. }
  93.  
  94.  
  95.  
  96. /*need to keep a linked list of all the dbs opened so that they
  97.   can all be closed down on exit */
  98.  
  99.  
  100.  
  101. PR_PUBLIC_API(RDF_Error)
  102. RDF_Shutdown ()
  103. {
  104.  
  105.   /*  flushBookmarks(); */
  106.   HT_Shutdown();
  107.   RDFglueExit();
  108.   if (profileDirURL != NULL)
  109.   {
  110.       freeMem(profileDirURL);
  111.       profileDirURL = NULL;
  112.   }
  113.   if (gBookmarkURL != NULL)
  114.   {
  115.       freeMem(gBookmarkURL);
  116.       gBookmarkURL = NULL;
  117.   }
  118.   if (gGlobalHistoryURL != NULL)
  119.   {
  120.       freeMem(gGlobalHistoryURL);
  121.       gGlobalHistoryURL = NULL;
  122.   }
  123.   if (gLocalStoreURL != NULL)
  124.   {
  125.       freeMem(gLocalStoreURL);
  126.       gLocalStoreURL = NULL;
  127.   }
  128.   disposeAllDBs();
  129.   sRDFInitedB = PR_FALSE;
  130.   
  131.   return 0;
  132. }
  133.  
  134.  
  135.  
  136. PR_PUBLIC_API(PRBool)
  137. RDF_CanAssert(RDF r, RDF_Resource u, RDF_Resource s, 
  138.             void* v, RDF_ValueType type)
  139. {
  140.     return true;
  141. }
  142.  
  143.  
  144.  
  145. PR_PUBLIC_API(PRBool)
  146. RDF_CanAssertFalse(RDF r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
  147. {
  148.     return true;
  149. }
  150.  
  151.  
  152.  
  153. PR_PUBLIC_API(PRBool)
  154. RDF_CanUnassert(RDF r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
  155. {
  156.     return true;
  157. }
  158.