Compare commits
14 Commits
release
...
RDF_XPCOM_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b2424f7ca | ||
|
|
75bfddcd5c | ||
|
|
d67638c1e0 | ||
|
|
021dfd7c81 | ||
|
|
272deb6ee9 | ||
|
|
f81f4440bd | ||
|
|
914f82571b | ||
|
|
0f1dfe3d0d | ||
|
|
05693f5648 | ||
|
|
26c6838a88 | ||
|
|
90406a1af2 | ||
|
|
41eefd7f6c | ||
|
|
ab25b9b291 | ||
|
|
a151d7380d |
9
mozilla/modules/rdf/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
#! gmake
|
||||
|
||||
DEPTH = ../..
|
||||
|
||||
DIRS = include src
|
||||
|
||||
INCLUDE = $(INCLUDE) -I$(DEPTH)/modules/libimg/public
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
14
mozilla/modules/rdf/Makefile.in
Normal file
@@ -0,0 +1,14 @@
|
||||
#! gmake
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = include src
|
||||
|
||||
INCLUDE += -I$(topsrcdir)/modules/libimg/public
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
BIN
mozilla/modules/rdf/images/channels.gif
Normal file
|
After Width: | Height: | Size: 269 B |
BIN
mozilla/modules/rdf/images/file.gif
Normal file
|
After Width: | Height: | Size: 126 B |
BIN
mozilla/modules/rdf/images/guide.gif
Normal file
|
After Width: | Height: | Size: 1017 B |
BIN
mozilla/modules/rdf/images/history.gif
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
mozilla/modules/rdf/images/ldap.gif
Normal file
|
After Width: | Height: | Size: 1017 B |
BIN
mozilla/modules/rdf/images/personal.gif
Normal file
|
After Width: | Height: | Size: 126 B |
BIN
mozilla/modules/rdf/images/search.gif
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
mozilla/modules/rdf/images/sitemap.gif
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
8
mozilla/modules/rdf/include/MANIFEST
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
rdf.h
|
||||
vocab.h
|
||||
htrdf.h
|
||||
jsec2rdf.h
|
||||
26
mozilla/modules/rdf/include/Makefile
Normal file
@@ -0,0 +1,26 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
MODULE = rdf
|
||||
DEPTH = ../../..
|
||||
EXPORTS = rdf.h htrdf.h vocab.h jsec2rdf.h
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
33
mozilla/modules/rdf/include/Makefile.in
Normal file
@@ -0,0 +1,33 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
MODULE = rdf
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
EXPORTS = rdf.h htrdf.h vocab.h jsec2rdf.h
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
8
mozilla/modules/rdf/include/export.mac
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
rdf.h
|
||||
vocab.h
|
||||
htrdf.h
|
||||
jsec2rdf.h
|
||||
580
mozilla/modules/rdf/include/htrdf.h
Normal file
@@ -0,0 +1,580 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef htrdf_h___
|
||||
#define htrdf_h___
|
||||
|
||||
/* the RDF HT API */
|
||||
|
||||
#include "rdf.h"
|
||||
|
||||
#ifdef XPCOM_XXX
|
||||
#include "ntypes.h"
|
||||
#include "structs.h"
|
||||
#include "pa_parse.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hyper Tree Api
|
||||
*
|
||||
* Hyper tree is the tree view of the rdf store. This is for use by the FE in
|
||||
* implementing the nav center.
|
||||
*
|
||||
* The RDF structure could be a gnarly graph whose nodes are RDF_Resource.
|
||||
* There can be multiple tree views (HT_View) into this graph. Corresponding
|
||||
* to each view, there is a hyper tree whose nodes are HT_Resource.
|
||||
* Each HT_Resource belongs to exactly one HT_View.
|
||||
* The FE iterate over the hypertree to draw it. It can start the iteration
|
||||
* either at the top or at some interior node. When some state change occurs
|
||||
* in the hypertree, the FE will get notified about the node on which the
|
||||
* change took place. At that point, it can either redraw the whole thing
|
||||
* or do a partial redraw. The FE does this by iterating over the relevant
|
||||
* portions of the hypertree. Since the hypertree is a strict tree, the FE
|
||||
* can also iterate upwards.
|
||||
*
|
||||
*
|
||||
* Possible state changes to the hypertree of an HT_View include :
|
||||
* (i) addition/deletion of nodes
|
||||
* (ii) containers closing/opening
|
||||
* (iii) selection changes
|
||||
* These changes could occur either because of
|
||||
* (i) User clicking around the tree
|
||||
* (ii) Network activity
|
||||
* (iii) scripts running
|
||||
* The FE can recieve notifications about these activities.
|
||||
* If the FE does not want to be notified about something, it can set
|
||||
* the notification mask to block certain notifications.
|
||||
*/
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
/* Opaque data structures */
|
||||
typedef struct _HT_ViewStruct* HT_View;
|
||||
|
||||
typedef struct _HT_PaneStruct* HT_Pane;
|
||||
|
||||
typedef struct _HT_CursorStruct* HT_Cursor;
|
||||
|
||||
typedef struct _HT_ResourceStruct* HT_Resource;
|
||||
|
||||
/* for use with HT_GetTemplate */
|
||||
enum TemplateType {
|
||||
ht_template_chrome,
|
||||
ht_template_management,
|
||||
ht_template_navigation
|
||||
};
|
||||
|
||||
/*
|
||||
* This is the Notification structure that gets passed to the HT layer on
|
||||
* creation of the view. This should be allocated/static memory. HT layer
|
||||
* will store a pointer to this structure. On CloseView, a View Closed
|
||||
* event will be generated and the notification function will be called.
|
||||
* At this point, the module using HT can free the memory associated with
|
||||
* the HT_Notification struct.
|
||||
*/
|
||||
|
||||
|
||||
typedef uint32 HT_NotificationMask;
|
||||
typedef uint32 HT_Event;
|
||||
typedef uint32 HT_Error;
|
||||
|
||||
#define HT_NoErr 0
|
||||
#define HT_Err 1
|
||||
|
||||
struct _HT_NotificationStruct;
|
||||
|
||||
typedef void (*HT_NotificationProc)(struct _HT_NotificationStruct*,
|
||||
HT_Resource node, HT_Event whatHappened, void *param, uint32 tokenType);
|
||||
typedef struct _HT_NotificationStruct {
|
||||
HT_NotificationProc notifyProc;
|
||||
void *data;
|
||||
} HT_NotificationStruct;
|
||||
|
||||
|
||||
/*
|
||||
* HT_Notification events and masks
|
||||
*/
|
||||
|
||||
|
||||
typedef HT_NotificationStruct* HT_Notification;
|
||||
|
||||
#define HT_EVENT_NODE_ADDED 0x00000001UL
|
||||
#define HT_EVENT_NODE_DELETED_DATA 0x00000002UL
|
||||
#define HT_EVENT_NODE_DELETED_NODATA 0x00000004UL
|
||||
#define HT_EVENT_NODE_VPROP_CHANGED 0x00000008UL
|
||||
#define HT_EVENT_NODE_SELECTION_CHANGED 0x00000010UL
|
||||
#define HT_EVENT_NODE_OPENCLOSE_CHANGED 0x00000020UL
|
||||
#define HT_EVENT_VIEW_CLOSED 0x00000040UL /* same as HT_EVENT_VIEW_DELETED */
|
||||
#define HT_EVENT_VIEW_DELETED 0x00000040UL /* same as HT_EVENT_VIEW_CLOSED */
|
||||
#define HT_EVENT_VIEW_SELECTED 0x00000080UL
|
||||
#define HT_EVENT_VIEW_ADDED 0x00000100UL
|
||||
#define HT_EVENT_NODE_OPENCLOSE_CHANGING 0x00000200UL
|
||||
#define HT_EVENT_VIEW_SORTING_CHANGED 0x00000400UL
|
||||
#define HT_EVENT_VIEW_REFRESH 0x00000800UL
|
||||
#define HT_EVENT_VIEW_WORKSPACE_REFRESH 0x00001000UL
|
||||
#define HT_EVENT_NODE_EDIT 0x00002000UL
|
||||
#define HT_EVENT_WORKSPACE_EDIT 0x00004000UL
|
||||
#define HT_EVENT_VIEW_HTML_ADD 0x00008000UL
|
||||
#define HT_EVENT_VIEW_HTML_REMOVE 0x00010000UL
|
||||
#define HT_EVENT_NODE_ENABLE 0x00020000UL
|
||||
#define HT_EVENT_NODE_DISABLE 0x00040000UL
|
||||
#define HT_EVENT_NODE_SCROLLTO 0x00080000UL
|
||||
#define HT_EVENT_COLUMN_ADD 0x00100000UL
|
||||
#define HT_EVENT_COLUMN_DELETE 0x00200000UL
|
||||
#define HT_EVENT_COLUMN_SIZETO 0x00400000UL
|
||||
#define HT_EVENT_COLUMN_REORDER 0x00800000UL
|
||||
#define HT_EVENT_COLUMN_SHOW 0x01000000UL
|
||||
#define HT_EVENT_COLUMN_HIDE 0x02000000UL
|
||||
#define HT_EVENT_VIEW_MODECHANGED 0x04000000UL
|
||||
#define HT_EVENT_VIEW_WINDOWTYPE_CHANGED 0x04000000UL
|
||||
|
||||
#define HT_EVENT_NO_NOTIFICATION_MASK 0x00000000UL
|
||||
#define HT_EVENT_DEFAULT_NOTIFICATION_MASK 0xFFFFFFFFUL
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* View/Pane Creation / Destruction / Management */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/* Window Types for Panes */
|
||||
#define HT_POPUP_WINDOW 0
|
||||
#define HT_DOCKED_WINDOW 1
|
||||
#define HT_STANDALONE_WINDOW 2
|
||||
#define HT_EMBEDDED_WINDOW 3
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_PaneFromResource(RDF_Resource r, HT_Notification n, PRBool autoFlush, PRBool autoOpen, PRBool useColumns);
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_PaneFromURL(void* context, char* url, char* templateType,
|
||||
HT_Notification n, PRBool autoFlush, int32 param_count,
|
||||
char** param_names, char** param_values);
|
||||
|
||||
/* NewQuickFilePane
|
||||
* Creates a pane consisting of one view. This view has the RDF resource
|
||||
* corresponding to the Quickfile folder as its root.
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_NewQuickFilePane (HT_Notification notify);
|
||||
|
||||
/* NewToolbarPane
|
||||
* Added by Dave
|
||||
* Create a pane consisting of multiple views. Each view corresponds to a single toolbar.
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Pane) HT_NewToolbarPane (HT_Notification notify);
|
||||
|
||||
/* NewPersonalToolbarPane
|
||||
* Creates a pane consisting of one view. This view has the RDF resource
|
||||
* corresponding to the Personal Toolbar folder as its root.
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_NewPersonalToolbarPane (HT_Notification notify);
|
||||
|
||||
/* HT_NewBreadcrumbPane
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_NewBreadcrumbPane (HT_Notification notify);
|
||||
|
||||
PR_PUBLIC_API(void) HT_AddToContainer (HT_Resource container, char *url, char *optionalTitle);
|
||||
PR_PUBLIC_API(void) HT_AddBookmark (char *url, char *optionalTitle);
|
||||
|
||||
/* CreateView
|
||||
* Takes an rdf node as the root of the view tree and creates a XP view.
|
||||
* HT_Notification would be to the notifier when there is a state change.
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_NewPane (HT_Notification notify);
|
||||
|
||||
/* DeleteView
|
||||
* Destroy a valid view created via CreateView
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Error) HT_DeleteView (HT_View view);
|
||||
PR_PUBLIC_API(HT_Error) HT_DeletePane (HT_Pane pane);
|
||||
|
||||
/* HT_TopNode
|
||||
* Obtain the top node associated with a view tree
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Resource) HT_TopNode (HT_View view);
|
||||
|
||||
PR_PUBLIC_API(void*) HT_GetViewFEData (HT_View node);
|
||||
PR_PUBLIC_API(void) HT_SetViewFEData (HT_View node, void* data);
|
||||
PR_PUBLIC_API(void*) HT_GetPaneFEData (HT_Pane pane);
|
||||
PR_PUBLIC_API(void) HT_SetPaneFEData (HT_Pane pane, void* data);
|
||||
|
||||
PR_PUBLIC_API(HT_View) HT_GetSelectedView (HT_Pane pane);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetSelectedView (HT_Pane pane, HT_View view);
|
||||
|
||||
#ifdef XPCOM_XXX
|
||||
PR_PUBLIC_API(void) HT_LayoutComplete(MWContext *context, TagList *metaTags, char *url);
|
||||
#endif
|
||||
|
||||
enum _HT_ViewType {
|
||||
HT_VIEW_BOOKMARK=0, HT_VIEW_HISTORY, HT_VIEW_SITEMAP, HT_VIEW_FILES, HT_VIEW_SEARCH
|
||||
} ;
|
||||
typedef enum _HT_ViewType HT_ViewType;
|
||||
|
||||
/*
|
||||
* HT_GetViewType: find a particular view type (returns NULL if not found or unknown)
|
||||
*/
|
||||
PR_PUBLIC_API(HT_View) HT_GetViewType (HT_Pane pane, HT_ViewType viewType);
|
||||
|
||||
|
||||
/*
|
||||
* HT_GetView
|
||||
* Obtain the view tree associated with a node
|
||||
*/
|
||||
PR_PUBLIC_API(HT_View) HT_GetView (HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Pane) HT_GetPane (HT_View view);
|
||||
|
||||
/*
|
||||
* HT_GetViewData / HT_SetViewData
|
||||
* get/set FE specific data to be associated with a view
|
||||
*/
|
||||
PR_PUBLIC_API(void*) HT_GetNodeFEData (HT_Resource node);
|
||||
PR_PUBLIC_API(void) HT_SetNodeFEData (HT_Resource node, void* data);
|
||||
|
||||
/*
|
||||
* HT_GetNotificationMask / HT_SetNotificationMask
|
||||
* get/set the notification mask associated with a view
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Error) HT_GetNotificationMask (HT_Pane node, HT_NotificationMask *mask);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetNotificationMask (HT_Pane node, HT_NotificationMask mask);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* View Traversal */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
PR_PUBLIC_API(char *) HT_GetViewName(HT_View view);
|
||||
|
||||
/*
|
||||
* HT_GetNthView
|
||||
*/
|
||||
PR_PUBLIC_API(HT_View) HT_GetNthView (HT_Pane pane, uint32 theIndex);
|
||||
PR_PUBLIC_API(uint32) HT_GetViewIndex(HT_View view);
|
||||
PR_PUBLIC_API(uint32) HT_GetViewListCount(HT_Pane pane);
|
||||
|
||||
/*
|
||||
* HT_GetNthItem / HT_GetNodeIndex
|
||||
* get the nth resource in a view (or NULL if not in view),
|
||||
* or find a resource's index in a view
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Resource) HT_GetNthItem (HT_View view, uint32 theIndex);
|
||||
PR_PUBLIC_API(uint32) HT_GetNodeIndex(HT_View view, HT_Resource node);
|
||||
PR_PUBLIC_API(uint32) HT_GetItemListCount(HT_View view);
|
||||
PR_PUBLIC_API(uint16) HT_GetItemIndentation(HT_Resource r);
|
||||
/*
|
||||
* HT_GetParent
|
||||
* obtain the parent of a node
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Resource) HT_GetParent (HT_Resource node);
|
||||
|
||||
/*
|
||||
* HT_NodeDisplayString/HT_ViewDisplayString (obsolete)
|
||||
* obtain the name of a node
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Error) HT_NodeDisplayString (HT_Resource node, char *buffer, int bufferLen); /* obsolete! */
|
||||
PR_PUBLIC_API(HT_Error) HT_ViewDisplayString (HT_View view, char *buffer, int bufferLen); /* obsolete! */
|
||||
|
||||
/* an API for external access to the templates. It takes a specifier
|
||||
defined by enum TemplateType, in this file. HT_GetTemplate() returns
|
||||
the basic HT_Pane corresponding to the requested type. */
|
||||
PR_PUBLIC_API(HT_Pane) HT_GetTemplate(int templateType);
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_GetTemplateData(HT_Resource node, void* token, uint32 tokenType, void **nodeData);
|
||||
PR_PUBLIC_API(PRBool) HT_GetNodeData (HT_Resource node, void *token,
|
||||
uint32 tokenType, void **data);
|
||||
PR_PUBLIC_API(PRBool) HT_IsNodeDataEditable(HT_Resource node,
|
||||
void *token, uint32 tokenType);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetNodeData (HT_Resource node, void *token,
|
||||
uint32 tokenType, void *data);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetNodeName (HT_Resource node, void *data);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetTreeStateForButton(HT_Resource node, int state);
|
||||
PR_PUBLIC_API(int) HT_GetTreeStateForButton(HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetWindowType(HT_Pane pane, int windowType);
|
||||
PR_PUBLIC_API(int) HT_GetWindowType(HT_Pane pane);
|
||||
|
||||
/*
|
||||
* HT_GetLargeIconURL / HT_GetSmallIconURL
|
||||
* obtain the large/small icon URLs for a node if available, otherwise return NULL
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(char *) HT_GetWorkspaceLargeIconURL (HT_View view);
|
||||
PR_PUBLIC_API(char *) HT_GetWorkspaceSmallIconURL (HT_View view);
|
||||
PR_PUBLIC_API(char *) HT_GetNodeLargeIconURL (HT_Resource r);
|
||||
PR_PUBLIC_API(char *) HT_GetNodeSmallIconURL (HT_Resource r);
|
||||
PR_PUBLIC_API(char *) HT_GetIconURL(HT_Resource r, PRBool isToolbarIcon, PRBool isWorkspace, int buttonState);
|
||||
|
||||
PR_PUBLIC_API(char *) HT_GetLargeIconURL (HT_Resource r); /* obsolete! */
|
||||
PR_PUBLIC_API(char *) HT_GetSmallIconURL (HT_Resource r); /* obsolete! */
|
||||
|
||||
/*
|
||||
* HT_NewColumnCursor / HT_GetNextColumn / HT_DeleteColumnCursor
|
||||
* obtain column information
|
||||
*/
|
||||
|
||||
enum _HT_ColumnType {
|
||||
HT_COLUMN_UNKNOWN=0, HT_COLUMN_STRING, HT_COLUMN_DATE_STRING,
|
||||
HT_COLUMN_DATE_INT, HT_COLUMN_INT, HT_COLUMN_RESOURCE
|
||||
} ;
|
||||
typedef enum _HT_ColumnType HT_ColumnType;
|
||||
|
||||
PR_PUBLIC_API(HT_Cursor) HT_NewColumnCursor (HT_View view);
|
||||
PR_PUBLIC_API(PRBool) HT_GetNextColumn(HT_Cursor cursor, char **colName,
|
||||
uint32 *colWidth, void **token, uint32 *tokenType);
|
||||
PR_PUBLIC_API(void) HT_DeleteColumnCursor(HT_Cursor cursor);
|
||||
PR_PUBLIC_API(void) HT_SetColumnOrder(HT_View view, void *srcColToken,
|
||||
void *destColToken,
|
||||
PRBool afterDestFlag);
|
||||
PR_PUBLIC_API(void) HT_SetSortColumn(HT_View view, void *token,
|
||||
uint32 tokenType, PRBool descendingFlag);
|
||||
PR_PUBLIC_API(void) HT_SetColumnWidth(HT_View view, void *token,
|
||||
uint32 tokenType, uint32 width);
|
||||
PR_PUBLIC_API(uint32) HT_GetColumnWidth(HT_View view, void *token, uint32 tokenType);
|
||||
PR_PUBLIC_API(void) HT_SetColumnVisibility(HT_View view, void *token, uint32 tokenType, PRBool isHiddenFlag);
|
||||
PR_PUBLIC_API(PRBool) HT_GetColumnVisibility(HT_View view, void *token, uint32 tokenType);
|
||||
PR_PUBLIC_API(void) HT_ShowColumn(HT_View view, void *token, uint32 tokenType);
|
||||
PR_PUBLIC_API(void) HT_HideColumn(HT_View view, void *token, uint32 tokenType);
|
||||
PR_PUBLIC_API(PRBool) HT_ContainerSupportsNaturalOrderSort(HT_Resource container);
|
||||
PR_PUBLIC_API(void) HT_SetColumnFEData(HT_View view, void *token, void *data);
|
||||
PR_PUBLIC_API(void *) HT_GetColumnFEData (HT_View view, void *token);
|
||||
|
||||
PR_PUBLIC_API(void) HT_SetTopVisibleNodeIndex(HT_View view, uint32 topNodeIndex);
|
||||
PR_PUBLIC_API(uint32) HT_GetTopVisibleNodeIndex(HT_View view);
|
||||
|
||||
|
||||
/*
|
||||
* HT Menu Commands
|
||||
*/
|
||||
|
||||
enum _HT_MenuCmd {
|
||||
HT_CMD_SEPARATOR=0, HT_CMD_OPEN, HT_CMD_OPEN_FILE, HT_CMD_PRINT_FILE,
|
||||
HT_CMD_OPEN_NEW_WIN, HT_CMD_OPEN_COMPOSER, HT_CMD_OPEN_AS_WORKSPACE,
|
||||
HT_CMD_NEW_BOOKMARK, HT_CMD_NEW_FOLDER, HT_CMD_NEW_SEPARATOR,
|
||||
HT_CMD_MAKE_ALIAS, HT_CMD_ADD_TO_BOOKMARKS, HT_CMD_SAVE_AS,
|
||||
HT_CMD_CREATE_SHORTCUT, HT_CMD_SET_TOOLBAR_FOLDER,
|
||||
HT_CMD_SET_BOOKMARK_MENU, HT_CMD_SET_BOOKMARK_FOLDER, HT_CMD_CUT,
|
||||
HT_CMD_COPY, HT_CMD_PASTE, HT_CMD_DELETE_FILE, HT_CMD_DELETE_FOLDER,
|
||||
HT_CMD_REVEAL_FILEFOLDER, HT_CMD_PROPERTIES, HT_CMD_RENAME_WORKSPACE,
|
||||
HT_CMD_DELETE_WORKSPACE, HT_CMD_MOVE_WORKSPACE_UP, HT_CMD_MOVE_WORKSPACE_DOWN,
|
||||
HT_CMD_REFRESH, HT_CMD_EXPORT, HT_CMD_REMOVE_BOOKMARK_MENU,
|
||||
HT_CMD_REMOVE_BOOKMARK_FOLDER, HT_CMD_SET_PASSWORD, HT_CMD_REMOVE_PASSWORD,
|
||||
HT_CMD_EXPORTALL, HT_CMD_UNDO, HT_CMD_NEW_WORKSPACE, HT_CMD_RENAME, HT_CMD_FIND,
|
||||
HT_CMD_GET_NEW_MAIL
|
||||
};
|
||||
|
||||
typedef enum _HT_MenuCmd HT_MenuCmd;
|
||||
|
||||
PR_PUBLIC_API(HT_Cursor) HT_NewContextMenuCursor(HT_Resource r);
|
||||
PR_PUBLIC_API(HT_Cursor) HT_NewContextualMenuCursor (HT_View view,
|
||||
PRBool workspaceMenuCmds,
|
||||
PRBool backgroundMenuCmds);
|
||||
PR_PUBLIC_API(PRBool) HT_NextContextMenuItem(HT_Cursor c, HT_MenuCmd *menuCmd);
|
||||
PR_PUBLIC_API(void) HT_DeleteContextMenuCursor(HT_Cursor c);
|
||||
PR_PUBLIC_API(char *) HT_GetMenuCmdName(HT_MenuCmd menuCmd);
|
||||
PR_PUBLIC_API(HT_Error) HT_DoMenuCmd(HT_Pane pane, HT_MenuCmd menuCmd);
|
||||
PR_PUBLIC_API(PRBool) HT_IsMenuCmdEnabled(HT_Pane pane, HT_MenuCmd menuCmd);
|
||||
|
||||
/*
|
||||
* HT_Find
|
||||
* show HTML find dialog (hint is the default string to look for and can be NULL)
|
||||
*/
|
||||
PR_PUBLIC_API(void) HT_Find(char *hint);
|
||||
|
||||
/*
|
||||
* HT_Properties
|
||||
* show HTML dialog of node's properties
|
||||
*/
|
||||
PR_PUBLIC_API(void) HT_Properties (HT_Resource r);
|
||||
|
||||
|
||||
/*
|
||||
* HT_GetRDFResource
|
||||
* obtain the RDF_Resource associated with a HT node
|
||||
*/
|
||||
PR_PUBLIC_API(RDF_Resource) HT_GetRDFResource (HT_Resource node);
|
||||
|
||||
/*
|
||||
* Access the node's name and URL
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(char *) HT_GetNodeURL(HT_Resource node);
|
||||
PR_PUBLIC_API(char *) HT_GetNodeDisplayURL(HT_Resource node);
|
||||
PR_PUBLIC_API(char *) HT_GetNodeName(HT_Resource node);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Accessor and Mutators */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* HT_IsURLBar
|
||||
* determine whether node is a URL bar
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_IsURLBar (HT_Resource node);
|
||||
|
||||
/*
|
||||
* HT_IsSeparator
|
||||
* determine whether node is a separator
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_IsSeparator (HT_Resource node);
|
||||
|
||||
/*
|
||||
* HT_IsContainer
|
||||
* determine whether node is a container
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_IsContainer (HT_Resource node);
|
||||
PR_PUBLIC_API(uint32) HT_GetCountVisibleChildren(HT_Resource node);
|
||||
PR_PUBLIC_API(uint32) HT_GetCountDirectChildren(HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Resource) HT_GetContainerItem(HT_Resource parent, uint32 childNum);
|
||||
|
||||
/*
|
||||
* HT_DataSource : obtain the origin of the data
|
||||
* HT_IsLocalData : is the data local?
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_IsLocalData (HT_Resource node) ;
|
||||
PR_PUBLIC_API(char *) HT_DataSource (HT_Resource node) ;
|
||||
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_GetHTPaneList ();
|
||||
PR_PUBLIC_API(HT_Pane) HT_GetNextHTPane (HT_Pane pane);
|
||||
/*
|
||||
* HT_IsSelected / HT_GetSelectedState / HT_SetSelectedState
|
||||
* manage selection state of a node; get/set operations will generate
|
||||
* a HT_EVENT_NODE_SELECTION_CHANGED notification unless masked out
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_IsSelected (HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Error) HT_GetSelectedState (HT_Resource node, PRBool *selectedState);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetSelectedState (HT_Resource node, PRBool isSelected);
|
||||
|
||||
PR_PUBLIC_API(HT_Error) HT_SetSelection (HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetSelectionAll (HT_View view, PRBool selectedState);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetSelectionRange (HT_Resource node1, HT_Resource node2);
|
||||
|
||||
PR_PUBLIC_API(HT_Resource) HT_GetNextSelection(HT_View view, HT_Resource startingNode);
|
||||
PR_PUBLIC_API(void) HT_ToggleSelection(HT_Resource node);
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_IsEnabled (HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Error) HT_GetEnabledState (HT_Resource node, PRBool *enabledState);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetEnabledState(HT_Resource node, PRBool isEnabled);
|
||||
|
||||
#ifdef XPCOM_XXX /* mwcontext dependency */
|
||||
PR_PUBLIC_API(PRBool) HT_Launch(HT_Resource node, MWContext *context);
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_LaunchURL(HT_Pane pane, char *url, MWContext *context);
|
||||
#endif
|
||||
|
||||
PR_PUBLIC_API(void) HT_TypeTo(HT_Pane pane, char *typed);
|
||||
|
||||
/*
|
||||
* HT_NewCursor, HT_GetNextItem, HT_DeleteCursor
|
||||
* Used to iterate over a container's children. Until the container has been
|
||||
* opened at least once, you won't see any of the children.
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(HT_Cursor) HT_NewCursor (HT_Resource node) ;
|
||||
PR_PUBLIC_API(HT_Error) HT_DeleteCursor (HT_Cursor cursor) ;
|
||||
PR_PUBLIC_API(HT_Resource) HT_GetNextItem (HT_Cursor cursor) ;
|
||||
|
||||
/*
|
||||
* HT_IsContainerOpen / HT_GetOpenState / HT_SetOpenState
|
||||
* manage open state of a node; get/set operations will generate
|
||||
* a HT_EVENT_NODE_OPENCLOSE_CHANGED notification unless masked out
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_IsContainerOpen (HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Error) HT_GetOpenState (HT_Resource containerNode, PRBool *openState);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetOpenState (HT_Resource containerNode, PRBool isOpen);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetAutoFlushOpenState (HT_Resource containerNode, PRBool isOpen);
|
||||
|
||||
|
||||
/*
|
||||
* HT_ItemHasForwardSibling / HT_ItemHasBackwardSibling
|
||||
* determine if a given node has a following/previous sibling node
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_ItemHasForwardSibling(HT_Resource r);
|
||||
PR_PUBLIC_API(PRBool) HT_ItemHasBackwardSibling(HT_Resource r);
|
||||
|
||||
PR_PUBLIC_API(void) HT_NewWorkspace(HT_Pane pane, char *id, char *optionalTitle);
|
||||
PR_PUBLIC_API(void) HT_SetWorkspaceOrder(HT_View src, HT_View dest, PRBool afterDestFlag);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Creating new containers */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
PR_PUBLIC_API(HT_Resource) HT_MakeNewContainer(HT_Resource parent, char* name);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Drag and Drop */
|
||||
/* drop actions should be made an enum */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
typedef uint8 HT_DropAction;
|
||||
|
||||
|
||||
#define DROP_NOT_ALLOWED 0
|
||||
#define COPY_MOVE_CONTENT 1
|
||||
#define UPLOAD_RDF 2
|
||||
#define COPY_MOVE_LINK 3
|
||||
#define UPLOAD_LFS 4
|
||||
#define DROP_ABORTED 5
|
||||
|
||||
PR_PUBLIC_API(HT_DropAction) HT_CanDropHTROn(HT_Resource dropTarget, HT_Resource obj);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_CanDropURLOn(HT_Resource dropTarget, char* url);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropHTROn(HT_Resource dropTarget, HT_Resource obj);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropURLOn(HT_Resource dropTarget, char* url);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropURLAndTitleOn(HT_Resource dropTarget,
|
||||
char* url, char *title);
|
||||
|
||||
PR_PUBLIC_API(HT_DropAction) HT_CanDropHTRAtPos(HT_Resource dropTarget, HT_Resource obj,
|
||||
PRBool before);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_CanDropURLAtPos(HT_Resource dropTarget, char* url,
|
||||
PRBool before);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropHTRAtPos(HT_Resource dropTarget, HT_Resource obj,
|
||||
PRBool before);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropURLAtPos(HT_Resource dropTarget, char* url,
|
||||
PRBool before);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropURLAndTitleAtPos(HT_Resource dropTarget,
|
||||
char* url, char *title, PRBool before);
|
||||
PR_PUBLIC_API(PRBool) HT_IsDropTarget(HT_Resource dropTarget);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Editing */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_RemoveChild (HT_Resource parent, HT_Resource child);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Other */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
|
||||
PR_PUBLIC_API(RDF) RDF_GetNavCenterDB();
|
||||
PR_PUBLIC_API(void) HT_InformRDFOfNewDocument(char* address);
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_HasHTMLPane(HT_View htView);
|
||||
PR_PUBLIC_API(char *) HT_HTMLPaneHeight(HT_View htView);
|
||||
|
||||
PR_PUBLIC_API(void) HT_AddSitemapFor(HT_Pane htPane, char *pUrl, char *pSitemapUrl, char* name);
|
||||
PR_PUBLIC_API(void) HT_AddRelatedLinksFor(HT_Pane htPane, char *pUrl);
|
||||
PR_PUBLIC_API(void) HT_ExitPage(HT_Pane htPane, char *pUrl);
|
||||
PR_PUBLIC_API(void)
|
||||
RDF_AddCookieResource(char* name, char* path, char* host, char* expires, char* value,
|
||||
PRBool isDomain, PRBool secure) ;
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif /* htrdf_h___ */
|
||||
75
mozilla/modules/rdf/include/jsec2rdf.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _JSEC_2_RDF_H_
|
||||
#define _JSEC_2_RDF_H_
|
||||
|
||||
#include "rdf.h"
|
||||
|
||||
typedef int16 JSec_Error;
|
||||
|
||||
#define JSec_OK ((JSec_Error)0x0000)
|
||||
#define JSec_NullObject ((JSec_Error)0x0001)
|
||||
|
||||
typedef RDF_Resource JSec_Principal;
|
||||
typedef RDF_Resource JSec_PrincipalUse;
|
||||
typedef RDF_Resource JSec_Target;
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
PR_EXTERN(char*) RDFJSec_GetPrincipalURLString(char *principalID);
|
||||
PR_EXTERN(const char*) RDFJSec_PrincipalUseID(JSec_PrincipalUse prUse);
|
||||
|
||||
PR_EXTERN(JSec_Error) RDFJSec_InitPrivilegeDB(); /* just use gNCDB */
|
||||
PR_EXTERN(JSec_Error) RDFJSec_SavePrivilegeDB();
|
||||
PR_EXTERN(JSec_Error) RDFJSec_ClosePrivilegeDB();
|
||||
|
||||
PR_EXTERN(RDF_Cursor) RDFJSec_ListAllPrincipals();
|
||||
PR_EXTERN(JSec_Principal) RDFJSec_NextPrincipal(RDF_Cursor c);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_ReleaseCursor(RDF_Cursor c);
|
||||
|
||||
PR_EXTERN(JSec_Principal) RDFJSec_NewPrincipal(char* principalID);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_AddPrincipal(JSec_Principal pr);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_DeletePrincipal(JSec_Principal pr);
|
||||
PR_EXTERN(char*) RDFJSec_PrincipalID(JSec_Principal pr);
|
||||
PR_EXTERN(void*) RDFJSec_AttributeOfPrincipal(JSec_Principal pr, char* attributeType);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_SetPrincipalAttribute(JSec_Principal pr, char* attributeType, void* attValue);
|
||||
|
||||
PR_EXTERN(RDF_Cursor) RDFJSec_ListAllPrincipalUses(JSec_Principal pr);
|
||||
PR_EXTERN(JSec_PrincipalUse) RDFJSec_NextPrincipalUse(RDF_Cursor c);
|
||||
|
||||
PR_EXTERN(JSec_PrincipalUse) RDFJSec_NewPrincipalUse(JSec_Principal pr, JSec_Target tr, char* priv);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_AddPrincipalUse(JSec_Principal pr, JSec_PrincipalUse prUse);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_DeletePrincipalUse (JSec_Principal pr, JSec_PrincipalUse prUse);
|
||||
|
||||
PR_EXTERN(JSec_Error) RDFJSec_AddPrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_DeletePrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv);
|
||||
PR_EXTERN(char*) RDFJSec_PrivilegeOfPrincipalUse (JSec_PrincipalUse p);
|
||||
|
||||
PR_EXTERN(JSec_Error) RDFJSec_AddTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_DeleteTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr);
|
||||
PR_EXTERN(JSec_Target) RDFJSec_TargetOfPrincipalUse (JSec_PrincipalUse p);
|
||||
|
||||
PR_EXTERN(JSec_Target) RDFJSec_NewTarget(char* targetName, JSec_Principal pr);
|
||||
PR_EXTERN(char*) RDFJSec_GetTargetName(JSec_Target tr);
|
||||
PR_EXTERN(char*) RDFJSec_AttributeOfTarget(JSec_Target tr, char* attributeType);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_SetTargetAttribute(JSec_Target tr, char* attributeType, char* attValue);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif /* _JSEC_2_RDF_H_ */
|
||||
37
mozilla/modules/rdf/include/makefile.win
Normal file
@@ -0,0 +1,37 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
DEPTH = ..\..\..
|
||||
|
||||
EXPORTS = rdf.h \
|
||||
rdfc.h \
|
||||
nsIRDFService.h \
|
||||
nsIRDFDataSource.h \
|
||||
nsIRDFDataBase.h \
|
||||
nsIRDFObserver.h \
|
||||
nsIRDFCursor.h \
|
||||
htrdf.h \
|
||||
vocab.h \
|
||||
jsec2rdf.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
53
mozilla/modules/rdf/include/nsIRDFCursor.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFCursor_h__
|
||||
#define nsIRDFCursor_h__
|
||||
|
||||
/*
|
||||
|
||||
nsIRDFCursor:
|
||||
|
||||
An iterator for RDF data sources.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "rdf.h"
|
||||
|
||||
|
||||
// 1c2abdb0-4cef-11d2-bc16-00805f912fe7
|
||||
#define NS_IRDFCURSOR_IID \
|
||||
{ \
|
||||
0x1c2abdb0, \
|
||||
0x4cef, \
|
||||
0x11d2, \
|
||||
{ 0xbc, 0x16, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } \
|
||||
}
|
||||
|
||||
|
||||
class nsIRDFCursor : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD HasElements(PRBool& hasElements) = 0;
|
||||
|
||||
NS_IMETHOD Next(RDF_NodeStruct& next /* in/out */) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIRDFCursor_h__ */
|
||||
74
mozilla/modules/rdf/include/nsIRDFDataBase.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFDataBase_h__
|
||||
#define nsIRDFDataBase_h__
|
||||
|
||||
/*
|
||||
This file contains the interface definition for an RDF database.
|
||||
|
||||
RDF databases aggregate RDF data sources (see nsIRDFDataSource.h)
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "rdf.h"
|
||||
|
||||
|
||||
// 96343820-307c-11d2-bc15-00805f912fe7
|
||||
#define NS_IRDFDATABASE_IID \
|
||||
{ \
|
||||
0x96343820, \
|
||||
0x307c, \
|
||||
0x11d2, \
|
||||
{ 0xb, 0xc15, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } \
|
||||
}
|
||||
|
||||
|
||||
class nsIRDFDataBase : public nsIRDFDataSource {
|
||||
public:
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
NS_IMETHOD Initialize(nsIRDFResourceManager* r) = 0;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
/*
|
||||
Add a data source for the specified URL to the database.
|
||||
|
||||
Parameters:
|
||||
dataSource -- a ptr to the data source to add
|
||||
|
||||
Returns:
|
||||
*/
|
||||
NS_IMETHOD AddDataSource(nsIRDFDataSource* dataSource) = 0;
|
||||
|
||||
NS_IMETHOD RemoveDataSource(nsIRDFDataSource* dataSource) = 0;
|
||||
|
||||
NS_IMETHOD GetDataSource(RDF_String url,
|
||||
nsIRDFDataSource **source /* out */ ) = 0;
|
||||
#endif
|
||||
|
||||
// XXX move these to datasource?
|
||||
NS_IMETHOD DeleteAllArcs(RDF_Resource resource) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIRDFDataBase_h__ */
|
||||
223
mozilla/modules/rdf/include/nsIRDFDataSource.h
Normal file
@@ -0,0 +1,223 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFDataSource_h__
|
||||
#define nsIRDFDataSource_h__
|
||||
|
||||
/*
|
||||
This file contains the interface definition for an RDF data source.
|
||||
|
||||
Classes which implement this interface for a particular type of URL
|
||||
are registered with the RDF singleton via nsIRDF::RegisterHandler(...)
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "rdf.h"
|
||||
|
||||
// 852666b0-2cce-11d2-bc14-00805f912fe7
|
||||
#define NS_IRDFDATASOURCE_IID \
|
||||
{ \
|
||||
0x852666b0, \
|
||||
0x2cce, \
|
||||
0x11d2, \
|
||||
{ 0xb, 0xc14,0x00, 0x80, 0x5f, 0x91 0x2f, 0xe7 } \
|
||||
}
|
||||
|
||||
class nsIRDFCursor;
|
||||
class nsIRDFObserver;
|
||||
class nsIRDFDataBase;
|
||||
|
||||
class nsIRDFDataSource : public nsISupports {
|
||||
public:
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
/**
|
||||
* Initialize this data source
|
||||
*/
|
||||
NS_IMETHOD Initialize(RDF_String url,
|
||||
nsIRDFResourceManager* m);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the name of this data source.
|
||||
*
|
||||
* For regular data sources, this will be the URL of the source.
|
||||
*
|
||||
* For aggregated sources, it generally will not be a valid RDF URL.
|
||||
*/
|
||||
NS_IMETHOD GetName(const RDF_String* name /* out */ ) = 0;
|
||||
|
||||
/**
|
||||
* Find an RDF resource that points to a given node over the
|
||||
* specified arc & truth value (defaults to "PR_TRUE").
|
||||
*/
|
||||
NS_IMETHOD GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Resource *source /* out */) = 0;
|
||||
|
||||
NS_IMETHOD GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_Resource *source /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Find all RDF resources that point to a given node over the
|
||||
* specified arc & truth value (defaults to "PR_TRUE").
|
||||
*/
|
||||
NS_IMETHOD GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
nsIRDFCursor **sources /* out */) = 0;
|
||||
|
||||
NS_IMETHOD GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
nsIRDFCursor **sources /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Find a child of that is related to the source by the given arc
|
||||
* arc and truth value (defaults to PR_TRUE).
|
||||
*/
|
||||
NS_IMETHOD GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
RDF_NodeStruct& target /* in/out */) = 0;
|
||||
|
||||
NS_IMETHOD GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
PRBool tv,
|
||||
RDF_NodeStruct& target /* in/out */) = 0;
|
||||
|
||||
/**
|
||||
* Find all children of that are related to the source by the given arc
|
||||
* arc and truth value (defaults to PR_TRUE).
|
||||
*/
|
||||
NS_IMETHOD GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */) = 0;
|
||||
|
||||
NS_IMETHOD GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */) = 0;
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
/**
|
||||
* Find all parents that point to a node over a given arc label,
|
||||
* regardless of truth value.
|
||||
*/
|
||||
NS_IMETHOD GetAllSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
nsIRDFCursor2 **sources /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Find all children of a resource that are related by the
|
||||
* given arc label, regardless of the truth value.
|
||||
*/
|
||||
NS_IMETHOD GetAllTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor2 **targets /* out */);
|
||||
#endif /* RDF_NOT_IMPLEMENTED */
|
||||
|
||||
|
||||
/**
|
||||
* Add an assertion to the graph.
|
||||
*/
|
||||
NS_IMETHOD Assert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool tv = PR_TRUE) = 0;
|
||||
|
||||
/**
|
||||
* Remove an assertion from the graph.
|
||||
*/
|
||||
NS_IMETHOD Unassert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target) = 0;
|
||||
|
||||
/**
|
||||
* Query whether an assertion exists in this graph.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD HasAssertion(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool truthValue,
|
||||
PRBool* hasAssertion /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Add an observer to this data source.
|
||||
*/
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver *n,
|
||||
RDF_EventMask type = RDF_ANY_NOTIFY) = 0;
|
||||
|
||||
/**
|
||||
* Remove an observer from this data source
|
||||
*/
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver *n,
|
||||
RDF_EventMask = RDF_ANY_NOTIFY) = 0;
|
||||
|
||||
/**
|
||||
* Get a cursor to iterate over all the arcs that point into a node.
|
||||
*/
|
||||
NS_IMETHOD ArcLabelsIn(RDF_Node node,
|
||||
nsIRDFCursor **labels /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Get a cursor to iterate over all the arcs that originate in
|
||||
* a resource.
|
||||
*/
|
||||
NS_IMETHOD ArcLabelsOut(RDF_Resource source,
|
||||
nsIRDFCursor **labels /* out */) = 0;
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
/**
|
||||
* Notify this data source that it is a child of a database.
|
||||
*
|
||||
* The datasource must send notifications to the parent when
|
||||
* changes to it's graph are made, in case the parent has observers
|
||||
* interested in the events generated.
|
||||
*/
|
||||
NS_IMETHOD AddParent(nsIRDFDataBase* parent) = 0;
|
||||
|
||||
/**
|
||||
* Notify this data source that it has been disconnected from a
|
||||
* parent.
|
||||
*/
|
||||
NS_IMETHOD RemoveParent(nsIRDFDataBase* parent) = 0;
|
||||
|
||||
/**
|
||||
* Request that a data source obtain updates if applicable.
|
||||
*/
|
||||
// XXX move this to an nsIRDFRemoteDataStore interface?
|
||||
NS_IMETHOD Update(RDF_Resource hint) = 0;
|
||||
#endif /* RDF_NOT_IMPLEMENTED */
|
||||
|
||||
/**
|
||||
* Request that a data source write it's contents out to
|
||||
* permanent storage if applicable.
|
||||
*/
|
||||
NS_IMETHOD Flush() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIRDFDataSource_h__ */
|
||||
51
mozilla/modules/rdf/include/nsIRDFObserver.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFObserver_h__
|
||||
#define nsIRDFObserver_h__
|
||||
|
||||
/*
|
||||
This file defines the interface for RDF observers.
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "rdf.h"
|
||||
|
||||
|
||||
// 3cc75360-484a-11d2-bc16-00805f912fe7
|
||||
#define NS_IRDFOBSERVER_IID \
|
||||
{ \
|
||||
0x3cc75360, \
|
||||
0x484a, \
|
||||
0x11d2, \
|
||||
{ 0xbc, 0x16, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } \
|
||||
}
|
||||
|
||||
class nsIRDFDataSource;
|
||||
|
||||
class nsIRDFObserver : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIRDFDataSource *source,
|
||||
RDF_Event event) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIRDFObserver_h__ */
|
||||
68
mozilla/modules/rdf/include/nsIRDFService.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFService_h__
|
||||
#define nsIRDFService_h__
|
||||
|
||||
/*
|
||||
This file defines the interface for the RDF singleton,
|
||||
which maintains various pieces of pieces of information global
|
||||
to all RDF data sources.
|
||||
|
||||
In particular, it provides the interface for mapping rdf URL types
|
||||
to nsIRDFDataSource implementors for that type of content.
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h" /* nsCID typedef, for consistency */
|
||||
#include "rdf.h"
|
||||
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFDataBase;
|
||||
|
||||
// 6edf3660-32f0-11d2-9abe-00600866748f
|
||||
#define NS_IRDFSERVICE_IID \
|
||||
{ \
|
||||
0x6edf3660, \
|
||||
0x32f0, \
|
||||
0x11d2, \
|
||||
{ 0x9a, 0xbe, 0x00, 0x60, 0x08, 0x66, 0x74, 0x8f } \
|
||||
}
|
||||
|
||||
|
||||
class nsIRDFService : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD Initialize();
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
NS_IMETHOD RegisterHandler(RDF_String url_selector, const nsCID& clsid) = 0;
|
||||
|
||||
NS_IMETHOD RemoveHandler(RDF_String url_selector, const nsCID& clsid) = 0;
|
||||
|
||||
NS_IMETHOD CreateDataSource(RDF_String url,
|
||||
nsIRDFDataSource **source /* out */) = 0;
|
||||
#endif /* RDF_NOT_IMPLEMENTED */
|
||||
|
||||
NS_IMETHOD CreateDatabase(const RDF_String* url_ary,
|
||||
nsIRDFDataBase **db /* out */) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIRDFService_h__ */
|
||||
120
mozilla/modules/rdf/include/rdf.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef rdf_h___
|
||||
#define rdf_h___
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsError.h"
|
||||
|
||||
typedef nsresult RDF_Error;
|
||||
|
||||
#define RDF_ERROR_ILLEGAL_ASSERT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF,1)
|
||||
#define RDF_ERROR_ILLEGAL_KILL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF,2)
|
||||
#define RDF_ERROR_UNABLE_TO_CREATE NS_ERROR_GENERATE_FAILURE( NS_ERROR_MODULE_RDF,3)
|
||||
|
||||
#define RDF_ERROR_NO_MEMORY NS_ERROR_OUT_OF_MEMORY /* XXX remove this */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct RDF_ResourceStruct* RDF_Resource;
|
||||
typedef struct RDF_CursorStruct* RDF_Cursor;
|
||||
typedef struct RDF_DBStruct* RDF;
|
||||
typedef struct RDF_TranslatorStruct *RDFT;
|
||||
|
||||
typedef char* RDF_String;
|
||||
|
||||
typedef enum {
|
||||
RDF_ANY_TYPE,
|
||||
RDF_RESOURCE_TYPE,
|
||||
RDF_INT_TYPE,
|
||||
RDF_STRING_TYPE,
|
||||
#ifdef RDF_BLOB
|
||||
RDF_BLOB_TYPE
|
||||
#endif
|
||||
} RDF_ValueType;
|
||||
|
||||
|
||||
#ifdef RDF_BLOB
|
||||
typedef struct RDF_BlobStruct {
|
||||
PRUint32 size;
|
||||
void* data;
|
||||
} *RDF_Blob;
|
||||
#endif
|
||||
|
||||
typedef struct RDF_NodeStruct {
|
||||
RDF_ValueType type;
|
||||
union {
|
||||
RDF_Resource r;
|
||||
RDF_String s;
|
||||
#ifdef RDF_BLOB
|
||||
RDF_Blob b;
|
||||
#endif
|
||||
} value;
|
||||
} *RDF_Node;
|
||||
|
||||
typedef PRUint32 RDF_EventType;
|
||||
#define RDF_ASSERT_NOTIFY ((RDF_EventType)0x00000001)
|
||||
#define RDF_DELETE_NOTIFY ((RDF_EventType)0x00000002)
|
||||
#define RDF_KILL_NOTIFY ((RDF_EventType)0x00000004)
|
||||
#define RDF_CREATE_NOTIFY ((RDF_EventType)0x00000008)
|
||||
#define RDF_RESOURCE_GC_NOTIFY ((RDF_EventType)0x00000010)
|
||||
#define RDF_INSERT_NOTIFY ((RDF_EventType)0x00000020)
|
||||
|
||||
typedef PRUint32 RDF_EventMask;
|
||||
#define RDF_ANY_NOTIFY ((RDF_EventMask)0xFFFFFFFF)
|
||||
|
||||
typedef struct RDF_AssertEventStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
void* v;
|
||||
RDF_ValueType type;
|
||||
PRBool tv;
|
||||
char* dataSource;
|
||||
} *RDF_AssertEvent;
|
||||
|
||||
|
||||
typedef struct RDF_UnassertEventStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
void* v;
|
||||
RDF_ValueType type;
|
||||
char* dataSource;
|
||||
} *RDF_UnassertEvent;
|
||||
|
||||
typedef struct RDF_KillEventStruct {
|
||||
RDF_Resource u;
|
||||
} *RDF_KillEvent;
|
||||
|
||||
|
||||
typedef struct RDF_EventStruct {
|
||||
RDF_EventType eventType;
|
||||
union ev {
|
||||
struct RDF_AssertEventStruct assert;
|
||||
struct RDF_UnassertEventStruct unassert;
|
||||
struct RDF_KillEventStruct kill;
|
||||
} event;
|
||||
} *RDF_Event;
|
||||
|
||||
#include "vocab.h"
|
||||
#include "rdfc.h"
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif /* rdf_h___ */
|
||||
106
mozilla/modules/rdf/include/rdf2.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef rdf_h___
|
||||
#define rdf_h___
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsError.h"
|
||||
|
||||
typedef nsresult RDF_Error;
|
||||
|
||||
#define RDF_ERROR_ILLEGAL_ASSERT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF,1)
|
||||
#define RDF_ERROR_ILLEGAL_KILL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF,2)
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct RDF_ResourceStruct* RDF_Resource;
|
||||
typedef struct RDF_CursorStruct* RDF_Cursor;
|
||||
typedef struct RDF_DBStruct* RDF;
|
||||
typedef struct RDF_TranslatorStruct *RDFT;
|
||||
|
||||
typedef enum {
|
||||
RDF_ANY_TYPE,
|
||||
RDF_RESOURCE_TYPE,
|
||||
RDF_INT_TYPE,
|
||||
RDF_STRING_TYPE.
|
||||
#ifdef RDF_BLOB
|
||||
RDF_BLOB_TYPE
|
||||
#endif
|
||||
} RDF_ValueType;
|
||||
|
||||
|
||||
#ifdef RDF_BLOB
|
||||
typedef struct RDF_BlobStruct {
|
||||
PRUint32 size;
|
||||
void* data;
|
||||
} *RDF_Blob;
|
||||
#endif
|
||||
|
||||
typedef struct RDF_NodeStruct {
|
||||
RDF_ValueType type;
|
||||
union {
|
||||
RDF_Resource r;
|
||||
RDF_String s;
|
||||
#ifdef RDF_BLOB
|
||||
RDF_Blob b;
|
||||
#endif
|
||||
} value;
|
||||
} *RDF_Node;
|
||||
|
||||
typedef PRUint32 RDF_EventType;
|
||||
#define RDF_ASSERT_NOTIFY ((RDF_EventType)0x00000001)
|
||||
#define RDF_DELETE_NOTIFY ((RDF_EventType)0x00000002)
|
||||
|
||||
typedef PRUint32 RDF_EventMask;
|
||||
#define RDF_ANY_NOTIFY ((RDF_EventMask)0xFFFFFFFF)
|
||||
|
||||
typedef struct RDF_AssertEventStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
struct RDF_NodeStruct v;
|
||||
PRBool tv;
|
||||
char* dataSource;
|
||||
} *RDF_AssertEvent;
|
||||
|
||||
typedef struct RDF_UnassertEventStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
struct RDF_NodeStruct v;
|
||||
char* dataSource;
|
||||
} *RDF_UnassertEvent;
|
||||
|
||||
typedef struct RDF_KillEventStruct {
|
||||
RDF_Resource u;
|
||||
} *RDF_KillEvent;
|
||||
|
||||
typedef struct RDF_EventStruct {
|
||||
RDF_EventType eventType;
|
||||
union ev {
|
||||
struct RDF_AssertEventStruct assert;
|
||||
struct RDF_UnassertEventStruct unassert;
|
||||
struct RDF_KillEventStruct kill;
|
||||
} event;
|
||||
} *RDF_Event;
|
||||
|
||||
#include "vocab.h"
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif /* rdf_h___ */
|
||||
128
mozilla/modules/rdf/include/rdfc.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef rdfc_h__
|
||||
#define rdfc_h__
|
||||
|
||||
#include "rdf.h"
|
||||
#include "nspr.h"
|
||||
|
||||
/* core rdf apis */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct _RDF_InitParamsStruct {
|
||||
char *profileURL;
|
||||
char *bookmarksURL;
|
||||
char *globalHistoryURL;
|
||||
} RDF_InitParamsStruct;
|
||||
|
||||
typedef struct _RDF_InitParamsStruct* RDF_InitParams;
|
||||
|
||||
struct RDF_NotificationStruct;
|
||||
typedef struct RDF_NotificationStruct* RDF_Notification;
|
||||
|
||||
typedef void (*RDF_NotificationProc)(RDF_Event theEvent, void* pdata);
|
||||
|
||||
PR_PUBLIC_API(RDF) RDF_GetDB(const RDF_String* dbs);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_ReleaseDB(RDF rdf);
|
||||
PR_PUBLIC_API(RDFT) RDF_AddDataSource(RDF rdf, char* dataSource);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_ReleaseDataSource(RDF rdf, RDFT dataSource);
|
||||
PR_PUBLIC_API(RDF_Resource) RDF_GetResource(RDF db, char* id, PRBool createp);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_ReleaseResource(RDF db, RDF_Resource resource);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_DeleteAllArcs(RDF rdfDB, RDF_Resource source);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_Update(RDF rdfDB, RDF_Resource u);
|
||||
|
||||
PR_PUBLIC_API(RDF_Notification) RDF_AddNotifiable (RDF rdfDB, RDF_NotificationProc callBack, RDF_Event ev, void* pdata);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_DeleteNotifiable (RDF_Notification ns);
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool) RDF_Assert(RDF rdfDB, RDF_Resource source, RDF_Resource arcLabel,
|
||||
void* target, RDF_ValueType targetType);
|
||||
PR_PUBLIC_API(PRBool) RDF_AssertFalse(RDF rdfDB, RDF_Resource source, RDF_Resource arcLabel,
|
||||
void* target, RDF_ValueType targetType);
|
||||
PR_PUBLIC_API(PRBool) RDF_Unassert(RDF rdfDB, RDF_Resource source, RDF_Resource arcLabel,
|
||||
void* target, RDF_ValueType targetType);
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool) RDF_CanAssert(RDF rdfDB, RDF_Resource u, RDF_Resource arcLabel, void* v, RDF_ValueType targetType);
|
||||
PR_PUBLIC_API(PRBool) RDF_CanAssertFalse(RDF rdfDB, RDF_Resource u, RDF_Resource arcLabel, void* v, RDF_ValueType targetType);
|
||||
PR_PUBLIC_API(PRBool) RDF_CanUnassert(RDF rdfDB, RDF_Resource u, RDF_Resource arcLabel, void* v, RDF_ValueType targetType);
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool) RDF_HasAssertion (RDF rdfDB, RDF_Resource source, RDF_Resource arcLabel,
|
||||
void* target, RDF_ValueType targetType, PRBool tv);
|
||||
PR_PUBLIC_API(void*) RDF_GetSlotValue (RDF rdfDB, RDF_Resource u, RDF_Resource s, RDF_ValueType targetType,
|
||||
PRBool inversep, PRBool tv);
|
||||
PR_PUBLIC_API(RDF_Cursor) RDF_GetTargets (RDF rdfDB, RDF_Resource source, RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType, PRBool tv);
|
||||
PR_PUBLIC_API(RDF_Cursor) RDF_GetSources (RDF rdfDB, RDF_Resource target, RDF_Resource arcLabel,
|
||||
RDF_ValueType sourceType, PRBool tv);
|
||||
PR_PUBLIC_API(RDF_Cursor) RDF_ArcLabelsOut (RDF rdfDB, RDF_Resource u);
|
||||
PR_PUBLIC_API(RDF_Cursor) RDF_ArcLabelsIn (RDF rdfDB, RDF_Resource u);
|
||||
PR_PUBLIC_API(void*) RDF_NextValue(RDF_Cursor c);
|
||||
PR_PUBLIC_API(char*) RDF_ValueDataSource(RDF_Cursor c);
|
||||
PR_PUBLIC_API(RDF_ValueType) RDF_CursorValueType(RDF_Cursor c);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_DisposeCursor (RDF_Cursor c);
|
||||
|
||||
|
||||
|
||||
/*** Guha needs to get his act together and figure out how to do this.
|
||||
PR_PUBLIC_API(RDF_Error) RDF_Undo(RDF rdf);
|
||||
***/
|
||||
|
||||
/* These two should be removed soon. They are here because Nav Center
|
||||
depends on them. */
|
||||
|
||||
/* PR_PUBLIC_API(RDF_Error) RDF_Init(char *profileDirURL); */
|
||||
PR_PUBLIC_API(RDF_Error) RDF_Init(RDF_InitParams params);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_Shutdown(void);
|
||||
|
||||
/* the stuff in vocab.h will supercede whats below. I am leaving this here
|
||||
only for the very near future */
|
||||
|
||||
|
||||
/** utilities : move out of here!!! **/
|
||||
/* well known resources */
|
||||
|
||||
|
||||
PR_PUBLIC_API(char*) RDF_GetResourceName(RDF rdfDB, RDF_Resource node);
|
||||
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetFirstInstance (RDF_Resource type, char* defaultURL);
|
||||
PR_PUBLIC_API(void) RDFUtil_SetFirstInstance (RDF_Resource type, RDF_Resource item);
|
||||
|
||||
typedef void (*printProc)(void* data, char* str);
|
||||
PR_PUBLIC_API(void) outputMCFTree (RDF db, printProc printer, void* data, RDF_Resource node);
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetBreadcrumb();
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetQuickFileFolder();
|
||||
PR_PUBLIC_API(void) RDFUtil_SetQuickFileFolder(RDF_Resource container);
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetPTFolder();
|
||||
PR_PUBLIC_API(void) RDFUtil_SetPTFolder(RDF_Resource container);
|
||||
PR_PUBLIC_API(RDF_Cursor) RDF_Find (RDF_Resource s, RDF_Resource match, void* v, RDF_ValueType type);
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetNewBookmarkFolder();
|
||||
PR_PUBLIC_API(void) RDFUtil_SetNewBookmarkFolder(RDF_Resource container);
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetDefaultSelectedView();
|
||||
PR_PUBLIC_API(void) RDFUtil_SetDefaultSelectedView(RDF_Resource container);
|
||||
|
||||
/** end utilities **/
|
||||
|
||||
/* this stuff is stuck in here for netlib */
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif /* rdfc_h__ */
|
||||
229
mozilla/modules/rdf/include/vocab.h
Normal file
@@ -0,0 +1,229 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_VOCAB_H_
|
||||
#define _RDF_VOCAB_H_
|
||||
|
||||
typedef struct _RDF_CoreVocabStruct {
|
||||
RDF_Resource RDF_parent;
|
||||
RDF_Resource RDF_name;
|
||||
RDF_Resource RDF_instanceOf;
|
||||
RDF_Resource RDF_subClassOf;
|
||||
RDF_Resource RDF_PropertyType;
|
||||
RDF_Resource RDF_Class;
|
||||
RDF_Resource RDF_slotsHere;
|
||||
RDF_Resource RDF_slotsIn;
|
||||
RDF_Resource RDF_domain;
|
||||
RDF_Resource RDF_range;
|
||||
RDF_Resource RDF_StringType;
|
||||
RDF_Resource RDF_IntType;
|
||||
RDF_Resource RDF_equals;
|
||||
RDF_Resource RDF_lessThan;
|
||||
RDF_Resource RDF_greaterThan;
|
||||
RDF_Resource RDF_lessThanOrEqual;
|
||||
RDF_Resource RDF_greaterThanOrEqual;
|
||||
RDF_Resource RDF_stringEquals;
|
||||
RDF_Resource RDF_stringNotEquals;
|
||||
RDF_Resource RDF_substring;
|
||||
RDF_Resource RDF_stringStartsWith;
|
||||
RDF_Resource RDF_stringEndsWith;
|
||||
RDF_Resource RDF_child;
|
||||
RDF_Resource RDF_comment;
|
||||
RDF_Resource RDF_content;
|
||||
RDF_Resource RDF_summary;
|
||||
} RDF_CoreVocabStruct;
|
||||
|
||||
typedef RDF_CoreVocabStruct* RDF_CoreVocab;
|
||||
|
||||
typedef struct _RDF_NCVocabStruct {
|
||||
RDF_Resource RDF_overview;
|
||||
RDF_Resource RDF_Trash;
|
||||
RDF_Resource RDF_Clipboard;
|
||||
RDF_Resource RDF_Top;
|
||||
RDF_Resource RDF_Search;
|
||||
RDF_Resource RDF_Sitemaps;
|
||||
RDF_Resource RDF_BreadCrumbCategory;
|
||||
RDF_Resource RDF_BookmarkFolderCategory;
|
||||
RDF_Resource RDF_NewBookmarkFolderCategory;
|
||||
RDF_Resource RDF_History;
|
||||
RDF_Resource RDF_HistoryBySite;
|
||||
RDF_Resource RDF_HistoryByDate;
|
||||
RDF_Resource RDF_HistoryMostVisited;
|
||||
|
||||
/* IE items */
|
||||
RDF_Resource RDF_IEBookmarkFolderCategory;
|
||||
RDF_Resource RDF_IEHistory;
|
||||
|
||||
RDF_Resource RDF_bookmarkAddDate;
|
||||
RDF_Resource RDF_PersonalToolbarFolderCategory;
|
||||
RDF_Resource RDF_Column;
|
||||
RDF_Resource RDF_ColumnResource;
|
||||
RDF_Resource RDF_ColumnWidth;
|
||||
RDF_Resource RDF_ColumnIconURL;
|
||||
RDF_Resource RDF_ColumnDataType;
|
||||
RDF_Resource RDF_smallIcon; /* Small normal icon. */
|
||||
RDF_Resource RDF_largeIcon; /* Large normal icon. */
|
||||
RDF_Resource RDF_Guide;
|
||||
RDF_Resource RDF_HTMLURL;
|
||||
RDF_Resource RDF_HTMLHeight;
|
||||
RDF_Resource RDF_LocalFiles;
|
||||
RDF_Resource RDF_FTP;
|
||||
RDF_Resource RDF_Appletalk;
|
||||
RDF_Resource RDF_Mail;
|
||||
RDF_Resource RDF_Password;
|
||||
RDF_Resource RDF_SBProviders;
|
||||
RDF_Resource RDF_WorkspacePos;
|
||||
RDF_Resource RDF_ItemPos;
|
||||
RDF_Resource RDF_Locks;
|
||||
RDF_Resource RDF_AddLock;
|
||||
RDF_Resource RDF_DeleteLock;
|
||||
RDF_Resource RDF_IconLock;
|
||||
RDF_Resource RDF_NameLock;
|
||||
RDF_Resource RDF_CopyLock;
|
||||
RDF_Resource RDF_MoveLock;
|
||||
RDF_Resource RDF_WorkspacePosLock;
|
||||
RDF_Resource RDF_DefaultSelectedView;
|
||||
RDF_Resource RDF_AutoOpen;
|
||||
RDF_Resource RDF_resultType;
|
||||
RDF_Resource RDF_methodType;
|
||||
RDF_Resource RDF_prompt;
|
||||
RDF_Resource RDF_HTMLType;
|
||||
RDF_Resource RDF_URLShortcut;
|
||||
RDF_Resource RDF_Poll;
|
||||
RDF_Resource RDF_PollInterval;
|
||||
RDF_Resource RDF_PollURL;
|
||||
|
||||
RDF_Resource RDF_Cookies;
|
||||
#ifdef TRANSACTION_RECEIPTS
|
||||
RDF_Resource RDF_Receipts;
|
||||
#endif
|
||||
RDF_Resource RDF_Toolbar;
|
||||
RDF_Resource RDF_JSec;
|
||||
RDF_Resource RDF_JSecPrincipal;
|
||||
RDF_Resource RDF_JSecTarget;
|
||||
RDF_Resource RDF_JSecAccess;
|
||||
|
||||
/* Commands */
|
||||
|
||||
RDF_Resource RDF_Command;
|
||||
RDF_Resource RDF_Command_Launch;
|
||||
RDF_Resource RDF_Command_Refresh;
|
||||
RDF_Resource RDF_Command_Reveal;
|
||||
RDF_Resource RDF_Command_Atalk_FlatHierarchy;
|
||||
RDF_Resource RDF_Command_Atalk_Hierarchy;
|
||||
|
||||
/* NavCenter appearance styles */
|
||||
|
||||
RDF_Resource viewFGColor;
|
||||
RDF_Resource viewBGColor;
|
||||
RDF_Resource viewBGURL;
|
||||
RDF_Resource showTreeConnections;
|
||||
RDF_Resource treeConnectionFGColor;
|
||||
RDF_Resource treeOpenTriggerIconURL;
|
||||
RDF_Resource treeClosedTriggerIconURL;
|
||||
RDF_Resource selectionFGColor;
|
||||
RDF_Resource selectionBGColor;
|
||||
RDF_Resource columnHeaderFGColor;
|
||||
RDF_Resource columnHeaderBGColor;
|
||||
RDF_Resource columnHeaderBGURL;
|
||||
RDF_Resource showColumnHeaders;
|
||||
RDF_Resource showColumnHeaderDividers;
|
||||
RDF_Resource showTitleBar; /* Whether or not to show the title bar at all */
|
||||
RDF_Resource showControlStrip; /* Whether or not to show the control strip at all. */
|
||||
|
||||
RDF_Resource sortColumnFGColor;
|
||||
RDF_Resource sortColumnBGColor;
|
||||
RDF_Resource titleBarFGColor;
|
||||
RDF_Resource titleBarBGColor;
|
||||
RDF_Resource titleBarBGURL;
|
||||
RDF_Resource titleBarShowText;
|
||||
RDF_Resource dividerColor;
|
||||
RDF_Resource showDivider;
|
||||
RDF_Resource selectedColumnHeaderFGColor;
|
||||
RDF_Resource selectedColumnHeaderBGColor;
|
||||
RDF_Resource showColumnHilite;
|
||||
RDF_Resource triggerPlacement;
|
||||
|
||||
/* NavCenter behavior flags */
|
||||
|
||||
RDF_Resource useInlineEditing;
|
||||
RDF_Resource useSingleClick;
|
||||
RDF_Resource loadOpenState;
|
||||
RDF_Resource saveOpenState;
|
||||
|
||||
/* Toolbar Appearance Styles */
|
||||
RDF_Resource toolbarBitmapPosition; /* Bitmap's position ("side"/"top") */
|
||||
RDF_Resource toolbarDisplayMode;
|
||||
RDF_Resource toolbarCollapsed;
|
||||
RDF_Resource toolbarVisible;
|
||||
RDF_Resource toolbarRolloverIcon; /* The icon to display on rollover. */
|
||||
RDF_Resource toolbarPressedIcon; /* The icon to display on a press. */
|
||||
RDF_Resource toolbarDisabledIcon; /* The icon to display when disabled. */
|
||||
RDF_Resource toolbarEnabledIcon; /* THe icon to display when enabled. */
|
||||
|
||||
/* Cookie Stuff */
|
||||
RDF_Resource cookieDomain;
|
||||
RDF_Resource cookieValue;
|
||||
RDF_Resource cookieHost;
|
||||
RDF_Resource cookiePath;
|
||||
RDF_Resource cookieSecure;
|
||||
RDF_Resource cookieExpires;
|
||||
|
||||
RDF_Resource toolbarButtonsFixedSize; /* Whether or not the buttons must be the same size ("yes"/"no") */
|
||||
RDF_Resource viewRolloverColor; /* What to display when an item is rolled over in a view.*/
|
||||
RDF_Resource viewPressedColor; /* What to display when an item is pressed in a view. */
|
||||
RDF_Resource viewDisabledColor; /* Color to use when item is disabled in a view. */
|
||||
RDF_Resource urlBar; /* Whether or not the button is a URL bar. */
|
||||
RDF_Resource urlBarWidth; /* The width of the URL bar. */
|
||||
|
||||
RDF_Resource buttonTreeState; /* The tree state (docked, popup) for a button. */
|
||||
RDF_Resource buttonTooltipText; /* The tooltip text for a button. */
|
||||
RDF_Resource buttonStatusbarText; /* The status bar text for a button. */
|
||||
RDF_Resource buttonBorderStyle; /* What type of border the button should have. */
|
||||
|
||||
RDF_Resource controlStripFGColor; /* The tree's control strip foreground */
|
||||
RDF_Resource controlStripBGColor; /* The tree's control strip background */
|
||||
RDF_Resource controlStripBGURL; /* The tree's control strip BG URL */
|
||||
RDF_Resource controlStripCloseText; /* The text displayed for the close function in the control strip. */
|
||||
|
||||
RDF_Resource pos;
|
||||
RDF_Resource from;
|
||||
RDF_Resource to;
|
||||
RDF_Resource subject;
|
||||
RDF_Resource date;
|
||||
RDF_Resource displayURL;
|
||||
} RDF_NCVocabStruct;
|
||||
|
||||
typedef RDF_NCVocabStruct* RDF_NCVocab;
|
||||
|
||||
typedef struct _RDF_WDVocabStruct {
|
||||
RDF_Resource RDF_URL;
|
||||
RDF_Resource RDF_description;
|
||||
RDF_Resource RDF_keyword;
|
||||
RDF_Resource RDF_Container;
|
||||
RDF_Resource RDF_firstVisitDate;
|
||||
RDF_Resource RDF_lastVisitDate;
|
||||
RDF_Resource RDF_numAccesses;
|
||||
RDF_Resource RDF_creationDate;
|
||||
RDF_Resource RDF_lastModifiedDate;
|
||||
RDF_Resource RDF_size;
|
||||
} RDF_WDVocabStruct;
|
||||
|
||||
typedef RDF_WDVocabStruct* RDF_WDVocab;
|
||||
|
||||
#endif
|
||||
27
mozilla/modules/rdf/macbuild/RDF.Prefix
Normal file
@@ -0,0 +1,27 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// RDFDebug.Prefix
|
||||
//
|
||||
// Global prefix file for the debug RDF project.
|
||||
//
|
||||
//
|
||||
|
||||
#include "MacPrefix_debug.h"
|
||||
#include "RDFConfig.h"
|
||||
193
mozilla/modules/rdf/macbuild/RDF.exp
Normal file
@@ -0,0 +1,193 @@
|
||||
###
|
||||
### Symbols you may have to hand annotate with #{code} or #{data}...
|
||||
###
|
||||
|
||||
HT_CanDropHTROn
|
||||
HT_CanDropURLOn
|
||||
HT_DeleteCursor
|
||||
HT_DeleteView
|
||||
HT_DropHTROn
|
||||
HT_DropURLOn
|
||||
HT_GetNextItem
|
||||
HT_GetNotificationMask
|
||||
HT_GetNthItem
|
||||
HT_GetNthItemInt
|
||||
HT_GetOpenState
|
||||
HT_GetParent
|
||||
HT_GetRDFResource
|
||||
HT_GetSelectedState
|
||||
HT_GetView
|
||||
HT_GetViewData
|
||||
HT_IsContainer
|
||||
HT_IsContainerOpen
|
||||
HT_IsSelected
|
||||
HT_KillResource
|
||||
HT_MakeNewContainer
|
||||
HT_NewCursor
|
||||
HT_NewView
|
||||
HT_NodeDisplayString
|
||||
HT_RemoveChild
|
||||
HT_SetNotificationMask
|
||||
HT_SetOpenState
|
||||
HT_SetSelectedState
|
||||
HT_SetViewData
|
||||
HT_TopNode
|
||||
HT_WriteOutAsBookmarks
|
||||
RDF_AddNotifiable
|
||||
RDF_Assert
|
||||
RDF_CanAssert
|
||||
RDF_CanUnassert
|
||||
RDF_Create
|
||||
RDF_DeleteNotifiable
|
||||
RDF_DisposeCursor
|
||||
RDF_GetSlotValue
|
||||
RDF_GetSlotValues
|
||||
RDF_HasAssertion
|
||||
RDF_Init
|
||||
RDF_InitLocalStores
|
||||
RDF_Kill
|
||||
RDF_NextValue
|
||||
RDF_SaveState
|
||||
RDF_SetResourceLock
|
||||
RDF_Shutdown
|
||||
RDF_StdVocab
|
||||
RDF_Unassert
|
||||
RDF_AddCookieResource
|
||||
# RDFglueExit
|
||||
# RDFglueInitialize
|
||||
# __initialize
|
||||
# __ptmf_null
|
||||
# __terminate
|
||||
# abortRDFParse
|
||||
# addChildAfter
|
||||
# addChildBefore
|
||||
# addDescription
|
||||
# addNotifiable
|
||||
# addSlotValue
|
||||
# addToAssertionList
|
||||
# addToResourceList
|
||||
# append2Strings
|
||||
# asEqual
|
||||
# asTv
|
||||
# asType
|
||||
# assert
|
||||
# assignHeaderSlot
|
||||
# assignSlot
|
||||
# beginReadingRDFFile
|
||||
# bkStateTransition
|
||||
# bookmarkSlotp
|
||||
# charSearch
|
||||
# containerIDp
|
||||
# containerp
|
||||
# copyString
|
||||
# createBootstrapResources
|
||||
# createContainer
|
||||
# createSeparator
|
||||
# deleteNotifiable
|
||||
# derelativizeURL
|
||||
# destroyViewInt
|
||||
# disposeCursor
|
||||
# endsWith
|
||||
# exitRDF
|
||||
# fillContainer
|
||||
# finishRDFParse
|
||||
# freeAssertion
|
||||
# freeMem
|
||||
# gBookmarkURL
|
||||
# gLocalStoreURL
|
||||
# gRDFDB
|
||||
# gcRDFFile
|
||||
# getElfProp
|
||||
# getFirstToken
|
||||
# getHash
|
||||
# getMem
|
||||
# getRDFDB
|
||||
# getRelURL
|
||||
# getSlotValue
|
||||
# getSlotValues
|
||||
# globals
|
||||
# hasAssertion
|
||||
# hashIndex
|
||||
# ht_fprintf
|
||||
# htrdfNotifFunc
|
||||
# idenEqual
|
||||
# idenHash
|
||||
# initDataSources
|
||||
# initLocalStore
|
||||
# inverseTV
|
||||
# isContainer
|
||||
# isLeaf
|
||||
# isSeparator
|
||||
# isTypeOf
|
||||
# killResource
|
||||
# localStoreAdd
|
||||
# localStoreAssert
|
||||
# localStoreDisposeCursor
|
||||
# localStoreGetSlotValue
|
||||
# localStoreGetSlotValues
|
||||
# localStoreHasAssertion
|
||||
# localStoreNextValue
|
||||
# localStoreRemove
|
||||
# localStoreUnassert
|
||||
# lockedp
|
||||
# longjmp
|
||||
# makeNewAssertion
|
||||
# makeNewID
|
||||
# makeNewRDFDB
|
||||
# makeRDFFile
|
||||
# newFolderBkItem
|
||||
# newHTEntry
|
||||
# newHashtable
|
||||
# newLeafBkItem
|
||||
# nextValue
|
||||
# outputRDFTree
|
||||
# outputRDFTreeInt
|
||||
# parseNextBkBlob
|
||||
# parseNextBkToken
|
||||
# parseNextMCFBlob
|
||||
# parseNextRDFBlob
|
||||
# parseNextRDFLine
|
||||
# parseNextRDFToken
|
||||
# parseNextRDFXMLBlob
|
||||
# parseRDFElement
|
||||
# parseSlotValue
|
||||
# possiblyGCResource
|
||||
# putHash
|
||||
# rdfDB
|
||||
# rdfDBInited
|
||||
# readRDFFile
|
||||
# remHash
|
||||
# remoteAssert
|
||||
# remoteStoreAdd
|
||||
# remoteStoreDisposeCursor
|
||||
# remoteStoreGetSlotValue
|
||||
# remoteStoreGetSlotValues
|
||||
# remoteStoreHasAssertion
|
||||
# remoteStoreNextValue
|
||||
# remoteStoreRemove
|
||||
# remoteUnassert
|
||||
# resolveGenlPosReference
|
||||
# resolveReference
|
||||
# resourceDescription
|
||||
# resourceFromID
|
||||
# resourceLastModifiedDate
|
||||
# resourceLastVisitDate
|
||||
# resourceName
|
||||
# resourceTransition
|
||||
# revCharSearch
|
||||
# saveLocalStore
|
||||
# sendNotification
|
||||
# sendNotifications
|
||||
# separatorCounter
|
||||
# setAsTv
|
||||
# setAsType
|
||||
# setContainerp
|
||||
# setHiddenState
|
||||
# setLockedp
|
||||
# startsWith
|
||||
# stringAppend
|
||||
# stringEquals
|
||||
# translators
|
||||
# unassert
|
||||
# urlEquals
|
||||
# writeResource
|
||||
BIN
mozilla/modules/rdf/macbuild/RDF.mcp
Normal file
18
mozilla/modules/rdf/macbuild/RDFConfig.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#define CGLUESUPPORTED 0 // turn off C glue support to avoid conflict on create() in RDF
|
||||
27
mozilla/modules/rdf/macbuild/RDFDebug.Prefix
Normal file
@@ -0,0 +1,27 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// RDFDebug.Prefix
|
||||
//
|
||||
// Global prefix file for the debug RDF project.
|
||||
//
|
||||
//
|
||||
|
||||
#include "MacPrefix_debug.h"
|
||||
#include "RDFConfig.h"
|
||||
29
mozilla/modules/rdf/macbuild/RDFNoLDAP.Prefix
Normal file
@@ -0,0 +1,29 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// RDFDebug.Prefix
|
||||
//
|
||||
// Global prefix file for the debug RDF project.
|
||||
//
|
||||
//
|
||||
|
||||
#define MOZ_LITE 1
|
||||
#define DEVELOPER_DEBUG 1
|
||||
#include "RDFConfig.h"
|
||||
#include <OpenTransport.h>
|
||||
30
mozilla/modules/rdf/macbuild/RDFNoLDAPDebug.Prefix
Normal file
@@ -0,0 +1,30 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// RDFDebug.Prefix
|
||||
//
|
||||
// Global prefix file for the debug RDF project.
|
||||
//
|
||||
//
|
||||
|
||||
#define MOZ_LITE 1
|
||||
#define DEBUG 1
|
||||
#define DEVELOPER_DEBUG 1
|
||||
#include "RDFConfig.h"
|
||||
#include <OpenTransport.h>
|
||||
9
mozilla/modules/rdf/makefile.win
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
DIRS=\
|
||||
include \
|
||||
src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
46
mozilla/modules/rdf/src/Makefile
Normal file
@@ -0,0 +1,46 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
MODULE = rdf
|
||||
LIBRARY_NAME = $(LITE_PREFIX)rdf
|
||||
LIBXP = $(DIST)/lib/libxp.$(LIB_SUFFIX)
|
||||
|
||||
REQUIRES = nspr
|
||||
|
||||
JNI_GEN = netscape.rdf.core.NativeRDF netscape.rdf.core.NativeRDFEnumeration
|
||||
|
||||
CSRCS = \
|
||||
vocab.c \
|
||||
mcf.c \
|
||||
remstore.c \
|
||||
utils.c \
|
||||
rdfparse.c \
|
||||
bmk2mcf.c \
|
||||
rdfht.c \
|
||||
columns.c \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = -I$(PUBLIC)/rdf
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
$(LIBRARY): $(OBJS)
|
||||
87
mozilla/modules/rdf/src/Makefile.in
Normal file
@@ -0,0 +1,87 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
MODULE = rdf
|
||||
LIBRARY_NAME = $(LITE_PREFIX)rdf
|
||||
LIBXP = $(DIST)/lib/libxp.$(LIB_SUFFIX)
|
||||
|
||||
REQUIRES = nspr dbm java js htmldlgs util img layer pref ldap network parse
|
||||
|
||||
JNI_GEN = netscape.rdf.core.NativeRDF netscape.rdf.core.NativeRDFEnumeration
|
||||
|
||||
CSRCS = \
|
||||
vocab.c \
|
||||
mcf.c \
|
||||
remstore.c \
|
||||
utils.c \
|
||||
rdfparse.c \
|
||||
mcff2mcf.c \
|
||||
bmk2mcf.c \
|
||||
ldap2rdf.c \
|
||||
glue.c \
|
||||
rdfht.c \
|
||||
jsec2rdf.c \
|
||||
$(NULL)
|
||||
|
||||
ifndef RDF_STANDALONE
|
||||
CSRCS += \
|
||||
nlcstore.c \
|
||||
find2rdf.c \
|
||||
fs2rdf.c \
|
||||
hist2rdf.c \
|
||||
pm2rdf.c \
|
||||
es2mcf.c \
|
||||
columns.c \
|
||||
ht.c \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
SPF_OBJS = $(OBJDIR)/spf2ldif.o \
|
||||
$(OBJDIR)/hashtable.o
|
||||
|
||||
LOCAL_INCLUDES = -I$(PUBLIC)/rdf
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifdef RDF_STANDALONE
|
||||
DEFINES := $(filter-out -DMOZILLA_CLIENT, $(DEFINES))
|
||||
endif
|
||||
|
||||
$(LIBRARY): $(OBJS)
|
||||
|
||||
test: $(OBJDIR)/test
|
||||
spf2ldif: $(OBJDIR)/spf2ldif
|
||||
|
||||
.PHONY: test spf2ldif
|
||||
|
||||
$(OBJDIR)/test: $(OBJDIR)/test.o $(LIBRARY)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -o $@ $(OBJDIR)/test.o $(LIBRARY) $(LIBNSPR) $(LIBXP) $(LDFLAGS) $(OS_LIBS)
|
||||
|
||||
$(OBJDIR)/spf2ldif: $(SPF_OBJS) $(LIBRARY)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -o $@ $(SPF_OBJS) $(LIBRARY) $(LIBNSPR) $(LIBXP) $(LDFLAGS) $(OS_LIBS)
|
||||
1235
mozilla/modules/rdf/src/atalk.c
Normal file
87
mozilla/modules/rdf/src/atalk.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_ATALK_H_
|
||||
#define _RDF_ATALK_H_
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
||||
#include <Appletalk.h>
|
||||
#include <Devices.h>
|
||||
#include <Gestalt.h>
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "mcf.h"
|
||||
#include "vocab.h"
|
||||
#include "utils.h"
|
||||
#include "prefapi.h"
|
||||
|
||||
|
||||
/* atalk.c data structures and defines */
|
||||
|
||||
extern int RDF_APPLETALK_TOP_NAME, RDF_AFP_CLIENT_37_STR, RDF_AFP_AUTH_FAILED_STR;
|
||||
extern int RDF_AFP_PW_EXPIRED_STR, RDF_AFP_ALREADY_MOUNTED_STR, RDF_AFP_MAX_SERVERS_STR;
|
||||
extern int RDF_AFP_NOT_RESPONDING_STR, RDF_AFP_SAME_NODE_STR, RDF_AFP_ERROR_NUM_STR;
|
||||
extern int RDF_VOLUME_DESC_STR, RDF_DIRECTORY_DESC_STR, RDF_FILE_DESC_STR;
|
||||
|
||||
#define ATALK_NOHIERARCHY_PREF "browser.navcenter.appletalk.zone.nohierarchy"
|
||||
|
||||
#define ATALK_CMD_PREFIX "Command:at:"
|
||||
|
||||
#define kAppleShareVerGestalt 'afps'
|
||||
#define kAppleShareVer_3_7 0x00000006
|
||||
#define AFPX_PROT_VERSION 0
|
||||
#define BASE_AFPX_OFFSET 30
|
||||
#define BASE_AFP_OFFSET 24
|
||||
|
||||
typedef struct _ourNBPUserDataStruct
|
||||
{
|
||||
RDFT rdf;
|
||||
char *parentID;
|
||||
} ourNBPUserDataStruct;
|
||||
typedef ourNBPUserDataStruct *ourNBPUserDataPtr;
|
||||
|
||||
|
||||
/* atalk.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
#ifdef XP_MAC
|
||||
PRBool isAFPVolume(short ioVRefNum);
|
||||
#endif
|
||||
|
||||
void getZones(RDFT rdf);
|
||||
void processZones(RDFT rdf, char *zones, uint16 numZones, XP_Bool noHierarchyFlag);
|
||||
void checkServerLookup (MPPParamBlock *nbp);
|
||||
void getServers(RDFT rdf, RDF_Resource parent);
|
||||
void AtalkPossible(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
RDF_Error AtalkDestroy (RDFT r);
|
||||
PRBool AtalkHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void *v, RDF_ValueType type, PRBool tv);
|
||||
PRBool AtalkAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void *v, RDF_ValueType type, PRBool tv);
|
||||
char * convertAFPtoUnescapedFile(char *id);
|
||||
void * AtalkGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor AtalkGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * AtalkNextValue (RDFT rdf, RDF_Cursor c);
|
||||
RDF_Resource CreateAFPFSUnit (char *nname, PRBool isDirectoryFlag);
|
||||
RDFT MakeAtalkStore (char* url);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
602
mozilla/modules/rdf/src/bmk2mcf.c
Normal file
@@ -0,0 +1,602 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* Reading bookmarks.htm into rdf.
|
||||
tags in the bookmark file.
|
||||
<TITLE>
|
||||
<H1>
|
||||
<H3>
|
||||
<DL></DL>
|
||||
<DT>
|
||||
<P>
|
||||
|
||||
<DT> indicates that an item is coming.
|
||||
If the next item is an <a then we have a url
|
||||
If the next item is a h3, we have a folder.
|
||||
<DL> indicates that the previous item (which should have been a folder)
|
||||
is the parent of the next set.
|
||||
</DL> indicates pop out a level
|
||||
<P> ignore this on reading, but write out one after each <DL>
|
||||
<DD> the description for the previous <DT>
|
||||
|
||||
Category urls. Make it up out of the add dates. */
|
||||
|
||||
|
||||
/*
|
||||
This file translates netscape bookmarks into the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
|
||||
#include "bmk2mcf.h"
|
||||
#include "utils.h"
|
||||
#include "time.h"
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
/* extern declarations */
|
||||
PR_PUBLIC_API(void) HT_WriteOutAsBookmarks (RDF r, PRFileDesc *fp, RDF_Resource u); /* XXX this should be elsewhere */
|
||||
extern char *gBookmarkURL;
|
||||
extern RDF gNCDB;
|
||||
|
||||
/* globals */
|
||||
uint16 separatorCounter = 0;
|
||||
static char* gBkFolderDate;
|
||||
static RDFT gBMKStore = 0;
|
||||
extern int RDF_PERSONAL_TOOLBAR_NAME;
|
||||
|
||||
RDF_Resource
|
||||
createSeparator(void)
|
||||
{
|
||||
char url[50];
|
||||
RDF_Resource sep;
|
||||
PR_snprintf(url, 50, "separator%i", separatorCounter++);
|
||||
sep = RDF_GetResource(NULL, url, 1);
|
||||
return sep;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
RDF_Resource
|
||||
createContainer (char* id)
|
||||
{
|
||||
RDF_Resource r = RDF_GetResource(NULL, id, true);
|
||||
setContainerp(r, 1);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
char *
|
||||
resourceDescription (RDF rdf, RDF_Resource r)
|
||||
{
|
||||
return (char*)RDF_GetSlotValue(rdf, r, gWebData->RDF_description, RDF_STRING_TYPE, false, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
resourceLastVisitDate (RDF rdf, RDF_Resource r)
|
||||
{
|
||||
return (char*)RDF_GetSlotValue(rdf, r, gWebData->RDF_lastVisitDate, RDF_STRING_TYPE, false, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
resourceLastModifiedDate (RDF rdf, RDF_Resource r)
|
||||
{
|
||||
return (char*)RDF_GetSlotValue(rdf, r, gWebData->RDF_lastModifiedDate, RDF_STRING_TYPE, false, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
parseNextBkBlob (RDFFile f, char* blob, int32 size)
|
||||
{
|
||||
int32 n, last, m;
|
||||
PRBool somethingseenp = false;
|
||||
n = last = 0;
|
||||
|
||||
while (n < size) {
|
||||
char c = blob[n];
|
||||
m = 0;
|
||||
somethingseenp = false;
|
||||
memset(f->line, '\0', f->lineSize);
|
||||
if (f->holdOver[0] != '\0') {
|
||||
memcpy(f->line, f->holdOver, RDF_STRLEN(f->holdOver));
|
||||
m = RDF_STRLEN(f->holdOver);
|
||||
somethingseenp = true;
|
||||
memset(f->holdOver, '\0', RDF_BUF_SIZE);
|
||||
}
|
||||
while ((m < 300) && (c != '<') && (c != '>') && (n < size)) {
|
||||
f->line[m] = c;
|
||||
m++;
|
||||
somethingseenp = (somethingseenp || ((c != ' ') && (c != '\r') && (c != '\n')));
|
||||
n++;
|
||||
c = blob[n];
|
||||
}
|
||||
if (c == '>') f->line[m] = c;
|
||||
n++;
|
||||
if (m > 0) {
|
||||
if ((c == '<') || (c == '>')) {
|
||||
last = n;
|
||||
if (c == '<') f->holdOver[0] = '<';
|
||||
if (somethingseenp == true) parseNextBkToken(f, f->line);
|
||||
} else if (size > last) {
|
||||
memcpy(f->holdOver, f->line, m);
|
||||
}
|
||||
} else if (c == '<') f->holdOver[0] = '<';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
parseNextBkToken (RDFFile f, char* token)
|
||||
{
|
||||
/* printf(token); */
|
||||
if (token[0] == '<') {
|
||||
bkStateTransition(f, token);
|
||||
} else {
|
||||
/* ok, we have a piece of content.
|
||||
can be the title, or a description or */
|
||||
if ((f->status == IN_TITLE) || (f->status == IN_H3) ||
|
||||
(f->status == IN_ITEM_TITLE)) {
|
||||
if (IN_H3 && gBkFolderDate) {
|
||||
char *url;
|
||||
RDF_Resource newFolder;
|
||||
url = PR_smprintf("%s%s.rdf", gBkFolderDate, token);
|
||||
newFolder = createContainer(url);
|
||||
free(url);
|
||||
addSlotValue(f,newFolder, gCoreVocab->RDF_parent, f->stack[f->depth-1],
|
||||
RDF_RESOURCE_TYPE, NULL);
|
||||
freeMem(gBkFolderDate);
|
||||
gBkFolderDate = NULL;
|
||||
f->lastItem = newFolder;
|
||||
}
|
||||
if ((f->db == gLocalStore) || (f->status != IN_TITLE))
|
||||
{
|
||||
addSlotValue(f, f->lastItem, gCoreVocab->RDF_name,
|
||||
copyString(token), RDF_STRING_TYPE, NULL);
|
||||
}
|
||||
|
||||
if (startsWith("Personal Toolbar", token) && (containerp(f->lastItem)))
|
||||
addSlotValue(f, f->lastItem, gCoreVocab->RDF_instanceOf,
|
||||
gNavCenter->RDF_PersonalToolbarFolderCategory,
|
||||
RDF_RESOURCE_TYPE, "true");
|
||||
|
||||
} else if (f->status == IN_ITEM_DESCRIPTION) {
|
||||
addDescription(f, f->lastItem, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
addDescription (RDFFile f, RDF_Resource r, char* token)
|
||||
{
|
||||
char* desc = (char*) remoteStoreGetSlotValue(gLocalStore, r, gWebData->RDF_description,
|
||||
RDF_STRING_TYPE, false, true);
|
||||
if (desc == NULL) {
|
||||
addSlotValue(f, f->lastItem, gWebData->RDF_description,
|
||||
copyString(token),
|
||||
RDF_STRING_TYPE, NULL);
|
||||
} else {
|
||||
addSlotValue(f, f->lastItem, gWebData->RDF_description,
|
||||
append2Strings(desc, token), RDF_STRING_TYPE, NULL);
|
||||
remoteUnassert(gLocalStore, f->lastItem, gWebData->RDF_description, desc, RDF_STRING_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
bkStateTransition (RDFFile f, char* token)
|
||||
{
|
||||
if (startsWith("<A", token)) {
|
||||
newLeafBkItem(f, token);
|
||||
f->status = IN_ITEM_TITLE;
|
||||
} else if (startsWith(OPEN_H3_STRING, token)) {
|
||||
newFolderBkItem(f, token);
|
||||
f->status = IN_H3;
|
||||
} else if (startsWith(OPEN_TITLE_STRING, token)) {
|
||||
f->status = IN_TITLE;
|
||||
} else if (startsWith(OPEN_H3_STRING, token)) {
|
||||
f->status = IN_H3;
|
||||
} else if (startsWith(DD_STRING, token)) {
|
||||
if (remoteStoreGetSlotValue(gLocalStore, f->lastItem, gWebData->RDF_description,
|
||||
RDF_STRING_TYPE, false, true)
|
||||
== NULL) f->status = IN_ITEM_DESCRIPTION;
|
||||
} else if (startsWith(OPEN_DL_STRING, token)) {
|
||||
f->stack[f->depth++] = f->lastItem;
|
||||
} else if (startsWith(CLOSE_DL_STRING, token)) {
|
||||
f->depth--;
|
||||
} else if (startsWith("<HR>", token)) {
|
||||
addSlotValue(f, createSeparator(), gCoreVocab->RDF_parent, f->stack[f->depth-1],
|
||||
RDF_RESOURCE_TYPE, NULL);
|
||||
f->status = 0;
|
||||
} else if ((f->status == IN_ITEM_DESCRIPTION) && (startsWith("<BR>", token))) {
|
||||
addDescription(f, f->lastItem, token);
|
||||
} else f->status = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
newFolderBkItem(RDFFile f, char* token)
|
||||
{
|
||||
int16 start, end;
|
||||
start = charSearch('"', token);
|
||||
end = revCharSearch('"', token);
|
||||
token[end] = '\0';
|
||||
gBkFolderDate = copyString(&token[start+1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
newLeafBkItem (RDFFile f, char* token)
|
||||
{
|
||||
char buffer[128];
|
||||
struct tm *time;
|
||||
uint32 dateVal;
|
||||
char* url = NULL;
|
||||
char* addDate = NULL;
|
||||
char* lastVisit = NULL;
|
||||
char* lastModified = NULL;
|
||||
uint8 current = 0;
|
||||
int32 len = RDF_STRLEN(token);
|
||||
int32 n = 0;
|
||||
char c = token[n++];
|
||||
PRBool inString = false;
|
||||
RDF_Resource newR;
|
||||
|
||||
while (n < len) {
|
||||
if (c == '"') {
|
||||
if (inString) {
|
||||
token[n-1] = '\0';
|
||||
inString = false;
|
||||
} else {
|
||||
inString = true;
|
||||
if (current == 0) {
|
||||
url = &token[n];
|
||||
} else if (current == 1) {
|
||||
addDate = &token[n];
|
||||
} else if (current == 2) {
|
||||
lastVisit = &token[n];
|
||||
} else if (current == 3) {
|
||||
lastModified = &token[n];
|
||||
}
|
||||
current++;
|
||||
}
|
||||
}
|
||||
c = token[n++];
|
||||
}
|
||||
if (url == NULL) return;
|
||||
newR = RDF_GetResource(NULL, url, true);
|
||||
addSlotValue(f, newR, gCoreVocab->RDF_parent, f->stack[f->depth-1],
|
||||
RDF_RESOURCE_TYPE, NULL);
|
||||
/* addSlotValue(f, newR, gWebData->RDF_URL, (void*)copyString(url),
|
||||
RDF_STRING_TYPE, true); */
|
||||
if (addDate != NULL)
|
||||
{
|
||||
dateVal = atol(addDate);
|
||||
if ((time = localtime((time_t *) &dateVal)) != NULL)
|
||||
{
|
||||
/* xxx
|
||||
#ifdef XP_MAC
|
||||
time->tm_year += 4;
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#elif XP_UNIX
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
|
||||
addSlotValue(f, newR, gNavCenter->RDF_bookmarkAddDate,
|
||||
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
|
||||
*/
|
||||
}
|
||||
}
|
||||
if (lastVisit != NULL)
|
||||
{
|
||||
dateVal = atol(lastVisit);
|
||||
if ((time = localtime((time_t *) &dateVal)) != NULL)
|
||||
{
|
||||
/* xxx
|
||||
#ifdef XP_MAC
|
||||
time->tm_year += 4;
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#elif XP_UNIX
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
addSlotValue(f, newR, gWebData->RDF_lastVisitDate,
|
||||
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
|
||||
*/
|
||||
}
|
||||
}
|
||||
if (lastModified != NULL)
|
||||
{
|
||||
dateVal = atol(lastModified);
|
||||
if ((time = localtime((time_t *) &dateVal)) != NULL)
|
||||
{
|
||||
/* xxx
|
||||
#ifdef XP_MAC
|
||||
time->tm_year += 4;
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#elif XP_UNIX
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
addSlotValue(f, newR, gWebData->RDF_lastModifiedDate,
|
||||
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
|
||||
*/
|
||||
}
|
||||
}
|
||||
f->lastItem = newR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
numericDate(char *url)
|
||||
{
|
||||
char *date = NULL;
|
||||
int len=0;
|
||||
|
||||
if (!url) return NULL;
|
||||
while (url[len])
|
||||
{
|
||||
if (!isdigit(url[len])) break;
|
||||
++len;
|
||||
}
|
||||
if (len > 0)
|
||||
{
|
||||
if ((date = getMem(len+1)) != NULL)
|
||||
{
|
||||
strncpy(date, url, len);
|
||||
}
|
||||
}
|
||||
return(date);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
bookmarkSlotp (RDF_Resource s)
|
||||
{
|
||||
return ((s == gCoreVocab->RDF_parent) || (s == gWebData->RDF_lastVisitDate) || (s == gWebData->RDF_description) ||
|
||||
(s == gNavCenter->RDF_bookmarkAddDate) || (s == gWebData->RDF_lastModifiedDate) ||
|
||||
(s == gCoreVocab->RDF_name));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HT_WriteOutAsBookmarks1 (RDF rdf, PRFileDesc *fp, RDF_Resource u, RDF_Resource top, int indent)
|
||||
{
|
||||
RDF_Cursor c = RDF_GetSources(rdf, u, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
|
||||
RDF_Resource next;
|
||||
char *date, *name, *url;
|
||||
int loop;
|
||||
|
||||
if (c == NULL) return;
|
||||
if (u == top) {
|
||||
name = RDF_GetResourceName(rdf, u);
|
||||
ht_rjcprintf(fp, "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n", NULL);
|
||||
ht_rjcprintf(fp, "<!-- This is an automatically generated file.\n", NULL);
|
||||
ht_rjcprintf(fp, "It will be read and overwritten.\n", NULL);
|
||||
ht_rjcprintf(fp, "Do Not Edit! -->\n", NULL);
|
||||
|
||||
ht_rjcprintf(fp, "<TITLE>%s</TITLE>\n", (name) ? name:"");
|
||||
ht_rjcprintf(fp, "<H1>%s</H1>\n<DL><p>\n", (name) ? name:"");
|
||||
}
|
||||
while ((next = RDF_NextValue(c)) != NULL) {
|
||||
|
||||
url = resourceID(next);
|
||||
if (containerp(next) && (!startsWith("ftp:",url)) && (!startsWith("file:",url))
|
||||
&& (!startsWith("IMAP:", url)) && (!startsWith("nes:", url))
|
||||
&& (!startsWith("mail:", url)) && (!startsWith("cache:", url))
|
||||
&& (!startsWith("ldap:", url))) {
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
||||
|
||||
date = numericDate(resourceID(next));
|
||||
ht_rjcprintf(fp, "<DT><H3 ADD_DATE=\"%s\">", (date) ? date:"");
|
||||
if (date) freeMem(date);
|
||||
name = RDF_GetResourceName(rdf, next);
|
||||
ht_rjcprintf(fp, "%s</H3>\n", name);
|
||||
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
||||
ht_rjcprintf(fp, "<DL><p>\n", NULL);
|
||||
HT_WriteOutAsBookmarks1(rdf, fp, next, top, indent+1);
|
||||
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
||||
|
||||
ht_rjcprintf(fp, "</DL><p>\n", NULL);
|
||||
}
|
||||
else if (isSeparator(next)) {
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
||||
ht_rjcprintf(fp, "<HR>\n", NULL);
|
||||
}
|
||||
else {
|
||||
char* bkAddDate = (char*)RDF_GetSlotValue(rdf, next,
|
||||
gNavCenter->RDF_bookmarkAddDate,
|
||||
RDF_STRING_TYPE, false, true);
|
||||
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
||||
|
||||
ht_rjcprintf(fp, "<DT><A HREF=\"%s\" ", resourceID(next));
|
||||
date = numericDate(bkAddDate);
|
||||
ht_rjcprintf(fp, "ADD_DATE=\"%s\" ", (date) ? date: "");
|
||||
if (date) freeMem(date);
|
||||
ht_rjcprintf(fp, "LAST_VISIT=\"%s\" ", resourceLastVisitDate(rdf, next));
|
||||
ht_rjcprintf(fp, "LAST_MODIFIED=\"%s\">", resourceLastModifiedDate(rdf, next));
|
||||
ht_rjcprintf(fp, "%s</A>\n", RDF_GetResourceName(rdf, next));
|
||||
|
||||
if (resourceDescription(rdf, next) != NULL) {
|
||||
ht_rjcprintf(fp, "<DD>%s\n", resourceDescription(rdf, next));
|
||||
}
|
||||
}
|
||||
}
|
||||
RDF_DisposeCursor(c);
|
||||
if (u == top) {
|
||||
ht_rjcprintf(fp, "</DL>\n", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(void)
|
||||
HT_WriteOutAsBookmarks (RDF r, PRFileDesc *fp, RDF_Resource u)
|
||||
{
|
||||
HT_WriteOutAsBookmarks1 (r, fp, u, u, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
flushBookmarks()
|
||||
{
|
||||
PRFileDesc *bkfp;
|
||||
|
||||
if (gBookmarkURL != NULL)
|
||||
{
|
||||
/*
|
||||
delete bookmark.htm as PROpen() with PR_TRUNCATE appears broken (at least on Mac)
|
||||
*/
|
||||
CallPRDeleteFileUsingFileURL(gBookmarkURL);
|
||||
|
||||
if ((bkfp = CallPROpenUsingFileURL(gBookmarkURL, (PR_WRONLY|PR_CREATE_FILE|PR_TRUNCATE),
|
||||
0644)) != NULL)
|
||||
{
|
||||
HT_WriteOutAsBookmarks(gNCDB, bkfp, gNavCenter->RDF_BookmarkFolderCategory);
|
||||
PR_Close(bkfp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
ResourceBelongsToBookmarksp (RDF_Resource r, int32 depth) {
|
||||
if (depth > 20) {
|
||||
return false;
|
||||
} else if (r == gNavCenter->RDF_BookmarkFolderCategory) {
|
||||
return 1;
|
||||
} else if (containerp(r)) {
|
||||
Assertion as = r->rarg1;
|
||||
while (as) {
|
||||
if ((as->db == gBMKStore) &&
|
||||
(as->s == gCoreVocab->RDF_parent) &&
|
||||
(as->tv == 1) &&
|
||||
(ResourceBelongsToBookmarksp((RDF_Resource)as->value, depth+1))) return 1;
|
||||
as = as->next;
|
||||
}
|
||||
return 0;
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool remoteAssert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv);
|
||||
PRBool remoteUnassert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type);
|
||||
|
||||
|
||||
PRBool
|
||||
bmkUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s,
|
||||
void* v, RDF_ValueType type) {
|
||||
if (ResourceBelongsToBookmarksp(u, 0)) {
|
||||
return (remoteStoreRemove(mcf, u, s, v, type) != NULL);
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
bmkAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv) {
|
||||
if (ResourceBelongsToBookmarksp(u, 0)) {
|
||||
return (remoteStoreAdd(mcf, u, s, v, type, tv) != NULL);
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
extern RDF_Resource gPTFolder;
|
||||
void
|
||||
readInBookmarks()
|
||||
{
|
||||
/* RDF_Resource ptFolder; */
|
||||
RDF_Resource bmk = RDF_GetResource(NULL, "NC:Bookmarks", true);
|
||||
RDFFile f = makeRDFFile(gBookmarkURL, bmk, true);
|
||||
PRFileDesc *fp;
|
||||
int32 len;
|
||||
char buf[512];
|
||||
f->fileType = RDF_BOOKMARKS;
|
||||
f->db = gBMKStore;
|
||||
f->assert = remoteAssert3;
|
||||
|
||||
fp = CallPROpenUsingFileURL(f->url, PR_RDONLY|PR_CREATE_FILE, 0644);
|
||||
if (fp == NULL) return;
|
||||
while((len=PR_Read(fp, buf, sizeof(buf))) >0) {
|
||||
parseNextBkBlob(f, buf, len);
|
||||
}
|
||||
|
||||
gPTFolder = remoteStoreGetSlotValue(f->db,
|
||||
gNavCenter->RDF_PersonalToolbarFolderCategory,
|
||||
gCoreVocab->RDF_instanceOf, RDF_RESOURCE_TYPE, true, true);
|
||||
|
||||
if (gPTFolder == NULL) {
|
||||
if ((gPTFolder = createContainer("personaltoolbar.rdf")) != NULL) {
|
||||
addSlotValue(f, gPTFolder, gCoreVocab->RDF_instanceOf,
|
||||
gNavCenter->RDF_PersonalToolbarFolderCategory,
|
||||
RDF_RESOURCE_TYPE, "true");
|
||||
addSlotValue(f, gPTFolder, gCoreVocab->RDF_name,
|
||||
copyString("Personal Toolbar"),
|
||||
RDF_STRING_TYPE, "true");
|
||||
RDFUtil_SetPTFolder(gPTFolder);
|
||||
}
|
||||
}
|
||||
|
||||
PR_Close(fp);
|
||||
freeMem(f->line);
|
||||
freeMem(f->currentSlot);
|
||||
freeMem(f->holdOver);
|
||||
}
|
||||
|
||||
|
||||
RDFT
|
||||
MakeBMKStore (char* url)
|
||||
{
|
||||
if (startsWith("rdf:bookmarks", url)) {
|
||||
if (gBMKStore == 0) {
|
||||
RDFT ntr = gBMKStore = NewRemoteStore(url);
|
||||
ntr->assert = bmkAssert;
|
||||
ntr->unassert = bmkUnassert;
|
||||
readInBookmarks();
|
||||
return ntr;
|
||||
} else return gBMKStore;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
72
mozilla/modules/rdf/src/bmk2mcf.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_BMK2MCF_H_
|
||||
#define _RDF_BMK2MCF_H_
|
||||
|
||||
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "vocab.h"
|
||||
#include "stdio.h"
|
||||
#include "ctype.h"
|
||||
|
||||
|
||||
/* bmk2mcf.c data structures and defines */
|
||||
|
||||
#define OPEN_TITLE_STRING "<TITLE>"
|
||||
#define CLOSE_TITLE_STRING "</TITLE>"
|
||||
#define OPEN_H1_STRING "<H1>"
|
||||
#define CLOSE_H1_STRING "</H1>"
|
||||
#define OPEN_H3_STRING "<H3"
|
||||
#define CLOSE_H3_STRING "</H3>"
|
||||
#define OPEN_DL_STRING "<DL>"
|
||||
#define CLOSE_DL_STRING "</DL>"
|
||||
#define DT_STRING "<DT>"
|
||||
#define PAR_STRING "<P>"
|
||||
#define DD_STRING "<DD>"
|
||||
|
||||
#define IN_TITLE 1
|
||||
#define IN_H3 5
|
||||
#define IN_ITEM_TITLE 7
|
||||
#define IN_ITEM_DESCRIPTION 9
|
||||
|
||||
|
||||
|
||||
/* bmk2mcf.c function prototypes */
|
||||
|
||||
|
||||
|
||||
RDF_Resource createSeparator(void);
|
||||
RDF_Resource createContainer (char* id);
|
||||
char * resourceDescription (RDF rdf, RDF_Resource r);
|
||||
char * resourceLastVisitDate (RDF rdf, RDF_Resource r);
|
||||
char * resourceLastModifiedDate (RDF rdf, RDF_Resource r);
|
||||
void parseNextBkBlob (RDFFile f, char* blob, int32 size);
|
||||
void parseNextBkToken (RDFFile f, char* token);
|
||||
void addDescription (RDFFile f, RDF_Resource r, char* token);
|
||||
void bkStateTransition (RDFFile f, char* token);
|
||||
void newFolderBkItem(RDFFile f, char* token);
|
||||
void newLeafBkItem (RDFFile f, char* token);
|
||||
char * numericDate(char *url);
|
||||
void HT_WriteOutAsBookmarks1 (RDF rdf, PRFileDesc *fp, RDF_Resource u, RDF_Resource top, int indent);
|
||||
void flushBookmarks();
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
114
mozilla/modules/rdf/src/che2rdf.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
/* We need to define a new class of urls for cache objects.
|
||||
e.g., cache:<something here>
|
||||
|
||||
The url for the rdf datastore corresponding to the cache
|
||||
is rdf:cache.
|
||||
|
||||
The Cache Schema.
|
||||
The cache consists of a hierarchy of objects. The standard
|
||||
hierarchy relation (RDF_parent). In addition, each object
|
||||
may have the following properties.
|
||||
lastAccess
|
||||
lastModified
|
||||
|
||||
container cache objects start with cache:container ...
|
||||
|
||||
*/
|
||||
|
||||
|
||||
RDFT gCacheStore = NULL;
|
||||
|
||||
RDFT MakeCacheStore (char* url) {
|
||||
if (startsWith("rdf:cache", url)) {
|
||||
if (gCacheStore != NULL) {
|
||||
return gCacheStore;
|
||||
} else {
|
||||
RDF_Translator ntr = (RDF_Translator)getMem(sizeof(RDF_TranslatorStruct));
|
||||
ntr->assert = NULL;
|
||||
ntr->unassert = NULL;
|
||||
ntr->getSlotValue = cacheGetSlotValue;
|
||||
ntr->getSlotValues = cacheGetSlotValues;
|
||||
ntr->hasAssertion = cacheHasAssertion;
|
||||
ntr->nextValue = cacheNextValue;
|
||||
ntr->disposeCursor = cacheDisposeCursor;
|
||||
gCacheStore = ntr;
|
||||
return ntr;
|
||||
}
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
cacheHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv) {
|
||||
if ((resourceType(u) == CACHE_RT) && tv) {
|
||||
/*e.g., u->id = cache:http://www.netscape.com/
|
||||
s = gWebData->RDF_size
|
||||
v = 1000
|
||||
type = RDF_INT_TYPE
|
||||
return true if the cache object corresponding to u has a size of 1000
|
||||
e.g., u->id = cache:http://www.netscape.com/
|
||||
s = gCoreVocab->RDF_parent
|
||||
type = RDF_RESOURCE_TYPE
|
||||
v-> = "cache:container:MemoryCache"
|
||||
*/
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RDF_Cursor cacheGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv) {
|
||||
if ((resourceType(u) == CACHE_RT) && tv && (s == gCoreVocab->RDF_parent) && inversep) {
|
||||
RDF_Cursor c;
|
||||
c = (RDF_Cursor) getMem(sizeof(RDF_CursorStruc));
|
||||
c->u = u;
|
||||
c->count = 0;
|
||||
c->pdata = NULL;
|
||||
c->type = type;
|
||||
return c;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
void* cacheNextValue (RDFT rdf, RDF_Cursor c) {
|
||||
"return the next value, update count, return NUll when there are no more.
|
||||
the children are nodes. to create a new node, call RDF_Create(url, 1);
|
||||
If something is a container, after getting the object, do setContainerp(r, 1);"
|
||||
}
|
||||
|
||||
RDF_Error cacheDisposeCursor (RDFT rdf, RDF_Cursor c) {
|
||||
"dispose it. c could be NULL"
|
||||
}
|
||||
|
||||
|
||||
void* cacheGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
PRBool inversep, PRBool tv) {
|
||||
if ("willing to answer this") {
|
||||
return the value;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
284
mozilla/modules/rdf/src/columns.c
Normal file
@@ -0,0 +1,284 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file synthesizes default columns for a given node.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "columns.h"
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
ColumnsGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
RDF_Cursor c;
|
||||
|
||||
if (!containerp(u) || (s != gNavCenter->RDF_Column) || (inversep) ||
|
||||
(!tv) || (type != RDF_RESOURCE_TYPE))
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
if ((c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct))) != NULL)
|
||||
{
|
||||
c->u = u;
|
||||
c->value = NULL;
|
||||
c->count = 0;
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
ColumnsGetSlotValue(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
PRBool inversep, PRBool tv)
|
||||
{
|
||||
void *val = NULL;
|
||||
|
||||
if (u == NULL) return(NULL);
|
||||
|
||||
if ((s == gCoreVocab->RDF_name) && (type == RDF_STRING_TYPE)
|
||||
&& (!inversep) && (tv))
|
||||
{
|
||||
#ifdef XXX
|
||||
if (u == gCoreVocab->RDF_name) val = copyString(XP_GetString(RDF_NAME_STR));
|
||||
else if (u == gNavCenter->RDF_URLShortcut) val = copyString(XP_GetString(RDF_SHORTCUT_STR));
|
||||
else if (u == gWebData->RDF_URL) val = copyString(XP_GetString(RDF_URL_STR));
|
||||
else if (u == gWebData->RDF_description) val = copyString(XP_GetString(RDF_DESCRIPTION_STR));
|
||||
else if (u == gWebData->RDF_firstVisitDate) val = copyString(XP_GetString(RDF_FIRST_VISIT_STR));
|
||||
else if (u == gWebData->RDF_lastVisitDate) val = copyString(XP_GetString(RDF_LAST_VISIT_STR));
|
||||
else if (u == gWebData->RDF_numAccesses) val = copyString(XP_GetString(RDF_NUM_ACCESSES_STR));
|
||||
else if (u == gWebData->RDF_creationDate) val = copyString(XP_GetString(RDF_CREATED_ON_STR));
|
||||
else if (u == gWebData->RDF_lastModifiedDate) val = copyString(XP_GetString(RDF_LAST_MOD_STR));
|
||||
else if (u == gWebData->RDF_size) val = copyString(XP_GetString(RDF_SIZE_STR));
|
||||
else if (u == gNavCenter->RDF_bookmarkAddDate) val = copyString(XP_GetString(RDF_ADDED_ON_STR));
|
||||
#endif
|
||||
}
|
||||
else if ((s == gNavCenter->RDF_ColumnDataType) &&
|
||||
(type == RDF_INT_TYPE) && (!inversep) && (tv))
|
||||
{
|
||||
if (u == gNavCenter->RDF_bookmarkAddDate ||
|
||||
u == gWebData->RDF_firstVisitDate ||
|
||||
u == gWebData->RDF_lastVisitDate ||
|
||||
u == gWebData->RDF_lastModifiedDate ||
|
||||
u == gWebData->RDF_creationDate)
|
||||
{
|
||||
val = (void *)HT_COLUMN_STRING;
|
||||
}
|
||||
else if (u == gWebData->RDF_size ||
|
||||
u == gWebData->RDF_numAccesses ||
|
||||
u == gNavCenter->cookieDomain ||
|
||||
u == gNavCenter->cookieSecure)
|
||||
{
|
||||
val = (void *)HT_COLUMN_INT;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* default to string... XXX wrong thing to do? */
|
||||
val = (void *)HT_COLUMN_STRING;
|
||||
}
|
||||
}
|
||||
else if ((s == gNavCenter->RDF_ColumnWidth) &&
|
||||
(type == RDF_INT_TYPE) && (!inversep) && (tv))
|
||||
{
|
||||
if (u == gCoreVocab->RDF_name) val = (void *)128L;
|
||||
else if (u == gWebData->RDF_URL) val = (void *)200L;
|
||||
else val = (void *)80;
|
||||
}
|
||||
return(val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
ColumnsNextValue (RDFT rdf, RDF_Cursor c)
|
||||
{
|
||||
void *arc = NULL;
|
||||
|
||||
PR_ASSERT(c != NULL);
|
||||
if (c == NULL) return(NULL);
|
||||
|
||||
switch( resourceType(c->u) )
|
||||
{
|
||||
case RDF_RT:
|
||||
if ((c->u == gNavCenter->RDF_Sitemaps) || (c->u == gNavCenter->RDF_Mail))
|
||||
{
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gWebData->RDF_URL; break;
|
||||
}
|
||||
}
|
||||
else do
|
||||
{
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1:
|
||||
if ((idenEqual(c->u, gNavCenter->RDF_BookmarkFolderCategory)) ||
|
||||
((!startsWith("http://", resourceID(c->u))) && endsWith(".rdf", resourceID(c->u))))
|
||||
{
|
||||
arc = gNavCenter->RDF_URLShortcut;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* disallow shortcuts from external RDF graphs, so skip to next column */
|
||||
arc = NULL;
|
||||
++(c->count);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: arc = gWebData->RDF_URL; break;
|
||||
case 3: arc = gWebData->RDF_description; break;
|
||||
case 4: arc = gWebData->RDF_keyword; break;
|
||||
case 5: arc = gNavCenter->RDF_bookmarkAddDate; break;
|
||||
case 6: arc = gWebData->RDF_lastVisitDate; break;
|
||||
case 7: arc = gWebData->RDF_lastModifiedDate; break;
|
||||
case 8: arc = gNavCenter->pos; break;
|
||||
}
|
||||
} while ((c->count <= 6) && (arc == NULL));
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case HISTORY_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gWebData->RDF_URL; break;
|
||||
case 2: arc = gWebData->RDF_firstVisitDate; break;
|
||||
case 3: arc = gWebData->RDF_lastVisitDate; break;
|
||||
case 4: arc = NULL; break;
|
||||
case 5: arc = gWebData->RDF_numAccesses; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case COOKIE_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gNavCenter->cookieHost; break;
|
||||
case 2: arc = gNavCenter->cookiePath; break;
|
||||
case 3: arc = gNavCenter->cookieValue; break;
|
||||
case 4: arc = gNavCenter->cookieExpires; break;
|
||||
case 5: arc = gNavCenter->cookieDomain; break;
|
||||
case 6: arc = gNavCenter->cookieSecure; break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case FTP_RT:
|
||||
case ES_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gWebData->RDF_URL; break;
|
||||
case 2: arc = gWebData->RDF_description; break;
|
||||
case 3: arc = gWebData->RDF_size; break;
|
||||
case 4: arc = gWebData->RDF_lastModifiedDate; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case LFS_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gWebData->RDF_URL; break;
|
||||
case 2: arc = gWebData->RDF_description; break;
|
||||
case 3: arc = gWebData->RDF_size; break;
|
||||
case 4: arc = gWebData->RDF_lastModifiedDate; break;
|
||||
case 5: arc = gWebData->RDF_creationDate; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case LDAP_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_RT:
|
||||
case IM_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gWebData->RDF_URL; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEARCH_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gNavCenter->RDF_URLShortcut; break;
|
||||
case 2: arc = gWebData->RDF_URL; break;
|
||||
case 3: arc = gWebData->RDF_description; break;
|
||||
case 4: arc = gWebData->RDF_keyword; break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
++(c->count);
|
||||
return(arc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
ColumnsDisposeCursor (RDFT rdf, RDF_Cursor c)
|
||||
{
|
||||
if (c != NULL)
|
||||
{
|
||||
freeMem(c);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeColumnStore (char* url)
|
||||
{
|
||||
RDFT ntr = NULL;
|
||||
|
||||
if (strstr(url, "rdf:columns"))
|
||||
{
|
||||
if ((ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct))) != NULL)
|
||||
{
|
||||
ntr->getSlotValues = ColumnsGetSlotValues;
|
||||
ntr->getSlotValue = ColumnsGetSlotValue;
|
||||
ntr->nextValue = ColumnsNextValue;
|
||||
ntr->disposeCursor = ColumnsDisposeCursor;
|
||||
ntr->url = copyString(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return(ntr);
|
||||
}
|
||||
48
mozilla/modules/rdf/src/columns.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_COLUMNS_H_
|
||||
#define _RDF_COLUMNS_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "htrdf.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
|
||||
/* columns.c data structures */
|
||||
|
||||
extern int RDF_NAME_STR, RDF_SHORTCUT_STR, RDF_URL_STR, RDF_DESCRIPTION_STR;
|
||||
extern int RDF_FIRST_VISIT_STR, RDF_LAST_VISIT_STR, RDF_NUM_ACCESSES_STR;
|
||||
extern int RDF_CREATED_ON_STR, RDF_LAST_MOD_STR, RDF_SIZE_STR, RDF_ADDED_ON_STR;
|
||||
|
||||
|
||||
/* columns.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
RDF_Cursor ColumnsGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * ColumnsGetSlotValue(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * ColumnsNextValue (RDFT rdf, RDF_Cursor c);
|
||||
RDF_Error ColumnsDisposeCursor (RDFT rdf, RDF_Cursor c);
|
||||
RDFT MakeColumnStore (char* url);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
574
mozilla/modules/rdf/src/comwrap.cpp
Normal file
@@ -0,0 +1,574 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "rdf.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFDataBase.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
|
||||
#include "nspr.h"
|
||||
#include "plhash.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
PR_PUBLIC_API(void) _comwrap_NotificationCB(RDF_Event event, void* pdata);
|
||||
PR_END_EXTERN_C
|
||||
|
||||
class rdfDataBaseWrapper;
|
||||
class rdfCursorWrapper;
|
||||
class rdfServiceWrapper;
|
||||
class rdfServiceFactory;
|
||||
|
||||
class rdfDatabaseWrapper : public nsIRDFDataBase {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
rdfDatabaseWrapper(RDF r);
|
||||
virtual ~rdfDatabaseWrapper();
|
||||
|
||||
/* nsIRDFDataSource methods: */
|
||||
|
||||
NS_METHOD GetName(const RDF_String* name /* out */ );
|
||||
|
||||
NS_METHOD GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Resource *source /* out */);
|
||||
|
||||
NS_METHOD GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_Resource *source /* out */);
|
||||
|
||||
NS_METHOD GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
nsIRDFCursor **sources /* out */);
|
||||
|
||||
NS_METHOD GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
nsIRDFCursor **sources /* out */);
|
||||
|
||||
NS_METHOD GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
RDF_NodeStruct& target /* in/out */);
|
||||
|
||||
NS_METHOD GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
PRBool tv,
|
||||
RDF_NodeStruct& target /* in/out */);
|
||||
|
||||
NS_METHOD GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */);
|
||||
|
||||
NS_METHOD GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */);
|
||||
|
||||
NS_METHOD Assert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool tv = PR_TRUE);
|
||||
|
||||
NS_METHOD Unassert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target);
|
||||
|
||||
NS_METHOD HasAssertion(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion /* out */);
|
||||
|
||||
NS_METHOD AddObserver(nsIRDFObserver *n,
|
||||
RDF_EventMask type = RDF_ANY_NOTIFY);
|
||||
|
||||
NS_METHOD RemoveObserver(nsIRDFObserver *n,
|
||||
RDF_EventMask = RDF_ANY_NOTIFY);
|
||||
|
||||
NS_METHOD ArcLabelsIn(RDF_Node node,
|
||||
nsIRDFCursor **labels /* out */);
|
||||
|
||||
NS_METHOD ArcLabelsOut(RDF_Resource source,
|
||||
nsIRDFCursor **labels /* out */);
|
||||
|
||||
NS_METHOD Flush();
|
||||
|
||||
/* nsIRDFDataBase methods: */
|
||||
NS_METHOD AddDataSource(nsIRDFDataSource* dataSource);
|
||||
|
||||
NS_METHOD RemoveDataSource(nsIRDFDataSource* dataSource);
|
||||
|
||||
NS_METHOD GetDataSource(RDF_String url,
|
||||
nsIRDFDataSource **source /* out */ );
|
||||
|
||||
NS_METHOD DeleteAllArcs(RDF_Resource resource);
|
||||
|
||||
private:
|
||||
RDF mRDF;
|
||||
|
||||
PLHashTable* mpObserverMap;
|
||||
};
|
||||
|
||||
class rdfCursorWrapper : public nsIRDFCursor {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
rdfCursorWrapper(RDF_Cursor c);
|
||||
virtual ~rdfCursorWrapper();
|
||||
|
||||
NS_METHOD HasElements(PRBool& hasElements);
|
||||
|
||||
NS_METHOD Next(RDF_NodeStruct& n);
|
||||
|
||||
private:
|
||||
RDF_Cursor mCursor;
|
||||
};
|
||||
|
||||
class rdfServiceWrapper : public nsIRDFService {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_METHOD CreateDatabase(const RDF_String* url,
|
||||
nsIRDFDataBase** db);
|
||||
|
||||
};
|
||||
|
||||
class rdfServiceFactory : public nsIFactory {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
rdfServiceFactory();
|
||||
virtual ~rdfServiceFactory();
|
||||
|
||||
NS_METHOD CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID anIID,
|
||||
void **aResult);
|
||||
|
||||
NS_METHOD LockFactory(PRBool aLock);
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
rdfDataBaseWrapper:
|
||||
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS( rdfDatabaseWrapper, NS_IRDFDATABASE_IID )
|
||||
|
||||
rdfDatabaseWrapper::rdfDatabaseWrapper(RDF r) : mRDF(r)
|
||||
{
|
||||
mpObserverMap = PL_NewHashTable( 100,
|
||||
NULL, // XXX isn't there are hash fn for pointers???
|
||||
PL_CompareValues,
|
||||
PL_CompareValues,
|
||||
0,
|
||||
0 );
|
||||
|
||||
PR_ASSERT( mpObserverMap );
|
||||
#ifdef XXX
|
||||
if( !mpObserverMap ) // XXX just like 'new' failing on this object?
|
||||
throw bad_alloc("rdf: unable to allocate observer map" );
|
||||
#endif
|
||||
}
|
||||
|
||||
rdfDatabaseWrapper::~rdfDatabaseWrapper()
|
||||
{
|
||||
PL_HashTableDestroy( mpObserverMap );
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetName(const RDF_String* name /* out */ )
|
||||
{
|
||||
PR_ASSERT( PR_FALSE );
|
||||
return NS_ERROR_NOT_IMPLEMENTED; // XXX
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Resource *source /* out */)
|
||||
{
|
||||
PR_ASSERT( target && source );
|
||||
*source = (RDF_Resource) RDF_GetSlotValue( mRDF,
|
||||
target->value.r,
|
||||
arcLabel,
|
||||
RDF_RESOURCE_TYPE, // anything else makes no sense
|
||||
PR_TRUE,
|
||||
PR_TRUE );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_Resource *source /* out */)
|
||||
{
|
||||
*source = (RDF_Resource) RDF_GetSlotValue( mRDF,
|
||||
target->value.r,
|
||||
arcLabel,
|
||||
RDF_RESOURCE_TYPE, // anything else makes no sense
|
||||
PR_TRUE,
|
||||
tv );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
nsIRDFCursor **sources /* out */)
|
||||
{
|
||||
return GetSources(target,arcLabel,PR_TRUE,sources);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
nsIRDFCursor **sources /* out */)
|
||||
{
|
||||
PR_ASSERT( sources );
|
||||
if( 0 == sources )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*sources = 0;
|
||||
|
||||
RDF_Cursor c = RDF_GetSources( mRDF,
|
||||
target->value.r,
|
||||
arcLabel,
|
||||
RDF_RESOURCE_TYPE, // anything else makes no sense
|
||||
tv );
|
||||
|
||||
if( c ) {
|
||||
*sources = new rdfCursorWrapper( c );
|
||||
(*sources)->AddRef();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
RDF_NodeStruct& target /* in/out */)
|
||||
{
|
||||
return GetTarget(source,arcLabel,targetType,PR_TRUE,target);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
PRBool tv,
|
||||
RDF_NodeStruct& target /* in/out */)
|
||||
{
|
||||
PR_ASSERT( targetType != RDF_ANY_TYPE ); // not ready to support this yet
|
||||
|
||||
void* value = RDF_GetSlotValue( mRDF,
|
||||
target.value.r,
|
||||
arcLabel,
|
||||
targetType, // anything else makes no sense
|
||||
PR_FALSE,
|
||||
tv );
|
||||
|
||||
target.type = targetType;
|
||||
target.value.r = (RDF_Resource) value; // reasonable? XXX
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */)
|
||||
{
|
||||
return GetTargets(source,arcLabel,PR_TRUE,targetType,targets);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */)
|
||||
{
|
||||
PR_ASSERT( targets );
|
||||
if( 0 == targets )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*targets = 0;
|
||||
|
||||
RDF_Cursor c = RDF_GetTargets( mRDF,
|
||||
source,
|
||||
arcLabel,
|
||||
targetType,
|
||||
tv );
|
||||
|
||||
if( c ) {
|
||||
*targets = new rdfCursorWrapper( c );
|
||||
(*targets)->AddRef();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::Assert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool tv)
|
||||
{
|
||||
PRBool b = tv ? RDF_Assert( mRDF, source, arcLabel, (void*)target->value.r, target->type ) :
|
||||
RDF_AssertFalse( mRDF, source, arcLabel, (void*)target->value.r, target->type );
|
||||
|
||||
// XXX
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::Unassert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target)
|
||||
{
|
||||
PRBool b = RDF_Unassert( mRDF,
|
||||
source,
|
||||
arcLabel,
|
||||
target->value.r,
|
||||
target->type ); // XXX
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::HasAssertion(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool truthValue,
|
||||
PRBool* hasAssertion /* out */)
|
||||
{
|
||||
*hasAssertion = RDF_HasAssertion( mRDF,
|
||||
source,
|
||||
arcLabel,
|
||||
target->value.r,
|
||||
target->type,
|
||||
truthValue );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
_comwrap_NotificationCB(RDF_Event event, void* pdata)
|
||||
{
|
||||
nsIRDFObserver* observer = (nsIRDFObserver*) pdata;
|
||||
// XXX QueryInterface & release??
|
||||
observer->HandleEvent( (nsIRDFDataSource*)pdata, event );
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::AddObserver(nsIRDFObserver *observer,
|
||||
RDF_EventMask type)
|
||||
{
|
||||
// XXX event masking does not currently work
|
||||
|
||||
RDF_Notification notification = (RDF_Notification) PL_HashTableLookup( mpObserverMap, observer );
|
||||
if( !notification ) {
|
||||
observer->AddRef();
|
||||
notification = RDF_AddNotifiable( mRDF,
|
||||
_comwrap_NotificationCB,
|
||||
NULL, // XXX
|
||||
observer );
|
||||
PL_HashTableAdd( mpObserverMap,
|
||||
observer,
|
||||
notification );
|
||||
}
|
||||
|
||||
return NS_OK; // XXX
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::RemoveObserver(nsIRDFObserver *observer,
|
||||
RDF_EventMask type)
|
||||
{
|
||||
|
||||
RDF_Notification notification = (RDF_Notification) PL_HashTableLookup( mpObserverMap, observer );
|
||||
if( !notification )
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
RDF_Error err = RDF_DeleteNotifiable( notification );
|
||||
PR_ASSERT( !err ); // the current implementation never fails!
|
||||
PL_HashTableRemove( mpObserverMap, observer );
|
||||
observer->Release();
|
||||
|
||||
return NS_OK; // XXX
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::ArcLabelsIn(RDF_Node node,
|
||||
nsIRDFCursor **labels /* out */)
|
||||
{
|
||||
PR_ASSERT( labels );
|
||||
if( 0 == labels )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*labels = 0;
|
||||
|
||||
RDF_Cursor c = RDF_ArcLabelsIn( mRDF, node->value.r );
|
||||
|
||||
if( c ) {
|
||||
*labels = new rdfCursorWrapper( c );
|
||||
(*labels)->AddRef();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::ArcLabelsOut(RDF_Resource source,
|
||||
nsIRDFCursor **labels /* out */)
|
||||
{
|
||||
PR_ASSERT( labels );
|
||||
if( 0 == labels )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*labels = 0;
|
||||
|
||||
RDF_Cursor c = RDF_ArcLabelsOut( mRDF, source );
|
||||
|
||||
if( c ) {
|
||||
*labels = new rdfCursorWrapper( c );
|
||||
(*labels)->AddRef();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::Flush()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED; // XXX
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::DeleteAllArcs(RDF_Resource resource)
|
||||
{
|
||||
return RDF_DeleteAllArcs( mRDF, resource );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
rdfServiceWrapper: the RDF service singleton
|
||||
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS( rdfServiceWrapper, NS_IRDFSERVICE_IID )
|
||||
|
||||
NS_METHOD
|
||||
rdfServiceWrapper::CreateDatabase(const RDF_String* url_ary,
|
||||
nsIRDFDataBase **db)
|
||||
{
|
||||
PR_ASSERT( 0 != db );
|
||||
if( 0 == db )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*db = 0;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
RDF rdf = RDF_GetDB(url_ary);
|
||||
|
||||
if( 0 == rdf ) {
|
||||
result = RDF_ERROR_UNABLE_TO_CREATE; // XXX this is too wishy-washy
|
||||
} else {
|
||||
*db = new rdfDatabaseWrapper(rdf); // XXX
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
rdfCursorWrapper
|
||||
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS( rdfCursorWrapper, NS_IRDFCURSOR_IID )
|
||||
|
||||
rdfCursorWrapper::rdfCursorWrapper(RDF_Cursor c) : mCursor(c)
|
||||
{
|
||||
}
|
||||
|
||||
rdfCursorWrapper::~rdfCursorWrapper()
|
||||
{
|
||||
RDF_DisposeCursor( mCursor );
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfCursorWrapper::Next(RDF_NodeStruct& next)
|
||||
{
|
||||
next.type = RDF_CursorValueType( mCursor );
|
||||
next.value.r = (RDF_Resource) RDF_NextValue( mCursor );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
rdfServiceFactory
|
||||
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS( rdfServiceFactory, NS_IFACTORY_IID )
|
||||
|
||||
NS_METHOD
|
||||
rdfServiceFactory::CreateInstance( nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult )
|
||||
{
|
||||
PR_ASSERT( aResult );
|
||||
if( 0 == aResult )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aResult = 0;
|
||||
|
||||
nsISupports* instance = new rdfServiceWrapper();
|
||||
|
||||
nsresult result = instance->QueryInterface( aIID, aResult );
|
||||
PR_ASSERT( result = NS_OK );
|
||||
|
||||
if( result != NS_OK )
|
||||
delete instance; // wrong interface!
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfServiceFactory::LockFactory(PRBool lock)
|
||||
{
|
||||
PR_ASSERT( PR_FALSE );
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
490
mozilla/modules/rdf/src/es2mcf.c
Normal file
@@ -0,0 +1,490 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements FTP support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "es2mcf.h"
|
||||
#include "glue.h"
|
||||
#include "ht.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
/* externs */
|
||||
extern RDF gNCDB;
|
||||
#define ESFTPRT(x) ((resourceType((RDF_Resource)x) == ES_RT) || (resourceType((RDF_Resource)x) == FTP_RT))
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeESFTPStore (char* url)
|
||||
{
|
||||
RDFT ntr = NewRemoteStore(url);
|
||||
ntr->assert = ESAssert;
|
||||
ntr->unassert = ESUnassert;
|
||||
ntr->possiblyAccessFile = ESFTPPossiblyAccessFile;
|
||||
return ntr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ESFTPPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
if (((resourceType(u) == ES_RT) || (resourceType(u) == FTP_RT)) &&
|
||||
(s == gCoreVocab->RDF_parent) && (containerp(u))) {
|
||||
char* id = resourceID(u);
|
||||
readRDFFile((resourceType(u) == ES_RT ? &id[4] : id), u, false, rdf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ESAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
PRBool retVal;
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char*) v)));
|
||||
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE) &&
|
||||
(ESFTPRT((RDF_Resource)v)) &&
|
||||
(tv) && (containerp((RDF_Resource)v))) {
|
||||
ESAddChild((RDF_Resource)v, u);
|
||||
retVal = PR_TRUE;
|
||||
} else {
|
||||
retVal = PR_FALSE;
|
||||
}
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ESUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
PRBool retVal;
|
||||
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char*) v)));
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE) &&
|
||||
(ESFTPRT((RDF_Resource)v)) &&
|
||||
(containerp((RDF_Resource)v))) {
|
||||
ESRemoveChild((RDF_Resource)v, u);
|
||||
retVal = PR_TRUE;
|
||||
} else {
|
||||
retVal = PR_FALSE;
|
||||
}
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
es_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
|
||||
{
|
||||
RDF_Resource parent = NULL, child = NULL, r;
|
||||
_esFEData *feData;
|
||||
char *newURL, *p;
|
||||
|
||||
feData = (_esFEData *)urls->fe_data;
|
||||
if ((status >= 0) && (feData != NULL))
|
||||
{
|
||||
parent = RDF_GetResource(gNCDB, feData->parent, false);
|
||||
child = RDF_GetResource(gNCDB, feData->child, false);
|
||||
if ((parent != NULL) && (child != NULL))
|
||||
{
|
||||
switch(feData->method)
|
||||
{
|
||||
case URL_POST_METHOD:
|
||||
if (((p = RDF_STRRCHR(resourceID(child), '/')) != NULL) && (*++p != '\0'))
|
||||
{
|
||||
if ((newURL = append2Strings(resourceID(parent), p)) != NULL)
|
||||
{
|
||||
if ((r = RDF_GetResource(gNCDB, newURL, 1)) != NULL)
|
||||
{
|
||||
setContainerp(r, containerp(child));
|
||||
setResourceType(r, resourceType(child));
|
||||
|
||||
remoteStoreAdd(gRemoteStore, r,
|
||||
gCoreVocab->RDF_parent, parent,
|
||||
RDF_RESOURCE_TYPE, 1);
|
||||
}
|
||||
freeMem(newURL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case URL_DELETE_METHOD:
|
||||
remoteStoreRemove(gRemoteStore, child,
|
||||
gCoreVocab->RDF_parent, parent,
|
||||
RDF_RESOURCE_TYPE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (status < 0)
|
||||
{
|
||||
if ((cx != NULL) && (urls != NULL) && (urls->error_msg != NULL))
|
||||
{
|
||||
FE_Alert(cx, urls->error_msg);
|
||||
}
|
||||
}
|
||||
if (feData != NULL)
|
||||
{
|
||||
esFreeFEData(feData);
|
||||
}
|
||||
NET_FreeURLStruct (urls);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
nativeFilename(char *filename)
|
||||
{
|
||||
char *newName = NULL, *temp;
|
||||
int x = 0;
|
||||
|
||||
if (filename == NULL) return(NULL);
|
||||
if ((newName = unescapeURL(filename)) != NULL)
|
||||
{
|
||||
if ((temp = convertFileURLToNSPRCopaceticPath(newName)) != NULL)
|
||||
{
|
||||
temp = copyString(temp);
|
||||
}
|
||||
freeMem(newName);
|
||||
newName = temp;
|
||||
#ifdef XP_WIN
|
||||
if (newName != NULL)
|
||||
{
|
||||
while (newName[x] != '\0')
|
||||
{
|
||||
if (newName[x] == '/')
|
||||
{
|
||||
newName[x] = '\\';
|
||||
}
|
||||
++x;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return(newName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
_esFEData *
|
||||
esMakeFEData(RDF_Resource parent, RDF_Resource child, int method)
|
||||
{
|
||||
_esFEData *feData;
|
||||
|
||||
if ((feData = (_esFEData *)XP_ALLOC(3*sizeof(char *))) != NULL)
|
||||
{
|
||||
feData->parent = copyString(resourceID(parent));
|
||||
feData->child = copyString(resourceID(child));
|
||||
feData->method = method;
|
||||
}
|
||||
return(feData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
esFreeFEData(_esFEData *feData)
|
||||
{
|
||||
if (feData != NULL)
|
||||
{
|
||||
if (feData->parent) freeMem(feData->parent);
|
||||
if (feData->child) freeMem(feData->child);
|
||||
freeMem(feData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** go tell the directory that child got added to parent **/
|
||||
void
|
||||
ESAddChild (RDF_Resource parent, RDF_Resource child)
|
||||
{
|
||||
URL_Struct *urls;
|
||||
void *feData, **files_to_post = NULL;
|
||||
|
||||
if ((urls = NET_CreateURLStruct(resourceID(parent), NET_SUPER_RELOAD)) != NULL)
|
||||
{
|
||||
feData = (void *)esMakeFEData(parent, child, URL_POST_METHOD);
|
||||
if ((files_to_post = (char **)XP_ALLOC(2*sizeof(char *))) != NULL)
|
||||
{
|
||||
files_to_post[0] = nativeFilename(resourceID(child));
|
||||
files_to_post[1] = NULL;
|
||||
}
|
||||
if ((feData != NULL) && (files_to_post != NULL))
|
||||
{
|
||||
urls->files_to_post = (void *)files_to_post;
|
||||
urls->post_to = NULL;
|
||||
urls->method = URL_POST_METHOD;
|
||||
urls->fe_data = (void *)feData;
|
||||
NET_GetURL(urls, FO_PRESENT,
|
||||
(MWContext *)gRDFMWContext(NULL),
|
||||
es_GetUrlExitFunc);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (feData != NULL)
|
||||
{
|
||||
esFreeFEData(feData);
|
||||
}
|
||||
if (files_to_post != NULL)
|
||||
{
|
||||
if (files_to_post[0] != NULL) freeMem(files_to_post[0]);
|
||||
XP_FREE(files_to_post);
|
||||
}
|
||||
NET_FreeURLStruct(urls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** remove the child from the directory **/
|
||||
void
|
||||
ESRemoveChild (RDF_Resource parent, RDF_Resource child)
|
||||
{
|
||||
URL_Struct *urls;
|
||||
void *feData;
|
||||
|
||||
if ((urls = NET_CreateURLStruct(resourceID(child), NET_SUPER_RELOAD)) != NULL)
|
||||
{
|
||||
feData = (void *)esMakeFEData(parent, child, URL_DELETE_METHOD);
|
||||
if (feData != NULL)
|
||||
{
|
||||
urls->method = URL_DELETE_METHOD;
|
||||
urls->fe_data = (void *)feData;
|
||||
NET_GetURL(urls, FO_PRESENT,
|
||||
(MWContext *)gRDFMWContext(NULL),
|
||||
es_GetUrlExitFunc);
|
||||
}
|
||||
else
|
||||
{
|
||||
NET_FreeURLStruct(urls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
parseNextESFTPLine (RDFFile f, char* line)
|
||||
{
|
||||
PRBool directoryp;
|
||||
RDF_Resource ru;
|
||||
char *token, *url;
|
||||
int16 loop, tokenNum = 0;
|
||||
int32 val;
|
||||
|
||||
if (f->fileType != FTP_RT && f->fileType != ES_RT) return;
|
||||
|
||||
/* work around bug where linefeeds are actually encoded as %0A */
|
||||
if (endsWith("%0A", line)) line[RDF_STRLEN(line)-3] = '\0';
|
||||
|
||||
if ((token = strtok(line, " ")) != NULL)
|
||||
{
|
||||
/* skip 1st token (the numeric command) */
|
||||
token = strtok(NULL, " \t");
|
||||
}
|
||||
|
||||
if (startsWith("200:", line))
|
||||
{
|
||||
while (token != NULL)
|
||||
{
|
||||
while ((token != NULL) && (tokenNum < RDF_MAX_NUM_FILE_TOKENS))
|
||||
{
|
||||
if (!RDF_STRCMP(token, "Filename"))
|
||||
{
|
||||
f->tokens[f->numFileTokens].token = gCoreVocab->RDF_name;
|
||||
f->tokens[f->numFileTokens].type = RDF_STRING_TYPE;
|
||||
f->tokens[f->numFileTokens].tokenNum = tokenNum;
|
||||
++(f->numFileTokens);
|
||||
}
|
||||
else if (!RDF_STRCMP(token, "Content-Length"))
|
||||
{
|
||||
f->tokens[f->numFileTokens].token = gWebData->RDF_size;
|
||||
f->tokens[f->numFileTokens].type = RDF_INT_TYPE;
|
||||
f->tokens[f->numFileTokens].tokenNum = tokenNum;
|
||||
++(f->numFileTokens);
|
||||
}
|
||||
else if (!RDF_STRCMP(token, "File-type"))
|
||||
{
|
||||
f->tokens[f->numFileTokens].token = gWebData->RDF_description;
|
||||
f->tokens[f->numFileTokens].type = RDF_STRING_TYPE;
|
||||
f->tokens[f->numFileTokens].tokenNum = tokenNum;
|
||||
++(f->numFileTokens);
|
||||
}
|
||||
else if (!RDF_STRCMP(token, "Last-Modified"))
|
||||
{
|
||||
f->tokens[f->numFileTokens].token = gWebData->RDF_lastModifiedDate;
|
||||
f->tokens[f->numFileTokens].type = RDF_STRING_TYPE;
|
||||
f->tokens[f->numFileTokens].tokenNum = tokenNum;
|
||||
++(f->numFileTokens);
|
||||
}
|
||||
/*
|
||||
else if (!RDF_STRCMP(token, "Permissions"))
|
||||
{
|
||||
f->tokens[f->numFileTokens].token = NULL;
|
||||
f->tokens[f->numFileTokens].type = RDF_STRING_TYPE;
|
||||
f->tokens[f->numFileTokens].tokenNum = tokenNum;
|
||||
++(f->numFileTokens);
|
||||
}
|
||||
*/
|
||||
++tokenNum;
|
||||
token = strtok(NULL, " \t");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (startsWith("201:", line))
|
||||
{
|
||||
directoryp = false;
|
||||
while (token != NULL)
|
||||
{
|
||||
for (loop=0; loop<f->numFileTokens; loop++)
|
||||
{
|
||||
if (tokenNum == f->tokens[loop].tokenNum)
|
||||
{
|
||||
f->tokens[loop].data = strdup(token);
|
||||
if (f->tokens[loop].token == gWebData->RDF_description)
|
||||
{
|
||||
if (startsWith("Directory", token) ||
|
||||
startsWith("Sym-Directory", token))
|
||||
{
|
||||
directoryp = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
++tokenNum;
|
||||
token = strtok(NULL, " \t");
|
||||
}
|
||||
|
||||
ru = NULL;
|
||||
for (loop=0; loop<f->numFileTokens; loop++)
|
||||
{
|
||||
/* find name, create resource from it */
|
||||
|
||||
if (f->tokens[loop].token == gCoreVocab->RDF_name)
|
||||
{
|
||||
if (resourceType(f->top) == ES_RT)
|
||||
{
|
||||
url = PR_smprintf("nes:%s%s%s", f->url, f->tokens[loop].data, (directoryp) ? "/":"");
|
||||
}
|
||||
else
|
||||
{
|
||||
url = PR_smprintf("%s%s%s", f->url, f->tokens[loop].data, (directoryp) ? "/":"");
|
||||
}
|
||||
if (url != NULL)
|
||||
{
|
||||
if ((ru = RDF_GetResource(NULL, url, 1)) != NULL)
|
||||
{
|
||||
setResourceType(ru, resourceType(f->top));
|
||||
if (directoryp == true)
|
||||
{
|
||||
setContainerp(ru, 1);
|
||||
}
|
||||
XP_FREE(url);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ru != NULL)
|
||||
{
|
||||
for (loop=0; loop<f->numFileTokens; loop++)
|
||||
{
|
||||
if (f->tokens[loop].data != NULL)
|
||||
{
|
||||
switch(f->tokens[loop].type)
|
||||
{
|
||||
case RDF_STRING_TYPE:
|
||||
addSlotValue(f, ru, f->tokens[loop].token,
|
||||
unescapeURL(f->tokens[loop].data),
|
||||
f->tokens[loop].type, NULL);
|
||||
break;
|
||||
|
||||
case RDF_INT_TYPE:
|
||||
if (directoryp == false)
|
||||
{
|
||||
sscanf(f->tokens[loop].data, "%lu", &val);
|
||||
if (val != 0)
|
||||
{
|
||||
addSlotValue(f, ru, f->tokens[loop].token,
|
||||
(void *)val, f->tokens[loop].type, NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
addSlotValue(f, ru, gCoreVocab->RDF_parent, f->top, RDF_RESOURCE_TYPE, NULL);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
parseNextESFTPBlob(NET_StreamClass *stream, char* blob, int32 size)
|
||||
{
|
||||
RDFFile f;
|
||||
int32 n, last, m;
|
||||
n = last = 0;
|
||||
|
||||
f = (RDFFile)stream->data_object;
|
||||
if (f == NULL || size < 0) {
|
||||
return MK_INTERRUPTED;
|
||||
}
|
||||
|
||||
while (n < size) {
|
||||
char c = blob[n];
|
||||
m = 0;
|
||||
memset(f->line, '\0', f->lineSize);
|
||||
if (f->holdOver[0] != '\0') {
|
||||
memcpy(f->line, f->holdOver, RDF_STRLEN(f->holdOver));
|
||||
m = RDF_STRLEN(f->holdOver);
|
||||
memset(f->holdOver, '\0', RDF_BUF_SIZE);
|
||||
}
|
||||
while ((m < f->lineSize) && (c != '\r') && (c != '\n') && (n < size)) {
|
||||
f->line[m] = c;
|
||||
m++;
|
||||
n++;
|
||||
c = blob[n];
|
||||
}
|
||||
n++;
|
||||
if (m > 0) {
|
||||
if ((c == '\n') || (c == '\r')) {
|
||||
last = n;
|
||||
parseNextESFTPLine(f, f->line);
|
||||
} else if (size > last) {
|
||||
memcpy(f->holdOver, f->line, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(size);
|
||||
}
|
||||
67
mozilla/modules/rdf/src/es2mcf.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_ES2MCF_H_
|
||||
#define _RDF_ES2MCF_H_
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "net.h"
|
||||
|
||||
|
||||
|
||||
/* es2mcf.c data structures and defines */
|
||||
|
||||
typedef struct {
|
||||
char *parent;
|
||||
char *child;
|
||||
int method;
|
||||
} _esFEData;
|
||||
|
||||
|
||||
|
||||
/* es2mcf.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
RDFT MakeESFTPStore (char* url);
|
||||
_esFEData * esMakeFEData(RDF_Resource parent, RDF_Resource child, int method);
|
||||
void esFreeFEData(_esFEData *feData);
|
||||
void ESFTPPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) ;
|
||||
RDF_Error ESInit (RDFT ntr);
|
||||
PRBool ESFTPRT (RDF_Resource u);
|
||||
PRBool ESAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool ESUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool ESDBAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool ESDBRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool ESHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
void * ESGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor ESGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * ESNextValue (RDFT mcf, RDF_Cursor c);
|
||||
RDF_Error ESDisposeCursor (RDFT mcf, RDF_Cursor c);
|
||||
void es_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx);
|
||||
char * nativeFilename(char *filename);
|
||||
void ESAddChild (RDF_Resource parent, RDF_Resource child);
|
||||
void ESRemoveChild (RDF_Resource parent, RDF_Resource child);
|
||||
void possiblyAccessES(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
void parseNextESFTPLine (RDFFile f, char* line);
|
||||
int parseNextESFTPBlob(NET_StreamClass *stream, char* blob, int32 size);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
372
mozilla/modules/rdf/src/find2rdf.c
Normal file
@@ -0,0 +1,372 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements Find support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "find2rdf.h"
|
||||
|
||||
/* globals */
|
||||
static RDFT gRDFFindDB = NULL;
|
||||
|
||||
|
||||
|
||||
void
|
||||
parseResourceIntoFindTokens(RDF_Resource u, findTokenStruct *tokens)
|
||||
{
|
||||
char *id, *token, *value;
|
||||
int loop;
|
||||
|
||||
if ((id = copyString(resourceID(u) + RDF_STRLEN("find:"))) != NULL)
|
||||
{
|
||||
/* parse ID, build up token list */
|
||||
if ((token = strtok(id, "&")) != NULL)
|
||||
{
|
||||
while (token != NULL)
|
||||
{
|
||||
if ((value = strstr(token, "=")) != NULL)
|
||||
{
|
||||
*value++ = '\0';
|
||||
}
|
||||
for (loop=0; tokens[loop].token != NULL; loop++)
|
||||
{
|
||||
if (!RDF_STRCMP(token, tokens[loop].token))
|
||||
{
|
||||
tokens[loop].value = copyString(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
token = strtok(NULL, "&");
|
||||
}
|
||||
}
|
||||
freeMem(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
parseFindURL(RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
RDF_Resource searchOn = NULL, matchOn = NULL;
|
||||
int loop;
|
||||
findTokenStruct tokens[5];
|
||||
|
||||
/* build up a token list */
|
||||
tokens[0].token = "location"; tokens[0].value = NULL;
|
||||
tokens[1].token = "attribute"; tokens[1].value = NULL;
|
||||
tokens[2].token = "method"; tokens[2].value = NULL;
|
||||
tokens[3].token = "value"; tokens[3].value = NULL;
|
||||
tokens[4].token = NULL; tokens[4].value = NULL;
|
||||
|
||||
parseResourceIntoFindTokens(u, tokens);
|
||||
|
||||
if ((tokens[1].value != NULL) && (tokens[3].value != NULL))
|
||||
{
|
||||
if ((searchOn = RDF_GetResource(NULL, tokens[1].value, 0)) != NULL)
|
||||
{
|
||||
if ((matchOn = RDF_GetResource(NULL, tokens[2].value, 0)) == NULL)
|
||||
{
|
||||
matchOn = gCoreVocab->RDF_substring;
|
||||
}
|
||||
if ((c = getMem(sizeof(struct RDF_CursorStruct))) != NULL)
|
||||
{
|
||||
c->u = u;
|
||||
c->s = s;
|
||||
c->type = type;
|
||||
c->tv = tv;
|
||||
c->inversep = inversep;
|
||||
c->count = 0;
|
||||
/* Note: need to copy value string [its a local variable] */
|
||||
c->pdata = (void *)RDF_Find(searchOn, matchOn,
|
||||
copyString(tokens[3].value), RDF_STRING_TYPE);
|
||||
if (c->pdata == NULL)
|
||||
{
|
||||
freeMem(c);
|
||||
c = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* free values in token list */
|
||||
for (loop=0; tokens[loop].token != NULL; loop++)
|
||||
{
|
||||
if (tokens[loop].value != NULL)
|
||||
{
|
||||
freeMem(tokens[loop].value);
|
||||
tokens[loop].value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
FindGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
PRBool passThru = PR_TRUE;
|
||||
|
||||
if ((((s == gCoreVocab->RDF_child) && (!inversep)) ||
|
||||
((s == gCoreVocab->RDF_parent) && (inversep))) &&
|
||||
(type == RDF_RESOURCE_TYPE) && (tv))
|
||||
{
|
||||
if (startsWith("find:", resourceID(u)))
|
||||
{
|
||||
passThru = PR_FALSE;
|
||||
c = parseFindURL(rdf, u, s, type, inversep, tv);
|
||||
}
|
||||
}
|
||||
|
||||
if (passThru == PR_TRUE)
|
||||
{
|
||||
c = remoteStoreGetSlotValues(rdf, u, s, type, inversep, tv);
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
findNextURL(RDF_Cursor c)
|
||||
{
|
||||
RDF_Resource r = NULL;
|
||||
PRBool valid = PR_FALSE;
|
||||
|
||||
do
|
||||
{
|
||||
if ((r = (RDF_Resource)RDF_NextValue(c)) != NULL)
|
||||
{
|
||||
if (strstr(resourceID(r), ":"))
|
||||
{
|
||||
if ((!startsWith("find:", resourceID(r))) &&
|
||||
(!startsWith("NC:", resourceID(r))) &&
|
||||
(!startsWith("Command:", resourceID(r))))
|
||||
{
|
||||
valid = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while((r != NULL) && (valid == PR_FALSE));
|
||||
return((void *)r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
FindNextValue(RDFT rdf, RDF_Cursor c)
|
||||
{
|
||||
PRBool passThru = PR_TRUE;
|
||||
void *retVal = NULL;
|
||||
|
||||
PR_ASSERT(c != NULL);
|
||||
if (c == NULL) return(NULL);
|
||||
|
||||
if ((c->u != NULL) && (((c->s == gCoreVocab->RDF_child) && (!(c->inversep))) ||
|
||||
((c->s == gCoreVocab->RDF_parent) && (c->inversep))) &&
|
||||
(c->type == RDF_RESOURCE_TYPE) && (c->tv))
|
||||
{
|
||||
if (startsWith("find:", resourceID(c->u)))
|
||||
{
|
||||
if (c->pdata != NULL)
|
||||
{
|
||||
passThru = PR_FALSE;
|
||||
retVal = findNextURL((RDF_Cursor)(c->pdata));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (passThru == PR_TRUE)
|
||||
{
|
||||
retVal = remoteStoreNextValue(rdf, c);
|
||||
}
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
FindGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
void *retVal = NULL;
|
||||
PRBool passThru = PR_TRUE;
|
||||
|
||||
if ((startsWith("find:", resourceID(u))) && (s == gCoreVocab->RDF_name))
|
||||
{
|
||||
/* DebugStr("\p FindGetSlotValue on name"); */
|
||||
}
|
||||
|
||||
if (passThru == PR_TRUE)
|
||||
{
|
||||
retVal = remoteStoreGetSlotValue(rdf, u, s, type, inversep, tv);
|
||||
}
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char*) retVal)));
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
FindPossible(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
RDF_Cursor c;
|
||||
RDF_Resource r;
|
||||
|
||||
if ((startsWith("find:", resourceID(u))) && (containerp(u) &&
|
||||
(((s == gCoreVocab->RDF_parent) && (inversep)) ||
|
||||
((s == gCoreVocab->RDF_child) && (!inversep))) ))
|
||||
{
|
||||
if ((c = FindGetSlotValues (rdf, u, s, RDF_RESOURCE_TYPE, inversep, PR_TRUE)) != NULL)
|
||||
{
|
||||
while((r = (RDF_Resource)FindNextValue(rdf, c)) != NULL)
|
||||
{
|
||||
if (!remoteStoreHasAssertion (rdf, r, gCoreVocab->RDF_parent,
|
||||
u, RDF_RESOURCE_TYPE, PR_TRUE))
|
||||
{
|
||||
remoteStoreAdd(rdf, r, gCoreVocab->RDF_parent,
|
||||
u, RDF_RESOURCE_TYPE, PR_TRUE);
|
||||
}
|
||||
}
|
||||
RDF_DisposeCursor(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
FindDisposeCursor(RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
RDF_Error err = noRDFErr;
|
||||
char *value;
|
||||
|
||||
if (c != NULL)
|
||||
{
|
||||
if ((((c->s == gCoreVocab->RDF_child) && (!(c->inversep))) ||
|
||||
((c->s == gCoreVocab->RDF_parent) && (c->inversep))) &&
|
||||
(c->type == RDF_RESOURCE_TYPE) && (c->tv))
|
||||
{
|
||||
if (startsWith("find:", resourceID(c->u)))
|
||||
{
|
||||
if (c->pdata != NULL)
|
||||
{
|
||||
/* Note: at creation, we had to copy "v",
|
||||
so free it here */
|
||||
if ((value = ((RDF_Cursor)(c->pdata))->value) != NULL)
|
||||
{
|
||||
freeMem(value);
|
||||
((RDF_Cursor)(c->pdata))->value = NULL;
|
||||
}
|
||||
RDF_DisposeCursor((RDF_Cursor)(c->pdata));
|
||||
c->pdata = NULL;
|
||||
}
|
||||
}
|
||||
freeMem(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = remoteStoreDisposeCursor (mcf, c);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
findPossiblyAddName(RDFT rdf, RDF_Resource u)
|
||||
{
|
||||
findTokenStruct tokens[5];
|
||||
char *name;
|
||||
|
||||
if ((name = (char *)remoteStoreGetSlotValue(rdf, u, gCoreVocab->RDF_name,
|
||||
RDF_STRING_TYPE, PR_FALSE, PR_TRUE)) == NULL)
|
||||
{
|
||||
/* build up a token list */
|
||||
tokens[0].token = "location"; tokens[0].value = NULL;
|
||||
tokens[1].token = "attribute"; tokens[1].value = NULL;
|
||||
tokens[2].token = "method"; tokens[2].value = NULL;
|
||||
tokens[3].token = "value"; tokens[3].value = NULL;
|
||||
tokens[4].token = NULL; tokens[4].value = NULL;
|
||||
|
||||
parseResourceIntoFindTokens(u, tokens);
|
||||
|
||||
if ((name = PR_smprintf(XP_GetString(RDF_FIND_FULLNAME_STR),
|
||||
((tokens[1].value != NULL) ? tokens[1].value : ""),
|
||||
((tokens[2].value != NULL) ? tokens[2].value : ""),
|
||||
((tokens[3].value != NULL) ? tokens[3].value : ""))) != NULL)
|
||||
{
|
||||
remoteStoreAdd(rdf, u, gCoreVocab->RDF_name, name,
|
||||
RDF_STRING_TYPE, PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
FindAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
/* don't handle the assert, but simply add a name if it doesn't already have one */
|
||||
|
||||
if (startsWith("find:", resourceID(u)))
|
||||
{
|
||||
findPossiblyAddName(rdf, u);
|
||||
}
|
||||
return(PR_FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeFindStore (char *url)
|
||||
{
|
||||
RDFT ntr = NULL;
|
||||
|
||||
if (gRDFFindDB != NULL) return(gRDFFindDB);
|
||||
|
||||
if (strstr(url, "rdf:find"))
|
||||
{
|
||||
if ((ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct))) != NULL)
|
||||
{
|
||||
ntr->assert = FindAssert;
|
||||
ntr->unassert = NULL;
|
||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->getSlotValue = FindGetSlotValue;
|
||||
ntr->getSlotValues = FindGetSlotValues;
|
||||
ntr->nextValue = FindNextValue;
|
||||
ntr->disposeCursor = FindDisposeCursor;
|
||||
ntr->possiblyAccessFile = FindPossible;
|
||||
ntr->destroy = NULL;
|
||||
ntr->url = copyString(url);
|
||||
gRDFFindDB = ntr;
|
||||
}
|
||||
}
|
||||
return(ntr);
|
||||
}
|
||||
52
mozilla/modules/rdf/src/find2rdf.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_FIND_H_
|
||||
#define _RDF_FIND_H_
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
/* find.c data structures and defines */
|
||||
|
||||
typedef struct _findTokenStruct {
|
||||
char *token;
|
||||
char *value;
|
||||
} findTokenStruct;
|
||||
|
||||
|
||||
/* find.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
void parseResourceIntoFindTokens(RDF_Resource u, findTokenStruct *tokens);
|
||||
RDF_Cursor parseFindURL(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor FindGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * findNextURL(RDF_Cursor c);
|
||||
void * FindNextValue(RDFT rdf, RDF_Cursor c);
|
||||
void * FindGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void FindPossible(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
RDF_Error FindDisposeCursor(RDFT mcf, RDF_Cursor c);
|
||||
void findPossiblyAddName(RDFT rdf, RDF_Resource u);
|
||||
PRBool FindAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
RDFT MakeFindStore (char* url);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
1143
mozilla/modules/rdf/src/fs2rdf.c
Normal file
84
mozilla/modules/rdf/src/fs2rdf.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_FS2RDF_H_
|
||||
#define _RDF_FS2RDF_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "xp_mem.h"
|
||||
#include "client.h"
|
||||
#include "prio.h"
|
||||
#include "prlong.h"
|
||||
#include "nlcstore.h"
|
||||
#include "remstore.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <Appletalk.h>
|
||||
#include <Devices.h>
|
||||
#include <Files.h>
|
||||
#include <FinderRegistry.h>
|
||||
#include <Folders.h>
|
||||
#include <Processes.h>
|
||||
|
||||
#include "FullPath.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* fs2rdf.c data structures and defines */
|
||||
|
||||
extern int RDF_VOLUME_DESC_STR, RDF_DIRECTORY_DESC_STR, RDF_FILE_DESC_STR;
|
||||
|
||||
#define fsUnitp(u) (resourceType(u) == LFS_RT)
|
||||
|
||||
#define XP_DIRECTORY_SEPARATOR '/'
|
||||
|
||||
|
||||
|
||||
|
||||
/* fs2rdf.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
#ifdef XP_MAC
|
||||
OSErr nativeMacPathname(char *fileURL, FSSpec *fss);
|
||||
OSErr getPSNbyTypeSig(ProcessSerialNumber *thePSN, OSType pType, OSType pSignature);
|
||||
#endif
|
||||
|
||||
void importForProfile (char *dir, const char *uname);
|
||||
void GuessIEBookmarks(void);
|
||||
char * getVolume(int16 volNum, PRBool afpVols);
|
||||
PRDir * OpenDir(char *name);
|
||||
RDFT MakeLFSStore (char* url);
|
||||
PRBool fsAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool fsRemoveFile(char *filePathname, PRBool justCheckWriteAccess);
|
||||
PRBool fsRemoveDir(char *filePathname, PRBool justCheckWriteAccess);
|
||||
PRBool fsUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool fsHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
void * fsGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
PRBool fileDirectoryp(RDF_Resource u);
|
||||
RDF_Cursor fsGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * fsNextValue (RDFT rdf, RDF_Cursor c);
|
||||
PRBool isFileVisible(char *fileURL);
|
||||
RDF_Error fsDisposeCursor (RDFT rdf, RDF_Cursor c);
|
||||
RDF_Resource CreateFSUnit (char* nname, PRBool isDirectoryFlag);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
469
mozilla/modules/rdf/src/glue.c
Normal file
@@ -0,0 +1,469 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains the glue code that links the RDF module with
|
||||
* ugly navigator stuff including Netlib for getURL, preferences for
|
||||
* finding out where bookmarks.htm and lclstore.mcf are located. By
|
||||
* changing this glue file, one should be able to use the rest of the
|
||||
* RDF library with something else (like the server).
|
||||
|
||||
* For more information on this file, contact rjc or guha
|
||||
* For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "glue.h"
|
||||
#include "remstore.h"
|
||||
#include "rdfparse.h"
|
||||
#include "es2mcf.h"
|
||||
#include "mcff2mcf.h"
|
||||
#include "nlcstore.h"
|
||||
#include "autoupdt.h"
|
||||
#include "ht.h"
|
||||
#ifdef NU_CACHE
|
||||
#include "CacheStubs.h"
|
||||
#endif
|
||||
|
||||
/* external routines */
|
||||
extern MWContext *FE_GetRDFContext(void);
|
||||
extern char *gDefaultNavcntr;
|
||||
extern RDF gNCDB;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned int
|
||||
rdf_write_ready(NET_StreamClass *stream)
|
||||
{
|
||||
return MAX_WRITE_READY;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
rdf_complete(NET_StreamClass *stream)
|
||||
{
|
||||
RDFFile f = (RDFFile)stream->data_object;
|
||||
if (RDF_STRCMP(f->url, gNavCntrUrl) == 0) {
|
||||
if (f->resourceCount == 0) {
|
||||
parseNextRDFXMLBlob(stream, gDefaultNavcntr, RDF_STRLEN(gDefaultNavcntr));
|
||||
} else {
|
||||
RDF_Resource browser = RDF_GetResource(NULL, "netscape:browser", 1);
|
||||
RDF_Resource updateFrom = RDF_GetResource(NULL, "updateURL", 1);
|
||||
char* uf = RDF_GetSlotValue(gNCDB, browser, updateFrom,
|
||||
RDF_STRING_TYPE, false, true);
|
||||
RDF_Resource fileSize = RDF_GetResource(NULL, "fileSize", 1);
|
||||
char* fs = RDF_GetSlotValue(gNCDB, browser, fileSize,
|
||||
RDF_STRING_TYPE, false, true);
|
||||
uint32 fSize;
|
||||
if (fs == NULL) {
|
||||
fSize = 3000;
|
||||
} else {
|
||||
sscanf("%lu", fs, &fSize);
|
||||
freeMem(fs);
|
||||
}
|
||||
if (uf != NULL) {
|
||||
#ifdef MOZ_SMARTUPDATE
|
||||
checkForAutoUpdate((void *)FE_GetRDFContext(), uf, fSize);
|
||||
#endif /* MOZ_SMARTUPDATE */
|
||||
freeMem(uf);
|
||||
}
|
||||
|
||||
/* A temporary hack to demo AutoUpdate on windows */
|
||||
#ifndef MOZ_SMARTUPDATE
|
||||
#ifdef XP_WIN
|
||||
checkForAutoUpdate((void *)FE_GetRDFContext(), "http://warp/u/raman/gromit/softupdt.exe", 45328);
|
||||
#endif /* XP_WIN */
|
||||
#endif /* MOZ_SMARTUPDATE */
|
||||
|
||||
}
|
||||
}
|
||||
if (f) {
|
||||
freeMem(f->line);
|
||||
freeMem(f->currentSlot);
|
||||
freeMem(f->holdOver);
|
||||
freeNamespaces(f) ;
|
||||
f->line = NULL;
|
||||
f->currentSlot = NULL;
|
||||
f->holdOver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
rdf_abort(NET_StreamClass *stream, int status)
|
||||
{
|
||||
RDFFile f = (RDFFile)stream->data_object;
|
||||
if (RDF_STRCMP(f->url, gNavCntrUrl) == 0) {
|
||||
parseNextRDFXMLBlob(stream, gDefaultNavcntr, RDF_STRLEN(gDefaultNavcntr));
|
||||
}
|
||||
|
||||
if (f) {
|
||||
f->locked = false;
|
||||
gcRDFFile (f);
|
||||
freeMem(f->line);
|
||||
freeMem(f->currentSlot);
|
||||
freeMem(f->holdOver);
|
||||
freeNamespaces(f) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
#ifdef XP_MAC
|
||||
PR_PUBLIC_API(NET_StreamClass *)
|
||||
#else
|
||||
PUBLIC NET_StreamClass *
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
parseNextRDFXMLBlob (NET_StreamClass *stream, char* blob, int32 size)
|
||||
{
|
||||
RDFFile f;
|
||||
|
||||
f = (RDFFile)stream->data_object;
|
||||
if ((f == NULL) || (size < 0)) {
|
||||
return MK_INTERRUPTED;
|
||||
}
|
||||
return parseNextRDFXMLBlobInt(f, blob, size);
|
||||
}
|
||||
|
||||
rdf_Converter(FO_Present_Types format_out, void *client_data,
|
||||
URL_Struct *urls, MWContext *cx)
|
||||
{
|
||||
RDFFile rdfFile;
|
||||
MKStreamWriteFunc writeFunc = NULL;
|
||||
|
||||
if ((urls == NULL) || (urls->fe_data == NULL))
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* determine appropriate write function to use */
|
||||
rdfFile = urls->fe_data;
|
||||
switch(rdfFile->fileType)
|
||||
{
|
||||
/* case ES_RT:
|
||||
case FTP_RT:
|
||||
writeFunc = (MKStreamWriteFunc)parseNextESFTPBlob;
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
writeFunc = (MKStreamWriteFunc)parseNextRDFXMLBlob;
|
||||
break;
|
||||
}
|
||||
|
||||
/* allocate stream data block */
|
||||
return NET_NewStream("RDF", writeFunc,
|
||||
(MKStreamCompleteFunc)rdf_complete,
|
||||
(MKStreamAbortFunc)rdf_abort,
|
||||
(MKStreamWriteReadyFunc)rdf_write_ready,
|
||||
urls->fe_data, cx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
rdf_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
|
||||
{
|
||||
RDFFile f;
|
||||
char *navCenterURL = NULL;
|
||||
|
||||
if ((status < 0) && (urls != NULL))
|
||||
{
|
||||
if ((cx != NULL) && (urls->error_msg != NULL))
|
||||
{
|
||||
FE_Alert(cx, urls->error_msg);
|
||||
}
|
||||
|
||||
/* if unable to read in navcntr.rdf file, create some default views */
|
||||
if ((f = (RDFFile) urls->fe_data) != NULL)
|
||||
{
|
||||
if (RDF_STRCMP(f->url, gNavCntrUrl) == 0)
|
||||
{
|
||||
parseNextRDFXMLBlobInt(f, gDefaultNavcntr,
|
||||
RDF_STRLEN(gDefaultNavcntr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (urls != NULL)
|
||||
{
|
||||
if ((f = (RDFFile) urls->fe_data) != NULL)
|
||||
{
|
||||
htLoadComplete(f->url, status);
|
||||
}
|
||||
}
|
||||
|
||||
NET_FreeURLStruct (urls);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
int
|
||||
rdfRetrievalType (RDFFile f)
|
||||
{
|
||||
URL_Struct *urls;
|
||||
char *url;
|
||||
int type;
|
||||
|
||||
url = f->url;
|
||||
if (f->localp)
|
||||
{
|
||||
urls = NET_CreateURLStruct(url, NET_CACHE_ONLY_RELOAD);
|
||||
if ((urls != NULL) && (NET_IsURLInDiskCache(urls) || NET_IsURLInMemCache(urls)))
|
||||
{
|
||||
type = NET_DONT_RELOAD;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = NET_NORMAL_RELOAD;
|
||||
}
|
||||
if (urls != NULL) NET_FreeURLStruct(urls);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = NET_NORMAL_RELOAD;
|
||||
}
|
||||
return(type);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
rdf_GetURL (MWContext *cx, int method, Net_GetUrlExitFunc *exit_routine, RDFFile rdfFile)
|
||||
{
|
||||
URL_Struct *urls = NULL;
|
||||
char* url ;
|
||||
#ifdef DEBUG_gagan
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
if (cx == NULL) return 0;
|
||||
if (rdfFile->refreshingp && rdfFile->updateURL) {
|
||||
url = rdfFile->updateURL;
|
||||
} else {
|
||||
url = rdfFile->url;
|
||||
}
|
||||
if (RDF_STRCMP(url, gNavCntrUrl) == 0) {
|
||||
urls = NET_CreateURLStruct(url, NET_CACHE_ONLY_RELOAD);
|
||||
#ifdef NU_CACHE
|
||||
if (!CacheManager_Contains(url)) {
|
||||
#else
|
||||
if (NET_IsURLInDiskCache(urls) || NET_IsURLInMemCache(urls)) {
|
||||
} else {
|
||||
#endif
|
||||
NET_FreeURLStruct(urls);
|
||||
urls = NULL;
|
||||
}
|
||||
}
|
||||
if (!urls)
|
||||
urls = NET_CreateURLStruct(url, (rdfFile->refreshingp ?
|
||||
NET_SUPER_RELOAD : NET_NORMAL_RELOAD));
|
||||
if (urls == NULL) return 0;
|
||||
urls->fe_data = rdfFile;
|
||||
if (method) urls->method = method;
|
||||
NET_GetURL(urls, FO_CACHE_AND_RDF, cx, rdf_GetUrlExitFunc);
|
||||
return 1;
|
||||
}
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
|
||||
|
||||
|
||||
void
|
||||
possiblyRereadRDFFiles (void* data)
|
||||
{
|
||||
possiblyRefreshRDFFiles();
|
||||
/* timerID = FE_SetTimeout(possiblyRereadRDFFiles, NULL, 1000 * 60 * 10);
|
||||
once every 10 minutes
|
||||
diabled for legal reasons.*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
RDFglueInitialize()
|
||||
{
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
timerID = FE_SetTimeout(possiblyRereadRDFFiles, NULL, 1000 * 60 * 10); /* once every 10 minutes */
|
||||
if (gRLForbiddenDomains != NULL)
|
||||
{
|
||||
freeMem(gRLForbiddenDomains);
|
||||
gRLForbiddenDomains = NULL;
|
||||
}
|
||||
if (PREF_CopyCharPref("browser.relatedLinksDisabledForDomains", &gRLForbiddenDomains) != PREF_OK)
|
||||
{
|
||||
gRLForbiddenDomains = NULL;
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
RDFglueExit (void)
|
||||
{
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
if (timerID != NULL)
|
||||
{
|
||||
/* commented out as the timer's window has already been destroyed */
|
||||
|
||||
/* FE_ClearTimeout(timerID); */
|
||||
timerID = NULL;
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
gRDFMWContext(RDFT db)
|
||||
{
|
||||
#ifndef MOZILLA_CLIENT
|
||||
return NULL;
|
||||
#else
|
||||
void *cx;
|
||||
RDFL rdf = NULL;
|
||||
|
||||
if (db) rdf = db->rdf;
|
||||
|
||||
while (rdf) {
|
||||
if (rdf->rdf->context) return (rdf->rdf->context);
|
||||
rdf = rdf->next;
|
||||
}
|
||||
|
||||
cx = (void *)FE_GetRDFContext();
|
||||
return(cx);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* beginReadingRDFFile is called whenever we need to read something of
|
||||
* the net (or local drive). The url of the file to be read is at
|
||||
* file->url. As the bits are read in (and it can take the bits in
|
||||
* any sized chunks) it should call parseNextRDFBlob(file, nextBlock,
|
||||
* blobSize) when its done, it should call void finishRDFParse
|
||||
* (RDFFile f) to abort, it should call void abortRDFParse (RDFFile f)
|
||||
* [which will undo all that has been read from that file]
|
||||
*/
|
||||
|
||||
void
|
||||
beginReadingRDFFile (RDFFile file)
|
||||
{
|
||||
char *url;
|
||||
int method = 0;
|
||||
|
||||
#ifndef MOZILLA_CLIENT
|
||||
|
||||
/* If standalone, we just use to open the file */
|
||||
NET_StreamClass stream;
|
||||
PRFileDesc *fd;
|
||||
PRFileInfo fi;
|
||||
PRBool bSuccess = FALSE;
|
||||
|
||||
url = file->url;
|
||||
fd = CallPROpenUsingFileURL(url, PR_RDONLY, 0);
|
||||
if(fd)
|
||||
{
|
||||
if(PR_GetOpenFileInfo(fd, &fi) == PR_SUCCESS)
|
||||
{
|
||||
char* buf = malloc(fi.size);
|
||||
if(PR_Read(fd, buf, fi.size))
|
||||
{
|
||||
stream.data_object = file;
|
||||
if(parseNextRDFXMLBlob (&stream, buf, fi.size))
|
||||
bSuccess = TRUE;
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
PR_Close(fd);
|
||||
}
|
||||
if(bSuccess == TRUE)
|
||||
rdf_complete(&stream);
|
||||
#else
|
||||
|
||||
/*
|
||||
XXX this is the pre-raptor world
|
||||
|
||||
url = file->url;
|
||||
if (file->fileType == ES_RT) method = URL_INDEX_METHOD;
|
||||
rdf_GetURL (gRDFMWContext(file->db), method, NULL, file);
|
||||
*/
|
||||
|
||||
rdfStreamListener* pListener = new rdfStreamListener;
|
||||
pListener->AddRef(); // XXX is this evil? Can't see any reason to use factories but...
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
DB *
|
||||
CallDBOpenUsingFileURL(char *fileURL, int flags,int mode, DBTYPE type, const void *openinfo)
|
||||
{
|
||||
DB *result;
|
||||
char *path;
|
||||
char *escapedPath;
|
||||
|
||||
if (fileURL == NULL) return NULL;
|
||||
|
||||
escapedPath = unescapeURL(fileURL);
|
||||
|
||||
#ifdef XP_MAC
|
||||
path = WH_FilePlatformName(convertFileURLToNSPRCopaceticPath(fileURL));
|
||||
PR_ASSERT(path != NULL);
|
||||
#else
|
||||
|
||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
||||
#endif
|
||||
result = dbopen(path, flags, mode, type, openinfo);
|
||||
#ifdef XP_MAC
|
||||
XP_FREE(path);
|
||||
#endif
|
||||
|
||||
if (escapedPath != NULL) freeMem(escapedPath);
|
||||
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
#if defined(XP_WIN) && defined(DEBUG)
|
||||
/* Some XP functions that are implemented in winfe
|
||||
* in the client.
|
||||
*/
|
||||
void XP_AssertAtLine( char *pFileName, int iLine )
|
||||
{
|
||||
fprintf(stderr, "assert: line %d, file %s%c\n", __LINE__, pFileName, 7);
|
||||
}
|
||||
|
||||
char* NOT_NULL(const char* x)
|
||||
{
|
||||
return (char*)x;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
90
mozilla/modules/rdf/src/glue.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_GLUE_H_
|
||||
#define _RDF_GLUE_H_
|
||||
|
||||
|
||||
#include "xp.h"
|
||||
#include "xp_mem.h"
|
||||
#include "net.h"
|
||||
#include "ntypes.h"
|
||||
#include "fe_proto.h"
|
||||
|
||||
#include "prinit.h"
|
||||
|
||||
#ifdef XP_UNIX
|
||||
#include <sys/fcntl.h>
|
||||
#elif defined(XP_MAC)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "ht.h"
|
||||
|
||||
|
||||
|
||||
#define APPLICATION_RDF "application/x-rdf" /* XXX what should these be? */
|
||||
#define EXTENSION_RDF ".rdf"
|
||||
#define EXTENSION_MCF ".mcf"
|
||||
|
||||
|
||||
|
||||
/* external globals */
|
||||
extern char* gLocalStoreURL;
|
||||
extern char* gBookmarkURL;
|
||||
|
||||
|
||||
|
||||
/* glue.c prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
void ht_fprintf(PRFileDesc *file, const char *fmt, ...);
|
||||
|
||||
unsigned int rdf_write_ready(NET_StreamClass *stream);
|
||||
void rdf_complete(NET_StreamClass *stream);
|
||||
void rdf_abort(NET_StreamClass *stream, int status);
|
||||
NET_StreamClass * rdf_Converter(FO_Present_Types format_out,
|
||||
void *client_data, URL_Struct *urls, MWContext *cx);
|
||||
void rdf_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx);
|
||||
int rdfRetrievalType (RDFFile f);
|
||||
int rdf_GetURL (MWContext *cx, int method,
|
||||
Net_GetUrlExitFunc *exit_routine, RDFFile rdfFile);
|
||||
void possiblyRereadRDFFiles (void* data);
|
||||
void RDFglueInitialize (void);
|
||||
void RDFglueExit (void);
|
||||
void *gRDFMWContext(RDFT db);
|
||||
void beginReadingRDFFile (RDFFile file);
|
||||
void readLocalFile (RDFFile file);
|
||||
|
||||
char *unescapeURL(char *inURL);
|
||||
char *convertFileURLToNSPRCopaceticPath(char* inURL);
|
||||
PRFileDesc *CallPROpenUsingFileURL(char *fileURL, PRIntn flags, PRIntn mode);
|
||||
PRDir *CallPROpenDirUsingFileURL(char *fileURL);
|
||||
int32 CallPRWriteAccessFileUsingFileURL(char *fileURL);
|
||||
int32 CallPRDeleteFileUsingFileURL(char *fileURL);
|
||||
int CallPR_RmDirUsingFileURL(char *dirURL);
|
||||
int32 CallPRMkDirUsingFileURL(char *dirURL, int mode);
|
||||
DB *CallDBOpenUsingFileURL(char *fileURL, int flags,int mode,
|
||||
DBTYPE type, const void *openinfo);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
675
mozilla/modules/rdf/src/hist2rdf.c
Normal file
@@ -0,0 +1,675 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements History support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "hist2rdf.h"
|
||||
#include "remstore.h"
|
||||
#include "utils.h"
|
||||
|
||||
static PRBool histInFlatFilep = 0;
|
||||
|
||||
/* extern declarations */
|
||||
void GH_DeleteHistoryItem (char * url);
|
||||
PR_PUBLIC_API(void) updateNewHistItem (DBT *key, DBT *data); /* XXX this should be elsewhere */
|
||||
|
||||
|
||||
/* externs */
|
||||
extern char *profileDirURL;
|
||||
extern char *gGlobalHistoryURL;
|
||||
|
||||
|
||||
/* external string references in allxpstr */
|
||||
extern int RDF_WEEKOF, RDF_WITHINLASTHOUR, RDF_TODAY, RDF_DAY_0;
|
||||
extern int RDF_RELATEDLINKSNAME;
|
||||
|
||||
|
||||
/* globals */
|
||||
PLHashTable *hostHash = 0;
|
||||
RDFT grdf = NULL;
|
||||
RDFT gHistoryStore = 0;
|
||||
PRBool ByDateOpened = 0;
|
||||
PRBool historyInitialized = 0;
|
||||
static int saveCount = 0;
|
||||
|
||||
|
||||
char *prefixList[] = {
|
||||
"about:", "javascript:", "livescript:", "mailbox:", "mailto:",
|
||||
"mocha:", "news:", "pop3", "snews:", "view-source", "wysiwyg:", NULL
|
||||
};
|
||||
|
||||
char *suffixList[] = {
|
||||
".gif", ".jpg", ".jpeg", ".xbm", ".pfr", ".class", ".tmp", ".js", ".rdf",
|
||||
".mcf", ".mco", NULL
|
||||
};
|
||||
|
||||
char *intermediateList[] = {
|
||||
".gif", ".GIF", NULL
|
||||
};
|
||||
|
||||
|
||||
|
||||
void
|
||||
collateHistory (RDFT r, RDF_Resource u, PRBool byDateFlag)
|
||||
{
|
||||
HASHINFO hash = { 4*1024, 0, 0, 0, 0, 0};
|
||||
DBT key, data;
|
||||
time_t last,first;
|
||||
uint32 numaccess;
|
||||
PRBool firstOne = 0;
|
||||
DB* db = CallDBOpenUsingFileURL(gGlobalHistoryURL, O_RDONLY ,0600,
|
||||
DB_HASH, &hash);
|
||||
grdf = r;
|
||||
if (db != NULL) {
|
||||
while (0 == (*db->seq)(db, &key, &data, (firstOne ? R_NEXT : R_FIRST))) {
|
||||
char* title = ((char*)data.data + 16); /* title */
|
||||
char* url = (char*)key.data; /* url */
|
||||
/* int32 flag = (int32)*((char*)data.data + 3*sizeof(int32)); */
|
||||
int32 flag;
|
||||
HIST_COPY_INT32(&flag, (int8 *)data.data + 3 * sizeof(int32));
|
||||
firstOne = 1;
|
||||
#ifdef XP_UNIX
|
||||
if ((/*1 == flag &&*/ displayHistoryItem((char*)key.data))) {
|
||||
#else
|
||||
if (1 == flag && displayHistoryItem((char*)key.data)) {
|
||||
#endif
|
||||
HIST_COPY_INT32(&last, (time_t *)((int8 *)data.data));
|
||||
HIST_COPY_INT32(&first, (time_t *)((int8 *)data.data + sizeof(int32)));
|
||||
HIST_COPY_INT32(&numaccess, (time_t *)((int8 *)data.data + 2*sizeof(int32)));
|
||||
|
||||
collateOneHist(r, u,url,title, last, first, numaccess, byDateFlag);
|
||||
}
|
||||
}
|
||||
(*db->close)(db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
collateOneHist (RDFT r, RDF_Resource u, char* url, char* title, time_t lastAccessDate,
|
||||
time_t firstAccessDate, uint32 numAccesses, PRBool byDateFlag)
|
||||
{
|
||||
char buffer[128];
|
||||
struct tm *time;
|
||||
RDF_Resource hostUnit, urlUnit;
|
||||
char* existingName = NULL;
|
||||
uint32 oldNumAccess = 0;
|
||||
if (startsWith("404", title)) return;
|
||||
urlUnit = HistCreate(url, 1);
|
||||
existingName = remoteStoreGetSlotValue(gLocalStore, urlUnit, gCoreVocab->RDF_name, RDF_STRING_TYPE, 0, 1);
|
||||
|
||||
PR_ASSERT( IsUTF8String((const char* )existingName));
|
||||
|
||||
if (existingName == NULL) {
|
||||
if (title[0] != '\0') remoteAddName(urlUnit, title);
|
||||
} else freeMem(existingName);
|
||||
if (byDateFlag) {
|
||||
hostUnit = hostUnitOfDate(r, u, lastAccessDate);
|
||||
} else {
|
||||
hostUnit = hostUnitOfURL(r, u, urlUnit, title);
|
||||
}
|
||||
|
||||
if (hostUnit == NULL) return;
|
||||
|
||||
|
||||
if (hostUnit != urlUnit) remoteAddParent(urlUnit, hostUnit);
|
||||
|
||||
if ((time = localtime((time_t *) &lastAccessDate)) != NULL)
|
||||
{
|
||||
#ifdef XP_MAC
|
||||
time->tm_year += 4;
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#elif XP_UNIX
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
PR_ASSERT( IsUTF8String((const char* )buffer));
|
||||
remoteStoreAdd(gRemoteStore, urlUnit, gWebData->RDF_lastVisitDate,
|
||||
(void *)copyString(buffer), RDF_STRING_TYPE, 1);
|
||||
}
|
||||
if ((time = localtime((time_t *) &firstAccessDate)) != NULL)
|
||||
{
|
||||
#ifdef XP_MAC
|
||||
time->tm_year += 4;
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#elif XP_UNIX
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
PR_ASSERT( IsUTF8String((const char* )buffer));
|
||||
remoteStoreAdd(gRemoteStore, urlUnit, gWebData->RDF_firstVisitDate,
|
||||
(void *)copyString(buffer), RDF_STRING_TYPE, 1);
|
||||
}
|
||||
/* oldNumAccess = remoteStoreGetSlotValue(gHistoryStore, urlUnit, gWebData->RDF_numAccesses,
|
||||
RDF_INT_TYPE, 0, 1);
|
||||
if (oldNumAccess) remoteStoreRemove(gHistoryStore, urlUnit, gWebData->RDF_numAccesses, oldNumAccess,
|
||||
RDF_INT_TYPE);
|
||||
if (numAccesses==0) ++numAccesses;
|
||||
remoteStoreAdd(gHistoryStore, urlUnit, gWebData->RDF_numAccesses,
|
||||
(void *)numAccesses, RDF_INT_TYPE, 1); */
|
||||
if (numAccesses > 5) histAddParent(urlUnit, gNavCenter->RDF_HistoryMostVisited);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
hostUnitOfURL (RDFT r, RDF_Resource top, RDF_Resource nu, char* title)
|
||||
{
|
||||
char host[100];
|
||||
char* url = resourceID(nu);
|
||||
int16 s1, s2, s3;
|
||||
RDF_Resource hostResource, existing;
|
||||
if (RDF_STRLEN(url) > 100) return NULL;
|
||||
if (startsWith("file", url)) {
|
||||
return RDF_GetResource(NULL, "Local Files", 1);
|
||||
} else {
|
||||
memset(host, '\0', 100);
|
||||
s1 = charSearch(':', url)+3;
|
||||
s2 = charSearch('/', &url[s1]);
|
||||
s3 = charSearch(':', &url[s1]);
|
||||
if (s2 == -1) s2 = RDF_STRLEN(url)-s1;
|
||||
if ((s3 != -1) && (s2 > s3)) s2 = s3;
|
||||
if (startsWith("www", &url[s1])) {s1 = s1+4; s2 = s2-4;}
|
||||
if (s2<1) return(NULL);
|
||||
memcpy((char*)host, &url[s1], s2);
|
||||
host[0] = toupper(host[0]);
|
||||
hostResource = RDF_GetResource(NULL, host, 1);
|
||||
setContainerp(hostResource, 1);
|
||||
setResourceType(hostResource, HISTORY_RT);
|
||||
existing = PL_HashTableLookup(hostHash, hostResource);
|
||||
if (existing != NULL) {
|
||||
if (existing == nu) {
|
||||
return existing;
|
||||
} else if (existing == top) {
|
||||
return hostResource;
|
||||
} else {
|
||||
remoteStoreRemove(gHistoryStore, existing, gCoreVocab->RDF_parent, top, RDF_RESOURCE_TYPE);
|
||||
histAddParent(existing, hostResource);
|
||||
histAddParent(hostResource, top);
|
||||
PL_HashTableAdd(hostHash, hostResource, top);
|
||||
return hostResource;
|
||||
}
|
||||
} else {
|
||||
PL_HashTableAdd(hostHash, hostResource, nu);
|
||||
histAddParent(nu, top);
|
||||
return nu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
hourRange(char *buffer, struct tm *theTm)
|
||||
{
|
||||
char *startHourStr="AM",*endHourStr="AM";
|
||||
|
||||
if (theTm->tm_hour > 0 && theTm->tm_hour < 12) {
|
||||
sprintf(buffer, "AM");
|
||||
} else {
|
||||
sprintf(buffer, "PM");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
hostUnitOfDate (RDFT r, RDF_Resource u, time_t lastAccessDate)
|
||||
{
|
||||
RDF_Resource node = NULL, parentNode;
|
||||
/*
|
||||
RDF_Resources std;
|
||||
*/
|
||||
time_t now, tempTime;
|
||||
struct tm *T,nowStruct, dateStruct;
|
||||
char hourBuffer[128], dayBuffer[128], weekBuffer[128];
|
||||
char bigBuffer[1024];
|
||||
int numDays;
|
||||
|
||||
/* NOTE: localtime uses a single static buffer, so MUST copy contents out */
|
||||
|
||||
time((time_t *)&now);
|
||||
if ((T = localtime(&now)) == NULL) return(NULL);
|
||||
nowStruct = *T;
|
||||
|
||||
if ((T = localtime(&lastAccessDate)) == NULL) return(NULL);
|
||||
dateStruct = *T;
|
||||
|
||||
bigBuffer[0] = hourBuffer[0] = dayBuffer[0] = weekBuffer[0] = 0;
|
||||
|
||||
if (now < (lastAccessDate + SECS_IN_HOUR)) /* within the last hour */
|
||||
{
|
||||
strcpy(hourBuffer, XP_GetString(RDF_WITHINLASTHOUR));
|
||||
}
|
||||
else if ((nowStruct.tm_year == dateStruct.tm_year) && /* some time today */
|
||||
(nowStruct.tm_yday == dateStruct.tm_yday))
|
||||
{
|
||||
strcpy(dayBuffer, XP_GetString(RDF_TODAY));
|
||||
hourRange(hourBuffer, &dateStruct);
|
||||
}
|
||||
else /* check if within last week */
|
||||
{
|
||||
numDays = 7;
|
||||
do
|
||||
{
|
||||
now -= SECS_IN_DAY;
|
||||
if ((T = localtime(&now)) == NULL) return(NULL);
|
||||
nowStruct = *T;
|
||||
if ((nowStruct.tm_year == dateStruct.tm_year) &&
|
||||
(nowStruct.tm_yday == dateStruct.tm_yday))
|
||||
{
|
||||
sprintf(dayBuffer, "%d/%d - %s",
|
||||
(uint) dateStruct.tm_mon + 1, (uint)dateStruct.tm_mday,
|
||||
XP_GetString(RDF_DAY_0 + nowStruct.tm_wday));
|
||||
hourRange(hourBuffer, &dateStruct);
|
||||
break;
|
||||
}
|
||||
} while (numDays-- > 0);
|
||||
|
||||
if (dayBuffer[0] == '\0') /* older than a week */
|
||||
{
|
||||
tempTime = lastAccessDate;
|
||||
numDays = dateStruct.tm_wday;
|
||||
while (numDays-- > 0)
|
||||
{
|
||||
tempTime -= SECS_IN_DAY;
|
||||
}
|
||||
if ((T = localtime(&tempTime)) == NULL) return(NULL);
|
||||
dateStruct = *T;
|
||||
#ifdef XP_MAC
|
||||
/* Mac epoch according to localtime is 1904 */
|
||||
PR_snprintf(weekBuffer, sizeof(weekBuffer)-1, XP_GetString(RDF_WEEKOF), (uint)dateStruct.tm_mon + 1,
|
||||
(int)dateStruct.tm_mday, (uint)dateStruct.tm_year + 1904);
|
||||
#else
|
||||
PR_snprintf(weekBuffer, sizeof(weekBuffer)-1, XP_GetString(RDF_WEEKOF), (uint)dateStruct.tm_mon + 1,
|
||||
(int)dateStruct.tm_mday, (uint)dateStruct.tm_year + 1900);
|
||||
#endif
|
||||
|
||||
if ((T = localtime(&lastAccessDate)) == NULL) return(NULL);
|
||||
dateStruct = *T;
|
||||
|
||||
#ifdef XP_MAC
|
||||
/* Mac epoch according to localtime is 1904 */
|
||||
sprintf(dayBuffer, "%s - %d/%d/%d",
|
||||
XP_GetString(RDF_DAY_0 + dateStruct.tm_wday), (uint) dateStruct.tm_mon + 1,
|
||||
(uint)dateStruct.tm_mday, (uint)dateStruct.tm_year + 1904);
|
||||
#else
|
||||
sprintf(dayBuffer, "%s - %d/%d/%d",
|
||||
XP_GetString(RDF_DAY_0 + dateStruct.tm_wday), (uint) dateStruct.tm_mon + 1,
|
||||
(uint)dateStruct.tm_mday, (uint)dateStruct.tm_year + 1900);
|
||||
#endif
|
||||
hourRange(hourBuffer, &dateStruct);
|
||||
}
|
||||
}
|
||||
parentNode = u;
|
||||
|
||||
if (weekBuffer[0] != '\0')
|
||||
{
|
||||
if ((node = RDF_GetResource(NULL, weekBuffer, false)) == NULL)
|
||||
{
|
||||
if ((node = RDF_GetResource(NULL, weekBuffer, true)) == NULL) return(NULL);
|
||||
}
|
||||
setContainerp(node, 1);
|
||||
setResourceType(node, HISTORY_RT);
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_parent,
|
||||
parentNode, RDF_RESOURCE_TYPE, 1);
|
||||
PR_ASSERT( IsUTF8String((const char* )weekBuffer));
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(weekBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
}
|
||||
if (dayBuffer[0] != '\0')
|
||||
{
|
||||
sprintf(bigBuffer, "%d/%d", (uint) dateStruct.tm_mon + 1,
|
||||
(uint)dateStruct.tm_mday);
|
||||
|
||||
|
||||
if ((node = RDF_GetResource(NULL, bigBuffer, false)) == NULL)
|
||||
{
|
||||
if ((node = RDF_GetResource(NULL, bigBuffer, true)) == NULL) return(NULL);
|
||||
}
|
||||
setContainerp(node, 1);
|
||||
setResourceType(node, HISTORY_RT);
|
||||
histAddParent(node, parentNode);
|
||||
sprintf(bigBuffer,"%s - %s",weekBuffer,dayBuffer);
|
||||
PR_ASSERT( IsUTF8String((const char* )dayBuffer));
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(dayBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
}
|
||||
if (hourBuffer[0] == 'W')
|
||||
{
|
||||
sprintf(bigBuffer, "%s", hourBuffer);
|
||||
|
||||
if ((node = RDF_GetResource(NULL, bigBuffer, false)) == NULL)
|
||||
{
|
||||
if ((node = RDF_GetResource(NULL, bigBuffer, true)) == NULL) return(NULL);
|
||||
}
|
||||
setContainerp(node, 1);
|
||||
setResourceType(node, HISTORY_RT);
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_parent,
|
||||
parentNode, RDF_RESOURCE_TYPE, 1);
|
||||
PR_ASSERT( IsUTF8String((const char* )hourBuffer));
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(hourBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
}
|
||||
return (node);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
saveHistory ()
|
||||
{
|
||||
char* escapedPath = unescapeURL(gGlobalHistoryURL);
|
||||
char* path = WH_FilePlatformName(convertFileURLToNSPRCopaceticPath(escapedPath));
|
||||
PRFileDesc* file = PR_Open(path, PR_WRONLY | PR_CREATE_FILE, 00200);
|
||||
char* hist;
|
||||
if (file != NULL) {
|
||||
hist = RDF_SerializeRDFStore(gHistoryStore) ;
|
||||
if (hist != NULL) {
|
||||
PR_Write(file, hist, RDF_STRLEN(hist));
|
||||
}
|
||||
}
|
||||
freeMem(path);
|
||||
freeMem(escapedPath);
|
||||
PR_Close(file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(void)
|
||||
updateNewHistItem (DBT *key, DBT *data)
|
||||
{
|
||||
time_t last,first,numaccess;
|
||||
int32 flg = (int32)*((char*)data->data + 3*sizeof(int32));
|
||||
if (!displayHistoryItem((char*)key->data)) return;
|
||||
if (historyInitialized && (gHistoryStore != NULL)) {
|
||||
HIST_COPY_INT32(&last, (time_t *)((char *)data->data));
|
||||
HIST_COPY_INT32(&first, (time_t *)((char *)data->data + sizeof(int32)));
|
||||
HIST_COPY_INT32(&numaccess, (time_t *)((char *)data->data + 2*sizeof(int32)));
|
||||
|
||||
if (hostHash) collateOneHist(grdf, gNavCenter->RDF_HistoryBySite,
|
||||
(char*)key->data, /* url */
|
||||
((char*)data->data + 4*sizeof(int32)), /* title */
|
||||
last, first, numaccess, 0);
|
||||
if (ByDateOpened) collateOneHist(grdf, gNavCenter->RDF_HistoryByDate,
|
||||
(char*)key->data, /* url */
|
||||
((char*)data->data + 4*sizeof(int32)), /* title */
|
||||
last, first, numaccess, 1);
|
||||
saveCount++;
|
||||
if (saveCount > 5) {
|
||||
if (histInFlatFilep) saveHistory();
|
||||
saveCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** History clustering utils **/
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
displayHistoryItem (char* url)
|
||||
{
|
||||
int x;
|
||||
x=0;
|
||||
while (prefixList[x]) {
|
||||
if (startsWith(prefixList[x++], url)) return 0;
|
||||
}
|
||||
x=0;
|
||||
while (suffixList[x]) {
|
||||
if (endsWith(suffixList[x++], url)) return 0;
|
||||
}
|
||||
x=0;
|
||||
while (intermediateList[x]) {
|
||||
if (strstr(url, intermediateList[x++])) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
HistCreate (char* url, PRBool createp)
|
||||
{
|
||||
size_t size = RDF_STRLEN(url);
|
||||
char* nurl = getMem(size+8);
|
||||
RDF_Resource ans;
|
||||
if (charSearch(':', url) == -1) {
|
||||
if (url[size-1] == '/') {
|
||||
sprintf(nurl, "http://%s", url);
|
||||
nurl[RDF_STRLEN(nurl)-1] = '\0';
|
||||
} else {
|
||||
sprintf(nurl, "http://%s/", url);
|
||||
}
|
||||
} else {
|
||||
if (url[size-1] == '/') {
|
||||
memcpy(nurl, url, size-1);
|
||||
} else {
|
||||
sprintf(nurl, "%s/", url);
|
||||
}
|
||||
}
|
||||
ans = RDF_GetResource(NULL, nurl, 0);
|
||||
if (ans != NULL) {
|
||||
freeMem(nurl);
|
||||
return ans;
|
||||
}
|
||||
freeMem(nurl);
|
||||
ans = RDF_GetResource(NULL, url, createp);
|
||||
|
||||
if (ans != NULL) {
|
||||
return ans;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool bySite = 0;
|
||||
|
||||
Assertion
|
||||
histAddParent (RDF_Resource child, RDF_Resource parent)
|
||||
{
|
||||
Assertion nextAs, prevAs, newAs;
|
||||
RDF_Resource s = gCoreVocab->RDF_parent;
|
||||
RDF_ValueType type = RDF_RESOURCE_TYPE;
|
||||
nextAs = prevAs = child->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(gHistoryStore, nextAs, child, s, parent, type)) return null;
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
newAs = makeNewAssertion(gHistoryStore, child, s, parent, type, 1);
|
||||
if (prevAs == null) {
|
||||
child->rarg1 = newAs;
|
||||
} else {
|
||||
prevAs->next = newAs;
|
||||
}
|
||||
nextAs = prevAs = parent->rarg2;
|
||||
if (nextAs == NULL) {
|
||||
parent->rarg2 = newAs;
|
||||
} else {
|
||||
PRBool added = 0;
|
||||
if (bySite) {
|
||||
while (nextAs && !isSeparator(nextAs->u)) {
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
if (nextAs) {
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
while (nextAs != null) {
|
||||
char* nid = resourceID(nextAs->u);
|
||||
if (RDF_STRCMP(resourceID(child), resourceID(nextAs->u)) > 0) {
|
||||
if (prevAs == nextAs) {
|
||||
newAs->invNext = prevAs;
|
||||
parent->rarg2 = newAs;
|
||||
added = 1;
|
||||
break;
|
||||
} else {
|
||||
newAs->invNext = nextAs;
|
||||
prevAs->invNext = newAs;
|
||||
added = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
if (!added) prevAs->invNext = newAs;
|
||||
}
|
||||
sendNotifications2(gHistoryStore, RDF_ASSERT_NOTIFY, child, s, parent, type, 1);
|
||||
/* XXX have to mark the entire subtree XXX */
|
||||
/* sendNotifications(gHistoryStore->rdf, RDF_ASSERT_NOTIFY, child, s, parent, type, 1); */
|
||||
return(newAs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
historyUnassert (RDFT hst, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if ((type == RDF_RESOURCE_TYPE) && (resourceType((RDF_Resource)v) == HISTORY_RT) &&
|
||||
(s == gCoreVocab->RDF_parent)) {
|
||||
RDF_Resource parents[5];
|
||||
int8 n = 0;
|
||||
Assertion as = u->rarg1;
|
||||
memset(parents, '\0', 5 * sizeof(RDF_Resource));
|
||||
while (as) {
|
||||
if ((as->type == RDF_RESOURCE_TYPE) && (as->s == gCoreVocab->RDF_parent) &&
|
||||
(resourceType((RDF_Resource)as->value) == HISTORY_RT) && (n < 5)) {
|
||||
parents[n++] = (RDF_Resource)as->value;
|
||||
}
|
||||
as = as->next;
|
||||
}
|
||||
if (containerp(u)) {
|
||||
Assertion as = u->rarg2;
|
||||
while (as) {
|
||||
if ((as->db == gHistoryStore) && (as->s == gCoreVocab->RDF_parent)) {
|
||||
GH_DeleteHistoryItem (resourceID(as->u));
|
||||
}
|
||||
as = as->invNext;
|
||||
}
|
||||
} else {
|
||||
GH_DeleteHistoryItem (resourceID(u));
|
||||
}
|
||||
|
||||
while (n > 0) {
|
||||
n = n - 1;
|
||||
if (parents[n]) {
|
||||
Assertion nas = remoteStoreRemove (gHistoryStore, u, gCoreVocab->RDF_parent,
|
||||
parents[n], RDF_RESOURCE_TYPE);
|
||||
freeMem(nas);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
HistPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
if ((s == gCoreVocab->RDF_parent) && inversep && (rdf == gHistoryStore) &&
|
||||
((u == gNavCenter->RDF_HistoryByDate) || (u == gNavCenter->RDF_HistoryBySite))) {
|
||||
if (histInFlatFilep) {
|
||||
readRDFFile(gGlobalHistoryURL, NULL, 0, gHistoryStore);
|
||||
historyInitialized = 1;
|
||||
} else {
|
||||
collateHistory(rdf, u, (u == gNavCenter->RDF_HistoryByDate));
|
||||
historyInitialized = 1;
|
||||
}
|
||||
} else if ((s == gCoreVocab->RDF_parent) && inversep && (rdf == gHistoryStore) &&
|
||||
(u == gNavCenter->RDF_HistoryMostVisited)) {
|
||||
collateHistory(rdf, gNavCenter->RDF_HistoryBySite, 0);
|
||||
historyInitialized = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RDFT
|
||||
MakeHistoryStore (char* url)
|
||||
{
|
||||
if (startsWith("rdf:history", url)) {
|
||||
if (gHistoryStore == 0) {
|
||||
RDFT ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct));
|
||||
RDF_Resource sep = createSeparator();
|
||||
ntr->assert = NULL;
|
||||
ntr->unassert = historyUnassert;
|
||||
ntr->getSlotValue = remoteStoreGetSlotValue;
|
||||
ntr->getSlotValues = remoteStoreGetSlotValues;
|
||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->nextValue = remoteStoreNextValue;
|
||||
ntr->disposeCursor = remoteStoreDisposeCursor;
|
||||
ntr->possiblyAccessFile = HistPossiblyAccessFile;
|
||||
gHistoryStore = ntr;
|
||||
histInFlatFilep = endsWith(".rdf", gGlobalHistoryURL);
|
||||
ntr->url = copyString(url);
|
||||
hostHash = PL_NewHashTable(500, idenHash, PL_CompareValues, PL_CompareValues, null, null);
|
||||
ByDateOpened = 1;
|
||||
return ntr;
|
||||
} else return gHistoryStore;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void
|
||||
dumpHist ()
|
||||
{
|
||||
FILE *fp = fopen("history.txt", "w");
|
||||
HASHINFO hash = { 4*1024, 0, 0, 0, 0, 0};
|
||||
DBT key, data;
|
||||
PRBool firstOne = 0;
|
||||
DB* db = CallDBOpenUsingFileURL(gGlobalHistoryURL, O_RDONLY ,0600,
|
||||
DB_HASH, &hash);
|
||||
|
||||
if (db != NULL) {
|
||||
while (0 == (*db->seq)(db, &key, &data, (firstOne ? R_NEXT : R_FIRST))) {
|
||||
firstOne = 1;
|
||||
if ((1 == (int32)*((char*)data.data + 3*sizeof(uint32)) &&
|
||||
displayHistoryItem((char*)key.data))) {
|
||||
fprintf(fp, "%s\n", (char*)key.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
(*db->close)(db);
|
||||
}
|
||||
|
||||
*/
|
||||
84
mozilla/modules/rdf/src/hist2rdf.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_HIST2RDF_H_
|
||||
#define _RDF_HIST2RDF_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "prtypes.h" /* for IS_LITTLE_ENDIAN / IS_BIG_ENDIAN */
|
||||
|
||||
|
||||
|
||||
#if !defined(IS_LITTLE_ENDIAN) && !defined(IS_BIG_ENDIAN)
|
||||
#error Must have a byte order
|
||||
#endif
|
||||
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
#define HIST_COPY_INT32(_a,_b) XP_MEMCPY(_a, _b, sizeof(int32));
|
||||
#else
|
||||
#define HIST_COPY_INT32(_a,_b) \
|
||||
do { \
|
||||
((char *)(_a))[0] = ((char *)(_b))[3]; \
|
||||
((char *)(_a))[1] = ((char *)(_b))[2]; \
|
||||
((char *)(_a))[2] = ((char *)(_b))[1]; \
|
||||
((char *)(_a))[3] = ((char *)(_b))[0]; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* hist2rdf.c data structures and defines */
|
||||
|
||||
#define remoteAddParent(child, parent) histAddParent(child, parent);
|
||||
#define remoteAddName(u, name) remoteStoreAdd(gRemoteStore, u, gCoreVocab->RDF_name, copyString(name), RDF_STRING_TYPE, 1);
|
||||
|
||||
#define SECS_IN_HOUR (60L * 60L)
|
||||
#define SECS_IN_DAY (SECS_IN_HOUR * 24L)
|
||||
|
||||
extern int RDF_HTML_WINDATE, RDF_HTML_MACDATE;
|
||||
|
||||
|
||||
/* hist2rdf.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
void collateHistory (RDFT r, RDF_Resource u, PRBool byDateFlag);
|
||||
void collateOneHist (RDFT r, RDF_Resource u, char* url, char* title, time_t lastAccessDate, time_t firstAccessDate, uint32 numAccesses, PRBool byDateFlag);
|
||||
RDF_Resource hostUnitOfURL (RDFT r, RDF_Resource top, RDF_Resource nu, char* title);
|
||||
void hourRange(char *buffer, struct tm *theTm);
|
||||
RDF_Resource hostUnitOfDate (RDFT r, RDF_Resource u, time_t lastAccessDate);
|
||||
void saveHistory();
|
||||
void deleteCurrentSitemaps (char *address);
|
||||
void addRelatedLinks (char* address);
|
||||
PRBool displayHistoryItem (char* url);
|
||||
RDF_Resource HistCreate (char* url, PRBool createp);
|
||||
Assertion histAddParent (RDF_Resource child, RDF_Resource parent);
|
||||
PRBool historyUnassert (RDFT hst, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
void HistPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
RDF_Cursor historyStoreGetSlotValuesInt (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
PRBool historyStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
RDFT MakeHistoryStore (char* url);
|
||||
void dumpHist ();
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
10391
mozilla/modules/rdf/src/ht.c
Normal file
398
mozilla/modules/rdf/src/ht.h
Normal file
@@ -0,0 +1,398 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_HT_H_
|
||||
#define _RDF_HT_H_
|
||||
|
||||
|
||||
#ifndef HT_RAPTOR
|
||||
#include "xpassert.h"
|
||||
#include "xp_qsort.h"
|
||||
#include "xp_time.h"
|
||||
#include "client.h"
|
||||
#include "net.h"
|
||||
#include "xpgetstr.h"
|
||||
#include "xp_str.h"
|
||||
#include "htmldlgs.h"
|
||||
#include "xp_ncent.h"
|
||||
#include "xpassert.h"
|
||||
#include "nspr.h"
|
||||
#include "prefapi.h"
|
||||
#include "fe_proto.h"
|
||||
#include "intl_csi.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include "stdlib.h"
|
||||
#include <Aliases.h>
|
||||
#endif
|
||||
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "math.h"
|
||||
#include "htrdf.h"
|
||||
|
||||
#ifdef SMART_MAIL
|
||||
#include "pm2rdf.h"
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include "prprf.h"
|
||||
#include "plhash.h"
|
||||
#include "xp_core.h"
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "mcf.h"
|
||||
#include "htrdf.h"
|
||||
#include "vocab.h"
|
||||
|
||||
#ifndef XP_ASSERT
|
||||
#define XP_ASSERT(x)
|
||||
#endif
|
||||
|
||||
#ifndef XP_FREE
|
||||
#define XP_FREE(x) PR_Free((x))
|
||||
#endif
|
||||
|
||||
#ifndef XP_STRCASECMP
|
||||
#define XP_STRCASECMP(x,y) strcmp((x),(y))
|
||||
#endif
|
||||
|
||||
#define MWContext void
|
||||
#endif
|
||||
|
||||
|
||||
/* HT data structures and defines */
|
||||
|
||||
#define ITEM_LIST_SIZE 500 /* XXX ITEM_LIST_SIZE should be dynamic */
|
||||
#define ITEM_LIST_ELEMENT_SIZE 20
|
||||
|
||||
#define NUM_MENU_CMDS 40
|
||||
|
||||
#define RDF_SITEMAP 1
|
||||
#define RDF_RELATED_LINKS 2
|
||||
#define FROM_PAGE 1
|
||||
#define GUESS_FROM_PREVIOUS_PAGE 2
|
||||
|
||||
#define HTDEL remoteStoreRemove
|
||||
|
||||
#ifndef HT_RAPTOR
|
||||
/* external string references in allxpstr */
|
||||
extern int RDF_HTML_STR, RDF_HTML_STR_1, RDF_HTML_STR_2, RDF_HTML_STR_3;
|
||||
extern int RDF_HTML_STR_4, RDF_HTML_STR_5, RDF_HTML_STR_NUMBER;
|
||||
extern int RDF_HTML_WINDATE, RDF_HTML_MACDATE, RDF_CMD_0, RDF_DATA_1, RDF_DATA_2;
|
||||
extern int RDF_DELETEFILE, RDF_UNABLETODELETEFILE, RDF_DELETEFOLDER;
|
||||
extern int RDF_UNABLETODELETEFOLDER, RDF_SITEMAPNAME;
|
||||
extern int RDF_RELATEDLINKSNAME, RDF_DEFAULTCOLUMNNAME;
|
||||
extern int RDF_NEWWORKSPACEPROMPT, RDF_DELETEWORKSPACE;
|
||||
extern int RDF_ADDITIONS_ALLOWED, RDF_DELETION_ALLOWED;
|
||||
extern int RDF_ICON_URL_LOCKED, RDF_NAME_LOCKED, RDF_COPY_ALLOWED;
|
||||
extern int RDF_MOVE_ALLOWED, RDF_WORKSPACE_POS_LOCKED;
|
||||
extern int RDF_MAIN_TITLE, RDF_COLOR_TITLE, RDF_HTML_INFOHEADER_STR;
|
||||
extern int RDF_MISSION_CONTROL_TITLE, RDF_TREE_COLORS_TITLE, RDF_SELECTION_COLORS_TITLE;
|
||||
extern int RDF_COLUMN_COLORS_TITLE, RDF_TITLEBAR_COLORS_TITLE, RDF_HTML_MAININFOHEADER_STR;
|
||||
extern int RDF_HTML_EMPTYHEADER_STR, RDF_HTML_COLOR_STR, RDF_SETCOLOR_JS, RDF_DEFAULTCOLOR_JS;
|
||||
extern int RDF_COLOR_LAYER, RDF_HTMLCOLOR_STR;
|
||||
extern int RDF_SELECT_START, RDF_SELECT_END, RDF_SELECT_OPTION;
|
||||
extern int RDF_FIND_STR1, RDF_FIND_STR2, RDF_FIND_INPUT_STR;
|
||||
extern int RDF_LOCAL_LOCATION_STR, RDF_REMOTE_LOCATION_STR, RDF_ALL_LOCATION_STR;
|
||||
extern int RDF_CONTAINS_STR, RDF_IS_STR, RDF_IS_NOT_STR, RDF_STARTS_WITH_STR, RDF_ENDS_WITH_STR;
|
||||
extern int RDF_FIND_TITLE, RDF_FIND_FULLNAME_STR, RDF_SHORTCUT_CONFLICT_STR, RDF_FTP_NAME_STR;
|
||||
|
||||
#ifdef HT_PASSWORD_RTNS
|
||||
extern int RDF_NEWPASSWORD, RDF_CONFIRMPASSWORD;
|
||||
extern int RDF_MISMATCHPASSWORD, RDF_ENTERPASSWORD;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define MISSION_CONTROL_RDF_PREF "browser.navcenter.admin"
|
||||
#define NETSCAPE_RDF_FILENAME "netscape.rdf"
|
||||
|
||||
typedef struct _SBProviderStruct {
|
||||
struct _SBProviderStruct *next;
|
||||
char *url;
|
||||
char *name;
|
||||
PRBool containerp;
|
||||
PRBool openp;
|
||||
} SBProviderStruct;
|
||||
typedef SBProviderStruct* SBProvider;
|
||||
|
||||
typedef struct _HT_PaneStruct {
|
||||
struct _HT_PaneStruct *next;
|
||||
void *pdata;
|
||||
HT_Notification ns;
|
||||
PLHashTable *hash;
|
||||
HT_NotificationMask mask;
|
||||
RDF db;
|
||||
RDF_Notification rns;
|
||||
struct _HT_ViewStruct *viewList;
|
||||
struct _HT_ViewStruct *selectedView;
|
||||
struct _HT_URLSiteMapAssoc *smp;
|
||||
struct _HT_URLSiteMapAssoc *sbp;
|
||||
uint32 viewListCount;
|
||||
PRBool autoFlushFlag;
|
||||
SBProvider smartBrowsingProviders;
|
||||
PRBool dirty;
|
||||
PRBool personaltoolbar;
|
||||
PRBool toolbar;
|
||||
PRBool bookmarkmenu;
|
||||
PRBool special;
|
||||
int windowType;
|
||||
char *windowURL;
|
||||
char *templateType;
|
||||
struct _HT_PaneStruct *templatePane;
|
||||
char *htdburl;
|
||||
RDFT htdb;
|
||||
} HT_PaneStruct;
|
||||
|
||||
typedef struct HT_ColumnStruct {
|
||||
struct HT_ColumnStruct *next;
|
||||
char *name;
|
||||
uint32 width;
|
||||
uint32 tokenType;
|
||||
void *token;
|
||||
void *feData;
|
||||
PRBool isHiddenFlag;
|
||||
} HT_ColumnStruct, *HT_Column;
|
||||
|
||||
typedef struct _HT_ViewStruct {
|
||||
struct _HT_ViewStruct *next;
|
||||
HT_Pane pane;
|
||||
HT_Resource top;
|
||||
void *pdata;
|
||||
HT_Column columns;
|
||||
uint32 workspacePos;
|
||||
struct _HT_ResourceStruct ***itemList;
|
||||
uint32 itemListSize;
|
||||
uint32 itemListCount;
|
||||
uint32 topNodeIndex;
|
||||
uint32 selectedNodeHint;
|
||||
uint32 sortTokenType;
|
||||
void *sortToken;
|
||||
PRBool descendingFlag;
|
||||
PRBool refreshingItemListp;
|
||||
PRBool inited;
|
||||
RDF_Resource treeRel;
|
||||
} HT_ViewStruct;
|
||||
|
||||
typedef struct _HT_ValueStruct {
|
||||
struct _HT_ValueStruct *next;
|
||||
uint32 tokenType;
|
||||
RDF_Resource token;
|
||||
void *data;
|
||||
} HT_ValueStruct, *HT_Value;
|
||||
|
||||
#define HT_CONTAINER_FLAG 0x0001
|
||||
#define HT_OPEN_FLAG 0x0002
|
||||
#define HT_AUTOFLUSH_OPEN_FLAG 0x0004
|
||||
#define HT_HIDDEN_FLAG 0x0008
|
||||
#define HT_SELECTED_FLAG 0x0010
|
||||
#define HT_VOLATILE_URL_FLAG 0x0020
|
||||
#define HT_FREEICON_URL_FLAG 0x0040
|
||||
#define HT_PASSWORDOK_FLAG 0x0080
|
||||
#define HT_INITED_FLAG 0x0100
|
||||
#define HT_DIRTY_FLAG 0x0200
|
||||
#define HT_ENABLED_FLAG 0x0400
|
||||
|
||||
typedef struct _HT_ResourceStruct {
|
||||
struct _HT_ResourceStruct *nextItem;
|
||||
HT_View view;
|
||||
HT_Resource parent;
|
||||
RDF_Resource node;
|
||||
void *feData;
|
||||
char *dataSource;
|
||||
char *url[5];
|
||||
HT_Value values;
|
||||
HT_Resource child;
|
||||
HT_Resource *children; /* used by sorting */
|
||||
uint32 unsortedIndex; /* used by sorting */
|
||||
uint32 itemListIndex;
|
||||
uint32 numChildren, numChildrenTotal;
|
||||
uint16 flags;
|
||||
uint16 depth;
|
||||
HT_Resource next;
|
||||
/* a pane or view might have multiple occurances of a RDF_Resource.
|
||||
The hash table just points to the first of them. This allows us to
|
||||
make a linked list of it */
|
||||
} HT_ResourceStruct;
|
||||
|
||||
typedef struct _HT_MenuCommandStruct {
|
||||
struct _HT_MenuCommandStruct *next;
|
||||
HT_MenuCmd menuCmd;
|
||||
char *name;
|
||||
RDF_Resource graphCommand;
|
||||
} _HT_MenuCommandStruct, *HT_MenuCommand;
|
||||
|
||||
typedef struct _HT_CursorStruct {
|
||||
HT_Resource container;
|
||||
HT_Resource node;
|
||||
RDF_Cursor cursor;
|
||||
uint32 numElements;
|
||||
HT_Column columns;
|
||||
uint16 contextMenuIndex;
|
||||
PRBool foundValidMenuItem;
|
||||
PRBool isWorkspaceFlag;
|
||||
PRBool isBackgroundFlag;
|
||||
PRBool commandExtensions;
|
||||
PRBool commandListBuild;
|
||||
HT_MenuCmd menuCmd;
|
||||
HT_MenuCommand menuCommandList;
|
||||
} HT_CursorStruct;
|
||||
|
||||
typedef struct _HT_Icon {
|
||||
struct _HT_Icon *next;
|
||||
char *name;
|
||||
} _HT_Icon, *HT_Icon;
|
||||
|
||||
typedef struct _htmlElement {
|
||||
struct _htmlElement *next;
|
||||
HT_Resource node;
|
||||
RDF_Resource token;
|
||||
uint32 tokenType;
|
||||
} _htmlElement, *_htmlElementPtr;
|
||||
|
||||
typedef struct _HT_URLSiteMapAssoc {
|
||||
uint8 siteToolType;
|
||||
uint8 origin;
|
||||
uint8 onDisplayp;
|
||||
char *url;
|
||||
RDF_Resource sitemap;
|
||||
char* name;
|
||||
char* sitemapUrl;
|
||||
RDFT db;
|
||||
struct _HT_URLSiteMapAssoc *next;
|
||||
} HT_URLSiteMapAssoc;
|
||||
|
||||
|
||||
|
||||
/* HT function prototypes */
|
||||
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
void HT_Startup();
|
||||
void HT_Shutdown();
|
||||
void htLoadComplete(char *url, int status);
|
||||
void htTimerRoutine(void *timerID);
|
||||
PRBool possiblyUpdateView(HT_View view);
|
||||
void updateViewItem(HT_Resource node);
|
||||
HT_Resource newHTEntry (HT_View view, RDF_Resource node);
|
||||
void addWorkspace(HT_Pane pane, RDF_Resource r, void *feData);
|
||||
void deleteWorkspace(HT_Pane pane, RDF_Resource r);
|
||||
void htrdfNotifFunc (RDF_Event ns, void* pdata);
|
||||
void bmkNotifFunc (RDF_Event ns, void* pdata);
|
||||
void refreshItemListInt (HT_View view, HT_Resource node);
|
||||
PRBool relatedLinksContainerp (HT_Resource node);
|
||||
int nodeCompareRtn(HT_Resource *node1, HT_Resource *node2);
|
||||
void sortNodes(HT_View view, HT_Resource parent, HT_Resource *children, uint32 numChildren);
|
||||
uint32 refreshItemList1(HT_View view, HT_Resource node);
|
||||
void refreshItemList (HT_Resource node, HT_Event whatHappened);
|
||||
void refreshPanes();
|
||||
PRBool initToolbars (HT_Pane pane);
|
||||
HT_Pane paneFromResource(RDF db, RDF_Resource resource, HT_Notification notify, PRBool autoFlushFlag, PRBool autoOpenFlag, PRBool useColumns);
|
||||
void htSetBookmarkAddDateToNow(RDF_Resource r);
|
||||
RDF newHTPaneDB();
|
||||
RDF HTRDF_GetDB();
|
||||
PRBool initViews (HT_Pane pane);
|
||||
void htNewWorkspace(HT_Pane pane, char *id, char *optionalTitle, uint32 workspacePos);
|
||||
HT_PaneStruct * HT_GetHTPaneList ();
|
||||
HT_PaneStruct * HT_GetNextHTPane (HT_PaneStruct* pane);
|
||||
void htSetWorkspaceOrder(RDF_Resource src, RDF_Resource dest, PRBool afterDestFlag);
|
||||
HT_View HT_NewView (RDF_Resource topNode, HT_Pane pane, PRBool useColumns, void *feData, PRBool autoOpen);
|
||||
void sendNotification (HT_Resource node, HT_Event whatHappened, RDF_Resource s, HT_ColumnType type);
|
||||
void deleteHTNode(HT_Resource node);
|
||||
void destroyViewInt (HT_Resource r, PRBool saveOpenState);
|
||||
void htDeletePane(HT_Pane pane, PRBool saveWorkspaceOrder);
|
||||
void saveWorkspaceOrder(HT_Pane pane);
|
||||
void resynchItem (HT_Resource node, void *token, void *data, PRBool assertAction);
|
||||
void resynchContainer (HT_Resource container);
|
||||
HT_Resource addContainerItem (HT_Resource container, RDF_Resource item);
|
||||
void refreshContainerIndexes(HT_Resource container);
|
||||
void removeHTFromHash (HT_Pane pane, HT_Resource item);
|
||||
void deleteHTSubtree (HT_Resource subtree);
|
||||
void deleteContainerItem (HT_Resource container, RDF_Resource item);
|
||||
uint32 fillContainer (HT_Resource node);
|
||||
void sendColumnNotification (HT_View view, void *token, uint32 tokenType, HT_Event whatHappened);
|
||||
PRBool htIsMenuCmdEnabled(HT_Pane pane, HT_MenuCmd menuCmd, PRBool isWorkspaceFlag, PRBool isBackgroundFlag);
|
||||
void freeMenuCommandList();
|
||||
void exportCallbackWrite(PRFileDesc *fp, char *str);
|
||||
void exportCallback(MWContext *context, char *filename, RDF_Resource node);
|
||||
void htEmptyClipboard(RDF_Resource parent);
|
||||
void htCopyReference(RDF_Resource original, RDF_Resource newParent, PRBool empty);
|
||||
PRBool htVerifyUniqueToken(HT_Resource node, void *token, uint32 tokenType, char *data);
|
||||
PRBool ht_isURLReal(HT_Resource node);
|
||||
char * buildInternalIconURL(HT_Resource node, PRBool *volatileURLFlag, PRBool largeIconFlag, PRBool workspaceFlag);
|
||||
char * getIconURL( HT_Resource node, PRBool toolbarFlag, PRBool workspaceFlag, int state);
|
||||
PRBool htIsPropertyInMoreOptions(RDF_Resource r);
|
||||
void addHtmlElement(HT_Resource node, RDF_Resource token, uint32 tokenType);
|
||||
void freeHtmlElementList();
|
||||
_htmlElementPtr findHtmlElement(void *token);
|
||||
void freeHtmlElement(void *token);
|
||||
char * constructHTMLTagData(char *dynStr, int strID, char *data);
|
||||
char * constructHTML(char *dynStr, HT_Resource node, void *token, uint32 tokenType);
|
||||
char * constructHTMLPermission(char *dynStr, HT_Resource node, RDF_Resource token, char *permText);
|
||||
PRBool htIsOpLocked(HT_Resource node, RDF_Resource token);
|
||||
char * constructBasicHTML(char *dynStr, int strID, char *data1, char *data2);
|
||||
void setHiddenState (HT_Resource node);
|
||||
void htSetFindResourceName(RDF db, RDF_Resource r);
|
||||
void htOpenTo(HT_View view, RDF_Resource u, PRBool selectView);
|
||||
PRBool mutableContainerp (RDF_Resource node);
|
||||
char * possiblyCleanUpTitle (char* title);
|
||||
PRBool htRemoveChild(HT_Resource parent, HT_Resource child, PRBool moveToTrash);
|
||||
void ht_SetPassword(HT_Resource node, char *password);
|
||||
PRBool ht_hasPassword(HT_Resource node);
|
||||
PRBool ht_checkPassword(HT_Resource node, PRBool alwaysCheck);
|
||||
HT_DropAction htLaunchSmartNode(HT_Resource dropTarget, char *fullURL);
|
||||
HT_DropAction dropOnSmartNode(HT_Resource dropTarget, HT_Resource dropObject, PRBool justAction);
|
||||
HT_DropAction dropOnSmartURL(HT_Resource dropTarget, char *objTitle, PRBool justAction);
|
||||
HT_DropAction dropOn (HT_Resource dropTarget, HT_Resource dropObject, PRBool justAction);
|
||||
void Win32FileCopyMove(HT_Resource dropTarget, HT_Resource dropObject);
|
||||
HT_DropAction copyMoveRDFLink (HT_Resource dropTarget, HT_Resource dropObject);
|
||||
HT_DropAction copyMoveRDFLinkAtPos (HT_Resource dropx, HT_Resource dropObject, PRBool before);
|
||||
HT_DropAction uploadLFS (HT_Resource dropTarget, HT_Resource dropObject);
|
||||
HT_DropAction uploadRDFFile (HT_Resource dropTarget, HT_Resource dropObject);
|
||||
HT_DropAction esfsCopyMoveContent (HT_Resource dropTarget, HT_Resource dropObject);
|
||||
RDF_BT urlResourceType (char* url);
|
||||
HT_DropAction dropURLOn (HT_Resource dropTarget, char* objURL, char *objTitle, PRBool justAction);
|
||||
void replacePipeWithColon(char* url);
|
||||
HT_DropAction copyRDFLinkURL (HT_Resource dropTarget, char* objURL, char *objTitle);
|
||||
HT_DropAction copyRDFLinkURLAt (HT_Resource dropx, char* objURL, char *objTitle, PRBool before);
|
||||
HT_DropAction uploadLFSURL (HT_Resource dropTarget, char* objURL);
|
||||
HT_DropAction uploadRDFFileURL (HT_Resource dropTarget, char* objURL);
|
||||
HT_DropAction esfsCopyMoveContentURL (HT_Resource dropTarget, char* objURL);
|
||||
RDFT HTADD(HT_Pane pane, RDF_Resource u, RDF_Resource s, void* v);
|
||||
HT_URLSiteMapAssoc * makeNewSMP (HT_Pane htPane, char* pUrl, char* sitemapurl);
|
||||
void RetainOldSitemaps (HT_Pane htPane, char *pUrl);
|
||||
void populateSBProviders (HT_Pane htPane);
|
||||
SBProvider SBProviderOfNode (HT_Resource node);
|
||||
PRBool implicitDomainURL (char* url);
|
||||
PRBool domainMatches (char *dom, char *url);
|
||||
void nextDomain (char* dom, size_t *n);
|
||||
PRBool relatedLinksEnabledURL (char* url);
|
||||
void cleanupInt (HT_Pane htPane, HT_URLSiteMapAssoc *nsmp, RDF_Resource parent);
|
||||
HT_Pane newTemplatePane(char* templateName);
|
||||
void PaneDeleteSBPCleanup (HT_Pane htPane);
|
||||
|
||||
#ifndef HT_RAPTOR
|
||||
PRBool rdfFindDialogHandler(XPDialogState *dlgstate, char **argv, int argc, unsigned int button);
|
||||
#endif
|
||||
|
||||
XP_END_PROTOS
|
||||
|
||||
#endif
|
||||
|
||||
404
mozilla/modules/rdf/src/jsec2rdf.c
Normal file
@@ -0,0 +1,404 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "jsec2rdf.h"
|
||||
#include "fs2rdf.h"
|
||||
#include "utils.h"
|
||||
#include "nlcstore.h"
|
||||
#include "vocabint.h"
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
extern RDF gNCDB;
|
||||
RDF gJSecDB = NULL;
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_InitPrivilegeDB()
|
||||
{
|
||||
if (gJSecDB == 0) {
|
||||
gJSecDB = gNCDB;
|
||||
}
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_SavePrivilegeDB()
|
||||
{
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_ClosePrivilegeDB()
|
||||
{
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
#define JSEC_PRINCIPAL_URL "jsecprin:"
|
||||
|
||||
char *
|
||||
RDFJSec_GetPrincipalURLString(char *principalID)
|
||||
{
|
||||
size_t size = RDF_STRLEN(principalID);
|
||||
char* url = getMem(size+RDF_STRLEN(JSEC_PRINCIPAL_URL)+1);
|
||||
if (url == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
sprintf(url, "%s%s", JSEC_PRINCIPAL_URL, principalID);
|
||||
strcpy(url, principalID);
|
||||
return url;
|
||||
}
|
||||
|
||||
RDF_Cursor
|
||||
RDFJSec_ListAllPrincipals()
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
if (gNavCenter != NULL) {
|
||||
c = RDF_GetSources(gJSecDB, gNavCenter->RDF_JSec,
|
||||
gNavCenter->RDF_JSecPrincipal,
|
||||
RDF_RESOURCE_TYPE, TRUE);
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
JSec_Principal
|
||||
RDFJSec_NextPrincipal(RDF_Cursor c)
|
||||
{
|
||||
if (c != NULL) {
|
||||
return RDF_NextValue(c);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RDF_Error
|
||||
RDFJSec_ReleaseCursor(RDF_Cursor c)
|
||||
{
|
||||
RDF_Error err = 0;
|
||||
if (c != NULL) {
|
||||
err = RDF_DisposeCursor(c);
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
|
||||
JSec_Principal
|
||||
RDFJSec_NewPrincipal(char* principalID)
|
||||
{
|
||||
RDF_Resource principalUnit;
|
||||
char *url = RDFJSec_GetPrincipalURLString(principalID);
|
||||
if (url == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
principalUnit = RDF_GetResource(NULL, url, FALSE);
|
||||
if (!principalUnit) {
|
||||
principalUnit = RDF_GetResource(NULL, url, TRUE);
|
||||
}
|
||||
freeMem(url);
|
||||
return (JSec_Principal)principalUnit;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_AddPrincipal(JSec_Principal pr)
|
||||
{
|
||||
if ((pr == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
if (RDF_HasAssertion(gJSecDB, pr, gNavCenter->RDF_JSecPrincipal, gNavCenter->RDF_JSec,
|
||||
RDF_RESOURCE_TYPE, PR_FALSE)) {
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
setContainerp(pr, PR_TRUE);
|
||||
setResourceType(pr, JSEC_RT);
|
||||
RDF_Assert(gJSecDB, pr, gNavCenter->RDF_JSecPrincipal, gNavCenter->RDF_JSec, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_DeletePrincipal(JSec_Principal pr)
|
||||
{
|
||||
RDF_Cursor c;
|
||||
if ((pr == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
/* Before deleting the principal, delete all the PrincipalUses for this principal.
|
||||
*/
|
||||
c = RDFJSec_ListAllPrincipalUses(pr);
|
||||
if (c != NULL) {
|
||||
JSec_PrincipalUse prUse;
|
||||
while ((prUse = RDFJSec_NextPrincipalUse(c)) != NULL) {
|
||||
RDFJSec_DeletePrincipalUse(pr, prUse);
|
||||
}
|
||||
}
|
||||
RDF_Unassert(gJSecDB, pr, gNavCenter->RDF_JSecPrincipal, gNavCenter->RDF_JSec, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
char *
|
||||
RDFJSec_PrincipalID(JSec_Principal pr)
|
||||
{
|
||||
char *url = resourceID(pr);
|
||||
char *ans = getMem(RDF_STRLEN(url)+1);
|
||||
int n;
|
||||
if (ans == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
n = charSearch(':', url);
|
||||
if (n == -1) {
|
||||
strcpy(ans, url);
|
||||
} else {
|
||||
strcpy(ans, url+n+1);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
void *
|
||||
RDFJSec_AttributeOfPrincipal(JSec_Principal pr, char* attributeType)
|
||||
{
|
||||
RDF_Resource attributeResource = RDF_GetResource(NULL, attributeType, TRUE);
|
||||
void *attValue;
|
||||
RDF_Cursor c = NULL;
|
||||
c = RDF_GetTargets(gJSecDB, pr, attributeResource, RDF_STRING_TYPE, TRUE);
|
||||
if (c == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
attValue = RDF_NextValue(c);
|
||||
RDF_DisposeCursor(c);
|
||||
return attValue;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_SetPrincipalAttribute(JSec_Principal pr, char* attributeType, void* attValue)
|
||||
{
|
||||
RDF_Resource attributeResource = RDF_GetResource(NULL, attributeType, TRUE);
|
||||
RDF_Assert(gJSecDB, pr, attributeResource, attValue, RDF_STRING_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
RDFJSec_ListAllPrincipalUses(JSec_Principal pr)
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
c = RDF_GetSources(gJSecDB, (RDF_Resource)pr, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
|
||||
return(c);
|
||||
}
|
||||
|
||||
JSec_PrincipalUse
|
||||
RDFJSec_NextPrincipalUse(RDF_Cursor c)
|
||||
{
|
||||
if (c != NULL) {
|
||||
return RDF_NextValue(c);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSec_PrincipalUse
|
||||
RDFJSec_NewPrincipalUse(JSec_Principal pr, JSec_Target tr, char* priv)
|
||||
{
|
||||
RDF_Resource principalUseUnit;
|
||||
char *targetID = resourceID(tr);
|
||||
char *principalID = resourceID(pr);
|
||||
char *principalUseID = getMem(RDF_STRLEN(principalID) + strlen(targetID) + 2);
|
||||
if (principalUseID == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
sprintf(principalUseID, "%s!%s", principalID, targetID);
|
||||
principalUseUnit = RDF_GetResource(NULL, principalUseID, FALSE);
|
||||
if (!principalUseUnit) {
|
||||
principalUseUnit = RDF_GetResource(NULL, principalUseID, TRUE);
|
||||
RDFJSec_AddTargetToPrincipalUse(principalUseUnit, tr);
|
||||
RDFJSec_AddPrincipalUsePrivilege(principalUseUnit, priv);
|
||||
}
|
||||
return principalUseUnit;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_AddPrincipalUse(JSec_Principal pr, JSec_PrincipalUse prUse)
|
||||
{
|
||||
if ((pr == NULL) || (prUse == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
setContainerp(prUse, PR_TRUE);
|
||||
setResourceType(prUse, JSEC_RT);
|
||||
RDF_Assert(gJSecDB, prUse, gCoreVocab->RDF_parent, pr, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_DeletePrincipalUse (JSec_Principal pr, JSec_PrincipalUse prUse)
|
||||
{
|
||||
JSec_Target tr;
|
||||
char *priv;
|
||||
if ((pr == NULL) || (prUse == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
/* Before deleting the principal, delete all the PrincipalUses for this principal.
|
||||
*/
|
||||
tr = RDFJSec_TargetOfPrincipalUse(prUse);
|
||||
RDFJSec_DeleteTargetToPrincipalUse(prUse, tr);
|
||||
priv = RDFJSec_PrivilegeOfPrincipalUse(prUse);
|
||||
RDFJSec_DeletePrincipalUsePrivilege(prUse, priv);
|
||||
RDF_Unassert(gJSecDB, prUse, gCoreVocab->RDF_parent, pr, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
const char *
|
||||
RDFJSec_PrincipalUseID(JSec_PrincipalUse prUse)
|
||||
{
|
||||
return resourceID(prUse);
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_AddPrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv)
|
||||
{
|
||||
char *oldPriv;
|
||||
if ((prUse == NULL) || (priv == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
/* Each PrincipalUse can only have one Privilege. Thus delete the old privilege*/
|
||||
oldPriv = RDFJSec_PrivilegeOfPrincipalUse(prUse);
|
||||
RDFJSec_DeletePrincipalUsePrivilege(prUse, oldPriv);
|
||||
RDF_Assert(gJSecDB, prUse, gNavCenter->RDF_JSecAccess, priv, RDF_STRING_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_DeletePrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv)
|
||||
{
|
||||
if ((prUse == NULL) || (priv == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
RDF_Unassert(gJSecDB, prUse, gNavCenter->RDF_JSecAccess, priv, RDF_STRING_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
char *
|
||||
RDFJSec_PrivilegeOfPrincipalUse (JSec_PrincipalUse prUse)
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
char *privilege;
|
||||
if (gNavCenter == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
c = RDF_GetTargets(gJSecDB, (RDF_Resource)prUse, gNavCenter->RDF_JSecAccess, RDF_STRING_TYPE, TRUE);
|
||||
if (c == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
privilege = RDF_NextValue(c);
|
||||
RDF_DisposeCursor(c);
|
||||
return privilege;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_AddTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr)
|
||||
{
|
||||
JSec_Target oldTarget;
|
||||
if ((prUse == NULL) || (tr == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
/* Each PrincipalUse can only have one Target. Thus delete the old target */
|
||||
oldTarget = RDFJSec_TargetOfPrincipalUse(prUse);
|
||||
RDFJSec_DeleteTargetToPrincipalUse(prUse, oldTarget);
|
||||
RDF_Assert(gJSecDB, prUse, gNavCenter->RDF_JSecTarget, tr, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_DeleteTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr)
|
||||
{
|
||||
if ((prUse == NULL) || (tr == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
RDF_Unassert(gJSecDB, prUse, gNavCenter->RDF_JSecTarget, tr, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Target
|
||||
RDFJSec_TargetOfPrincipalUse (JSec_PrincipalUse prUse)
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
JSec_Target tr;
|
||||
if ((prUse == NULL) || (gNavCenter == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
c = RDF_GetTargets(gJSecDB, (RDF_Resource)prUse, gNavCenter->RDF_JSecTarget, RDF_RESOURCE_TYPE, true);
|
||||
if (c == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
tr = RDF_NextValue(c);
|
||||
RDF_DisposeCursor(c);
|
||||
return tr;
|
||||
}
|
||||
|
||||
JSec_Target
|
||||
RDFJSec_NewTarget(char* targetName, JSec_Principal pr)
|
||||
{
|
||||
RDF_Resource tr;
|
||||
/* RDF_Resource prResource; */
|
||||
char *principalID = RDFJSec_PrincipalID(pr);
|
||||
char *targetID = getMem(RDF_STRLEN(targetName) + strlen(principalID) + 2);
|
||||
if (targetID == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (gNavCenter == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sprintf(targetID, "%s!%s", targetName, principalID);
|
||||
tr = RDF_GetResource(NULL, targetID, FALSE);
|
||||
if (!tr) {
|
||||
tr = RDF_GetResource(NULL, targetID, TRUE);
|
||||
if (tr == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
RDFJSec_SetTargetAttribute(tr, "targetName", targetName);
|
||||
RDF_Assert(gJSecDB, tr, gNavCenter->RDF_JSecPrincipal, pr, RDF_RESOURCE_TYPE);
|
||||
}
|
||||
return tr;
|
||||
}
|
||||
|
||||
char *
|
||||
RDFJSec_GetTargetName(JSec_Target tr)
|
||||
{
|
||||
return RDFJSec_AttributeOfTarget(tr, "targetName");
|
||||
}
|
||||
|
||||
char *
|
||||
RDFJSec_AttributeOfTarget(JSec_Target tr, char* attributeType)
|
||||
{
|
||||
RDF_Resource attributeResource = RDF_GetResource(NULL, attributeType, TRUE);
|
||||
char *attValue;
|
||||
RDF_Cursor c = NULL;
|
||||
c = RDF_GetTargets(gJSecDB, tr, attributeResource, RDF_STRING_TYPE, TRUE);
|
||||
if (c == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
attValue = RDF_NextValue(c);
|
||||
RDF_DisposeCursor(c);
|
||||
return attValue;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_SetTargetAttribute(JSec_Target tr, char* attributeType, char* attValue)
|
||||
{
|
||||
RDF_Resource attributeResource = RDF_GetResource(NULL, attributeType, TRUE);
|
||||
RDF_Assert(gJSecDB, tr, attributeResource, attValue, RDF_STRING_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
562
mozilla/modules/rdf/src/ldap2rdf.c
Normal file
@@ -0,0 +1,562 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements LDAP support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
/*
|
||||
XXX Someone needs to get this up to speed again
|
||||
*/
|
||||
#if 0
|
||||
#ifdef MOZ_LDAP
|
||||
|
||||
#include "ldap2rdf.h"
|
||||
#include "utils.h"
|
||||
|
||||
/* statics */
|
||||
static PRHashTable *ldap2rdfHash;
|
||||
static PRHashTable *invldap2rdfHash;
|
||||
static RDFT gRDFDB;
|
||||
static PRBool ldap2rdfInitedp = 0;
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeLdapStore (char* url)
|
||||
{
|
||||
RDFT ntr = (RDFT)getMem(sizeof(RDF_TranslatorStruct));
|
||||
ntr->assert = ldapAssert;
|
||||
ntr->unassert = ldapUnassert;
|
||||
ntr->getSlotValue = ldapGetSlotValue;
|
||||
ntr->getSlotValues = ldapGetSlotValues;
|
||||
ntr->hasAssertion = ldapHasAssertion;
|
||||
ntr->nextValue = ldapNextValue;
|
||||
ntr->disposeCursor = ldapDisposeCursor;
|
||||
ldap2rdfInit(ntr);
|
||||
return ntr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
LdapInit (RDFT ntr)
|
||||
{
|
||||
ntr->assert = ldapAssert;
|
||||
ntr->unassert = ldapUnassert;
|
||||
ntr->getSlotValue = ldapGetSlotValue;
|
||||
ntr->getSlotValues = ldapGetSlotValues;
|
||||
ntr->hasAssertion = ldapHasAssertion;
|
||||
ntr->nextValue = ldapNextValue;
|
||||
ntr->disposeCursor = ldapDisposeCursor;
|
||||
ldap2rdfInit(ntr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ldap2rdfInit (RDFT rdf)
|
||||
{
|
||||
if (!ldap2rdfInitedp) {
|
||||
ldap2rdfHash = PR_NewHashTable(500, idenHash, idenEqual, idenEqual, null, null);
|
||||
invldap2rdfHash = PR_NewHashTable(500, idenHash, idenEqual, idenEqual, null, null);
|
||||
gRDFDB = rdf;
|
||||
ldap2rdfInitedp = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
ldaparg1 (RDF_Resource u)
|
||||
{
|
||||
return (Assertion) PR_HashTableLookup(ldap2rdfHash, u);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
setldaparg1 (RDF_Resource u, Assertion as)
|
||||
{
|
||||
return (Assertion) PR_HashTableAdd(ldap2rdfHash, u, as);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
ldaparg2 (RDF_Resource u)
|
||||
{
|
||||
return (Assertion) PR_HashTableLookup(invldap2rdfHash, u);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
setldaparg2 (RDF_Resource u, Assertion as)
|
||||
{
|
||||
return (Assertion) PR_HashTableAdd(invldap2rdfHash, u, as);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v));
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE) &&
|
||||
(tv) && (ldapContainerp(v))) {
|
||||
return (ldapAddChild(rdf, (RDF_Resource)v, u));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE) &&
|
||||
(ldapContainerp(v))) {
|
||||
return (ldapRemoveChild(rdf, (RDF_Resource)v, u));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapDBAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
Assertion nextAs, prevAs, newAs;
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if ((s == gCoreVocab->RDF_instanceOf) && (v == gWebData->RDF_Container)) {
|
||||
setContainerp(u, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
nextAs = prevAs = ldaparg1(u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type)) return 1;
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
newAs = makeNewAssertion(u, s, v, type, 1);
|
||||
if (prevAs == null) {
|
||||
setldaparg1(u, newAs);
|
||||
} else {
|
||||
prevAs->next = newAs;
|
||||
}
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
nextAs = prevAs = ldaparg2((RDF_Resource)v);
|
||||
while (nextAs != null) {
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
if (prevAs == null) {
|
||||
setldaparg2((RDF_Resource)v, newAs);
|
||||
} else {
|
||||
prevAs->invNext = newAs;
|
||||
}
|
||||
}
|
||||
sendNotifications2(rdf, RDF_ASSERT_NOTIFY, u, s, v, type, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapDBRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
Assertion nextAs, prevAs, ans;
|
||||
PRBool found = false;
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
nextAs = prevAs = ldaparg1(u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type)) {
|
||||
if (prevAs == null) {
|
||||
setldaparg1(u, nextAs->next);
|
||||
} else {
|
||||
prevAs->next = nextAs->next;
|
||||
}
|
||||
found = true;
|
||||
ans = nextAs;
|
||||
break;
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
if (found == false) return false;
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
nextAs = prevAs = ldaparg2((RDF_Resource)v);
|
||||
while (nextAs != null) {
|
||||
if (nextAs == ans) {
|
||||
if (prevAs == nextAs) {
|
||||
setldaparg2((RDF_Resource)v, nextAs->invNext);
|
||||
} else {
|
||||
prevAs->invNext = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
sendNotifications2(rdf, RDF_DELETE_NOTIFY, u, s, v, type, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
|
||||
nextAs = ldaparg1(u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type) && (nextAs->tv == tv)) return true;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
|
||||
possiblyAccessldap(rdf, u, s, false);
|
||||
|
||||
nextAs = ldaparg1(u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type) && (nextAs->tv == tv)) return true;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
ldapGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
|
||||
nextAs = (inversep ? ldaparg2(u) : ldaparg1(u));
|
||||
while (nextAs != null) {
|
||||
if ((nextAs->s == s) && (nextAs->tv == tv) && (nextAs->type == type)) {
|
||||
void * retVal = (inversep ? nextAs->u : nextAs->value);
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )retVal)));
|
||||
return retVal
|
||||
}
|
||||
nextAs = (inversep ? nextAs->invNext : nextAs->next);
|
||||
}
|
||||
|
||||
possiblyAccessldap(rdf, u, s, inversep);
|
||||
|
||||
nextAs = (inversep ? ldaparg2(u) : ldaparg1(u));
|
||||
while (nextAs != null) {
|
||||
if ((nextAs->s == s) && (nextAs->tv == tv) && (nextAs->type == type)) {
|
||||
void * retVal = (inversep ? nextAs->u : nextAs->value);
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )retVal)));
|
||||
return retVal
|
||||
}
|
||||
nextAs = (inversep ? nextAs->invNext : nextAs->next);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
ldapGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
Assertion as;
|
||||
RDF_Cursor c;
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
as = (inversep ? ldaparg2(u) : ldaparg1(u));
|
||||
if (as == null) {
|
||||
possiblyAccessldap(rdf, u, s, inversep);
|
||||
as = (inversep ? ldaparg2(u) : ldaparg1(u));
|
||||
if (as == null)
|
||||
return null;
|
||||
}
|
||||
c = (RDF_CursorStruc*)getMem(sizeof(RDF_CursorStruc));
|
||||
c->u = u;
|
||||
c->s = s;
|
||||
c->type = type;
|
||||
c->inversep = inversep;
|
||||
c->tv = tv;
|
||||
c->count = 0;
|
||||
c->pdata = as;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
ldapNextValue (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
while (c->pdata != null) {
|
||||
Assertion as = (Assertion) c->pdata;
|
||||
if ((as->s == c->s) && (as->tv == c->tv) && (c->type == as->type)) {
|
||||
c->value = (c->inversep ? as->u : as->value);
|
||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
||||
return c->value;
|
||||
}
|
||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
ldapDisposeCursor (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
freeMem(c);
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
ldapNewContainer(char *id)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
ldapModifyEntry (RDFT rdf, RDF_Resource parent, RDF_Resource child, PRBool addFlag)
|
||||
{
|
||||
RDF_Cursor c;
|
||||
RDF_Resource newParent, r;
|
||||
char *urivals[2];
|
||||
LDAP *ld;
|
||||
LDAPMod urimod, *mods[2];
|
||||
LDAPURLDesc *ldURL=NULL;
|
||||
int err;
|
||||
char *errStr, *parentID;
|
||||
|
||||
parentID = resourceID(parent);
|
||||
|
||||
if (containerp(child))
|
||||
{
|
||||
if (newParent = ldapNewContainer(parentID))
|
||||
{
|
||||
if ((c = RDF_GetSources(rdf->rdf->rdf, child,
|
||||
gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, 1)) != NULL)
|
||||
{
|
||||
while ((r = RDF_NextValue(c)) != NULL)
|
||||
{
|
||||
err = ldapModifyEntry(rdf, newParent, r, addFlag);
|
||||
if (err)
|
||||
{
|
||||
/* XXX MAJOR rollback issues!
|
||||
Punt for now! */
|
||||
|
||||
return(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
ldap_url_parse(parentID, &ldURL);
|
||||
if (ldURL == NULL) return(-1);
|
||||
ld = ldap_init (ldURL->lud_host, ldURL->lud_port);
|
||||
if (ld == NULL)
|
||||
{
|
||||
ldap_free_urldesc(ldURL);
|
||||
return(-1);
|
||||
}
|
||||
if ((err = ldap_simple_bind_s(ld, ADMIN_ID, ADMIN_PW)) /* XXX */
|
||||
!= LDAP_SUCCESS)
|
||||
{
|
||||
if ((errStr = ldap_err2string(err)) != NULL)
|
||||
{
|
||||
/* We need to change XP_MakeHTMLAlert to use UTF8 */
|
||||
XP_MakeHTMLAlert(NULL, errStr);
|
||||
}
|
||||
|
||||
ldap_unbind(ld);
|
||||
ldap_free_urldesc(ldURL);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
urivals[0] = resourceID(child);
|
||||
urivals[1] = NULL;
|
||||
|
||||
urimod.mod_op = ((addFlag == true) ? LDAP_MOD_ADD : LDAP_MOD_DELETE);
|
||||
urimod.mod_type = "labeledURI";
|
||||
urimod.mod_values = urivals;
|
||||
|
||||
mods[0] = &urimod;
|
||||
mods[1] = NULL;
|
||||
|
||||
err = ldap_modify_s(ld, ldURL->lud_dn, mods);
|
||||
if (err != LDAP_SUCCESS)
|
||||
{
|
||||
if ((errStr = ldap_err2string(err)) != NULL)
|
||||
{
|
||||
/* We need to change XP_MakeHTMLAlert to use UTF8 */
|
||||
XP_MakeHTMLAlert(NULL, errStr);
|
||||
}
|
||||
}
|
||||
|
||||
ldap_unbind(ld);
|
||||
ldap_free_urldesc(ldURL);
|
||||
return(err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapAddChild (RDFT rdf, RDF_Resource parent, RDF_Resource child)
|
||||
{
|
||||
return (ldapModifyEntry(rdf, parent, child, true) != LDAP_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapRemoveChild (RDFT rdf, RDF_Resource parent, RDF_Resource child)
|
||||
{
|
||||
return (ldapModifyEntry(rdf, parent, child, false) != LDAP_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
possiblyAccessldap(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
/** try to get the values of u.s from the directory **/
|
||||
|
||||
LDAP *ld;
|
||||
LDAPMessage *result=NULL, *entry;
|
||||
LDAPURLDesc *ldURL=NULL;
|
||||
RDF_Resource node;
|
||||
char *attrs[2], **vals;
|
||||
int err, i;
|
||||
char *title = NULL;
|
||||
|
||||
/*
|
||||
Note: a labeledURI is a url followed by an optional [space title-string]
|
||||
*/
|
||||
|
||||
if (!stringEquals(resourceID(s), resourceID(gCoreVocab->RDF_parent)) || (!inversep) || (!ldap_is_ldap_url(resourceID(u)))) return;
|
||||
|
||||
ldap_url_parse(resourceID(u), &ldURL);
|
||||
if (ldURL == NULL) return;
|
||||
ld = ldap_init (ldURL->lud_host, ldURL->lud_port);
|
||||
if (ld == NULL)
|
||||
{
|
||||
ldap_free_urldesc(ldURL);
|
||||
return;
|
||||
}
|
||||
if ((err = ldap_simple_bind_s(ld, NULL, NULL)) != LDAP_SUCCESS)
|
||||
{
|
||||
ldap_unbind(ld);
|
||||
ldap_free_urldesc(ldURL);
|
||||
return;
|
||||
}
|
||||
|
||||
attrs[0] = "labeledURI";
|
||||
attrs[1] = NULL;
|
||||
|
||||
err = ldap_search_s(ld, ldURL->lud_dn, LDAP_SCOPE_BASE, ldURL->lud_filter, attrs, 0, &result);
|
||||
if (err == LDAP_SUCCESS)
|
||||
{
|
||||
for (entry=ldap_first_entry(ld, result); entry!=NULL; entry=ldap_next_entry(ld, entry))
|
||||
{
|
||||
if ((vals = ldap_get_values(ld, entry, attrs[0])) != NULL)
|
||||
{
|
||||
for (i=0; vals[i] != NULL; i++)
|
||||
{
|
||||
/* vals[i] has a URL... add into RDF graph */
|
||||
|
||||
/*
|
||||
if (((title = strstr(vals[i], " ")) != NULL)
|
||||
&& (*(title+1) != '\0'))
|
||||
{
|
||||
*(++title) = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
title = NULL;
|
||||
}
|
||||
*/
|
||||
if ((node = RDF_Create(vals[i], true)) != NULL)
|
||||
{
|
||||
setResourceType(node, LDAP_RT);
|
||||
if (ldapContainerp(node) == true)
|
||||
{
|
||||
setContainerp(node, 1);
|
||||
}
|
||||
|
||||
ldapDBAdd(rdf, node, gCoreVocab->RDF_parent,
|
||||
u, RDF_RESOURCE_TYPE);
|
||||
|
||||
if (title != NULL)
|
||||
{
|
||||
ldapDBAdd(rdf, node, gCoreVocab->RDF_name,
|
||||
title, RDF_STRING_TYPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
ldap_value_free(vals);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result != NULL)
|
||||
{
|
||||
ldap_msgfree(result);
|
||||
}
|
||||
ldap_unbind(ld);
|
||||
ldap_free_urldesc(ldURL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapContainerp (RDF_Resource u)
|
||||
{
|
||||
return(ldap_is_ldap_url(resourceID(u))); /* XXX ??? */
|
||||
}
|
||||
|
||||
|
||||
#endif /* MOZ_LDAP */
|
||||
#endif
|
||||
|
||||
69
mozilla/modules/rdf/src/ldap2rdf.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_LDAP2RDF_H_
|
||||
#define _RDF_LDAP2RDF_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
#ifdef MOZ_LDAP
|
||||
#include "ldap.h"
|
||||
#include "xpgetstr.h"
|
||||
#include "htmldlgs.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* ldap2rdf.c data structures and defines */
|
||||
|
||||
#define ADMIN_ID "uid=rjc, ou=People, o=airius.com"
|
||||
#define ADMIN_PW "netscape"
|
||||
|
||||
|
||||
|
||||
/* ldap2rdf.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
RDFT MakeLdapStore (char* url);
|
||||
RDF_Error LdapInit (RDFT ntr);
|
||||
void ldap2rdfInit (RDFT rdf);
|
||||
Assertion ldaparg1 (RDF_Resource u);
|
||||
Assertion setldaparg1 (RDF_Resource u, Assertion as);
|
||||
Assertion ldaparg2 (RDF_Resource u);
|
||||
Assertion setldaparg2 (RDF_Resource u, Assertion as);
|
||||
PRBool ldapAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool ldapUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool ldapDBAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool ldapDBRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool ldapHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
void * ldapGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor ldapGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * ldapNextValue (RDFT mcf, RDF_Cursor c);
|
||||
RDF_Error ldapDisposeCursor (RDFT mcf, RDF_Cursor c);
|
||||
RDF_Resource ldapNewContainer(char *id);
|
||||
int ldapModifyEntry (RDFT rdf, RDF_Resource parent, RDF_Resource child, PRBool addFlag);
|
||||
PRBool ldapAddChild (RDFT rdf, RDF_Resource parent, RDF_Resource child);
|
||||
PRBool ldapRemoveChild (RDFT rdf, RDF_Resource parent, RDF_Resource child);
|
||||
void possiblyAccessldap(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
PRBool ldapContainerp (RDF_Resource u);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
52
mozilla/modules/rdf/src/makefile.win
Normal file
@@ -0,0 +1,52 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
DEPTH = ..\..\..
|
||||
LIBRARY_SUFFIX=$(MOZ_BITS)
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
MODULE=rdf
|
||||
LIBRARY_NAME=rdf
|
||||
REQUIRES=nspr
|
||||
|
||||
C_OBJS=.\$(OBJDIR)\vocab.obj \
|
||||
.\$(OBJDIR)\mcf.obj \
|
||||
.\$(OBJDIR)\remstore.obj \
|
||||
.\$(OBJDIR)\utils.obj \
|
||||
.\$(OBJDIR)\rdfparse.obj \
|
||||
.\$(OBJDIR)\bmk2mcf.obj \
|
||||
.\$(OBJDIR)\columns.obj \
|
||||
.\$(OBJDIR)\rdfht.obj \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\comwrap.obj \
|
||||
.\$(OBJDIR)\netglue.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(XPDIST)\public\xpcom
|
||||
LINCS=$(LINCS) -I$(PUBLIC)\rdf
|
||||
LINCS=$(LINCS) -I$(PUBLIC)\netlib -I$(PUBLIC)\raptor
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
|
||||
|
||||
|
||||
1125
mozilla/modules/rdf/src/mcf.c
Normal file
93
mozilla/modules/rdf/src/mcf.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_MCF_H_
|
||||
#define _RDF_MCF_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "prprf.h"
|
||||
#include "prtime.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* mcf.c data structures and defines */
|
||||
|
||||
struct RDF_NotificationStruct {
|
||||
RDF_Event theEvent;
|
||||
void* pdata;
|
||||
RDF_NotificationProc notifFunction;
|
||||
RDF rdf;
|
||||
struct RDF_NotificationStruct* next;
|
||||
};
|
||||
|
||||
|
||||
#define ntr(r, n) (*((RDFT*)r->translators + n))
|
||||
#define ntrn(r, n) (*((RDFT*)r->translators + n) == NULL)
|
||||
#define callAssert(n, r, u, s, v,type,tv) (ntrn(r, n) || (ntr(r, n)->assert == NULL) ? 0 : (*(ntr(r, n)->assert))(ntr(r, n), u, s, v, type, tv))
|
||||
#define callUnassert(n, r, u, s, v,type) (ntrn(r, n) || (ntr(r, n)->unassert == NULL) ? 0 : (*(ntr(r, n)->unassert))(ntr(r, n), u, s, v, type))
|
||||
#define callGetSlotValue(n, r, u, s, type, invp, tv) (ntrn(r, n) || (ntr(r, n)->getSlotValue == NULL) ? 0 : (*(ntr(r, n)->getSlotValue))(ntr(r, n), u, s, type, invp, tv))
|
||||
#define callGetSlotValues(n, r, u, s, type,invp, tv) (ntrn(r, n) || (ntr(r, n)->getSlotValues == NULL) ? 0 : (*(ntr(r, n)->getSlotValues))(ntr(r, n), u, s, type,invp, tv))
|
||||
#define callHasAssertions(n, r, u, s, v,type,tv) (ntrn(r, n) || (ntr(r, n)->hasAssertion == NULL) ? 0 : (*(ntr(r, n)->hasAssertion))(ntr(r, n), u, s, v, type, tv))
|
||||
#define callArcLabelsOut(n, r, u) (ntrn(r, n) || (ntr(r, n)->arcLabelsOut == NULL) ? 0 : (*(ntr(r, n)->arcLabelsOut))(ntr(r, n), u))
|
||||
#define callArcLabelsIn(n, r, u) (ntrn(r, n) || (ntr(r, n)->arcLabelsIn == NULL) ? 0 : (*(ntr(r, n)->arcLabelsIn))(ntr(r, n), u))
|
||||
#define callDisposeResource(n, r, u) (ntrn(r, n) || (ntr(r, n)->disposeResource == NULL) ? 1 : (*(ntr(r, n)->disposeResource))(ntr(r, n), u))
|
||||
#define callExitRoutine(n, r) (ntrn(r, n) || (ntr(r, n)->destroy == NULL) ? 0 : (*(ntr(r, n)->destroy))(ntr(r, n)))
|
||||
#define callUpdateRoutine(n, r, u) (ntrn(r, n) || (ntr(r, n)->update == NULL) ? 0 : (*(ntr(r, n)->update))(ntr(r, n), u))
|
||||
|
||||
#define ID_BUF_SIZE 20
|
||||
|
||||
|
||||
|
||||
/* mcf.c function prototypes */
|
||||
|
||||
|
||||
|
||||
RDFT getTranslator (char* url);
|
||||
RDFL deleteFromRDFList (RDFL xrl, RDF db);
|
||||
RDF_Error exitRDF (RDF rdf);
|
||||
RDF_Resource addDep (RDF db, RDF_Resource u);
|
||||
PRBool rdfassert(RDF rdf, RDF_Resource u, RDF_Resource s, void* value, RDF_ValueType type, PRBool tv);
|
||||
PRBool containerIDp(char* id);
|
||||
char * makeNewID ();
|
||||
PRBool iscontainerp (RDF_Resource u);
|
||||
RDF_BT resourceTypeFromID (char* id);
|
||||
RDF_Resource specialUrlResource (char* id);
|
||||
RDF_Resource NewRDFResource (char* id);
|
||||
RDF_Resource QuickGetResource (char* id);
|
||||
RDF_Cursor getSlotValues (RDF rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void disposeResourceInt (RDF rdf, RDF_Resource u);
|
||||
void possiblyGCResource (RDF_Resource u);
|
||||
RDF_Resource NewRDFResource (char* id);
|
||||
RDF_Resource QuickGetResource (char* id);
|
||||
void assertNotify (RDF rdf, RDF_Notification not, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv, char* ds);
|
||||
void insertNotify (RDF rdf, RDF_Notification not, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv, char* ds);
|
||||
void unassertNotify (RDF_Notification not, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, char* ds);
|
||||
void sendNotifications1 (RDFL rl, RDF_EventType opType, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
void sendNotifications (RDF rdf, RDF_EventType opType, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv, char* ds);
|
||||
RDF_Resource nextFindValue (RDF_Cursor c);
|
||||
PRBool matchStrings(RDF_Resource match, char *str1, char *str2);
|
||||
PRBool itemMatchesFind (RDF r, RDF_Resource u, RDF_Resource s, void* v, RDF_Resource match, RDF_ValueType type);
|
||||
PR_PUBLIC_API(RDF_Cursor)RDF_Find (RDF_Resource s, RDF_Resource match, void* v, RDF_ValueType type);
|
||||
PRIntn findEnumerator (PLHashEntry *he, PRIntn i, void *arg);
|
||||
void disposeAllDBs ();
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
374
mozilla/modules/rdf/src/mcff2mcf.c
Normal file
@@ -0,0 +1,374 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "mcff2mcf.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
|
||||
int
|
||||
parseNextMCFBlob(NET_StreamClass *stream, char* blob, int32 size)
|
||||
{
|
||||
RDFFile f;
|
||||
int32 n, last, m;
|
||||
n = last = 0;
|
||||
|
||||
f = (RDFFile)stream->data_object;
|
||||
if ((f == NULL) || (size < 0)) {
|
||||
return MK_INTERRUPTED;
|
||||
}
|
||||
|
||||
while (n < size) {
|
||||
char c = blob[n];
|
||||
m = 0;
|
||||
memset(f->line, '\0', f->lineSize);
|
||||
if (f->holdOver[0] != '\0') {
|
||||
memcpy(f->line, f->holdOver, RDF_STRLEN(f->holdOver));
|
||||
m = RDF_STRLEN(f->holdOver);
|
||||
memset(f->holdOver, '\0', RDF_BUF_SIZE);
|
||||
}
|
||||
while ((m < f->lineSize) && (c != '\r') && (c != '\n') && (n < size)) {
|
||||
f->line[m] = c;
|
||||
m++;
|
||||
n++;
|
||||
c = blob[n];
|
||||
}
|
||||
n++;
|
||||
if (m > 0) {
|
||||
if ((c == '\n') || (c == '\r')) {
|
||||
last = n;
|
||||
parseNextMCFLine(f, f->line);
|
||||
} else if (size > last) {
|
||||
memcpy(f->holdOver, f->line, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
parseNextMCFLine (RDFFile f, char* line)
|
||||
{
|
||||
char* nextToken ;
|
||||
int16 offset = 0;
|
||||
RDF_Error err;
|
||||
|
||||
if ((nullp(line)) || (line[0] == '\0'))return;
|
||||
nextToken = getMem(MAX_URL_SIZE);
|
||||
err = getFirstToken(line, nextToken, &offset);
|
||||
|
||||
offset++;
|
||||
if ((err != noRDFErr) && (nextToken[0] == ';')) {
|
||||
freeMem(nextToken);
|
||||
return;
|
||||
}
|
||||
if (startsWith("begin-headers", nextToken)) {
|
||||
f->status = HEADERS;
|
||||
} else if (startsWith("end-headers", nextToken)) {
|
||||
f->status = BODY;
|
||||
} else if (startsWith("unit", nextToken)) {
|
||||
f->status = BODY;
|
||||
if (!(nullp(f->currentResource))) resourceTransition(f);
|
||||
getFirstToken(&line[offset], nextToken, &offset);
|
||||
f->currentResource = resolveReference(nextToken, f);
|
||||
} else if (nextToken[RDF_STRLEN(nextToken)-1] == ':') {
|
||||
memset(f->currentSlot, '\0', 100);
|
||||
memcpy(f->currentSlot, nextToken, RDF_STRLEN(nextToken)-1);
|
||||
while (getFirstToken(&line[offset], nextToken, &offset) == noRDFErr) {
|
||||
if (f->status == HEADERS) {
|
||||
assignHeaderSlot(f, f->currentSlot, nextToken);
|
||||
} else if (f->currentResource) {
|
||||
assignSlot(f->currentResource, f->currentSlot, nextToken, f);
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
freeMem(nextToken);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
finishMCFParse (RDFFile f)
|
||||
{
|
||||
parseNextMCFLine(f, f->storeAway);
|
||||
resourceTransition(f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
resourceTransition (RDFFile f)
|
||||
{
|
||||
if ((f->currentResource) && (!f->genlAdded))
|
||||
addSlotValue(f, f->currentResource, gCoreVocab->RDF_parent, f->rtop,
|
||||
RDF_RESOURCE_TYPE, NULL);
|
||||
f->genlAdded = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
assignHeaderSlot (RDFFile f, char* slot, char* value)
|
||||
{
|
||||
if (startsWith(slot, "expiresOn")) {
|
||||
if (f->expiryTime == NULL) f->expiryTime = (PRTime*)getMem(sizeof(PRTime));
|
||||
if (PR_ParseTimeString (value, 0, f->expiryTime) != PR_SUCCESS) {
|
||||
freeMem(f->expiryTime);
|
||||
f->expiryTime = NULL;
|
||||
}
|
||||
} else if (!(startsWith(slot, "RDFVersion"))) {
|
||||
assignSlot(f->top, slot, value, f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
getFirstToken (char* line, char* nextToken, int16* l)
|
||||
{
|
||||
PRBool in_paren = 0;
|
||||
PRBool in_string = 0;
|
||||
PRBool in_bracket = 0;
|
||||
PRBool something_seen = 0;
|
||||
uint16 front_spaces = 0;
|
||||
uint16 index;
|
||||
RDF_Error ans = -1;
|
||||
|
||||
memset(nextToken, '\0', 200);
|
||||
|
||||
for (index = 0; index < RDF_STRLEN(line); index++) {
|
||||
char c = line[index];
|
||||
|
||||
if ((c == '\n') || (c == '\0') || (c == '\r')) {
|
||||
*l = index + *l ;
|
||||
return ans;
|
||||
}
|
||||
|
||||
if ((c == ':') && ((index == 0) || (line[index-1] == ' ')) &&
|
||||
((line[index+1] == ' ') || (line[index+1] == '\0'))) c = ' ';
|
||||
|
||||
if (c != ' ') something_seen = 1;
|
||||
|
||||
if (in_paren) {
|
||||
if (c == ')') {
|
||||
nextToken[index-front_spaces] = c;
|
||||
ans = noRDFErr;
|
||||
*l = index + *l ;
|
||||
return ans;
|
||||
} else {
|
||||
ans = noRDFErr;
|
||||
nextToken[index-front_spaces] = c;
|
||||
}
|
||||
} else if (in_string) {
|
||||
if (c == '"') {
|
||||
nextToken[index-front_spaces] = c;
|
||||
ans = noRDFErr;
|
||||
*l = index + *l ;
|
||||
return ans;
|
||||
} else {
|
||||
ans = noRDFErr;
|
||||
nextToken[index-front_spaces] = c;
|
||||
}
|
||||
} else if (in_bracket) {
|
||||
if (c == ']') {
|
||||
nextToken[index-front_spaces] = c;
|
||||
*l = index + *l ;
|
||||
ans = noRDFErr;
|
||||
return ans;
|
||||
} else {
|
||||
ans = noRDFErr;
|
||||
nextToken[index-front_spaces] = c;
|
||||
}
|
||||
} else if (c == '"') {
|
||||
ans = noRDFErr;
|
||||
nextToken[index-front_spaces] = c;
|
||||
in_string = 1;
|
||||
} else if (c == '[') {
|
||||
ans = noRDFErr;
|
||||
nextToken[index-front_spaces] = c;
|
||||
in_bracket = 1;
|
||||
} else if (c == '(') {
|
||||
ans = noRDFErr;
|
||||
nextToken[index-front_spaces] = c;
|
||||
in_paren = 1;
|
||||
} else if (c == ' '){
|
||||
if (something_seen) {
|
||||
*l = index + *l ;
|
||||
return ans;
|
||||
} else {
|
||||
front_spaces++;
|
||||
}
|
||||
} else {
|
||||
ans = noRDFErr;
|
||||
nextToken[index-front_spaces] = c;
|
||||
}
|
||||
}
|
||||
*l = index + *l ;
|
||||
return ans;
|
||||
}
|
||||
|
||||
void
|
||||
assignSlot (RDF_Resource u, char* slot, char* value, RDFFile f)
|
||||
{
|
||||
PRBool tv = true;
|
||||
char* tvstr;
|
||||
if (value[0] == '(') {
|
||||
tv = false;
|
||||
value = &value[1];
|
||||
value[RDF_STRLEN(value)-1] = '\0';
|
||||
}
|
||||
|
||||
if (tv) {
|
||||
tvstr = "true";
|
||||
} else tvstr = "false";
|
||||
|
||||
if (startsWith("default_genl", slot)) return;
|
||||
|
||||
if (startsWith("name", slot) || (startsWith("local-name", slot))) {
|
||||
value[RDF_STRLEN(value)-1] = '\0';
|
||||
addSlotValue(f, u, gCoreVocab->RDF_name, copyString(&value[1]), RDF_STRING_TYPE, tvstr);
|
||||
} else if (startsWith("specs", slot) || (startsWith("child", slot))) {
|
||||
RDF_Resource spec = resolveReference(value, f);
|
||||
if (!nullp(spec)) addSlotValue(f, spec, gCoreVocab->RDF_parent, u, RDF_RESOURCE_TYPE, tvstr);
|
||||
} else if (startsWith("genls_pos", slot)) {
|
||||
RDF_Resource genl = resolveGenlPosReference(value, f);
|
||||
if (!nullp(genl)) addSlotValue(f, u, gCoreVocab->RDF_parent, genl, RDF_RESOURCE_TYPE, tvstr);
|
||||
} else if ((startsWith("genls", slot)) || (startsWith("parent", slot))) {
|
||||
RDF_Resource genl = resolveReference(value, f);
|
||||
if (!nullp(genl)) addSlotValue(f, u, gCoreVocab->RDF_parent, genl, RDF_RESOURCE_TYPE, tvstr);
|
||||
} else {
|
||||
void* parsed_value;
|
||||
RDF_ValueType data_type;
|
||||
RDF_Resource s = RDF_GetResource(NULL, slot, true);
|
||||
RDF_Error err = parseSlotValue(f, s, value, &parsed_value, &data_type);
|
||||
if ((err == noRDFErr) && (!nullp(parsed_value)))
|
||||
addSlotValue(f, u, s, parsed_value, data_type, tvstr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
parseSlotValue (RDFFile f, RDF_Resource s, char* value, void** parsed_value, RDF_ValueType* data_type)
|
||||
{
|
||||
if (value[0] == '"') {
|
||||
int32 size = RDF_STRLEN(value)-1;
|
||||
*parsed_value = getMem(size);
|
||||
value[size] = '\0';
|
||||
*parsed_value = &value[1];
|
||||
*data_type = RDF_STRING_TYPE;
|
||||
return noRDFErr;
|
||||
} else if (value[0] == '#') {
|
||||
if (value[1] == '"') {
|
||||
value[RDF_STRLEN(value)-1] = '\0';
|
||||
value = &value[2];
|
||||
} else {
|
||||
value = &value[1];
|
||||
}
|
||||
*parsed_value = resolveReference(value, f);
|
||||
return noRDFErr;
|
||||
} else if (charSearch('.', value) == -1) {
|
||||
int16 ans = 0;
|
||||
/* XXX sscanf(value, "%ld", &ans); */
|
||||
*data_type = RDF_INT_TYPE;
|
||||
return noRDFErr;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
derelativizeURL (char* tok, char* url, RDFFile f)
|
||||
{
|
||||
if ((tok[0] == '/') && (endsWith(".mco", tok))) {
|
||||
void stringAppendBase (char* dest, const char* addition) ;
|
||||
stringAppendBase(url, f->url);
|
||||
stringAppend(url, "#");
|
||||
stringAppend(url, tok);
|
||||
} else if ((endsWith(".mco", tok)) && (charSearch('#', tok) == -1)) {
|
||||
void stringAppendBase (char* dest, const char* addition) ;
|
||||
stringAppendBase(url, f->url);
|
||||
stringAppend(url, "#");
|
||||
stringAppend(url, tok);
|
||||
} else {
|
||||
memcpy(url, tok, RDF_STRLEN(tok));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
resolveReference (char *tok, RDFFile f)
|
||||
{
|
||||
RDF_Resource existing;
|
||||
char* url = getMem(MAX_URL_SIZE);
|
||||
if (tok[0] == '#') tok = &tok[1];
|
||||
if (tok[RDF_STRLEN(tok)-1] == '"') tok[strlen(tok)-1] = '\0';
|
||||
if (tok[0] == '"') tok = &tok[1];
|
||||
memset(url, '\0', 200);
|
||||
if (charSearch(':', tok) == -1) {
|
||||
derelativizeURL(tok, url, f);
|
||||
} else {
|
||||
memcpy(url, tok, RDF_STRLEN(tok));
|
||||
}
|
||||
if (RDF_STRCMP(url,"this") == 0) {
|
||||
existing = f->top;
|
||||
} else {
|
||||
existing = RDF_GetResource(NULL, url, false);
|
||||
}
|
||||
if (existing != null) return existing;
|
||||
existing = RDF_GetResource(NULL, url, true);
|
||||
addToResourceList(f, existing);
|
||||
freeMem(url);
|
||||
return existing;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
resolveGenlPosReference(char* tok, RDFFile f)
|
||||
{
|
||||
RDF_Resource ans;
|
||||
char* url = (char*)getMem(MAX_URL_SIZE);
|
||||
long i1, i2;
|
||||
i1 = charSearch('"', tok);
|
||||
i2 = revCharSearch('"', tok);
|
||||
memcpy(url, &tok[i1], i2-i1+1);
|
||||
ans = resolveReference(url, f);
|
||||
freeMem(url);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
getRelURL (RDF_Resource u, RDF_Resource top)
|
||||
{
|
||||
char* uID = resourceID(u);
|
||||
char* topID = resourceID(top);
|
||||
if (startsWith(topID, uID)) {
|
||||
int16 n = charSearch('#', uID);
|
||||
if (n == -1) return uID;
|
||||
return &(uID)[n+1];
|
||||
} else return uID;
|
||||
}
|
||||
61
mozilla/modules/rdf/src/mcff2mcf.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_MCFF2MCF_H_
|
||||
#define _RDF_MCFF2MCF_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
|
||||
|
||||
/* mcff2mcf.c data structures and defines */
|
||||
|
||||
|
||||
|
||||
|
||||
/* mcff2mcf.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
RDF_Resource getMCFFrtop (char* furl);
|
||||
RDFFile makeRDFFile (char* url, RDF_Resource top, PRBool localp);
|
||||
void initRDFFile (RDFFile ans);
|
||||
void finishRDFParse (RDFFile f);
|
||||
void abortRDFParse (RDFFile f);
|
||||
void addToResourceList (RDFFile f, RDF_Resource u);
|
||||
void addToAssertionList (RDFFile f, Assertion as);
|
||||
void parseNextRDFBlob (RDFFile f, char* blob, int32 size);
|
||||
int parseNextMCFBlob(NET_StreamClass *stream, char* blob, int32 size);
|
||||
void parseNextMCFLine (RDFFile f, char* line);
|
||||
void finishMCFParse (RDFFile f);
|
||||
void resourceTransition (RDFFile f);
|
||||
void assignHeaderSlot (RDFFile f, char* slot, char* value);
|
||||
RDF_Error getFirstToken (char* line, char* nextToken, int16* l);
|
||||
|
||||
void assignSlot (RDF_Resource u, char* slot, char* value, RDFFile f);
|
||||
RDF_Error parseSlotValue (RDFFile f, RDF_Resource s, char* value, void** parsed_value, RDF_ValueType* data_type);
|
||||
void derelativizeURL (char* tok, char* url, RDFFile f);
|
||||
RDF_Resource resolveReference (char *tok, RDFFile f);
|
||||
RDF_Resource resolveGenlPosReference(char* tok, RDFFile f);
|
||||
char * getRelURL (RDF_Resource u, RDF_Resource top);
|
||||
PRBool bookmarkSlotp (RDF_Resource s);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
165
mozilla/modules/rdf/src/netglue.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsString.h"
|
||||
#include "rdf-int.h"
|
||||
|
||||
class rdfStreamListener : public nsIStreamListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
rdfStreamListener(RDFFile);
|
||||
~rdfStreamListener();
|
||||
|
||||
NS_METHOD GetBindInfo(nsIURL* aURL);
|
||||
|
||||
NS_METHOD OnProgress(nsIURL* aURL, PRInt32 Progress, PRInt32 ProgressMax);
|
||||
|
||||
NS_METHOD OnStatus(nsIURL* aURL, const nsString& aMsg);
|
||||
|
||||
NS_METHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
|
||||
|
||||
NS_METHOD OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 length);
|
||||
|
||||
NS_METHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg);
|
||||
|
||||
protected:
|
||||
rdfStreamListener::rdfStreamListener();
|
||||
|
||||
private:
|
||||
RDFFile mFile;
|
||||
};
|
||||
|
||||
rdfStreamListener::rdfStreamListener(RDFFile f) : mFile(f)
|
||||
{
|
||||
}
|
||||
|
||||
rdfStreamListener::~rdfStreamListener()
|
||||
{
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfStreamListener::GetBindInfo(nsIURL* aURL)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfStreamListener::OnProgress(nsIURL* aURL,
|
||||
PRInt32 Progress,
|
||||
PRInt32 ProgressMax)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfStreamListener::OnStatus(nsIURL* aURL,
|
||||
const nsString& aMsg)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfStreamListener::OnStartBinding(nsIURL* aURL,
|
||||
const char *aContentType)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfStreamListener::OnDataAvailable(nsIURL* aURL,
|
||||
nsIInputStream *pIStream,
|
||||
PRInt32 length)
|
||||
{
|
||||
PRInt32 len;
|
||||
|
||||
// PRLOG(("\n+++ rdfStreamListener::OnDataAvailable: URL: %p, %d bytes available...\n", aURL, length));
|
||||
|
||||
do {
|
||||
const PRUint32 buffer_size = 80;
|
||||
char buffer[buffer_size];
|
||||
|
||||
nsresult err = pIStream->Read(buffer, 0, buffer_size, &len);
|
||||
if (err == NS_OK) {
|
||||
(void) parseNextRDFXMLBlobInt(mFile, buffer, len);
|
||||
} // else XXX ?
|
||||
} while (len > 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfStreamListener::OnStopBinding(nsIURL* aURL,
|
||||
PRInt32 status,
|
||||
const nsString& aMsg)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
switch( status ) {
|
||||
|
||||
case NS_BINDING_SUCCEEDED:
|
||||
finishRDFParse( mFile );
|
||||
break;
|
||||
|
||||
case NS_BINDING_FAILED:
|
||||
case NS_BINDING_ABORTED:
|
||||
abortRDFParse( mFile );
|
||||
// XXX status code?
|
||||
break;
|
||||
|
||||
default:
|
||||
PR_ASSERT(PR_FALSE);
|
||||
result = NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* beginReadingRDFFile is called whenever we need to read something of
|
||||
* the net (or local drive). The url of the file to be read is at
|
||||
* file->url. As the bits are read in (and it can take the bits in
|
||||
* any sized chunks) it should call parseNextRDFBlobInt(file, nextBlock,
|
||||
* blobSize) when its done, it should call void finishRDFParse
|
||||
* (RDFFile f) to abort, it should call void abortRDFParse (RDFFile f)
|
||||
* [which will undo all that has been read from that file]
|
||||
*/
|
||||
|
||||
void
|
||||
beginReadingRDFFile (RDFFile file)
|
||||
{
|
||||
rdfStreamListener* pListener = new rdfStreamListener(file);
|
||||
pListener->AddRef(); // XXX is this evil? Can't see any reason to use factories but...
|
||||
nsIURL* pURL = NULL;
|
||||
nsString url_address( file->url );
|
||||
nsresult r = NS_NewURL( &pURL, url_address );
|
||||
if( NS_OK != r ) {
|
||||
// XXX what to do?
|
||||
}
|
||||
|
||||
r = pURL->Open(pListener);
|
||||
if( NS_OK != r ) {
|
||||
// XXX what to do?
|
||||
}
|
||||
|
||||
}
|
||||
829
mozilla/modules/rdf/src/nlcstore.c
Normal file
@@ -0,0 +1,829 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements local store support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "nlcstore.h"
|
||||
#include "glue.h"
|
||||
#include "mcf.h"
|
||||
#include "xpassert.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
/* globals */
|
||||
PRBool doingFirstTimeInitp = 0;
|
||||
RDFT gOPSStore = 0;
|
||||
|
||||
|
||||
|
||||
/* externs */
|
||||
extern char *profileDirURL;
|
||||
extern char *gBookmarkURL;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
To do : killing a unit
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
compareUnalignedUINT32Ptrs(void *v1, void *v2)
|
||||
{
|
||||
uint32 val1, val2;
|
||||
|
||||
memcpy(&val1,v1,sizeof(uint32));
|
||||
memcpy(&val2,v2,sizeof(uint32));
|
||||
return((val1==val2) ? PR_TRUE:PR_FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
DBM_OpenDBMStore (DBMRDF store, char* directory)
|
||||
{
|
||||
HASHINFO hash_info = {128, 0, 0, 0, 0, 0};
|
||||
PRBool createp = 0;
|
||||
char* dbPathname;
|
||||
char* dirPathname;
|
||||
CHECK_VAR1(profileDirURL);
|
||||
dirPathname = makeDBURL(directory);
|
||||
CallPRMkDirUsingFileURL(dirPathname, 00700);
|
||||
freeMem(dirPathname);
|
||||
|
||||
dbPathname = makeRDFDBURL(directory, "names.db");
|
||||
CHECK_VAR1(dbPathname);
|
||||
store->nameDB = CallDBOpenUsingFileURL(dbPathname, O_RDWR, 0644, DB_HASH, &hash_info);
|
||||
if (store->nameDB == NULL) {
|
||||
createp = 1;
|
||||
store->nameDB = CallDBOpenUsingFileURL(dbPathname, O_RDWR | O_CREAT, 0644, DB_HASH, &hash_info);
|
||||
}
|
||||
freeMem(dbPathname);
|
||||
CHECK_VAR1(store->nameDB);
|
||||
dbPathname = makeRDFDBURL(directory, "child.db");
|
||||
CHECK_VAR1(dbPathname);
|
||||
hash_info.bsize = 2056;
|
||||
store->childrenDB = CallDBOpenUsingFileURL(dbPathname,
|
||||
O_RDWR | O_CREAT, 0644, DB_HASH, &hash_info);
|
||||
freeMem(dbPathname);
|
||||
CHECK_VAR1(store->childrenDB);
|
||||
|
||||
dbPathname = makeRDFDBURL(directory, "lstr.db");
|
||||
hash_info.bsize = 1024 ;
|
||||
store->propDB = CallDBOpenUsingFileURL(dbPathname,
|
||||
O_RDWR | O_CREAT, 0644, DB_HASH, &hash_info);
|
||||
freeMem(dbPathname);
|
||||
CHECK_VAR1(store->propDB);
|
||||
|
||||
dbPathname = makeRDFDBURL(directory, "ilstr.db");
|
||||
CHECK_VAR1(dbPathname);
|
||||
hash_info.bsize = 1024*16;
|
||||
store->invPropDB = CallDBOpenUsingFileURL(dbPathname,
|
||||
O_RDWR | O_CREAT, 0644, DB_HASH, &hash_info);
|
||||
freeMem(dbPathname);
|
||||
CHECK_VAR1(store->invPropDB);
|
||||
|
||||
if (RDF_STRCMP(directory, "NavCen") == 0) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
DBM_CloseRDFDBMStore (RDFT r)
|
||||
{
|
||||
|
||||
DBMRDF db = (DBMRDF)r->pdata;
|
||||
if (r->rdf) return 0;
|
||||
if (db->nameDB != NULL) (*db->nameDB->close)(db->nameDB);
|
||||
if (db->childrenDB != NULL) (*db->childrenDB->close)(db->childrenDB);
|
||||
if (db->propDB != NULL) (*db->propDB->close)(db->propDB);
|
||||
if (db->invPropDB != NULL) (*db->invPropDB->close)(db->invPropDB);
|
||||
freeMem(db);
|
||||
r->pdata = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
makeUSKey (RDF_Resource u, RDF_Resource s, PRBool inversep, size_t *size)
|
||||
{
|
||||
if ((s == gCoreVocab->RDF_name) || (inversep && (s == gCoreVocab->RDF_parent))) {
|
||||
*size = RDF_STRLEN(resourceID(u));
|
||||
return resourceID(u);
|
||||
} else {
|
||||
char* ans;
|
||||
*size = RDF_STRLEN(resourceID(u)) + strlen(resourceID(s));
|
||||
ans = getMem(*size);
|
||||
memcpy(ans, resourceID(u), RDF_STRLEN(resourceID(u)));
|
||||
memcpy(&ans[RDF_STRLEN(resourceID(u))], resourceID(s), strlen(resourceID(s)));
|
||||
return ans;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
DB *
|
||||
getUSDB (RDFT r, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
DBMRDF db = (DBMRDF)r->pdata;
|
||||
if (inversep) {
|
||||
if (s == gCoreVocab->RDF_parent) {
|
||||
return db->childrenDB;
|
||||
} else {
|
||||
return db->invPropDB;
|
||||
}
|
||||
} else if (s == gCoreVocab->RDF_name) {
|
||||
return db->nameDB;
|
||||
} else return db->propDB;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
freeKey (char* keyData, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
if ((s == gCoreVocab->RDF_name) || (inversep && (s == gCoreVocab->RDF_parent))) return;
|
||||
freeMem(keyData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DBMAs *
|
||||
DBM_GetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep, size_t *size)
|
||||
{
|
||||
size_t keySize;
|
||||
void* keyData = makeUSKey(u, s, inversep, &keySize);
|
||||
DBT key, data;
|
||||
DB *db;
|
||||
int status;
|
||||
CHECK_VAR(keyData, NULL);
|
||||
key.data = keyData;
|
||||
key.size = keySize;
|
||||
db = getUSDB(rdf, u, s, inversep);
|
||||
if (db == NULL) {
|
||||
*size = 0;
|
||||
freeKey(keyData, u, s, inversep);
|
||||
return NULL;
|
||||
}
|
||||
status = (*db->get)(db, &key, &data, 0);
|
||||
if (status != 0) {
|
||||
*size = 0;
|
||||
freeKey(keyData, u, s, inversep);
|
||||
return NULL;
|
||||
} else {
|
||||
void* ans = (char*)getMem(data.size);
|
||||
*size = data.size;
|
||||
memcpy(ans, data.data, *size);
|
||||
freeKey(keyData, u, s, inversep);
|
||||
return (DBMAs*) ans;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
DBM_PutSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep, void* value, size_t size)
|
||||
{
|
||||
size_t keySize;
|
||||
void* keyData = makeUSKey(u, s, inversep, &keySize);
|
||||
DBT key, data;
|
||||
int status;
|
||||
DB* db;
|
||||
CHECK_VAR1(keyData);
|
||||
db = getUSDB(rdf, u, s, inversep);
|
||||
if (db == NULL) {
|
||||
freeKey(keyData, u, s, inversep);
|
||||
return ;
|
||||
}
|
||||
key.data = keyData;
|
||||
key.size = keySize;
|
||||
data.data = value;
|
||||
data.size = size;
|
||||
status = (*db->del)(db, &key, 0);
|
||||
if (value != NULL) {
|
||||
status = (*db->put)(db, &key, &data, 0);
|
||||
}
|
||||
if ((status == 0) && (!doingFirstTimeInitp)) (*db->sync)(db, 0);
|
||||
freeKey(keyData, u, s, inversep);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
nlocalStoreHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
size_t size ;
|
||||
DBMAs *data;
|
||||
uint16 n = 0;
|
||||
PRBool ans = 0;
|
||||
PRBool invp = (s == gCoreVocab->RDF_parent);
|
||||
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
data = (invp ? DBM_GetSlotValue(rdf, (RDF_Resource)v, s, 1, &size) :
|
||||
DBM_GetSlotValue(rdf, u, s, 0, &size));
|
||||
if (data == NULL) return 0;
|
||||
while (n < size) {
|
||||
DBMAs nas = nthdbmas(data, n);
|
||||
if (nas == NULL) break;
|
||||
if ((type == valueTypeOfAs(nas)) && (tvOfAs(nas) == tv) &&
|
||||
(invp ? valueEqual(type, dataOfDBMAs(nas), u) : valueEqual(type, dataOfDBMAs(nas), v))) {
|
||||
ans = 1;
|
||||
break;
|
||||
}
|
||||
n = dbmasSize(nas) + n;
|
||||
}
|
||||
freeMem(data);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
nlocalStoreGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
size_t size ;
|
||||
DBMAs *data;
|
||||
uint16 n = 0;
|
||||
void* ans;
|
||||
data = DBM_GetSlotValue(rdf, u, s, inversep, &size);
|
||||
if (data == NULL) return 0;
|
||||
while (n < size) {
|
||||
DBMAs nas = nthdbmas(data, n);
|
||||
if (nas == NULL) break;
|
||||
if (type == valueTypeOfAs(nas)) {
|
||||
if (type == RDF_STRING_TYPE) {
|
||||
ans = copyString((char *)dataOfDBMAs(nas));
|
||||
} else if (type == RDF_RESOURCE_TYPE) {
|
||||
ans = RDF_GetResource(NULL, (char *)dataOfDBMAs(nas), true);
|
||||
} else if (type == RDF_INT_TYPE) {
|
||||
/* ans = dataOfDBMAs(nas); */
|
||||
memcpy((char*)&ans, dataOfDBMAs(nas), sizeof(uint32));
|
||||
}
|
||||
freeMem(data);
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )ans)));
|
||||
return ans;
|
||||
}
|
||||
n = dbmasSize(nas) + n;
|
||||
}
|
||||
freeMem((void*)data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
nlocalStoreGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type,
|
||||
PRBool inversep, PRBool tv)
|
||||
{
|
||||
RDF_Cursor c;
|
||||
void* val;
|
||||
size_t size;
|
||||
if (resourceType(u) == LFS_RT) return NULL;
|
||||
if (!tv && (s != gCoreVocab->RDF_parent)) return NULL;
|
||||
val = DBM_GetSlotValue(rdf, u, s, inversep, &size);
|
||||
if (val == NULL) return NULL;
|
||||
c = (RDF_Cursor) getMem(sizeof(struct RDF_CursorStruct));
|
||||
if (c == NULL) {
|
||||
freeMem(val);
|
||||
return NULL;
|
||||
}
|
||||
c->u = u;
|
||||
c->s = s;
|
||||
c->inversep = inversep;
|
||||
c->type = type;
|
||||
c->tv = tv;
|
||||
c->count = 0;
|
||||
c->pdata = val;
|
||||
c->size = size;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
nlocalStoreNextValue (RDFT rdf, RDF_Cursor c)
|
||||
{
|
||||
void* ans;
|
||||
void* data;
|
||||
if ((c == NULL) || (c->pdata == NULL)) return NULL;
|
||||
if ((c->type == RDF_ARC_LABELS_IN_QUERY) || (c->type == RDF_ARC_LABELS_OUT_QUERY))
|
||||
return nlcStoreArcsInOutNextValue(rdf, c);
|
||||
data = c->pdata;
|
||||
while (c->count < c->size) {
|
||||
DBMAs nas = nthdbmas(data, c->count);
|
||||
if (nas == NULL) break;
|
||||
if ((c->tv == tvOfAs(nas)) && (c->type == valueTypeOfAs(nas))) {
|
||||
if (c->type == RDF_RESOURCE_TYPE) {
|
||||
RDF_Resource nu = RDF_GetResource(NULL, (char *)dataOfDBMAs(nas), 1);
|
||||
|
||||
if (nu && startsWith("http:", resourceID(nu)) && strstr(resourceID(nu), ".rdf")) {
|
||||
RDFL rl = rdf->rdf;
|
||||
char* dburl = getBaseURL(resourceID(nu));
|
||||
while (rl) {
|
||||
RDF_AddDataSource(rl->rdf, dburl);
|
||||
rl = rl->next;
|
||||
}
|
||||
freeMem(dburl);
|
||||
}
|
||||
|
||||
ans = nu;
|
||||
c->count = dbmasSize(nas) + c->count;
|
||||
return nu;
|
||||
} else {
|
||||
ans = dataOfDBMAs(nas);
|
||||
c->count = dbmasSize(nas) + c->count;
|
||||
return ans;
|
||||
}
|
||||
}
|
||||
c->count = dbmasSize(nas) + c->count;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
nlocalStoreDisposeCursor (RDFT rdf, RDF_Cursor c)
|
||||
{
|
||||
if (c != NULL) {
|
||||
if (c->pdata) freeMem(c->pdata);
|
||||
c->pdata = NULL;
|
||||
freeMem(c);
|
||||
}
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DBMAs
|
||||
makeAsBlock (void* v, RDF_ValueType type, PRBool tv, size_t *size)
|
||||
{
|
||||
size_t vsize=0;
|
||||
DBMAs ans;
|
||||
int rem = 0;
|
||||
/*
|
||||
ldiv_t cdiv ;
|
||||
*/
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if (type == RDF_STRING_TYPE) {
|
||||
vsize = RDF_STRLEN(v);
|
||||
} else if (type == RDF_RESOURCE_TYPE) {
|
||||
vsize = RDF_STRLEN( resourceID((RDF_Resource)v));
|
||||
} else if (type == RDF_INT_TYPE) {
|
||||
vsize = 4;
|
||||
}
|
||||
*size = 4 + vsize + 1;
|
||||
rem = *size % 4;
|
||||
if (rem) {
|
||||
*size += 4 - rem;
|
||||
}
|
||||
ans = (DBMAs) getMem(*size);
|
||||
if (ans == NULL) return NULL;
|
||||
ans->size[0] = (uint8)(((*size) & 0x00FF0000) >> 16);
|
||||
ans->size[1] = (uint8)(((*size) & 0x0000FF00) >> 8);
|
||||
ans->size[2] = (uint8)((*size) & 0x000000FF);
|
||||
*(((unsigned char *)ans)+3) = (tv ? 0x10 : 0) | (type & 0x0F);
|
||||
if (type == RDF_STRING_TYPE) {
|
||||
memcpy((char*)ans+4, (char*) v, vsize);
|
||||
} else if (type == RDF_RESOURCE_TYPE) {
|
||||
memcpy((char*)ans+4, resourceID((RDF_Resource)v), vsize);
|
||||
} else if (type == RDF_INT_TYPE) {
|
||||
memcpy((char*)ans+4, (char*)v, vsize);
|
||||
}
|
||||
/*
|
||||
cdiv = ldiv(*size, 256);
|
||||
ans->size[0] = (uint8)(cdiv.quot);
|
||||
ans->size[1] = (uint8)(cdiv.rem);
|
||||
ans->tag = (tv ? 0x10 : 0) | (type & 0x0F);
|
||||
if (type == RDF_STRING_TYPE) {
|
||||
memcpy((char*)ans+3, (char*) v, vsize);
|
||||
} else if (type == RDF_RESOURCE_TYPE) {
|
||||
memcpy((char*)ans+3, resourceID((RDF_Resource)v), vsize);
|
||||
} else if (type == RDF_INT_TYPE) {
|
||||
memcpy((char*)ans+3, (char*)v, vsize);
|
||||
}
|
||||
*/
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
nlocalStoreAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
size_t size ;
|
||||
DBMAs* data;
|
||||
char* ndata;
|
||||
DBMAs temp;
|
||||
uint16 n = 0;
|
||||
size_t tsize;
|
||||
PRBool ans = 0;
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
|
||||
/* don't store RDF Commands in the local store */
|
||||
if (s == gNavCenter->RDF_Command) return 0;
|
||||
|
||||
data = DBM_GetSlotValue(rdf, u, s, 0, &size);
|
||||
if (((data == NULL) && (size != 0)) || ((size == 0) && (data != NULL))) return 0;
|
||||
while (n < size) {
|
||||
DBMAs nas = nthdbmas(data, n);
|
||||
if (nas == NULL) {freeMem(data); return 0;}
|
||||
if (type == valueTypeOfAs(nas) && (valueEqual(type, dataOfDBMAs(nas), v))) {
|
||||
ans = 1;
|
||||
break;
|
||||
}
|
||||
n = dbmasSize(nas) + n;
|
||||
}
|
||||
if (ans) {
|
||||
freeMem(data);
|
||||
return 1;
|
||||
} else {
|
||||
temp = makeAsBlock(v, type, tv, &tsize);
|
||||
if (temp == NULL) {freeMem(data);return 0;}
|
||||
if (data == NULL) {
|
||||
DBM_PutSlotValue(rdf, u, s, 0, (void*)temp, tsize);
|
||||
/* addSlotsHere(rdf, u, s); */
|
||||
freeMem(temp);
|
||||
temp = NULL;
|
||||
} else {
|
||||
ndata = (char*)getMem(size + tsize);
|
||||
if (ndata == NULL) {freeMem(data); freeMem(temp);return 0;}
|
||||
memcpy(ndata, data, size);
|
||||
memcpy(&ndata[size], (char*)temp, tsize);
|
||||
DBM_PutSlotValue(rdf, u,s, 0, ndata, size+tsize);
|
||||
freeMem(data);
|
||||
freeMem(ndata);
|
||||
freeMem(temp);
|
||||
}
|
||||
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
temp = makeAsBlock(u, RDF_RESOURCE_TYPE, tv, &tsize);
|
||||
if (temp == NULL) return 0;
|
||||
data = DBM_GetSlotValue(rdf, (RDF_Resource)v, s, 1, &size);
|
||||
if (data == NULL) {
|
||||
DBM_PutSlotValue(rdf, (RDF_Resource)v, s, 1, (void*) temp, tsize);
|
||||
freeMem(temp);
|
||||
/* addSlotsIn(rdf, (RDF_Resource)v, s);*/
|
||||
} else {
|
||||
ndata = (char*)getMem(size + tsize);
|
||||
if (ndata == NULL) {freeMem(data); freeMem(temp);return 0;}
|
||||
memcpy(ndata, data, size);
|
||||
memcpy(&ndata[size], (char*)temp, tsize);
|
||||
DBM_PutSlotValue(rdf, (RDF_Resource)v, s, 1, ndata, size+tsize);
|
||||
freeMem(data);
|
||||
freeMem(ndata);
|
||||
freeMem(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
sendNotifications2(rdf, RDF_INSERT_NOTIFY, u, s, v, type, tv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
nlocalStoreAssert1 (RDFFile f, RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
return nlocalStoreAssert(rdf, u, s, v, type, tv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
nlocalStoreUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
size_t size ;
|
||||
DBMAs* data;
|
||||
char* temp;
|
||||
uint16 n = 0;
|
||||
size_t tsize;
|
||||
PRBool ans = 0;
|
||||
DBMAs nas;
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
data = DBM_GetSlotValue(rdf, u, s, 0, &size);
|
||||
if (data == NULL) return 1;
|
||||
while (n < size) {
|
||||
nas = nthdbmas(data, n);
|
||||
if (type == valueTypeOfAs(nas) && (valueEqual(type, dataOfDBMAs(nas), v))) {
|
||||
ans = 1;
|
||||
break;
|
||||
}
|
||||
n = dbmasSize(nas) + n;
|
||||
}
|
||||
if (!ans) {
|
||||
freeMem(data);
|
||||
return 1;
|
||||
} else {
|
||||
if (size == dbmasSize(nas)) {
|
||||
DBM_PutSlotValue(rdf, u, s, 0, NULL, 0);
|
||||
/*deleteSlotsHere(rdf, u, s);*/
|
||||
} else {
|
||||
tsize = size - dbmasSize(nas);
|
||||
temp = (char*)getMem(tsize);
|
||||
if (temp == NULL) {
|
||||
freeMem(data);
|
||||
return 0;
|
||||
}
|
||||
if (n != 0) memcpy(temp, data, n);
|
||||
memcpy(((char*)temp+n), ((char*)data + n + dbmasSize(nas)), tsize-n);
|
||||
DBM_PutSlotValue(rdf, u, s, 0, temp, tsize);
|
||||
freeMem(temp);
|
||||
}
|
||||
freeMem(data);
|
||||
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
data = DBM_GetSlotValue(rdf, ((RDF_Resource)v), s, 1, &size);
|
||||
ans = n = 0;
|
||||
if (data == NULL) {
|
||||
return 1;
|
||||
} else {
|
||||
while (n < size) {
|
||||
nas = nthdbmas(data, n);
|
||||
if (valueEqual(RDF_RESOURCE_TYPE, dataOfDBMAs(nas), u)){
|
||||
ans = 1;
|
||||
break;
|
||||
}
|
||||
n = dbmasSize(nas) + n;
|
||||
}
|
||||
if (!ans) {
|
||||
return 1;
|
||||
} else {
|
||||
if (size == dbmasSize(nas)) {
|
||||
DBM_PutSlotValue(rdf, (RDF_Resource)v, s, 1, NULL, 0);
|
||||
/* deleteSlotsIn(rdf, (RDF_Resource)v, s); */
|
||||
} else {
|
||||
tsize = size - dbmasSize(nas);
|
||||
temp = (char*)getMem(tsize);
|
||||
if (temp == NULL) {
|
||||
freeMem(data);
|
||||
return 0;
|
||||
}
|
||||
if (n) memcpy(temp, data, n);
|
||||
memcpy(((char*)temp+n), ((char*)data + n + dbmasSize(nas)), tsize-n);
|
||||
DBM_PutSlotValue(rdf, ((RDF_Resource)v), s, 1, temp, tsize);
|
||||
freeMem(temp);
|
||||
}
|
||||
freeMem(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sendNotifications2(rdf, RDF_DELETE_NOTIFY, u, s, v, type, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
addSlotsHere (RDFT rdf, RDF_Resource u, RDF_Resource s)
|
||||
{
|
||||
if ((s != gCoreVocab->RDF_name) && (s != gCoreVocab->RDF_parent) &&
|
||||
(s != gCoreVocab->RDF_slotsHere) && (s != gCoreVocab->RDF_slotsIn)) {
|
||||
nlocalStoreAssert (rdf, u, gCoreVocab->RDF_slotsHere, s, RDF_RESOURCE_TYPE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
deleteSlotsHere (RDFT rdf, RDF_Resource u, RDF_Resource s)
|
||||
{
|
||||
if ((s != gCoreVocab->RDF_name) && (s != gCoreVocab->RDF_parent) &&
|
||||
(s != gCoreVocab->RDF_slotsHere) && (s != gCoreVocab->RDF_slotsIn)) {
|
||||
nlocalStoreUnassert (rdf, u, gCoreVocab->RDF_slotsHere, s, RDF_RESOURCE_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
addSlotsIn (RDFT rdf, RDF_Resource u, RDF_Resource s)
|
||||
{
|
||||
if ((s != gCoreVocab->RDF_name) && (s != gCoreVocab->RDF_parent) &&
|
||||
(s != gCoreVocab->RDF_slotsHere) && (s != gCoreVocab->RDF_slotsIn)) {
|
||||
nlocalStoreAssert (rdf, u, gCoreVocab->RDF_slotsIn, s, RDF_RESOURCE_TYPE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
deleteSlotsIn (RDFT rdf, RDF_Resource u, RDF_Resource s)
|
||||
{
|
||||
if ((s != gCoreVocab->RDF_name) && (s != gCoreVocab->RDF_parent) &&
|
||||
(s != gCoreVocab->RDF_slotsHere) && (s != gCoreVocab->RDF_slotsIn)) {
|
||||
nlocalStoreUnassert (rdf, u, gCoreVocab->RDF_slotsIn, s, RDF_RESOURCE_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
nlclStoreKill (RDFT rdf, RDF_Resource u)
|
||||
{
|
||||
size_t size ;
|
||||
DBMAs* data;
|
||||
uint16 n = 0;
|
||||
data = DBM_GetSlotValue(rdf, u, gCoreVocab->RDF_slotsHere, 0, &size);
|
||||
while (n < size) {
|
||||
DBMAs nas = nthdbmas(data, n);
|
||||
RDF_Resource s;
|
||||
s = RDF_GetResource(NULL, (char*)dataOfDBMAs(nas), 1);
|
||||
DBM_PutSlotValue(rdf, u, s, 0, NULL, 0);
|
||||
n = dbmasSize(nas) + n;
|
||||
}
|
||||
DBM_PutSlotValue(rdf, u, gCoreVocab->RDF_name, 0, NULL, 0) ;
|
||||
DBM_PutSlotValue(rdf, u, gCoreVocab->RDF_parent, 1, NULL, 0) ;
|
||||
DBM_PutSlotValue(rdf, u, gCoreVocab->RDF_parent, 0, NULL, 0) ;
|
||||
data = DBM_GetSlotValue(rdf, u, gCoreVocab->RDF_slotsIn, 0, &size);
|
||||
while (n < size) {
|
||||
DBMAs nas = nthdbmas(data, n);
|
||||
RDF_Resource s;
|
||||
s = RDF_GetResource(NULL, (char*)dataOfDBMAs(nas), 1);
|
||||
DBM_PutSlotValue(rdf, u, s, 1, NULL, 0);
|
||||
n = dbmasSize(nas) + n;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
nlocalStoreAddChildAt(RDFT rdf, RDF_Resource parent, RDF_Resource ref,
|
||||
RDF_Resource new, PRBool beforep)
|
||||
{
|
||||
size_t size ;
|
||||
DBMAs* data;
|
||||
char* ndata;
|
||||
RDF_Resource s = gCoreVocab->RDF_parent;
|
||||
DBMAs temp;
|
||||
uint16 n = 0;
|
||||
size_t tsize;
|
||||
PRBool ans = 0;
|
||||
DBMAs nas;
|
||||
data = DBM_GetSlotValue(rdf, parent, s, 1, &size);
|
||||
if (!data) return 0;
|
||||
while (n < size) {
|
||||
nas = nthdbmas(data, n);
|
||||
if (valueEqual(RDF_RESOURCE_TYPE, dataOfDBMAs(nas), ref)) {
|
||||
ans = 1;
|
||||
if (!beforep) {
|
||||
n = dbmasSize(nas) + n;
|
||||
}
|
||||
break;
|
||||
}
|
||||
n = dbmasSize(nas) + n;
|
||||
}
|
||||
if (!ans) {
|
||||
freeMem(data);
|
||||
return 0;
|
||||
} else {
|
||||
char* dx = (char*)data;
|
||||
|
||||
temp = makeAsBlock(new, RDF_RESOURCE_TYPE, 1, &tsize);
|
||||
ndata = (char*)getMem(size + tsize);
|
||||
if ((temp == NULL) || (ndata == NULL)) {freeMem(data);freeMem(temp);freeMem(ndata);return 1;}
|
||||
memcpy(ndata, dx, n);
|
||||
memcpy(&ndata[n], (char*)temp, tsize);
|
||||
memcpy(&ndata[n+tsize], &dx[n], size-n);
|
||||
DBM_PutSlotValue(rdf, parent, s, 1, ndata, size+tsize);
|
||||
freeMem(data);
|
||||
freeMem(ndata);
|
||||
freeMem(temp);
|
||||
}
|
||||
|
||||
temp = makeAsBlock(parent, RDF_RESOURCE_TYPE, 1, &tsize);
|
||||
if (temp == NULL) return 0;
|
||||
data = DBM_GetSlotValue(rdf, new, s, 0, &size);
|
||||
if (data == NULL) {
|
||||
DBM_PutSlotValue(rdf, new, s, 0, (void*) temp, tsize);
|
||||
} else {
|
||||
ndata = (char*)getMem(size + tsize);
|
||||
if (ndata == NULL) {freeMem(data);freeMem(temp);return 0;}
|
||||
memcpy(ndata, data, size);
|
||||
memcpy(&ndata[size], (char*)temp, tsize);
|
||||
DBM_PutSlotValue(rdf, (RDF_Resource)new, s, 0, ndata, size+tsize);
|
||||
freeMem(data);
|
||||
freeMem(ndata);
|
||||
freeMem(temp);
|
||||
}
|
||||
sendNotifications2(rdf, RDF_INSERT_NOTIFY, new, s, parent, RDF_RESOURCE_TYPE, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
nlcStoreArcsIn (RDFT rdf, RDF_Resource u)
|
||||
{
|
||||
RDF_Cursor c = (RDF_Cursor) getMem(sizeof(struct RDF_CursorStruct));
|
||||
c->u = u;
|
||||
c->queryType = RDF_ARC_LABELS_IN_QUERY;
|
||||
c->inversep = 1;
|
||||
c->count = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
nlcStoreArcsOut (RDFT rdf, RDF_Resource u)
|
||||
{
|
||||
RDF_Cursor c = (RDF_Cursor) getMem(sizeof(struct RDF_CursorStruct));
|
||||
c->u = u;
|
||||
c->queryType = RDF_ARC_LABELS_OUT_QUERY;
|
||||
c->count = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
nlcStoreArcsInOutNextValue (RDFT rdf, RDF_Cursor c)
|
||||
{
|
||||
while (c->count < (int16) gCoreVocabSize) {
|
||||
RDF_Resource s = *(gAllVocab + c->count);
|
||||
size_t size;
|
||||
void* data = DBM_GetSlotValue(rdf, c->u, s, c->inversep, &size);
|
||||
c->count++;
|
||||
if (data) {
|
||||
freeMem(data);
|
||||
return s;
|
||||
} else {
|
||||
freeMem(data);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
RDFT
|
||||
MakeLocalStore (char* url)
|
||||
{
|
||||
if (startsWith(url, "rdf:localStore") && (gLocalStore)) {
|
||||
return gLocalStore;
|
||||
} else if (startsWith(url, "rdf:ops") && (gOPSStore)) {
|
||||
return gOPSStore;
|
||||
} else if (startsWith(url, "rdf:ops") || startsWith(url, "rdf:localStore")) {
|
||||
RDFT ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct));
|
||||
DBMRDF db = (DBMRDF)getMem(sizeof(struct _DBMRDFStruct));
|
||||
CHECK_VAR(ntr, NULL);
|
||||
CHECK_VAR(db, NULL);
|
||||
if (startsWith(url, "rdf:localStore")) {
|
||||
gLocalStore = ntr;
|
||||
} else {
|
||||
gOPSStore = ntr;
|
||||
}
|
||||
ntr->url = copyString(url);
|
||||
ntr->assert = nlocalStoreAssert;
|
||||
ntr->unassert = nlocalStoreUnassert;
|
||||
ntr->getSlotValue = nlocalStoreGetSlotValue;
|
||||
ntr->getSlotValues = nlocalStoreGetSlotValues;
|
||||
ntr->hasAssertion = nlocalStoreHasAssertion;
|
||||
ntr->nextValue = nlocalStoreNextValue;
|
||||
ntr->disposeCursor = nlocalStoreDisposeCursor;
|
||||
ntr->destroy = DBM_CloseRDFDBMStore;
|
||||
ntr->arcLabelsIn = nlcStoreArcsIn;
|
||||
ntr->arcLabelsOut = nlcStoreArcsOut;
|
||||
ntr->pdata = db;
|
||||
DBM_OpenDBMStore(db, (startsWith(url, "rdf:localStore") ? "NavCen" : &url[4]));
|
||||
nlocalStoreAssert(ntr, gNavCenter->RDF_BookmarkFolderCategory, gCoreVocab->RDF_name,
|
||||
copyString("Bookmarks"), RDF_STRING_TYPE, 1);
|
||||
return ntr;
|
||||
}
|
||||
else return NULL;
|
||||
|
||||
} */
|
||||
122
mozilla/modules/rdf/src/nlcstore.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_NLCSTORE_H_
|
||||
#define _RDF_NLCSTORE_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "rdf.h"
|
||||
#include "mcom_ndbm.h"
|
||||
|
||||
|
||||
#if !defined(IS_LITTLE_ENDIAN) && !defined(IS_BIG_ENDIAN)
|
||||
#error Must have a byte order
|
||||
#endif
|
||||
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
#define COPY_INT16(_a,_b) XP_MEMCPY(_a, _b, sizeof(uint16));
|
||||
#else
|
||||
#define COPY_INT16(_a,_b) \
|
||||
do { \
|
||||
((char *)(_a))[0] = ((char *)(_b))[1]; \
|
||||
((char *)(_a))[1] = ((char *)(_b))[0]; \
|
||||
} while(0)
|
||||
#endif
|
||||
#if !defined(XP_MAC) && !defined(COPY_INT16)
|
||||
#define COPY_INT16(_a,_b) XP_MEMCPY(_a, _b, sizeof(int16));
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* nlcstore.c data structures and defines */
|
||||
|
||||
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma options align=packed
|
||||
#endif
|
||||
|
||||
typedef struct _DBMAsStruct {
|
||||
uint8 size[3];
|
||||
uint8 tag;
|
||||
uint8 data[1]; /* me & the compiler man, we're like _this_ */
|
||||
} DBMAsStruct;
|
||||
typedef DBMAsStruct* DBMAs;
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
typedef struct _DBMRDFStruct {
|
||||
DB *propDB;
|
||||
DB *invPropDB;
|
||||
DB *nameDB;
|
||||
DB *childrenDB;
|
||||
} *DBMRDF;
|
||||
|
||||
|
||||
#define dataOfDBMAs(dbmas) (((char *)dbmas) + 4)
|
||||
#define dbmasSize(dbmas) ((size_t)(((1 << 16) * dbmas->size[0]) + ((1 << 8) * dbmas->size[1]) + dbmas->size[2]))
|
||||
#define nthdbmas(data, n) ((DBMAs)(((char *)data) + n))
|
||||
#define valueTypeOfAs(nas) (RDF_ValueType) ((*(((uint8 *)(nas)) + 3)) & 0x0F)
|
||||
#define tvOfAs(nas) ((PRBool)(((*((uint8 *)(nas) + 3)) & 0x10) != 0))
|
||||
#define valueEqual(type, v1, v2) (((type == RDF_RESOURCE_TYPE) && stringEquals((char*)v1, resourceID((RDF_Resource)v2))) || \
|
||||
((type == RDF_INT_TYPE) && (compareUnalignedUINT32Ptrs(v1,v2))) || \
|
||||
((type == RDF_STRING_TYPE) && stringEquals((char*)v1, (char*)v2)))
|
||||
|
||||
|
||||
|
||||
/* nlcstore.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
PRBool compareUnalignedUINT32Ptrs(void *v1, void *v2);
|
||||
char * makeRDFDBURL(char* directory, char* name);
|
||||
void readInBookmarksOnInit(RDFFile f);
|
||||
void DBM_OpenDBMStore (DBMRDF store, char* directory);
|
||||
RDF_Error DBM_CloseRDFDBMStore (RDFT r);
|
||||
char * makeUSKey (RDF_Resource u, RDF_Resource s, PRBool inversep, size_t *size);
|
||||
DB * getUSDB (RDFT r, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
void freeKey (char* keyData, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
DBMAs * DBM_GetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep, size_t *size);
|
||||
void DBM_PutSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep, void* value, size_t size);
|
||||
PRBool nlocalStoreHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
void * nlocalStoreGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor nlocalStoreGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * nlocalStoreNextValue (RDFT rdf, RDF_Cursor c);
|
||||
RDF_Error nlocalStoreDisposeCursor (RDFT rdf, RDF_Cursor c);
|
||||
DBMAs makeAsBlock (void* v, RDF_ValueType type, PRBool tv, size_t *size);
|
||||
PRBool nlocalStoreAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool nlocalStoreAssert1 (RDFFile f, RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool nlocalStoreUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
void addSlotsHere (RDFT rdf, RDF_Resource u, RDF_Resource s);
|
||||
void deleteSlotsHere (RDFT rdf, RDF_Resource u, RDF_Resource s);
|
||||
void addSlotsIn (RDFT rdf, RDF_Resource u, RDF_Resource s);
|
||||
void deleteSlotsIn (RDFT rdf, RDF_Resource u, RDF_Resource s);
|
||||
void nlclStoreKill (RDFT rdf, RDF_Resource u);
|
||||
PRBool nlocalStoreAddChildAt(RDFT rdf, RDF_Resource parent, RDF_Resource ref, RDF_Resource new, PRBool beforep);
|
||||
RDF_Cursor nlcStoreArcsIn (RDFT rdf, RDF_Resource u);
|
||||
RDF_Cursor nlcStoreArcsOut (RDFT rdf, RDF_Resource u);
|
||||
RDF_Resource nlcStoreArcsInOutNextValue (RDFT rdf, RDF_Cursor c);
|
||||
RDFT MakeLocalStore (char* url);
|
||||
RDF_Resource nlcStoreArcsInOutNextValue (RDFT rdf, RDF_Cursor c) ;
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
563
mozilla/modules/rdf/src/pm2rdf.c
Normal file
@@ -0,0 +1,563 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements mail support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#ifdef SMART_MAIL
|
||||
#include "pm2rdf.h"
|
||||
|
||||
extern char *profileDirURL;
|
||||
|
||||
|
||||
|
||||
void
|
||||
Pop_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
GetPopToRDF (RDFT rdf)
|
||||
{
|
||||
MF folder = (MF) rdf->pdata;
|
||||
if (endsWith("/inbox", rdf->url)) {
|
||||
char* popurl = getMem(100);
|
||||
int n = 10;
|
||||
int l = RDF_STRLEN(rdf->url);
|
||||
URL_Struct *urls ;
|
||||
memcpy(popurl, "pop3://", 7);
|
||||
while (n < l) {
|
||||
if (rdf->url[n] == '/') break;
|
||||
popurl[n-3] = rdf->url[n];
|
||||
n++;
|
||||
}
|
||||
|
||||
urls = NET_CreateURLStruct(popurl, NET_DONT_RELOAD);
|
||||
if (urls != NULL) {
|
||||
urls->fe_data = rdf;
|
||||
|
||||
NET_GetURL(urls, FO_PRESENT, gRDFMWContext(rdf), Pop_GetUrlExitFunc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
PopGetNewMail (RDF_Resource r)
|
||||
{
|
||||
if (containerp(r) && (resourceType(r) == PM_RT)) {
|
||||
MF folder = (MF) r->pdata;
|
||||
GetPopToRDF(folder->rdf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
stripCopy (char* str)
|
||||
{
|
||||
return copyString(XP_StripLine(str));
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
msgDeletedp (MM msg)
|
||||
{
|
||||
return (msg && (msg->flags) && (msg->flags[4] == '8'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
FILE *
|
||||
openPMFile (char* path)
|
||||
{
|
||||
FILE* ans = fopen(path, "r+");
|
||||
if (!ans) {
|
||||
ans = fopen(path, "w");
|
||||
if (ans) fclose(ans);
|
||||
ans = fopen(path, "r+");
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
addMsgToFolder (MF folder, MM msg)
|
||||
{
|
||||
if (!folder->tail) {
|
||||
folder->msg = folder->tail = msg;
|
||||
} else {
|
||||
folder->tail->next = msg;
|
||||
folder->tail = msg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
RDF_StartMessageDelivery (RDFT rdf)
|
||||
{
|
||||
MF folder = (MF) rdf->pdata;
|
||||
MM msg = (MM) getMem(sizeof(struct MailMessage));
|
||||
char* nurl = getMem(100);
|
||||
fseek(folder->mfile, 0L, SEEK_END);
|
||||
fprintf(folder->mfile, "From - \n");
|
||||
msg->offset = ftell(folder->mfile);
|
||||
sprintf(nurl, "%s?%i", rdf->url, msg->offset);
|
||||
msg->r = RDF_GetResource(NULL, nurl, 1);
|
||||
msg->r->pdata = msg;
|
||||
msg->flags = getMem(4);
|
||||
folder->add = msg;
|
||||
setResourceType(msg->r, PM_RT);
|
||||
fseek(folder->mfile, 0L, SEEK_END);
|
||||
fputs("X-Mozilla-Status: 0000\n", folder->mfile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
MIW1 (const char* block, int32 len)
|
||||
{
|
||||
char* blk = XP_ALLOC(len +1);
|
||||
int32 n = 0;
|
||||
int32 m = 0;
|
||||
PRBool seenp = 0;
|
||||
PRBool wsendp = 0;
|
||||
memset(blk, '\0', len);
|
||||
while (n++ < len) {
|
||||
char c = block[n];
|
||||
if ((c == '\r') || (c == '\n')) break;
|
||||
if (!seenp) {
|
||||
seenp = (c == ':');
|
||||
} else {
|
||||
if (c != ' ') wsendp = 1;
|
||||
if (wsendp) {
|
||||
blk[m++] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return blk;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
RDF_AddMessageLine (RDFT rdf, char* block, int32 length)
|
||||
{
|
||||
MF folder = (MF) rdf->pdata;
|
||||
MM msg = folder->add;
|
||||
char* temp = getMem(length+1);
|
||||
memcpy(temp, block, length);
|
||||
if (!msg->from && (startsWith("From:", block))) {
|
||||
msg->from = MIW1(block, length);
|
||||
} else if (!msg->subject && (startsWith("Subject:", block))) {
|
||||
msg->subject = MIW1(block, length);
|
||||
} else if (!msg->date && (startsWith("Date:", block))) {
|
||||
msg->date = MIW1(block, length);
|
||||
}
|
||||
fseek(folder->mfile, 0L, SEEK_END);
|
||||
fputs(temp, folder->mfile);
|
||||
freeMem(temp);
|
||||
}
|
||||
|
||||
|
||||
#define TON(s) ((s == NULL) ? "" : s)
|
||||
void writeMsgSum (MF folder, MM msg) {
|
||||
if (!msg->flags) msg->flags = copyString("0000");
|
||||
if (msg->summOffset == -1) {
|
||||
fseek(folder->sfile, 0L, SEEK_END);
|
||||
msg->summOffset = ftell(folder->sfile);
|
||||
} else {
|
||||
fseek(folder->sfile, msg->summOffset, SEEK_SET);
|
||||
}
|
||||
fprintf(folder->sfile, "Status: %s\nSOffset: %d\nFrom: %s\nSubject: %s\nDate: %s\nMOffset: %d\n",
|
||||
msg->flags, ftell(folder->sfile),
|
||||
TON(msg->from), TON(msg->subject), TON(msg->date), msg->offset );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
RDF_FinishMessageDelivery (RDFT rdf)
|
||||
{
|
||||
MF folder = (MF) rdf->pdata;
|
||||
MM msg = folder->add;
|
||||
folder->add = NULL;
|
||||
addMsgToFolder(folder, msg);
|
||||
setResourceType(msg->r, PM_RT);
|
||||
fseek(folder->sfile, 0L, SEEK_END);
|
||||
msg->summOffset = ftell(folder->sfile);
|
||||
writeMsgSum(folder, msg);
|
||||
fseek(folder->mfile, 0L, SEEK_END);
|
||||
fputs("\n", folder->mfile);
|
||||
sendNotifications2(rdf, RDF_ASSERT_NOTIFY, msg->r, gCoreVocab->RDF_parent, folder->top,
|
||||
RDF_RESOURCE_TYPE, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
setMessageFlag (RDFT rdf, RDF_Resource r, char* newFlag)
|
||||
{
|
||||
MF folder = (MF) rdf->pdata;
|
||||
MM msg = (MM)r->pdata;
|
||||
fseek(folder->sfile, msg->summOffset+8, SEEK_SET);
|
||||
fputs(newFlag, folder->sfile);
|
||||
freeMem(msg->flags);
|
||||
msg->flags = copyString(newFlag);
|
||||
/* need to mark the flag in the message file */
|
||||
fflush(folder->sfile);
|
||||
}
|
||||
|
||||
#define BUFF_SIZE 50000
|
||||
|
||||
|
||||
RDFT
|
||||
getBFTranslator (char* url) {
|
||||
if (startsWith("mailbox://folder/", url)) {
|
||||
char* temp = getMem(RDF_STRLEN(url));
|
||||
RDFT ans = NULL;
|
||||
sprintf(temp, "mailbox://%s", &url[17]);
|
||||
ans = getTranslator(temp);
|
||||
freeMem(temp);
|
||||
return ans;
|
||||
} else return getTranslator(url);
|
||||
}
|
||||
|
||||
PRBool
|
||||
MoveMessage (char* to, char* from, MM message) {
|
||||
RDFT todb = getBFTranslator(to);
|
||||
RDFT fromdb = getBFTranslator(from);
|
||||
MF tom = todb->pdata;
|
||||
MF fom = fromdb->pdata;
|
||||
RDF_Resource r;
|
||||
MM newMsg = (MM)getMem(sizeof(struct MailMessage));
|
||||
char* buffer = getMem(BUFF_SIZE);
|
||||
if (!buffer) return 0;
|
||||
setMessageFlag(fromdb, message->r, "0008");
|
||||
fseek(tom->mfile, 0L, SEEK_END);
|
||||
fseek(fom->mfile, message->offset, SEEK_SET);
|
||||
fputs("From -\n", tom->mfile);
|
||||
sprintf(buffer, "mailbox://%s?%d", &to[17], ftell(tom->mfile));
|
||||
r = RDF_GetResource(NULL, buffer, 1);
|
||||
newMsg->subject = copyString(message->subject);
|
||||
newMsg->from = copyString(message->from);
|
||||
newMsg->date = copyString(message->date);
|
||||
newMsg->r = r;
|
||||
r->pdata = newMsg;
|
||||
setResourceType(r, PM_RT);
|
||||
newMsg->summOffset = -1;
|
||||
newMsg->offset = ftell(tom->mfile);
|
||||
writeMsgSum(tom, newMsg);
|
||||
addMsgToFolder (tom, newMsg) ;
|
||||
fflush(tom->sfile);
|
||||
while (fgets(buffer, BUFF_SIZE, fom->mfile) && strncmp("From ", buffer, 5)) {
|
||||
fputs(buffer, tom->mfile);
|
||||
}
|
||||
sendNotifications2(todb, RDF_ASSERT_NOTIFY, r, gCoreVocab->RDF_parent, tom->top,
|
||||
RDF_RESOURCE_TYPE, 1);
|
||||
sendNotifications2(fromdb, RDF_DELETE_NOTIFY, message->r, gCoreVocab->RDF_parent, fom->top,
|
||||
RDF_RESOURCE_TYPE, 1);
|
||||
freeMem(buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
readSummaryFile (RDFT rdf)
|
||||
{
|
||||
if (startsWith("mailbox://", rdf->url)) {
|
||||
char* url = rdf->url;
|
||||
char* folderURL = &url[10];
|
||||
int32 flen = RDF_STRLEN(profileDirURL) + strlen(folderURL) + 4;
|
||||
char* fileurl = getMem(flen);
|
||||
char* nurl = getMem(RDF_STRLEN(url) + 20);
|
||||
FILE *f;
|
||||
char* buff = getMem(BUFF_SIZE);
|
||||
MF folder = (MF) getMem(sizeof(struct MailFolder));
|
||||
MM msg = NULL;
|
||||
FILE *mf;
|
||||
char* aclen;
|
||||
|
||||
rdf->pdata = folder;
|
||||
sprintf(fileurl, "%s%s.ssf", profileDirURL, folderURL);
|
||||
fileurl = MCDepFileURL(fileurl);
|
||||
f = openPMFile(fileurl);
|
||||
sprintf(fileurl, "%s%s", profileDirURL, folderURL);
|
||||
fileurl = MCDepFileURL(fileurl);
|
||||
mf = openPMFile(fileurl);
|
||||
folder->top = RDF_GetResource(NULL, rdf->url, 1);
|
||||
setResourceType(folder->top, PM_RT);
|
||||
setContainerp(folder->top, 1);
|
||||
folder->top->pdata = folder;
|
||||
folder->rdf = rdf;
|
||||
folder->sfile = f;
|
||||
folder->mfile = mf;
|
||||
|
||||
while (f && fgets(buff, BUFF_SIZE, f)) {
|
||||
if (startsWith("Status:", buff)) {
|
||||
msg = (MM) getMem(sizeof(struct MailMessage));
|
||||
msg->flags = stripCopy(&buff[8]);
|
||||
fgets(buff, BUFF_SIZE, f);
|
||||
sscanf(&buff[9], "%d", &msg->summOffset);
|
||||
fgets(buff, BUFF_SIZE, f);
|
||||
msg->from = stripCopy(&buff[6]);
|
||||
fgets(buff, BUFF_SIZE, f);
|
||||
msg->subject = stripCopy(&buff[8]);
|
||||
fgets(buff, BUFF_SIZE, f);
|
||||
msg->date = stripCopy(&buff[6]);
|
||||
fgets(buff, BUFF_SIZE, f);
|
||||
sscanf(&buff[9], "%d", &msg->offset);
|
||||
sprintf(nurl, "%s?%d", url, msg->offset);
|
||||
msg->r = RDF_GetResource(NULL, nurl, 1);
|
||||
msg->r->pdata = msg;
|
||||
addMsgToFolder (folder, msg) ;
|
||||
setResourceType(msg->r, PM_RT);
|
||||
}
|
||||
}
|
||||
|
||||
if (msg == NULL) {
|
||||
/* either a new mailbox or need to read BMF to recreate */
|
||||
while (mf && fgets(buff, BUFF_SIZE, mf)) {
|
||||
if (strncmp("From ", buff, 5) ==0) {
|
||||
if (msg) writeMsgSum(folder, msg);
|
||||
msg = (MM) getMem(sizeof(struct MailMessage));
|
||||
msg->offset = ftell(mf);
|
||||
msg->summOffset = -1;
|
||||
sprintf(nurl, "%s?%i", url, msg->offset);
|
||||
msg->r = RDF_GetResource(NULL, nurl, 1);
|
||||
msg->r->pdata = msg;
|
||||
setResourceType(msg->r, PM_RT);
|
||||
addMsgToFolder (folder, msg) ;
|
||||
}
|
||||
if ((!msg->from) && (startsWith("From:", buff))) {
|
||||
msg->from = stripCopy(&buff[6]);
|
||||
} else if ((!msg->date) && (startsWith("Date:", buff))) {
|
||||
msg->date = stripCopy(&buff[6]);
|
||||
} else if ((!msg->subject) && (startsWith("Subject:", buff))) {
|
||||
msg->subject = stripCopy(&buff[8]);
|
||||
} else if ((!msg->flags) && (startsWith("X-Mozilla-Status:", buff))) {
|
||||
msg->flags = stripCopy(&buff[17]);
|
||||
}
|
||||
}
|
||||
if (msg) writeMsgSum(folder, msg);
|
||||
if (folder->sfile) fflush(folder->sfile);
|
||||
}
|
||||
memset(fileurl, '\0', flen);
|
||||
memcpy(fileurl, rdf->url, RDF_STRLEN(rdf->url));
|
||||
aclen = RDF_STRCHR(&fileurl[10], '/');
|
||||
fileurl[aclen-fileurl] = '\0';
|
||||
RDF_STRCAT(fileurl, "/trash");
|
||||
folder->trash = fileurl;
|
||||
freeMem(buff);
|
||||
freeMem(nurl);
|
||||
/* GetPopToRDF(rdf); */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
pmGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
PRBool inversep, PRBool tv)
|
||||
{
|
||||
if ((resourceType(u) == PM_RT) && tv && (!inversep) && (type == RDF_STRING_TYPE) && (u->pdata)) {
|
||||
MM msg = (MM) u->pdata;
|
||||
if (s == gNavCenter->from) {
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )msg->from)));
|
||||
return copyString(msg->from);
|
||||
} else if (s == gNavCenter->subject) {
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )msg->subject)));
|
||||
return copyString(msg->subject);
|
||||
} else if (s == gNavCenter->date) {
|
||||
return copyString(msg->date);
|
||||
} else return NULL;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
pmGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
PRBool inversep, PRBool tv)
|
||||
{
|
||||
if ((resourceType(u) == PM_RT) && tv && (inversep) && (type == RDF_RESOURCE_TYPE)
|
||||
&& (s == gCoreVocab->RDF_parent)) {
|
||||
MF folder = (MF)rdf->pdata;
|
||||
if (folder->top == u) {
|
||||
RDF_Cursor c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct));
|
||||
c->u = u;
|
||||
c->s = s;
|
||||
c->type = type;
|
||||
c->inversep = inversep;
|
||||
c->tv = tv;
|
||||
c->count = 0;
|
||||
c->pdata = folder->msg;
|
||||
return c;
|
||||
} else return NULL;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
pmNextValue (RDFT rdf, RDF_Cursor c)
|
||||
{
|
||||
MM msg = (MM) c->pdata;
|
||||
RDF_Resource ans = NULL;
|
||||
while (msg && msgDeletedp(msg)) {
|
||||
msg = msg->next;
|
||||
}
|
||||
if (msg) {
|
||||
ans = msg->r;
|
||||
c->pdata = msg->next;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
pmDisposeCursor (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
freeMem(c);
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FILE *
|
||||
getPopMBox (RDFT db)
|
||||
{
|
||||
MF folder = (MF)db->pdata;
|
||||
return folder->mfile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
pmHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
/*this is clearly wrong, but doesn't break anything now ...*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
pmRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if ((startsWith("mailbox://", rdf->url)) && (resourceType(u) == PM_RT) && (s == gCoreVocab->RDF_parent)
|
||||
&& (type == RDF_RESOURCE_TYPE)) {
|
||||
RDF_Resource mbox = (RDF_Resource) v;
|
||||
if (!(containerp(mbox) && (resourceType(mbox) == PM_RT))) {
|
||||
return false;
|
||||
} else {
|
||||
MF folder = (MF)mbox->pdata;
|
||||
sendNotifications2(rdf, RDF_DELETE_NOTIFY, u, s, v, type, 1);
|
||||
MoveMessage(folder->trash, resourceID(mbox), (MM)u->pdata);
|
||||
return 1;
|
||||
}
|
||||
} else return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakePopDB (char* url)
|
||||
{
|
||||
if (startsWith("mailbox://", url)) {
|
||||
RDFT ntr;
|
||||
if ((ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct))) != NULL) {
|
||||
char* fileurl = getMem(100);
|
||||
PRDir* dir ;
|
||||
char* aclen;
|
||||
sprintf(fileurl, "%s%s", profileDirURL, &url[10]);
|
||||
aclen = RDF_STRCHR(&fileurl[RDF_STRLEN(profileDirURL)+1], '/');
|
||||
fileurl[aclen-fileurl] = '\0';
|
||||
dir = OpenDir(fileurl);
|
||||
if (dir == NULL) {
|
||||
if ( CallPRMkDirUsingFileURL(fileurl, 00700) > -1) dir = OpenDir(fileurl);
|
||||
}
|
||||
freeMem(fileurl);
|
||||
if (dir) {
|
||||
PR_CloseDir(dir);
|
||||
ntr->assert = NULL;
|
||||
ntr->unassert = pmRemove;
|
||||
ntr->getSlotValue = pmGetSlotValue;
|
||||
ntr->getSlotValues = pmGetSlotValues;
|
||||
ntr->hasAssertion = pmHasAssertion;
|
||||
ntr->nextValue = pmNextValue;
|
||||
ntr->disposeCursor = pmDisposeCursor;
|
||||
ntr->url = copyString(url);
|
||||
readSummaryFile(ntr);
|
||||
return ntr;
|
||||
} else {
|
||||
freeMem(ntr);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else return NULL;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeMailAccountDB (char* url)
|
||||
{
|
||||
if (startsWith("mailaccount://", url)) {
|
||||
RDFT ntr = NewRemoteStore(url);
|
||||
char* fileurl = getMem(100);
|
||||
int32 n = PR_SKIP_BOTH;
|
||||
PRDirEntry *de;
|
||||
PRDir* dir ;
|
||||
RDF_Resource top = RDF_GetResource(NULL, url, 1);
|
||||
sprintf(fileurl, "%s%s", profileDirURL, &url[14]);
|
||||
dir = OpenDir(fileurl);
|
||||
if (dir == NULL) {
|
||||
if ( CallPRMkDirUsingFileURL(fileurl, 00700) > -1) dir = OpenDir(fileurl);
|
||||
}
|
||||
while ((dir != NULL) && ((de = PR_ReadDir(dir, (PRDirFlags)(n++))) != NULL)) {
|
||||
if ((!endsWith(".ssf", de->name)) && (!endsWith(".dat", de->name)) &&
|
||||
(!endsWith(".snm", de->name)) && (!endsWith("~", de->name))) {
|
||||
RDF_Resource r;
|
||||
sprintf(fileurl, "mailbox://folder/%s/%s", &url[14], de->name);
|
||||
r = RDF_GetResource(NULL, fileurl, 1);
|
||||
setResourceType(r, PMF_RT);
|
||||
remoteStoreAdd(ntr, r, gCoreVocab->RDF_parent, top, RDF_RESOURCE_TYPE, 1);
|
||||
remoteStoreAdd(ntr, r, gCoreVocab->RDF_name, copyString(de->name), RDF_STRING_TYPE, 1);
|
||||
}
|
||||
}
|
||||
freeMem(fileurl);
|
||||
if (dir) PR_CloseDir(dir);
|
||||
return ntr;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
101
mozilla/modules/rdf/src/pm2rdf.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_PM2RDF_H_
|
||||
#define _RDF_PM2RDF_H_
|
||||
|
||||
#include "net.h"
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "prio.h"
|
||||
#include "glue.h"
|
||||
#include "utils.h"
|
||||
#include "xp_str.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/* pm2rdf.c data structures and defines */
|
||||
|
||||
#define TON(s) ((s == NULL) ? "" : s)
|
||||
|
||||
#define pmUnitp(u) ((resourceType(u) == PM_RT) || (resourceType(u) == IM_RT))
|
||||
|
||||
struct MailFolder {
|
||||
FILE *sfile;
|
||||
FILE *mfile;
|
||||
struct MailMessage* msg;
|
||||
struct MailMessage* tail;
|
||||
struct MailMessage* add;
|
||||
RDF_Resource top;
|
||||
int32 status;
|
||||
RDFT rdf;
|
||||
char* trash;
|
||||
};
|
||||
|
||||
typedef struct MailFolder* MF;
|
||||
|
||||
struct MailMessage {
|
||||
char* subject;
|
||||
char* from;
|
||||
char* date;
|
||||
int32 offset;
|
||||
char* flags;
|
||||
int32 summOffset;
|
||||
RDF_Resource r;
|
||||
struct MailMessage *next;
|
||||
};
|
||||
|
||||
typedef struct MailMessage* MM;
|
||||
|
||||
|
||||
/* pm2rdf.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
void Pop_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx);
|
||||
void GetPopToRDF (RDFT rdf);
|
||||
void PopGetNewMail (RDF_Resource r);
|
||||
char * stripCopy (char* str);
|
||||
PRBool msgDeletedp (MM msg);
|
||||
FILE * openPMFile (char* path);
|
||||
void addMsgToFolder (MF folder, MM msg);
|
||||
void RDF_StartMessageDelivery (RDFT rdf);
|
||||
char * MIW1 (const char* block, int32 len);
|
||||
void RDF_AddMessageLine (RDFT rdf, char* block, int32 length);
|
||||
void writeMsgSum (MF folder, MM msg);
|
||||
void RDF_FinishMessageDelivery (RDFT rdf);
|
||||
void setMessageFlag (RDFT rdf, RDF_Resource r, char* newFlag);
|
||||
PRBool MoveMessage (char* to, char* from, MM message);
|
||||
void readSummaryFile (RDFT rdf);
|
||||
void * pmGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor pmGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * pmNextValue (RDFT rdf, RDF_Cursor c);
|
||||
RDF_Error pmDisposeCursor (RDFT mcf, RDF_Cursor c);
|
||||
FILE * getPopMBox (RDFT db);
|
||||
PRBool pmHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool pmRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
RDFT MakePopDB (char* url);
|
||||
RDFT MakeMailAccountDB (char* url);
|
||||
|
||||
|
||||
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
432
mozilla/modules/rdf/src/qryparse.c
Normal file
@@ -0,0 +1,432 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* qryparse.c
|
||||
|
||||
A parser for queries expressed in RDF syntax.
|
||||
|
||||
There is a query tag (RDF:Query) which encloses one or more literal tags.
|
||||
It has an id (which is currently ignored).
|
||||
Literal tags (RDF:Literal) are like assertions, except they may contain variables.
|
||||
Variables are specified as hrefs, the first character of which is $.
|
||||
|
||||
The format of a literal whose range is a resource type is:
|
||||
|
||||
<RDF:Literal href=domain>
|
||||
<property href=range>
|
||||
</RDF:Literal>
|
||||
|
||||
a literal whose range is a string or int is expressed as:
|
||||
|
||||
<RDF:Literal href=domain>
|
||||
<property>string-or-int-value</property>
|
||||
</RDF:Literal>
|
||||
|
||||
Note: in order for the query engine to correctly retrieve property values
|
||||
which are strings or ints, you must add assertions about the
|
||||
property's range (otherwise it is assumed to be a resource).
|
||||
The range property may be the resource named "String", "Int", or any
|
||||
other resource.
|
||||
|
||||
For example:
|
||||
<RDF:Resource id="motto">
|
||||
<domain href="State.mcf"/>
|
||||
<range href="String"/>
|
||||
</RDF:Resource>
|
||||
|
||||
Here is an example of a query:
|
||||
|
||||
<RDF:Query id="query1">
|
||||
<result href="$result"/>
|
||||
<RDF:Literal href="$var1">
|
||||
<typeof href="Country.mcf"/>
|
||||
</RDF:Literal>
|
||||
<RDF:Literal href="$var1">
|
||||
<state href="$var2"/>
|
||||
</RDF:Literal>
|
||||
<RDF:Literal href="$var2">
|
||||
<capitalCity href="$result"/>
|
||||
</RDF:Literal>
|
||||
</RDF:Query>
|
||||
|
||||
In the Prolog-like syntax this looks like:
|
||||
typeof($var1, Country) & state($var1, $var2) & capitalCity($var2, $result)
|
||||
*/
|
||||
|
||||
#include "query.h"
|
||||
#include "rdf-int.h"
|
||||
|
||||
#define QUERY_TAG "RDF:Query"
|
||||
#define LITERAL_TAG "RDF:Literal"
|
||||
#define RESULT_TAG "RDF:result"
|
||||
#define SEQ_TAG "RDF:seq"
|
||||
#define SEQ_END_TAG "</RDF:seq>"
|
||||
#define LI_TAG "RDF:li"
|
||||
#define RDF_OBJECT 10 /* status */
|
||||
#define RDF_PROPERTY 11 /* status */
|
||||
#define RDF_SEQ 12
|
||||
#define RDF_LI 13
|
||||
#define RDF_PARSE_ERROR 5 /* this should go in rdf.h */
|
||||
|
||||
/* analogous to RDFFile */
|
||||
typedef struct _QueryParseStruct {
|
||||
uint16 status; /* whether we're parsing an object or property */
|
||||
PRBool tv; /* truth value of current literal */
|
||||
uint16 depth;
|
||||
RDF rdf;
|
||||
RDF_Query query;
|
||||
RDFElement elf;
|
||||
TermStruc stack[16];
|
||||
TermStruc* value;
|
||||
uint8 valueCount;
|
||||
uint8 valueSize;
|
||||
} QueryParseStruct;
|
||||
|
||||
extern void parseRDFElement(RDFElement elf, char* token);
|
||||
extern char* getElfProp(char* prop, RDFElement elf);
|
||||
extern PRBool variableTermp(TermStruc term);
|
||||
extern PRBool resourceTermp(TermStruc term);
|
||||
extern PRBool constantTermp(TermStruc term);
|
||||
|
||||
/* prototypes */
|
||||
PRBool variablep(char* elf);
|
||||
RDF_ValueType rangeType(RDF rdf, RDF_Resource prop);
|
||||
RDF_Error parseNextQueryToken (QueryParseStruct *q, char* token);
|
||||
RDF_Query parseQuery(RDF rdf, char* blob, int32 size);
|
||||
RDF_Error parsePropertyValue(QueryParseStruct *q, char* token);
|
||||
RDF_Error parseEndTag(QueryParseStruct *q, char* token);
|
||||
RDF_Error parseTag (QueryParseStruct *q, char* token);
|
||||
RDF_Error addValueToList(QueryParseStruct *q, void* value, RDF_TermType type);
|
||||
TermStruc* copyTermList(TermStruc* list, uint8 count);
|
||||
|
||||
PRBool variablep(char* elf) {
|
||||
return elf[0] == '$';
|
||||
}
|
||||
|
||||
/* Returns the ValueType of the range of the property specified */
|
||||
RDF_ValueType rangeType(RDF rdf, RDF_Resource prop) {
|
||||
RDF_Resource rangeType;
|
||||
if (prop == gCoreVocab->RDF_substring) return RDF_STRING_TYPE;
|
||||
else if (prop == gCoreVocab->RDF_notSubstring) return RDF_STRING_TYPE;
|
||||
else if (prop == gCoreVocab->RDF_stringEquals) return RDF_STRING_TYPE;
|
||||
else if (prop == gCoreVocab->RDF_notStringEquals) return RDF_STRING_TYPE;
|
||||
else if (prop == gCoreVocab->RDF_lessThan) return RDF_INT_TYPE;
|
||||
else if (prop == gCoreVocab->RDF_greaterThan) return RDF_INT_TYPE;
|
||||
else if (prop == gCoreVocab->RDF_lessThanOrEqual) return RDF_INT_TYPE;
|
||||
else if (prop == gCoreVocab->RDF_greaterThanOrEqual) return RDF_INT_TYPE;
|
||||
else if (prop == gCoreVocab->RDF_equals) return RDF_INT_TYPE;
|
||||
else if (prop == gCoreVocab->RDF_notEquals) return RDF_INT_TYPE;
|
||||
/* fix me - add RDF_stringEquals */
|
||||
rangeType = RDF_GetSlotValue(rdf, prop, gCoreVocab->RDF_range, RDF_RESOURCE_TYPE, false, true);
|
||||
if (rangeType == NULL) return RDF_RESOURCE_TYPE; /* don't know so assume resource */
|
||||
else if (rangeType == gCoreVocab->RDF_StringType) return RDF_STRING_TYPE;
|
||||
else if (rangeType == gCoreVocab->RDF_IntType) return RDF_INT_TYPE;
|
||||
else return RDF_RESOURCE_TYPE; /* not string or int so must be a resource */
|
||||
}
|
||||
|
||||
/* Returns query parsed from blob, NULL if there was a parsing error.
|
||||
This is adapted from parseNextRDFXMLBlob, the main differences being that
|
||||
a file structure is not maintained. blob must contain the entire query.
|
||||
*/
|
||||
RDF_Query parseQuery(RDF rdf, char* blob, int32 size) {
|
||||
RDF_Error err = noRDFErr;
|
||||
QueryParseStruct q;
|
||||
char line[LINE_SIZE];
|
||||
char holdOver[LINE_SIZE];
|
||||
int32 n, last, m;
|
||||
PRBool somethingseenp = false;
|
||||
n = last = 0;
|
||||
q.depth = 0;
|
||||
q.elf = (RDFElement)getMem(sizeof(RDFElementStruct));
|
||||
q.rdf = rdf;
|
||||
q.query = RDF_CreateQuery(rdf);
|
||||
q.tv = true;
|
||||
q.value = NULL;
|
||||
q.valueCount = 0;
|
||||
q.valueSize = 0;
|
||||
|
||||
memset(holdOver, '\0', LINE_SIZE);
|
||||
while (n < size) {
|
||||
char c = blob[n];
|
||||
m = 0;
|
||||
somethingseenp = false;
|
||||
memset(line, '\0', LINE_SIZE);
|
||||
if (holdOver[0] != '\0') {
|
||||
memcpy(line, holdOver, RDF_STRLEN(holdOver));
|
||||
m = RDF_STRLEN(holdOver);
|
||||
somethingseenp = true;
|
||||
memset(holdOver, '\0', LINE_SIZE);
|
||||
}
|
||||
while ((m < 300) && (c != '<') && (c != '>')) {
|
||||
line[m] = c;
|
||||
m++;
|
||||
somethingseenp = (somethingseenp || ((c != ' ') && (c != '\r') && (c != '\n')));
|
||||
n++;
|
||||
if (n < size) c = blob[n];
|
||||
else break;
|
||||
}
|
||||
if (c == '>') line[m] = c;
|
||||
n++;
|
||||
if (m > 0) {
|
||||
if ((c == '<') || (c == '>')) {
|
||||
last = n;
|
||||
if (c == '<') holdOver[0] = '<';
|
||||
if (somethingseenp == true) {
|
||||
err = parseNextQueryToken(&q, line);
|
||||
if (err != noRDFErr) {
|
||||
if (q.query != NULL) RDF_DestroyQuery(q.query);
|
||||
q.query = NULL;
|
||||
break; /* while (n < size) */
|
||||
}
|
||||
}
|
||||
} else if (size > last) {
|
||||
memcpy(holdOver, line, m);
|
||||
}
|
||||
} else if (c == '<') holdOver[0] = '<';
|
||||
}
|
||||
if (q.elf != NULL) freeMem(q.elf);
|
||||
return q.query;
|
||||
}
|
||||
|
||||
RDF_Error addValueToList(QueryParseStruct *q, void* value, RDF_TermType type) {
|
||||
RDF_Error err = noRDFErr;
|
||||
int increment = 5;
|
||||
if (q->valueSize == q->valueCount) {
|
||||
TermStruc* old = q->value;
|
||||
TermStruc* newTermList = (TermStruc*)getMem((q->valueSize + increment) * sizeof(TermStruc));
|
||||
if (newTermList == NULL) return RDF_NO_MEMORY;
|
||||
memcpy((char*)newTermList, (char*)q->value, (q->valueSize)* sizeof(TermStruc));
|
||||
q->value = newTermList;
|
||||
q->valueSize = q->valueSize + increment;
|
||||
freeMem(old);
|
||||
}
|
||||
(q->value + q->valueCount)->value = value;
|
||||
(q->value + q->valueCount)->type = type;
|
||||
q->valueCount++;
|
||||
return err;
|
||||
}
|
||||
|
||||
TermStruc* copyTermList(TermStruc* list, uint8 count) {
|
||||
TermStruc* newList = (TermStruc*)getMem(count * sizeof(TermStruc));
|
||||
if (newList == NULL) return NULL;
|
||||
memcpy((char*)newList, (char*)list, count * sizeof(TermStruc));
|
||||
return newList;
|
||||
}
|
||||
|
||||
RDF_Error parsePropertyValue(QueryParseStruct *q, char* token) {
|
||||
RDF_Error err = noRDFErr;
|
||||
if ((q->depth == 3) && (q->status == RDF_PROPERTY)) {
|
||||
/* parse the property value */
|
||||
RDF_Resource slot = (RDF_Resource)q->stack[q->depth-1].value;
|
||||
RDF_ValueType type = rangeType(q->rdf, slot);
|
||||
TermStruc unitTerm = q->stack[q->depth-2];
|
||||
switch (type) { /* switch on value type of property */
|
||||
int i;
|
||||
case RDF_RESOURCE_TYPE:
|
||||
err = RDF_PARSE_ERROR;
|
||||
break;
|
||||
case RDF_STRING_TYPE:
|
||||
if (variablep(token)) {
|
||||
RDF_Variable rangeVar = RDF_GetVariable(q->query, token);
|
||||
if (variableTermp(unitTerm))
|
||||
err = RDF_AddConjunctVRV(q->query, (RDF_Variable)unitTerm.value, slot, rangeVar, type);
|
||||
else err = RDF_AddConjunctRRV(q->query, (RDF_Resource)unitTerm.value, slot, rangeVar, type);
|
||||
} else if (variableTermp(unitTerm)) {
|
||||
err = RDF_AddConjunctVRO(q->query, (RDF_Variable)unitTerm.value, slot, (void*)token, type);
|
||||
} else err = RDF_AddConjunctRRO(q->query, (RDF_Resource)unitTerm.value, slot, (void*)token, type);
|
||||
break;
|
||||
case RDF_INT_TYPE:
|
||||
if (variablep(token)) {
|
||||
RDF_Variable rangeVar = RDF_GetVariable(q->query, token);
|
||||
if (variableTermp(unitTerm))
|
||||
err = RDF_AddConjunctVRV(q->query, (RDF_Variable)unitTerm.value, slot, rangeVar, type);
|
||||
else err = RDF_AddConjunctRRV(q->query, (RDF_Resource)unitTerm.value, slot, rangeVar, type);
|
||||
} else if (sscanf(token, "%d", &i) == 1) { /* fix me */
|
||||
if (variableTermp(unitTerm)) {
|
||||
err = RDF_AddConjunctVRO(q->query, (RDF_Variable)unitTerm.value, slot, (void*)i, type);
|
||||
} else err = RDF_AddConjunctRRO(q->query, (RDF_Resource)unitTerm.value, slot, (void*)i, type);
|
||||
} else err = RDF_PARSE_ERROR;
|
||||
break;
|
||||
default:
|
||||
err = RDF_PARSE_ERROR; /* should never get here */
|
||||
break;
|
||||
}
|
||||
} else if (q->status == RDF_LI) {
|
||||
RDF_Resource slot = (RDF_Resource)q->stack[q->depth-3].value;
|
||||
RDF_ValueType type = rangeType(q->rdf, slot);
|
||||
switch (type) {
|
||||
int i;
|
||||
case RDF_RESOURCE_TYPE:
|
||||
err = RDF_PARSE_ERROR;
|
||||
break;
|
||||
case RDF_STRING_TYPE:
|
||||
if (variablep(token))
|
||||
err = addValueToList(q, RDF_GetVariable(q->query, token), RDF_VARIABLE_TERM_TYPE);
|
||||
else err = addValueToList(q, copyString(token), RDF_CONSTANT_TERM_TYPE);
|
||||
break;
|
||||
case RDF_INT_TYPE:
|
||||
if (variablep(token)) {
|
||||
err = addValueToList(q, RDF_GetVariable(q->query, token), RDF_VARIABLE_TERM_TYPE);
|
||||
} else if (sscanf(token, "%d", &i) == 1) { /* fix me */
|
||||
err = addValueToList(q, (void*)i, RDF_CONSTANT_TERM_TYPE);
|
||||
} else err = RDF_PARSE_ERROR;
|
||||
break;
|
||||
default:
|
||||
err = RDF_PARSE_ERROR; /* should never get here */
|
||||
break;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
RDF_Error parseTag (QueryParseStruct *q, char* token) {
|
||||
RDF_Error err = noRDFErr;
|
||||
RDFElement elf = q->elf;
|
||||
memset((char*)elf, '\0', sizeof(RDFElementStruct));
|
||||
parseRDFElement(elf, token);
|
||||
|
||||
/* the block can start with Query, Literal or a property name */
|
||||
|
||||
if (startsWith(QUERY_TAG, elf->tagName)) {
|
||||
char* url = getElfProp("id", elf);
|
||||
/* don't have anything to do with id right now */
|
||||
q->stack[q->depth++].value = (void*)NULL;
|
||||
q->status = RDF_OBJECT;
|
||||
} else if (startsWith(LITERAL_TAG, elf->tagName)) {
|
||||
char* domain = getElfProp("href", elf);
|
||||
if (variablep(domain)) {
|
||||
q->stack[q->depth].value = RDF_GetVariable(q->query, domain);
|
||||
q->stack[q->depth].type = RDF_VARIABLE_TERM_TYPE;
|
||||
q->depth++;
|
||||
} else {
|
||||
q->stack[q->depth].value = resourceFromID(domain, true);
|
||||
q->stack[q->depth].type = RDF_RESOURCE_TERM_TYPE;
|
||||
q->depth++;
|
||||
}
|
||||
q->status = RDF_OBJECT;
|
||||
/*
|
||||
if (stringEquals(LITERAL_NEGATION_TAG, elf->tagName))
|
||||
q->tv = false;
|
||||
else q->tv = true;
|
||||
*/
|
||||
} else if (stringEquals(elf->tagName, RESULT_TAG) && (q->depth == 1)) {
|
||||
/* set a result variable */
|
||||
char* range = getElfProp("href", elf);
|
||||
RDF_Variable resultVar = RDF_GetVariable(q->query, range);
|
||||
RDF_SetResultVariable(resultVar, true);
|
||||
q->status = RDF_OBJECT;
|
||||
} else if (stringEquals(elf->tagName, SEQ_TAG) && (q->depth == 3)) {
|
||||
/* ignore stack value */
|
||||
q->depth++;
|
||||
q->status = RDF_SEQ;
|
||||
q->valueSize = 10;
|
||||
q->valueCount = 0;
|
||||
q->value = (TermStruc*)getMem(q->valueSize * sizeof(TermStruc));
|
||||
if (q->value == NULL) err = RDF_PARSE_ERROR;
|
||||
} else if (stringEquals(elf->tagName, LI_TAG) && (q->depth == 4)) {
|
||||
/* ignore stack value */
|
||||
if (elf->emptyTagp) { /* <RDF:li href="$var"/> */
|
||||
char* range = getElfProp("href", elf);
|
||||
RDF_Resource slot = (RDF_Resource)q->stack[q->depth-2].value;
|
||||
RDF_ValueType type = rangeType(q->rdf, slot);
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
if (variablep(range)) {
|
||||
err = addValueToList(q, RDF_GetVariable(q->query, range), RDF_VARIABLE_TERM_TYPE);
|
||||
} else err = addValueToList(q, resourceFromID(range, true), RDF_RESOURCE_TERM_TYPE);
|
||||
} else err = RDF_PARSE_ERROR;
|
||||
} else { /* <RDF:li> */
|
||||
q->depth++;
|
||||
q->status = RDF_LI;
|
||||
}
|
||||
} else if (q->depth != 1) { /* property */
|
||||
char* pname = elf->tagName;
|
||||
RDF_Resource slot = resourceFromID(pname, true);
|
||||
if (elf->emptyTagp) {
|
||||
char* range = getElfProp("href", elf);
|
||||
RDF_ValueType type = rangeType(q->rdf, slot);
|
||||
TermStruc unitTerm = q->stack[q->depth-1];
|
||||
switch (type) { /* switch on value type of property */
|
||||
case RDF_RESOURCE_TYPE:
|
||||
if (variablep(range)) {
|
||||
RDF_Variable rangeVar = RDF_GetVariable(q->query, range);
|
||||
if (variableTermp(unitTerm)) {
|
||||
err = RDF_AddConjunctVRV(q->query, (RDF_Variable)unitTerm.value, slot, rangeVar, type);
|
||||
} else {
|
||||
err = RDF_AddConjunctRRV(q->query, (RDF_Resource)unitTerm.value, slot, rangeVar, type);
|
||||
}
|
||||
} else {
|
||||
RDF_Resource rangeRsrc = resourceFromID(range, true);
|
||||
if (variableTermp(unitTerm)) {
|
||||
/* RDF_AddConjunctVRR */
|
||||
err = RDF_AddConjunctVRR(q->query, (RDF_Variable)unitTerm.value, slot, rangeRsrc);
|
||||
} else err = RDF_PARSE_ERROR;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
err = RDF_PARSE_ERROR; /* strings and ints cannot be inside href */
|
||||
break;
|
||||
}
|
||||
q->status = RDF_OBJECT;
|
||||
} else {
|
||||
/* this isn't really a term, its just a property but we access it in the same way as a term */
|
||||
q->stack[q->depth].value = slot;
|
||||
q->stack[q->depth].type = RDF_RESOURCE_TERM_TYPE;
|
||||
q->depth++;
|
||||
q->status = RDF_PROPERTY;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
RDF_Error parseEndTag(QueryParseStruct *q, char* token) {
|
||||
RDF_Error err = noRDFErr;
|
||||
if (stringEquals(SEQ_END_TAG, token)) {
|
||||
RDF_Resource slot = (RDF_Resource)q->stack[q->depth-2].value;
|
||||
RDF_ValueType type = rangeType(q->rdf, slot);
|
||||
TermStruc unitTerm = q->stack[q->depth-3];
|
||||
/* copy the value list, add the conjunct, and destroy the list - the engine destroys the copy. */
|
||||
TermStruc* copy = copyTermList(q->value, q->valueCount);
|
||||
if (copy == NULL) return RDF_NO_MEMORY;
|
||||
err = RDF_AddConjunctVRL(q->query, (RDF_Variable)unitTerm.value, slot, (RDF_Term)copy, type, q->valueCount);
|
||||
q->valueCount = q->valueSize = 0;
|
||||
freeMem(q->value);
|
||||
}
|
||||
if (q->depth == 0) return RDF_PARSE_ERROR;
|
||||
q->depth--;
|
||||
if (q->status == RDF_OBJECT)
|
||||
q->status = RDF_PROPERTY;
|
||||
else if (q->status == RDF_LI)
|
||||
q->status = RDF_SEQ;
|
||||
else if (q->status == RDF_SEQ)
|
||||
q->status = RDF_OBJECT; /* also terminates the property */
|
||||
return err;
|
||||
}
|
||||
|
||||
/* this is adapted from parseNextRDFToken, the difference being in the actions. */
|
||||
RDF_Error parseNextQueryToken (QueryParseStruct *q, char* token) {
|
||||
RDF_Error err = noRDFErr;
|
||||
if (token[0] == '\n' || token[0] == '\r') return err;
|
||||
if (token[0] != '<') {
|
||||
err = parsePropertyValue(q, token);
|
||||
} else if (token[1] == '/') {
|
||||
err = parseEndTag(q, token);
|
||||
} else {
|
||||
err = parseTag(q, token);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
651
mozilla/modules/rdf/src/query.c
Normal file
@@ -0,0 +1,651 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements query support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#ifdef XP_PC
|
||||
#define strcasecomp RDF_STRCMP
|
||||
#endif
|
||||
|
||||
#include "query.h"
|
||||
#include "rdf-int.h"
|
||||
|
||||
/* prototypes */
|
||||
PRBool variableTermp(TermStruc term);
|
||||
PRBool resourceTermp(TermStruc term);
|
||||
PRBool constantTermp(TermStruc term);
|
||||
RDF_Error addVariableToList(RDF_Variable variable, RDF_VariableList *list);
|
||||
void destroyVariableList(RDF_VariableList list, PRBool destroyVariables);
|
||||
void destroyLiteralList(RDF_LiteralList list, PRBool destroyLiterals);
|
||||
PRBool comparisonp(RDF_Resource r);
|
||||
PRBool specialResourcePredicate(RDF_Resource r);
|
||||
PRBool findLiteral(RDF_Literal target, RDF_LiteralList list);
|
||||
RDF_Literal getNthLiteral(RDF_Query q, uint16 index);
|
||||
PRBool constantp(TermStruc term, RDF_VariableList knownVars);
|
||||
RDF_Literal oneUnknownAs(RDF_Query q, RDF_LiteralList orderedLiterals, RDF_VariableList knownVars);
|
||||
RDF_Literal noUnknownAs(RDF_Query q, RDF_LiteralList orderedLiterals, RDF_VariableList knownVars);
|
||||
PRBool orderConjuncts(RDF_Query q);
|
||||
PRBool processNextLiteral(RDF_Query q, RDF_Literal literal);
|
||||
void addLiteral(RDF_Query q, RDF_Literal literal);
|
||||
|
||||
/* Variable API */
|
||||
PR_PUBLIC_API(PRBool) RDF_IsResultVariable(RDF_Variable var) {
|
||||
return var->isResult;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(void) RDF_SetResultVariable(RDF_Variable var, PRBool isResult) {
|
||||
var->isResult = isResult;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(void*) RDF_GetVariableValue(RDF_Variable var) {
|
||||
if (var->query->queryRunning)
|
||||
return var->value;
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(void) RDF_SetVariableValue(RDF_Variable var, void* value, RDF_ValueType type) {
|
||||
if (!var->query->queryRunning) var->query->conjunctsOrdered = false;
|
||||
var->value = value;
|
||||
var->type = type;
|
||||
}
|
||||
|
||||
PRBool variableTermp(TermStruc term) {
|
||||
return term.type == RDF_VARIABLE_TERM_TYPE;
|
||||
}
|
||||
|
||||
PRBool resourceTermp(TermStruc term) {
|
||||
return term.type == RDF_RESOURCE_TERM_TYPE;
|
||||
}
|
||||
|
||||
PRBool constantTermp(TermStruc term) {
|
||||
return term.type == RDF_CONSTANT_TERM_TYPE;
|
||||
}
|
||||
|
||||
/* Adds the variable to the variable list if it isn't already on the list. */
|
||||
RDF_Error addVariableToList(RDF_Variable variable, RDF_VariableList *list) {
|
||||
PRBool found = false;
|
||||
RDF_VariableList current = *list;
|
||||
while (current != NULL) {
|
||||
if (current->element == variable) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
if (!found) {
|
||||
RDF_VariableList newlist = (RDF_VariableList)getMem(sizeof(RDF_VariableListStruc));
|
||||
if (newlist == NULL) return RDF_NO_MEMORY;
|
||||
newlist->element = variable;
|
||||
newlist->next = *list;
|
||||
*list = newlist;
|
||||
}
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
void destroyVariableList(RDF_VariableList list, PRBool destroyVariables) {
|
||||
if (list != NULL) {
|
||||
destroyVariableList(list->next, destroyVariables);
|
||||
if (destroyVariables) freeMem(list->element); /* free the variable */
|
||||
freeMem(list); /* free the list structure */
|
||||
}
|
||||
}
|
||||
|
||||
void destroyLiteralList(RDF_LiteralList list, PRBool destroyLiterals) {
|
||||
if (list != NULL) {
|
||||
destroyLiteralList(list->next, destroyLiterals);
|
||||
if (destroyLiterals) {
|
||||
RDF_Literal literal = list->element;
|
||||
if (literal->c != NULL) RDF_DisposeCursor(literal->c);
|
||||
if (literal->valueType == RDF_STRING_TYPE) {
|
||||
int i;
|
||||
for (i = 0; i < literal->valueCount; i++) {
|
||||
TermStruc term = *(literal->v + i);
|
||||
if (constantTermp(term)) freeMem(term.value);
|
||||
}
|
||||
}
|
||||
freeMem(literal->v);
|
||||
freeMem(list->element); /* free the literal */
|
||||
}
|
||||
freeMem(list); /* free the list structure */
|
||||
}
|
||||
}
|
||||
|
||||
PRBool comparisonp(RDF_Resource r) {
|
||||
return (r == gCoreVocab->RDF_substring ||
|
||||
r == gCoreVocab->RDF_notSubstring ||
|
||||
r == gCoreVocab->RDF_lessThan ||
|
||||
r == gCoreVocab->RDF_greaterThan ||
|
||||
r == gCoreVocab->RDF_lessThanOrEqual ||
|
||||
r == gCoreVocab->RDF_greaterThanOrEqual ||
|
||||
r == gCoreVocab->RDF_equals ||
|
||||
r == gCoreVocab->RDF_notEquals ||
|
||||
r == gCoreVocab->RDF_stringEquals ||
|
||||
r == gCoreVocab->RDF_notStringEquals);
|
||||
}
|
||||
|
||||
PRBool specialResourcePredicate(RDF_Resource r) {
|
||||
return (r == gCoreVocab->RDF_notInstanceOf || r == gCoreVocab->RDF_notParent);
|
||||
}
|
||||
|
||||
/* Creates and initializes a query. Returns NULL if not enough memory. */
|
||||
PR_PUBLIC_API(RDF_Query) RDF_CreateQuery(RDF rdf) {
|
||||
RDF_Query q = (RDF_Query)getMem(sizeof(RDF_QueryStruc));
|
||||
if (q == NULL) return q;
|
||||
q->variables = NULL;
|
||||
q->literals = NULL;
|
||||
q->numLiterals = 0;
|
||||
q->index = 0;
|
||||
q->conjunctsOrdered = false;
|
||||
q->queryRunning = false;
|
||||
q->rdf = rdf;
|
||||
return q;
|
||||
}
|
||||
|
||||
/* Destroys a query. */
|
||||
PR_PUBLIC_API(void) RDF_DestroyQuery(RDF_Query q) {
|
||||
destroyLiteralList(q->literals, true); /* free the literals */
|
||||
q->literals = NULL;
|
||||
destroyVariableList(q->variables, true); /* free the variables */
|
||||
q->variables = NULL;
|
||||
freeMem(q); /* free the query */
|
||||
q = NULL;
|
||||
}
|
||||
|
||||
/* Returns the variable with the given name in the query.
|
||||
If not found:
|
||||
if the query is running, return NULL
|
||||
otherwise create a new variable with the given name.
|
||||
if there isn't enough memory, return NULL.
|
||||
*/
|
||||
PR_PUBLIC_API(RDF_Variable) RDF_GetVariable(RDF_Query q, char* name) {
|
||||
RDF_Variable newvar;
|
||||
RDF_VariableList newlist;
|
||||
RDF_VariableList current = q->variables;
|
||||
while (current != NULL) {
|
||||
if (stringEquals(current->element->id, name)) return current->element;
|
||||
if (current->next == NULL) break;
|
||||
else current = current->next;
|
||||
}
|
||||
if (q->queryRunning) return NULL;
|
||||
newvar = (RDF_Variable)getMem(sizeof(RDF_VariableStruc));
|
||||
if (newvar == NULL) return NULL;
|
||||
newvar->id = copyString(name);
|
||||
newvar->query = q;
|
||||
/* create a list containing the variable and append it to the front of the variable list */
|
||||
newlist = (RDF_VariableList)getMem(sizeof(RDF_VariableListStruc));
|
||||
if (newlist == NULL) {
|
||||
freeMem(newvar);
|
||||
return NULL;
|
||||
}
|
||||
newlist->element = newvar;
|
||||
newlist->next = q->variables;
|
||||
q->variables = newlist;
|
||||
return newvar;
|
||||
}
|
||||
|
||||
/* Returns the number of variables in the query. */
|
||||
PR_PUBLIC_API(uint16) RDF_GetVariableListCount(RDF_Query q) {
|
||||
RDF_VariableList current = q->variables;
|
||||
uint16 count = 0;
|
||||
while (current != NULL) {
|
||||
current = current->next;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Returns the variables belonging to the query at the given index. */
|
||||
PR_PUBLIC_API(RDF_Variable) RDF_GetNthVariable(RDF_Query q, uint16 index) {
|
||||
RDF_VariableList current = q->variables;
|
||||
uint16 count = 0;
|
||||
while (current != NULL) {
|
||||
if (count == index)
|
||||
return current->element;
|
||||
else {
|
||||
current = current->next;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Returns true if target is found in literal */
|
||||
PRBool findLiteral(RDF_Literal target, RDF_LiteralList list) {
|
||||
while (list != NULL) {
|
||||
if (list->element == target) return true;
|
||||
else list = list->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Returns the literal belonging to the query at the given index. */
|
||||
RDF_Literal getNthLiteral(RDF_Query q, uint16 index) {
|
||||
RDF_LiteralList current = q->literals;
|
||||
uint16 count = 0;
|
||||
while (current != NULL) {
|
||||
if (count == index)
|
||||
return current->element;
|
||||
else {
|
||||
current = current->next;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* A term is constant if it is not a variable, if it is a variable with
|
||||
a non-null value, or if it is a known variable.
|
||||
*/
|
||||
PRBool constantp(TermStruc term, RDF_VariableList knownVars) {
|
||||
if (term.type != RDF_VARIABLE_TERM_TYPE) return true;
|
||||
else {
|
||||
RDF_Variable var = (RDF_Variable)term.value;
|
||||
if (var->value != NULL) return true;
|
||||
else {
|
||||
while (knownVars != NULL) {
|
||||
if (knownVars->element == var) return true;
|
||||
knownVars = knownVars->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns a literal with a constant term which has not been ordered yet. */
|
||||
RDF_Literal oneUnknownAs(RDF_Query q, RDF_LiteralList orderedLiterals, RDF_VariableList knownVars) {
|
||||
RDF_LiteralList list = q->literals;
|
||||
RDF_Literal answer = NULL;
|
||||
while (list != NULL) {
|
||||
RDF_Literal current = list->element;
|
||||
if (!findLiteral(current, orderedLiterals)) {
|
||||
if (((constantp(current->u, knownVars)) || (constantp(*current->v, knownVars))) &&
|
||||
current->valueCount == 1 && /* no disjunctions */
|
||||
!comparisonp(current->s) && /* comparisons must have constant terms */
|
||||
!specialResourcePredicate(current->s) /* notTypeOf and notParent must have constant terms */
|
||||
/* && current->tv == true */) {
|
||||
if (answer == NULL) {
|
||||
answer = current;
|
||||
} else {
|
||||
/* fix me - deal with branching factor */
|
||||
answer = current;
|
||||
}
|
||||
}
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/* Returns a literal with both terms constant which has not been ordered yet. */
|
||||
RDF_Literal noUnknownAs(RDF_Query q, RDF_LiteralList orderedLiterals, RDF_VariableList knownVars) {
|
||||
RDF_LiteralList list = q->literals;
|
||||
while (list != NULL) {
|
||||
RDF_Literal current = list->element;
|
||||
if (!findLiteral(current, orderedLiterals) &&
|
||||
constantp(current->u, knownVars)) {
|
||||
int i;
|
||||
PRBool foundNonConstant = false;
|
||||
for (i = 0; i < current->valueCount; i++) { /* all values constant? */
|
||||
TermStruc term = *(current->v + i);
|
||||
if (!constantp(term, knownVars)) foundNonConstant = true;
|
||||
}
|
||||
if (foundNonConstant) list = list->next;
|
||||
else return current;
|
||||
}
|
||||
else list = list->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Returns true if the conjuncts were ordered succesfully.
|
||||
*/
|
||||
PRBool orderConjuncts(RDF_Query q) {
|
||||
uint16 numOrdered = 0;
|
||||
RDF_Error err = noRDFErr;
|
||||
RDF_LiteralList orderedLiterals = NULL;
|
||||
RDF_LiteralList orderedLiteralsTail = orderedLiterals;
|
||||
RDF_VariableList knownVars = NULL;
|
||||
|
||||
if (q->conjunctsOrdered) return true;
|
||||
|
||||
while (numOrdered < q->numLiterals) {
|
||||
RDF_Literal lit1 = noUnknownAs(q, orderedLiterals, knownVars);
|
||||
if (lit1 != NULL) {
|
||||
/* add literal to ordered list */
|
||||
RDF_LiteralList newlist = (RDF_LiteralList)getMem(sizeof(RDF_LiteralListStruc));
|
||||
if (newlist == NULL) break;
|
||||
newlist->element = lit1;
|
||||
newlist->next = NULL;
|
||||
if (orderedLiterals == NULL)
|
||||
orderedLiterals = orderedLiteralsTail = newlist;
|
||||
else {
|
||||
orderedLiteralsTail->next = newlist;
|
||||
orderedLiteralsTail = orderedLiteralsTail->next;
|
||||
}
|
||||
numOrdered++;
|
||||
} else {
|
||||
RDF_Literal lit2 = oneUnknownAs(q, orderedLiterals, knownVars);
|
||||
if (lit2 != NULL) {
|
||||
RDF_LiteralList newlist = (RDF_LiteralList)getMem(sizeof(RDF_LiteralListStruc));
|
||||
if (newlist == NULL) break;
|
||||
/* add unit and value as known variables */
|
||||
lit2->variable = (RDF_Variable) (constantp(lit2->u, knownVars) ? lit2->v->value : lit2->u.value);
|
||||
if (variableTermp(lit2->u)) {
|
||||
err = addVariableToList((RDF_Variable)lit2->u.value, &knownVars);
|
||||
if (err != noRDFErr) break;
|
||||
}
|
||||
if (variableTermp(*lit2->v)) {
|
||||
err = addVariableToList((RDF_Variable)lit2->v->value, &knownVars);
|
||||
if (err != noRDFErr) break;
|
||||
}
|
||||
/* add literal to ordered list */
|
||||
newlist->element = lit2;
|
||||
newlist->next = NULL;
|
||||
if (orderedLiterals == NULL)
|
||||
orderedLiterals = orderedLiteralsTail = newlist;
|
||||
else {
|
||||
orderedLiteralsTail->next = newlist;
|
||||
orderedLiteralsTail = orderedLiteralsTail->next;
|
||||
}
|
||||
numOrdered++;
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
if (numOrdered == q->numLiterals) { /* ordered all succesfully so replace literals */
|
||||
RDF_LiteralList old = q->literals;
|
||||
q->literals = orderedLiterals;
|
||||
destroyLiteralList(old, false);
|
||||
q->conjunctsOrdered = true;
|
||||
} else { /* unsuccessful so destroy ordered list structure */
|
||||
destroyLiteralList(orderedLiterals, false);
|
||||
q->conjunctsOrdered = false;
|
||||
}
|
||||
destroyVariableList(knownVars, false); /* free the knownVars list structure */
|
||||
return q->conjunctsOrdered;
|
||||
}
|
||||
|
||||
PRBool processNextLiteral(RDF_Query q, RDF_Literal literal) {
|
||||
if (literal->c != NULL) {
|
||||
RDF_SetVariableValue(literal->variable, RDF_NextValue(literal->c), literal->valueType);
|
||||
return (RDF_GetVariableValue(literal->variable) != NULL);
|
||||
} else {
|
||||
RDF_Resource u; /* unit is a resource except for the comparison case so don't set it yet. */
|
||||
RDF_Resource s = literal->s;
|
||||
void* v;
|
||||
if (literal->variable == NULL) {
|
||||
PRBool result = false;
|
||||
PRBool ans = false;
|
||||
int i;
|
||||
if (literal->bt) return false;
|
||||
/* find a value that satisfies predicate */
|
||||
for (i = 0; i < literal->valueCount; i++) {
|
||||
TermStruc valueTerm = *(literal->v + i);
|
||||
if (comparisonp(s)) {
|
||||
/* unit is a variable in all comparisons.
|
||||
value may be a variable or a constant.
|
||||
*/
|
||||
switch (literal->valueType) {
|
||||
char *str, *pattern;
|
||||
int i, j;
|
||||
case RDF_STRING_TYPE:
|
||||
if (literal->u.type != RDF_VARIABLE_TERM_TYPE) return false; /* error */
|
||||
if (((RDF_Variable)literal->u.value)->type != RDF_STRING_TYPE) return false;
|
||||
str = (char*)RDF_GetVariableValue((RDF_Variable)literal->u.value);
|
||||
switch (valueTerm.type) {
|
||||
case RDF_VARIABLE_TERM_TYPE:
|
||||
pattern = (char*)RDF_GetVariableValue((RDF_Variable)valueTerm.value);
|
||||
break;
|
||||
case RDF_CONSTANT_TERM_TYPE:
|
||||
pattern = (char*)valueTerm.value;
|
||||
break;
|
||||
default:
|
||||
/* should blow up */
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
if (s == gCoreVocab->RDF_stringEquals) {
|
||||
ans = stringEquals(pattern, str);
|
||||
} else if (s == gCoreVocab->RDF_substring) {
|
||||
ans = substring(pattern, str);
|
||||
} else if (s == gCoreVocab->RDF_notStringEquals) {
|
||||
ans = !stringEquals(pattern, str);
|
||||
} else if (s == gCoreVocab->RDF_notSubstring) {
|
||||
ans = !substring(pattern, str);
|
||||
} else return false; /* error */
|
||||
break;
|
||||
case RDF_INT_TYPE:
|
||||
if (literal->u.type != RDF_VARIABLE_TERM_TYPE) return false; /* error */
|
||||
if (((RDF_Variable)literal->u.value)->type != RDF_INT_TYPE) return false;
|
||||
i = (int)RDF_GetVariableValue((RDF_Variable)literal->u.value);
|
||||
switch (valueTerm.type) {
|
||||
case RDF_VARIABLE_TERM_TYPE:
|
||||
j = (int)RDF_GetVariableValue((RDF_Variable)valueTerm.value);
|
||||
break;
|
||||
case RDF_CONSTANT_TERM_TYPE:
|
||||
j = (int)valueTerm.value;
|
||||
break;
|
||||
default:
|
||||
/* should blow up */
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
if (s == gCoreVocab->RDF_equals) {
|
||||
ans = (i == j);
|
||||
} else if (s == gCoreVocab->RDF_notEquals) {
|
||||
ans = (i != j);
|
||||
} else if (s == gCoreVocab->RDF_lessThan) {
|
||||
ans = (i < j);
|
||||
} else if (s == gCoreVocab->RDF_greaterThan) {
|
||||
ans = (i > j);
|
||||
} else if (s == gCoreVocab->RDF_lessThanOrEqual) {
|
||||
ans = (i <= j);
|
||||
} else if (s == gCoreVocab->RDF_greaterThanOrEqual) {
|
||||
ans = (i >= j);
|
||||
} else return false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
u = (RDF_Resource)((variableTermp(literal->u)) ? ((RDF_Variable)literal->u.value)->value : literal->u.value);
|
||||
/* special predicates */
|
||||
if (s == gCoreVocab->RDF_notInstanceOf) {
|
||||
ans = !RDF_HasAssertion(q->rdf, u, gCoreVocab->RDF_instanceOf, valueTerm.value, literal->valueType, true);
|
||||
} else if (s == gCoreVocab->RDF_notParent) {
|
||||
ans = !RDF_HasAssertion(q->rdf, u, gCoreVocab->RDF_parent, valueTerm.value, literal->valueType, true);
|
||||
} else ans = RDF_HasAssertion(q->rdf, u, s, valueTerm.value, literal->valueType, true);
|
||||
}
|
||||
literal->bt = true;
|
||||
/* result = ((literal->tv == true) ? ans : !ans); */
|
||||
result = ans;
|
||||
if (result) return result; /* otherwise try next value */
|
||||
}
|
||||
return result;
|
||||
}
|
||||
u = (RDF_Resource)((variableTermp(literal->u)) ? ((RDF_Variable)literal->u.value)->value : literal->u.value);
|
||||
v = (variableTermp(*literal->v)) ? ((RDF_Variable)literal->v->value)->value : literal->v->value;
|
||||
if ((u == NULL) && variableTermp(literal->u) && resourceTermp(*literal->v)) {
|
||||
literal->c = RDF_GetSources(q->rdf, (RDF_Resource)v, s, literal->valueType, true);
|
||||
if (literal->c == NULL) return false;
|
||||
RDF_SetVariableValue(literal->variable, RDF_NextValue(literal->c), literal->valueType);
|
||||
return (RDF_GetVariableValue(literal->variable) != NULL);
|
||||
} else if ((v == NULL) && variableTermp(*literal->v) && (u != NULL)) {
|
||||
literal->c = RDF_GetTargets(q->rdf, u, s, literal->valueType, true); /* note arg order differs from java implementation */
|
||||
if (literal->c == NULL) return false;
|
||||
RDF_SetVariableValue(literal->variable, RDF_NextValue(literal->c), literal->valueType);
|
||||
return (RDF_GetVariableValue(literal->variable) != NULL);
|
||||
} else return false;
|
||||
}
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(PRBool) RDF_RunQuery (RDF_Query q) {
|
||||
q->queryRunning = true;
|
||||
orderConjuncts(q);
|
||||
if (q->conjunctsOrdered)
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(PRBool) RDF_GetNextElement(RDF_Query q) {
|
||||
if (!q->queryRunning) RDF_RunQuery(q);
|
||||
if (q->index == q->numLiterals) q->index--;
|
||||
while (q->index < q->numLiterals) {
|
||||
RDF_Literal lit = getNthLiteral(q, q->index); /* we know it's it range so don't have to check for NULL */
|
||||
if (!processNextLiteral(q, lit)) {
|
||||
if (q->index == 0) return false;
|
||||
lit->c = NULL;
|
||||
if (lit->variable != NULL) RDF_SetVariableValue(lit->variable, (void*)NULL, RDF_RESOURCE_TYPE);
|
||||
lit->bt = false;
|
||||
q->index--;
|
||||
} else {
|
||||
q->index++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(void) RDF_EndQuery (RDF_Query q) {
|
||||
q->queryRunning = false;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(RDF_VariableList) RDF_GetVariableList(RDF_Query q) {
|
||||
return q->variables;
|
||||
}
|
||||
|
||||
/* Note: should put a test for overflow of numLiterals */
|
||||
|
||||
/* Adds a literal to the query. */
|
||||
void addLiteral(RDF_Query q, RDF_Literal literal) {
|
||||
RDF_LiteralList newlist = (RDF_LiteralList)getMem(sizeof(RDF_LiteralListStruc));
|
||||
if (newlist == NULL) return;
|
||||
newlist->element = literal;
|
||||
newlist->next = q->literals;
|
||||
q->literals = newlist;
|
||||
q->numLiterals++;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRV(RDF_Query q, RDF_Variable arg1, RDF_Resource s, RDF_Variable arg2, RDF_ValueType type) {
|
||||
RDF_Literal literal = (RDF_Literal)getMem(sizeof(LiteralStruc));
|
||||
if (literal == NULL) return RDF_NO_MEMORY;
|
||||
literal->u.value = (void*)arg1;
|
||||
literal->u.type = RDF_VARIABLE_TERM_TYPE;
|
||||
((RDF_Variable)literal->u.value)->type = RDF_RESOURCE_TYPE;
|
||||
literal->s = s;
|
||||
literal->valueCount = 1;
|
||||
literal->v = (TermStruc*)getMem(sizeof(TermStruc));
|
||||
literal->v->value = (void*)arg2;
|
||||
literal->v->type = RDF_VARIABLE_TERM_TYPE;
|
||||
((RDF_Variable)literal->v->value)->type = literal->valueType = type;
|
||||
literal->tv = true;
|
||||
addLiteral(q, literal);
|
||||
q->conjunctsOrdered = false;
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRO(RDF_Query q, RDF_Variable arg1, RDF_Resource s, void* arg2, RDF_ValueType type) {
|
||||
RDF_Literal literal = (RDF_Literal)getMem(sizeof(LiteralStruc));
|
||||
if (literal == NULL) return RDF_NO_MEMORY;
|
||||
literal->u.value = (void*)arg1;
|
||||
literal->u.type = RDF_VARIABLE_TERM_TYPE;
|
||||
((RDF_Variable)literal->u.value)->type = type;
|
||||
literal->s = s;
|
||||
literal->valueCount = 1;
|
||||
literal->v = (TermStruc*)getMem(sizeof(TermStruc));
|
||||
literal->v->value = (type == RDF_STRING_TYPE) ? (void*)copyString((char*)arg2) : (void*)arg2;
|
||||
literal->v->type = RDF_CONSTANT_TERM_TYPE;
|
||||
literal->valueType = type;
|
||||
literal->tv = true;
|
||||
addLiteral(q, literal);
|
||||
q->conjunctsOrdered = false;
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctRRO(RDF_Query q, RDF_Resource arg1, RDF_Resource s, void* arg2, RDF_ValueType type) {
|
||||
RDF_Literal literal = (RDF_Literal)getMem(sizeof(LiteralStruc));
|
||||
if (literal == NULL) return RDF_NO_MEMORY;
|
||||
literal->u.value = (void*)arg1;
|
||||
literal->u.type = RDF_RESOURCE_TERM_TYPE;
|
||||
literal->s = s;
|
||||
literal->valueCount = 1;
|
||||
literal->v = (TermStruc*)getMem(sizeof(TermStruc));
|
||||
literal->v->value = (type == RDF_STRING_TYPE) ? (void*)copyString((char*)arg2) : (void*)arg2;
|
||||
literal->v->type = RDF_CONSTANT_TERM_TYPE;
|
||||
literal->valueType = type;
|
||||
literal->tv = true;
|
||||
addLiteral(q, literal);
|
||||
q->conjunctsOrdered = false;
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRR(RDF_Query q, RDF_Variable arg1, RDF_Resource s, RDF_Resource arg2) {
|
||||
RDF_Literal literal = (RDF_Literal)getMem(sizeof(LiteralStruc));
|
||||
if (literal == NULL) return RDF_NO_MEMORY;
|
||||
literal->u.value = (void*)arg1;
|
||||
literal->u.type = RDF_VARIABLE_TERM_TYPE;
|
||||
((RDF_Variable)literal->u.value)->type = RDF_RESOURCE_TYPE;
|
||||
literal->s = s;
|
||||
literal->valueCount = 1;
|
||||
literal->v = (TermStruc*)getMem(sizeof(TermStruc));
|
||||
literal->v->value = (void*)arg2;
|
||||
literal->v->type = RDF_RESOURCE_TERM_TYPE;
|
||||
literal->valueType = RDF_RESOURCE_TYPE;
|
||||
literal->tv = true;
|
||||
addLiteral(q, literal);
|
||||
q->conjunctsOrdered = false;
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctRRV(RDF_Query q, RDF_Resource arg1, RDF_Resource s, RDF_Variable arg2, RDF_ValueType type) {
|
||||
RDF_Literal literal = (RDF_Literal)getMem(sizeof(LiteralStruc));
|
||||
if (literal == NULL) return RDF_NO_MEMORY;
|
||||
literal->u.value = arg1;
|
||||
literal->u.type = RDF_RESOURCE_TERM_TYPE;
|
||||
literal->s = s;
|
||||
literal->valueCount = 1;
|
||||
literal->v = (TermStruc*)getMem(sizeof(TermStruc));
|
||||
literal->v->value = (void*)arg2;
|
||||
literal->v->type = RDF_VARIABLE_TERM_TYPE;
|
||||
((RDF_Variable)literal->v->value)->type = literal->valueType = type;
|
||||
literal->tv = true;
|
||||
addLiteral(q, literal);
|
||||
q->conjunctsOrdered = false;
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRL(RDF_Query q, RDF_Variable arg1, RDF_Resource s, RDF_Term arg2, RDF_ValueType type, uint8 count) {
|
||||
RDF_Literal literal = (RDF_Literal)getMem(sizeof(LiteralStruc));
|
||||
if (literal == NULL) return RDF_NO_MEMORY;
|
||||
literal->u.value = (void*)arg1;
|
||||
literal->u.type = RDF_VARIABLE_TERM_TYPE;
|
||||
((RDF_Variable)literal->u.value)->type = type;
|
||||
literal->s = s;
|
||||
literal->valueCount = count;
|
||||
literal->v = (void*)arg2;
|
||||
/* value and type of each term already assigned */
|
||||
literal->valueType = type;
|
||||
literal->tv = true;
|
||||
addLiteral(q, literal);
|
||||
q->conjunctsOrdered = false;
|
||||
return noRDFErr;
|
||||
}
|
||||
113
mozilla/modules/rdf/src/query.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef query_h___
|
||||
#define query_h___
|
||||
|
||||
/* the RDF Query API. */
|
||||
|
||||
#include "rdf.h"
|
||||
|
||||
typedef uint8 RDF_TermType; /* type of a term */
|
||||
|
||||
/* values of RDF_TermType */
|
||||
#define RDF_VARIABLE_TERM_TYPE 1
|
||||
#define RDF_RESOURCE_TERM_TYPE 2
|
||||
#define RDF_CONSTANT_TERM_TYPE 3
|
||||
|
||||
typedef struct _RDF_VariableStruc {
|
||||
void* value;
|
||||
RDF_ValueType type;
|
||||
char* id;
|
||||
PRBool isResult;
|
||||
struct _RDF_QueryStruc* query;
|
||||
} RDF_VariableStruc;
|
||||
|
||||
typedef RDF_VariableStruc* RDF_Variable;
|
||||
|
||||
typedef struct _RDF_VariableListStruc {
|
||||
RDF_Variable element;
|
||||
struct _RDF_VariableListStruc* next;
|
||||
} RDF_VariableListStruc;
|
||||
|
||||
typedef RDF_VariableListStruc* RDF_VariableList;
|
||||
|
||||
PR_PUBLIC_API(PRBool) RDF_IsResultVariable(RDF_Variable var);
|
||||
PR_PUBLIC_API(void) RDF_SetResultVariable(RDF_Variable var, PRBool isResult);
|
||||
PR_PUBLIC_API(void*) RDF_GetVariableValue(RDF_Variable var);
|
||||
PR_PUBLIC_API(void) RDF_SetVariableValue(RDF_Variable var, void* value, RDF_ValueType type);
|
||||
|
||||
typedef struct _Term {
|
||||
void* value;
|
||||
RDF_TermType type;
|
||||
} TermStruc;
|
||||
|
||||
typedef struct TermStruc* RDF_Term;
|
||||
|
||||
typedef struct _LiteralStruc {
|
||||
TermStruc u;
|
||||
RDF_Resource s;
|
||||
TermStruc* v;
|
||||
uint8 valueCount; /* disjunction */
|
||||
RDF_Cursor c;
|
||||
PRBool tv;
|
||||
PRBool bt;
|
||||
RDF_Variable variable;
|
||||
RDF_ValueType valueType;
|
||||
} LiteralStruc;
|
||||
|
||||
typedef LiteralStruc* RDF_Literal;
|
||||
|
||||
typedef struct _RDF_LiteralListStruc {
|
||||
RDF_Literal element;
|
||||
struct _RDF_LiteralListStruc* next;
|
||||
} RDF_LiteralListStruc;
|
||||
|
||||
typedef RDF_LiteralListStruc* RDF_LiteralList;
|
||||
|
||||
typedef struct _RDF_QueryStruc {
|
||||
struct _RDF_VariableListStruc* variables;
|
||||
struct _RDF_LiteralListStruc* literals;
|
||||
uint16 numLiterals;
|
||||
uint16 index;
|
||||
PRBool conjunctsOrdered;
|
||||
PRBool queryRunning;
|
||||
RDF rdf;
|
||||
} RDF_QueryStruc;
|
||||
|
||||
typedef RDF_QueryStruc* RDF_Query;
|
||||
|
||||
/* Note: the API assumes that the query parameter is non-NULL. */
|
||||
PR_PUBLIC_API(RDF_Query) RDF_CreateQuery(RDF rdf);
|
||||
PR_PUBLIC_API(void) RDF_DestroyQuery(RDF_Query q);
|
||||
PR_PUBLIC_API(RDF_Variable) RDF_GetVariable(RDF_Query q, char* name);
|
||||
PR_PUBLIC_API(PRBool) RDF_RunQuery (RDF_Query q);
|
||||
PR_PUBLIC_API(PRBool) RDF_GetNextElement(RDF_Query q);
|
||||
PR_PUBLIC_API(void) RDF_EndQuery (RDF_Query q);
|
||||
PR_PUBLIC_API(RDF_VariableList) RDF_GetVariableList(RDF_Query q);
|
||||
PR_PUBLIC_API(uint16) RDF_GetVariableListCount(RDF_Query q);
|
||||
PR_PUBLIC_API(RDF_Variable) RDF_GetNthVariable(RDF_Query q, uint16 index);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRV(RDF_Query q, RDF_Variable arg1, RDF_Resource s, RDF_Variable arg2, RDF_ValueType type);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRO(RDF_Query q, RDF_Variable arg1, RDF_Resource s, void* arg2, RDF_ValueType type);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctRRO(RDF_Query q, RDF_Resource arg1, RDF_Resource s, void* arg2, RDF_ValueType type);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRR(RDF_Query q, RDF_Variable arg1, RDF_Resource s, RDF_Resource arg2);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctRRV(RDF_Query q, RDF_Resource arg1, RDF_Resource s, RDF_Variable arg2, RDF_ValueType type);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRL(RDF_Query q, RDF_Variable arg1, RDF_Resource s, RDF_Term arg2, RDF_ValueType type, uint8 count);
|
||||
|
||||
#endif /* query_h___ */
|
||||
|
||||
451
mozilla/modules/rdf/src/rdf-int.h
Normal file
@@ -0,0 +1,451 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _RDF_RDF_INT_H
|
||||
#define _RDF_RDF_INT_H
|
||||
|
||||
|
||||
#define WINTEST 0
|
||||
#define DBMTEST 1
|
||||
#define FSTEST 1
|
||||
|
||||
|
||||
#define RDF_BUF_SIZE 4096
|
||||
#define LINE_SIZE 512
|
||||
#define RDF_BOOKMARKS 128
|
||||
#define RDF_MCF 129
|
||||
#define RDF_XML 130
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "rdf.h"
|
||||
#include "nspr.h"
|
||||
#include "plhash.h"
|
||||
|
||||
#include "rdfstr.h"
|
||||
|
||||
|
||||
|
||||
#ifndef true
|
||||
#define true PR_TRUE
|
||||
#endif
|
||||
#ifndef false
|
||||
#define false PR_FALSE
|
||||
#endif
|
||||
#define null NULL
|
||||
#define nullp(x) (((void*)x) == ((void*)0))
|
||||
#define LookupResource(x) ((RDF_Resource)PL_HashTableLookup(resourceHash, x));
|
||||
|
||||
#define noRDFErr 0
|
||||
#define noMoreValuesErr 1
|
||||
|
||||
#define MAX_ATTRIBUTES 64
|
||||
|
||||
#define RDF_RT 0
|
||||
#define LFS_RT 1
|
||||
#define FTP_RT 3
|
||||
#define ES_RT 4
|
||||
#define SEARCH_RT 5
|
||||
#define HISTORY_RT 6
|
||||
#define LDAP_RT 7
|
||||
#define PM_RT 8
|
||||
#define RDM_RT 9
|
||||
#define IM_RT 10
|
||||
#define CACHE_RT 11
|
||||
#define ATALK_RT 12
|
||||
#define ATALKVIRTUAL_RT 13
|
||||
#define COOKIE_RT 14
|
||||
#define JSEC_RT 15
|
||||
#define PMF_RT 16
|
||||
|
||||
#define CHECK_VAR(var, return_value) {if (var == NULL) {/*xxx PR_ASSERT(var); */ return return_value;}}
|
||||
#define CHECK_VAR1(var) {if (var == NULL) {/*xxx PR_ASSERT(var);*/ return;}}
|
||||
|
||||
|
||||
#ifdef XP_WIN
|
||||
#define FS_URL_OFFSET 8
|
||||
#else
|
||||
#define FS_URL_OFFSET 7
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_URL_SIZE 300
|
||||
|
||||
|
||||
#define convertString2UTF8(charsetid, s) \
|
||||
(s != NULL ? \
|
||||
INTL_ConvertLineWithoutAutoDetect( \
|
||||
(charsetid) , \
|
||||
CS_UTF8, \
|
||||
(unsigned char*)(s), \
|
||||
RDF_STRLEN(s) \
|
||||
) : NULL)
|
||||
|
||||
#define stringEquals(x, y) (strcasecomp(x, y) ==0)
|
||||
/*#define stringAppend(x, y) XP_AppendStr(x,y) */
|
||||
|
||||
struct RDF_ResourceStruct {
|
||||
char* url;
|
||||
uint8 type;
|
||||
uint8 flags;
|
||||
struct RDF_AssertionStruct* rarg1;
|
||||
struct RDF_AssertionStruct* rarg2;
|
||||
struct RDF_ListStruct* rdf;
|
||||
void* pdata;
|
||||
} ;
|
||||
|
||||
#define RDF_GET_SLOT_VALUES_QUERY 0x01
|
||||
#define RDF_GET_SLOT_VALUE_QUERY 0x02
|
||||
#define RDF_FIND_QUERY 0x03
|
||||
#define RDF_ARC_LABELS_IN_QUERY 0x04
|
||||
#define RDF_ARC_LABELS_OUT_QUERY 0x05
|
||||
|
||||
struct RDF_CursorStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
RDF_Resource match;
|
||||
void *value;
|
||||
struct RDF_CursorStruct* current;
|
||||
RDF rdf;
|
||||
void* pdata;
|
||||
PRBool tv;
|
||||
PRBool inversep;
|
||||
RDF_ValueType type;
|
||||
int16 count;
|
||||
uint16 size;
|
||||
uint8 queryType;
|
||||
};
|
||||
|
||||
typedef uint8 RDF_BT;
|
||||
|
||||
#define getMem(x) PR_Calloc(1,(x))
|
||||
#define freeMem(x) PR_Free((x))
|
||||
|
||||
struct RDF_AssertionStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
void* value;
|
||||
PRBool tv;
|
||||
RDF_ValueType type;
|
||||
uint8 tags;
|
||||
struct RDF_AssertionStruct* next;
|
||||
struct RDF_AssertionStruct* invNext;
|
||||
struct RDF_TranslatorStruct* db;
|
||||
} ;
|
||||
|
||||
|
||||
typedef struct RDF_AssertionStruct *Assertion;
|
||||
typedef struct RDF_FileStruct *RDFFile;
|
||||
|
||||
|
||||
typedef PRBool (*assertProc)(RDFT r, RDF_Resource u, RDF_Resource s, void* value, RDF_ValueType type, PRBool tv);
|
||||
typedef PRBool (*hasAssertionProc)(RDFT r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
typedef void* (*getSlotValueProc)(RDFT r, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
||||
typedef RDF_Cursor (*getSlotValuesProc)(RDFT r, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
typedef PRBool (*unassertProc)(RDFT r, RDF_Resource u, RDF_Resource s, void* value, RDF_ValueType type);
|
||||
typedef void* (*nextItemProc)(RDFT r, RDF_Cursor c) ;
|
||||
typedef RDF_Error (*disposeCursorProc)(RDFT r, RDF_Cursor c);
|
||||
typedef RDF_Error (*disposeResourceProc)(RDFT r, RDF_Resource u);
|
||||
typedef RDF_Error (*updateProc)(RDFT r, RDF_Resource u);
|
||||
typedef RDF_Error (*destroyProc)(struct RDF_TranslatorStruct*);
|
||||
typedef RDF_Cursor (*arcLabelsOutProc)(RDFT r, RDF_Resource u);
|
||||
typedef RDF_Cursor (*arcLabelsInProc)(RDFT r, RDF_Resource u);
|
||||
typedef PRBool (*fAssert1Proc) (RDFFile file, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
||||
typedef PRBool (*fUnAssert1Proc) (RDFFile file, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) ;
|
||||
typedef void (*accessFileProc) (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) ;
|
||||
|
||||
struct RDF_ListStruct {
|
||||
struct RDF_DBStruct* rdf;
|
||||
struct RDF_ListStruct* next;
|
||||
} ;
|
||||
|
||||
typedef struct RDF_ListStruct *RDFL;
|
||||
|
||||
struct RDF_TranslatorStruct {
|
||||
RDFL rdf;
|
||||
char* url;
|
||||
void* pdata;
|
||||
destroyProc destroy;
|
||||
hasAssertionProc hasAssertion;
|
||||
unassertProc unassert;
|
||||
assertProc assert;
|
||||
getSlotValueProc getSlotValue;
|
||||
getSlotValuesProc getSlotValues;
|
||||
nextItemProc nextValue;
|
||||
disposeCursorProc disposeCursor;
|
||||
disposeResourceProc disposeResource;
|
||||
arcLabelsInProc arcLabelsIn;
|
||||
arcLabelsInProc arcLabelsOut;
|
||||
accessFileProc possiblyAccessFile;
|
||||
updateProc update;
|
||||
RDFL dependents;
|
||||
RDFL dependentOn;
|
||||
};
|
||||
|
||||
|
||||
extern PLHashTable* resourceHash;
|
||||
extern PLHashTable* dataSourceHash;
|
||||
extern char* gNavCntrUrl;
|
||||
struct RDF_DBStruct {
|
||||
int32 numTranslators;
|
||||
int32 translatorArraySize;
|
||||
RDFT* translators;
|
||||
struct RDF_FileStruct* files;
|
||||
struct RDF_NotificationStruct* notifs;
|
||||
void* context;
|
||||
};
|
||||
|
||||
extern RDFT gLocalStore;
|
||||
extern RDFT gRemoteStore;
|
||||
extern RDFT gSessionDB;
|
||||
extern size_t gCoreVocabSize;
|
||||
extern RDF_Resource* gAllVocab;
|
||||
|
||||
/* reading rdf */
|
||||
|
||||
#define HEADERS 1
|
||||
#define BODY 2
|
||||
|
||||
|
||||
struct XMLNameSpaceStruct {
|
||||
char* as;
|
||||
char* url;
|
||||
struct XMLNameSpaceStruct* next;
|
||||
} ;
|
||||
|
||||
typedef struct XMLNameSpaceStruct *XMLNameSpace;
|
||||
|
||||
#define RDF_MAX_NUM_FILE_TOKENS 8
|
||||
|
||||
struct RDF_FileStructTokens {
|
||||
RDF_Resource token;
|
||||
RDF_ValueType type;
|
||||
int16 tokenNum;
|
||||
char *data;
|
||||
};
|
||||
|
||||
struct RDF_FileStruct {
|
||||
char* url;
|
||||
|
||||
RDF_Resource currentResource;
|
||||
RDF_Resource top;
|
||||
RDF_Resource rtop;
|
||||
char* currentSlot;
|
||||
PRBool genlAdded;
|
||||
PRBool localp;
|
||||
char* storeAway;
|
||||
char* line;
|
||||
XMLNameSpace namespaces;
|
||||
uint16 status;
|
||||
char* holdOver;
|
||||
int32 lineSize;
|
||||
RDF_Resource stack[16];
|
||||
uint16 depth ;
|
||||
|
||||
|
||||
uint16 resourceCount;
|
||||
uint16 resourceListSize;
|
||||
uint16 assertionCount;
|
||||
uint16 assertionListSize;
|
||||
RDF_Resource* resourceList;
|
||||
Assertion* assertionList;
|
||||
char* updateURL;
|
||||
char* postURL;
|
||||
|
||||
PRTime lastReadTime;
|
||||
PRTime *expiryTime;
|
||||
uint8 fileType;
|
||||
PRBool locked;
|
||||
RDF_Resource lastItem;
|
||||
|
||||
|
||||
PRBool tv;
|
||||
fAssert1Proc assert;
|
||||
fUnAssert1Proc unassert;
|
||||
RDFT db;
|
||||
PRBool refreshingp;
|
||||
|
||||
void* pdata;
|
||||
|
||||
int16 numFileTokens;
|
||||
struct RDF_FileStructTokens tokens[RDF_MAX_NUM_FILE_TOKENS];
|
||||
struct RDF_FileStruct* next;
|
||||
};
|
||||
|
||||
RDF newNavCenterDB();
|
||||
void walkThroughAllBookmarks (RDF_Resource u);
|
||||
RDFT NewRemoteStore (char* url);
|
||||
RDF_Resource nextFindValue (RDF_Cursor c) ;
|
||||
PRBool isTypeOf (RDF rdf, RDF_Resource u, RDF_Resource v);
|
||||
RDF getRDFDB (void);
|
||||
RDFFile readRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT rdf);
|
||||
void sendNotifications (RDF rdf, RDF_EventType opType, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv, char* ds);
|
||||
void sendNotifications2 (RDFT rdf, RDF_EventType opType, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
||||
RDF_Error exitRDF (RDF rdf);
|
||||
void gcRDFFileInt (RDFFile f);
|
||||
void parseNextBkBlob(RDFFile f, char* blob, int32 blobSize);
|
||||
void printAssertion(Assertion as);
|
||||
RDF_Error addChildAfter (RDFT rdf, RDF_Resource parent, RDF_Resource child, RDF_Resource afterWhat);
|
||||
RDF_Error addChildBefore (RDFT rdf, RDF_Resource parent, RDF_Resource child, RDF_Resource beforeWhat);
|
||||
void nlclStoreKill(RDFT rdf, RDF_Resource r);
|
||||
char* resourceID(RDF_Resource id);
|
||||
PRBool containerp (RDF_Resource r);
|
||||
void setContainerp (RDF_Resource r, PRBool contp);
|
||||
PRBool lockedp (RDF_Resource r);
|
||||
void setLockedp (RDF_Resource r, PRBool contp);
|
||||
uint8 resourceType (RDF_Resource r);
|
||||
void setResourceType (RDF_Resource r, uint8 type);
|
||||
char* getBaseURL (const char* url) ;
|
||||
void freeNamespaces (RDFFile f) ;
|
||||
PRBool asEqual(RDFT r, Assertion as, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
Assertion makeNewAssertion (RDFT r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
|
||||
RDFT MakeRemoteStore (char* url);
|
||||
RDFT MakeMailAccountDB(char* url);
|
||||
PRDir * OpenDir(char *name);
|
||||
void PopGetNewMail (RDF_Resource r) ;
|
||||
void readResourceFile(RDF rdf, RDF_Resource u);
|
||||
void possiblyGCResource(RDF_Resource u);
|
||||
PLHashNumber idenHash(const void* key);
|
||||
|
||||
RDFT MakeBMKStore (char* url);
|
||||
|
||||
/* string utilities */
|
||||
|
||||
int16 charSearch(const char c,const char* string);
|
||||
int16 revCharSearch(const char c, const char* string);
|
||||
PR_PUBLIC_API(PRBool) startsWith(const char* startPattern,const char* string);
|
||||
PRBool endsWith(const char* endPattern,const char* string);
|
||||
PRBool inverseTV(PRBool tv);
|
||||
void createBootstrapResources();
|
||||
PRBool urlEquals(const char* url1,const char* url2);
|
||||
char* append2Strings(const char* str1,const char* str2);
|
||||
char* convertString2UTF8AndAppend(int16 charsetID, const char* str1,const char* str2);
|
||||
PRBool substring(const char* pattern, const char* data);
|
||||
void stringAppend(char* in, const char* append);
|
||||
|
||||
RDFFile makeRDFFile (char* url, RDF_Resource top, PRBool localp);
|
||||
void initRDFFile (RDFFile ans) ;
|
||||
void parseNextRDFLine (RDFFile f, char* line) ;
|
||||
void parseNextRDFBlob (RDFFile f, char* blob, int32 size);
|
||||
void finishRDFParse (RDFFile f) ;
|
||||
void abortRDFParse (RDFFile f);
|
||||
void unitTransition (RDFFile f) ;
|
||||
void assignHeaderSlot (RDFFile f, char* slot, char* value);
|
||||
RDF_Error getFirstToken (char* line, char* nextToken, int16* l) ;
|
||||
void addSlotValue (RDFFile f, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, char* op);
|
||||
void assignSlot (RDF_Resource u, char* slot, char* value, RDFFile f);
|
||||
RDF_Error parseSlotValue (RDFFile f, RDF_Resource s, char* value, void** parsed_value, RDF_ValueType* data_type) ;
|
||||
RDF_Resource resolveReference (char *tok, RDFFile f) ;
|
||||
RDF_Resource resolveGenlPosReference(char* tok, RDFFile f);
|
||||
RDF_Resource resolveReference (char *tok, RDFFile f) ;
|
||||
RDF_Resource resolveGenlPosReference(char* tok, RDFFile f);
|
||||
void beginReadingRDFFile(RDFFile f);
|
||||
void gcRDFFile (RDFFile f);
|
||||
#ifdef XP_MAC
|
||||
char* unescapeURL(char* inURL);
|
||||
#endif
|
||||
char* convertFileURLToNSPRCopaceticPath(char* inURL);
|
||||
PRFileDesc* CallPROpenUsingFileURL(char *fileURL, PRIntn flags, PRIntn mode);
|
||||
/* DB *CallDBOpenUsingFileURL(char *fileURL, int flags,int mode, DBTYPE type, const void *openinfo); */
|
||||
|
||||
char* copyString (const char* url);
|
||||
PRBool nlocalStoreAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv) ;
|
||||
char* MCDepFileURL (char* url) ;
|
||||
void initLocalStore(RDFT rdf);
|
||||
void freeAssertion(Assertion as);
|
||||
Assertion localStoreAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
||||
Assertion localStoreRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) ;
|
||||
|
||||
Assertion remoteStoreAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
||||
Assertion remoteStoreRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) ;
|
||||
void* remoteStoreGetSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
||||
void ht_fprintf(PRFileDesc *file, const char *fmt, ...);
|
||||
|
||||
RDF_Resource createContainer (char* id);
|
||||
PRBool isContainer (RDF_Resource r) ;
|
||||
PRBool isSeparator (RDF_Resource r) ;
|
||||
PRBool isLeaf (RDF_Resource r) ;
|
||||
PRBool bookmarkSlotp (RDF_Resource s) ;
|
||||
|
||||
void basicAssertions (void) ;
|
||||
char* makeResourceName (RDF_Resource node) ;
|
||||
char* makeDBURL (char* name);
|
||||
|
||||
/* int rdf_GetURL (MWContext *cx, int method, Net_GetUrlExitFunc *exit_routine, RDFFile rdfFile); */
|
||||
|
||||
RDFT MakePopDB (char* url) ;
|
||||
PRBool nlocalStoreAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv) ;
|
||||
PRBool nlocalStoreUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type) ;
|
||||
PRBool nlocalStoreHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
||||
void* nlocalStoreGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
||||
RDF_Cursor nlocalStoreGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
||||
void* nlocalStoreNextValue (RDFT mcf, RDF_Cursor c) ;
|
||||
RDF_Error nlocalStoreDisposeCursor (RDFT mcf, RDF_Cursor c) ;
|
||||
void createCoreVocab () ;
|
||||
int parseNextRDFXMLBlobInt(RDFFile f, char* blob, int32 size) ;
|
||||
|
||||
PRBool remoteAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv) ;
|
||||
PRBool remoteUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type) ;
|
||||
PRBool remoteAssert1 (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv) ;
|
||||
PRBool remoteAssert2 (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv) ;
|
||||
PRBool remoteUnassert1 (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type) ;
|
||||
PRBool remoteStoreHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
||||
void* remoteStoreGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
||||
RDF_Cursor remoteStoreGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
||||
RDF_Cursor remoteStoreGetSlotValuesInt (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
||||
RDF_Resource createSeparator(void);
|
||||
PRBool
|
||||
remoteAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
|
||||
void* remoteStoreNextValue (RDFT mcf, RDF_Cursor c) ;
|
||||
RDF_Error remoteStoreDisposeCursor (RDFT mcf, RDF_Cursor c) ;
|
||||
PRBool remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
||||
PRBool remoteStoreHasAssertionInt (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
||||
PRBool nlocalStoreAddChildAt(RDFT mcf, RDF_Resource obj, RDF_Resource ref, RDF_Resource _new,
|
||||
PRBool beforep);
|
||||
RDFT getTranslator (char* url);
|
||||
|
||||
RDFT MakeCookieStore (char* url);
|
||||
|
||||
char* advertURLOfContainer (RDF r, RDF_Resource u) ;
|
||||
RDFT RDFTNamed (RDF rdf, char* name) ;
|
||||
|
||||
char* RDF_SerializeRDFStore (RDFT store) ;
|
||||
char * unescapeURL(char *inURL);
|
||||
|
||||
|
||||
|
||||
|
||||
extern RDF_WDVocab gWebData;
|
||||
extern RDF_NCVocab gNavCenter;
|
||||
extern RDF_CoreVocab gCoreVocab;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
177
mozilla/modules/rdf/src/rdfht.c
Normal file
@@ -0,0 +1,177 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements high level support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "vocab.h"
|
||||
#include "vocabint.h"
|
||||
#include "bmk2mcf.h"
|
||||
#include "mcf.h"
|
||||
|
||||
|
||||
/* globals */
|
||||
char *profileDirURL = NULL;
|
||||
char *gLocalStoreURL = NULL;
|
||||
char *gBookmarkURL = NULL;
|
||||
char *gGlobalHistoryURL = NULL;
|
||||
void *timerID = NULL;
|
||||
char *gRLForbiddenDomains = NULL;
|
||||
|
||||
extern RDF gNCDB ;
|
||||
|
||||
|
||||
static PRBool sRDFInitedB = PR_FALSE;
|
||||
char* gNavCntrUrl;
|
||||
|
||||
|
||||
char * gNavCenterDataSources[15] =
|
||||
{"rdf:localStore", "rdf:remoteStore", "rdf:bookmarks", "rdf:remoteStore", "rdf:history",
|
||||
/* "rdf:ldap", */
|
||||
"rdf:esftp",
|
||||
"rdf:lfs", "rdf:CookieStore",
|
||||
"rdf:columns", "rdf:find",
|
||||
|
||||
#ifdef XP_MAC
|
||||
"rdf:appletalk",
|
||||
#endif
|
||||
|
||||
NULL, NULL
|
||||
};
|
||||
|
||||
|
||||
|
||||
RDF
|
||||
newNavCenterDB()
|
||||
{
|
||||
return RDF_GetDB((char**)gNavCenterDataSources);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
walkThroughAllBookmarks (RDF_Resource u)
|
||||
{
|
||||
#ifdef MOZILLA_CLIENT
|
||||
RDF_Cursor c = RDF_GetSources(gNCDB, u, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
|
||||
RDF_Resource next;
|
||||
while ((next = RDF_NextValue(c)) != NULL) {
|
||||
if (resourceType(next) == RDF_RT) walkThroughAllBookmarks(next);
|
||||
}
|
||||
RDF_DisposeCursor(c);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(RDF_Error)
|
||||
RDF_Init(RDF_InitParams params)
|
||||
{
|
||||
#ifdef MOZILLA_CLIENT
|
||||
char* navCenterURL;
|
||||
#endif
|
||||
if ( sRDFInitedB )
|
||||
return -1;
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
/*
|
||||
copy init params out before doing anything else (such as creating vocabulary)
|
||||
to prevent any XP_GetString round-robin problems (ex: FE could be using XP_GetString
|
||||
to pass in the init strings, which createVocabs() could affect
|
||||
*/
|
||||
profileDirURL = copyString(params->profileURL);
|
||||
gBookmarkURL = copyString(params->bookmarksURL);
|
||||
gGlobalHistoryURL = copyString(params->globalHistoryURL);
|
||||
#endif
|
||||
|
||||
resourceHash = PL_NewHashTable(500, PL_HashString, PL_CompareStrings,
|
||||
PL_CompareValues, NULL, NULL);
|
||||
dataSourceHash = PL_NewHashTable(100, PL_HashString, PL_CompareStrings,
|
||||
PL_CompareValues, NULL, NULL);
|
||||
RDFglueInitialize();
|
||||
MakeRemoteStore("rdf:remoteStore");
|
||||
createVocabs();
|
||||
sRDFInitedB = PR_TRUE;
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
/* xxx
|
||||
PREF_SetDefaultCharPref("browser.NavCenter", "http://rdf.netscape.com/rdf/navcntr.rdf");
|
||||
PREF_CopyCharPref("browser.NavCenter", &navCenterURL);
|
||||
*/
|
||||
navCenterURL = copyString("http://rdf.netscape.com/rdf/navcntr.rdf");
|
||||
if (!RDF_STRCHR(navCenterURL, ':')) {
|
||||
navCenterURL = makeDBURL(navCenterURL);
|
||||
}
|
||||
gNavCntrUrl = copyString(navCenterURL);
|
||||
*(gNavCenterDataSources + 1) = copyString(navCenterURL);
|
||||
gNCDB = newNavCenterDB();
|
||||
freeMem(navCenterURL);
|
||||
|
||||
HT_Startup();
|
||||
|
||||
/* GuessIEBookmarks(); */
|
||||
|
||||
#endif
|
||||
walkThroughAllBookmarks(RDF_GetResource(NULL, "NC:Bookmarks", true));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*need to keep a linked list of all the dbs opened so that they
|
||||
can all be closed down on exit */
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(RDF_Error)
|
||||
RDF_Shutdown ()
|
||||
{
|
||||
#ifdef MOZILLA_CLIENT
|
||||
/* flushBookmarks(); */
|
||||
HT_Shutdown();
|
||||
RDFglueExit();
|
||||
if (profileDirURL != NULL)
|
||||
{
|
||||
freeMem(profileDirURL);
|
||||
profileDirURL = NULL;
|
||||
}
|
||||
if (gBookmarkURL != NULL)
|
||||
{
|
||||
freeMem(gBookmarkURL);
|
||||
gBookmarkURL = NULL;
|
||||
}
|
||||
if (gGlobalHistoryURL != NULL)
|
||||
{
|
||||
freeMem(gGlobalHistoryURL);
|
||||
gGlobalHistoryURL = NULL;
|
||||
}
|
||||
if (gLocalStoreURL != NULL)
|
||||
{
|
||||
freeMem(gLocalStoreURL);
|
||||
gLocalStoreURL = NULL;
|
||||
}
|
||||
#endif
|
||||
disposeAllDBs();
|
||||
sRDFInitedB = PR_FALSE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
554
mozilla/modules/rdf/src/rdfparse.c
Normal file
@@ -0,0 +1,554 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements parsing support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "rdfparse.h"
|
||||
#include "mcf.h"
|
||||
|
||||
|
||||
#define wsCharp(c) ((c == '\r') || (c == '\t') || (c == ' ') || (c == '\n'))
|
||||
|
||||
|
||||
|
||||
char
|
||||
decodeEntityRef (char* string, int32* stringIndexPtr, int32 len)
|
||||
{
|
||||
if (startsWith("lt;", string)) {
|
||||
*stringIndexPtr = *stringIndexPtr + 3;
|
||||
return '<';
|
||||
} else if (startsWith("gt;", string)) {
|
||||
*stringIndexPtr = *stringIndexPtr + 3;
|
||||
return '>';
|
||||
} else if (startsWith("amp;", string)) {
|
||||
*stringIndexPtr = *stringIndexPtr + 4;
|
||||
return '&';
|
||||
} else return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
copyStringIgnoreWhiteSpace(char* string)
|
||||
{
|
||||
int32 len = RDF_STRLEN(string);
|
||||
char* buf = (char*)getMem(len + 1);
|
||||
PRBool inWhiteSpace = 1;
|
||||
int32 buffIndex = 0;
|
||||
int32 stringIndex = 0;
|
||||
|
||||
while (stringIndex < len) {
|
||||
char nextChar = *(string + stringIndex);
|
||||
PRBool wsp = wsCharp(nextChar);
|
||||
if (!wsp) {
|
||||
if (nextChar == '&') {
|
||||
*(buf + buffIndex++) = decodeEntityRef(&string[stringIndex+1],
|
||||
&stringIndex, len-stringIndex);
|
||||
} else {
|
||||
*(buf + buffIndex++) = nextChar;
|
||||
}
|
||||
inWhiteSpace = 0;
|
||||
} else if (!inWhiteSpace) {
|
||||
*(buf + buffIndex++) = ' ';
|
||||
inWhiteSpace = 1;
|
||||
} else {
|
||||
inWhiteSpace = 1;
|
||||
}
|
||||
stringIndex++;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
getHref(char** attlist)
|
||||
{
|
||||
char* ans = getAttributeValue(attlist, "rdf:href");
|
||||
if (!ans) ans = getAttributeValue(attlist, "RDF:href");
|
||||
if (!ans) ans = getAttributeValue(attlist, "href");
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
int parseNextRDFXMLBlobInt(RDFFile f, char* blob, int32 size) {
|
||||
int32 n, last, m;
|
||||
PRBool somethingseenp = 0;
|
||||
n = last = 0;
|
||||
|
||||
while (n < size) {
|
||||
char c = blob[n];
|
||||
m = 0;
|
||||
somethingseenp = 0;
|
||||
memset(f->line, '\0', RDF_BUF_SIZE-1);
|
||||
if (f->holdOver[0] != '\0') {
|
||||
memcpy(f->line, f->holdOver, RDF_STRLEN(f->holdOver));
|
||||
m = RDF_STRLEN(f->holdOver);
|
||||
somethingseenp = 1;
|
||||
memset(f->holdOver, '\0', RDF_BUF_SIZE-1);
|
||||
}
|
||||
while ((n < size) && (wsc(c))) {c = blob[++n];}
|
||||
/* f->line[m++] = c;
|
||||
c = blob[++n]; */
|
||||
while ((m < RDF_BUF_SIZE) && (c != '<') && (c != '>')) {
|
||||
f->line[m] = c;
|
||||
m++;
|
||||
somethingseenp = (somethingseenp || (!(wsc(c))));
|
||||
n++;
|
||||
if (n < size) c = blob[n];
|
||||
else break;
|
||||
}
|
||||
if (c == '>') f->line[m] = c;
|
||||
n++;
|
||||
if (m > 0) {
|
||||
if ((c == '<') || (c == '>')) {
|
||||
last = n;
|
||||
if (c == '<') f->holdOver[0] = '<';
|
||||
if (somethingseenp == 1) parseNextRDFToken(f, f->line);
|
||||
} else if (size > last) {
|
||||
memcpy(f->holdOver, f->line, m);
|
||||
}
|
||||
} else if (c == '<') f->holdOver[0] = '<';
|
||||
}
|
||||
return(size);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
parseRDFProcessingInstruction (RDFFile f, char* token)
|
||||
{
|
||||
char* attlist[2*MAX_ATTRIBUTES+1];
|
||||
char* elementName;
|
||||
tokenizeElement(token, attlist, &elementName);
|
||||
if (RDF_STRCMP(elementName, "?xml:namespace") == 0) {
|
||||
char* as = getAttributeValue(attlist, "prefix");
|
||||
char* url = getAttributeValue(attlist, "ns");
|
||||
if ((as != NULL) && (url != NULL)) {
|
||||
XMLNameSpace ns = (XMLNameSpace)getMem(sizeof(struct XMLNameSpaceStruct));
|
||||
size_t urln = RDF_STRLEN(url);
|
||||
PRBool addSlash = (url[urln-1] != '/');
|
||||
if(addSlash) urln++;
|
||||
ns->url = (char*)getMem(sizeof(char) * (urln + 1));
|
||||
sprintf(ns->url, "%s%s", url, addSlash ? "/" : "");
|
||||
ns->as = copyString(as);
|
||||
ns->next = f->namespaces;
|
||||
f->namespaces = ns;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
freeNamespaces (RDFFile f)
|
||||
{
|
||||
XMLNameSpace ns1 = f->namespaces;
|
||||
while (ns1) {
|
||||
XMLNameSpace next = ns1->next;
|
||||
freeMem(ns1->as);
|
||||
freeMem(ns1->url);
|
||||
freeMem(ns1);
|
||||
ns1 = next;
|
||||
}
|
||||
f->namespaces = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(char *)
|
||||
getAttributeValue (char** attlist, char* elName)
|
||||
{
|
||||
size_t n = 0;
|
||||
if (!attlist) return NULL;
|
||||
while ((n < 2*MAX_ATTRIBUTES) && (*(attlist + n) != NULL)) {
|
||||
if (RDF_STRCMP(*(attlist + n), elName) == 0) return *(attlist + n + 1);
|
||||
n = n + 2;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
tagEquals (RDFFile f, char* tag1, char* tag2)
|
||||
{
|
||||
return (RDF_STRCMP(tag1, tag2) == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
addElementProps (char** attlist, char* elementName, RDFFile f, RDF_Resource obj)
|
||||
{
|
||||
uint32 count = 0;
|
||||
while (count < 2*MAX_ATTRIBUTES) {
|
||||
char* attName = attlist[count++];
|
||||
char* attValue = attlist[count++];
|
||||
if ((attName == NULL) || (attValue == NULL)) break;
|
||||
if (!tagEquals(f, attName, "href") && !tagEquals(f, attName, "rdf:href") &&
|
||||
!tagEquals(f, attName, "RDF:href") && !tagEquals(f, attName, "tv")
|
||||
&& !tagEquals(f, attName, "id")) {
|
||||
addSlotValue(f, obj, ResourceFromElementName(f, attName), copyStringIgnoreWhiteSpace(attValue),
|
||||
RDF_STRING_TYPE, "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
knownObjectElement (char* eln)
|
||||
{
|
||||
return (RDF_STRCMP(eln, "RDF:Description") == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
possiblyMakeAbsolute (RDFFile f, char* url)
|
||||
{
|
||||
if (RDF_STRCHR(url, ':') != NULL) {
|
||||
return copyString(url);
|
||||
} else {
|
||||
char* ans = getMem(RDF_STRLEN(f->url) + strlen(url)+2);
|
||||
sprintf(ans, "%s#%s", f->url, url);
|
||||
return ans;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
containerTagp (RDFFile f, char* elementName)
|
||||
{
|
||||
return (tagEquals(f, elementName, "Container") ||
|
||||
tagEquals(f, elementName, "Topic") ||
|
||||
(tagEquals(f, elementName, "RelatedLinks")));
|
||||
}
|
||||
|
||||
#define DC_TITLE "http://purl.org/metadata/dublin_core/title"
|
||||
#define SM_CHILD "http://purl.org/metadata/sitemap/child"
|
||||
|
||||
RDF_Resource
|
||||
ResourceFromElementName (RDFFile f, char* elementName)
|
||||
{
|
||||
if(!elementName || (RDF_STRCHR(elementName, ':') == NULL) ) {
|
||||
return RDF_GetResource(NULL, elementName, 1);
|
||||
} else {
|
||||
XMLNameSpace ns = f->namespaces;
|
||||
while (ns) {
|
||||
if (startsWith(ns->as, elementName)) {
|
||||
RDF_Resource ans;
|
||||
size_t asn = RDF_STRLEN(ns->as);
|
||||
size_t urln = RDF_STRLEN(ns->url);
|
||||
char* url = getMem(RDF_STRLEN(ns->url) + strlen(elementName)-asn);
|
||||
memcpy(url, ns->url, urln);
|
||||
RDF_STRCAT(url, &elementName[asn+1]);
|
||||
if (RDF_STRCMP(url, DC_TITLE) == 0) {
|
||||
ans = gCoreVocab->RDF_name;
|
||||
} else if (RDF_STRCMP(url, SM_CHILD) == 0) {
|
||||
ans = gCoreVocab->RDF_child;
|
||||
} else
|
||||
ans = RDF_GetResource(NULL, url, 1);
|
||||
freeMem(url);
|
||||
return ans;
|
||||
}
|
||||
ns = ns->next;
|
||||
}
|
||||
return RDF_GetResource(NULL, elementName, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
parseNextRDFToken (RDFFile f, char* token)
|
||||
{
|
||||
char* attlist[2*MAX_ATTRIBUTES+1];
|
||||
char* elementName;
|
||||
if (token[0] != '<') {
|
||||
if ((f->status == EXPECTING_OBJECT) && (f->depth > 1)) {
|
||||
RDF_Resource u = f->stack[f->depth-2];
|
||||
RDF_Resource s = f->stack[f->depth-1];
|
||||
addSlotValue(f, u, s, copyStringIgnoreWhiteSpace(token), RDF_STRING_TYPE, NULL);
|
||||
}
|
||||
} else if (startsWith("<!--", token)) {
|
||||
return;
|
||||
} else if (token[1] == '?') {
|
||||
parseRDFProcessingInstruction(f, token);
|
||||
} else if (token[1] == '/') {
|
||||
if ((f->status != EXPECTING_OBJECT) && (f->status != EXPECTING_PROPERTY)) return;
|
||||
if (f->depth > 0) f->depth--;
|
||||
f->status = (f->status == EXPECTING_OBJECT ? EXPECTING_PROPERTY : EXPECTING_OBJECT);
|
||||
} else if ((f->status == 0) && startsWith("<RDF:RDF", token)) {
|
||||
char* status = NULL;
|
||||
char* update;
|
||||
char* post;
|
||||
f->status = EXPECTING_OBJECT;
|
||||
tokenizeElement(token, attlist, &elementName);
|
||||
update = getAttributeValue(attlist, "updateURL");
|
||||
post = getAttributeValue(attlist, "postURL");
|
||||
if (update) f->updateURL = copyString(update);
|
||||
if (post) f->postURL = copyString(post);
|
||||
status = getAttributeValue(attlist, "status");
|
||||
if (status && (RDF_STRCMP(status, "replace"))) gcRDFFileInt(f);
|
||||
} else if (startsWith("<RelatedLinks", token)) {
|
||||
f->stack[f->depth++] = f->top;
|
||||
f->status = EXPECTING_PROPERTY;
|
||||
} else {
|
||||
PRBool emptyElementp = (token[RDF_STRLEN(token)-2] == '/');
|
||||
if ((f->status != EXPECTING_OBJECT) && (f->status != EXPECTING_PROPERTY)) return;
|
||||
tokenizeElement(token, attlist, &elementName);
|
||||
if ((f->status == EXPECTING_PROPERTY) && (knownObjectElement(elementName))) return;
|
||||
if (f->status == EXPECTING_OBJECT) {
|
||||
char* url = NULL;
|
||||
RDF_Resource obj;
|
||||
uint16 count = 0;
|
||||
url = getHref(attlist);
|
||||
if (url == NULL) url = getAttributeValue(attlist, "id");
|
||||
if (url) url = possiblyMakeAbsolute(f, url);
|
||||
obj = ResourceFromElementName(f, url);
|
||||
if (url) freeMem(url);
|
||||
addToResourceList(f, obj);
|
||||
addElementProps (attlist, elementName, f, obj) ;
|
||||
if (!tagEquals(f, elementName, "RDF:Description")) {
|
||||
if (containerTagp(f, elementName)) {
|
||||
setContainerp(obj, 1);
|
||||
} else {
|
||||
RDF_Resource eln = ResourceFromElementName(f, elementName);
|
||||
addSlotValue(f, obj, gCoreVocab->RDF_instanceOf, eln, RDF_RESOURCE_TYPE, getAttributeValue(attlist, "tv"));
|
||||
}
|
||||
}
|
||||
if (f->depth > 1) {
|
||||
addSlotValue(f, f->stack[f->depth-2], f->stack[f->depth-1], obj,
|
||||
RDF_RESOURCE_TYPE, getAttributeValue(attlist, "tv"));
|
||||
}
|
||||
if (!emptyElementp) {
|
||||
f->stack[f->depth++] = obj;
|
||||
f->status = EXPECTING_PROPERTY;
|
||||
}
|
||||
} else if (f->status == EXPECTING_PROPERTY) {
|
||||
char* url;
|
||||
RDF_Resource obj;
|
||||
uint16 count = 0;
|
||||
url = getHref(attlist) ;
|
||||
if (url) {
|
||||
RDF_Resource eln = ResourceFromElementName(f, elementName);
|
||||
char* tvAtt = getAttributeValue(attlist, "tv");
|
||||
url = possiblyMakeAbsolute(f, url);
|
||||
obj = ResourceFromElementName(f, url);
|
||||
freeMem(url);
|
||||
addElementProps (attlist, elementName, f, obj) ;
|
||||
addToResourceList(f, obj);
|
||||
addSlotValue(f, f->stack[f->depth-1], eln,obj,RDF_RESOURCE_TYPE,
|
||||
getAttributeValue(attlist, "tv"));
|
||||
} else if ((RDF_STRCMP(elementName, "child") == 0) && attlist[0] &&
|
||||
(RDF_STRCMP(attlist[0], "instanceOf") == 0) &&
|
||||
attlist[1] && startsWith("Separator", attlist[1])) {
|
||||
RDF_Resource sep = createSeparator();
|
||||
RDF_Resource eln = ResourceFromElementName(f, elementName);
|
||||
addSlotValue(f, f->stack[f->depth-1], eln,sep,RDF_RESOURCE_TYPE,
|
||||
getAttributeValue(attlist, "tv"));
|
||||
}
|
||||
|
||||
if (!emptyElementp) {
|
||||
f->stack[f->depth++] = ResourceFromElementName(f, elementName);
|
||||
f->status = EXPECTING_OBJECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
tokenizeElement (char* attr, char** attlist, char** elementName)
|
||||
{
|
||||
size_t n = 1;
|
||||
size_t s = RDF_STRLEN(attr);
|
||||
char c ;
|
||||
size_t m = 0;
|
||||
size_t atc = 0;
|
||||
PRBool emptyTagp = (attr[s-2] == '/');
|
||||
PRBool inAttrNamep = 1;
|
||||
c = attr[n++];
|
||||
while (wsc(c)) {
|
||||
c = attr[n++];
|
||||
}
|
||||
*elementName = &attr[n-1];
|
||||
while (n < s) {
|
||||
if (wsc(c)) break;
|
||||
c = attr[n++];
|
||||
}
|
||||
attr[n-1] = '\0';
|
||||
while (atc < 2*MAX_ATTRIBUTES+1) {*(attlist + atc++) = NULL;}
|
||||
atc = 0;
|
||||
s = (emptyTagp ? s-2 : s-1);
|
||||
while (n < s) {
|
||||
PRBool attributeOpenStringSeenp = 0;
|
||||
m = 0;
|
||||
c = attr[n++];
|
||||
while ((n <= s) && (atc < 2*MAX_ATTRIBUTES)) {
|
||||
if (inAttrNamep && (m > 0) && (wsc(c) || (c == '='))) {
|
||||
attr[n-1] = '\0';
|
||||
*(attlist + atc++) = &attr[n-m-1];
|
||||
break;
|
||||
}
|
||||
if (!inAttrNamep && attributeOpenStringSeenp && (c == '"')) {
|
||||
attr[n-1] = '\0';
|
||||
*(attlist + atc++) = &attr[n-m-1];
|
||||
break;
|
||||
}
|
||||
if (inAttrNamep) {
|
||||
if ((m > 0) || (!wsc(c))) m++;
|
||||
} else {
|
||||
if (c == '"') {
|
||||
attributeOpenStringSeenp = 1;
|
||||
} else {
|
||||
if ((m > 0) || (!(wsc(c)))) m++;
|
||||
}
|
||||
}
|
||||
c = attr[n++];
|
||||
}
|
||||
inAttrNamep = (inAttrNamep ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
outputRDFTreeInt (RDF rdf, PRFileDesc *fp, RDF_Resource node, uint32 depth, PRBool localOnly)
|
||||
{
|
||||
RDF_Cursor c = RDF_GetSources(rdf, node, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
|
||||
RDF_Resource next;
|
||||
char* buf = getMem(1024);
|
||||
char* space = getMem((4*depth)+1);
|
||||
char* url = resourceID(node);
|
||||
char* name = RDF_GetResourceName(rdf, node);
|
||||
char* hrefid;
|
||||
|
||||
if ((buf == NULL) || (space == NULL)) return;
|
||||
if (depth > 0) memset(space, ' ', depth);
|
||||
|
||||
if (!RDF_STRCHR(url, ':') || (depth == 0)) {
|
||||
hrefid = "id";
|
||||
} else {
|
||||
hrefid = "rdf:href";
|
||||
}
|
||||
|
||||
if (depth == 0) url="root";
|
||||
|
||||
if (containerp(node)) {
|
||||
if (depth > 0) {
|
||||
sprintf(buf, "%s<child>\n", space);
|
||||
PR_Write(fp, buf, RDF_STRLEN(buf));
|
||||
}
|
||||
sprintf(buf, "%s<Topic %s=\"%s\"\n%s name=\"%s\">\n", space, hrefid, url, space, name);
|
||||
PR_Write(fp, buf, RDF_STRLEN(buf));
|
||||
|
||||
while ((next = RDF_NextValue(c)) != NULL) {
|
||||
|
||||
/* if exporting EVERYTHING, need to skip over certain things */
|
||||
if ((localOnly == PR_FALSE) || ((!startsWith("ftp:",url)) && (!startsWith("file:",url))
|
||||
&& (!startsWith("IMAP:", url)) && (!startsWith("nes:", url))
|
||||
&& (!startsWith("mail:", url)) && (!startsWith("cache:", url))
|
||||
&& (!startsWith("ldap:", url)) &&
|
||||
(!urlEquals(resourceID(node), resourceID(gNavCenter->RDF_LocalFiles))) &&
|
||||
(!urlEquals(resourceID(node), resourceID(gNavCenter->RDF_History)))))
|
||||
{
|
||||
outputRDFTreeInt(rdf, fp, next, depth+1, localOnly);
|
||||
}
|
||||
}
|
||||
sprintf(buf, "%s</Topic>\n", space);
|
||||
PR_Write(fp, buf, RDF_STRLEN(buf));
|
||||
if (depth > 0) {
|
||||
sprintf(buf, "%s</child>\n", space);
|
||||
PR_Write(fp, buf, RDF_STRLEN(buf));
|
||||
}
|
||||
} else {
|
||||
sprintf(buf, "%s<child %s=\"%s\"\n%s name=\"%s\"/>\n", space, hrefid, url, space, name);
|
||||
PR_Write(fp, buf, RDF_STRLEN(buf));
|
||||
}
|
||||
RDF_DisposeCursor(c);
|
||||
freeMem(buf);
|
||||
freeMem(space);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
outputRDFTree (RDF rdf, PRFileDesc *fp, RDF_Resource node)
|
||||
{
|
||||
ht_fprintf(fp, "<RDF:RDF>\n\n");
|
||||
outputRDFTreeInt(rdf, fp, node, 0, (node==gNavCenter->RDF_Top) ? PR_TRUE:PR_FALSE);
|
||||
ht_fprintf(fp, "\n</RDF:RDF>\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
addSlotValue (RDFFile f, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, char* op)
|
||||
{
|
||||
PRBool tv;
|
||||
if (f == NULL || u == NULL || s == NULL || v == NULL) return;
|
||||
if (s == gCoreVocab->RDF_child) {
|
||||
RDF_Resource temp = (RDF_Resource)v;
|
||||
if (type != RDF_RESOURCE_TYPE) return;
|
||||
s = gCoreVocab->RDF_parent;
|
||||
v = u;
|
||||
u = temp;
|
||||
}
|
||||
if (op == NULL) {
|
||||
tv = 1;
|
||||
} else if (RDF_STRCMP(op, "true") == 0) {
|
||||
tv = 1;
|
||||
} else if (RDF_STRCMP(op, "false") == 0) {
|
||||
tv = 0;
|
||||
} else if (RDF_STRCMP(op, "delete") == 0) {
|
||||
if (f->unassert) (*f->unassert)(f, f->db, u, s, v, type);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE)) {
|
||||
f->genlAdded = true;
|
||||
if (strstr(resourceID(u), ".rdf") && startsWith("http", resourceID(u))) {
|
||||
RDFL rl = f->db->rdf;
|
||||
char* dburl = getBaseURL(resourceID(u));
|
||||
if (!startsWith(dburl, resourceID((RDF_Resource)v))) {
|
||||
while (rl) {
|
||||
RDF_AddDataSource(rl->rdf, dburl);
|
||||
rl = rl->next;
|
||||
}
|
||||
freeMem(dburl);
|
||||
}
|
||||
}
|
||||
}
|
||||
(*f->assert)(f, f->db, u, s, v, type, tv);
|
||||
if (s == gCoreVocab->RDF_parent) setContainerp((RDF_Resource)v, 1);
|
||||
#ifndef MOZILLA_CLIENT
|
||||
notifySlotValueAdded(u, s, v, type);
|
||||
#endif
|
||||
}
|
||||
|
||||
60
mozilla/modules/rdf/src/rdfparse.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_RDFPARSE_H_
|
||||
#define _RDF_RDFPARSE_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/* rdfparse.c data structures and defines */
|
||||
|
||||
#define wsc(c) ((c == ' ') || (c == '\r') || (c == '\n') || (c == '\t'))
|
||||
|
||||
|
||||
#define EXPECTING_OBJECT 21
|
||||
#define EXPECTING_PROPERTY 22
|
||||
|
||||
|
||||
|
||||
/* rdfparse.c function prototypes */
|
||||
|
||||
|
||||
|
||||
char decodeEntityRef (char* string, int32* stringIndexPtr, int32 len);
|
||||
char * copyStringIgnoreWhiteSpace(char* string);
|
||||
char * getHref(char** attlist);
|
||||
void parseRDFProcessingInstruction (RDFFile f, char* token);
|
||||
PR_PUBLIC_API(char *) getAttributeValue (char** attlist, char* elName);
|
||||
PRBool tagEquals (RDFFile f, char* tag1, char* tag2);
|
||||
void addElementProps (char** attlist, char* elementName, RDFFile f, RDF_Resource obj);
|
||||
PRBool knownObjectElement (char* eln);
|
||||
char * possiblyMakeAbsolute (RDFFile f, char* url);
|
||||
PRBool containerTagp (RDFFile f, char* elementName);
|
||||
RDF_Resource ResourceFromElementName (RDFFile f, char* elementName);
|
||||
void parseNextRDFToken (RDFFile f, char* token);
|
||||
void tokenizeElement (char* attr, char** attlist, char** elementName);
|
||||
void outputRDFTreeInt (RDF rdf, PRFileDesc *fp, RDF_Resource node, uint32 depth, PRBool localOnly);
|
||||
void outputRDFTree (RDF rdf, PRFileDesc *fp, RDF_Resource node);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
32
mozilla/modules/rdf/src/rdfstr.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "plstr.h"
|
||||
|
||||
#define RDF_STRLEN(s) PL_strlen((s))
|
||||
#define RDF_STRCMP(s1,s2) PL_strcmp((s1),(s2))
|
||||
|
||||
/* #define RDF_STRDUP(s) PL_strdup((s)) evil? */
|
||||
|
||||
#define RDF_STRCHR(s,c) PL_strchr((s),(c))
|
||||
#define RDF_STRRCHR(s,c) PL_strrchr((s),(c))
|
||||
#define RDF_STRCAT(dest,src) PL_strcat((dest),(src))
|
||||
#define RDF_STRCASECMP(s1,s2) PL_strcasecmp((s1),(s2))
|
||||
#define RDF_STRNCASECMP(s1,s2,n) PL_strncasecmp((s1),(s2),(n))
|
||||
#define RDF_STRCASESTR(s1,s2) PL_strcasestr((s1),(s2))
|
||||
|
||||
832
mozilla/modules/rdf/src/remstore.c
Normal file
@@ -0,0 +1,832 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements remote store support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "remstore.h"
|
||||
|
||||
/* globals */
|
||||
|
||||
extern char *profileDirURL;
|
||||
extern char *gBookmarkURL;
|
||||
RDFT gLocalStore = 0;
|
||||
|
||||
RDFT
|
||||
MakeRemoteStore (char* url)
|
||||
{
|
||||
if (startsWith("rdf:remoteStore", url)) {
|
||||
if (gRemoteStore == 0) {
|
||||
gRemoteStore = NewRemoteStore(url);
|
||||
return gRemoteStore;
|
||||
} else return gRemoteStore;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeFileDB (char* url)
|
||||
{
|
||||
if (RDF_STRCHR(url, ':')) {
|
||||
RDFT ntr = NewRemoteStore(url);
|
||||
ntr->possiblyAccessFile = RDFFilePossiblyAccessFile ;
|
||||
if (RDF_STRCMP(gNavCntrUrl, url) == 0)
|
||||
readRDFFile(url, RDF_GetResource(NULL, url, 1), 0, ntr);
|
||||
return ntr;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
asEqual(RDFT r, Assertion as, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
return ((as->db == r) && (as->u == u) && (as->s == s) && (as->type == type) &&
|
||||
((as->value == v) ||
|
||||
((type == RDF_STRING_TYPE) && ((RDF_STRCMP(v, as->value) == 0) || (((char *)v)[0] =='\0')))));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
makeNewAssertion (RDFT r, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion newAs = (Assertion) getMem(sizeof(struct RDF_AssertionStruct));
|
||||
newAs->u = u;
|
||||
newAs->s = s;
|
||||
newAs->value = v;
|
||||
newAs->type = type;
|
||||
newAs->tv = tv;
|
||||
newAs->db = r;
|
||||
if (RDF_STRCMP(r->url, "rdf:history")) {
|
||||
int n = 0;
|
||||
}
|
||||
return newAs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
freeAssertion (Assertion as)
|
||||
{
|
||||
if (as->type == RDF_STRING_TYPE) {
|
||||
freeMem(as->value);
|
||||
}
|
||||
freeMem(as);
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
remoteAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
return (remoteStoreAdd(mcf, u, s, v, type, tv) != NULL);
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
remoteUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
return (remoteStoreRemove(mcf, u, s, v, type) != NULL);
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
remoteAssert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion as = remoteStoreAdd(mcf, u, s, v, type, tv);
|
||||
if (as != NULL) {
|
||||
addToAssertionList(fi, as);
|
||||
return 1;
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
remoteUnassert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
Assertion as = remoteStoreRemove(mcf, u, s, v, type);
|
||||
if (as != NULL) {
|
||||
removeFromAssertionList(fi, as);
|
||||
return 1;
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
remoteStoreflushChildren(RDFT mcf, RDF_Resource parent)
|
||||
{
|
||||
RDF_Cursor c;
|
||||
RDF_Resource child;
|
||||
#if 0
|
||||
RDF_Cursor cc;
|
||||
RDF_Resource s;
|
||||
char *value;
|
||||
#endif
|
||||
|
||||
if (parent == NULL) return;
|
||||
if ((c = remoteStoreGetSlotValues (mcf, parent, gCoreVocab->RDF_parent,
|
||||
RDF_RESOURCE_TYPE, true, true)) != NULL)
|
||||
{
|
||||
while((child = remoteStoreNextValue (mcf, c)) != NULL)
|
||||
{
|
||||
remoteStoreflushChildren(mcf, child);
|
||||
|
||||
/* XXX should we remove all arcs coming off of this node? */
|
||||
#if 0
|
||||
if ((cc = remoteStoreArcLabelsOut(mcf, child)) != NULL)
|
||||
{
|
||||
if ((s = remoteStoreNextValue (mcf, cc)) != NULL)
|
||||
{
|
||||
if (s == gCoreVocab->RDF_name)
|
||||
{
|
||||
value = remoteStoreGetSlotValue (mcf, child, s,
|
||||
RDF_STRING_TYPE, PR_FALSE, PR_TRUE);
|
||||
if (value != NULL)
|
||||
{
|
||||
remoteStoreRemove (mcf, child, s,
|
||||
value, RDF_STRING_TYPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
remoteStoreDisposeCursor(mcf, cc);
|
||||
}
|
||||
#endif
|
||||
remoteStoreRemove (mcf, child, gCoreVocab->RDF_parent,
|
||||
parent, RDF_RESOURCE_TYPE);
|
||||
}
|
||||
remoteStoreDisposeCursor (mcf, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
remoteStoreAdd (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion nextAs, prevAs, newAs;
|
||||
nextAs = prevAs = u->rarg1;
|
||||
|
||||
if (s == gNavCenter->RDF_Command)
|
||||
{
|
||||
if ((type == RDF_RESOURCE_TYPE) && (tv) && (v == gNavCenter->RDF_Command_Refresh))
|
||||
{
|
||||
/* flush any children of 'u' */
|
||||
remoteStoreflushChildren(mcf, u);
|
||||
}
|
||||
/* don't store RDF Commands in the remote store */
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
while (nextAs != null) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type)) return null;
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
newAs = makeNewAssertion(mcf, u, s, v, type, tv);
|
||||
if (prevAs == null) {
|
||||
u->rarg1 = newAs;
|
||||
} else {
|
||||
prevAs->next = newAs;
|
||||
}
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
nextAs = prevAs = ((RDF_Resource)v)->rarg2;
|
||||
while (nextAs != null) {
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
if (prevAs == null) {
|
||||
((RDF_Resource)v)->rarg2 = newAs;
|
||||
} else {
|
||||
prevAs->invNext = newAs;
|
||||
}
|
||||
}
|
||||
sendNotifications2(mcf, RDF_ASSERT_NOTIFY, u, s, v, type, tv);
|
||||
return newAs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
remoteStoreRemove (RDFT mcf, RDF_Resource u, RDF_Resource s,
|
||||
void* v, RDF_ValueType type)
|
||||
{
|
||||
Assertion nextAs, prevAs, ans;
|
||||
PRBool found = false;
|
||||
nextAs = prevAs = u->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type)) {
|
||||
if (prevAs == nextAs) {
|
||||
u->rarg1 = nextAs->next;
|
||||
} else {
|
||||
prevAs->next = nextAs->next;
|
||||
}
|
||||
found = true;
|
||||
ans = nextAs;
|
||||
break;
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
if (found == false) return null;
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
nextAs = prevAs = ((RDF_Resource)v)->rarg2;
|
||||
while (nextAs != null) {
|
||||
if (nextAs == ans) {
|
||||
if (prevAs == nextAs) {
|
||||
((RDF_Resource)v)->rarg2 = nextAs->invNext;
|
||||
} else {
|
||||
prevAs->invNext = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
sendNotifications2(mcf, RDF_DELETE_NOTIFY, u, s, v, type, ans->tv);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static PRBool
|
||||
fileReadp (RDFT rdf, char* url, PRBool mark)
|
||||
{
|
||||
RDFFile f;
|
||||
RDFFile rdfFiles = (RDFFile) rdf->pdata;
|
||||
uint n = 0;
|
||||
for (f = rdfFiles; (f != NULL) ; f = f->next) {
|
||||
if (urlEquals(url, f->url)) {
|
||||
if (mark == true) f->lastReadTime = PR_Now();
|
||||
return false; /* true; */
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
possiblyAccessFile (RDFT mcf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
if (mcf->possiblyAccessFile)
|
||||
(*(mcf->possiblyAccessFile))(mcf, u, s, inversep);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
RDFFilePossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
if ((resourceType(u) == RDF_RT) &&
|
||||
(startsWith(rdf->url, resourceID(u))) &&
|
||||
|
||||
(s == gCoreVocab->RDF_parent) && (containerp(u))) {
|
||||
readRDFFile( resourceID(u), u, false, rdf);
|
||||
/* if(newFile) newFile->lastReadTime = PR_Now(); */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
if ((s == gNavCenter->RDF_Command) && (type == RDF_RESOURCE_TYPE) && (tv) && (v == gNavCenter->RDF_Command_Refresh))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
nextAs = u->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type) && (nextAs->tv == tv)) return true;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
possiblyAccessFile(mcf, u, s, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
remoteStoreGetSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
|
||||
if ((s == gWebData->RDF_URL) && (tv) && (!inversep) && (type == RDF_STRING_TYPE))
|
||||
{
|
||||
return copyString(resourceID(u));
|
||||
}
|
||||
|
||||
nextAs = (inversep ? u->rarg2 : u->rarg1);
|
||||
while (nextAs != null) {
|
||||
if ((nextAs->db == mcf) && (nextAs->s == s) && (nextAs->tv == tv) && (nextAs->type == type)) {
|
||||
void* ans = (inversep ? nextAs->u : nextAs->value);
|
||||
if (type == RDF_STRING_TYPE) {
|
||||
return copyString((char*)ans);
|
||||
} else return ans;
|
||||
}
|
||||
nextAs = (inversep ? nextAs->invNext : nextAs->next);
|
||||
}
|
||||
if (s == gCoreVocab->RDF_parent) possiblyAccessFile(mcf, u, s, inversep);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
remoteStoreGetSlotValuesInt (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
Assertion as = (inversep ? u->rarg2 : u->rarg1);
|
||||
RDF_Cursor c;
|
||||
if (as == null) {
|
||||
possiblyAccessFile(mcf, u, s, inversep);
|
||||
as = (inversep ? u->rarg2 : u->rarg1);
|
||||
if (as == NULL) return null;
|
||||
}
|
||||
c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct));
|
||||
c->u = u;
|
||||
c->s = s;
|
||||
c->type = type;
|
||||
c->inversep = inversep;
|
||||
c->tv = tv;
|
||||
c->count = 0;
|
||||
c->pdata = as;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
remoteStoreGetSlotValues (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
|
||||
return remoteStoreGetSlotValuesInt(mcf, u, s, type, inversep, tv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
remoteStoreArcLabelsIn (RDFT mcf, RDF_Resource u)
|
||||
{
|
||||
if (u->rarg2) {
|
||||
RDF_Cursor c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct));
|
||||
c->u = u;
|
||||
c->queryType = RDF_ARC_LABELS_IN_QUERY;
|
||||
c->pdata = u->rarg2;
|
||||
return c;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
remoteStoreArcLabelsOut (RDFT mcf, RDF_Resource u)
|
||||
{
|
||||
if (u->rarg1) {
|
||||
RDF_Cursor c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct));
|
||||
c->u = u;
|
||||
c->queryType = RDF_ARC_LABELS_OUT_QUERY;
|
||||
c->pdata = u->rarg1;
|
||||
return c;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
arcLabelsOutNextValue (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
while (c->pdata != null) {
|
||||
Assertion as = (Assertion) c->pdata;
|
||||
if ((as->db == mcf) && (as->u == c->u)) {
|
||||
c->value = as->s;
|
||||
c->pdata = as->next;
|
||||
return c->value;
|
||||
}
|
||||
c->pdata = as->next;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
arcLabelsInNextValue (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
while (c->pdata != null) {
|
||||
Assertion as = (Assertion) c->pdata;
|
||||
if ((as->db == mcf) && (as->value == c->u)) {
|
||||
c->value = as->s;
|
||||
c->pdata = as->invNext;
|
||||
return c->value;
|
||||
}
|
||||
c->pdata = as->invNext;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
remoteStoreNextValue (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
if (c->queryType == RDF_ARC_LABELS_OUT_QUERY) {
|
||||
return arcLabelsOutNextValue(mcf, c);
|
||||
} else if (c->queryType == RDF_ARC_LABELS_IN_QUERY) {
|
||||
return arcLabelsInNextValue(mcf, c);
|
||||
} else {
|
||||
while (c->pdata != null) {
|
||||
Assertion as = (Assertion) c->pdata;
|
||||
if ((as->db == mcf) && (as->s == c->s) && (as->tv == c->tv) && (c->type == as->type)) {
|
||||
c->value = (c->inversep ? as->u : as->value);
|
||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
||||
return c->value;
|
||||
}
|
||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
remoteStoreDisposeCursor (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
freeMem(c);
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static RDFFile
|
||||
leastRecentlyUsedRDFFile (RDF mcf)
|
||||
{
|
||||
RDFFile lru = mcf->files;
|
||||
RDFFile f;
|
||||
#ifndef HAVE_LONG_LONG
|
||||
int64 result;
|
||||
#endif /* !HAVE_LONG_LONG */
|
||||
for (f = mcf->files ; (f != NULL) ; f = f->next) {
|
||||
if (!f->locked) {
|
||||
#ifndef HAVE_LONG_LONG
|
||||
LL_SUB(result, lru->lastReadTime, f->lastReadTime);
|
||||
if ((!LL_IS_ZERO(result) && LL_GE_ZERO(result)) && (f->localp == false))
|
||||
#else
|
||||
if (((lru->lastReadTime - f->lastReadTime) > 0) && (f->localp == false))
|
||||
#endif /* !HAVE_LONG_LONG */
|
||||
lru = f;
|
||||
}
|
||||
}
|
||||
if (!lru->locked) {
|
||||
return lru;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
gcRDFFileInt (RDFFile f)
|
||||
{
|
||||
int32 n = 0;
|
||||
while (n < f->assertionCount) {
|
||||
Assertion as = *(f->assertionList + n);
|
||||
remoteStoreRemove(f->db, as->u, as->s, as->value, as->type);
|
||||
freeAssertion(as);
|
||||
*(f->assertionList + n) = NULL;
|
||||
n++;
|
||||
}
|
||||
n = 0;
|
||||
while (n < f->resourceCount) {
|
||||
*(f->resourceList + n) = NULL;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
DeleteRemStore (RDFT db)
|
||||
{
|
||||
RDFFile f = (RDFFile) db->pdata;
|
||||
RDFFile next;
|
||||
while (f) {
|
||||
next = f->next;
|
||||
gcRDFFileInt(f);
|
||||
freeMem(f->assertionList);
|
||||
freeMem(f->resourceList);
|
||||
f = next;
|
||||
}
|
||||
freeMem(db);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
remStoreUpdate (RDFT db, RDF_Resource u)
|
||||
{
|
||||
RDFFile f = db->pdata;
|
||||
if (f != NULL) {
|
||||
int32 n = 0;
|
||||
PRBool proceedp = 0;
|
||||
while (n < f->resourceCount) {
|
||||
if (*(f->resourceList + n++) == u) {
|
||||
proceedp = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (proceedp) {
|
||||
RDF_Resource top = f->top;
|
||||
char* url = db->url;
|
||||
PRBool localp = f->localp;
|
||||
gcRDFFileInt(f);
|
||||
freeMem(f->assertionList);
|
||||
freeMem(f->resourceList);
|
||||
f->assertionList = NULL;
|
||||
f->resourceList = NULL;
|
||||
initRDFFile(f);
|
||||
f->refreshingp = 1;
|
||||
beginReadingRDFFile(f);
|
||||
return 0;
|
||||
} else return -1;
|
||||
} else return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
gcRDFFile (RDFFile f)
|
||||
{
|
||||
RDFFile f1 = (RDFFile) f->db->pdata;
|
||||
|
||||
if (f->locked) return;
|
||||
|
||||
if (f == f1) {
|
||||
f->db->pdata = f->next;
|
||||
} else {
|
||||
RDFFile prev = f1;
|
||||
while (f1 != NULL) {
|
||||
if (f1 == f) {
|
||||
prev->next = f->next;
|
||||
break;
|
||||
}
|
||||
prev = f1;
|
||||
f1 = f1->next;
|
||||
}
|
||||
}
|
||||
gcRDFFileInt(f);
|
||||
freeMem(f->assertionList);
|
||||
freeMem(f->resourceList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static PRBool
|
||||
freeSomeRDFSpace (RDF mcf)
|
||||
{
|
||||
RDFFile lru = leastRecentlyUsedRDFFile (mcf);
|
||||
if (lru== NULL) {
|
||||
return false;
|
||||
} else {
|
||||
gcRDFFile(lru);
|
||||
freeMem(lru);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFFile
|
||||
readRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db)
|
||||
{
|
||||
RDFFile f = makeNewRDFFile(url, top, localp, db);
|
||||
if (!f) return NULL;
|
||||
beginReadingRDFFile(f);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFFile
|
||||
makeNewRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db)
|
||||
{
|
||||
if ((!strstr(url, ":/")) ||
|
||||
(fileReadp(db, url, true))) {
|
||||
return NULL;
|
||||
} else {
|
||||
RDFFile newFile = makeRDFFile(url, top, localp);
|
||||
if (db->pdata) {
|
||||
newFile->next = (RDFFile) db->pdata;
|
||||
db->pdata = newFile;
|
||||
} else {
|
||||
db->pdata = (RDFFile) newFile;
|
||||
}
|
||||
newFile->assert = remoteAssert3;
|
||||
newFile->unassert = remoteUnassert3;
|
||||
if (top) {
|
||||
if (resourceType(top) == RDF_RT) {
|
||||
if (strstr(url, ".mcf")) {
|
||||
newFile->fileType = RDF_MCF;
|
||||
} else {
|
||||
newFile->fileType = RDF_XML;
|
||||
}
|
||||
} else {
|
||||
newFile->fileType = resourceType(top);
|
||||
}
|
||||
}
|
||||
newFile->db = db;
|
||||
return newFile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
possiblyRefreshRDFFiles ()
|
||||
{
|
||||
RDFFile f = (RDFFile)gRemoteStore->pdata;
|
||||
PRTime tm = PR_Now();
|
||||
while (f != NULL) {
|
||||
if (f->expiryTime != NULL) {
|
||||
PRTime *expiry = f->expiryTime;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
if ((tm - *expiry) > 0)
|
||||
#else
|
||||
int64 result;
|
||||
LL_SUB(result, tm, *expiry);
|
||||
if ((!LL_IS_ZERO(result) && LL_GE_ZERO(result)))
|
||||
#endif
|
||||
{
|
||||
gcRDFFile (f);
|
||||
initRDFFile(f);
|
||||
beginReadingRDFFile(f);
|
||||
}
|
||||
}
|
||||
f = f->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
SCookPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
/*if ((resourceType(u) == RDF_RT) && (startsWith("rdf:ht", rdf->url)) &&
|
||||
(s == gCoreVocab->RDF_parent) &&
|
||||
(containerp(u))) {
|
||||
RDFFile newFile = readRDFFile( resourceID(u), u, false, rdf);
|
||||
if(newFile) newFile->lastReadTime = PR_Now();
|
||||
} */
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
NewRemoteStore (char* url)
|
||||
{
|
||||
RDFT ntr;
|
||||
|
||||
if ((ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct))) != NULL)
|
||||
{
|
||||
ntr->getSlotValue = remoteStoreGetSlotValue;
|
||||
ntr->getSlotValues = remoteStoreGetSlotValues;
|
||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->nextValue = remoteStoreNextValue;
|
||||
ntr->disposeCursor = remoteStoreDisposeCursor;
|
||||
ntr->url = copyString(url);
|
||||
ntr->destroy = DeleteRemStore;
|
||||
ntr->arcLabelsIn = remoteStoreArcLabelsIn;
|
||||
ntr->arcLabelsOut = remoteStoreArcLabelsOut;
|
||||
ntr->update = remStoreUpdate;
|
||||
}
|
||||
return(ntr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeSCookDB (char* url)
|
||||
{
|
||||
if (startsWith("rdf:scook:", url) || (startsWith("rdf:ht", url))) {
|
||||
RDFT ntr = NewRemoteStore(url);
|
||||
ntr->possiblyAccessFile = SCookPossiblyAccessFile;
|
||||
return ntr;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
RDFT
|
||||
MakeLocalStore (char* url)
|
||||
{
|
||||
char* file = makeRDFDBURL(profileDirURL, "localStore.rdf");
|
||||
RDFT ntr = NewRemoteStore(file);
|
||||
gLocalStore = ntr;
|
||||
ntr->assert = remoteAssert;
|
||||
ntr->unassert = remoteUnassert;
|
||||
return ntr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
addToRDFTOut (RDFTOut out)
|
||||
{
|
||||
int32 len = RDF_STRLEN(out->temp);
|
||||
if (len + out->bufferPos < out->bufferSize) {
|
||||
RDF_STRCAT(out->buffer, out->temp);
|
||||
out->bufferPos = out->bufferPos + len;
|
||||
memset(out->temp, '\0', 1000);
|
||||
} else {
|
||||
PR_Realloc(out->buffer, out->bufferSize + 20000);
|
||||
out->bufferSize = out->bufferSize + 20000;
|
||||
addToRDFTOut (out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRIntn
|
||||
RDFSerializerEnumerator (PLHashEntry *he, PRIntn i, void *arg)
|
||||
{
|
||||
RDF_Resource u = (RDF_Resource)he->value;
|
||||
RDFTOut out = (RDFTOut) arg;
|
||||
Assertion as = u->rarg1;
|
||||
PRBool somethingOutp = 0;
|
||||
while (as) {
|
||||
if (as->db == out->store) {
|
||||
if (!somethingOutp) {
|
||||
somethingOutp = 1;
|
||||
sprintf(out->temp, "<RDF:Description href=\"%s\">\n", resourceID(as->u));
|
||||
addToRDFTOut(out);
|
||||
}
|
||||
if (as->type == RDF_RESOURCE_TYPE) {
|
||||
sprintf(out->temp, " <%s href=\"%s\"/>\n", resourceID(as->s),
|
||||
resourceID((RDF_Resource)as->value));
|
||||
} else if (as->type == RDF_INT_TYPE) {
|
||||
sprintf(out->temp, " <%s dt=\"int\">%i</%s>\n", resourceID(as->s),
|
||||
(int)as->value, resourceID(as->s));
|
||||
} else {
|
||||
sprintf(out->temp, " <%s>%s</%s>\n", resourceID(as->s),
|
||||
(char*)as->value, resourceID(as->s));
|
||||
}
|
||||
addToRDFTOut(out);
|
||||
}
|
||||
as = as->next;
|
||||
}
|
||||
if (somethingOutp) {
|
||||
sprintf(out->temp, "</RDF:Description>\n\n");
|
||||
addToRDFTOut(out);
|
||||
}
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
RDF_SerializeRDFStore (RDFT store) {
|
||||
RDFTOut out = getMem(sizeof(struct RDFTOutStruct));
|
||||
char* ans = out->buffer = getMem(20000);
|
||||
out->bufferSize = 20000;
|
||||
out->temp = getMem(1000);
|
||||
out->store = store;
|
||||
sprintf(out->temp, "<RDF:RDF>\n\n");
|
||||
addToRDFTOut(out);
|
||||
PL_HashTableEnumerateEntries(resourceHash, RDFSerializerEnumerator, out);
|
||||
sprintf(out->temp, "</RDF:RDF>\n\n");
|
||||
addToRDFTOut(out);
|
||||
freeMem(out->temp);
|
||||
freeMem(out);
|
||||
return ans;
|
||||
}
|
||||
|
||||
85
mozilla/modules/rdf/src/remstore.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_REMSTORE_H_
|
||||
#define _RDF_REMSTORE_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
#include "prtime.h"
|
||||
|
||||
|
||||
|
||||
/* remstore.c data structures and defines */
|
||||
|
||||
struct RDFTOutStruct {
|
||||
char *buffer;
|
||||
int32 bufferSize;
|
||||
int32 bufferPos;
|
||||
char *temp;
|
||||
RDFT store;
|
||||
};
|
||||
typedef struct RDFTOutStruct *RDFTOut;
|
||||
|
||||
|
||||
|
||||
/* remstore.c function prototypes */
|
||||
|
||||
|
||||
|
||||
RDFT MakeRemoteStore (char* url);
|
||||
RDFT existingRDFFileDB (char* url);
|
||||
RDFT MakeFileDB (char* url);
|
||||
void freeAssertion (Assertion as);
|
||||
PRBool remoteAssert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool remoteUnassert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
void remoteStoreflushChildren(RDFT mcf, RDF_Resource parent);
|
||||
Assertion remoteStoreAdd (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
Assertion remoteStoreRemove (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool fileReadablep (char* id);
|
||||
PRBool remoteStoreHasAssertionInt (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
void * remoteStoreGetSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor remoteStoreGetSlotValuesInt (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor remoteStoreGetSlotValues (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor remoteStoreArcLabelsIn (RDFT mcf, RDF_Resource u);
|
||||
RDF_Cursor remoteStoreArcLabelsOut (RDFT mcf, RDF_Resource u);
|
||||
void * arcLabelsOutNextValue (RDFT mcf, RDF_Cursor c);
|
||||
void * arcLabelsInNextValue (RDFT mcf, RDF_Cursor c);
|
||||
void * remoteStoreNextValue (RDFT mcf, RDF_Cursor c);
|
||||
RDF_Error remoteStoreDisposeCursor (RDFT mcf, RDF_Cursor c);
|
||||
RDF_Error DeleteRemStore (RDFT db);
|
||||
RDF_Error remStoreUpdate (RDFT db, RDF_Resource u);
|
||||
void gcRDFFile (RDFFile f);
|
||||
void RDFFilePossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
void possiblyRefreshRDFFiles ();
|
||||
void SCookPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
RDFT MakeSCookDB (char* url);
|
||||
void addToRDFTOut (RDFTOut out);
|
||||
PRIntn RDFSerializerEnumerator (PLHashEntry *he, PRIntn i, void *arg);
|
||||
RDFFile makeNewRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db) ;
|
||||
static PRBool fileReadp (RDFT rdf, char* url, PRBool mark);
|
||||
static void possiblyAccessFile (RDFT mcf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
static RDFFile leastRecentlyUsedRDFFile (RDF mcf);
|
||||
static PRBool freeSomeRDFSpace (RDF mcf);
|
||||
RDFFile reReadRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
440
mozilla/modules/rdf/src/scook.c
Normal file
@@ -0,0 +1,440 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements Super Cookie support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "scook.h"
|
||||
#include "glue.h"
|
||||
#include "remstore.h"
|
||||
|
||||
|
||||
/* externs */
|
||||
extern char* profileDirURL;
|
||||
|
||||
|
||||
|
||||
char *
|
||||
makeSCookPathname(char* name)
|
||||
{
|
||||
char *ans ;
|
||||
size_t s;
|
||||
|
||||
if ((ans = (char*) getMem(RDF_STRLEN(profileDirURL) + strlen(name) + 8)) != NULL) {
|
||||
s = RDF_STRLEN(profileDirURL);
|
||||
memcpy(ans, profileDirURL, s);
|
||||
if (ans[s-1] != '/') {
|
||||
ans[s++] = '/';
|
||||
}
|
||||
memcpy(&ans[s], "SCook/", 5);
|
||||
s = s + 5;
|
||||
|
||||
#ifdef XP_WIN
|
||||
if (ans[9] == '|') ans[9] = ':';
|
||||
#endif
|
||||
|
||||
CallPRMkDirUsingFileURL(ans, 00700);
|
||||
memcpy(&ans[s], name, RDF_STRLEN(name));
|
||||
}
|
||||
return(ans);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
SCookAssert1 (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
SCookAssert3 (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
return (SCookAssert(mcf, u, s, v, type, tv) != NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
SCookAssert2 (RDFFile file, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion as = SCookAssert(mcf , u, s, v, type, tv);
|
||||
if (as != NULL) {
|
||||
void addToAssertionList (RDFFile f, Assertion as) ;
|
||||
addToAssertionList(file, as);
|
||||
return 1;
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
SCookAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion nextAs, prevAs, newAs;
|
||||
nextAs = prevAs = getArg1(mcf, u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type)) return null;
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
newAs = makeNewAssertion(mcf, u, s, v, type, tv);
|
||||
if (prevAs == null) {
|
||||
setArg1(mcf, u, newAs);
|
||||
} else {
|
||||
prevAs->next = newAs;
|
||||
}
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
nextAs = prevAs = getArg2(mcf, (RDF_Resource)v);
|
||||
while (nextAs != null) {
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
if (prevAs == null) {
|
||||
setArg2(mcf, ((RDF_Resource)v), newAs);
|
||||
} else {
|
||||
prevAs->invNext = newAs;
|
||||
}
|
||||
}
|
||||
/* XXX have to mark the entire subtree XXX */
|
||||
sendNotifications2(mcf, RDF_ASSERT_NOTIFY, u, s, v, type, tv);
|
||||
return newAs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
SCookUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
Assertion as = SCookRemove(mcf, u, s, v, type);
|
||||
freeMem(as);
|
||||
return (as != NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
SCookRemove (RDFT mcf, RDF_Resource u, RDF_Resource s,
|
||||
void* v, RDF_ValueType type)
|
||||
{
|
||||
Assertion nextAs, prevAs, ans;
|
||||
PRBool found = false;
|
||||
nextAs = prevAs = getArg1(mcf, u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type)) {
|
||||
if (prevAs == nextAs) {
|
||||
setArg1(mcf, u, nextAs->next);
|
||||
} else {
|
||||
prevAs->next = nextAs->next;
|
||||
}
|
||||
found = true;
|
||||
ans = nextAs;
|
||||
break;
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
if (found == false) return null;
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
nextAs = prevAs = getArg2(mcf, (RDF_Resource)v);
|
||||
while (nextAs != null) {
|
||||
if (nextAs == ans) {
|
||||
if (prevAs == nextAs) {
|
||||
setArg2(mcf, ((RDF_Resource)v), nextAs->invNext);
|
||||
} else {
|
||||
prevAs->invNext = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
/* Need to make sure that if something is removed from the bookmark tree,
|
||||
the type is updated */
|
||||
sendNotifications2(mcf, RDF_DELETE_NOTIFY, u, s, v, type, ans->tv);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
SCookHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
nextAs = getArg1(mcf, u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type) && (nextAs->tv == tv)) return true;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
possiblyAccessSCookFile(mcf, u, s, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
SCookGetSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
nextAs = (inversep ? getArg2(mcf, u) : getArg1(mcf, u));
|
||||
while (nextAs != null) {
|
||||
if ((nextAs->s == s) && (nextAs->tv == tv) && (nextAs->type == type)) {
|
||||
return (inversep ? nextAs->u : nextAs->value);
|
||||
}
|
||||
nextAs = (inversep ? nextAs->invNext : nextAs->next);
|
||||
}
|
||||
possiblyAccessSCookFile(mcf, u, s, inversep);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
SCookGetSlotValues (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
Assertion as = (inversep ? getArg2(mcf, u) : getArg1(mcf, u));
|
||||
RDF_Cursor c;
|
||||
if (as == null) {
|
||||
possiblyAccessSCookFile(mcf, u, s, inversep);
|
||||
as = (inversep ? getArg2(mcf, u) : getArg1(mcf, u));
|
||||
if (as == NULL) return null;
|
||||
}
|
||||
c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct));
|
||||
c->u = u;
|
||||
c->s = s;
|
||||
c->type = type;
|
||||
c->inversep = inversep;
|
||||
c->tv = tv;
|
||||
c->count = 0;
|
||||
c->pdata = as;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
SCookNextValue (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
while (c->pdata != null) {
|
||||
Assertion as = (Assertion) c->pdata;
|
||||
if ((as->s == c->s) && (as->tv == c->tv) && (c->type == as->type)) {
|
||||
if (c->s == gCoreVocab->RDF_slotsHere) {
|
||||
c->value = as->s;
|
||||
} else {
|
||||
c->value = (c->inversep ? as->u : as->value);
|
||||
}
|
||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
||||
return c->value;
|
||||
}
|
||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
SCookDisposeCursor (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
freeMem(c);
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
getArg1 (RDFT r, RDF_Resource u)
|
||||
{
|
||||
return PL_HashTableLookup(((SCookDB)r->pdata)->lhash, u);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
getArg2 (RDFT r, RDF_Resource u)
|
||||
{
|
||||
return PL_HashTableLookup(((SCookDB)r->pdata)->rhash, u);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
setArg1 (RDFT r, RDF_Resource u, Assertion as)
|
||||
{
|
||||
if (as == NULL) {
|
||||
PL_HashTableRemove(((SCookDB)r->pdata)->lhash, u);
|
||||
} else {
|
||||
PL_HashTableAdd(((SCookDB)r->pdata)->lhash, u, as);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
setArg2 (RDFT r, RDF_Resource u, Assertion as)
|
||||
|
||||
{
|
||||
if (as == NULL) {
|
||||
PL_HashTableRemove(((SCookDB)r->pdata)->rhash, u);
|
||||
} else {
|
||||
PL_HashTableAdd(((SCookDB)r->pdata)->rhash, u, as);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
gcSCookFile (RDFT rdf, RDFFile f)
|
||||
{
|
||||
int16 n = 0;
|
||||
RDFFile f1;
|
||||
SCookDB sk = (SCookDB)rdf->pdata;
|
||||
f1 = sk->rf;
|
||||
|
||||
if (f->locked) return;
|
||||
|
||||
if (f == f1) {
|
||||
sk->rf = f->next;
|
||||
} else {
|
||||
RDFFile prev = f1;
|
||||
while (f1 != NULL) {
|
||||
if (f1 == f) {
|
||||
prev->next = f->next;
|
||||
break;
|
||||
}
|
||||
prev = f1;
|
||||
f1 = f1->next;
|
||||
}
|
||||
}
|
||||
|
||||
while (n < f->assertionCount) {
|
||||
Assertion as = *(f->assertionList + n);
|
||||
SCookUnassert(rdf, as->u, as->s, as->value, as->type);
|
||||
freeAssertion(as);
|
||||
*(f->assertionList + n) = NULL;
|
||||
n++;
|
||||
}
|
||||
n = 0;
|
||||
while (n < f->resourceCount) {
|
||||
RDF_Resource u = *(f->resourceList + n);
|
||||
possiblyGCResource(u);
|
||||
n++;
|
||||
}
|
||||
freeMem(f->assertionList);
|
||||
freeMem(f->resourceList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
disposeAllSCookFiles (RDFT rdf, RDFFile f)
|
||||
{
|
||||
if (f != NULL) {
|
||||
disposeAllSCookFiles(rdf, f->next);
|
||||
gcSCookFile(rdf, f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
SCookDisposeDB (RDFT rdf)
|
||||
{
|
||||
SCookDB db = (SCookDB)rdf->pdata;
|
||||
disposeAllSCookFiles(rdf, db->rf);
|
||||
PL_HashTableDestroy(db->rhash);
|
||||
PL_HashTableDestroy(db->lhash);
|
||||
freeMem(db);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static PRBool
|
||||
SCookFileReadp (RDFT rdf, RDF_Resource u)
|
||||
{
|
||||
RDFFile f;
|
||||
SCookDB db = (SCookDB)rdf->pdata;
|
||||
uint n = 0;
|
||||
for (f = db->rf; (f != NULL) ; f = f->next) {
|
||||
n++;
|
||||
if (urlEquals( resourceID(u), f->url)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
possiblyAccessSCookFile (RDFT mcf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
if ((s == gCoreVocab->RDF_parent) && (strstr(resourceID(u), ":/")) &&
|
||||
(((SCookDB)mcf->pdata)->rf != NULL) && (containerp(u)) &&
|
||||
(resourceType(u) == RDF_RT) && (!SCookFileReadp(mcf, u))) {
|
||||
RDFFile newFile = makeRDFFile( resourceID(u), u, 0);
|
||||
SCookDB db = (SCookDB)mcf->pdata;
|
||||
newFile->next = db->rf;
|
||||
newFile->fileType = RDF_XML;
|
||||
newFile->db = mcf;
|
||||
db->rf = newFile;
|
||||
newFile->db = mcf;
|
||||
newFile->assert = SCookAssert2;
|
||||
beginReadingRDFFile(newFile);
|
||||
}
|
||||
}
|
||||
|
||||
void SCookPossiblyAccessFile1 (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) {
|
||||
if ((resourceType(u) == RDF_RT) && (RDF_STRCMP(rdf->url, "rdf:ht") ==0) &&
|
||||
(strstr(resourceID(u), ".rdf") || strstr(resourceID(u), ".mcf")) &&
|
||||
(s == gCoreVocab->RDF_parent) &&
|
||||
(containerp(u))) {
|
||||
RDFFile newFile = readRDFFile( resourceID(u), u, false, rdf);
|
||||
if(newFile) newFile->lastReadTime = PR_Now();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RDFT
|
||||
MakeSCookDB1 (char* url)
|
||||
{
|
||||
if (startsWith("rdf:scook:", url) || (startsWith("rdf:ht", url))) {
|
||||
RDFT ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct));
|
||||
ntr->assert = NULL;
|
||||
ntr->unassert = NULL;
|
||||
ntr->getSlotValue = remoteStoreGetSlotValue;
|
||||
ntr->getSlotValues = remoteStoreGetSlotValues;
|
||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->nextValue = remoteStoreNextValue;
|
||||
ntr->disposeCursor = remoteStoreDisposeCursor;
|
||||
ntr->possiblyAccessFile = RDFFilePossiblyAccessFile ;
|
||||
ntr->url = copyString(url);
|
||||
return ntr;
|
||||
} else return NULL;
|
||||
}
|
||||
69
mozilla/modules/rdf/src/scook.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_SCOOK_H_
|
||||
#define _RDF_SCOOK_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
|
||||
|
||||
/* scook.c data structures */
|
||||
|
||||
typedef struct _SCookDBStruct {
|
||||
PLHashTable* lhash;
|
||||
PLHashTable* rhash;
|
||||
char* reader;
|
||||
RDFFile rf;
|
||||
RDFT db;
|
||||
} SCookDBStruct;
|
||||
|
||||
typedef SCookDBStruct* SCookDB;
|
||||
|
||||
|
||||
|
||||
/* scook.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
char * makeSCookPathname(char* name);
|
||||
PRBool SCookAssert1 (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool SCookAssert3 (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool SCookAssert2 (RDFFile file, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
Assertion SCookAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool SCookUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
Assertion SCookRemove (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool SCookHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
void * SCookGetSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor SCookGetSlotValues (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * SCookNextValue (RDFT mcf, RDF_Cursor c);
|
||||
RDF_Error SCookDisposeCursor (RDFT mcf, RDF_Cursor c);
|
||||
Assertion getArg1 (RDFT r, RDF_Resource u);
|
||||
Assertion getArg2 (RDFT r, RDF_Resource u);
|
||||
void setArg1 (RDFT r, RDF_Resource u, Assertion as);
|
||||
void setArg2 (RDFT r, RDF_Resource u, Assertion as);
|
||||
void gcSCookFile (RDFT rdf, RDFFile f);
|
||||
void disposeAllSCookFiles (RDFT rdf, RDFFile f);
|
||||
void SCookDisposeDB (RDFT rdf);
|
||||
void possiblyAccessSCookFile (RDFT mcf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
RDFT MakeSCookDB (char* url);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
177
mozilla/modules/rdf/src/test.cpp
Normal file
@@ -0,0 +1,177 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* test.cpp
|
||||
*
|
||||
* This file is provided to ensure that the RDF engine will
|
||||
* compile and run standalone (outside of mozilla). It may also
|
||||
* be useful as a demonstration of how to initialize and
|
||||
* use the engine, and possibly for performance testing.
|
||||
* Finally, it ensures that the header files are probably written
|
||||
* for C++.
|
||||
*
|
||||
* Currently this program simply reads in an rdf site-map file
|
||||
* and spits it back out to the display. Feel free to
|
||||
* modify/enhance as desired.
|
||||
*
|
||||
* See Dan Libby (danda@netscape.com) for more info.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "rdf-int.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfparse.h"
|
||||
|
||||
const char *dataSources[] = {
|
||||
"rdf:remoteStore", NULL
|
||||
};
|
||||
|
||||
void
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
RDF rdf;
|
||||
RDF_Error err;
|
||||
RDF_InitParamsStruct initParams = {0};
|
||||
RDF_Resource u, s, root;
|
||||
void *v;
|
||||
RDFFile file;
|
||||
#ifdef XP_WIN
|
||||
char* fileURL = (argc > 1) ? argv[1] : "file:///test.rdf";
|
||||
#else
|
||||
char* fileURL = (argc > 1) ? argv[1] : "file://test.rdf";
|
||||
#endif
|
||||
char* rootURL = (char*)getMem(200);
|
||||
|
||||
err = RDF_Init(&initParams);
|
||||
if (err)
|
||||
{
|
||||
perror("RDF_Init: ");
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("RDF Init success\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Try and get a reference to the remote store DB
|
||||
*/
|
||||
rdf = RDF_GetDB(dataSources);
|
||||
if (rdf == NULL)
|
||||
{
|
||||
perror("RDF_GetDB");
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("RDF_GetDB success\n");
|
||||
}
|
||||
sprintf(rootURL, "%s#root", fileURL);
|
||||
root = (RDF_Resource)RDF_GetResource(NULL, rootURL, PR_TRUE);
|
||||
setResourceType(root, RDF_RT);
|
||||
|
||||
/* Create a test resource */
|
||||
u = RDF_GetResource(rdf, "http://people.netscape.com/danda/", TRUE);
|
||||
s = gCoreVocab->RDF_name;
|
||||
v = "Dan Libby";
|
||||
|
||||
/* make an assertion into RDF's graph */
|
||||
RDF_Assert(rdf, u,s,v, RDF_STRING_TYPE);
|
||||
|
||||
/* check to see if assertion exists */
|
||||
if (!RDF_HasAssertion(rdf,u,s,v, RDF_STRING_TYPE, true))
|
||||
{
|
||||
printf("Assertion failure.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Assertion success.\n");
|
||||
}
|
||||
|
||||
/* Import an RDF file */
|
||||
printf("Reading \"%s\"\n", fileURL);
|
||||
fflush(stdout);
|
||||
|
||||
file = readRDFFile (fileURL, root, PR_TRUE, gRemoteStore);
|
||||
if (file && file->assertionCount > 0)
|
||||
{
|
||||
printf("\"%s\" read in successfully. (%i assertions)\n", fileURL, file->assertionCount);
|
||||
fflush(stdout);
|
||||
|
||||
PRFileDesc *fd = PR_GetSpecialFD(PR_StandardOutput);
|
||||
outputRDFTree (rdf, fd, root);
|
||||
|
||||
#if 0
|
||||
RDF_Cursor c;
|
||||
int i = 0;
|
||||
|
||||
c = RDF_GetSources(rdf, root, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
|
||||
if (c)
|
||||
{
|
||||
u = (RDF_Resource)RDF_NextValue(c);
|
||||
while (u)
|
||||
{
|
||||
printf("%i: %s\n", ++i, u->url);
|
||||
u = (RDF_Resource)RDF_NextValue(c);
|
||||
}
|
||||
|
||||
RDF_DisposeCursor(c);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("error reading %s\n", fileURL);
|
||||
}
|
||||
|
||||
RDF_Shutdown();
|
||||
}
|
||||
|
||||
|
||||
/* This function has to be here when building standalone RDF or you
|
||||
* will get a link error.
|
||||
*/
|
||||
extern "C"
|
||||
void notifySlotValueAdded(RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
if(type == RDF_STRING_TYPE)
|
||||
{
|
||||
#if 0
|
||||
printf("String Value added: %s\n", (char*)v);
|
||||
#endif
|
||||
}
|
||||
else if(type == RDF_RESOURCE_TYPE)
|
||||
{
|
||||
if(type == RDF_RESOURCE_TYPE)
|
||||
{
|
||||
/* Right here you can find out when
|
||||
* resources are added, and what their
|
||||
* ids are, for querying later. This is
|
||||
* useful when the ID of the resource is
|
||||
* not known at compile time.
|
||||
*/
|
||||
#if 0
|
||||
printf("Resource added, ID: %s\n", resourceID((RDF_Resource)v));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
798
mozilla/modules/rdf/src/utils.c
Normal file
@@ -0,0 +1,798 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements utility routines for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
|
||||
#include "utils.h"
|
||||
#include "vocabint.h"
|
||||
|
||||
|
||||
/* globals */
|
||||
PRBool rdfDBInited = 0;
|
||||
PLHashTable* resourceHash = 0;
|
||||
PLHashTable* dataSourceHash = 0;
|
||||
RDFT gRemoteStore = 0;
|
||||
RDFT gSessionDB = 0;
|
||||
|
||||
/* externs */
|
||||
extern char *profileDirURL;
|
||||
|
||||
#define INITIAL_RESOURCE_LIST_SIZE 50
|
||||
#define INITIAL_ASSERTION_LIST_SIZE 100
|
||||
#define GROW_LIST_INCR 50
|
||||
|
||||
|
||||
|
||||
int
|
||||
compareStrings(char *s1, char *s2)
|
||||
{
|
||||
return RDF_STRCASECMP(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
makeRDFDBURL(char* directory, char* name)
|
||||
{
|
||||
char *ans;
|
||||
size_t s;
|
||||
|
||||
if (profileDirURL == NULL) return NULL;
|
||||
if ((ans = (char*) getMem(RDF_STRLEN(profileDirURL) + strlen(directory) + strlen(name) + 3)) != NULL) {
|
||||
s = RDF_STRLEN(profileDirURL);
|
||||
memcpy(ans, profileDirURL, s);
|
||||
if (ans[s-1] != '/') {
|
||||
ans[s++] = '/';
|
||||
}
|
||||
stringAppend(ans, directory);
|
||||
stringAppend(ans, "/");
|
||||
stringAppend(ans, name);
|
||||
}
|
||||
return(ans);
|
||||
}
|
||||
|
||||
|
||||
RDF_Resource
|
||||
getMCFFrtop (char* furl)
|
||||
{
|
||||
char* url = getBaseURL(furl);
|
||||
RDF_Resource r;
|
||||
r = RDF_GetResource(NULL, url, 1);
|
||||
freeMem(url);
|
||||
return r;
|
||||
}
|
||||
|
||||
char*
|
||||
copyString (const char* url) {
|
||||
int32 len = RDF_STRLEN(url);
|
||||
char* newStr = (char*)getMem(len+1);
|
||||
if (newStr != NULL) {
|
||||
memcpy(newStr, url, len);
|
||||
}
|
||||
return newStr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFFile
|
||||
makeRDFFile (char* url, RDF_Resource top, PRBool localp)
|
||||
{
|
||||
RDFFile ans = (RDFFile)getMem(sizeof(struct RDF_FileStruct));
|
||||
/* ans->rdf = rdf; */
|
||||
ans->url = getBaseURL(url);
|
||||
ans->top = top;
|
||||
ans->localp = localp;
|
||||
if (!localp) ans->refreshingp = PR_TRUE;
|
||||
initRDFFile(ans);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
initRDFFile (RDFFile ans)
|
||||
{
|
||||
char* url = ans->url;
|
||||
ans->rtop = getMCFFrtop(url);
|
||||
ans->line = (char*)getMem(RDF_BUF_SIZE);
|
||||
ans->currentSlot = (char*)getMem(100);
|
||||
ans->resourceList = (RDF_Resource*)getMem(INITIAL_RESOURCE_LIST_SIZE * sizeof(RDF_Resource));
|
||||
ans->assertionList = (Assertion*)getMem(INITIAL_ASSERTION_LIST_SIZE * sizeof(Assertion));
|
||||
ans->resourceListSize = INITIAL_RESOURCE_LIST_SIZE;
|
||||
ans->assertionListSize = INITIAL_ASSERTION_LIST_SIZE;
|
||||
ans->holdOver = (char*)getMem(RDF_BUF_SIZE);
|
||||
ans->depth = 1;
|
||||
ans->lastItem = ans->stack[0] = ans->top;
|
||||
ans->locked = ans->localp;
|
||||
ans->lineSize = LINE_SIZE;
|
||||
ans->tv = true;
|
||||
ans->resourceCount = 0;
|
||||
ans->assertionCount = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
addToResourceList (RDFFile f, RDF_Resource u)
|
||||
{
|
||||
if (f->resourceListSize == f->resourceCount) {
|
||||
RDF_Resource* newResourceList = (RDF_Resource*)getMem(sizeof(RDF_Resource)*(f->resourceListSize + GROW_LIST_INCR));
|
||||
RDF_Resource* old = f->resourceList;
|
||||
memcpy((char*)newResourceList, (char*)f->resourceList, sizeof(RDF_Resource)*f->resourceListSize);
|
||||
f->resourceList = newResourceList;
|
||||
f->resourceListSize = f->resourceListSize + GROW_LIST_INCR;
|
||||
freeMem(old);
|
||||
}
|
||||
*(f->resourceList + f->resourceCount++) = u;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
addToAssertionList (RDFFile f, Assertion as)
|
||||
{
|
||||
if (f->assertionListSize == f->assertionCount) {
|
||||
Assertion* newAssertionList = (Assertion*)getMem(sizeof(RDF_Resource)*(f->assertionListSize + GROW_LIST_INCR));
|
||||
Assertion* old = f->assertionList;
|
||||
memcpy((char*)newAssertionList, (char*)f->assertionList, sizeof(RDF_Resource)*f->assertionListSize);
|
||||
f->assertionList = newAssertionList;
|
||||
f->assertionListSize = f->assertionListSize + GROW_LIST_INCR;
|
||||
freeMem(old);
|
||||
}
|
||||
*(f->assertionList + f->assertionCount++) = as;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
removeFromAssertionList(RDFFile f, Assertion as)
|
||||
{
|
||||
/* XXX implement */
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ht_fprintf(PRFileDesc *file, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *buf;
|
||||
va_start(ap, fmt);
|
||||
buf = PR_smprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
if(buf) {
|
||||
PR_Write(file, buf, RDF_STRLEN(buf));
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ht_rjcprintf(PRFileDesc *file, const char *fmt, const char *data)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
buf = PR_smprintf(fmt, data);
|
||||
if(buf) {
|
||||
PR_Write(file, buf, RDF_STRLEN(buf));
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
makeDBURL(char* name)
|
||||
{
|
||||
char *ans;
|
||||
size_t s;
|
||||
|
||||
if (profileDirURL == NULL) return NULL;
|
||||
if ((ans = (char*) getMem(RDF_STRLEN(profileDirURL) + strlen(name) + 3)) != NULL) {
|
||||
s = RDF_STRLEN(profileDirURL);
|
||||
memcpy(ans, profileDirURL, s);
|
||||
if (ans[s-1] != '/') {
|
||||
ans[s++] = '/';
|
||||
}
|
||||
memcpy(&ans[s], name, RDF_STRLEN(name));
|
||||
|
||||
#ifdef XP_WIN
|
||||
if (ans[9] == '|') ans[9] = ':';
|
||||
#endif
|
||||
}
|
||||
return(ans);
|
||||
}
|
||||
|
||||
|
||||
PLHashNumber
|
||||
idenHash (const void *key)
|
||||
{
|
||||
return (PLHashNumber)key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
idenEqual (const void *v1, const void *v2)
|
||||
{
|
||||
return (v1 == v2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
inverseTV (PRBool tv)
|
||||
{
|
||||
if (tv == true) {
|
||||
return false;
|
||||
} else return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
append2Strings (const char* str1, const char* str2)
|
||||
{
|
||||
int32 l1 = RDF_STRLEN(str1);
|
||||
int32 len = l1 + RDF_STRLEN(str2);
|
||||
char* ans = (char*) getMem(len+1);
|
||||
memcpy(ans, str1, l1);
|
||||
memcpy(&ans[l1], str2, len-l1);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
stringAppendBase (char* dest, const char* addition)
|
||||
{
|
||||
int32 l1 = RDF_STRLEN(dest);
|
||||
int32 l2 = RDF_STRLEN(addition);
|
||||
int32 l3 = charSearch('#', addition);
|
||||
if (l3 != -1) l2 = l3;
|
||||
memcpy(&dest[l1], addition, l2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
stringAppend (char* dest, const char* addition)
|
||||
{
|
||||
int32 l1 = RDF_STRLEN(dest);
|
||||
int32 l2 = RDF_STRLEN(addition);
|
||||
memcpy(&dest[l1], addition, l2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16
|
||||
charSearch (const char c, const char* data)
|
||||
{
|
||||
char* ch = RDF_STRCHR(data, c);
|
||||
|
||||
if (ch) {
|
||||
return (ch - data);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
endsWith (const char* pattern, const char* uuid)
|
||||
{
|
||||
short l1 = RDF_STRLEN(pattern);
|
||||
short l2 = RDF_STRLEN(uuid);
|
||||
short index;
|
||||
|
||||
if (l2 < l1) return false;
|
||||
|
||||
for (index = 1; index <= l1; index++) {
|
||||
if (toupper(pattern[l1-index]) != toupper(uuid[l2-index])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool)
|
||||
startsWith (const char* pattern, const char* uuid)
|
||||
{
|
||||
short l1 = RDF_STRLEN(pattern);
|
||||
short l2 = RDF_STRLEN(uuid);
|
||||
if (l2 < l1) return false;
|
||||
return (RDF_STRNCASECMP(pattern, uuid, l1) == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
substring (const char* pattern, const char* data)
|
||||
{
|
||||
char *p = RDF_STRCASESTR(data, pattern);
|
||||
return p != NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16
|
||||
revCharSearch (const char c, const char* data)
|
||||
{
|
||||
char *p = RDF_STRRCHR(data, c);
|
||||
return p ? p-data : -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
urlEquals (const char* url1, const char* url2)
|
||||
{
|
||||
int16 n1 = charSearch('#', url1);
|
||||
int16 n2 = charSearch('#', url2);
|
||||
if ((n1 == -1) && (n2 == -1)) {
|
||||
return (RDF_STRCMP(url1, url2) == 0);
|
||||
} else if ((n2 == -1) && (n1 > 0)) {
|
||||
return ((RDF_STRLEN(url2) == (size_t)(n1)) && (strncmp(url1, url2, n1) == 0));
|
||||
} else if ((n1 == -1) && (size_t) (n2 > 0)) {
|
||||
return ((RDF_STRLEN(url1) == (size_t)(n2)) && (strncmp(url1, url2, n2) == 0));
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
isSeparator (RDF_Resource r)
|
||||
{
|
||||
return (startsWith("separator", resourceID(r)) || startsWith("nc:separator", resourceID(r))) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
getBaseURL (const char* url)
|
||||
{
|
||||
int n = charSearch('#' , url);
|
||||
char* ans;
|
||||
if (n == -1) return copyString(url);
|
||||
if (n == 0) return NULL;
|
||||
ans = getMem(n+1);
|
||||
memcpy(ans, url, n);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
setContainerp (RDF_Resource r, PRBool val)
|
||||
{
|
||||
if (val) {
|
||||
r->flags |= CONTAINER_FLAG;
|
||||
} else {
|
||||
r->flags &= (~CONTAINER_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
containerp (RDF_Resource r)
|
||||
{
|
||||
return (r->flags & CONTAINER_FLAG);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
setLockedp (RDF_Resource r, PRBool val)
|
||||
{
|
||||
if (val) {
|
||||
r->flags |= LOCKED_FLAG;
|
||||
} else {
|
||||
r->flags &= (~LOCKED_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
lockedp (RDF_Resource r)
|
||||
{
|
||||
return (r->flags & LOCKED_FLAG);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8
|
||||
resourceType (RDF_Resource r)
|
||||
{
|
||||
return r->type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
setResourceType (RDF_Resource r, uint8 val)
|
||||
{
|
||||
r->type = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
resourceID(RDF_Resource r)
|
||||
{
|
||||
return r->url;
|
||||
}
|
||||
|
||||
char* opTypeToString (RDF_EventType opType) {
|
||||
switch (opType) {
|
||||
case RDF_ASSERT_NOTIFY :
|
||||
return "Assert";
|
||||
case RDF_INSERT_NOTIFY :
|
||||
return "Insert";
|
||||
case RDF_DELETE_NOTIFY :
|
||||
return "Unassert";
|
||||
}
|
||||
return "Unknown Op";
|
||||
}
|
||||
|
||||
|
||||
void traceNotify (char* event, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) {
|
||||
#ifdef DEBUG_guha1
|
||||
char* traceLine = getMem(1000);
|
||||
if (type == RDF_INT_TYPE) {
|
||||
sprintf(traceLine, "%s %s(%s, %i)\n",
|
||||
event, resourceID(s), resourceID(u), (int) v);
|
||||
} else if (type == RDF_STRING_TYPE){
|
||||
sprintf(traceLine, "%s %s(%s, \"%s\")\n",
|
||||
event, resourceID(s), resourceID(u), (char*) v);
|
||||
} else if (type == RDF_RESOURCE_TYPE) {
|
||||
sprintf(traceLine, "%s %s(%s, %s)\n",
|
||||
event, resourceID(s), resourceID(u), resourceID((RDF_Resource)v));
|
||||
} else {
|
||||
sprintf(traceLine, "%s <gubbish>\n", event);
|
||||
}
|
||||
FE_Trace(traceLine);
|
||||
freeMem(traceLine);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
makeResourceName (RDF_Resource node)
|
||||
{
|
||||
char *name = NULL;
|
||||
|
||||
name = resourceID(node);
|
||||
if (startsWith("http:", resourceID(node)))
|
||||
{
|
||||
name = &name[7];
|
||||
}
|
||||
else if (startsWith("file:", resourceID(node)))
|
||||
{
|
||||
name = &name[FS_URL_OFFSET];
|
||||
}
|
||||
else
|
||||
{
|
||||
name = resourceID(node);
|
||||
|
||||
}
|
||||
return ((name != NULL) ? copyString(name) : NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(char *)
|
||||
RDF_GetResourceName(RDF rdf, RDF_Resource node)
|
||||
{
|
||||
char* name = RDF_GetSlotValue(rdf, node, gCoreVocab->RDF_name, RDF_STRING_TYPE, false, true);
|
||||
if (name != NULL) return name;
|
||||
name = makeResourceName(node);
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
PR_PUBLIC_API(RDF_Resource)
|
||||
RDFUtil_GetFirstInstance (RDF_Resource type, char* defaultURL)
|
||||
{
|
||||
|
||||
RDF_Resource bmk = remoteStoreGetSlotValue(gLocalStore, type,
|
||||
gCoreVocab->RDF_instanceOf,
|
||||
RDF_RESOURCE_TYPE, true, true);
|
||||
if (bmk == NULL) {
|
||||
/* bmk = RDF_GetResource(NULL, defaultURL, 1); */
|
||||
bmk = createContainer(defaultURL);
|
||||
remoteAssert(gLocalStore, bmk, gCoreVocab->RDF_instanceOf,
|
||||
type, RDF_RESOURCE_TYPE, 1);
|
||||
}
|
||||
return bmk;
|
||||
}
|
||||
|
||||
|
||||
PR_PUBLIC_API(void)
|
||||
RDFUtil_SetFirstInstance (RDF_Resource type, RDF_Resource item)
|
||||
{
|
||||
RDF_Resource bmk = remoteStoreGetSlotValue(gLocalStore, type,
|
||||
gCoreVocab->RDF_instanceOf,
|
||||
RDF_RESOURCE_TYPE, true, true);
|
||||
if (bmk) {
|
||||
remoteUnassert(gLocalStore, bmk, gCoreVocab->RDF_instanceOf,
|
||||
type, RDF_RESOURCE_TYPE);
|
||||
}
|
||||
if (item) {
|
||||
remoteAssert(gLocalStore, item, gCoreVocab->RDF_instanceOf,
|
||||
type, RDF_RESOURCE_TYPE, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(RDF_Resource)
|
||||
RDFUtil_GetQuickFileFolder()
|
||||
{
|
||||
return RDFUtil_GetFirstInstance(gNavCenter->RDF_BookmarkFolderCategory, "NC:Bookmarks");
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(void)
|
||||
RDFUtil_SetQuickFileFolder(RDF_Resource container)
|
||||
{
|
||||
RDFUtil_SetFirstInstance(gNavCenter->RDF_BookmarkFolderCategory, container);
|
||||
}
|
||||
|
||||
|
||||
RDF_Resource gPTFolder = NULL;
|
||||
PR_PUBLIC_API(RDF_Resource)
|
||||
RDFUtil_GetPTFolder()
|
||||
{
|
||||
if (gPTFolder) return gPTFolder;
|
||||
return (gPTFolder = RDFUtil_GetFirstInstance(gNavCenter->RDF_PersonalToolbarFolderCategory, "PersonalToolbar"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(void)
|
||||
RDFUtil_SetPTFolder(RDF_Resource container)
|
||||
{
|
||||
/*
|
||||
RDFUtil_SetFirstInstance( gNavCenter->RDF_PersonalToolbarFolderCategory, container);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(RDF_Resource)
|
||||
RDFUtil_GetNewBookmarkFolder()
|
||||
{
|
||||
return RDFUtil_GetFirstInstance(gNavCenter->RDF_NewBookmarkFolderCategory, "NC:Bookmarks");
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(void)
|
||||
RDFUtil_SetNewBookmarkFolder(RDF_Resource container)
|
||||
{
|
||||
RDFUtil_SetFirstInstance(gNavCenter->RDF_NewBookmarkFolderCategory, container);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(RDF_Resource)
|
||||
RDFUtil_GetDefaultSelectedView()
|
||||
{
|
||||
return RDFUtil_GetFirstInstance(gNavCenter->RDF_DefaultSelectedView, "selectedView");
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(void)
|
||||
RDFUtil_SetDefaultSelectedView(RDF_Resource container)
|
||||
{
|
||||
RDFUtil_SetFirstInstance(gNavCenter->RDF_DefaultSelectedView, container);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Returns a new string with inURL unescaped. */
|
||||
/* We return a new string because NET_UnEscape unescapes */
|
||||
/* string in place */
|
||||
char *
|
||||
unescapeURL(char *inURL)
|
||||
{
|
||||
char *escapedPath = copyString(inURL);
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
#ifdef XP_WIN
|
||||
replacePipeWithColon(escapedPath);
|
||||
#endif
|
||||
|
||||
/* xxx NET_UnEscape(escapedPath); */
|
||||
#endif
|
||||
|
||||
return (escapedPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Given a file URL of form "file:///", return substring */
|
||||
/* that can be used as a path for PR_Open. */
|
||||
/* NOTE: This routine DOESN'T allocate a new string */
|
||||
|
||||
|
||||
char *
|
||||
convertFileURLToNSPRCopaceticPath(char* inURL)
|
||||
{
|
||||
#ifdef XP_WIN
|
||||
if (startsWith("file://", inURL)) return (inURL + 8);
|
||||
else if (startsWith("mailbox:/", inURL)) return (inURL + 9);
|
||||
else if (startsWith("IMAP:/", inURL)) return (inURL + 6);
|
||||
else return (inURL);
|
||||
#else
|
||||
/* For Mac & Unix, need preceeding '/' so that NSPR */
|
||||
/* interprets path as full path */
|
||||
if (startsWith("file://", inURL)) return (inURL + 7);
|
||||
else if (startsWith("mailbox:/", inURL)) return (inURL + 8);
|
||||
else if (startsWith("IMAP:/", inURL)) return (inURL + 5);
|
||||
else return (inURL);
|
||||
#endif
|
||||
}
|
||||
|
||||
char* MCDepFileURL (char* url) {
|
||||
char* furl;
|
||||
int32 len;
|
||||
char* baz = "\\";
|
||||
int32 n = 0;
|
||||
furl = convertFileURLToNSPRCopaceticPath(unescapeURL(url));
|
||||
len = RDF_STRLEN(furl);
|
||||
#ifdef XP_WIN
|
||||
while (n < len) {
|
||||
if (furl[n] == '/') furl[n] = baz[0];
|
||||
n++;
|
||||
}
|
||||
#endif
|
||||
return furl;
|
||||
}
|
||||
|
||||
PRFileDesc *
|
||||
CallPROpenUsingFileURL(char *fileURL, PRIntn flags, PRIntn mode)
|
||||
{
|
||||
PRFileDesc* result = NULL;
|
||||
const char *path;
|
||||
|
||||
char *escapedPath = unescapeURL(fileURL);
|
||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
||||
|
||||
if (path != NULL) {
|
||||
result = PR_Open(path, flags, mode);
|
||||
}
|
||||
|
||||
if (escapedPath != NULL) freeMem(escapedPath);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRDir *
|
||||
CallPROpenDirUsingFileURL(char *fileURL)
|
||||
{
|
||||
PRDir* result = NULL;
|
||||
const char *path;
|
||||
char *escapedPath = unescapeURL(fileURL);
|
||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
||||
|
||||
if (path != NULL) {
|
||||
result = PR_OpenDir(path);
|
||||
}
|
||||
|
||||
if (escapedPath != NULL) freeMem(escapedPath);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32
|
||||
CallPRWriteAccessFileUsingFileURL(char *fileURL)
|
||||
{
|
||||
int32 result = -1;
|
||||
const char *path;
|
||||
char *escapedPath = unescapeURL(fileURL);
|
||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
||||
|
||||
if (path != NULL) {
|
||||
result = PR_Access(path, PR_ACCESS_WRITE_OK);
|
||||
}
|
||||
|
||||
if (escapedPath != NULL) freeMem(escapedPath);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32
|
||||
CallPRDeleteFileUsingFileURL(char *fileURL)
|
||||
{
|
||||
int32 result = -1;
|
||||
const char *path;
|
||||
char *escapedPath = unescapeURL(fileURL);
|
||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
||||
|
||||
if (path != NULL) {
|
||||
result = PR_Delete(path);
|
||||
}
|
||||
|
||||
if (escapedPath != NULL) freeMem(escapedPath);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
CallPR_RmDirUsingFileURL(char *dirURL)
|
||||
{
|
||||
int32 result=-1;
|
||||
const char *path;
|
||||
|
||||
char *escapedPath = unescapeURL(dirURL);
|
||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
||||
|
||||
if (path != NULL) {
|
||||
result = PR_RmDir(path);
|
||||
}
|
||||
|
||||
if (escapedPath != NULL) freeMem(escapedPath);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32
|
||||
CallPRMkDirUsingFileURL(char *dirURL, int mode)
|
||||
{
|
||||
int32 result=-1;
|
||||
const char *path;
|
||||
|
||||
char *escapedPath = unescapeURL(dirURL);
|
||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
||||
|
||||
if (path != NULL) {
|
||||
result = PR_MkDir(path,mode);
|
||||
}
|
||||
|
||||
if (escapedPath != NULL) freeMem(escapedPath);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
89
mozilla/modules/rdf/src/utils.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_UTILS_H_
|
||||
#define _RDF_UTILS_H_
|
||||
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "htrdf.h"
|
||||
#include "prprf.h"
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
|
||||
|
||||
/* utils.c data structures and defines */
|
||||
|
||||
#define CONTAINER_FLAG 0x01
|
||||
#define LOCKED_FLAG 0x02
|
||||
|
||||
|
||||
|
||||
/* utils.c function prototypes */
|
||||
|
||||
|
||||
|
||||
RDF_Resource getMCFFrtop (char* furl);
|
||||
void addToResourceList (RDFFile f, RDF_Resource u);
|
||||
void addToAssertionList (RDFFile f, Assertion as);
|
||||
void removeFromAssertionList(RDFFile f, Assertion as);
|
||||
void ht_fprintf(PRFileDesc *file, const char *fmt, ...);
|
||||
void ht_rjcprintf(PRFileDesc *file, const char *fmt, const char *data);
|
||||
char * makeDBURL(char* name);
|
||||
PLHashNumber idenHash (const void *key);
|
||||
int idenEqual (const void *v1, const void *v2);
|
||||
PRBool inverseTV (PRBool tv);
|
||||
char * append2Strings (const char* str1, const char* str2);
|
||||
void stringAppendBase (char* dest, const char* addition);
|
||||
void stringAppend (char* dest, const char* addition);
|
||||
int16 charSearch (const char c, const char* data);
|
||||
PRBool endsWith (const char* pattern, const char* uuid);
|
||||
|
||||
PRBool substring (const char* pattern, const char* data);
|
||||
int compareStrings(char *s1, char *s2);
|
||||
int16 revCharSearch (const char c, const char* data);
|
||||
PRBool urlEquals (const char* url1, const char* url2);
|
||||
PRBool isSeparator (RDF_Resource r);
|
||||
void setContainerp (RDF_Resource r, PRBool val);
|
||||
PRBool containerp (RDF_Resource r);
|
||||
uint8 resourceType (RDF_Resource r);
|
||||
void setResourceType (RDF_Resource r, uint8 val);
|
||||
char * resourceID(RDF_Resource r);
|
||||
char * makeResourceName (RDF_Resource node);
|
||||
char* opTypeToString (RDF_EventType opType) ;
|
||||
void traceNotify (char* event, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) ;
|
||||
|
||||
PRBool IsUTF8Text(const char* utf8, int32 len);
|
||||
PRBool IsUTF8String(const char* utf8);
|
||||
|
||||
void AddCookieResource(char* name, char* path, char* host, char* expires);
|
||||
void RDF_ReadCookies(char * filename);
|
||||
PRBool CookieUnassert (RDFT r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
|
||||
RDF_Cursor CookieGetSlotValues(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * CookieGetNextValue(RDFT rdf, RDF_Cursor c);
|
||||
RDF_Error CookieDisposeCursor(RDFT rdf, RDF_Cursor c);
|
||||
PRBool CookieAssert(RDFT rdf, RDF_Resource u, RDF_Resource s, void *v, RDF_ValueType type, PRBool tv);
|
||||
void * CookieGetSlotValue(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
338
mozilla/modules/rdf/src/vocab.c
Normal file
@@ -0,0 +1,338 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements a standard vocabulary for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "vocabint.h"
|
||||
#include "bmk2mcf.h"
|
||||
|
||||
|
||||
/* globals */
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma export on
|
||||
#endif
|
||||
|
||||
RDF_WDVocab gWebData = NULL;
|
||||
RDF_NCVocab gNavCenter = NULL;
|
||||
RDF_CoreVocab gCoreVocab = NULL;
|
||||
|
||||
|
||||
#ifdef XP_MAC
|
||||
#pragma export off
|
||||
#endif
|
||||
|
||||
size_t gCoreVocabSize = 0;
|
||||
RDF_Resource* gAllVocab;
|
||||
|
||||
|
||||
/* externs */
|
||||
extern char* gLocalStoreURL;
|
||||
extern char* profileDirURL;
|
||||
RDF gCoreDB = 0;
|
||||
|
||||
|
||||
|
||||
void
|
||||
createVocabs ()
|
||||
{
|
||||
size_t n = 0;
|
||||
size_t m = 0;
|
||||
gAllVocab = getMem((gCoreVocabSize =
|
||||
sizeof(RDF_CoreVocabStruct)+sizeof(RDF_NCVocabStruct)+sizeof(RDF_WDVocabStruct)));
|
||||
gCoreDB = (RDF)getMem(sizeof(struct RDF_DBStruct));
|
||||
|
||||
createCoreVocab();
|
||||
createNavCenterVocab();
|
||||
createWebDataVocab();
|
||||
|
||||
while (n < (sizeof(RDF_CoreVocabStruct)/sizeof(RDF_Resource))) {
|
||||
*(gAllVocab + m++) = *((RDF_Resource*)gCoreVocab + n++);
|
||||
}
|
||||
|
||||
n = 0;
|
||||
while (n < (sizeof(RDF_NCVocabStruct)/sizeof(RDF_Resource))) {
|
||||
*(gAllVocab + m++) = *((RDF_Resource*)gNavCenter + n++);
|
||||
}
|
||||
|
||||
n = 0;
|
||||
while (n < (sizeof(RDF_WDVocabStruct)/sizeof(RDF_Resource))) {
|
||||
*(gAllVocab + m++) = *((RDF_Resource*)gWebData + n++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
createCoreVocab ()
|
||||
{
|
||||
gCoreVocab = (RDF_CoreVocab) getMem(sizeof(RDF_CoreVocabStruct));
|
||||
gCoreVocab->RDF_parent = RDF_GetResource(gCoreDB, "parent", 1);
|
||||
gCoreVocab->RDF_name = RDF_GetResource(gCoreDB, "name", 1);
|
||||
gCoreVocab->RDF_instanceOf = RDF_GetResource(gCoreDB, "instanceOf", 1);
|
||||
gCoreVocab->RDF_subClassOf = RDF_GetResource(gCoreDB, "subClassOf", 1);
|
||||
gCoreVocab->RDF_Class = RDF_GetResource(gCoreDB, "Class", 1);
|
||||
gCoreVocab->RDF_PropertyType = RDF_GetResource(gCoreDB, "PropertyType", 1);
|
||||
gCoreVocab->RDF_slotsHere = RDF_GetResource(gCoreDB, "slotsHere", 1);
|
||||
gCoreVocab->RDF_slotsIn = RDF_GetResource(gCoreDB, "slotsIn", 1);
|
||||
gCoreVocab->RDF_domain = RDF_GetResource(gCoreDB, "domain", 1);
|
||||
gCoreVocab->RDF_range = RDF_GetResource(gCoreDB, "range", 1);
|
||||
gCoreVocab->RDF_StringType = RDF_GetResource(gCoreDB, "String", 1);
|
||||
gCoreVocab->RDF_IntType = RDF_GetResource(gCoreDB, "Int", 1);
|
||||
gCoreVocab->RDF_equals = RDF_GetResource(gCoreDB, "equals", 1);
|
||||
gCoreVocab->RDF_lessThan = RDF_GetResource(gCoreDB, "lessThan", 1);
|
||||
gCoreVocab->RDF_greaterThan = RDF_GetResource(gCoreDB, "greaterThan", 1);
|
||||
gCoreVocab->RDF_lessThanOrEqual = RDF_GetResource(gCoreDB, "lessThanOrEqualTo", 1);
|
||||
gCoreVocab->RDF_greaterThanOrEqual = RDF_GetResource(gCoreDB, "greaterThanOrEqualTo", 1);
|
||||
gCoreVocab->RDF_stringEquals = newResource("stringEquals", RDF_IS_STR);
|
||||
gCoreVocab->RDF_stringNotEquals = newResource("stringNotEquals", RDF_IS_NOT_STR);
|
||||
gCoreVocab->RDF_substring = newResource("substring", RDF_CONTAINS_STR);
|
||||
gCoreVocab->RDF_stringStartsWith = newResource("stringStartsWith", RDF_STARTS_WITH_STR);
|
||||
gCoreVocab->RDF_stringEndsWith = newResource("stringEndsWith", RDF_ENDS_WITH_STR);
|
||||
gCoreVocab->RDF_child = RDF_GetResource(gCoreDB, "child", 1);
|
||||
gCoreVocab->RDF_content = RDF_GetResource(gCoreDB, "content", 1);
|
||||
gCoreVocab->RDF_summary = RDF_GetResource(gCoreDB, "summary", 1);
|
||||
gCoreVocab->RDF_comment = RDF_GetResource(gCoreDB, "comment", 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
createNavCenterVocab () {
|
||||
gNavCenter = (RDF_NCVocab) getMem(sizeof(RDF_NCVocabStruct));
|
||||
#ifdef MOZILLA_CLIENT
|
||||
gNavCenter->RDF_overview = RDF_GetResource(gCoreDB, "overview", 1);
|
||||
gNavCenter->RDF_Trash = createContainer("Trash");
|
||||
gNavCenter->RDF_Clipboard = createContainer("Clipboard");
|
||||
gNavCenter->RDF_Top = createContainer("NC:NavCenter");
|
||||
setResourceType(gNavCenter->RDF_Top, RDF_RT);
|
||||
gNavCenter->RDF_Search = createContainer("NC:Search");
|
||||
setResourceType(gNavCenter->RDF_Search, SEARCH_RT);
|
||||
gNavCenter->RDF_Sitemaps = createContainer("NC:Sitemaps");
|
||||
gNavCenter->RDF_BreadCrumbCategory = createContainer("BreadCrumbs");
|
||||
gNavCenter->RDF_BookmarkFolderCategory = createContainer("NC:Bookmarks");
|
||||
gNavCenter->RDF_NewBookmarkFolderCategory = RDF_GetResource(gCoreDB, "NewBookmarks", true);
|
||||
gNavCenter->RDF_History = createContainer("NC:History");
|
||||
gNavCenter->RDF_HistoryBySite = createContainer("NC:HistoryBySite");
|
||||
gNavCenter->RDF_HistoryByDate = createContainer("NC:HistoryByDate");
|
||||
gNavCenter->RDF_HistoryMostVisited = createContainer("NC:HistoryMostVisited");
|
||||
setResourceType(gNavCenter->RDF_History, HISTORY_RT);
|
||||
setResourceType(gNavCenter->RDF_HistoryBySite, HISTORY_RT);
|
||||
setResourceType(gNavCenter->RDF_HistoryByDate, HISTORY_RT);
|
||||
setResourceType(gNavCenter->RDF_HistoryMostVisited, HISTORY_RT);
|
||||
|
||||
/* IE items */
|
||||
gNavCenter->RDF_IEBookmarkFolderCategory = createContainer("NC:IEBookmarks");
|
||||
gNavCenter->RDF_IEHistory = createContainer("NC:IEHistory");
|
||||
setResourceType(gNavCenter->RDF_IEHistory, HISTORY_RT);
|
||||
|
||||
gNavCenter->RDF_bookmarkAddDate = newResource("bookmarkAddDate", RDF_ADDED_ON_STR);
|
||||
gNavCenter->RDF_PersonalToolbarFolderCategory =
|
||||
RDF_GetResource(gCoreDB, "PersonalToolbarCat", true);
|
||||
gNavCenter->RDF_Column = RDF_GetResource(gCoreDB, "Column", true);
|
||||
gNavCenter->RDF_ColumnResource = RDF_GetResource(gCoreDB, "ColumnResource", true);
|
||||
gNavCenter->RDF_ColumnWidth = RDF_GetResource(gCoreDB, "ColumnWidth", true);
|
||||
gNavCenter->RDF_ColumnIconURL = RDF_GetResource(gCoreDB, "ColumnIconURL", true);
|
||||
gNavCenter->RDF_ColumnDataType = RDF_GetResource(gCoreDB, "ColumnDataType", true);
|
||||
gNavCenter->RDF_smallIcon = newResource("smallIcon", RDF_ICON_URL_STR);
|
||||
gNavCenter->RDF_largeIcon = newResource("largeIcon", RDF_LARGE_ICON_URL_STR);
|
||||
gNavCenter->RDF_HTMLURL = newResource("htmlURL", RDF_HTML_URL_STR);
|
||||
gNavCenter->RDF_HTMLHeight = newResource("htmlHeight", RDF_HTML_HEIGHT_STR);
|
||||
gNavCenter->RDF_LocalFiles = createContainer("NC:LocalFiles");
|
||||
/* setResourceType(gNavCenter->RDF_LocalFiles, LFS_RT); */
|
||||
gNavCenter->RDF_FTP = createContainer("NC:FTP");
|
||||
gNavCenter->RDF_FTP = newResource("NC:FTP", RDF_FTP_NAME_STR);
|
||||
gNavCenter->RDF_Appletalk = createContainer("NC:Appletalk");
|
||||
gNavCenter->RDF_Appletalk = newResource("NC:Appletalk", RDF_APPLETALK_TOP_NAME);
|
||||
setResourceType(gNavCenter->RDF_Appletalk, ATALKVIRTUAL_RT);
|
||||
gNavCenter->RDF_Mail = RDF_GetResource(gCoreDB, "NC:Mail", true);
|
||||
gNavCenter->RDF_Guide = RDF_GetResource(gCoreDB, "NC:Guide", true);
|
||||
gNavCenter->RDF_Password = RDF_GetResource(gCoreDB, "password", true);
|
||||
gNavCenter->RDF_SBProviders = RDF_GetResource(gCoreDB, "NC:SmartBrowsingProviders", true);
|
||||
gNavCenter->RDF_WorkspacePos = RDF_GetResource(gCoreDB, "workspacePos", true);
|
||||
gNavCenter->RDF_ItemPos = RDF_GetResource(gCoreDB, "pos", true);
|
||||
gNavCenter->RDF_Locks = RDF_GetResource(gCoreDB, "locks", true);
|
||||
gNavCenter->RDF_AddLock = RDF_GetResource(gCoreDB, "addLock", true);
|
||||
gNavCenter->RDF_DeleteLock = RDF_GetResource(gCoreDB, "deleteLock", true);
|
||||
gNavCenter->RDF_IconLock = RDF_GetResource(gCoreDB, "iconLock", true);
|
||||
gNavCenter->RDF_NameLock = RDF_GetResource(gCoreDB, "nameLock", true);
|
||||
gNavCenter->RDF_CopyLock = RDF_GetResource(gCoreDB, "copyLock", true);
|
||||
gNavCenter->RDF_MoveLock = RDF_GetResource(gCoreDB, "moveLock", true);
|
||||
gNavCenter->RDF_WorkspacePosLock = RDF_GetResource(gCoreDB, "workspacePosLock", true);
|
||||
gNavCenter->RDF_DefaultSelectedView = RDF_GetResource(gCoreDB, "selectedView", true);
|
||||
gNavCenter->RDF_AutoOpen = RDF_GetResource(gCoreDB, "autoOpen", true);
|
||||
gNavCenter->RDF_resultType = RDF_GetResource (gCoreDB, "resultType", true);
|
||||
gNavCenter->RDF_methodType = RDF_GetResource (gCoreDB, "methodType", true);
|
||||
gNavCenter->RDF_prompt = RDF_GetResource (gCoreDB, "prompt", true);
|
||||
gNavCenter->RDF_HTMLType = RDF_GetResource (gCoreDB, "HTMLPage", true);
|
||||
gNavCenter->RDF_URLShortcut = RDF_GetResource(gCoreDB, "URLShortcut", true);
|
||||
gNavCenter->RDF_Poll = RDF_GetResource(gCoreDB, "poll", true);
|
||||
gNavCenter->RDF_PollInterval = RDF_GetResource(gCoreDB, "pollInterval", true);
|
||||
gNavCenter->RDF_PollURL = RDF_GetResource(gCoreDB, "pollURL", true);
|
||||
|
||||
gNavCenter->RDF_Cookies = createContainer("NC:Cookies");
|
||||
setResourceType(gNavCenter->RDF_Cookies, COOKIE_RT);
|
||||
|
||||
gNavCenter->RDF_Toolbar = createContainer("NC:Toolbar");
|
||||
gNavCenter->RDF_JSec = createContainer("NC:Jsec");
|
||||
gNavCenter->RDF_JSecPrincipal = RDF_GetResource(gCoreDB, "JsecPrincipal", true);
|
||||
gNavCenter->RDF_JSecTarget = RDF_GetResource(gCoreDB, "JsecTarget", true);
|
||||
gNavCenter->RDF_JSecAccess = RDF_GetResource(gCoreDB, "JsecAccess", true);
|
||||
|
||||
/* Commands */
|
||||
|
||||
gNavCenter->RDF_Command = RDF_GetResource (gCoreDB, "Command", true);
|
||||
gNavCenter->RDF_Command_Launch = RDF_GetResource(gCoreDB, "Command:Launch", true);
|
||||
gNavCenter->RDF_Command_Refresh = RDF_GetResource(gCoreDB, "Command:Refresh", true);
|
||||
gNavCenter->RDF_Command_Reveal = RDF_GetResource(gCoreDB, "Command:Reveal", true);
|
||||
gNavCenter->RDF_Command_Atalk_FlatHierarchy = RDF_GetResource(gCoreDB, "Command:at:View Zone List", true);
|
||||
gNavCenter->RDF_Command_Atalk_Hierarchy = RDF_GetResource(gCoreDB, "Command:at:View Zone Hierarchy", true);
|
||||
|
||||
/* NavCenter appearance styles */
|
||||
|
||||
gNavCenter->viewFGColor = newResource("viewFGColor", RDF_FOREGROUND_COLOR_STR);
|
||||
gNavCenter->viewBGColor = newResource("viewBGColor", RDF_BACKGROUND_COLOR_STR);
|
||||
gNavCenter->viewBGURL = newResource("viewBGURL", RDF_BACKGROUND_IMAGE_STR);
|
||||
gNavCenter->showTreeConnections = newResource("showTreeConnections", RDF_SHOW_TREE_CONNECTIONS_STR);
|
||||
gNavCenter->treeConnectionFGColor = newResource("treeConnectionFGColor", RDF_CONNECTION_FG_COLOR_STR);
|
||||
gNavCenter->treeOpenTriggerIconURL = newResource("treeOpenTriggerIconURL", RDF_OPEN_TRIGGER_IMAGE_STR);
|
||||
gNavCenter->treeClosedTriggerIconURL = newResource("treeClosedTriggerIconURL", RDF_CLOSED_TRIGGER_IMAGE_STR);
|
||||
gNavCenter->selectionFGColor = newResource("selectionFGColor", RDF_FOREGROUND_COLOR_STR);
|
||||
gNavCenter->selectionBGColor = newResource("selectionBGColor", RDF_BACKGROUND_COLOR_STR);
|
||||
gNavCenter->columnHeaderFGColor = newResource("columnHeaderFGColor", RDF_FOREGROUND_COLOR_STR);
|
||||
gNavCenter->columnHeaderBGColor = newResource("columnHeaderBGColor", RDF_BACKGROUND_COLOR_STR);
|
||||
gNavCenter->columnHeaderBGURL = newResource("columnHeaderBGURL", RDF_BACKGROUND_IMAGE_STR);
|
||||
gNavCenter->showColumnHeaders = newResource("showColumnHeaders", RDF_SHOW_HEADERS_STR);
|
||||
gNavCenter->showColumnHeaderDividers = newResource("showColumnHeaderDividers", RDF_SHOW_HEADER_DIVIDERS_STR);
|
||||
gNavCenter->sortColumnFGColor = newResource("sortColumnFGColor", RDF_SORT_COLUMN_FG_COLOR_STR);
|
||||
gNavCenter->sortColumnBGColor = newResource("sortColumnBGColor", RDF_SORT_COLUMN_BG_COLOR_STR);
|
||||
gNavCenter->titleBarFGColor = newResource("titleBarFGColor", RDF_FOREGROUND_COLOR_STR);
|
||||
gNavCenter->titleBarBGColor = newResource("titleBarBGColor", RDF_BACKGROUND_COLOR_STR);
|
||||
gNavCenter->titleBarBGURL = newResource("titleBarBGURL", RDF_BACKGROUND_IMAGE_STR);
|
||||
gNavCenter->dividerColor = newResource("dividerColor", RDF_DIVIDER_COLOR_STR);
|
||||
gNavCenter->showDivider = newResource("showDivider", RDF_SHOW_COLUMN_DIVIDERS_STR);
|
||||
gNavCenter->selectedColumnHeaderFGColor = newResource("selectedColumnHeaderFGColor", RDF_SELECTED_HEADER_FG_COLOR_STR);
|
||||
gNavCenter->selectedColumnHeaderBGColor = newResource("selectedColumnHeaderBGColor", RDF_SELECTED_HEADER_BG_COLOR_STR);
|
||||
gNavCenter->showColumnHilite = newResource("showColumnHilite", RDF_SHOW_COLUMN_HILITING_STR);
|
||||
gNavCenter->triggerPlacement = newResource("triggerPlacement", RDF_TRIGGER_PLACEMENT_STR);
|
||||
|
||||
/* NavCenter behavior properties */
|
||||
gNavCenter->useInlineEditing = newResource("useInlineEditing", 0 /* XXX */);
|
||||
gNavCenter->useSingleClick = newResource("useSingleClick", 0 /* XXX */);
|
||||
gNavCenter->loadOpenState = newResource("loadOpenState", 0 /* XXX */);
|
||||
gNavCenter->saveOpenState = newResource("saveOpenState", 0 /* XXX */);
|
||||
|
||||
/* Toolbars */
|
||||
|
||||
/* Toolbar Appearance Styles */
|
||||
gNavCenter->toolbarBitmapPosition = newResource("toolbarBitmapPosition", 0 /* XXX "Toolbar Bitmap Position" */ );
|
||||
gNavCenter->toolbarButtonsFixedSize = newResource("toolbarButtonsFixedSize", 0 /* XXX "Toolbar Bitmap Position" */ );
|
||||
gNavCenter->toolbarDisplayMode = newResource("toolbarDisplayMode", 0);
|
||||
gNavCenter->toolbarCollapsed = newResource("toolbarCollapsed", 0);
|
||||
gNavCenter->toolbarVisible = newResource("toolbarVisible", 0);
|
||||
gNavCenter->toolbarDisabledIcon = newResource("toolbarDisabledIcon", 0 /* XXX */);
|
||||
gNavCenter->toolbarEnabledIcon = newResource("toolbarEnabledIcon", 0 /* XXX */);
|
||||
gNavCenter->toolbarRolloverIcon = newResource("toolbarRolloverIcon", 0 /* XXX */);
|
||||
gNavCenter->toolbarPressedIcon = newResource("toolbarPressedIcon", 0 /* XXX */);
|
||||
gNavCenter->buttonTooltipText = newResource("buttonTooltipText", 0 /* XXX */);
|
||||
gNavCenter->buttonStatusbarText = newResource("buttonStatusbarText", 0 /* XXX */);
|
||||
gNavCenter->buttonBorderStyle = newResource("buttonBorderStyle", 0 /* XXX */);
|
||||
gNavCenter->urlBar = newResource("urlBar", 0 /* XXX */);
|
||||
gNavCenter->urlBarWidth = newResource("urlBarWidth", 0 /* XXX */);
|
||||
gNavCenter->pos = newResource("pos", 0 /* XXX */);
|
||||
gNavCenter->viewRolloverColor = newResource("viewRolloverColor", 0 /* XXX */);
|
||||
gNavCenter->viewPressedColor = newResource("viewPressedColor", 0 /* XXX */);
|
||||
gNavCenter->viewDisabledColor = newResource("viewDisabledColor", 0 /* XXX */);
|
||||
gNavCenter->controlStripFGColor = newResource("controlStripFGColor", 0 /* XXX */);
|
||||
gNavCenter->controlStripBGColor = newResource("controlStripBGColor", 0 /* XXX */);
|
||||
gNavCenter->controlStripBGURL = newResource("controlStripBGURL", 0 /* XXX */);
|
||||
gNavCenter->controlStripCloseText = newResource("controlStripCloseText", 0 /* XXX */);
|
||||
gNavCenter->titleBarShowText = newResource("titleBarShowText", 0 /* XXX */);
|
||||
gNavCenter->showTitleBar = newResource("showTitleBar", 0 /* XXX */);
|
||||
gNavCenter->showControlStrip = newResource("showControlStrip", 0 /* XXX */);
|
||||
|
||||
/* Buttons */
|
||||
gNavCenter->buttonTreeState = newResource("buttonTreeState", 0 /* XXX */);
|
||||
|
||||
/* Cookies */
|
||||
gNavCenter->cookieDomain = newResource("cookieDomain", 0 /* XXX */);
|
||||
gNavCenter->cookieValue = newResource("cookieValue", 0 /* XXX */);
|
||||
gNavCenter->cookieHost = newResource("cookieHost", 0 /* XXX */);
|
||||
gNavCenter->cookiePath = newResource("cookiePath", 0 /* XXX */);
|
||||
gNavCenter->cookieSecure = newResource("cookieSecure", 0 /* XXX */);
|
||||
gNavCenter->cookieExpires = newResource("cookieExpiration", 0 /* XXX */);
|
||||
gNavCenter->from = newResource("mail:From", 0 );
|
||||
gNavCenter->to = newResource("mail:To", 0 );
|
||||
gNavCenter->subject = newResource("mail:Subject", 0 /* XXX */);
|
||||
gNavCenter->date = newResource("mail:Date", 0 /* XXX */);
|
||||
gNavCenter->displayURL = newResource("displayURL", 0 /* XXX */);
|
||||
remoteStoreAdd(gRemoteStore, gNavCenter->from, gCoreVocab->RDF_name, copyString("from"), RDF_STRING_TYPE, 1);
|
||||
remoteStoreAdd(gRemoteStore, gNavCenter->to, gCoreVocab->RDF_name, copyString("to"), RDF_STRING_TYPE, 1);
|
||||
remoteStoreAdd(gRemoteStore, gNavCenter->subject, gCoreVocab->RDF_name, copyString("subject"), RDF_STRING_TYPE, 1);
|
||||
remoteStoreAdd(gRemoteStore, gNavCenter->date, gCoreVocab->RDF_name, copyString("date"), RDF_STRING_TYPE, 1);
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
createWebDataVocab ()
|
||||
{
|
||||
gWebData = (RDF_WDVocab) getMem(sizeof(RDF_WDVocabStruct));
|
||||
#ifdef MOZILLA_CLIENT
|
||||
gWebData->RDF_URL = newResource("URL", RDF_URL_STR);
|
||||
gWebData->RDF_description = newResource("description", RDF_DESCRIPTION_STR);
|
||||
gWebData->RDF_keyword = newResource("keyword", 0 /* XXX */);
|
||||
gWebData->RDF_Container = RDF_GetResource (gCoreDB, "Container", true);
|
||||
gWebData->RDF_firstVisitDate = newResource("firstVisitDate", RDF_FIRST_VISIT_STR);
|
||||
gWebData->RDF_lastVisitDate = newResource("lastVisitDate", RDF_LAST_VISIT_STR);
|
||||
gWebData->RDF_numAccesses = newResource("numAccesses", RDF_NUM_ACCESSES_STR);
|
||||
gWebData->RDF_creationDate = newResource("creationDate", RDF_CREATED_ON_STR);
|
||||
gWebData->RDF_lastModifiedDate = newResource("lastModifiedDate", RDF_LAST_MOD_STR);
|
||||
gWebData->RDF_size = newResource("size", RDF_SIZE_STR);
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
newResource(char *id, int optionalNameStrID)
|
||||
{
|
||||
RDF_Resource r;
|
||||
|
||||
r = RDF_GetResource(gCoreDB, id, true);
|
||||
return(r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
getResourceDefaultName(RDF_Resource node)
|
||||
{
|
||||
int strID = 0;
|
||||
char *defaultName = NULL;
|
||||
return resourceID(node);
|
||||
}
|
||||
|
||||
char *gDefaultNavcntr =
|
||||
"<RDF:RDF> <Topic id=\"NC:Toolbar\"> <child> <Topic id=\"NC:CommandToolBar\" name=\"Command Toolbar\" toolbarBitmapPosition=\"top\" toolbarButtonsFixedSize=\"yes\" > <child href=\"command:back\" name=\"Back\"/> <child buttonTooltipText=\"Reload this page from the server\" buttonStatusbarText=\"Reload the current page\" href=\"command:reload\" name=\"Reload\"/> <child href=\"command:stop\" name=\"Stop\"/> <child href=\"command:forward\" name=\"Forward\"/> <child name=\"separator0\" href=\"nc:separator0\"/> <child href=\"command:urlbar\" name=\" \" buttonStatusBarText=\"Location/Search Bar\" buttonTooltipText=\"Location/Search Bar\" urlBar=\"Yes\" urlBarWidth=\"*\"/> <child name=\"separator2\" href=\"nc:separator2\"/> </Topic> </child> <child> <Topic id=\"NC:InfoToolbar\" name=\"Info Toolbar\"> <child> <Topic id=\"NC:Bookmarks\" name=\"Bookmarks\"></Topic> </child> <child> <Topic id=\"NC:History\" largeIcon=\"icon/large:workspace,history\" name=\"History\"> <child href=\"NC:HistoryMostVisited\" name=\"Most Frequented Pages\"/> <child href=\"NC:HistoryBySite\" name=\"History By Site\"/> <child href=\"NC:HistoryByDate\" name=\"History By Date\"/> </Topic> </child> <child href=\"NC:Sitemaps\" name=\"Related\" htmlURL=\"http://rdf.netscape.com/rdf/navcntradvert.html\"/> </Topic> </child> <child> <Topic id=\"NC:PersonalToolbar\" name=\"Personal Toolbar\"> </Topic> </child> </Topic> <Topic id=\"NC:NavCenter\"> <child href=\"NC:Bookmarks\" name=\"Bookmarks\"/> <child href=\"NC:Search\" largeIcon=\"icon/large:workspace,search\" name=\"Search\"/> <child href=\"NC:History\" name=\"History\"/> <child id=\"NC:Sitemaps\" name=\"Site Tools\" htmlURL=\"http://rdf.netscape.com/rdf/navcntradvert.html\" /> <child id=\"NC:LocalFiles\" name=\"Files\" largeIcon=\"http://rdf.netscape.com/rdf/heabou.gif\"/> </Topic></RDF:RDF>" ;
|
||||
56
mozilla/modules/rdf/src/vocabint.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_VOCABINT_H_
|
||||
#define _RDF_VOCABINT_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "htrdf.h"
|
||||
|
||||
|
||||
/* vocab.c data structures */
|
||||
|
||||
extern int RDF_FOREGROUND_COLOR_STR, RDF_BACKGROUND_COLOR_STR, RDF_BACKGROUND_IMAGE_STR;
|
||||
extern int RDF_SHOW_TREE_CONNECTIONS_STR, RDF_CONNECTION_FG_COLOR_STR, RDF_OPEN_TRIGGER_IMAGE_STR;
|
||||
extern int RDF_CLOSED_TRIGGER_IMAGE_STR, RDF_SHOW_HEADERS_STR, RDF_SHOW_HEADER_DIVIDERS_STR;
|
||||
extern int RDF_SORT_COLUMN_FG_COLOR_STR, RDF_SORT_COLUMN_BG_COLOR_STR, RDF_DIVIDER_COLOR_STR;
|
||||
extern int RDF_SHOW_COLUMN_DIVIDERS_STR, RDF_SELECTED_HEADER_FG_COLOR_STR, RDF_SELECTED_HEADER_BG_COLOR_STR;
|
||||
extern int RDF_SHOW_COLUMN_HILITING_STR, RDF_TRIGGER_PLACEMENT_STR, RDF_URL_STR;
|
||||
extern int RDF_DESCRIPTION_STR, RDF_FIRST_VISIT_STR, RDF_LAST_VISIT_STR, RDF_NUM_ACCESSES_STR;
|
||||
extern int RDF_CREATED_ON_STR, RDF_LAST_MOD_STR, RDF_SIZE_STR, RDF_ADDED_ON_STR, RDF_ICON_URL_STR;
|
||||
extern int RDF_LARGE_ICON_URL_STR, RDF_HTML_URL_STR, RDF_HTML_HEIGHT_STR;
|
||||
extern int RDF_CONTAINS_STR, RDF_IS_STR, RDF_IS_NOT_STR, RDF_STARTS_WITH_STR, RDF_ENDS_WITH_STR;
|
||||
extern int RDF_FTP_NAME_STR, RDF_APPLETALK_TOP_NAME;
|
||||
|
||||
|
||||
/* vocab.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
void createVocabs ();
|
||||
void createCoreVocab ();
|
||||
void createNavCenterVocab ();
|
||||
void createWebDataVocab ();
|
||||
RDF_Resource newResource(char *id, int optionalNameStrID);
|
||||
char *getResourceDefaultName(RDF_Resource r);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#
|
||||
## hostname: fx-linux-tbox
|
||||
## uname: Linux fx-linux-tbox.build.mozilla.org 2.6.18-8.el5 #1 SMP Thu Mar 15 19:57:35 EDT 2007 i686 i686 i386 GNU/Linux
|
||||
#
|
||||
|
||||
export CFLAGS="-gstabs+"
|
||||
export CXXFLAGS="-gstabs+"
|
||||
|
||||
mk_add_options MOZ_CO_PROJECT=browser
|
||||
mk_add_options PROFILE_GEN_SCRIPT=@TOPSRCDIR@/build/profile_pageloader.pl
|
||||
mk_add_options MOZ_CO_MODULE="mozilla/tools/update-packaging"
|
||||
mk_add_options MOZ_MAKE_FLAGS="-j1"
|
||||
|
||||
ac_add_options --enable-application=browser
|
||||
ac_add_options --enable-update-channel=release
|
||||
ac_add_options --enable-update-packaging
|
||||
|
||||
# Don't add explicit optimize flags here, set them in configure.in, see bug 407794.
|
||||
ac_add_options --enable-optimize
|
||||
ac_add_options --disable-debug
|
||||
ac_add_options --disable-tests
|
||||
|
||||
ac_add_options --enable-official-branding
|
||||
|
||||
CC=/tools/gcc/bin/gcc
|
||||
CXX=/tools/gcc/bin/g++
|
||||
@@ -1,268 +0,0 @@
|
||||
#
|
||||
## hostname: fx-linux-tbox
|
||||
## uname: Linux fx-linux-tbox.build.mozilla.org 2.6.18-8.el5 #1 SMP Thu Mar 15 19:57:35 EDT 2007 i686 i686 i386 GNU/Linux
|
||||
#
|
||||
|
||||
#- tinder-config.pl - Tinderbox configuration file.
|
||||
#- Uncomment the variables you need to set.
|
||||
#- The default values are the same as the commented variables.
|
||||
|
||||
$ENV{CVS_RSH} = "ssh";
|
||||
$ENV{MOZ_CRASHREPORTER_NO_REPORT} = '1';
|
||||
|
||||
# To ensure Talkback client builds properly on some Linux boxen where LANG
|
||||
# is set to "en_US.UTF-8" by default, override that setting here by setting
|
||||
# it to "en_US.iso885915" (the setting on ocean). Proper fix is to update
|
||||
# where xrestool is called in the build system so that 'LANG=C' in its
|
||||
# environment, according to bryner.
|
||||
$ENV{LANG} = "en_US.iso885915";
|
||||
|
||||
# $ENV{MOZ_PACKAGE_MSI}
|
||||
#-----------------------------------------------------------------------------
|
||||
# Default: 0
|
||||
# Values: 0 | 1
|
||||
# Purpose: Controls whether a MSI package is made.
|
||||
# Requires: Windows and a local MakeMSI installation.
|
||||
#$ENV{MOZ_PACKAGE_MSI} = 0;
|
||||
|
||||
# $ENV{MOZ_SYMBOLS_TRANSFER_TYPE}
|
||||
#-----------------------------------------------------------------------------
|
||||
# Default: scp
|
||||
# Values: scp | rsync
|
||||
# Purpose: Use scp or rsync to transfer symbols to the Talkback server.
|
||||
# Requires: The selected type requires the command be available both locally
|
||||
# and on the Talkback server.
|
||||
#$ENV{MOZ_SYMBOLS_TRANSFER_TYPE} = "scp";
|
||||
|
||||
#- PLEASE FILL THIS IN WITH YOUR PROPER EMAIL ADDRESS
|
||||
$BuildAdministrator = 'build@mozilla.org';
|
||||
#$BuildAdministrator = "$ENV{USER}\@$ENV{HOST}";
|
||||
#$BuildAdministrator = ($ENV{USER} || "cltbld") . "\@" . ($ENV{HOST} || "dhcp");
|
||||
|
||||
#- You'll need to change these to suit your machine's needs
|
||||
$DisplayServer = ':0.0';
|
||||
|
||||
#- Default values of command-line opts
|
||||
#-
|
||||
#$BuildDepend = 1; # Depend or Clobber
|
||||
#$BuildDebug = 0; # Debug or Opt (Darwin)
|
||||
#$ReportStatus = 1; # Send results to server, or not
|
||||
#$ReportFinalStatus = 1; # Finer control over $ReportStatus.
|
||||
$UseTimeStamp = 0; # Use the CVS 'pull-by-timestamp' option, or not
|
||||
#$BuildOnce = 0; # Build once, don't send results to server
|
||||
#$TestOnly = 0; # Only run tests, don't pull/build
|
||||
#$BuildEmbed = 0; # After building seamonkey, go build embed app.
|
||||
#$SkipMozilla = 0; # Use to debug post-mozilla.pl scripts.
|
||||
#$BuildLocales = 0; # Do l10n packaging?
|
||||
|
||||
# Tests
|
||||
$CleanProfile = 1;
|
||||
#$ResetHomeDirForTests = 1;
|
||||
$ProductName = "Firefox";
|
||||
$VendorName = 'Mozilla';
|
||||
|
||||
$RunMozillaTests = 1; # Allow turning off of all tests if needed.
|
||||
$RegxpcomTest = 1;
|
||||
$AliveTest = 1;
|
||||
#$JavaTest = 0;
|
||||
#$ViewerTest = 0;
|
||||
#$BloatTest = 0; # warren memory bloat test
|
||||
#$BloatTest2 = 0; # dbaron memory bloat test, require tracemalloc
|
||||
#$DomToTextConversionTest = 0;
|
||||
#$XpcomGlueTest = 0;
|
||||
$CodesizeTest = 0; # Z, require mozilla/tools/codesighs
|
||||
$EmbedCodesizeTest = 0; # mZ, require mozilla/tools/codesigns
|
||||
#$MailBloatTest = 0;
|
||||
#$EmbedTest = 0; # Assumes you wanted $BuildEmbed=1
|
||||
$LayoutPerformanceTest = 0; # Tp
|
||||
$DHTMLPerformanceTest = 0; # Tdhtml
|
||||
#$QATest = 0;
|
||||
#$XULWindowOpenTest = 0; # Txul
|
||||
$StartupPerformanceTest = 0; # Ts
|
||||
|
||||
$TestsPhoneHome = 0; # Should test report back to server?
|
||||
$GraphNameOverride = 'fx-linux-tbox';
|
||||
|
||||
# $results_server
|
||||
#----------------------------------------------------------------------------
|
||||
# Server on which test results will be accessible. This was originally tegu,
|
||||
# then became axolotl. Once we moved services from axolotl, it was time
|
||||
# to give this service its own hostname to make future transitions easier.
|
||||
# - cmp@mozilla.org
|
||||
#$results_server = "build-graphs.mozilla.org";
|
||||
|
||||
#$pageload_server = "spider"; # localhost
|
||||
$pageload_server = "pageload.build.mozilla.org";
|
||||
|
||||
|
||||
#
|
||||
# Timeouts, values are in seconds.
|
||||
#
|
||||
#$CVSCheckoutTimeout = 3600;
|
||||
#$CreateProfileTimeout = 45;
|
||||
#$RegxpcomTestTimeout = 120;
|
||||
|
||||
#$AliveTestTimeout = 45;
|
||||
#$ViewerTestTimeout = 45;
|
||||
#$EmbedTestTimeout = 45;
|
||||
#$BloatTestTimeout = 120; # seconds
|
||||
#$MailBloatTestTimeout = 120; # seconds
|
||||
#$JavaTestTimeout = 45;
|
||||
#$DomTestTimeout = 45; # seconds
|
||||
#$XpcomGlueTestTimeout = 15;
|
||||
#$CodesizeTestTimeout = 900; # seconds
|
||||
#$CodesizeTestType = "auto"; # {"auto"|"base"}
|
||||
#$LayoutPerformanceTestTimeout = 1200; # entire test, seconds
|
||||
#$DHTMLPerformanceTestTimeout = 1200; # entire test, seconds
|
||||
#$QATestTimeout = 1200; # entire test, seconds
|
||||
#$LayoutPerformanceTestPageTimeout = 30000; # each page, ms
|
||||
#$StartupPerformanceTestTimeout = 15; # seconds
|
||||
#$XULWindowOpenTestTimeout = 150; # seconds
|
||||
|
||||
|
||||
#$MozConfigFileName = 'mozconfig';
|
||||
|
||||
#$UseMozillaProfile = 1;
|
||||
#$MozProfileName = 'default';
|
||||
|
||||
#- Set these to what makes sense for your system
|
||||
#$Make = 'gmake'; # Must be GNU make
|
||||
#$MakeOverrides = '';
|
||||
#$mail = '/bin/mail';
|
||||
#$CVS = 'cvs -q';
|
||||
#$CVSCO = 'checkout -P';
|
||||
|
||||
# win32 usually doesn't have /bin/mail
|
||||
#$blat = 'c:/nstools/bin/blat';
|
||||
#$use_blat = 0;
|
||||
|
||||
# Set moz_cvsroot to something like:
|
||||
# :pserver:$ENV{USER}%netscape.com\@cvs.mozilla.org:/cvsroot
|
||||
# :pserver:anonymous\@cvs-mirror.mozilla.org:/cvsroot
|
||||
#
|
||||
# Note that win32 may not need \@, depends on ' or ".
|
||||
# :pserver:$ENV{USER}%netscape.com@cvs.mozilla.org:/cvsroot
|
||||
|
||||
#$moz_cvsroot = $ENV{CVSROOT};
|
||||
# CONFIG: $moz_cvsroot = '%mozillaCvsroot%';
|
||||
$moz_cvsroot = 'cltbld@cvs.mozilla.org:/cvsroot';
|
||||
|
||||
#- Set these proper values for your tinderbox server
|
||||
#$Tinderbox_server = 'tinderbox-daemon@tinderbox.mozilla.org';
|
||||
|
||||
# Allow for non-client builds, e.g. camino.
|
||||
#$moz_client_mk = 'client.mk';
|
||||
|
||||
#- Set if you want to build in a separate object tree
|
||||
$ObjDir = 'obj-fx-trunk';
|
||||
|
||||
# Extra build name, if needed.
|
||||
$BuildNameExtra = 'Release';
|
||||
|
||||
# User comment, eg. ip address for dhcp builds.
|
||||
# ex: $UserComment = "ip = 208.12.36.108";
|
||||
#$UserComment = 0;
|
||||
|
||||
#-
|
||||
#- The rest should not need to be changed
|
||||
#-
|
||||
|
||||
#- Minimum wait period from start of build to start of next build in minutes.
|
||||
#$BuildSleep = 10;
|
||||
|
||||
#- Until you get the script working. When it works,
|
||||
#- change to the tree you're actually building
|
||||
# CONFIG: $BuildTree = '%buildTree%';
|
||||
$BuildTree = 'MozillaRelease';
|
||||
|
||||
#$BuildName = '';
|
||||
# CONFIG: $BuildTag = '%productTag%_RELEASE';
|
||||
$BuildTag = 'FIREFOX_3_0_19_RELEASE';
|
||||
#$BuildConfigDir = 'mozilla/config';
|
||||
#$Topsrcdir = 'mozilla';
|
||||
|
||||
$BinaryName = 'firefox-bin';
|
||||
|
||||
#
|
||||
# For embedding app, use:
|
||||
#$EmbedBinaryName = 'TestGtkEmbed';
|
||||
#$EmbedDistDir = 'dist/bin'
|
||||
|
||||
|
||||
#$ShellOverride = ''; # Only used if the default shell is too stupid
|
||||
#$ConfigureArgs = '';
|
||||
#$ConfigureEnvArgs = '';
|
||||
#$Compiler = 'gcc';
|
||||
#$NSPRArgs = '';
|
||||
#$ShellOverride = '';
|
||||
|
||||
# Release build options
|
||||
$ReleaseBuild = 1;
|
||||
$shiptalkback = 0;
|
||||
$ReleaseToLatest = 0; # Push the release to latest-<milestone>?
|
||||
$ReleaseToDated = 1; # Push the release to YYYY-MM-DD-HH-<milestone>?
|
||||
$build_hour = 4;
|
||||
$package_creation_path = "/browser/installer";
|
||||
# needs setting for mac + talkback: $mac_bundle_path = "/browser/app";
|
||||
$ssh_version = "2";
|
||||
# CONFIG: $ssh_user = "%sshUser%";
|
||||
$ssh_user = "cltbld";
|
||||
# CONFIG: $ssh_server = "%sshServer%";
|
||||
$ssh_server = "stage-old.mozilla.org";
|
||||
$ftp_path = "/home/ftp/pub/firefox/nightly";
|
||||
$url_path = "http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly";
|
||||
$tbox_ftp_path = "/home/ftp/pub/firefox/tinderbox-builds";
|
||||
$tbox_url_path = "http://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds";
|
||||
# CONFIG: $milestone = "firefox%version%";
|
||||
$milestone = "firefox3.0.19";
|
||||
$notify_list = 'build-announce@mozilla.org';
|
||||
$stub_installer = 0;
|
||||
$sea_installer = 0;
|
||||
$archive = 1;
|
||||
$push_raw_xpis = 0;
|
||||
$update_pushinfo = 0;
|
||||
$update_package = 1;
|
||||
$update_product = "Firefox";
|
||||
$update_version = "trunk";
|
||||
$update_platform = "Linux_x86-gcc3";
|
||||
$update_hash = "sha1";
|
||||
$update_filehost = 'ftp.mozilla.org';
|
||||
$update_ver_file = 'browser/config/version.txt';
|
||||
$crashreporter_buildsymbols = 1;
|
||||
$crashreporter_pushsymbols = 1;
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_HOST'} = '%symbolServer%';
|
||||
$ENV{'SYMBOL_SERVER_HOST'} = 'dm-symbolpush01.mozilla.org';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_USER'} = '%symbolServerUser%';
|
||||
$ENV{'SYMBOL_SERVER_USER'} = 'ffxbld';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_PATH'} = '%symbolServerPath%';
|
||||
$ENV{'SYMBOL_SERVER_PATH'} = '/mnt/netapp/breakpad/symbols_ffx';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_SSH_KEY'} = '%symbolServerKey%';
|
||||
$ENV{'SYMBOL_SERVER_SSH_KEY'} = '/home/cltbld/.ssh/ffxbld_dsa';
|
||||
|
||||
# Reboot the OS at the end of build-and-test cycle. This is primarily
|
||||
# intended for Win9x, which can't last more than a few cycles before
|
||||
# locking up (and testing would be suspect even after a couple of cycles).
|
||||
# Right now, there is only code to force the reboot for Win9x, so even
|
||||
# setting this to 1, will not have an effect on other platforms. Setting
|
||||
# up win9x to automatically logon and begin running tinderbox is left
|
||||
# as an exercise to the reader.
|
||||
#$RebootSystem = 0;
|
||||
|
||||
# LogCompression specifies the type of compression used on the log file.
|
||||
# Valid options are 'gzip', and 'bzip2'. Please make sure the binaries
|
||||
# for 'gzip' or 'bzip2' are in the user's path before setting this
|
||||
# option.
|
||||
#$LogCompression = '';
|
||||
|
||||
# LogEncoding specifies the encoding format used for the logs. Valid
|
||||
# options are 'base64', and 'uuencode'. If $LogCompression is set above,
|
||||
# this needs to be set to 'base64' or 'uuencode' to ensure that the
|
||||
# binary data is transferred properly.
|
||||
#$LogEncoding = '';
|
||||
|
||||
# Prevent Extension Manager from spawning child processes during tests
|
||||
# - processes that tbox scripts cannot kill.
|
||||
#$ENV{NO_EM_RESTART} = '1';
|
||||
|
||||
# Do not build XForms
|
||||
$BuildXForms = 0;
|
||||
@@ -1,26 +0,0 @@
|
||||
#
|
||||
## hostname: bm-xserve08.build.mozilla.org
|
||||
## uname: Darwin bm-xserve08.build.mozilla.org 8.8.4 Darwin Kernel Version 8.8.4: Sun Oct 29 15:26:54 PST 2006; root:xnu-792.16.4.obj~1/RELEASE_I386 i386 i386
|
||||
#
|
||||
|
||||
# symbols for breakpad
|
||||
export CFLAGS="-g -gfull"
|
||||
export CXXFLAGS="-g -gfull"
|
||||
|
||||
. $topsrcdir/build/macosx/universal/mozconfig
|
||||
|
||||
mk_add_options MOZ_MAKE_FLAGS="-j1"
|
||||
mk_add_options MOZ_CO_MODULE="mozilla/tools/update-packaging"
|
||||
mk_add_options MOZ_CO_PROJECT="browser"
|
||||
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../build/universal
|
||||
|
||||
ac_add_options --enable-application=browser
|
||||
ac_add_options --enable-update-channel=release
|
||||
# Don't add explicit optimize flags here, set them in configure.in, see bug 407794.
|
||||
ac_add_options --enable-optimize
|
||||
ac_add_options --disable-debug
|
||||
ac_add_options --disable-tests
|
||||
ac_add_options --enable-update-packaging
|
||||
|
||||
ac_add_options --enable-official-branding
|
||||
ac_add_app_options ppc --enable-prebinding
|
||||
@@ -1,267 +0,0 @@
|
||||
#
|
||||
## hostname: bm-xserve08.build.mozilla.org
|
||||
## uname: Darwin bm-xserve08.build.mozilla.org 8.8.4 Darwin Kernel Version 8.8.4: Sun Oct 29 15:26:54 PST 2006; root:xnu-792.16.4.obj~1/RELEASE_I386 i386 i386
|
||||
#
|
||||
|
||||
#- tinder-config.pl - Tinderbox configuration file.
|
||||
#- Uncomment the variables you need to set.
|
||||
#- The default values are the same as the commented variables.
|
||||
|
||||
$ENV{NO_EM_RESTART} = "1";
|
||||
$ENV{DYLD_NO_FIX_PREBINDING} = "1";
|
||||
$ENV{LD_PREBIND_ALLOW_OVERLAP} = "1";
|
||||
$ENV{CVS_RSH} = "ssh";
|
||||
|
||||
$MacUniversalBinary = 1;
|
||||
|
||||
# $ENV{MOZ_PACKAGE_MSI}
|
||||
#-----------------------------------------------------------------------------
|
||||
# Default: 0
|
||||
# Values: 0 | 1
|
||||
# Purpose: Controls whether a MSI package is made.
|
||||
# Requires: Windows and a local MakeMSI installation.
|
||||
#$ENV{MOZ_PACKAGE_MSI} = 0;
|
||||
|
||||
# $ENV{MOZ_SYMBOLS_TRANSFER_TYPE}
|
||||
#-----------------------------------------------------------------------------
|
||||
# Default: scp
|
||||
# Values: scp | rsync
|
||||
# Purpose: Use scp or rsync to transfer symbols to the Talkback server.
|
||||
# Requires: The selected type requires the command be available both locally
|
||||
# and on the Talkback server.
|
||||
#$ENV{MOZ_SYMBOLS_TRANSFER_TYPE} = "scp";
|
||||
|
||||
#- PLEASE FILL THIS IN WITH YOUR PROPER EMAIL ADDRESS
|
||||
$BuildAdministrator = 'build@mozilla.org';
|
||||
#$BuildAdministrator = "$ENV{USER}\@$ENV{HOST}";
|
||||
#$BuildAdministrator = ($ENV{USER} || "cltbld") . "\@" . ($ENV{HOST} || "dhcp");
|
||||
|
||||
#- You'll need to change these to suit your machine's needs
|
||||
#$DisplayServer = ':0.0';
|
||||
|
||||
#- Default values of command-line opts
|
||||
#-
|
||||
#$BuildDepend = 1; # Depend or Clobber
|
||||
#$BuildDebug = 0; # Debug or Opt (Darwin)
|
||||
#$ReportStatus = 1; # Send results to server, or not
|
||||
#$ReportFinalStatus = 1; # Finer control over $ReportStatus.
|
||||
$UseTimeStamp = 0; # Use the CVS 'pull-by-timestamp' option, or not
|
||||
#$BuildOnce = 0; # Build once, don't send results to server
|
||||
#$TestOnly = 0; # Only run tests, don't pull/build
|
||||
#$BuildEmbed = 0; # After building seamonkey, go build embed app.
|
||||
#$SkipMozilla = 0; # Use to debug post-mozilla.pl scripts.
|
||||
#$BuildLocales = 0; # Do l10n packaging?
|
||||
|
||||
# Tests
|
||||
$CleanProfile = 1;
|
||||
#$ResetHomeDirForTests = 1;
|
||||
$ProductName = 'Firefox';
|
||||
$VendorName = "Mozilla";
|
||||
|
||||
$RunMozillaTests = 1; # Allow turning off of all tests if needed.
|
||||
$RegxpcomTest = 1;
|
||||
$AliveTest = 1;
|
||||
#$JavaTest = 0;
|
||||
#$ViewerTest = 0;
|
||||
#$BloatTest = 0; # warren memory bloat test
|
||||
#$BloatTest2 = 0; # dbaron memory bloat test, require tracemalloc
|
||||
#$DomToTextConversionTest = 0;
|
||||
#$XpcomGlueTest = 0;
|
||||
$CodesizeTest = 0; # Z, require mozilla/tools/codesighs
|
||||
$EmbedCodesizeTest = 0; # mZ, require mozilla/tools/codesigns
|
||||
#$MailBloatTest = 0;
|
||||
#$EmbedTest = 0; # Assumes you wanted $BuildEmbed=1
|
||||
$LayoutPerformanceTest = 0; # Tp
|
||||
$LayoutPerformanceLocalTest = 0; # Tp2
|
||||
$DHTMLPerformanceTest = 0; # Tdhtml
|
||||
#$QATest = 0;
|
||||
$XULWindowOpenTest = 0; # Txul
|
||||
$StartupPerformanceTest = 0; # Ts
|
||||
|
||||
$TestsPhoneHome = 0; # Should test report back to server?
|
||||
|
||||
$GraphNameOverride = 'xserve08.build.mozilla.org_Fx-Trunk';
|
||||
|
||||
# $results_server
|
||||
#----------------------------------------------------------------------------
|
||||
# Server on which test results will be accessible. This was originally tegu,
|
||||
# then became axolotl. Once we moved services from axolotl, it was time
|
||||
# to give this service its own hostname to make future transitions easier.
|
||||
# - cmp@mozilla.org
|
||||
#$results_server = "build-graphs.mozilla.org";
|
||||
|
||||
#$pageload_server = "spider"; # localhost
|
||||
$pageload_server = "pageload.build.mozilla.org"; # localhost
|
||||
|
||||
#
|
||||
# Timeouts, values are in seconds.
|
||||
#
|
||||
#$CVSCheckoutTimeout = 3600;
|
||||
#$CreateProfileTimeout = 45;
|
||||
#$RegxpcomTestTimeout = 120;
|
||||
|
||||
$AliveTestTimeout = 10;
|
||||
#$ViewerTestTimeout = 45;
|
||||
#$EmbedTestTimeout = 45;
|
||||
#$BloatTestTimeout = 120; # seconds
|
||||
#$MailBloatTestTimeout = 120; # seconds
|
||||
#$JavaTestTimeout = 45;
|
||||
#$DomTestTimeout = 45; # seconds
|
||||
#$XpcomGlueTestTimeout = 15;
|
||||
#$CodesizeTestTimeout = 900; # seconds
|
||||
#$CodesizeTestType = "auto"; # {"auto"|"base"}
|
||||
$LayoutPerformanceTestTimeout = 300; # entire test, seconds
|
||||
$LayoutPerformanceLocalTestTimeout = 180; # entire test, seconds
|
||||
$DHTMLPerformanceTestTimeout = 180; # entire test, seconds
|
||||
#$QATestTimeout = 1200; # entire test, seconds
|
||||
#$LayoutPerformanceTestPageTimeout = 30000; # each page, ms
|
||||
#$StartupPerformanceTestTimeout = 15; # seconds
|
||||
#$XULWindowOpenTestTimeout = 150; # seconds
|
||||
|
||||
|
||||
#$MozConfigFileName = 'mozconfig';
|
||||
|
||||
#$UseMozillaProfile = 1;
|
||||
#$MozProfileName = 'default';
|
||||
|
||||
#- Set these to what makes sense for your system
|
||||
#$Make = 'gmake'; # Must be GNU make
|
||||
#$MakeOverrides = '';
|
||||
#$mail = '/bin/mail';
|
||||
#$CVS = 'cvs -q';
|
||||
#$CVSCO = 'checkout -P';
|
||||
|
||||
# win32 usually doesn't have /bin/mail
|
||||
#$blat = 'c:/nstools/bin/blat';
|
||||
#$use_blat = 0;
|
||||
|
||||
# Set moz_cvsroot to something like:
|
||||
# :pserver:$ENV{USER}%netscape.com\@cvs.mozilla.org:/cvsroot
|
||||
# :pserver:anonymous\@cvs-mirror.mozilla.org:/cvsroot
|
||||
#
|
||||
# Note that win32 may not need \@, depends on ' or ".
|
||||
# :pserver:$ENV{USER}%netscape.com@cvs.mozilla.org:/cvsroot
|
||||
|
||||
# CONFIG: $moz_cvsroot = '%mozillaCvsroot%';
|
||||
$moz_cvsroot = 'cltbld@cvs.mozilla.org:/cvsroot';
|
||||
|
||||
#- Set these proper values for your tinderbox server
|
||||
#$Tinderbox_server = 'tinderbox-daemon@tinderbox.mozilla.org';
|
||||
|
||||
# Allow for non-client builds, e.g. camino.
|
||||
#$moz_client_mk = 'client.mk';
|
||||
|
||||
#- Set if you want to build in a separate object tree
|
||||
$ObjDir = '../build/universal';
|
||||
|
||||
# Extra build name, if needed.
|
||||
$BuildNameExtra = 'Release';
|
||||
|
||||
# User comment, eg. ip address for dhcp builds.
|
||||
# ex: $UserComment = "ip = 208.12.36.108";
|
||||
#$UserComment = 0;
|
||||
|
||||
#-
|
||||
#- The rest should not need to be changed
|
||||
#-
|
||||
|
||||
#- Minimum wait period from start of build to start of next build in minutes.
|
||||
#$BuildSleep = 10;
|
||||
|
||||
#- Until you get the script working. When it works,
|
||||
#- change to the tree you're actually building
|
||||
# CONFIG: $BuildTree = '%buildTree%';
|
||||
$BuildTree = 'MozillaRelease';
|
||||
|
||||
#$BuildName = '';
|
||||
# CONFIG: $BuildTag = '%productTag%_RELEASE';
|
||||
$BuildTag = 'FIREFOX_3_0_19_RELEASE';
|
||||
#$BuildConfigDir = 'mozilla/config';
|
||||
#$Topsrcdir = 'mozilla';
|
||||
|
||||
$BinaryName = 'firefox-bin';
|
||||
|
||||
#
|
||||
# For embedding app, use:
|
||||
#$EmbedBinaryName = 'TestGtkEmbed';
|
||||
#$EmbedDistDir = 'dist/bin'
|
||||
|
||||
|
||||
#$ShellOverride = ''; # Only used if the default shell is too stupid
|
||||
#$ConfigureArgs = '';
|
||||
#$ConfigureEnvArgs = '';
|
||||
#$Compiler = 'gcc';
|
||||
#$NSPRArgs = '';
|
||||
#$ShellOverride = '';
|
||||
|
||||
# Release build options
|
||||
$ReleaseBuild = 1;
|
||||
$shiptalkback = 0;
|
||||
$ReleaseToLatest = 0; # Push the release to latest-<milestone>?
|
||||
$ReleaseToDated = 1; # Push the release to YYYY-MM-DD-HH-<milestone>?
|
||||
$build_hour = "4";
|
||||
$package_creation_path = "/browser/installer";
|
||||
# needs setting for mac + talkback: $mac_bundle_path = "/browser/app";
|
||||
$mac_bundle_path = "/browser/app";
|
||||
$ssh_version = "2";
|
||||
# CONFIG: $ssh_user = "%sshUser%";
|
||||
$ssh_user = "cltbld";
|
||||
# CONFIG: $ssh_server = "%sshServer%";
|
||||
$ssh_server = "stage-old.mozilla.org";
|
||||
$ftp_path = "/home/ftp/pub/firefox/nightly";
|
||||
$url_path = "http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly";
|
||||
$tbox_ftp_path = "/home/ftp/pub/firefox/tinderbox-builds";
|
||||
$tbox_url_path = "http://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds";
|
||||
# CONFIG: $milestone = 'firefox%version%';
|
||||
$milestone = 'firefox3.0.19';
|
||||
$notify_list = "build-announce\@mozilla.org";
|
||||
$stub_installer = 0;
|
||||
$sea_installer = 0;
|
||||
$archive = 1;
|
||||
$push_raw_xpis = 0;
|
||||
$update_package = 1;
|
||||
$update_product = "Firefox";
|
||||
$update_version = "trunk";
|
||||
$update_platform = "Darwin_Universal-gcc3";
|
||||
$update_hash = "sha1";
|
||||
$update_filehost = "ftp.mozilla.org";
|
||||
$update_ver_file = 'browser/config/version.txt';
|
||||
$update_pushinfo = 0;
|
||||
$crashreporter_buildsymbols = 1;
|
||||
$crashreporter_pushsymbols = 1;
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_HOST'} = '%symbolServer%';
|
||||
$ENV{'SYMBOL_SERVER_HOST'} = 'dm-symbolpush01.mozilla.org';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_USER'} = '%symbolServerUser%';
|
||||
$ENV{'SYMBOL_SERVER_USER'} = 'ffxbld';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_PATH'} = '%symbolServerPath%';
|
||||
$ENV{'SYMBOL_SERVER_PATH'} = '/mnt/netapp/breakpad/symbols_ffx';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_SSH_KEY'} = '%symbolServerKey%';
|
||||
$ENV{'SYMBOL_SERVER_SSH_KEY'} = '/Users/cltbld/.ssh/ffxbld_dsa';
|
||||
|
||||
# Reboot the OS at the end of build-and-test cycle. This is primarily
|
||||
# intended for Win9x, which can't last more than a few cycles before
|
||||
# locking up (and testing would be suspect even after a couple of cycles).
|
||||
# Right now, there is only code to force the reboot for Win9x, so even
|
||||
# setting this to 1, will not have an effect on other platforms. Setting
|
||||
# up win9x to automatically logon and begin running tinderbox is left
|
||||
# as an exercise to the reader.
|
||||
#$RebootSystem = 0;
|
||||
|
||||
# LogCompression specifies the type of compression used on the log file.
|
||||
# Valid options are 'gzip', and 'bzip2'. Please make sure the binaries
|
||||
# for 'gzip' or 'bzip2' are in the user's path before setting this
|
||||
# option.
|
||||
#$LogCompression = '';
|
||||
|
||||
# LogEncoding specifies the encoding format used for the logs. Valid
|
||||
# options are 'base64', and 'uuencode'. If $LogCompression is set above,
|
||||
# this needs to be set to 'base64' or 'uuencode' to ensure that the
|
||||
# binary data is transferred properly.
|
||||
#$LogEncoding = '';
|
||||
|
||||
# Prevent Extension Manager from spawning child processes during tests
|
||||
# - processes that tbox scripts cannot kill.
|
||||
#$ENV{NO_EM_RESTART} = '1';
|
||||
|
||||
# Do not build XForms
|
||||
$BuildXForms = 0;
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
## hostname: fx-win32-tbox
|
||||
## uname: MINGW32_NT-5.2 FX-WIN32-TBOX 1.0.11(0.46/3/2) 2007-01-12 12:05 i686 Msys
|
||||
#
|
||||
export CFLAGS="-GL -wd4624 -wd4952"
|
||||
export CXXFLAGS="-GL -wd4624 -wd4952"
|
||||
export LDFLAGS="-LTCG"
|
||||
|
||||
mk_add_options MOZ_CO_PROJECT=browser
|
||||
mk_add_options MOZ_MAKE_FLAGS="-j1"
|
||||
mk_add_options MOZ_CO_MODULE="mozilla/tools/update-packaging"
|
||||
mk_add_options PROFILE_GEN_SCRIPT='$(PYTHON) $(MOZ_OBJDIR)/_profile/pgo/profileserver.py'
|
||||
|
||||
ac_add_options --enable-application=browser
|
||||
ac_add_options --enable-update-channel=release
|
||||
ac_add_options --enable-optimize
|
||||
ac_add_options --disable-debug
|
||||
ac_add_options --disable-tests
|
||||
ac_add_options --enable-update-packaging
|
||||
ac_add_options --enable-official-branding
|
||||
ac_add_options --enable-jemalloc
|
||||
ac_add_options --with-crashreporter-enable-percent=10
|
||||
@@ -1,267 +0,0 @@
|
||||
#
|
||||
## hostname: fx-win32-tbox
|
||||
## uname: MINGW32_NT-5.2 FX-WIN32-TBOX 1.0.11(0.46/3/2) 2007-01-12 12:05 i686 Msys
|
||||
#
|
||||
|
||||
#- tinder-config.pl - Tinderbox configuration file.
|
||||
#- Uncomment the variables you need to set.
|
||||
#- The default values are the same as the commented variables.
|
||||
|
||||
$ENV{NO_EM_RESTART} = '1';
|
||||
$ENV{CVS_RSH} = "ssh";
|
||||
$ENV{MOZ_CRASHREPORTER_NO_REPORT} = '1';
|
||||
# Both these two variables are for source server support
|
||||
$ENV{PDBSTR_PATH} = 'C:\\Program Files\\Debugging Tools for Windows\\sdk\\srcsrv\\pdbstr.exe';
|
||||
$ENV{SRCSRV_ROOT} = ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot';
|
||||
|
||||
# $ENV{MOZ_PACKAGE_MSI}
|
||||
#-----------------------------------------------------------------------------
|
||||
# Default: 0
|
||||
# Values: 0 | 1
|
||||
# Purpose: Controls whether a MSI package is made.
|
||||
# Requires: Windows and a local MakeMSI installation.
|
||||
#$ENV{MOZ_PACKAGE_MSI} = 0;
|
||||
|
||||
# $ENV{MOZ_SYMBOLS_TRANSFER_TYPE}
|
||||
#-----------------------------------------------------------------------------
|
||||
# Default: scp
|
||||
# Values: scp | rsync
|
||||
# Purpose: Use scp or rsync to transfer symbols to the Talkback server.
|
||||
# Requires: The selected type requires the command be available both locally
|
||||
# and on the Talkback server.
|
||||
#$ENV{MOZ_SYMBOLS_TRANSFER_TYPE} = "scp";
|
||||
|
||||
#- PLEASE FILL THIS IN WITH YOUR PROPER EMAIL ADDRESS
|
||||
$BuildAdministrator = 'build@mozilla.org';
|
||||
#$BuildAdministrator = "$ENV{USER}\@$ENV{HOST}";
|
||||
#$BuildAdministrator = ($ENV{USER} || "cltbld") . "\@" . ($ENV{HOST} || "dhcp");
|
||||
|
||||
#- You'll need to change these to suit your machine's needs
|
||||
#$DisplayServer = ':0.0';
|
||||
|
||||
#- Default values of command-line opts
|
||||
#-
|
||||
#$BuildDepend = 1; # Depend or Clobber
|
||||
#$BuildDebug = 0; # Debug or Opt (Darwin)
|
||||
#$ReportStatus = 1; # Send results to server, or not
|
||||
#$ReportFinalStatus = 1; # Finer control over $ReportStatus.
|
||||
$UseTimeStamp = 0; # Use the CVS 'pull-by-timestamp' option, or not
|
||||
#$BuildOnce = 0; # Build once, don't send results to server
|
||||
#$TestOnly = 0; # Only run tests, don't pull/build
|
||||
#$BuildEmbed = 0; # After building seamonkey, go build embed app.
|
||||
#$SkipMozilla = 0; # Use to debug post-mozilla.pl scripts.
|
||||
#$BuildLocales = 0; # Do l10n packaging?
|
||||
|
||||
# Tests
|
||||
$CleanProfile = 1;
|
||||
#$ResetHomeDirForTests = 1;
|
||||
$ProductName = "Firefox";
|
||||
$VendorName = "Mozilla";
|
||||
|
||||
$RunMozillaTests = 1; # Allow turning off of all tests if needed.
|
||||
$RegxpcomTest = 1;
|
||||
$AliveTest = 1;
|
||||
$JavaTest = 0;
|
||||
$ViewerTest = 0;
|
||||
$BloatTest = 0; # warren memory bloat test
|
||||
$BloatTest2 = 0; # dbaron memory bloat test, require tracemalloc
|
||||
$DomToTextConversionTest = 0;
|
||||
$XpcomGlueTest = 0;
|
||||
$CodesizeTest = 0; # Z, require mozilla/tools/codesighs
|
||||
$EmbedCodesizeTest = 0; # mZ, require mozilla/tools/codesigns
|
||||
$MailBloatTest = 0;
|
||||
$EmbedTest = 0; # Assumes you wanted $BuildEmbed=1
|
||||
$LayoutPerformanceTest = 0; # Tp
|
||||
$DHTMLPerformanceTest = 0; # Tdhtml
|
||||
$QATest = 0;
|
||||
$XULWindowOpenTest = 0; # Txul
|
||||
$StartupPerformanceTest = 0; # Ts
|
||||
$NeckoUnitTest = 0;
|
||||
$RenderPerformanceTest = 0; # Tgfx
|
||||
|
||||
$TestsPhoneHome = 0; # Should test report back to server?
|
||||
$GraphNameOverride = 'fx-win32-tbox';
|
||||
|
||||
# $results_server
|
||||
#----------------------------------------------------------------------------
|
||||
# Server on which test results will be accessible. This was originally tegu,
|
||||
# then became axolotl. Once we moved services from axolotl, it was time
|
||||
# to give this service its own hostname to make future transitions easier.
|
||||
# - cmp@mozilla.org
|
||||
#$results_server = "build-graphs.mozilla.org";
|
||||
|
||||
$pageload_server = "pageload.build.mozilla.org"; # localhost
|
||||
|
||||
#
|
||||
# Timeouts, values are in seconds.
|
||||
#
|
||||
#$CVSCheckoutTimeout = 3600;
|
||||
#$CreateProfileTimeout = 45;
|
||||
#$RegxpcomTestTimeout = 120;
|
||||
|
||||
#$AliveTestTimeout = 30;
|
||||
#$ViewerTestTimeout = 45;
|
||||
#$EmbedTestTimeout = 45;
|
||||
#$BloatTestTimeout = 120; # seconds
|
||||
#$MailBloatTestTimeout = 120; # seconds
|
||||
#$JavaTestTimeout = 45;
|
||||
#$DomTestTimeout = 45; # seconds
|
||||
#$XpcomGlueTestTimeout = 15;
|
||||
#$CodesizeTestTimeout = 900; # seconds
|
||||
#$CodesizeTestType = "auto"; # {"auto"|"base"}
|
||||
$LayoutPerformanceTestTimeout = 800; # entire test, seconds
|
||||
#$DHTMLPerformanceTestTimeout = 1200; # entire test, seconds
|
||||
#$QATestTimeout = 1200; # entire test, seconds
|
||||
#$LayoutPerformanceTestPageTimeout = 30000; # each page, ms
|
||||
#$StartupPerformanceTestTimeout = 20; # seconds
|
||||
#$XULWindowOpenTestTimeout = 90; # seconds
|
||||
#$NeckoUnitTestTimeout = 30; # seconds
|
||||
$RenderPerformanceTestTimeout = 1800; # seconds
|
||||
|
||||
#$MozConfigFileName = 'mozconfig';
|
||||
|
||||
#$UseMozillaProfile = 1;
|
||||
#$MozProfileName = 'default';
|
||||
|
||||
#- Set these to what makes sense for your system
|
||||
$Make = 'make'; # Must be GNU make
|
||||
#$MakeOverrides = '';
|
||||
#$mail = '/bin/mail';
|
||||
#$CVS = 'cvs -q';
|
||||
#$CVSCO = 'checkout -P';
|
||||
|
||||
# win32 usually doesn't have /bin/mail
|
||||
$blat = '/d/mozilla-build/blat261/full/blat';
|
||||
#$use_blat = 1;
|
||||
|
||||
# Set moz_cvsroot to something like:
|
||||
# :pserver:$ENV{USER}%netscape.com\@cvs.mozilla.org:/cvsroot
|
||||
# :pserver:anonymous\@cvs-mirror.mozilla.org:/cvsroot
|
||||
#
|
||||
# Note that win32 may not need \@, depends on ' or ".
|
||||
# :pserver:$ENV{USER}%netscape.com@cvs.mozilla.org:/cvsroot
|
||||
|
||||
# CONFIG: $moz_cvsroot = '%mozillaCvsroot%';
|
||||
$moz_cvsroot = 'cltbld@cvs.mozilla.org:/cvsroot';
|
||||
|
||||
#- Set these proper values for your tinderbox server
|
||||
#$Tinderbox_server = 'tinderbox-daemon@tinderbox.mozilla.org';
|
||||
|
||||
# Allow for non-client builds, e.g. camino.
|
||||
#$moz_client_mk = 'client.mk';
|
||||
|
||||
#- Set if you want to build in a separate object tree
|
||||
$ObjDir = 'obj-fx-trunk';
|
||||
|
||||
# Extra build name, if needed.
|
||||
$BuildNameExtra = 'Release';
|
||||
|
||||
# User comment, eg. ip address for dhcp builds.
|
||||
# ex: $UserComment = "ip = 208.12.36.108";
|
||||
#$UserComment = 0;
|
||||
|
||||
#-
|
||||
#- The rest should not need to be changed
|
||||
#-
|
||||
|
||||
#- Minimum wait period from start of build to start of next build in minutes.
|
||||
#$BuildSleep = 10;
|
||||
|
||||
#- Until you get the script working. When it works,
|
||||
#- change to the tree you're actually building
|
||||
#$BuildTree = 'MozillaTest';
|
||||
# CONFIG: $BuildTree = '%buildTree%';
|
||||
$BuildTree = 'MozillaRelease';
|
||||
|
||||
#$BuildName = '';
|
||||
# CONFIG: $BuildTag = '%productTag%_RELEASE';
|
||||
$BuildTag = 'FIREFOX_3_0_19_RELEASE';
|
||||
#$BuildConfigDir = 'mozilla/config';
|
||||
#$Topsrcdir = 'mozilla';
|
||||
|
||||
$BinaryName = 'firefox.exe';
|
||||
|
||||
#
|
||||
# For embedding app, use:
|
||||
#$EmbedBinaryName = 'TestGtkEmbed';
|
||||
#$EmbedDistDir = 'dist/bin'
|
||||
|
||||
|
||||
#$ShellOverride = ''; # Only used if the default shell is too stupid
|
||||
#$ConfigureArgs = '';
|
||||
#$ConfigureEnvArgs = '';
|
||||
#$Compiler = 'gcc';
|
||||
#$NSPRArgs = '';
|
||||
#$ShellOverride = '';
|
||||
|
||||
$ProfiledBuild = 1;
|
||||
# Release build options
|
||||
$ReleaseBuild = 1;
|
||||
$shiptalkback = 0;
|
||||
$ReleaseToLatest = 0; # Push the release to latest-<milestone>?
|
||||
$ReleaseToDated = 1; # Push the release to YYYY-MM-DD-HH-<milestone>?
|
||||
$build_hour = "4";
|
||||
$package_creation_path = "/browser/installer";
|
||||
# needs setting for mac + talkback: $mac_bundle_path = "/browser/app";
|
||||
$ssh_version = "2";
|
||||
# CONFIG: $ssh_user = "%sshUser%";
|
||||
$ssh_user = "cltbld";
|
||||
# CONFIG: $ssh_server = "%sshServer%";
|
||||
$ssh_server = "stage-old.mozilla.org";
|
||||
$ftp_path = "/home/ftp/pub/firefox/nightly";
|
||||
$url_path = "http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly";
|
||||
$tbox_ftp_path = "/home/ftp/pub/firefox/tinderbox-builds";
|
||||
$tbox_url_path = "http://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds";
|
||||
# CONFIG: $milestone = 'firefox%version%';
|
||||
$milestone = 'firefox3.0.19';
|
||||
$notify_list = 'build-announce@mozilla.org';
|
||||
$stub_installer = 0;
|
||||
$sea_installer = 1;
|
||||
$archive = 1;
|
||||
$push_raw_xpis = 0;
|
||||
$update_package = 1;
|
||||
$update_product = "Firefox";
|
||||
$update_version = "trunk";
|
||||
$update_platform = "WINNT_x86-msvc";
|
||||
$update_hash = "sha1";
|
||||
$update_filehost = "ftp.mozilla.org";
|
||||
$update_ver_file = 'browser/config/version.txt';
|
||||
$update_pushinfo = 0;
|
||||
$crashreporter_buildsymbols = 1;
|
||||
$crashreporter_pushsymbols = 1;
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_HOST'} = '%symbolServer%';
|
||||
$ENV{'SYMBOL_SERVER_HOST'} = 'dm-symbolpush01.mozilla.org';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_USER'} = '%symbolServerUser%';
|
||||
$ENV{'SYMBOL_SERVER_USER'} = 'ffxbld';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_PATH'} = '%symbolServerPath%';
|
||||
$ENV{'SYMBOL_SERVER_PATH'} = '/mnt/netapp/breakpad/symbols_ffx';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_SSH_KEY'} = '%symbolServerKey%';
|
||||
$ENV{'SYMBOL_SERVER_SSH_KEY'} = '/c/Documents and Settings/cltbld/.ssh/ffxbld_dsa';
|
||||
|
||||
# Reboot the OS at the end of build-and-test cycle. This is primarily
|
||||
# intended for Win9x, which can't last more than a few cycles before
|
||||
# locking up (and testing would be suspect even after a couple of cycles).
|
||||
# Right now, there is only code to force the reboot for Win9x, so even
|
||||
# setting this to 1, will not have an effect on other platforms. Setting
|
||||
# up win9x to automatically logon and begin running tinderbox is left
|
||||
# as an exercise to the reader.
|
||||
#$RebootSystem = 0;
|
||||
|
||||
# LogCompression specifies the type of compression used on the log file.
|
||||
# Valid options are 'gzip', and 'bzip2'. Please make sure the binaries
|
||||
# for 'gzip' or 'bzip2' are in the user's path before setting this
|
||||
# option.
|
||||
#$LogCompression = '';
|
||||
|
||||
# LogEncoding specifies the encoding format used for the logs. Valid
|
||||
# options are 'base64', and 'uuencode'. If $LogCompression is set above,
|
||||
# this needs to be set to 'base64' or 'uuencode' to ensure that the
|
||||
# binary data is transferred properly.
|
||||
#$LogEncoding = '';
|
||||
|
||||
# Prevent Extension Manager from spawning child processes during tests
|
||||
# - processes that tbox scripts cannot kill.
|
||||
#$ENV{NO_EM_RESTART} = '1';
|
||||
|
||||
# Do not build XForms
|
||||
$BuildXForms = 0;
|
||||
@@ -1 +0,0 @@
|
||||
Clobbering to force nightly due to nightly bustage from bug 428672.
|
||||
@@ -1,25 +0,0 @@
|
||||
#
|
||||
## hostname: tb-linux-tbox
|
||||
## uname: Linux tb-linux-tbox.build.mozilla.org 2.6.18-8.el5 #1 SMP Thu Mar 15 19:57:35 EDT 2007 i686 athlon i386 GNU/Linux
|
||||
#
|
||||
|
||||
# symbols for breakpad
|
||||
export CFLAGS="-gstabs+"
|
||||
export CXXFLAGS="-gstabs+"
|
||||
|
||||
mk_add_options MOZ_CO_PROJECT=mail
|
||||
mk_add_options MOZ_MAKE_FLAGS=-j1
|
||||
mk_add_options MOZ_CO_MODULE="mozilla/tools/update-packaging"
|
||||
|
||||
ac_add_options --enable-application=mail
|
||||
ac_add_options --enable-update-channel=beta
|
||||
ac_add_options --disable-debug
|
||||
ac_add_options --enable-update-packaging
|
||||
# Add explicit optimize flags in configure.in, not here - see bug 407794
|
||||
ac_add_options --enable-optimize
|
||||
ac_add_options --disable-tests
|
||||
ac_add_options --disable-shared
|
||||
ac_add_options --enable-static
|
||||
|
||||
CC=/tools/gcc-4.1.1/bin/gcc
|
||||
CXX=/tools/gcc-4.1.1/bin/g++
|
||||
@@ -1,225 +0,0 @@
|
||||
#
|
||||
## hostname: tb-linux-tbox
|
||||
## uname: Linux tbnewref-linux-tbox.build.mozilla.org 2.6.18-8.el5 #1 SMP Thu Mar 15 19:57:35 EDT 2007 i686 athlon i386 GNU/Linux
|
||||
#
|
||||
|
||||
#- tinder-config.pl - Tinderbox configuration file.
|
||||
#- Uncomment the variables you need to set.
|
||||
#- The default values are the same as the commented variables.
|
||||
|
||||
$ENV{CVS_RSH} = "ssh";
|
||||
$ENV{MOZ_CRASHREPORTER_NO_REPORT} = '1';
|
||||
|
||||
#- PLEASE FILL THIS IN WITH YOUR PROPER EMAIL ADDRESS
|
||||
#$BuildAdministrator = "$ENV{USER}\@$ENV{HOST}";
|
||||
#$BuildAdministrator = ($ENV{USER} || "cltbld") . "\@" . ($ENV{HOST} || "dhcp");
|
||||
|
||||
#- You'll need to change these to suit your machine's needs
|
||||
#$DisplayServer = ':0.0';
|
||||
|
||||
#- Default values of command-line opts
|
||||
#-
|
||||
$BuildDepend = 0; # Depend or Clobber
|
||||
#$BuildDebug = 0; # Debug or Opt (Darwin)
|
||||
#$ReportStatus = 1; # Send results to server, or not
|
||||
#$ReportFinalStatus = 1; # Finer control over $ReportStatus.
|
||||
$UseTimeStamp = 0; # Use the CVS 'pull-by-timestamp' option, or not
|
||||
#$BuildOnce = 0; # Build once, don't send results to server
|
||||
#$TestOnly = 0; # Only run tests, don't pull/build
|
||||
#$BuildEmbed = 0; # After building seamonkey, go build embed app.
|
||||
#$SkipMozilla = 0; # Use to debug post-mozilla.pl scripts.
|
||||
|
||||
# Tests
|
||||
$CleanProfile = 1;
|
||||
#$ResetHomeDirForTests = 1;
|
||||
$ProductName = "Thunderbird";
|
||||
#$VendorName = "";
|
||||
|
||||
$RunMozillaTests = 1; # Allow turning off of all tests if needed.
|
||||
#$RegxpcomTest = 1;
|
||||
#$AliveTest = 1;
|
||||
#$JavaTest = 0;
|
||||
#$ViewerTest = 0;
|
||||
#$BloatTest = 0; # warren memory bloat test
|
||||
#$BloatTest2 = 0; # dbaron memory bloat test, require tracemalloc
|
||||
#$DomToTextConversionTest = 0;
|
||||
#$XpcomGlueTest = 0;
|
||||
$CodesizeTest = 0; # Z, require mozilla/tools/codesighs
|
||||
#$EmbedCodesizeTest = 0; # mZ, require mozilla/tools/codesigns
|
||||
#$MailBloatTest = 0;
|
||||
#$EmbedTest = 0; # Assumes you wanted $BuildEmbed=1
|
||||
#$LayoutPerformanceTest = 0; # Tp
|
||||
#$QATest = 0;
|
||||
#$XULWindowOpenTest = 0; # Txul
|
||||
#$StartupPerformanceTest = 0; # Ts
|
||||
|
||||
$TestsPhoneHome = 0; # Should test report back to server?
|
||||
#$results_server = "axolotl.mozilla.org"; # was tegu
|
||||
#$pageload_server = "spider"; # localhost
|
||||
|
||||
#
|
||||
# Timeouts, values are in seconds.
|
||||
#
|
||||
#$CVSCheckoutTimeout = 3600;
|
||||
#$CreateProfileTimeout = 45;
|
||||
#$RegxpcomTestTimeout = 15;
|
||||
|
||||
#$AliveTestTimeout = 45;
|
||||
#$ViewerTestTimeout = 45;
|
||||
#$EmbedTestTimeout = 45;
|
||||
#$BloatTestTimeout = 120; # seconds
|
||||
#$MailBloatTestTimeout = 120; # seconds
|
||||
#$JavaTestTimeout = 45;
|
||||
#$DomTestTimeout = 45; # seconds
|
||||
#$XpcomGlueTestTimeout = 15;
|
||||
#$CodesizeTestTimeout = 900; # seconds
|
||||
#$CodesizeTestType = "auto"; # {"auto"|"base"}
|
||||
#$LayoutPerformanceTestTimeout = 1200; # entire test, seconds
|
||||
#$QATestTimeout = 1200; # entire test, seconds
|
||||
#$LayoutPerformanceTestPageTimeout = 30000; # each page, ms
|
||||
#$StartupPerformanceTestTimeout = 60; # seconds
|
||||
#$XULWindowOpenTestTimeout = 150; # seconds
|
||||
|
||||
|
||||
#$MozConfigFileName = 'mozconfig';
|
||||
|
||||
#$UseMozillaProfile = 1;
|
||||
#$MozProfileName = 'default';
|
||||
|
||||
#- Set these to what makes sense for your system
|
||||
#$Make = 'gmake'; # Must be GNU make
|
||||
#$MakeOverrides = '';
|
||||
#$mail = '/bin/mail';
|
||||
#$CVS = 'cvs -q';
|
||||
#$CVSCO = 'checkout -P';
|
||||
|
||||
# win32 usually doesn't have /bin/mail
|
||||
#$blat = 'c:/nstools/bin/blat';
|
||||
#$use_blat = 0;
|
||||
|
||||
# Set moz_cvsroot to something like:
|
||||
# :pserver:$ENV{USER}%netscape.com\@cvs.mozilla.org:/cvsroot
|
||||
# :pserver:anonymous\@cvs-mirror.mozilla.org:/cvsroot
|
||||
#
|
||||
# Note that win32 may not need \@, depends on ' or ".
|
||||
# :pserver:$ENV{USER}%netscape.com@cvs.mozilla.org:/cvsroot
|
||||
|
||||
# CONFIG: $moz_cvsroot = '%mozillaCvsroot%';
|
||||
$moz_cvsroot = 'cltbld@cvs.mozilla.org:/cvsroot';
|
||||
|
||||
#- Set these proper values for your tinderbox server
|
||||
#$Tinderbox_server = 'tinderbox-daemon@tinderbox.mozilla.org';
|
||||
|
||||
# Allow for non-client builds, e.g. camino.
|
||||
#$moz_client_mk = 'client.mk';
|
||||
|
||||
#- Set if you want to build in a separate object tree
|
||||
$ObjDir = 'obj-tb-trunk';
|
||||
|
||||
# Extra build name, if needed.
|
||||
$BuildNameExtra = 'Release';
|
||||
|
||||
# User comment, eg. ip address for dhcp builds.
|
||||
# ex: $UserComment = "ip = 208.12.36.108";
|
||||
#$UserComment = 0;
|
||||
|
||||
#-
|
||||
#- The rest should not need to be changed
|
||||
#-
|
||||
|
||||
#- Minimum wait period from start of build to start of next build in minutes.
|
||||
#$BuildSleep = 10;
|
||||
|
||||
#- Until you get the script working. When it works,
|
||||
#- change to the tree you're actually building
|
||||
# CONFIG: $BuildTree = '%buildTree%';
|
||||
$BuildTree = 'MozillaRelease';
|
||||
|
||||
#$BuildName = '';
|
||||
# CONFIG: $BuildTag = '%productTag%_RELEASE';
|
||||
$BuildTag = 'THUNDERBIRD_3_0a2_RELEASE';
|
||||
#$BuildConfigDir = 'mozilla/config';
|
||||
#$Topsrcdir = 'mozilla';
|
||||
|
||||
$BinaryName = 'thunderbird-bin';
|
||||
|
||||
#
|
||||
# For embedding app, use:
|
||||
#$EmbedBinaryName = 'TestGtkEmbed';
|
||||
#$EmbedDistDir = 'dist/bin'
|
||||
|
||||
|
||||
#$ShellOverride = ''; # Only used if the default shell is too stupid
|
||||
#$ConfigureArgs = '';
|
||||
#$ConfigureEnvArgs = '';
|
||||
#$Compiler = 'gcc';
|
||||
#$NSPRArgs = '';
|
||||
#$ShellOverride = '';
|
||||
|
||||
# allow override of timezone value (for win32 POSIX::strftime)
|
||||
#$Timezone = '';
|
||||
|
||||
# Release build options
|
||||
$ReleaseBuild = 1;
|
||||
$ReleaseToLatest = 0; # Push the release to latest-<milestone>?
|
||||
$ReleaseToDated = 1; # Push the release to YYYY-MM-DD-HH-<milestone>?
|
||||
$shiptalkback = 0;
|
||||
$build_hour = "3";
|
||||
$package_creation_path = "/mail/installer";
|
||||
$ssh_version = "2";
|
||||
# CONFIG: $ssh_user = "%sshUser%";
|
||||
$ssh_user = "cltbld";
|
||||
# CONFIG: $ssh_server = "%sshServer%";
|
||||
$ssh_server = "stage-old.mozilla.org";
|
||||
#$ReleaseGroup = "thunderbird";
|
||||
$ftp_path = "/home/ftp/pub/thunderbird/nightly";
|
||||
$url_path = "http://ftp.mozilla.org/pub/mozilla.org/thunderbird/nightly";
|
||||
$tbox_ftp_path = "/home/ftp/pub/thunderbird/tinderbox-builds";
|
||||
$tbox_url_path = "http://ftp.mozilla.org/pub/mozilla.org/thunderbird/tinderbox-builds";
|
||||
# CONFIG: $milestone = 'thunderbird%version%';
|
||||
$milestone = 'thunderbird3.0a2';
|
||||
$notify_list = "build-announce\@mozilla.org";
|
||||
$stub_installer = 0;
|
||||
$sea_installer = 0;
|
||||
$archive = 1;
|
||||
$update_package = 1;
|
||||
$update_product = "Thunderbird";
|
||||
$update_version = "trunk";
|
||||
$update_platform = "Linux_x86-gcc3";
|
||||
$update_hash = "sha1";
|
||||
$update_filehost = "ftp.mozilla.org";
|
||||
$update_ver_file = "mail/config/version.txt";
|
||||
$update_pushinfo = 0;
|
||||
$crashreporter_buildsymbols = 1;
|
||||
$crashreporter_pushsymbols = 1;
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_HOST'} = '%symbolServer%';
|
||||
$ENV{'SYMBOL_SERVER_HOST'} = 'dm-symbolpush01.mozilla.org';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_USER'} = '%symbolServerUser%';
|
||||
$ENV{'SYMBOL_SERVER_USER'} = 'tbirdbld';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_PATH'} = '%symbolServerPath%';
|
||||
$ENV{'SYMBOL_SERVER_PATH'} = '/mnt/netapp/breakpad/symbols_tbrd';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_SSH_KEY'} = '%symbolServerKey%';
|
||||
$ENV{'SYMBOL_SERVER_SSH_KEY'} = '/home/cltbld/.ssh/tbirdbld_dsa';
|
||||
|
||||
# Reboot the OS at the end of build-and-test cycle. This is primarily
|
||||
# intended for Win9x, which can't last more than a few cycles before
|
||||
# locking up (and testing would be suspect even after a couple of cycles).
|
||||
# Right now, there is only code to force the reboot for Win9x, so even
|
||||
# setting this to 1, will not have an effect on other platforms. Setting
|
||||
# up win9x to automatically logon and begin running tinderbox is left
|
||||
# as an exercise to the reader.
|
||||
#$RebootSystem = 0;
|
||||
|
||||
# LogCompression specifies the type of compression used on the log file.
|
||||
# Valid options are 'gzip', and 'bzip2'. Please make sure the binaries
|
||||
# for 'gzip' or 'bzip2' are in the user's path before setting this
|
||||
# option.
|
||||
#$LogCompression = 'bzip2';
|
||||
|
||||
# LogEncoding specifies the encoding format used for the logs. Valid
|
||||
# options are 'base64', and 'uuencode'. If $LogCompression is set above,
|
||||
# this needs to be set to 'base64' or 'uuencode' to ensure that the
|
||||
# binary data is transferred properly.
|
||||
#$LogEncoding = 'base64';
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Clobbering to force nightly due to nightly bustage from bug 428672.
|
||||
@@ -1,28 +0,0 @@
|
||||
#
|
||||
## hostname: bm-xserve07.build.mozilla.org
|
||||
## uname: Darwin bm-xserve07.build.mozilla.org 8.8.4 Darwin Kernel Version 8.8.4: Sun Oct 29 15:26:54 PST 2006; root:xnu-792.16.4.obj~1/RELEASE_I386 i386 i386
|
||||
#
|
||||
|
||||
# symbols for breakpad
|
||||
export CFLAGS="-g -gfull"
|
||||
export CXXFLAGS="-g -gfull"
|
||||
|
||||
. $topsrcdir/build/macosx/universal/mozconfig
|
||||
|
||||
# Make flags
|
||||
mk_add_options MOZ_CO_PROJECT=mail
|
||||
mk_add_options MOZ_MAKE_FLAGS="-j1"
|
||||
mk_add_options MOZ_CO_MODULE="mozilla/tools/update-packaging"
|
||||
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../build/universal
|
||||
|
||||
# Configure flags
|
||||
ac_add_options --enable-application=mail
|
||||
ac_add_options --enable-update-channel=beta
|
||||
# Add explicit optimize flags in configure.in, not here - see bug 407794
|
||||
ac_add_options --enable-optimize
|
||||
ac_add_options --disable-debug
|
||||
ac_add_options --disable-tests
|
||||
ac_add_options --enable-static
|
||||
ac_add_options --disable-shared
|
||||
|
||||
ac_add_options --enable-update-packaging
|
||||
@@ -1,262 +0,0 @@
|
||||
#
|
||||
## hostname: bm-xserve07.build.mozilla.org
|
||||
## uname: Darwin bm-xserve07.build.mozilla.org 8.8.4 Darwin Kernel Version 8.8.4: Sun Oct 29 15:26:54 PST 2006; root:xnu-792.16.4.obj~1/RELEASE_I386 i386 i386
|
||||
#
|
||||
|
||||
#- tinder-config.pl - Tinderbox configuration file.
|
||||
#- Uncomment the variables you need to set.
|
||||
#- The default values are the same as the commented variables.
|
||||
|
||||
# $ENV{NO_EM_RESTART} = "1";
|
||||
# $ENV{DYLD_NO_FIX_PREBINDING} = "1";
|
||||
# $ENV{LD_PREBIND_ALLOW_OVERLAP} = "1";
|
||||
$ENV{MOZ_CRASHREPORTER_NO_REPORT} = '1';
|
||||
|
||||
$MacUniversalBinary = 1;
|
||||
|
||||
# $ENV{MOZ_PACKAGE_MSI}
|
||||
#-----------------------------------------------------------------------------
|
||||
# Default: 0
|
||||
# Values: 0 | 1
|
||||
# Purpose: Controls whether a MSI package is made.
|
||||
# Requires: Windows and a local MakeMSI installation.
|
||||
#$ENV{MOZ_PACKAGE_MSI} = 0;
|
||||
|
||||
# $ENV{MOZ_SYMBOLS_TRANSFER_TYPE}
|
||||
#-----------------------------------------------------------------------------
|
||||
# Default: scp
|
||||
# Values: scp | rsync
|
||||
# Purpose: Use scp or rsync to transfer symbols to the Talkback server.
|
||||
# Requires: The selected type requires the command be available both locally
|
||||
# and on the Talkback server.
|
||||
#$ENV{MOZ_SYMBOLS_TRANSFER_TYPE} = "scp";
|
||||
|
||||
#- PLEASE FILL THIS IN WITH YOUR PROPER EMAIL ADDRESS
|
||||
$BuildAdministrator = 'build@mozilla.org';
|
||||
#$BuildAdministrator = "$ENV{USER}\@$ENV{HOST}";
|
||||
#$BuildAdministrator = ($ENV{USER} || "cltbld") . "\@" . ($ENV{HOST} || "dhcp");
|
||||
|
||||
#- You'll need to change these to suit your machine's needs
|
||||
#$DisplayServer = ':0.0';
|
||||
|
||||
#- Default values of command-line opts
|
||||
#-
|
||||
#$BuildDepend = 1; # Depend or Clobber
|
||||
#$BuildDebug = 0; # Debug or Opt (Darwin)
|
||||
#$ReportStatus = 1; # Send results to server, or not
|
||||
#$ReportFinalStatus = 1; # Finer control over $ReportStatus.
|
||||
$UseTimeStamp = 0; # Use the CVS 'pull-by-timestamp' option, or not
|
||||
#$BuildOnce = 0; # Build once, don't send results to server
|
||||
#$TestOnly = 0; # Only run tests, don't pull/build
|
||||
#$BuildEmbed = 0; # After building seamonkey, go build embed app.
|
||||
#$SkipMozilla = 0; # Use to debug post-mozilla.pl scripts.
|
||||
#$BuildLocales = 0; # Do l10n packaging?
|
||||
|
||||
# Tests
|
||||
$CleanProfile = 1;
|
||||
#$ResetHomeDirForTests = 1;
|
||||
$ProductName = "Thunderbird";
|
||||
#$VendorName = 'Mozilla';
|
||||
|
||||
$RunMozillaTests = 1; # Allow turning off of all tests if needed.
|
||||
$RegxpcomTest = 1;
|
||||
$AliveTest = 1;
|
||||
#$JavaTest = 0;
|
||||
#$ViewerTest = 0;
|
||||
#$BloatTest = 0; # warren memory bloat test
|
||||
#$BloatTest2 = 0; # dbaron memory bloat test, require tracemalloc
|
||||
#$DomToTextConversionTest = 0;
|
||||
#$XpcomGlueTest = 0;
|
||||
$CodesizeTest = 0; # Z, require mozilla/tools/codesighs
|
||||
$EmbedCodesizeTest = 0; # mZ, require mozilla/tools/codesigns
|
||||
#$MailBloatTest = 0;
|
||||
#$EmbedTest = 0; # Assumes you wanted $BuildEmbed=1
|
||||
#$LayoutPerformanceTest = 0; # Tp
|
||||
#$DHTMLPerformanceTest = 0; # Tdhtml
|
||||
#$QATest = 0;
|
||||
#$XULWindowOpenTest = 0; # Txul
|
||||
#$StartupPerformanceTest = 0; # Ts
|
||||
|
||||
$TestsPhoneHome = 0; # Should test report back to server?
|
||||
|
||||
# $results_server
|
||||
#----------------------------------------------------------------------------
|
||||
# Server on which test results will be accessible. This was originally tegu,
|
||||
# then became axolotl. Once we moved services from axolotl, it was time
|
||||
# to give this service its own hostname to make future transitions easier.
|
||||
# - cmp@mozilla.org
|
||||
#$results_server = "build-graphs.mozilla.org";
|
||||
|
||||
#$pageload_server = "spider"; # localhost
|
||||
|
||||
#
|
||||
# Timeouts, values are in seconds.
|
||||
#
|
||||
#$CVSCheckoutTimeout = 3600;
|
||||
#$CreateProfileTimeout = 45;
|
||||
#$RegxpcomTestTimeout = 120;
|
||||
|
||||
#$AliveTestTimeout = 45;
|
||||
#$ViewerTestTimeout = 45;
|
||||
#$EmbedTestTimeout = 45;
|
||||
#$BloatTestTimeout = 120; # seconds
|
||||
#$MailBloatTestTimeout = 120; # seconds
|
||||
#$JavaTestTimeout = 45;
|
||||
#$DomTestTimeout = 45; # seconds
|
||||
#$XpcomGlueTestTimeout = 15;
|
||||
#$CodesizeTestTimeout = 900; # seconds
|
||||
#$CodesizeTestType = "auto"; # {"auto"|"base"}
|
||||
#$LayoutPerformanceTestTimeout = 1200; # entire test, seconds
|
||||
#$DHTMLPerformanceTestTimeout = 1200; # entire test, seconds
|
||||
#$QATestTimeout = 1200; # entire test, seconds
|
||||
#$LayoutPerformanceTestPageTimeout = 30000; # each page, ms
|
||||
#$StartupPerformanceTestTimeout = 15; # seconds
|
||||
#$XULWindowOpenTestTimeout = 150; # seconds
|
||||
|
||||
|
||||
#$MozConfigFileName = 'mozconfig';
|
||||
|
||||
#$UseMozillaProfile = 1;
|
||||
#$MozProfileName = 'default';
|
||||
|
||||
#- Set these to what makes sense for your system
|
||||
#$Make = 'gmake'; # Must be GNU make
|
||||
#$MakeOverrides = '';
|
||||
#$mail = '/bin/mail';
|
||||
#$CVS = 'cvs -q';
|
||||
#$CVSCO = 'checkout -P';
|
||||
|
||||
# win32 usually doesn't have /bin/mail
|
||||
#$blat = 'c:/nstools/bin/blat';
|
||||
#$use_blat = 0;
|
||||
|
||||
# Set moz_cvsroot to something like:
|
||||
# :pserver:$ENV{USER}%netscape.com\@cvs.mozilla.org:/cvsroot
|
||||
# :pserver:anonymous\@cvs-mirror.mozilla.org:/cvsroot
|
||||
#
|
||||
# Note that win32 may not need \@, depends on ' or ".
|
||||
# :pserver:$ENV{USER}%netscape.com@cvs.mozilla.org:/cvsroot
|
||||
|
||||
#$moz_cvsroot = $ENV{CVSROOT};
|
||||
# CONFIG: $moz_cvsroot = '%mozillaCvsroot%';
|
||||
$moz_cvsroot = 'cltbld@cvs.mozilla.org:/cvsroot';
|
||||
|
||||
#- Set these proper values for your tinderbox server
|
||||
#$Tinderbox_server = 'tinderbox-daemon@tinderbox.mozilla.org';
|
||||
|
||||
# Allow for non-client builds, e.g. camino.
|
||||
#$moz_client_mk = 'client.mk';
|
||||
|
||||
#- Set if you want to build in a separate object tree
|
||||
$ObjDir = '../build/universal';
|
||||
|
||||
# Extra build name, if needed.
|
||||
$BuildNameExtra = 'Release';
|
||||
|
||||
# User comment, eg. ip address for dhcp builds.
|
||||
# ex: $UserComment = "ip = 208.12.36.108";
|
||||
#$UserComment = 0;
|
||||
|
||||
#-
|
||||
#- The rest should not need to be changed
|
||||
#-
|
||||
|
||||
#- Minimum wait period from start of build to start of next build in minutes.
|
||||
#$BuildSleep = 10;
|
||||
|
||||
#- Until you get the script working. When it works,
|
||||
#- change to the tree you're actually building
|
||||
#$BuildTree = 'MozillaTest';
|
||||
# CONFIG: $BuildTree = '%buildTree%';
|
||||
$BuildTree = 'MozillaRelease';
|
||||
|
||||
#$BuildName = '';
|
||||
# CONFIG: $BuildTag = '%productTag%_RELEASE';
|
||||
$BuildTag = 'THUNDERBIRD_3_0a2_RELEASE';
|
||||
#$BuildConfigDir = 'mozilla/config';
|
||||
#$Topsrcdir = 'mozilla';
|
||||
|
||||
$BinaryName = 'thunderbird-bin';
|
||||
|
||||
#
|
||||
# For embedding app, use:
|
||||
#$EmbedBinaryName = 'TestGtkEmbed';
|
||||
#$EmbedDistDir = 'dist/bin'
|
||||
|
||||
|
||||
#$ShellOverride = ''; # Only used if the default shell is too stupid
|
||||
#$ConfigureArgs = '';
|
||||
#$ConfigureEnvArgs = '';
|
||||
#$Compiler = 'gcc';
|
||||
#$NSPRArgs = '';
|
||||
#$ShellOverride = '';
|
||||
|
||||
# Release build options
|
||||
$ReleaseBuild = 1;
|
||||
$shiptalkback = 0;
|
||||
$ReleaseToLatest = 0; # Push the release to latest-<milestone>?
|
||||
$ReleaseToDated = 1; # Push the release to YYYY-MM-DD-HH-<milestone>?
|
||||
$build_hour = "3";
|
||||
$package_creation_path = "/mail/installer";
|
||||
# needs setting for mac + talkback: $mac_bundle_path = "/browser/app";
|
||||
$mac_bundle_path = "/mail/app";
|
||||
$ssh_version = "2";
|
||||
# CONFIG: $ssh_user = "%sshUser%";
|
||||
$ssh_user = "cltbld";
|
||||
# CONFIG: $ssh_server = "%sshServer%";
|
||||
$ssh_server = "stage-old.mozilla.org";
|
||||
#$ReleaseGroup = "thunderbird";
|
||||
$ftp_path = "/home/ftp/pub/thunderbird/nightly";
|
||||
$url_path = "http://ftp.mozilla.org/pub/mozilla.org/thunderbird/nightly";
|
||||
$tbox_ftp_path = "/home/ftp/pub/thunderbird/tinderbox-builds";
|
||||
$tbox_url_path = "http://ftp.mozilla.org/pub/mozilla.org/thunderbird/tinderbox-builds";
|
||||
# CONFIG: $milestone = 'thunderbird%version%';
|
||||
$milestone = 'thunderbird3.0a2';
|
||||
$notify_list = "build-announce\@mozilla.org";
|
||||
$stub_installer = 0;
|
||||
$sea_installer = 0;
|
||||
$archive = 1;
|
||||
$push_raw_xpis = 0;
|
||||
$update_package = 1;
|
||||
$update_product = "Thunderbird";
|
||||
$update_version = "trunk";
|
||||
$update_platform = "Darwin_Universal-gcc3";
|
||||
$update_hash = "sha1";
|
||||
$update_filehost = "ftp.mozilla.org";
|
||||
$update_ver_file = "mail/config/version.txt";
|
||||
$update_pushinfo = 0;
|
||||
$crashreporter_buildsymbols = 1;
|
||||
$crashreporter_pushsymbols = 1;
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_HOST'} = '%symbolServer%';
|
||||
$ENV{'SYMBOL_SERVER_HOST'} = 'dm-symbolpush01.mozilla.org';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_USER'} = '%symbolServerUser%';
|
||||
$ENV{'SYMBOL_SERVER_USER'} = 'tbirdbld';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_PATH'} = '%symbolServerPath%';
|
||||
$ENV{'SYMBOL_SERVER_PATH'} = '/mnt/netapp/breakpad/symbols_tbrd';
|
||||
# CONFIG: $ENV{'SYMBOL_SERVER_SSH_KEY'} = '%symbolServerKey%';
|
||||
$ENV{'SYMBOL_SERVER_SSH_KEY'} = '/Users/cltbld/.ssh/tbirdbld_dsa';
|
||||
|
||||
# Reboot the OS at the end of build-and-test cycle. This is primarily
|
||||
# intended for Win9x, which can't last more than a few cycles before
|
||||
# locking up (and testing would be suspect even after a couple of cycles).
|
||||
# Right now, there is only code to force the reboot for Win9x, so even
|
||||
# setting this to 1, will not have an effect on other platforms. Setting
|
||||
# up win9x to automatically logon and begin running tinderbox is left
|
||||
# as an exercise to the reader.
|
||||
#$RebootSystem = 0;
|
||||
|
||||
# LogCompression specifies the type of compression used on the log file.
|
||||
# Valid options are 'gzip', and 'bzip2'. Please make sure the binaries
|
||||
# for 'gzip' or 'bzip2' are in the user's path before setting this
|
||||
# option.
|
||||
#$LogCompression = '';
|
||||
|
||||
# LogEncoding specifies the encoding format used for the logs. Valid
|
||||
# options are 'base64', and 'uuencode'. If $LogCompression is set above,
|
||||
# this needs to be set to 'base64' or 'uuencode' to ensure that the
|
||||
# binary data is transferred properly.
|
||||
#$LogEncoding = '';
|
||||
|
||||
# Prevent Extension Manager from spawning child processes during tests
|
||||
# - processes that tbox scripts cannot kill.
|
||||
#$ENV{NO_EM_RESTART} = '1';
|
||||
@@ -1 +0,0 @@
|
||||
Clobbering to force nightly due to nightly bustage from bug 428672.
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
## hostname: tbnewref-win32-tbox
|
||||
## MINGW32_NT-5.2 TBNEWREF-WIN32- 1.0.11(0.46/3/2) 2007-01-12 12:05 i686 Msys
|
||||
#
|
||||
|
||||
mk_add_options MOZ_CO_PROJECT=mail
|
||||
mk_add_options MOZ_DEBUG_SYMBOLS=1
|
||||
mk_add_options MOZ_MAKE_FLAGS=-j1
|
||||
mk_add_options MOZ_CO_MODULE="mozilla/tools/update-packaging"
|
||||
|
||||
ac_add_options --enable-application=mail
|
||||
ac_add_options --enable-update-channel=beta
|
||||
ac_add_options --disable-debug
|
||||
# Add explicit optimize flags in configure.in, not here - see bug 407794
|
||||
ac_add_options --enable-optimize
|
||||
ac_add_options --disable-tests
|
||||
ac_add_options --disable-shared
|
||||
ac_add_options --enable-static
|
||||
ac_add_options --enable-update-packaging
|
||||
|
||||
export WIN32_REDIST_DIR="/d/msvs8/VC/redist/x86/Microsoft.VC80.CRT"
|
||||
|
||||