/* * CDE - Common Desktop Environment * * Copyright (c) 1993-2012, The Open Group. All rights reserved. * * These libraries and programs are free software; you can * redistribute them and/or modify them under the terms of the GNU * Lesser General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * any later version. * * These libraries and programs are distributed in the hope that * they will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public * License along with these libraries and programs; if not, write * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301 USA */ /* $TOG: FormatSDL.c /main/18 1999/10/14 13:18:42 mgreess $ */ /************************************<+>************************************* **************************************************************************** ** ** File: FormatSDL.c ** ** Project: CDE Help System ** ** Description: This code formats information in an SDL volume into ** an into internal format. ** ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company ** ** (c) Copyright 1993, 1994 Hewlett-Packard Company ** (c) Copyright 1993, 1994 International Business Machines Corp. ** (c) Copyright 1993, 1994 Sun Microsystems, Inc. ** (c) Copyright 1993, 1994 Novell, Inc. ** **************************************************************************** ************************************<+>*************************************/ /* * system includes */ #include #include #include #include #include #include /* * Core Engine includes */ #include "CanvasP.h" #include "CanvasSegP.h" #include "LinkMgrP.h" /* * private includes */ #include "bufioI.h" #include "CanvasOsI.h" #include "CleanUpI.h" #include "CvStringI.h" #include "CvtToArrayP.h" #include "FontAttrI.h" #include "Access.h" #include "AccessI.h" #include "AccessSDLP.h" #include "AccessSDLI.h" #include "FormatUtilI.h" #include "FormatSDLI.h" #include "StringFuncsI.h" #include "SDLI.h" #include "UtilSDLI.h" #include "RegionI.h" #ifdef NLS16 #endif /****************************************************************************** * Private structures ******************************************************************************/ typedef struct _snbLinkInfo { SDLCdata xid; /* also used for data & command */ SDLCdata format; SDLCdata method; SDLNumber offset; } SnbLinkInfo; typedef struct _elementInfo { unsigned long enum_values; unsigned long num_values; unsigned long str1_values; unsigned long str2_values; enum SdlElement el_type; /* the current element */ SdlOption timing; /* the current timing type */ SdlOption sdl_type; /* dynamic, lined, literal, etc */ SdlOption window; SdlOption interp; union { SDLNumber count; SDLNumber offset; } nums; SDLCdata language; SDLCdata char_set; SDLCdata id; SDLCdata elstr1; SDLCdata elstr2; union { SDLDocInfo doc_info; /* */ SDLIdInfo id_info; /* */ SnbLinkInfo snb_info; /* , , , , */ _DtCvSegment *table_info; /*
*/ SDLEntryInfo entry_info; /* el_info.char_set) #define ElClan(x) ((x)->el_info.match.clan) #define ElCount(x) ((x)->el_info.nums.count) #define ElFlag1(x) ((x)->el_info.enum_values) #define ElFlag2(x) ((x)->el_info.num_values) #define ElFlag3(x) ((x)->el_info.str1_values) #define ElFlag4(x) ((x)->el_info.str2_values) #define ElFrmtType(x) ((x)->el_info.sdl_type) #define ElId(x) ((x)->el_info.id) #define ElInterp(x) ((x)->el_info.interp) #define ElLanguage(x) ((x)->el_info.language) #define ElLevel(x) ((x)->el_info.match.level) #define ElOffset(x) ((x)->el_info.nums.offset) #define ElSsi(x) ((x)->el_info.match.ssi) #define ElTiming(x) ((x)->el_info.timing) #define ElType(x) ((x)->el_info.el_type) #define ElWindow(x) ((x)->el_info.window) #define ElInfoClan(x) ((x)->match.clan) #define ElDocInfo(x) ((x)->el_info.w.doc_info) #define ElEntryInfo(x) ((x)->el_info.w.entry_info) #define ElIdInfo(x) ((x)->el_info.w.id_info) #define ElSnbXid(x) ((x)->el_info.w.snb_info.xid) #define ElSnbFormat(x) ((x)->el_info.w.snb_info.format) #define ElSnbMethod(x) ((x)->el_info.w.snb_info.method) #define ElSwitchBranches(x) ((x)->el_info.elstr1) #define ElTable(x) ((x)->el_info.w.table_info) #define ElTableCellIds(x) \ _DtCvCellIdsOfTableSeg(((x)->el_info.w.table_info)) #define ElTableColNum(x) \ _DtCvNumColsOfTableSeg(((x)->el_info.w.table_info)) #define ElTableColWidths(x) \ _DtCvColWOfTableSeg(((x)->el_info.w.table_info)) #define ElTableColJust(x) \ _DtCvColJustifyOfTableSeg(((x)->el_info.w.table_info)) #define ElTableList(x) \ _DtCvCellsOfTableSeg(((x)->el_info.w.table_info)) #define ElString1(x) ((x)->el_info.elstr1) #define ElString2(x) ((x)->el_info.elstr2) #define ElAbbrev(x) ((x)->el_info.elstr1) #define ElEnter(x) ((x)->el_info.elstr1) #define ElExit(x) ((x)->el_info.elstr2) #define ElSpcName(x) ((x)->el_info.elstr1) #define ElTableCellId(x) ((x)->el_info.elstr1) #define ElTableColJStr(x) ((x)->el_info.elstr1) #define ElTableColWStr(x) ((x)->el_info.elstr2) #define SnbOffset(x) ((x)->offset) #define BMarginOfSeg(x) _DtCvContainerBMarginOfSeg(x) #define TMarginOfSeg(x) _DtCvContainerTMarginOfSeg(x) #define MySaveString(seg_list,my_struct,string,cur_link,multi_len,nl_flag)\ _DtHelpCeSaveString(my_struct->ui_info->client_data, \ seg_list, \ &(my_struct->last_seg), \ &(my_struct->prev_data), \ string, \ my_struct->my_fonts, \ cur_link, \ multi_len, \ my_struct->flags, \ my_struct->ui_info->load_font, \ my_struct->resolve_font, \ nl_flag) #define SDL_WRAPPER _DtCvAPP_FLAG1 #define SetSdlWrapper(x) _DtCvSetAppFlag1(x) #define IsSdlWrapper(x) ((x) & SDL_WRAPPER) #define SetDupFlag(x) \ (FrmtPrivInfoPtr(x)->dup_flag = True) #define ClearDupFlag(x) \ (FrmtPrivInfoPtr(x)->dup_flag = False) #define AbbrevOfSeg(x) ((FrmtPrivInfoPtr(x))->abbrev) #define ContainerPtrToType(x) ((x)->type) #define ContainerPtrToVJustify(x) ((x)->vjustify) #define ContainerPtrToJustify(x) ((x)->justify) #define ClearSegLinks(x) \ (((x)->type) & ~(_DtCvHYPER_TEXT | _DtCvGHOST_LINK)) #define SegMatchData(x) ((FrmtPrivInfoPtr(x))->match_info) #define SegMatchDataPtr(x) ((SdlMatchData *) SegMatchData(x)) /****************************************************************************** * Private Strings *****************************************************************************/ static const char AllStr[] = "all"; static const char AnchorStr[] = " -----------------------------------------------------------------------------*/ #define SDL_ENTITY_SYSTEM_NOTATIONS \ SDLInitMaskTwelve(SdlElementGraphic, \ SdlElementText, \ SdlElementAudio, \ SdlElementVideo, \ SdlElementAnimate, \ SdlElementCrossDoc, \ SdlElementManPage, \ SdlElementTextFile, \ SdlElementSysCmd, \ SdlElementCallback, \ SdlElementScript, \ SdlElementSwitch) /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ #define SDL_ENTITY_GENERATED_ELEMENTS \ { SDLInitMask(SdlElementLoids) , OnlyOne }, \ { SDLInitMask(SdlElementToss) , ZeroOrOne }, \ { SDLInitMask(SdlElementLoPhrases), ZeroOrOne }, \ { SDLInitMask(SdlElementIndex) , ZeroOrOne }, \ { SDLInitMask(SdlElementRelDocs) , ZeroOrOne }, \ { SDLInitMask(SdlElementRelFile) , ZeroOrOne }, \ { SDLInitMask(SdlElementNotes) , ZeroOrOne }, /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ #define SDL_ENTITY_CLASSK \ { "acro" , SdlClassAcro }, \ { "book" , SdlClassBook }, \ { "emph" , SdlClassEmph }, \ { "jargon" , SdlClassJargon }, \ { "l10n" , SdlClassL10n }, \ { NameStr , SdlClassName }, \ { "quote" , SdlClassQuote }, \ { ProductStr , SdlClassProduct }, \ { "termdef" , SdlClassTermdef }, \ { "term" , SdlClassTerm }, \ { "mach-in" , SdlClassMachIn }, \ { "mach-out" , SdlClassMachOut }, \ { "mach-cont", SdlClassMachCont }, \ { "pub-lit" , SdlClassPubLit }, \ { UdefKeyStr , SdlClassUdefkey } /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ #define SDL_ENTITY_CLASSH \ { "label" , SdlClassLabel }, \ { (HeadStr+1) , SdlClassHead }, \ { "caption" , SdlClassCaption }, \ { "annotation", SdlClassAnnotation }, \ { "phead" , SdlClassPHead }, \ { "udefhead" , SdlClassUdefhead } /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ #define SDL_ENTITY_CLASSF \ { "table" , SdlClassTable }, \ { "cell" , SdlClassCell }, \ { "list" , SdlClassList }, \ { "item" , SdlClassItem }, \ { (TextStr+1), SdlClassText }, \ { "udeffrmt" , SdlClassUdeffrmt } /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ #define SDL_ENTITY_CLASSG \ { "figure" , SdlClassFigure }, \ { "in-line" , SdlClassInLine }, \ { ButtonStr , SdlClassButton }, \ { "icon" , SdlClassIcon }, \ { "udefgraph" , SdlClassUdefgraph } /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ #define SDL_ENTITY_CLASSP \ { "super" , SdlClassSuper }, \ { "sub" , SdlClassSub } /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ #define font_stylesAttrList \ { SDL_ATTR_POINTSZ , SdlAttrValueImplied , TenStr }, \ { SDL_ATTR_SETWIDTH , SdlAttrValueImplied , TenStr }, \ { SDL_ATTR_COLOR , SdlAttrValueImpliedDef , NULL }, \ { SDL_ATTR_XLFD , SdlAttrValueImpliedDef , NULL }, \ { SDL_ATTR_XLFDI , SdlAttrValueImpliedDef , NULL }, \ { SDL_ATTR_XLFDB , SdlAttrValueImpliedDef , NULL }, \ { SDL_ATTR_XLFDIB , SdlAttrValueImpliedDef , NULL }, \ { SDL_ATTR_TYPENAM , SdlAttrValueImpliedDef , NULL }, \ { SDL_ATTR_TYPENAMI , SdlAttrValueImpliedDef , NULL }, \ { SDL_ATTR_TYPENAMB , SdlAttrValueImpliedDef , NULL }, \ { SDL_ATTR_TYPENAMIB, SdlAttrValueImpliedDef , NULL }, \ { SDL_ATTR_STYLE , SdlAttrValueImplied , "sans-serif" }, \ { SDL_ATTR_SPACING , SdlAttrValueImplied , "monospace" }, \ { SDL_ATTR_WEIGHT , SdlAttrValueImplied , "medium" }, \ { SDL_ATTR_SLANT , SdlAttrValueImplied , "roman" }, \ { SDL_ATTR_SPECIAL , SdlAttrValueImplied , "none" } /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ #define formt_stylesAttrList \ { SDL_ATTR_LMARGIN , SdlAttrValueImplied , ZeroStr }, \ { SDL_ATTR_RMARGIN , SdlAttrValueImplied , ZeroStr }, \ { SDL_ATTR_TMARGIN , SdlAttrValueImplied , ZeroStr }, \ { SDL_ATTR_BMARGIN , SdlAttrValueImplied , ZeroStr }, \ { SDL_ATTR_BORDER , SdlAttrValueImplied , NoBorderStr }, \ { SDL_ATTR_VJUST , SdlAttrValueImplied , TopVJustStr } /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ #define SDL_ENTITY_SIMPLE \ SDLInitMaskSeven( \ SdlElementKey , SdlElementSphrase, SdlElementRev , \ SdlElementIf , SdlElementSpc , SdlElementSnRef, \ SdlElementCdata) /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ #define SDL_ENTITY_ATOMIC \ SDLInitMaskNine( \ SdlElementKey , SdlElementSphrase, SdlElementRev , \ SdlElementIf , SdlElementSpc , SdlElementSnRef , \ SdlElementAnchor, SdlElementLink , SdlElementCdata) /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ typedef struct _ceInterpData { SdlOption type; char *cmd; } _CEInterpData; static _CEInterpData InterpData[] = { { SdlInterpKsh, "ksh" }, { SdlInterpCsh, "csh" }, { SdlInterpSh , "sh" }, { SdlInterpTcl, "tcl" }, { _DtCvOPTION_BAD, NULL }, }; /****************************************************************************** * Private Variables *****************************************************************************/ static OptionList hclass[] = { SDL_ENTITY_CLASSH, {NULL, _DtCvOPTION_BAD}}; static OptionList fclass[] = { SDL_ENTITY_CLASSF, {NULL, _DtCvOPTION_BAD}}; static OptionList kclass[] = { SDL_ENTITY_CLASSK, {NULL, _DtCvOPTION_BAD}}; static OptionList pclass[] = { SDL_ENTITY_CLASSP, {NULL, _DtCvOPTION_BAD}}; static OptionList gclass[] = { SDL_ENTITY_CLASSG, {NULL, _DtCvOPTION_BAD}}; static OptionList fgclass[] = { SDL_ENTITY_CLASSF, SDL_ENTITY_CLASSG, {NULL, _DtCvOPTION_BAD}}; static OptionList apps[] = { { AllStr , SdlAppAll }, { "help" , SdlAppHelp }, { "tutorial", SdlAppTutorial }, { "ref" , SdlAppRef }, { "sys" , SdlAppSys }, { NULL , _DtCvOPTION_BAD } }; static OptionList timing[] = { { (ASyncStr+1), SdlTimingSync }, { ASyncStr , SdlTimingAsync }, { NULL , _DtCvOPTION_BAD }, }; static OptionList frmtTypes[] = { { "literal" , SdlTypeLiteral }, { "lined" , SdlTypeLined }, { DynamicStr, SdlTypeDynamic }, { NULL , _DtCvOPTION_BAD } }; static OptionList idTypes[] = { { (VirpageStr+1) , SdlIdVirpage }, { (BlockStr+1) , SdlIdBlock }, { (FormStr+1) , SdlIdForm }, { (ParaStr+1) , SdlIdPara }, { (CParaStr+1) , SdlIdCPara }, { (HeadStr+1) , SdlIdHead }, { (SubHeadStr+1) , SdlIdSubHead }, { (AnchorStr+1) , SdlIdAnchor }, { (SwitchStr+1) , SdlIdSwitch }, { (SnrefStr+1) , SdlIdSnRef }, { (GraphicStr+1) , SdlIdGraphic }, { (TextStr+1) , SdlIdText }, { (AudioStr+1) , SdlIdAudio }, { (VideoStr+1) , SdlIdVideo }, { (AnimateStr+1) , SdlIdAnimate }, { (CrossdocStr+1), SdlIdCrossDoc }, { (ManpageStr+1) , SdlIdManPage }, { (TextfileStr+1), SdlIdTextFile }, { (SyscmdStr+1) , SdlIdSysCmd }, { (ScriptStr+1) , SdlIdScript }, { (CallbackStr+1), SdlIdCallback }, { NULL , _DtCvOPTION_BAD }, }; static OptionList bool_types[] = { { "YES", SdlBoolYes }, { "NO" , SdlBoolNo }, { NULL , _DtCvOPTION_BAD }, }; static OptionList borders[] = { { NoBorderStr , _DtCvBORDER_NONE }, { "full-border" , _DtCvBORDER_FULL }, { "horizontal-border", _DtCvBORDER_HORZ }, { "vertical-border" , _DtCvBORDER_VERT }, { "top-border" , _DtCvBORDER_TOP }, { "bottom-border" , _DtCvBORDER_BOTTOM }, { "left-border" , _DtCvBORDER_LEFT }, { "right-border" , _DtCvBORDER_RIGHT }, { NULL , _DtCvOPTION_BAD }, }; static OptionList justify1[] = { { LeftJustifyStr , _DtCvJUSTIFY_LEFT }, { RightJustifyStr , _DtCvJUSTIFY_RIGHT }, { CenterJustifyStr , _DtCvJUSTIFY_CENTER }, { "numeric-justify", _DtCvJUSTIFY_NUM }, { NULL , _DtCvOPTION_BAD }, }; static OptionList justify2[] = { { LeftJustifyStr , _DtCvJUSTIFY_LEFT }, { RightJustifyStr , _DtCvJUSTIFY_RIGHT }, { CenterJustifyStr , _DtCvJUSTIFY_CENTER }, { NULL , _DtCvOPTION_BAD }, }; static OptionList vjust[] = { { TopVJustStr , _DtCvJUSTIFY_TOP }, { "bottom-vjust", _DtCvJUSTIFY_BOTTOM }, { "center-vjust", _DtCvJUSTIFY_CENTER }, { NULL , _DtCvOPTION_BAD }, }; static OptionList orient[] = { { "left-orient" , _DtCvJUSTIFY_LEFT }, { CenterOrientStr , _DtCvJUSTIFY_CENTER }, { "right-orient" , _DtCvJUSTIFY_RIGHT }, { "left-margin-orient" , _DtCvJUSTIFY_LEFT_MARGIN }, { "right-margin-orient", _DtCvJUSTIFY_RIGHT_MARGIN}, { "left-corner-orient" , _DtCvJUSTIFY_LEFT_CORNER }, { "right-corner-orient", _DtCvJUSTIFY_RIGHT_CORNER}, { NULL , _DtCvOPTION_BAD }, }; static OptionList vorient[] = { { TopVOrientStr , _DtCvJUSTIFY_TOP }, { "bottom-vorient", _DtCvJUSTIFY_BOTTOM }, { "center-vorient", _DtCvJUSTIFY_CENTER }, { NULL , _DtCvOPTION_BAD }, }; static OptionList placement[] = { { "object" , SdlPlaceObject }, { ParentStr , SdlPlaceParent }, { NULL , _DtCvOPTION_BAD }, }; static OptionList stacking[] = { { "horiz" , SdlStackHoriz }, { "vert" , SdlStackVert }, { NULL , _DtCvOPTION_BAD }, }; static OptionList flow[] = { { (NoWrapStr+2), _DtCvWRAP }, { NoWrapStr , _DtCvWRAP_NONE }, { "join" , _DtCvWRAP_JOIN }, { NULL , _DtCvOPTION_BAD }, }; static OptionList window[] = { { "current", SdlWindowCurrent }, { "new" , SdlWindowNew }, { "popup" , SdlWindowPopup }, { NULL , _DtCvOPTION_BAD }, }; static OptionList traversal[] = { { "return" , SdlTraversalReturn }, { "noreturn", SdlTraversalNoReturn }, { NULL , _DtCvOPTION_BAD }, }; static OptionList interpreters[] = { { "ksh" , SdlInterpKsh }, { "tcl" , SdlInterpTcl }, { "csh" , SdlInterpCsh }, { "sh" , SdlInterpSh }, { NULL , _DtCvOPTION_BAD }, }; static SDLAttributeOptions SDLOptionsList[] = { {SDL_ATTR_CLASSH , hclass }, {SDL_ATTR_CLASSF , fclass }, {SDL_ATTR_CLASSK , kclass }, {SDL_ATTR_CLASSFG , fgclass }, {SDL_ATTR_CLASSP , pclass }, {SDL_ATTR_CLASSG , gclass }, {SDL_ATTR_HDR , bool_types }, {SDL_ATTR_APP , apps }, {SDL_ATTR_TIMING , timing }, {SDL_ATTR_TYPEFRMT , frmtTypes }, {SDL_ATTR_BORDER , borders }, {SDL_ATTR_JUSTIFY1 , justify1 }, {SDL_ATTR_JUSTIFY2 , justify2 }, {SDL_ATTR_VJUST , vjust }, {SDL_ATTR_ORIENT , orient }, {SDL_ATTR_VORIENT , vorient }, {SDL_ATTR_PLACEMENT, placement }, {SDL_ATTR_STACK , stacking }, {SDL_ATTR_FLOW , flow }, {SDL_ATTR_WINDOW , window }, {SDL_ATTR_TRAVERSAL, traversal }, {SDL_ATTR_TYPEID , idTypes }, {SDL_ATTR_INTERP , interpreters }, {(unsigned long) -1, NULL } }; static FontSpecOption styles[] = { { "serif" , _DtHelpFontStyleSerif }, { "sans-serif", _DtHelpFontStyleSanSerif }, { "symbol" , _DtHelpFontStyleSymbol }, { NULL , _DtHelpFontValueBad }, }; static FontSpecOption spacing[] = { { "monospace" , _DtHelpFontSpacingMono}, { "propspace" , _DtHelpFontSpacingProp}, { NULL , _DtHelpFontValueBad }, }; static FontSpecOption weights[] = { { "medium" , _DtHelpFontWeightMedium }, { "bold" , _DtHelpFontWeightBold }, { NULL , _DtHelpFontValueBad }, }; static FontSpecOption slants[] = { { "roman" , _DtHelpFontSlantRoman }, { "italic" , _DtHelpFontSlantItalic }, { "rev-italic", _DtHelpFontSlantRevItalic}, { NULL , _DtHelpFontValueBad }, }; static FontSpecOption special[] = { { "none" , _DtHelpFontSpecialNone }, { "underline" , _DtHelpFontSpecialUnderLine }, { "strikeout" , _DtHelpFontSpecialStrikeOut }, { NULL , _DtHelpFontValueBad }, }; static SDLFontSpecList SDLFontList[] = { {SDL_ATTR_STYLE , styles }, {SDL_ATTR_SPACING , spacing }, {SDL_ATTR_WEIGHT , weights }, {SDL_ATTR_SLANT , slants }, {SDL_ATTR_SPECIAL , special }, {(unsigned long) -1, NULL } }; /* * Make sure the attribute names are in lower case. * The read routine to find an attribute automatically changes it to lower * case. */ #ifndef _DtCvContainerPtr typedef _DtCvContainer * _DtCvContainerPtr; #endif #ifndef _DtCvSegmentPtr typedef _DtCvSegment * _DtCvSegmentPtr; #endif static SDLAttribute SDLAttributeList[] = { { "abbrev" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_ABBREV , SDLAttrOffset(ElementInfoPtr,elstr1) }, { "app" , SdlAttrDataTypeEnum , SdlIgnore , SDL_ATTR_APP , 0 }, { "author" , SdlAttrDataTypeCdata , SdlIgnore , SDL_ATTR_AUTHOR , 0 }, { "b-margin" , SdlAttrDataTypeNumber, SdlContainerSpecific , SDL_ATTR_BMARGIN, SDLAttrOffset(_DtCvContainerPtr,bmargin) }, { "border" , SdlAttrDataTypeEnum , SdlContainerSpecific , SDL_ATTR_BORDER, SDLAttrOffset(_DtCvContainerPtr,border) }, { "branches" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_BRANCHES , SDLAttrOffset(ElementInfoPtr,elstr1) }, { ButtonStr , SdlAttrDataTypeId , SdlIgnore , SDL_ATTR_BUTTON, 0 }, { "cells" , SdlAttrDataTypeId , SdlElementSpecific, SDL_ATTR_CELLS, SDLAttrOffset(ElementInfoPtr,elstr1) }, { "charset" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_CHARSET, SDLAttrOffset(ElementInfoPtr,char_set) }, { "class" , SdlAttrDataTypeEnum , SdlElementSpecific, SDL_ATTR_CLASS , SDLAttrOffset(ElementInfoPtr,match.clan) }, { "colj" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_COLJ , SDLAttrOffset(ElementInfoPtr,elstr1) }, { "color" , SdlAttrDataTypeCdata , SdlFontSpecific, SDL_ATTR_COLOR , SDLAttrOffset(_DtHelpFontHintPtr,color) }, { "colw" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_COLW , SDLAttrOffset(ElementInfoPtr,elstr2) }, { "command" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_COMMAND , SDLAttrOffset(ElementInfoPtr,w.snb_info.xid) }, { "count" , SdlAttrDataTypeNumber, SdlElementSpecific, SDL_ATTR_COUNT , SDLAttrOffset(ElementInfoPtr,nums.count) }, { "data" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_DATA , SDLAttrOffset(ElementInfoPtr,w.snb_info.xid) }, { "descript" , SdlAttrDataTypeCdata , SdlIgnore , SDL_ATTR_DESCRIPT, 0 }, { "doc-id" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_DOCID , SDLAttrOffset(ElementInfoPtr,w.doc_info.doc_id) }, { "enter" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_ENTER , SDLAttrOffset(ElementInfoPtr,elstr1) }, { "exit" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_EXIT , SDLAttrOffset(ElementInfoPtr,elstr2) }, { "first-page" , SdlAttrDataTypeId , SdlElementSpecific, SDL_ATTR_FRST_PG, SDLAttrOffset(ElementInfoPtr,w.doc_info.first_pg) }, { "flow" , SdlAttrDataTypeEnum , SdlContainerSpecific , SDL_ATTR_FLOW , SDLAttrOffset(_DtCvContainerPtr,flow) }, { "f-margin" , SdlAttrDataTypeNumber, SdlContainerSpecific , SDL_ATTR_FMARGIN, SDLAttrOffset(_DtCvContainerPtr,fmargin) }, { "format" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_FORMAT , SDLAttrOffset(ElementInfoPtr,w.snb_info.format) }, { "hdr" , SdlAttrDataTypeEnum , SdlIgnore , SDL_ATTR_HDR , 0 }, { "headw" , SdlAttrDataTypeNumber , SdlContainerSpecific , SDL_ATTR_HEADWDTH, SDLAttrOffset(_DtCvContainerPtr,percent) }, { "id" , SdlAttrDataTypeId , SdlElementSpecific, SDL_ATTR_ID , SDLAttrOffset(ElementInfoPtr,id) }, { "interp" , SdlAttrDataTypeEnum , SdlElementSpecific, SDL_ATTR_INTERP , SDLAttrOffset(ElementInfoPtr,interp) }, { "justify" , SdlAttrDataTypeEnum , SdlContainerSpecific , SDL_ATTR_JUSTIFY, SDLAttrOffset(_DtCvContainerPtr,justify) }, { "l-margin" , SdlAttrDataTypeNumber, SdlContainerSpecific , SDL_ATTR_LMARGIN, SDLAttrOffset(_DtCvContainerPtr,lmargin) }, { "language" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_LANGUAGE , SDLAttrOffset(ElementInfoPtr,language) }, { "length" , SdlAttrDataTypeNumber, SdlIgnore , SDL_ATTR_LENGTH , 0 }, { "level" , SdlAttrDataTypeNumber, SdlElementSpecific, SDL_ATTR_LEVEL , SDLAttrOffset(ElementInfoPtr,match.level) }, { "license" , SdlAttrDataTypeCdata , SdlIgnore , SDL_ATTR_LICENSE , 0 }, { "linkinfo" , SdlAttrDataTypeCdata , SdlIgnore , SDL_ATTR_LINKINFO, 0 }, { "locs" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_LOCS , SDLAttrOffset(ElementInfoPtr,w.entry_info.locs) }, { "main" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_MAIN , SDLAttrOffset(ElementInfoPtr,w.entry_info.main) }, { "method" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_METHOD , SDLAttrOffset(ElementInfoPtr,w.snb_info.method) }, { NameStr , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_NAME , SDLAttrOffset(ElementInfoPtr,elstr1) }, { "ncols" , SdlAttrDataTypeNumber, SdlTableSpecific, SDL_ATTR_NCOLS , SDLAttrOffset(_DtCvSegmentPtr, handle.table.num_cols) }, { "offset" , SdlAttrDataTypeNumber, SdlElementSpecific, SDL_ATTR_OFFSET , SDLAttrOffset(ElementInfoPtr,nums.offset) }, {(TopVOrientStr+5), SdlAttrDataTypeEnum , SdlContainerSpecific , SDL_ATTR_ORIENT , SDLAttrOffset(_DtCvContainerPtr,orient) }, { "placement" , SdlAttrDataTypeEnum , SdlIgnore , SDL_ATTR_PLACEMENT, 0 }, { "phrase" , SdlAttrDataTypeCdata , SdlIgnore , SDL_ATTR_PHRASE , 0 }, { "pointsz" , SdlAttrDataTypeNumber, SdlFontSpecific, SDL_ATTR_POINTSZ , SDLAttrOffset(_DtHelpFontHintPtr,pointsz) }, { "pub-id" , SdlAttrDataTypeCdata , SdlIgnore , SDL_ATTR_PUBID , 0 }, { "prodpn" , SdlAttrDataTypeCdata , SdlIgnore , SDL_ATTR_PRODPN , 0 }, { ProductStr , SdlAttrDataTypeCdata , SdlIgnore , SDL_ATTR_PRODUCT, 0 }, { "prodver" , SdlAttrDataTypeCdata , SdlIgnore , SDL_ATTR_PRODVER, 0 }, { "r-margin" , SdlAttrDataTypeNumber, SdlContainerSpecific , SDL_ATTR_RMARGIN, SDLAttrOffset(_DtCvContainerPtr,rmargin) }, { "rid" , SdlAttrDataTypeId , SdlElementSpecific , SDL_ATTR_RID , SDLAttrOffset(ElementInfoPtr,id) }, { "rlevel" , SdlAttrDataTypeNumber, SdlElementSpecific, SDL_ATTR_RLEVEL , SDLAttrOffset(ElementInfoPtr,match.level) }, { "rssi" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_RSSI , SDLAttrOffset(ElementInfoPtr,match.ssi) }, { "sdldtd" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_SDLDTD , SDLAttrOffset(ElementInfoPtr,w.doc_info.sdldtd) }, { "set-width" , SdlAttrDataTypeNumber, SdlFontSpecific, SDL_ATTR_SETWIDTH, SDLAttrOffset(_DtHelpFontHintPtr,set_width)}, { "slant" , SdlAttrDataTypeFont , SdlFontSpecific , SDL_ATTR_SLANT, SDLAttrOffset(_DtHelpFontHintPtr,slant) }, { "sort" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_SORT , SDLAttrOffset(ElementInfoPtr,w.entry_info.sort) }, { "spacing" , SdlAttrDataTypeFont , SdlFontSpecific , SDL_ATTR_SPACING, SDLAttrOffset(_DtHelpFontHintPtr,spacing) }, { "special" , SdlAttrDataTypeFont , SdlFontSpecific , SDL_ATTR_SPECIAL, SDLAttrOffset(_DtHelpFontHintPtr,special) }, { "srcdtd" , SdlAttrDataTypeCdata , SdlIgnore , SDL_ATTR_SRCDTD , 0 }, { "srch-wt" , SdlAttrDataTypeNumber, SdlIgnore , SDL_ATTR_SRCHWT , 0 }, { "ssi" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_SSI , SDLAttrOffset(ElementInfoPtr,match.ssi) }, { "stack" , SdlAttrDataTypeEnum , SdlIgnore , SDL_ATTR_STACK, 0 }, { "style" , SdlAttrDataTypeFont , SdlFontSpecific , SDL_ATTR_STYLE, SDLAttrOffset(_DtHelpFontHintPtr,style) }, { "syns" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_SYNS , SDLAttrOffset(ElementInfoPtr,w.entry_info.syns) }, { "t-margin" , SdlAttrDataTypeNumber, SdlContainerSpecific , SDL_ATTR_TMARGIN, SDLAttrOffset(_DtCvContainerPtr,tmargin) }, { (TextStr+1) , SdlAttrDataTypeCdata , SdlIgnore, SDL_ATTR_TEXT , 0 }, { "timestmp" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_TIMESTAMP, SDLAttrOffset(ElementInfoPtr,w.doc_info.timestamp) }, { "timing" , SdlAttrDataTypeEnum , SdlElementSpecific, SDL_ATTR_TIMING , SDLAttrOffset(ElementInfoPtr,timing) }, { "type" , SdlAttrDataTypeEnum , SdlElementSpecific, SDL_ATTR_TYPE , SDLAttrOffset(ElementInfoPtr,sdl_type) }, { "traversal" , SdlAttrDataTypeEnum , SdlIgnore , SDL_ATTR_TRAVERSAL, 0 }, { "typenam" , SdlAttrDataTypeCdata , SdlFontSpecific , SDL_ATTR_TYPENAM, SDLAttrOffset(_DtHelpFontHintPtr,typenam) }, { "typenamb" , SdlAttrDataTypeCdata , SdlFontSpecific , SDL_ATTR_TYPENAMB, SDLAttrOffset(_DtHelpFontHintPtr,typenamb) }, { "typenami" , SdlAttrDataTypeCdata , SdlFontSpecific , SDL_ATTR_TYPENAMI, SDLAttrOffset(_DtHelpFontHintPtr,typenami) }, { "typenamib" , SdlAttrDataTypeCdata , SdlFontSpecific , SDL_ATTR_TYPENAMIB, SDLAttrOffset(_DtHelpFontHintPtr,typenamib) }, { "version" , SdlAttrDataTypeCdata , SdlIgnore , SDL_ATTR_VERSION, 0 }, {(TopVJustStr+4) , SdlAttrDataTypeEnum , SdlContainerSpecific , SDL_ATTR_VJUST, SDLAttrOffset(_DtCvContainerPtr,vjustify) }, {(TopVOrientStr+4), SdlAttrDataTypeEnum , SdlContainerSpecific , SDL_ATTR_VORIENT , SDLAttrOffset(_DtCvContainerPtr,vorient) }, { "weight" , SdlAttrDataTypeFont , SdlFontSpecific , SDL_ATTR_WEIGHT, SDLAttrOffset(_DtHelpFontHintPtr,weight) }, { "window" , SdlAttrDataTypeEnum , SdlElementSpecific, SDL_ATTR_WINDOW, SDLAttrOffset(ElementInfoPtr,window) }, { "xid" , SdlAttrDataTypeCdata , SdlElementSpecific, SDL_ATTR_XID , SDLAttrOffset(ElementInfoPtr,w.snb_info.xid) }, { "xlfd" , SdlAttrDataTypeCdata , SdlFontSpecific , SDL_ATTR_XLFD , SDLAttrOffset(_DtHelpFontHintPtr,xlfd) }, { "xlfdb" , SdlAttrDataTypeCdata , SdlFontSpecific , SDL_ATTR_XLFDB , SDLAttrOffset(_DtHelpFontHintPtr,xlfdb) }, { "xlfdi" , SdlAttrDataTypeCdata , SdlFontSpecific , SDL_ATTR_XLFDI , SDLAttrOffset(_DtHelpFontHintPtr,xlfdi) }, { "xlfdib" , SdlAttrDataTypeCdata , SdlFontSpecific , SDL_ATTR_XLFDIB , SDLAttrOffset(_DtHelpFontHintPtr,xlfdib) }, { 0 , SdlAttrDataTypeInvalid, -1, 0 }, }; /****************************************************************************** * Element Content *****************************************************************************/ /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent SdlDocContent[] = { /* { SDLInitMask(SdlElementVStruct), OnlyOne }, * Do not want to parse the entire document. * Want to only read enought to work with. */ { SDLInitMask(SdlElementSdlDoc) , FakeEnd }, { SDLInitMask(SdlElementSdlDoc) , CopyDocInfo }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList SdlDocAttrList[] = { { SDL_ATTR_PUBID , SdlAttrValueRequired, NULL }, { SDL_ATTR_DOCID , SdlAttrValueRequired, NULL }, { SDL_ATTR_TIMESTAMP, SdlAttrValueRequired, NULL }, { SDL_ATTR_PRODUCT , SdlAttrValueImplied , NULL }, { SDL_ATTR_PRODPN , SdlAttrValueImplied , NULL }, { SDL_ATTR_PRODVER , SdlAttrValueImplied , NULL }, { SDL_ATTR_LICENSE , SdlAttrValueImplied , NULL }, { SDL_ATTR_LANGUAGE , SdlAttrValueImplied , "C" }, { SDL_ATTR_CHARSET , SdlAttrValueImplied , "UTF-8"}, { SDL_ATTR_AUTHOR , SdlAttrValueImplied , NULL }, { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL }, { SDL_ATTR_FRST_PG , SdlAttrValueImplied , NULL }, { SDL_ATTR_SDLDTD , SdlAttrValueRequired, NULL }, { SDL_ATTR_SRCDTD , SdlAttrValueImplied , NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent VStructContent[] = { SDL_ENTITY_GENERATED_ELEMENTS { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList VStructAttrList[] = { { SDL_ATTR_DOCID , SdlAttrValueImplied , NULL }, { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent VirpageContent[] = { { SDLInitMask(SdlElementHead) , SetSaveSnref }, { SDLInitMask(SdlElementHead) , ZeroToN }, { SDLInitMask(SdlElementSnb) , ZeroOrOne }, { SDLInitMask(SdlElementHead) , ClearAndCheckSnref}, { SDLInitMaskTwo(SdlElementBlock, \ SdlElementForm), ZeroToN }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLContent VirpageHeadContent[] = { { SDLInitMask(SdlElementHead) , SetSaveSnref}, { SDLInitMask(SdlElementHead) , ZeroToN }, { SDLInitMask(SdlElementVirpage) , CheckForSnb }, { SDLInitMask(SdlElementTitle) , FakeEnd }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLContent HeadAndSnb[] = { { SDLInitMask(SdlElementHead) , SetSaveSnref}, { SDLInitMask(SdlElementHead) , ZeroToN }, { SDLInitMask(SdlElementHead) , CheckForSnb }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList VirpageAttrList[] = { { SDL_ATTR_ID , SdlAttrValueRequired , NULL }, { SDL_ATTR_LEVEL , SdlAttrValueRequired , NULL }, { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL }, { SDL_ATTR_LANGUAGE, SdlAttrValueImplied , NULL }, { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL }, { SDL_ATTR_DOCID , SdlAttrValueRequired , NULL }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent SnbContent[] = { { SDLInitMask(SdlElementHead) , ZeroOrOne }, { SDL_ENTITY_SYSTEM_NOTATIONS , OneToN }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList SnbAttrList[] = { { SDL_ATTR_VERSION, SdlAttrValueImplied , NULL }, { -1 ,SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent BlockContent[] = { { SDLInitMask(SdlElementBlock) , SetTransit}, { SDLInitMask(SdlElementHead) , ZeroToN }, { SDLInitMaskTwo(SdlElementPara, SdlElementCPara), ZeroToN }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList BlockAttrList[] = { { SDL_ATTR_ID , SdlAttrValueImpliedDef , NULL }, { SDL_ATTR_LEVEL , SdlAttrValueImpliedDef , OneStr }, { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL }, { SDL_ATTR_CLASSF , SdlAttrValueImplied , (TextStr+1) }, { SDL_ATTR_LANGUAGE, SdlAttrValueImplied , NULL }, { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL }, { SDL_ATTR_LENGTH , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_APP , SdlAttrValueImplied , AllStr }, { SDL_ATTR_TIMING , SdlAttrValueImplied , (ASyncStr+1) }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef , NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent FormContent[] = { { SDLInitMask(SdlElementHead) , ZeroToN }, { SDLInitMaskTwo(SdlElementFstyle, SdlElementFdata), OnlyOneEach }, { SDLInitMask(SdlElementForm) , ColInfoToTableInfo }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList FormAttrList[] = { { SDL_ATTR_ID , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_LEVEL , SdlAttrValueImplied , OneStr }, { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL }, { SDL_ATTR_CLASSF , SdlAttrValueImplied , (TextStr+1) }, { SDL_ATTR_LANGUAGE, SdlAttrValueImplied , NULL }, { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL }, { SDL_ATTR_LENGTH , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_APP , SdlAttrValueImplied , AllStr }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { -1 ,SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent FstyleContent[] = { { SDLInitMask(SdlElementFrowvec), OneToN }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList FstyleAttrList[] = { { SDL_ATTR_NCOLS , SdlAttrValueImpliedDef , OneStr }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent FrowvecContent[] = { { SDLInitMask(SdlElementFrowvec), AddRowToTable}, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList FrowvecAttrList[] = { { SDL_ATTR_HDR , SdlAttrValueImplied , "NO" }, { SDL_ATTR_CELLS , SdlAttrValueRequired, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent FdataContent[] = { { SDLInitMaskTwo(SdlElementBlock, SdlElementForm), ZeroToN }, { SDLInitMask(SdlElementNone) , NULL }, }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent ParaContent[] = { /* * This is optional and followed by potential PCDATA, therefore include * the SdlElementCdata & SdlPcDataFollows flag. */ { SDLInitMaskThree(SdlElementHead, SdlPcDataFollows, SdlElementCdata), ZeroToN }, { SDLInitMask(SdlElementPara), InitLast }, /* * PCDATA is described as 0 to n characters, * therefore, while the content says 'one to n' of (%atomic | #PCDATA) * we need to specify ZeroToN to work for PCDATA { SDL_ENTITY_ATOMIC , OneToN }, */ { SDL_ENTITY_ATOMIC , ZeroToN }, { SDLInitMask(SdlElementNone), NULL }, }; static SDLElementAttrList ParaAttrList[] = { { SDL_ATTR_ID , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL }, { SDL_ATTR_TYPEFRMT, SdlAttrValueImplied , DynamicStr}, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent CParaContent[] = { { SDLInitMask(SdlElementCPara), InitLast }, { SDLInitMask(SdlElementCdata), ZeroOrOne }, { SDLInitMask(SdlElementNone) , NULL }, }; /* uses the same attributes as

*/ /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent HeadContent[] = { { SDLInitMask(SdlElementHead) , InitLast }, { SDL_ENTITY_ATOMIC , ZeroToN }, { SDLInitMask(SdlElementSubHead), ZeroToN }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLContent SubHeadContent[] = { { SDLInitMask(SdlElementSubHead), InitLast }, { SDL_ENTITY_ATOMIC , ZeroToN }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList HeadAttrList[] = { { SDL_ATTR_ID , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL }, { SDL_ATTR_CLASSH , SdlAttrValueImplied , (HeadStr+1)}, { SDL_ATTR_LANGUAGE, SdlAttrValueImplied , NULL }, { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL }, { SDL_ATTR_TYPEFRMT, SdlAttrValueImplied , DynamicStr }, { SDL_ATTR_ABBREV , SdlAttrValueImplied , NULL }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLElementAttrList AnchorAttrList[] = { { SDL_ATTR_ID , SdlAttrValueRequired, NULL }, { -1 , SdlAttrValueBad , NULL } }; static SDLContent AnchorContent[] = { { SDLInitMask(SdlElementAnchor) , CopyAnchorId }, { SDLInitMask(SdlElementNone) , NULL }, }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent LinkContent[] = { { SDLInitMask(SdlElementLink) , RegisterLink }, /* * PCDATA is described as 0 to n characters, * therefore, while the content says 'one to n' of (%atomic | #PCDATA) * we need to specify ZeroToN to work for PCDATA { SDL_ENTITY_ATOMIC , OneToN }, */ { SDL_ENTITY_ATOMIC , ZeroToN }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList LinkAttrList[] = { { SDL_ATTR_RID , SdlAttrValueRequired , NULL }, { SDL_ATTR_BUTTON , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_WINDOW , SdlAttrValueImplied , "current" }, { SDL_ATTR_TRAVERSAL, SdlAttrValueImplied , "noreturn"}, { SDL_ATTR_DESCRIPT , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_LINKINFO , SdlAttrValueImpliedDef, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent SnrefContent[] = { { SDLInitMask(SdlElementSnRef) , MarkFound }, { SDLInitMask(SdlElementRefItem), OneToN }, { SDLInitMask(SdlElementAltText), ZeroOrOne }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList SnrefAttrList[] = { { SDL_ATTR_ID, SdlAttrValueImpliedDef, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent RefItemContent[] = { { SDLInitMask(SdlElementHead) , ZeroOrOne }, { SDLInitMask(SdlElementRefItem) , SaveItemInfo }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList RefItemAttrList[] = { { SDL_ATTR_RID , SdlAttrValueRequired , NULL }, { SDL_ATTR_CLASSFG, SdlAttrValueRequired , NULL }, { SDL_ATTR_BUTTON , SdlAttrValueImplied , NULL }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent AltTextContent[] = { { SDLInitMask(SdlElementCdata), ZeroOrOne }, { SDLInitMask(SdlElementNone) , NULL }, }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent RevContent[] = { { SDL_ENTITY_ATOMIC , ZeroToN }, { SDLInitMask(SdlElementNone), NULL }, }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent KeyContent[] = { { SDLInitMask(SdlElementKey) , ProcessEnterAttr }, { SDL_ENTITY_ATOMIC , ZeroToN }, { SDLInitMask(SdlElementKey) , ProcessExitAttr }, { SDLInitMask(SdlElementNone), NULL }, }; static SDLElementAttrList KeyAttrList[] = { { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL }, { SDL_ATTR_CLASSK , SdlAttrValueRequired , NULL }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent SphraseContent[] = { { SDLInitMask(SdlElementSphrase), CheckType }, { SDLInitMaskTwo(SdlElementSpc, SdlElementCdata), ZeroToN }, { SDLInitMask(SdlElementSphrase), SetType }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList SphraseAttrList[] = { { SDL_ATTR_CLASSP , SdlAttrValueRequired , NULL }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent IfContent[] = { { SDLInitMask(SdlElementIf) , IfInfo }, { SDLInitMask(SdlElementCond), OnlyOne }, { SDLInitMask(SdlElementThen), OnlyOne }, { SDLInitMask(SdlElementElse), ZeroOrOne }, { SDLInitMask(SdlElementNone), NULL }, }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent CondContent[] = { { SDLInitMask(SdlElementCond) , SetType }, { SDLInitMask(SdlElementCdata), ZeroOrOne }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList CondAttrList[] = { { SDL_ATTR_INTERP , SdlAttrValueImplied , "ksh" }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent ThenElseContent[] = { { SDLInitMask(SdlElementIf) , IfInfo }, { SDL_ENTITY_ATOMIC , ZeroToN }, { SDLInitMask(SdlElementNone), NULL }, }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent SpcContent[] = { { SDLInitMask(SdlElementSpc) , ResolveSpcInfo }, { SDLInitMask(SdlElementNone), NULL }, }; static SDLElementAttrList SpcAttrList[] = { { SDL_ATTR_NAME, SdlAttrValueRequired, NULL }, { -1 ,SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent GraphicContent[] = { { SDLInitMask(SdlElementGraphic), LoadGraphic }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList NotationAttrList[] = { { SDL_ATTR_ID , SdlAttrValueRequired, NULL }, { SDL_ATTR_FORMAT, SdlAttrValueImplied , NULL }, { SDL_ATTR_METHOD, SdlAttrValueImplied , NULL }, { SDL_ATTR_XID , SdlAttrValueRequired, NULL }, { -1 ,SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent TextContent[] = { { SDLInitMask(SdlElementText) , SaveLangCharSet }, { SDLInitMaskTwo(SdlElementPara, SdlElementCPara), ZeroToN }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList TextAttrList[] = { { SDL_ATTR_ID , SdlAttrValueRequired, NULL }, { SDL_ATTR_LANGUAGE, SdlAttrValueImplied , NULL }, { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- /---- /- The audio, video, and animate use the NotationAttrList /- structure defined under graphic. /--- -----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent ScriptContent[] = { { SDLInitMask(SdlElementScript) , SetType }, { SDLInitMask(SdlElementCdata) , ZeroOrOne }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList ScriptAttrList[] = { { SDL_ATTR_ID , SdlAttrValueRequired, NULL }, { SDL_ATTR_INTERP , SdlAttrValueImplied , "ksh" }, { -1 ,SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent CrossDocContent[] = { { SDLInitMask(SdlElementCrossDoc) , RegisterSnbLink }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLContent ManPageContent[] = { { SDLInitMask(SdlElementManPage) , RegisterSnbLink }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList IdAndXidAttrList[] = { { SDL_ATTR_ID , SdlAttrValueRequired, NULL }, { SDL_ATTR_XID , SdlAttrValueRequired, NULL }, { -1 ,SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent TextFileContent[] = { { SDLInitMask(SdlElementTextFile) , RegisterSnbLink }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList TextFileAttrList[] = { { SDL_ATTR_ID , SdlAttrValueRequired, NULL }, { SDL_ATTR_XID , SdlAttrValueRequired, NULL }, { SDL_ATTR_OFFSET , SdlAttrValueImplied , ZeroStr }, { SDL_ATTR_FORMAT , SdlAttrValueImplied , NULL }, { -1 ,SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent SysCmdContent[] = { { SDLInitMask(SdlElementSysCmd) , RegisterSnbLink }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList SysCmdAttrList[] = { { SDL_ATTR_ID , SdlAttrValueRequired, NULL }, { SDL_ATTR_COMMAND , SdlAttrValueRequired, NULL }, { -1 ,SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent CallbackContent[] = { { SDLInitMask(SdlElementCallback) , RegisterSnbLink }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList CallbackAttrList[] = { { SDL_ATTR_ID , SdlAttrValueRequired, NULL }, { SDL_ATTR_DATA , SdlAttrValueImplied , NULL }, { -1 ,SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent SwitchContent[] = { { SDLInitMask(SdlElementSwitch), SetType }, { SDLInitMask(SdlElementCdata) , ZeroOrOne }, { SDLInitMask(SdlElementSwitch), RegisterSwitch }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList SwitchAttrList[] = { { SDL_ATTR_ID , SdlAttrValueRequired, NULL }, { SDL_ATTR_INTERP , SdlAttrValueImplied , "ksh" }, { SDL_ATTR_BRANCHES , SdlAttrValueRequired, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent LoidsContent[] = { { SDLInitMask(SdlElementLoids), AllocateBlock }, { SDLInitMask(SdlElementId) , ZeroToN }, { SDLInitMask(SdlElementLoids), CleanUpBlock }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList LoidsAttrList[] = { { SDL_ATTR_COUNT, SdlAttrValueImplied, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent IdContent[] = { { SDLInitMask(SdlElementId) , CopyIdInfo }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList IdAttrList[] = { { SDL_ATTR_TYPEID , SdlAttrValueRequired, NULL }, { SDL_ATTR_RID , SdlAttrValueRequired, NULL }, { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_RSSI , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_OFFSET , SdlAttrValueRequired, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent IndexContent[] = { { SDLInitMask(SdlElementEntry), ZeroToN }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList IndexAttrList[] = { { SDL_ATTR_COUNT, SdlAttrValueImplied, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent EntryContent[] = { { SDLInitMask(SdlElementEntry), CopyEntryInfo }, { SDL_ENTITY_SIMPLE , ZeroToN }, { SDLInitMask(SdlElementEntry), ZeroToN }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList EntryAttrList[] = { { SDL_ATTR_ID ,SdlAttrValueImpliedDef , NULL }, { SDL_ATTR_MAIN ,SdlAttrValueImpliedDef , NULL }, { SDL_ATTR_LOCS ,SdlAttrValueImpliedDef , NULL }, { SDL_ATTR_SYNS ,SdlAttrValueImpliedDef , NULL }, { SDL_ATTR_SORT ,SdlAttrValueImpliedDef , NULL }, { -1 ,SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent LoPhraseContent[] = { { SDLInitMask(SdlElementPhrase) , OneToN }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList LoPhraseAttrList[] = { { SDL_ATTR_COUNT, SdlAttrValueImplied, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLElementAttrList PhraseAttrList[] = { { SDL_ATTR_TEXT , SdlAttrValueRequired, NULL }, { -1 ,SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent TossContent[] = { { SDLInitMask(SdlElementToss) , AllocateBlock }, { SDLInitMask(SdlElementKeyStyle) , ZeroToN }, { SDLInitMask(SdlElementHeadStyle), ZeroToN }, { SDLInitMask(SdlElementFormStyle), ZeroToN }, { SDLInitMask(SdlElementFrmtStyle), ZeroToN }, { SDLInitMask(SdlElementGrphStyle), ZeroToN }, { SDLInitMask(SdlElementToss) , CleanUpBlock }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList TossAttrList[] = { { SDL_ATTR_COUNT, SdlAttrValueImplied, NULL }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent KeyStyleContent[] = { { SDLInitMask(SdlElementKeyStyle) , CopyTossInfo }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList KeyStyleAttrList[] = { { SDL_ATTR_CLASSK , SdlAttrValueRequired , NULL }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_PHRASE , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_SRCHWT , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_ENTER , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_EXIT , SdlAttrValueImpliedDef, NULL }, font_stylesAttrList, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent HeadStyleContent[] = { { SDLInitMask(SdlElementHeadStyle), CopyTossInfo }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList HeadStyleAttrList[] = { { SDL_ATTR_CLASSH , SdlAttrValueRequired , NULL }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_PHRASE , SdlAttrValueImplied , NULL }, { SDL_ATTR_SRCHWT , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_ORIENT , SdlAttrValueImplied , CenterOrientStr}, { SDL_ATTR_VORIENT , SdlAttrValueImplied , TopVOrientStr }, { SDL_ATTR_HEADWDTH , SdlAttrValueImplied , TenThousandStr }, { SDL_ATTR_PLACEMENT, SdlAttrValueImpliedDef, ParentStr }, { SDL_ATTR_STACK , SdlAttrValueImpliedDef, "vert" }, { SDL_ATTR_FLOW , SdlAttrValueImplied , NoWrapStr }, font_stylesAttrList , formt_stylesAttrList, { SDL_ATTR_JUSTIFY1 , SdlAttrValueImplied , LeftJustifyStr }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent FormStyleContent[] = { { SDLInitMask(SdlElementFormStyle), CopyTossInfo }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList FormStyleAttrList[] = { { SDL_ATTR_CLASSF , SdlAttrValueRequired , NULL }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_PHRASE , SdlAttrValueImplied , NULL }, { SDL_ATTR_SRCHWT , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_COLW , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_COLJ , SdlAttrValueImpliedDef, NULL }, font_stylesAttrList, formt_stylesAttrList, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ static SDLContent FrmtStyleContent[] = { { SDLInitMask(SdlElementFrmtStyle), CopyTossInfo }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList FrmtStyleAttrList[] = { { SDL_ATTR_CLASSF , SdlAttrValueRequired , NULL }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_PHRASE , SdlAttrValueImplied , NULL }, { SDL_ATTR_SRCHWT , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_FMARGIN , SdlAttrValueImplied , ZeroStr }, font_stylesAttrList , formt_stylesAttrList, { SDL_ATTR_JUSTIFY1 , SdlAttrValueImplied , LeftJustifyStr }, { -1 , SdlAttrValueBad , NULL } }; /*----------------------------------------------------------------------------- ] > -----------------------------------------------------------------------------*/ static SDLContent GrphStyleContent[] = { { SDLInitMask(SdlElementGrphStyle), CopyTossInfo }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLElementAttrList GrphStyleAttrList[] = { { SDL_ATTR_CLASSG , SdlAttrValueRequired , NULL }, { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL }, { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr }, { SDL_ATTR_PHRASE , SdlAttrValueImplied , NULL }, formt_stylesAttrList, { SDL_ATTR_JUSTIFY2 , SdlAttrValueImplied , LeftJustifyStr }, { -1 , SdlAttrValueBad , NULL } }; static SDLContent CdataContent[] = { { SDLInitMask(SdlElementCdata), Cdata }, { SDLInitMask(SdlElementNone) , NULL }, }; static SDLContent SDLDocumentContent[] = { { SDLInitMask(SdlElementSgml) , ZeroOrOne }, { SDLInitMask(SdlElementDocType), ZeroOrOne }, { SDLInitMask(SdlElementSdlDoc) , OnlyOne }, { SDLInitMask(SdlElementNone) , NULL }, }; /* * entries in this structure: * all 'element strings' must start with '<' * all 'element end strings' must start with '", 4, 4, SdlElementSphrase , SDLInitMask(SdlElementNone), SphraseAttrList , SphraseContent , False, True , False , True , SdlToContainer }, { SubHeadStr , " 1) \ { \ myMask = myMask >> 1; y++; \ } \ myI = SDL_MASK_LEN; \ } \ } #define ClearAttrFlag(pa, attr) \ { \ int mask = attr & VALUE_MASK; \ int flag = ~(attr & (~VALUE_MASK)); \ \ if (mask == ENUM_VALUE) \ (pa).enum_values = (pa).enum_values & flag; \ else if (mask == NUMBER_VALUE) \ (pa).num_values = (pa).num_values & flag; \ else if (mask == STRING1_VALUE) \ (pa).str1_values = (pa).str1_values & flag; \ else if (mask == STRING2_VALUE) \ (pa).str2_values = (pa).str2_values & flag; \ } /****************************************************************************** * * Private Functions * *****************************************************************************/ /****************************************************************************** * Function: CompressTable * *****************************************************************************/ static _DtCvSegment * CompressTable( FormatStruct *my_struct, _DtCvSegment *seg) { _DtCvSegment *retSeg = seg; _DtCvSegment **tableSegs; char **rowIds; /* * make sure we're working with a non-null segment. */ if (NULL != seg) { /* * get the row ids. */ rowIds = _DtCvCellIdsOfTableSeg(seg); /* * if there is only one column and zero to one rows, * compress out the table */ if (1 == _DtCvNumColsOfTableSeg(seg) && (NULL == rowIds || NULL == *rowIds || NULL == rowIds[1])) { /* * get the list of table segments. */ tableSegs = _DtCvCellsOfTableSeg(seg); /* * now find the correct segment. Start out with a null return. */ retSeg = NULL; if (NULL != rowIds && NULL != *rowIds) { _DtCvSegment *prevSeg = NULL; /* * look through the table's list for the one segment * to fill the one column/row table. */ while (NULL != tableSegs && NULL != *tableSegs && _DtCvStrCaseCmpLatin1(*rowIds, _DtCvContainerIdOfSeg(*tableSegs))) { prevSeg = *tableSegs; tableSegs++; } /* * does the segment exist in the table's list? */ if (NULL != tableSegs && NULL != *tableSegs) { /* * set the return value. */ retSeg = *tableSegs; /* * now propagate the justification. */ if (_DtCvINHERIT == _DtCvContainerJustifyOfSeg(retSeg) && NULL != _DtCvColJustifyOfTableSeg(seg)) _DtCvContainerJustifyOfSeg(retSeg) = *(_DtCvColJustifyOfTableSeg(seg)); /* * now move up any other table segments, whereby * eliminating this segment from the list so it * won't be freed via _DtHelpFreeSegments(). */ while (NULL != *tableSegs) { *tableSegs = tableSegs[1]; tableSegs++; } } } /* * Now free the table segment */ _DtHelpFreeSegments(seg, _DtCvFALSE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); } } return retSeg; } /****************************************************************************** * Function: PropagateJustification * *****************************************************************************/ static void PropagateJustification( _DtCvSegment *seg, _DtCvFrmtOption justify) { if (NULL != seg && _DtCvIsSegContainer(seg) && _DtCvINHERIT == _DtCvContainerJustifyOfSeg(seg)) _DtCvContainerJustifyOfSeg(seg) = justify; } /****************************************************************************** * Function: void FreeAttributes (enum SdlElement element, * CESDLAttrStruct *attributes) * * Parameters: * * Returns: * * Purpose: * ******************************************************************************/ static void FreeAttributes( enum SdlElement element, ElementInfo *cur_info, _DtHelpFontHints *font_specs) { int i = 0; const SDLElementAttrList *myList; const SDLAttribute *attrib; char *varOffset; char **strPtr; while (i < MaxSDLElements && SdlElementList[i].sdl_element != element) i++; myList = SdlElementList[i].attrib_list; if (myList != NULL && (cur_info->str1_values != 0 || cur_info->str2_values != 0)) { while (myList->sdl_attr_define != -1) { if (SDLIsStrAttrSet(*cur_info, myList->sdl_attr_define) && SDLIsAttrSet(*cur_info, myList->sdl_attr_define)) { attrib = SDLAttributeList; while (attrib->sdl_attr_define != -1 && !ATTRS_EQUAL(attrib->data_type, myList->sdl_attr_define, attrib->sdl_attr_define)) attrib++; if (attrib->struct_type == SdlFontSpecific || attrib->struct_type == SdlElementSpecific) { if (attrib->struct_type == SdlFontSpecific) varOffset = ((char *) font_specs); else if (attrib->struct_type == SdlElementSpecific) varOffset = ((char *) cur_info); varOffset = varOffset + attrib->field_ptr; strPtr = (char **) varOffset; if (NULL != *strPtr) free (*strPtr); } } myList++; } } } /****************************************************************************** * Function: DuplicateElement * *****************************************************************************/ static _DtCvSegment * DuplicateElement( _DtCvPointer client_data, _DtCvSegment *toss, _DtCvSegment *src_seg, _DtCvSegment **prev_data, _DtCvSegment **last_seg, void (*load_font)(), _DtCvValue (*resolve_spc)(), _DtCvUnit line_height, int ave_char, _DtHelpFontHints srcFonts, int link_idx, _DtCvValue vis_link) { int oldIndex = link_idx; _DtCvSegment *topSeg = NULL; _DtCvSegment *prevData = NULL; _DtCvSegment *lastSeg = NULL; _DtCvSegment *newSeg; _DtHelpFontHints curFonts; SdlMatchData *match; _DtHelpDARegion *region; FrmtPrivateInfo *priv; if (NULL != prev_data) prevData = *prev_data; if (NULL != last_seg) lastSeg = *last_seg; while (src_seg != NULL) { curFonts = srcFonts; link_idx = oldIndex; if (_DtCvIsSegHyperText(src_seg) || _DtCvIsSegGhostLink(src_seg)) { link_idx = src_seg->link_idx; if (_DtCvIsSegHyperText(src_seg)) vis_link = True; } if (_DtHelpCeAllocSegment(1, NULL, NULL, &newSeg) != 0) return NULL; /* * copy over the information. (But don't blow away the private * information, except - keep the dup flag.) */ priv = FrmtPrivInfoPtr(newSeg); *newSeg = *src_seg; newSeg->client_use = priv; priv->dup_flag = FrmtPrivInfoPtr(src_seg)->dup_flag; /* * set the duplicate on the source seg. That way, allocated memory * now belongs to the new segment. */ SetDupFlag(src_seg); /* * now re-set some information pertinent to this flow of control */ newSeg->link_idx = link_idx; newSeg->type = ClearSegLinks(newSeg); if (link_idx != -1) { if (vis_link == True) newSeg->type = _DtCvSetTypeToHyperText(newSeg->type); else newSeg->type = _DtCvSetTypeToGhostLink(newSeg->type); } _DtCvNextSeg(newSeg) = NULL; newSeg->next_disp = NULL; /* * put this segment into the list. */ if (NULL != lastSeg) _DtCvNextSeg(lastSeg) = newSeg; /* * type cast the internal structure to a match data struct * now, since more than one element may use it. */ match = SegMatchDataPtr(src_seg); switch (_DtCvPrimaryTypeOfSeg(newSeg)) { case _DtCvCONTAINER: /* * merge the attributes into the new elements. */ if (NULL != match) { if (NULL != toss) { _DtHelpCeMergeSdlAttribInfo( _DtHelpCeMatchSemanticStyle( toss, match->clan, match->level, match->ssi), newSeg, &curFonts, NULL, NULL, NULL); /* * set the margins to absolute values */ if (ave_char > 0) { _DtCvContainerLMarginOfSeg(newSeg) = _DtCvContainerLMarginOfSeg(newSeg) * ave_char; _DtCvContainerRMarginOfSeg(newSeg) = _DtCvContainerRMarginOfSeg(newSeg) * ave_char; _DtCvContainerFMarginOfSeg(newSeg) = _DtCvContainerFMarginOfSeg(newSeg) * ave_char; } /* * set the top and bottom margins to absolute values */ if (line_height > 0) { TMarginOfSeg(newSeg) = TMarginOfSeg(newSeg) * line_height; BMarginOfSeg(newSeg) = BMarginOfSeg(newSeg) * line_height; } } } _DtCvContainerListOfSeg(newSeg) = DuplicateElement( client_data, toss, _DtCvContainerListOfSeg(src_seg), &prevData, &lastSeg, load_font, resolve_spc, line_height, ave_char, curFonts, link_idx, vis_link); if (NULL == _DtCvContainerListOfSeg(newSeg)) { free(newSeg); return NULL; } /* * if this is a wrapper, throw it away */ if (IsSdlWrapper(newSeg->type)) { _DtCvSegment *tmpSeg = newSeg; newSeg = _DtCvContainerListOfSeg(newSeg); free(tmpSeg); } break; case _DtCvSTRING: /* * now load the font for this element */ (load_font)(client_data, _DtHelpFontHintsLang(curFonts), _DtHelpFontHintsCharSet(curFonts), curFonts, &(_DtCvFontOfStringSeg(newSeg))); /* * put this segment in the display list. */ if (NULL != prevData) prevData->next_disp = newSeg; prevData = newSeg; break; case _DtCvREGION: region = (_DtHelpDARegion *) _DtCvInfoOfRegionSeg(src_seg); if (False == region->inited) { _DtHelpDASpcInfo *spcInfo = (_DtHelpDASpcInfo *) region->handle; (resolve_spc)(client_data, _DtHelpFontHintsLang(curFonts), _DtHelpFontHintsCharSet(curFonts), curFonts, spcInfo->name, &(_DtCvInfoOfRegionSeg(newSeg)), &(_DtCvWidthOfRegionSeg(newSeg)), &(_DtCvHeightOfRegionSeg(newSeg)), &(_DtCvAscentOfRegionSeg(newSeg))); ClearDupFlag(src_seg); } /* * check for in-line flags on this item. */ if (NULL != match && (SdlClassInLine == match->clan || SdlClassButton == match->clan || SdlClassIcon == match->clan)) newSeg->type = _DtCvSetTypeToInLine(newSeg->type); /* * put this segment in the display list. */ if (NULL != prevData) prevData->next_disp = newSeg; prevData = newSeg; break; } if (topSeg == NULL) topSeg = newSeg; lastSeg = newSeg; src_seg = _DtCvNextSeg(src_seg); } if (NULL != prev_data) *prev_data = prevData; if (NULL != last_seg) *last_seg = lastSeg; return topSeg; } /****************************************************************************** * Function: _DtCvSegment *ResolveSnref (FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static _DtCvSegment * ResolveSnref( FormatStruct *my_struct, _DtCvSegment *snref, char *snref_id) { _DtCvValue found = False; _DtCvSegment *snbEntry = NULL; _DtCvSegment *altText = NULL; _DtCvSegment *newSeg = NULL; _DtCvSegment *refItem = _DtCvContainerListOfSeg(snref); FrmtPrivateInfo *priv; _DtHelpFontHints saveFonts = *(my_struct->my_fonts); /* * Check to see if a snb has been found yet. If not, put off resolving * refitems. */ if (NULL != my_struct->snb) { /* * check each refitem to see if it can be resolved */ while (False == found && NULL != refItem) { /* * assume the refitem will be found in the snb */ found = True; snbEntry = NULL; if (NULL != _DtCvContainerIdOfSeg(refItem)) snbEntry = FindSnbEntry(my_struct->snb, _DtCvContainerIdOfSeg(refItem)); else /* the container */ altText = refItem; if (NULL == snbEntry) { /* * didn't find the refitem, so set the flag * for another loop. */ found = False; refItem = _DtCvNextSeg(refItem); } } /* * was a system notation block item found? */ if (True == found) { /* * an refitem can be a region (graphic, audio, video, animate), * text or a script. If a script, need to process it differently. */ priv = FrmtPrivInfoPtr(snbEntry); if (SdlElementScript == priv->sdl_el_type) { /* * NULL variables, get the interpretor. */ SdlMatchData *match; char *runData; char *newData = NULL; char *interpStr = GetInterpCmd((SdlOption) (priv->interp)); /* * get the data to run */ runData = _DtCvStringOfStringSeg( _DtCvContainerListOfSeg(snbEntry)); if (NULL == interpStr || -1 == _DtCvRunInterp(my_struct->ui_info->exec_filter, my_struct->ui_info->client_data, interpStr, runData, &newData) || NULL == newData || 0 == strlen(newData)) { free(newData); return NULL; } /* * set the match data for toss lookup */ match = SegMatchDataPtr(refItem); if (NULL != match && NULL != my_struct->toss) _DtHelpCeMergeSdlAttribInfo( _DtHelpCeMatchSemanticStyle( my_struct->toss, match->clan, match->level, match->ssi), newSeg, my_struct->my_fonts, NULL, NULL, NULL); if (0 != MySaveString(&newSeg, my_struct, newData, my_struct->cur_link, my_struct->mb_len, False)) { free(newData); return NULL; } free(newData); } else { /* * strip the container wrapper from the snbEntry before * duplication. * * Also, include the toss match data for this segment * in the snbEntry. */ snbEntry = _DtCvContainerListOfSeg(snbEntry); if (NULL != snbEntry) { SegMatchData(snbEntry) = SegMatchData(refItem); newSeg = DuplicateElement(my_struct->ui_info->client_data, my_struct->toss, snbEntry, &(my_struct->prev_data), NULL, my_struct->ui_info->load_font, my_struct->ui_info->resolve_spc, my_struct->ui_info->line_height / 2, my_struct->ui_info->avg_char, *(my_struct->my_fonts), my_struct->cur_link, True); SegMatchData(snbEntry) = NULL; if (NULL == newSeg) return NULL; /* * if the only item in the list for the snb entry is * a region, then assume it is a graphic, video, etc. * Check to see if the region is in-line or a figure. * If in-line, ignore any heads with the refitem. If a * figure, include them (they may be a caption to the * region). */ if (_DtCvIsSegRegion(newSeg) && NULL == _DtCvNextSeg(newSeg)) { SdlMatchData *info = SegMatchDataPtr(refItem); /* * is this a figure? */ if (SdlClassFigure == info->clan) { _DtCvNextSeg(newSeg) = _DtCvContainerListOfSeg(refItem); _DtCvContainerListOfSeg(refItem) = NULL; } } } } } /* * was there alternate text? */ else if (NULL != altText && NULL != _DtCvContainerListOfSeg(altText)) { /* * the new segment becomes the contents of the * container - why copy? Just null the pointer * to prevent the free from destroying the contents. */ newSeg = _DtCvContainerListOfSeg(altText); _DtCvContainerListOfSeg(altText) = NULL; /* * load the font for this snref. */ (my_struct->ui_info->load_font)(my_struct->ui_info->client_data, _DtHelpFontHintsLang(*(my_struct->my_fonts)), _DtHelpFontHintsCharSet(*(my_struct->my_fonts)), *(my_struct->my_fonts), &(_DtCvFontOfStringSeg(newSeg))); } if (my_struct->prev_data != NULL) my_struct->prev_data->next_disp = newSeg; my_struct->last_was_space = False; my_struct->last_was_mb = False; my_struct->last_was_nl = False; if (NULL != newSeg) my_struct->prev_data = newSeg; } else if (_DtCvTRUE == my_struct->save_snref) { int count = my_struct->snref_cnt; if (NULL == my_struct->un_snrefs) my_struct->un_snrefs = (UnresSnref *) malloc (sizeof(UnresSnref)); else my_struct->un_snrefs = (UnresSnref *) realloc ( (void *) my_struct->un_snrefs, (sizeof(UnresSnref) * (count + 1))); if (NULL != my_struct->un_snrefs) { my_struct->un_snrefs[count].id = snref_id; my_struct->un_snrefs[count].seg = snref; my_struct->un_snrefs[count].cur_link = my_struct->cur_link; my_struct->un_snrefs[count].fonts = *(my_struct->my_fonts); my_struct->snref_cnt++; /* * return the snref segment as our new segment to act as a * place holder, otherwise it gets squeezed * out. */ newSeg = snref; if (my_struct->prev_data != NULL) my_struct->prev_data->next_disp = newSeg; my_struct->prev_data = newSeg; /* * make the snref a noop so it gets the proper next/last * display pointers. */ newSeg->type = _DtCvSetTypeToNoop(newSeg->type); } } *(my_struct->my_fonts) = saveFonts; return newSeg; } /* End ResolveSnref */ /****************************************************************************** * Function: static CEFontSpecs AllocateFontInfo(my_struct); * * Parameters: * * Returns: non-null if successful, NULL if errors * * Purpose: Allocates a FontInfo structure and intializes it to * the current fonts hints. * ******************************************************************************/ static _DtHelpFontHints * AllocateFontInfo( FormatStruct *my_struct) { _DtHelpFontHints *retFont = NULL; if (my_struct->free_cnt > 0) retFont = my_struct->free_fonts[--my_struct->free_cnt]; else { /* * malloc and initialize the starting font information */ retFont = (_DtHelpFontHints *) malloc (sizeof(_DtHelpFontHints)); if (NULL == retFont) return NULL; } /* * initialize the font structure */ if (NULL != my_struct->my_fonts) *retFont = *(my_struct->my_fonts); else *retFont = DefFontInfo; return retFont; } /****************************************************************************** * Function: static _DtCvSegment **ConvertToList(segs); * * Parameters: * * Returns: non-null if successful, NULL if errors * * Purpose: Allocates a list of null terminated _DtCvSegment pointers. * ******************************************************************************/ static _DtCvSegment ** ConvertToList(_DtCvSegment *segs) { _DtCvSegment **ptr = NULL; /* * count the segments */ while (NULL != segs) { _DtCvSegment *next; ptr = (_DtCvSegment **) _DtCvAddPtrToArray ((void **) ptr, (void *) segs); next = _DtCvNextSeg(segs); _DtCvNextSeg(segs) = NULL; segs = next; } return (ptr); } /****************************************************************************** * Function: static int DestroyFontInfo(my_struct); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Places the font structure in the free list for re-use. * ******************************************************************************/ static void DestroyFontInfo( FormatStruct *my_struct) { /* * free the font structures allocated */ while (0 < my_struct->free_cnt) { my_struct->free_cnt--; free(my_struct->free_fonts[my_struct->free_cnt]); } if (NULL != my_struct->free_fonts) free(my_struct->free_fonts); my_struct->free_fonts = NULL; if (NULL != my_struct->my_fonts) free(my_struct->my_fonts); } /****************************************************************************** * Function: static int FreeFontInfo(my_struct); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Places the font structure in the free list for re-use. * ******************************************************************************/ static int FreeFontInfo( FormatStruct *my_struct) { if (my_struct->free_cnt >= my_struct->free_max) { my_struct->free_max += GROW_SIZE; if (NULL != my_struct->free_fonts) my_struct->free_fonts = (_DtHelpFontHints **) realloc ( my_struct->free_fonts, sizeof(_DtHelpFontHints *) * my_struct->free_max); else my_struct->free_fonts = (_DtHelpFontHints **) malloc ( sizeof(_DtHelpFontHints *) * my_struct->free_max); if (NULL == my_struct->free_fonts) return -1; } my_struct->free_fonts[my_struct->free_cnt++] = my_struct->my_fonts; return 0; } /****************************************************************************** * Function: static int ResolveAsyncBlock(my_struct, table_seg); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: * ******************************************************************************/ static int ResolveAsyncBlock( FormatStruct *my_struct, _DtCvSegment *table_seg) { char c; char *next; char *start = NULL; char **rowIds = _DtCvCellIdsOfTableSeg(table_seg); _DtCvFrmtOption *colJ; _DtCvSegment **cellSegs; _DtCvSegment *newSeg; _DtCvSegment *asyncSegs; _DtCvValue found; while (NULL != rowIds && NULL != *rowIds) { /* * get the start of the row ids */ next = *rowIds; colJ = _DtCvColJustifyOfTableSeg(table_seg); while (NULL != next && '\0' != *next) { /* * skip leading spaces */ while (' ' == *next) next++; /* * set the starting pointer. */ start = next; /* * skip to the next delimitter. */ while (' ' != *next && '\0' != *next) next++; /* * check for the id in the set of segments. */ if (start != next) { /* * save and replace the last character with a null byte. */ c = *next; *next = '\0'; /* * get the cells in the table */ cellSegs = _DtCvCellsOfTableSeg(table_seg); /* * check that one of these cells matches the id */ found = False; if (NULL != cellSegs) { while (False == found && NULL != *cellSegs) { if (_DtCvStrCaseCmpLatin1( _DtCvContainerIdOfSeg(*cellSegs), start) == 0) found = True; else cellSegs++; } newSeg = *cellSegs; } /* * the id did not match any of the cells in the table * Look in the async list. */ if (False == found) { asyncSegs = my_struct->async_blks; while (False == found && NULL != asyncSegs) { if (_DtCvStrCaseCmpLatin1( _DtCvContainerIdOfSeg(asyncSegs), start) == 0) found = True; else asyncSegs = _DtCvNextSeg(asyncSegs); } /* * found one in the aysnc blocks * Duplicate it. */ if (True == found) { _DtCvSegment *lastSrc = NULL; _DtCvSegment *lastNext = NULL; /* * break the link to the next segment * or we'll copy this segment and all * the next segments. */ _DtCvSegment *nextSeg = _DtCvNextSeg(asyncSegs); _DtCvNextSeg(asyncSegs) = NULL; /* * allocate a new segment for this async block. */ newSeg = DuplicateElement( my_struct->ui_info->client_data, my_struct->toss, asyncSegs, &lastSrc, &lastNext, my_struct->ui_info->load_font, my_struct->ui_info->resolve_spc, my_struct->ui_info->line_height / 2, my_struct->ui_info->avg_char, *(my_struct->my_fonts), -1, False); /* * restore the async seg linked list */ _DtCvNextSeg(asyncSegs) = nextSeg; /* * check to see if anything was copied */ if (NULL == newSeg) return -1; /* * now place this segment in the list. */ _DtCvCellsOfTableSeg(table_seg) = (_DtCvSegment **) _DtCvAddPtrToArray( (void **) _DtCvCellsOfTableSeg(table_seg), (void *) newSeg); } } /* * replace the character. */ *next = c; } colJ++; } /* * check the next row */ rowIds++; } return 0; } /****************************************************************************** * Function: static int FindSnb(my_struct, id); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: * ******************************************************************************/ static _DtCvSegment * FindSnbEntry( _DtCvSegment *snb, char *target) { char *id; _DtCvSegment *retEntry; if (NULL != snb) { retEntry = _DtCvContainerListOfSeg(snb); while (NULL != retEntry) { id = NULL; if (_DtCvIsSegContainer(retEntry)) id = _DtCvContainerIdOfSeg(retEntry); if (NULL != id && _DtCvStrCaseCmpLatin1(target, id) == 0) return retEntry; retEntry = _DtCvNextSeg(retEntry); } } return NULL; } /* A little helper function, acts like strcpy * but safe for overlapping regions. */ static void *strmove(void *dest, const void *src) { return memmove(dest, src, strlen(src) + 1); } /****************************************************************************** * Function: static int ProcessString(string, int idx); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: * ******************************************************************************/ static int ProcessString( FormatStruct *my_struct, _DtCvValue last_flag, _DtCvValue nl_flag, _DtCvValue mod_str, _DtCvValue cpy_str, _DtCvValue process_flag, char *string, int byte_len, int *idx) { if (mod_str == True) string[*idx] = '\0'; if (process_flag == True && MySaveString(&(my_struct->seg_list), my_struct, string, my_struct->cur_link, byte_len, nl_flag) != 0) { MyFree(string); return -1; } my_struct->last_was_space = last_flag; if (cpy_str == True) { strmove (string, &string[*idx+1]); *idx = -1; } return 0; } /****************************************************************************** * Function: static void CompressLinkSeg(seg); * * Parameters: * * Returns: nothing * * Purpose: Check to see if there is a blank at the beginning of the * segment and if it is needed. * ******************************************************************************/ static void CompressLinkSeg( _DtCvSegment *p_seg) { void *pChar; int wcFlag; /* * check to see if the first segment is a string. */ while (NULL != p_seg && _DtCvIsSegNoop(p_seg)) p_seg = _DtCvNextSeg(p_seg); if (NULL == p_seg) return; if (_DtCvIsSegString(p_seg)) { wcFlag = _DtCvIsSegWideChar(p_seg); pChar = _DtCvStrPtr(_DtCvStringOfStringSeg(p_seg), wcFlag, 0); /* * is this the only segment in the link? * Is it only one character in size? */ if (NULL == _DtCvNextDisp(p_seg) && 1 <= _DtCvStrLen(pChar, wcFlag)) return; /* * is it a blank? (wide char and single char codes are equal * for blanks - ISO standard) */ if ((_DtCvIsSegWideChar(p_seg) && ' ' == *((wchar_t *) pChar)) || (_DtCvIsSegRegChar(p_seg) && ' ' == *((char *) pChar))) { /* * compress out the blank * * is this a single byte string? If so, use strcpy to move * the string. */ if (_DtCvIsSegRegChar(p_seg)) strmove(((char *)pChar), &(((char *)pChar)[1])); else { wchar_t *wcChar = (wchar_t *) pChar; while (0 != wcChar[0]) { wcChar[0] = wcChar[1]; wcChar++; } } } } } /****************************************************************************** * Function: static int ProcessNonBreakChar(string, int idx); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: * ******************************************************************************/ static int ProcessNonBreakChar( FormatStruct *my_struct, _DtCvValue process_flag, char *break_str, char *string, int byte_len, int *idx) { if (ProcessString(my_struct, False, False, True, False, process_flag, string, byte_len, idx) != 0) return -1; my_struct->flags = _DtCvSetTypeToNonBreak(my_struct->flags); if (ProcessString(my_struct, False, False, False, False, process_flag, break_str, byte_len, idx) != 0) return -1; my_struct->flags = my_struct->flags & ~(_DtCvNON_BREAK); strmove (string, &string[*idx+1]); *idx = -1; return 0; } /****************************************************************************** * Function: static int MoveString(string, int idx); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: * ******************************************************************************/ static int MoveString( char **string, int *max_len, int *idx) { int i = *idx; int myLen = *max_len; char *src = *string; i--; if (i == -1) { if (strlen(src) == myLen) { src = (char *) realloc (src, myLen + 2); if (src == NULL) return -1; myLen++; *string = src; *max_len = myLen; } for (i = myLen; i > 0; i--) src[i] = src[i-1]; } *idx = i; return 0; } /****************************************************************************** * Function: int SetUp (_DtHelpVolumeHdl volume, * CESDLVolume **sdl_vol, * FormatStruct *frmt_struct, * _DtCvSegment *toss, * _DtCvSegment *cur_frmt, * _DtCvValue lang * * Parameters: * volume Specifies the volume handle. If non-NULL, * create and return the sdl volume pointer * in 'sdl_vol'. * sdl_vol If not NULL, returns the sdl volume pointer. * frmt_struct Specifies the formatting structure to use. * toss Specifies the toss to use. If NULL and * sdl_vol asked for and flag == True, the * sdl_vol->toss will be used. * lang Specifies if the language/charset should * be set using information from the volume. * flag Specifies if to get/use the sdl_vol->toss * if toss is NULL. * * Returns: 0 if no failures, -1 if errors. * * Purpose: Set up the formatting structure to use. * *****************************************************************************/ static int SetUp ( _DtHelpVolumeHdl volume, CESDLVolume **sdl_vol, FormatStruct *frmt_struct, _DtCvSegment *toss, const _FrmtUiInfo *ui_info, int fd, _DtCvValue lang, _DtCvValue flag) { *frmt_struct = DefFormatStruct; frmt_struct->my_links = _DtLinkDbCreate(); if (NULL == frmt_struct->my_links) return -1; if (volume != NULL && sdl_vol != NULL) { *sdl_vol = _DtHelpCeGetSdlVolumePtr(volume); if (*sdl_vol == NULL) { _DtLinkDbDestroy(frmt_struct->my_links); return -1; } } /* * malloc and initialize the starting font information */ frmt_struct->my_fonts = AllocateFontInfo(frmt_struct); if (NULL == frmt_struct->my_fonts) { _DtLinkDbDestroy(frmt_struct->my_links); return -1; } if (volume != NULL) { frmt_struct->vol_name = _DtHelpCeGetVolumeName(volume); if (toss == NULL && flag == True) toss = _DtHelpCeGetSdlVolToss(volume, fd); if (lang == True) { _DtHelpFontHintsLang(*(frmt_struct->my_fonts)) = _DtHelpCeGetSdlVolLanguage(volume); _DtHelpFontHintsCharSet(*(frmt_struct->my_fonts)) = (char *) _DtHelpCeGetSdlVolCharSet(volume); } } /* * determine mb_len should be based on lang/charset. */ frmt_struct->mb_len = MB_CUR_MAX; frmt_struct->toss = toss; frmt_struct->ui_info = ui_info; return 0; } /****************************************************************************** * Function: void AddToAsyncList (_DtCvSegment *seg_list) * * Parameters: * * Returns Nothing * * Purpose: Add a segment block to the async list. * *****************************************************************************/ static void AddToAsyncList ( FormatStruct *my_struct, _DtCvSegment *block_seg) { if (my_struct->async_blks != NULL) { _DtCvSegment *pSeg = my_struct->async_blks; while (_DtCvNextSeg(pSeg) != NULL) pSeg = _DtCvNextSeg(pSeg); _DtCvNextSeg(pSeg) = block_seg; } else my_struct->async_blks = block_seg; } /****************************************************************************** * Function: int CheckOptionList (int attr_value_type, const char *attr, * _DtCvValue check_flag, * SdlOption cur_num, * SdlOption *num); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: If found, returns the enum value. * ******************************************************************************/ static int CheckOptionList( int attr_value_type, const char *attr, _DtCvValue check, SdlOption cur_num, SdlOption *num) { int i = 0; int lowerChar; int result = -1; const OptionList *option; _DtCvValue found = False; _DtCvValue cmpFnd = False; while (SDLOptionsList[i].attr_value != -1 && SDLOptionsList[i].attr_value != attr_value_type) i++; if (SDLOptionsList[i].attr_value != -1) { option = SDLOptionsList[i].options; lowerChar = _DtHelpCeToLower(*attr); while (option != NULL && option->string != NULL && (check == True || cmpFnd == False)) { /* * check to see if the current option is in the list * of valid options for this attribute. */ if (check && cur_num == option->option_value) { /* * okay, it's been found, don't check anymore. */ found = True; check = False; } /* * otherwise, find out if this value is a valid option * for the attribute. */ else if (cmpFnd == False && lowerChar == _DtHelpCeToLower(*(option->string)) && _DtCvStrCaseCmpLatin1(option->string, attr) == 0) { cmpFnd = True; *num = option->option_value; } option++; } } /* * if found is true, means check was originally set to true and * we found the current value in the option list for this attribute. */ if (found == True) *num = cur_num; /* * if we found that the current value was valid or that the string * was a valid option in the list for the attribute, return no error. */ if (found == True || cmpFnd == True) result = 0; return result; } /****************************************************************************** * Function: int CheckFontList (int attr_value_type, char *attr, * enum CEFontSpec *num); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: If found, returns the enum value. * ******************************************************************************/ static int CheckFontList( int attr_value_type, char *attr, _DtHelpFontValue *num) { int i = 0; const FontSpecOption *option; while (SDLFontList[i].attr_value != -1 && SDLFontList[i].attr_value != attr_value_type) i++; if (SDLFontList[i].attr_value != -1) { option = SDLFontList[i].options; while (option != NULL && option->string != NULL) { if (_DtCvStrCaseCmpLatin1(option->string, attr) == 0) { *num = option->option_value; return 0; } option++; } } return -1; } /****************************************************************************** * Function: int LookAhead (FormatStruct my_struct, int token_value, * int remove_flag); * * Parameters: * my_struct Specifies the parsing structure. * token_value Specifies the token to match * remove_flag Specifies whether to clear the look ahead * value. If True, will set the look ahead * parsed value to invalid iff token_value * equals the parsed look ahead value. * * Returns: 0 if token_value matched parsed value, * 1 if parsed value is invalid. * -1 if parsed value is valid but token_value did not match. * * Purpose: * ******************************************************************************/ static int TestLookAhead( FormatStruct *my_struct, enum SdlElement token_value, _DtCvValue end_flag, int remove_flag) { if (my_struct->parsed == SdlElementNone) return 1; if (my_struct->parsed == token_value && my_struct->end_flag == end_flag) { if (remove_flag == True) { my_struct->parsed = SdlElementNone; if (my_struct->remember != NULL) { free (my_struct->remember); my_struct->remember = NULL; } } return 0; } return -1; } /****************************************************************************** * Function: int MatchSDLElement (FormatStruct my_struct, sdl_string, * int sdl_element, sig_chars) * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the specific element. * ******************************************************************************/ static int MatchSDLElement( FormatStruct *my_struct, const char *sdl_string, enum SdlElement sdl_element, int sig_chars, _DtCvValue end_flag) { int i; i = TestLookAhead(my_struct, sdl_element, end_flag, True); if ( i != 1) return i; return (_DtHelpCeMatchSdlElement(my_struct->my_file,sdl_string,sig_chars)); } /****************************************************************************** * Function: void SetAttributeFlag ( * ******************************************************************************/ static void SetAttributeFlag( ElementInfoPtr cur_info, unsigned long attr_define) { unsigned long flag = attr_define & ~(VALUE_MASK); switch (attr_define & VALUE_MASK) { case ENUM_VALUE: cur_info->enum_values |= flag; break; case STRING1_VALUE: cur_info->str1_values |= flag; break; case STRING2_VALUE: cur_info->str2_values |= flag; break; case NUMBER_VALUE: cur_info->num_values |= flag; break; } } /****************************************************************************** * Function: void InitAttributes(SDLAttrStruct *as, * SDLElementAttrList *attr_list) * * Parameters: * * Returns: Attribute Processed if successful, -1 if errors * * Purpose: Looks for the virtual page beginning. * ******************************************************************************/ static void InitAttributes( _DtCvSegment *p_seg, _DtHelpFontHints *font_specs, ElementInfo *element_info, const SDLElementAttrList *attr_list) { char **strPtr1; char *varOffset1 = NULL; SDLNumber *numPtr1; SdlOption *enumPtr1; SdlOption defNum = _DtCvOPTION_BAD; const SDLAttribute *pAttr; while (attr_list->sdl_attr_define != -1) { if (attr_list->def_string != NULL || attr_list->sdl_value == SdlAttrValueImpliedDef) { pAttr = SDLAttributeList; while (pAttr->data_type != SdlAttrDataTypeInvalid && !(ATTRS_EQUAL(pAttr->data_type, pAttr->sdl_attr_define, attr_list->sdl_attr_define))) pAttr++; if (pAttr->struct_type != SdlIgnore && pAttr->data_type != SdlAttrDataTypeInvalid && SDLIsAttrSet(*element_info, pAttr->sdl_attr_define) == False) { /* * determine which structure the information goes in */ if (pAttr->struct_type == SdlFontSpecific) varOffset1 = ((char *) font_specs); else if (pAttr->struct_type == SdlContainerSpecific) varOffset1 = ((char *)_SdlContainerPtrOfSeg(p_seg)); else if (pAttr->struct_type == SdlElementSpecific) varOffset1 = ((char *) element_info); else if (pAttr->struct_type == SdlTableSpecific) varOffset1 = ((char *) element_info->w.table_info); varOffset1 = varOffset1 + pAttr->field_ptr; if (pAttr->data_type == SdlAttrDataTypeNumber) { numPtr1 = (SDLNumber *) varOffset1; *numPtr1 = ((SDLNumber)atoi(attr_list->def_string)); } else if (pAttr->data_type == SdlAttrDataTypeEnum) { enumPtr1 = (SdlOption *) varOffset1; (void) CheckOptionList (attr_list->sdl_attr_define, attr_list->def_string, ((attr_list->sdl_attr_define & SDL_ATTR_CLASS) ? True : False), ElInfoClan(element_info), &defNum); if ((attr_list->sdl_attr_define & SDL_ATTR_CLASS & ~(VALUE_MASK)) && ElInfoClan(element_info) != defNum) SetAttributeFlag(element_info, attr_list->sdl_attr_define); *enumPtr1 = defNum; } else if (SDLIsString1(pAttr->sdl_attr_define) || SDLIsString2(pAttr->sdl_attr_define)) { strPtr1 = (char **) varOffset1; *strPtr1 = (char *) attr_list->def_string; } } } attr_list++; } } #ifdef DEBUG static char * ElToName(enum SdlElement el) { switch (el) { case SdlElementNone: return ("None"); case SdlElementComment: return ("Comment"); case SdlElementSdlDoc: return ("SdlDoc"); case SdlElementVStruct: return ("VStruct"); case SdlElementVirpage: return ("Virpage"); case SdlElementHead: return ("Head"); case SdlElementSubHead: return ("SubHead"); case SdlElementSnb: return ("Snb"); case SdlElementBlock: return ("Block"); case SdlElementForm: return ("Form"); case SdlElementPara: return ("Para"); case SdlElementCPara: return ("CPara"); case SdlElementFdata: return ("Fdata"); case SdlElementFstyle: return ("Fstyle"); case SdlElementFrowvec: return ("Frowvec"); case SdlElementKey: return ("Key"); case SdlElementCdata: return ("Cdata"); case SdlElementGraphic: return ("Graphic"); case SdlElementText: return ("Text"); case SdlElementAudio: return ("Audio"); case SdlElementVideo: return ("Video"); case SdlElementAnimate: return ("Animate"); case SdlElementCrossDoc: return ("CrossDoc"); case SdlElementManPage: return ("ManPage"); case SdlElementTextFile: return ("TextFile"); case SdlElementSysCmd: return ("SysCmd"); case SdlElementCallback: return ("Callback"); case SdlElementScript: return ("Script"); case SdlElementAnchor: return ("Anchor"); case SdlElementLink: return ("Link"); case SdlElementSwitch: return ("Switch"); case SdlElementSnRef: return ("SnRef"); case SdlElementRefItem: return ("RefItem"); case SdlElementAltText: return ("AltText"); case SdlElementSphrase: return ("Sphrase"); case SdlElementRev: return ("Rev"); case SdlElementSpc: return ("Spc"); case SdlElementIf: return ("If"); case SdlElementCond: return ("Cond"); case SdlElementThen: return ("Then"); case SdlElementElse: return ("Else"); case SdlElementDocument: return ("Document"); case SdlElementSgml: return ("Sgml"); case SdlElementDocType: return ("DocType"); case SdlElementLoids: return ("Loids"); case SdlElementToss: return ("Toss"); case SdlElementLoPhrases: return ("LoPhrases"); case SdlElementPhrase: return ("Phrase"); case SdlElementIndex: return ("Index"); case SdlElementEntry: return ("Entry"); case SdlElementRelDocs: return ("RelDocs"); case SdlElementRelFile: return ("RelFile"); case SdlElementNotes: return ("Notes"); case SdlElementKeyStyle: return ("KeyStyle"); case SdlElementHeadStyle: return ("HeadStyle"); case SdlElementFormStyle: return ("FormStyle"); case SdlElementFrmtStyle: return ("FrmtStyle"); case SdlElementGrphStyle: return ("GrphStyle"); case SdlElementId: return ("Id"); case SdlElementBlockAsync: return ("BlockAsync"); case SdlElementTitle: return ("Title"); case SdlPcDataFollows: return ("Follows"); } return ("Unknown"); } #endif /* DEBUG */ /****************************************************************************** * Function: int ProcessSDLAttribute(FormatStruct my_struct, * SDLAttrStruct *cur_attr, * SDLElementAttrList *attr_list, * char *attr_name, * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page beginning. * ******************************************************************************/ static int ProcessSDLAttribute( FormatStruct *my_struct, _DtCvSegment *p_seg, _DtHelpFontHints *font_specs, ElementInfo *element_info, const SDLElementAttrList *attr_list, char *attr_name) { int result; char *attrValue; char **strPtr; char numBuf[DTD_NAMELEN+1]; char *varOffset1 = NULL; SDLNumber *numPtr1; SdlOption *enumPtr1; SdlOption attrNum; _DtHelpFontValue fontNum = 0; _DtHelpFontValue *fontPtr1; const SDLAttribute *pAttr = SDLAttributeList; /* * find the attribute in the list of SDL attributes * assumes that 'attr_name' has been lower cased, since all the * attribute names in SDLAttributeList are already lower case. */ while (pAttr->data_type != SdlAttrDataTypeInvalid && (*(pAttr->name) != *attr_name || strcmp(pAttr->name, attr_name))) pAttr++; if (pAttr->data_type != SdlAttrDataTypeInvalid) { /* * Check to see if this element contains an attribute with * the found value. */ while (attr_list->sdl_attr_define != -1 && !ATTRS_EQUAL(pAttr->data_type, pAttr->sdl_attr_define, attr_list->sdl_attr_define)) attr_list++; if (attr_list->sdl_attr_define == -1) return -1; } /* * check it against the ones that are allowed for this element */ if (pAttr->data_type != SdlAttrDataTypeInvalid) { switch (pAttr->data_type) { case SdlAttrDataTypeId: result = _DtHelpCeGetSdlId(my_struct->my_file, &attrValue); break; case SdlAttrDataTypeNumber: result = _DtHelpCeGetSdlNumber(my_struct->my_file, numBuf); break; case SdlAttrDataTypeCdata: result = _DtHelpCeGetSdlAttributeCdata(my_struct->my_file, False, &attrValue); break; case SdlAttrDataTypeFont: result = _DtHelpCeGetSdlAttributeCdata(my_struct->my_file, False, &attrValue); if (result != -1) result = CheckFontList (attr_list->sdl_attr_define, attrValue, &fontNum); break; case SdlAttrDataTypeEnum: result = _DtHelpCeGetSdlAttributeCdata(my_struct->my_file, False, &attrValue); if (result != -1) result = CheckOptionList (attr_list->sdl_attr_define, attrValue, False, (SdlOption) _DtCvOPTION_BAD, &attrNum); break; default: printf ("hit unknown in processing attribute\n"); result = -1; break; } if (result == 0) { if (pAttr->struct_type != SdlIgnore) { /* * determine which structure the information goes in */ if (pAttr->struct_type == SdlFontSpecific) varOffset1 = ((char *) font_specs); else if (pAttr->struct_type == SdlContainerSpecific) varOffset1 = ((char *)_SdlContainerPtrOfSeg(p_seg)); else if (pAttr->struct_type == SdlElementSpecific) varOffset1 = ((char *) element_info); else if (pAttr->struct_type == SdlTableSpecific) varOffset1 = ((char *) element_info->w.table_info); varOffset1 = varOffset1 + pAttr->field_ptr; if (pAttr->data_type == SdlAttrDataTypeNumber) { numPtr1 = (SDLNumber *) varOffset1; *numPtr1 = ((SDLNumber) atoi(numBuf)); } else if (pAttr->data_type == SdlAttrDataTypeEnum) { enumPtr1 = (SdlOption *) varOffset1; *enumPtr1 = attrNum; free(attrValue); } else if (pAttr->data_type == SdlAttrDataTypeFont) { fontPtr1 = (_DtHelpFontValue *) varOffset1; *fontPtr1 = fontNum; free(attrValue); } else { strPtr = (char **) varOffset1; *strPtr = attrValue; } } else if (SdlAttrDataTypeNumber != pAttr->data_type) free(attrValue); SetAttributeFlag(element_info, pAttr->sdl_attr_define); } return result; } return -1; } /****************************************************************************** * Function: int VerifyAttrList ( * SDLElementAttrList *attr_list) * * Parameters: * * Returns: Attribute Processed if successful, -1 if errors * * Purpose: Looks for the virtual page beginning. * ******************************************************************************/ static int VerifyAttrList( ElementInfoPtr el_info, const SDLElementAttrList *attr_list) { long value = 0; while (attr_list->sdl_attr_define != -1) { if (attr_list->sdl_value == SdlAttrValueRequired) { switch (attr_list->sdl_attr_define & VALUE_MASK) { case ENUM_VALUE: /* * mask off the minor number */ value = el_info->enum_values & ~(MINOR_MASK); break; case STRING1_VALUE: value = el_info->str1_values; break; case STRING2_VALUE: value = el_info->str2_values; break; case NUMBER_VALUE: value = el_info->num_values; break; } if (!(attr_list->sdl_attr_define & value)) return -1; } attr_list++; } return 0; } /****************************************************************************** * Function: void MergeTossInfo ( * _DtCvSegment *cur_element, * FormatStruct my_struct); * * Parameters: * * Returns: nothing * * Purpose: Looks for the virtual page beginning. * ******************************************************************************/ static void MergeTossInfo( FormatStruct *my_struct, _DtCvSegment *cur_contain, _DtHelpFontHints *font_specs) { _DtCvSegment *tossSeg; if (my_struct->toss == NULL) return; tossSeg = _DtHelpCeMatchSemanticStyle (my_struct->toss, ElClan(my_struct), ElLevel(my_struct), ElSsi(my_struct)); _DtHelpCeMergeSdlAttribInfo(tossSeg, cur_contain, font_specs, &(my_struct->el_info), &(my_struct->el_info.str1_values), &(my_struct->el_info.str2_values)); return; } /*------------------------- Element Processing ------------------------------*/ /****************************************************************************** * Function: int ParseElementStart ( * FormatStruct my_struct, * int element, _DtCvValue process_flag); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page beginning. * ******************************************************************************/ static int ParseElementStart( FormatStruct *my_struct, SDLElementInfo element, _DtCvValue process_flag) { _DtCvSegment *segPtr; _DtCvSegment *newSeg; FrmtPrivateInfo *priv; if (MatchSDLElement (my_struct, element.element_str, element.sdl_element, element.str_sig_chars, False) != 0) return -1; /* * remember what we are currently parsing */ ElType(my_struct) = element.sdl_element; /* * does this element possibly pull in different fonts? * if so, allocate a new font structure. */ if (True == process_flag && element.new_fonts) { my_struct->my_fonts = AllocateFontInfo(my_struct); if (NULL == my_struct->my_fonts) return -1; } /* * if Cdata or skipping information don't do anything else */ if (element.sdl_to_gen == SdlToNone || process_flag == False) return 0; /* * allocate a segment for this element */ if (_DtHelpCeAllocSegment(my_struct->malloc_size, &(my_struct->alloc_size), &(my_struct->block_list), &segPtr) != 0) return -1; /* * add this segment to the list when done */ my_struct->add_seg = segPtr; /* * Set the flags and initialize variables depending on the * type of general segment this element becomes. */ switch (element.sdl_to_gen) { case SdlToContainer: /* * set the container flag and initialize its formatting * information to the default. */ segPtr->type = _DtCvSetTypeToContainer(segPtr->type); _DtCvContainerOfSeg(segPtr) = DefFrmtSpecs; _DtCvContainerLeadingOfSeg(segPtr) = my_struct->ui_info->leading; /* * if this is a formatting type container, do some more work. */ if (element.formatting) { const _DtCvContainer *active = my_struct->active_frmt; if (NULL == active) active = &DefFrmtSpecs; /* * The margin information - it gets zero'ed */ _DtCvContainerLMarginOfSeg(segPtr) = 0; _DtCvContainerRMarginOfSeg(segPtr) = 0; _DtCvContainerFMarginOfSeg(segPtr) = 0; _DtCvContainerTMarginOfSeg(segPtr) = 0; _DtCvContainerBMarginOfSeg(segPtr) = 0; /* * inherit some of the formatting directives */ _DtCvContainerVJustifyOfSeg(segPtr) = ContainerPtrToVJustify(active); _DtCvContainerJustifyOfSeg(segPtr) = ContainerPtrToJustify(active); /* * break the connection with the previous data. */ my_struct->prev_data = NULL; _DtCvContainerListOfSeg(segPtr) = NULL; /* * check to see if these are controllers. */ if (element.sdl_element == SdlElementHead || SdlElementSubHead == element.sdl_element) segPtr->type = _DtCvSetTypeToController(segPtr->type); /* * make this the currently active formatting information */ my_struct->active_frmt = &(_DtCvContainerOfSeg(segPtr)); } break; case SdlToMarker: /* * set the type; the attribute processing will set the id. */ segPtr->type = _DtCvSetTypeToMarker(segPtr->type); break; case SdlToSnb: /* * set the type; the attribute processing will set the id. * graphics only exist in a snb. You have to keep the * id around until the graphic get resolved. So a graphic * is a container with a region. */ segPtr->type = _DtCvSetTypeToContainer(segPtr->type); /* * remember the refitem type. */ priv = FrmtPrivInfoPtr(segPtr); priv->sdl_el_type = ElType(my_struct); break; case SdlToSpc: /* * set the type; the attribute processing will set the id. */ segPtr->type = _DtCvSetTypeToRegion(segPtr->type); break; } if (my_struct->cur_link != -1) { segPtr->type = _DtCvSetTypeToHyperText(segPtr->type); segPtr->link_idx = my_struct->cur_link; } switch (element.sdl_element) { case SdlElementSnb: my_struct->resolve_font = _SdlFontModeNone; my_struct->snb = segPtr; my_struct->prev_data = NULL; break; case SdlElementAltText: segPtr->type = _DtCvSetTypeToNonBreak(segPtr->type); break; case SdlElementForm: /* * allocate a table for all the information */ if (_DtHelpCeAllocSegment(my_struct->malloc_size, &(my_struct->alloc_size), &(my_struct->block_list), &newSeg) != 0) return -1; newSeg->type = _DtCvSetTypeToTable(newSeg->type); _DtCvJustifyCharsOfTableSeg(newSeg) = NULL; /* * set the my_struct pointer to this table so that * as the fstyle and frowec elements are parsed, the * data goes directly into this table. */ ElTable(my_struct) = newSeg; break; } return 0; } /* End ParseElementStart */ /****************************************************************************** * Function: int ParseElementAttr ( * FormatStruct my_struct, * SDLElementAttrList *attribs) * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int ParseElementAttr( FormatStruct *my_struct, enum SdlElement cur_element, const SDLElementAttrList *attribs, _DtCvValue flag, _DtCvValue process_flag) { int result = 0; char attribName[MAX_ATTRIBUTE_LENGTH + 2]; _DtCvSegment *mySeg; if (attribs == NULL || process_flag == False) { /* * No attributes - is there cdata in here? */ if (flag || attribs != NULL) result = _DtHelpCeSkipCdata (my_struct->my_file, (cur_element == SdlElementDocType ? True : False)); /* * get the element's end. */ if (result != -1) result = _DtHelpCeGetSdlAttribute(my_struct->my_file, MAX_ATTRIBUTE_LENGTH, attribName); /* * _DtHelpCeGetSdlAttribute should return 1, meaning it found * the > */ if (result != 1) return -1; return 0; } /* * clean and initialize the attributes for this element. */ my_struct->el_info.enum_values = 0; my_struct->el_info.num_values = 0; my_struct->el_info.str1_values = 0; my_struct->el_info.str2_values = 0; mySeg = my_struct->add_seg; InitAttributes(mySeg, my_struct->my_fonts, &(my_struct->el_info), attribs); /* * clear the colJ and colW */ if (SdlElementForm == ElType(my_struct)) { ElTableColJStr(my_struct) = NULL; ElTableColWStr(my_struct) = NULL; } /* * force the default of subheading orientation to heads as below the head. */ if (ElType(my_struct) == SdlElementSubHead) _DtCvContainerVOrientOfSeg(mySeg) = _DtCvJUSTIFY_BOTTOM; do { result = _DtHelpCeGetSdlAttribute(my_struct->my_file, MAX_ATTRIBUTE_LENGTH, attribName); if (result == 0) result = ProcessSDLAttribute(my_struct, mySeg, my_struct->my_fonts, &(my_struct->el_info), attribs, attribName); } while (result == 0); if (result != -1) result = VerifyAttrList(&(my_struct->el_info), attribs); if (result != -1) { if (cur_element == SdlElementVirpage || SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CLASS) || SDLIsAttrSet(my_struct->el_info, SDL_ATTR_SSI) || SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LEVEL)) MergeTossInfo(my_struct, mySeg, my_struct->my_fonts); if (SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_LANGUAGE) || SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_CHARSET)) my_struct->mb_len = MB_CUR_MAX; /* * Do some specific work for containers. */ if (NULL != mySeg && _DtCvIsSegContainer(mySeg)) { /* * transfer any id or rid that got specified */ if (SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_ID) || SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_RID)) { _DtCvContainerIdOfSeg(mySeg) = ElId(my_struct); ClearAttrFlag(my_struct->el_info, SDL_ATTR_ID); ClearAttrFlag(my_struct->el_info, SDL_ATTR_RID); } /* * set the margins to absolute values */ if (my_struct->ui_info->avg_char > 0) { _DtCvContainerLMarginOfSeg(mySeg) = _DtCvContainerLMarginOfSeg(mySeg) * my_struct->ui_info->avg_char; _DtCvContainerRMarginOfSeg(mySeg) = _DtCvContainerRMarginOfSeg(mySeg) * my_struct->ui_info->avg_char; _DtCvContainerFMarginOfSeg(mySeg) = _DtCvContainerFMarginOfSeg(mySeg) * my_struct->ui_info->avg_char; } /* * set the container spacing to absolute values */ if (my_struct->ui_info->line_height / 2 > 0) { /* * TODO .... take maximum! of spacing. */ TMarginOfSeg(mySeg) = TMarginOfSeg(mySeg) * (my_struct->ui_info->line_height / 2); BMarginOfSeg(mySeg) = BMarginOfSeg(mySeg) * (my_struct->ui_info->line_height / 2); } /* * set the border width information */ if (_DtCvBORDER_NONE != _DtCvContainerBorderOfSeg(mySeg)) _DtCvContainerLineWidthOfSeg(mySeg) = my_struct->ui_info->line_width; } } if (result == 1) result = 0; return result; } /* End ParseElementAttr */ /****************************************************************************** * Function: int ParseElementEnd ( * FormatStruct my_struct, * int el_type); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page beginning. * ******************************************************************************/ static int ParseElementEnd( FormatStruct *my_struct, _DtCvSegment *if_prev, SDLElementInfo element, _DtCvValue process_flag, _DtCvValue end_flag) { char *id; _DtCvSegment *newSeg; _DtCvSegment *segList; if (MatchSDLElement (my_struct, element.element_end_str, element.sdl_element, element.end_sig_chars, True) != 0 || (end_flag == False && _DtHelpCeFindSkipSdlElementEnd(my_struct->my_file) != 0)) return -1; if (process_flag == True) { _DtCvSegment *pElement = my_struct->add_seg; /* * if we aren't resolving the fonts for this element, * we need to save the toss information for later * when the element gets used in a table or snref. */ if (_SdlFontModeResolve != my_struct->resolve_font && (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CLASS) || SDLIsAttrSet(my_struct->el_info, SDL_ATTR_SSI) || SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LEVEL))) { SdlMatchData *match; /* * was a segment allocated for this element? * if not, we'll have to put our own special segment * around the segment list so the correct font inheritance * occurs. Later, this special segment will have to be * stripped out when the async blocks or snref item * is resolved. */ if (NULL == pElement) { if (_DtHelpCeAllocSegment(1, NULL, NULL, &pElement) != 0) return -1; pElement->type = _DtCvSetTypeToContainer(pElement->type); pElement->type = SetSdlWrapper(pElement->type); _DtCvContainerListOfSeg(pElement) = my_struct->seg_list; my_struct->seg_list = pElement; } /* * has match data already been allocated for this element? */ match = SegMatchDataPtr(pElement); if (NULL == match) { match = (SdlMatchData *) malloc(sizeof(SdlMatchData)); if (NULL == match) return -1; } /* * save the clan, level and ssi of this element. */ *match = my_struct->el_info.match; SegMatchData(pElement) = (void *) match; ClearAttrFlag(my_struct->el_info, SDL_ATTR_SSI); } /* * attach the current segment list to the container's list */ if (NULL != pElement && _DtCvIsSegContainer(pElement)) _DtCvContainerListOfSeg(pElement) = my_struct->seg_list; /* * check to see if the element has any data. * If not, can it (the element) be eleminated and free up memory? */ if (NULL != pElement && my_struct->seg_list == NULL && element.elim_flag == True && ElType(my_struct) != SdlElementKey && TMarginOfSeg(pElement) == 0 && BMarginOfSeg(pElement) == 0) { _DtHelpFreeSegments(my_struct->add_seg, _DtCvFALSE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); if (ElType(my_struct) == SdlElementLink) _DtLinkDbRemoveLink(my_struct->my_links, my_struct->cur_link); my_struct->add_seg = NULL; } else { switch(ElType(my_struct)) { case SdlElementSnb: my_struct->add_seg = NULL; break; case SdlElementBlock: if (ElTiming(my_struct) == SdlTimingAsync) { if (NULL != my_struct->add_seg) AddToAsyncList(my_struct, my_struct->add_seg); my_struct->add_seg = NULL; } break; case SdlElementHead: case SdlElementSubHead: if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_ABBREV) && ElAbbrev(my_struct) != NULL && strlen(ElAbbrev(my_struct))) { AbbrevOfSeg(my_struct->add_seg) = (void *) ElAbbrev(my_struct); ClearAttrFlag(my_struct->el_info, SDL_ATTR_ABBREV); } break; case SdlElementFdata: ElTableList(my_struct) = ConvertToList(my_struct->seg_list); break; case SdlElementLink: CompressLinkSeg(my_struct->seg_list); case SdlElementKey: case SdlElementSphrase: /* * move the content of the element up. */ my_struct->add_seg = my_struct->seg_list; /* * free the no longer needed segments. */ if (NULL != pElement) { _DtCvContainerListOfSeg(pElement) = NULL; _DtHelpFreeSegments(pElement, _DtCvFALSE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); } break; case SdlElementForm: /* * get the segment list. */ newSeg = ElTable(my_struct); /* * include any async blocks into the table list. */ if (ResolveAsyncBlock(my_struct, newSeg) != 0) return -1; /* * compress the table if possible down to just * a container. */ newSeg = CompressTable(my_struct, newSeg); /* * add the table segment to the form's container list * taking into account any heads for the form. */ _DtCvNextSeg(newSeg) = _DtCvContainerListOfSeg(pElement); _DtCvContainerListOfSeg(pElement) = newSeg; break; case SdlElementIf: if (ResolveIf (my_struct, if_prev)) return -1; break; case SdlElementSnRef: /* * get the id of snref */ id = NULL; if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_ID)) id = _DtCvContainerIdOfSeg(pElement); /* * Resolve the snref to one of its items */ newSeg = ResolveSnref(my_struct, pElement, id); /* * if the snref got resolved, process * otherwise, let it pass through. We'll try to * resolve it later. */ if (newSeg != pElement) { /* * remember the segment list that we want * to free. This includes the snref. */ segList = pElement; /* * if this had an id with it, then * expand the to a marker segment * (with the id) and a resolved refitem. * * Otherwise, eliminate the container. */ if (NULL != id) { /* * remember the segment list of the container. * Since we are re-using the snref segment, * we want to eliminate just the refitems of * the snref and not the actual snref. */ segList = _DtCvContainerListOfSeg(pElement); /* * Move the refitem to be a sibling of the * container. */ _DtCvNextSeg(pElement) = newSeg; /* * transfer the container id to a marker id * and change the container into a marker. */ _DtCvIdOfMarkerSeg(pElement) = _DtCvContainerIdOfSeg(pElement); pElement->type = _DtCvSetTypeToMarker(pElement->type); newSeg = pElement; } /* * free the no longer needed segments. */ _DtHelpFreeSegments(segList, _DtCvFALSE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); } my_struct->add_seg = newSeg; break; } } /* * free the attributes for this element */ FreeAttributes(ElType(my_struct), &(my_struct->el_info), my_struct->my_fonts); /* * if this element can pull in new fonts, then a new font * structure was allocated for this element. Since we are * leaving the element, place the font structure in the * free list for possible reuse. */ if (element.new_fonts && FreeFontInfo(my_struct) == -1) return -1; } else my_struct->add_seg = my_struct->seg_list; if (element.formatting == True) my_struct->prev_data = NULL; return 0; } /* End ParseElementEnd */ /****************************************************************************** * * SDL Element Content Functions * *****************************************************************************/ /****************************************************************************** * Function: int FindAndFix ( * _DtCvSegment *toss, * _DtCvSegment *snb, * _DtCvSegment *seg_list) * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: * ******************************************************************************/ static int FindAndFix( FormatStruct *my_struct) { int curLink = my_struct->cur_link; _DtCvSegment *newSeg; _DtCvSegment *prevData = my_struct->prev_data; _DtCvSegment *lastSeg = my_struct->last_seg; _DtCvSegment *tmpSeg; _DtHelpFontHints *oldFonts = my_struct->my_fonts; /* * If the head has an snref in it, get the snb and resolve them */ if (0 < my_struct->snref_cnt) { UnresSnref *snref = my_struct->un_snrefs; while (my_struct->snref_cnt) { /* * reset the structure to what it was at the time * this snref was encountered. */ my_struct->prev_data = NULL; my_struct->last_seg = NULL; my_struct->my_fonts = &(snref->fonts); my_struct->cur_link = snref->cur_link; /* * resolve it. */ newSeg = ResolveSnref(my_struct, snref->seg, NULL); /* * free the snref items */ _DtHelpFreeSegments(_DtCvContainerListOfSeg(snref->seg), _DtCvFALSE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); /* * find the end of the new segment's and have it point to * the next segments that the old segment points to. */ if (NULL != newSeg) { tmpSeg = newSeg; while (NULL != _DtCvNextSeg(tmpSeg)) tmpSeg = _DtCvNextSeg(tmpSeg); _DtCvNextSeg(tmpSeg) = _DtCvNextSeg(snref->seg); _DtCvNextDisp(tmpSeg) = _DtCvNextDisp(snref->seg); } /* * does the snref have an id? */ if (NULL != snref->id) { /* * re-use the old snref, turning it into a marker */ _DtCvIdOfMarkerSeg(snref->seg) = snref->id; snref->seg->type = _DtCvSetTypeToMarker(snref->seg->type); /* * set the next pointers on the old segment to * the new segment. */ if (NULL != newSeg) { _DtCvNextSeg(snref->seg) = newSeg; _DtCvNextDisp(snref->seg) = newSeg; } } /* * else move the resolved segment on top of the old snref. */ else if (NULL != newSeg) { /* * free the private information. No longer needed. */ free(snref->seg->client_use); /* * now trounce the snref segment info. */ *(snref->seg) = *newSeg; /* * free the duplicate new segment. */ if (_DtCvIsSegContainer(newSeg)) _DtCvContainerListOfSeg(newSeg) = NULL; free(newSeg); } /* * else there was no resolution, leave this segment as a NOOP. */ /* * go to the next unresolved snref */ snref++; my_struct->snref_cnt--; } free(my_struct->un_snrefs); my_struct->un_snrefs = NULL; } my_struct->cur_link = curLink; my_struct->prev_data = prevData; my_struct->last_seg = lastSeg; my_struct->my_fonts = oldFonts; return 0; } /****************************************************************************** * Function: char *GetInterpCmd (SdlOption interp_type); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Return the command associated with the interpreter type. * ******************************************************************************/ static char * GetInterpCmd(SdlOption interp_type) { const _CEInterpData *interp = InterpData; while (interp->type != _DtCvOPTION_BAD) { if (interp->type == interp_type) return interp->cmd; interp++; } return NULL; } /****************************************************************************** * Function: int CheckForSnb ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int CheckForSnb( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { int result = 0; /* * If the head has an snref in it, get the snb and resolve them */ if (my_struct->snref_used == True) { _DtCvSegment *oldSegList = my_struct->seg_list; _DtCvSegment *oldAddSeg = my_struct->add_seg; _DtCvSegment *oldPrevSeg = my_struct->prev_data; _DtCvSegment *oldLastSeg = my_struct->last_seg; my_struct->seg_list = NULL; my_struct->add_seg = NULL; my_struct->prev_data = NULL; my_struct->last_seg = NULL; result = ProcessSDLMarkup(my_struct, SdlElementSnb, SdlElementNone, exceptions, process_mask); my_struct->seg_list = oldSegList; my_struct->add_seg = oldAddSeg; my_struct->prev_data = oldPrevSeg; my_struct->last_seg = oldLastSeg; /* * if no problems getting the snb, go through the items and * resolve the snrefs. */ if (result != -1) result = FindAndFix(my_struct); } return result; } /* End CheckForSnb */ /****************************************************************************** * Function: int SetSaveSnref ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int SetSaveSnref( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { my_struct->save_snref = _DtCvTRUE; return 0; } /* End SetSaveSnref */ /****************************************************************************** * Function: int ClearAndCheckSnref ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int ClearAndCheckSnref( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { int result = 0; /* * reset the flag for saving snref elements */ my_struct->save_snref = _DtCvFALSE; /* * was any snrefs found? If so, resolve them now. */ if (my_struct->snref_used == True) result = FindAndFix(my_struct); return result; } /* End ClearAndCheckSnref */ /****************************************************************************** * Function: int CheckType ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int CheckType( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { SdlOption newOpt; /* * cannot honor newlines in super or sub scripts. */ newOpt = ElFrmtType(my_struct); if (SdlTypeLiteral == newOpt) newOpt = SdlTypeUnlinedLiteral; else if (SdlTypeLined == newOpt) newOpt = SdlTypeDynamic; ElFrmtType(my_struct) = newOpt; if (SdlTypeDynamic != newOpt) my_struct->flags = _DtCvSetTypeToNonBreak(my_struct->flags); if (SdlClassSub == ElClan(my_struct)) my_struct->flags = _DtCvSetTypeToSubScript(my_struct->flags); else if (SdlClassSuper == ElClan(my_struct)) my_struct->flags = _DtCvSetTypeToSuperScript(my_struct->flags); /* * strip hypertext links */ my_struct->cur_link = -1; return 0; } /* End CheckType */ /****************************************************************************** * Function: int SetType ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int SetType( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { if (ElType(my_struct) == SdlElementSphrase) { ContainerPtrToType(my_struct->active_frmt) = (_DtCvFrmtOption) SdlTypeLiteral; ElFrmtType(my_struct) = SdlTypeLiteral; my_struct->flags = 0; } else ElFrmtType(my_struct) = SdlTypeCdata; if (SdlElementScript == ElType(my_struct)) { /* * remember the interpretor value */ FrmtPrivateInfo *priv = FrmtPrivInfoPtr(my_struct->add_seg); priv->interp = ElInterp(my_struct); } return 0; } /* End SetType */ /****************************************************************************** * Function: int ElseInfo ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int IfInfo( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { if (ElType(my_struct) == SdlElementIf) { my_struct->then_prev = NULL; my_struct->else_prev = NULL; } else if (ElType(my_struct) == SdlElementThen) my_struct->then_prev = my_struct->prev_data; else /* if (ElType(my_struct) == SdlElementElse) */ my_struct->else_prev = my_struct->prev_data; return 0; } /* End IfInfo */ /****************************************************************************** * Function: int MarkFound ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int MarkFound( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { my_struct->snref_used = True; /* * is there a newline hanging around that needs turning into a space? */ if (SDLSearchMask(process_mask, SdlElementCdata) && my_struct->last_was_space == False && my_struct->last_was_nl == True) { _DtCvSegment *pSeg = my_struct->prev_data; /* * tack the space onto the end of previous string if possible. */ if (pSeg != NULL && _DtCvIsSegString(pSeg) && _DtCvIsSegRegChar(pSeg) && !(_DtCvIsSegNewLine(pSeg))) { char *strPtr; int len = _DtCvStrLen(_DtCvStringOfStringSeg(pSeg), 0); _DtCvStringOfStringSeg(pSeg) = (char *) realloc( _DtCvStringOfStringSeg(pSeg), len+2); if (_DtCvStringOfStringSeg(pSeg) == NULL) return -1; strPtr = (char *) _DtCvStrPtr(_DtCvStringOfStringSeg(pSeg), 0, len); *strPtr++ = ' '; *strPtr = '\0'; } else if (MySaveString(&(my_struct->seg_list), my_struct, " ", my_struct->cur_link, 1, False ) != 0) return -1; my_struct->last_was_space = True; my_struct->last_was_nl = False; } return 0; } /* End MarkFound */ /****************************************************************************** * Function: int SaveItemInfo ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int SaveItemInfo( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { _DtCvSegment *refItem = my_struct->add_seg; SdlMatchData *info; if (SDLSearchMask(process_mask, SdlElementRefItem) == False) return 0; info = (SdlMatchData *) malloc (sizeof(SdlMatchData)); if (NULL == info) return -1; /* * save the clan, ssi & level of this refitem */ *info = my_struct->el_info.match; SegMatchData(refItem) = (void *) info; ClearAttrFlag(my_struct->el_info, SDL_ATTR_SSI); return 0; } /* End SaveItemInfo */ /****************************************************************************** * Function: int AllocateBlock ( * FormatStruct my_struct, * int element_types, * int exceptions); * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: * ******************************************************************************/ static int AllocateBlock( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { /* * allocate a block of information all at once for later segments. * This, hopefully, will save processing time when later freed. * * Simply change the malloc_size in the formatting struct. */ if (my_struct->add_seg != NULL) { if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_COUNT)) my_struct->malloc_size = ElCount(my_struct); else { my_struct->malloc_size = 500; if (ElType(my_struct) == SdlElementToss) my_struct->malloc_size = 160; } } return 0; } /* End AllocateBlock */ /****************************************************************************** * Function: int CleanUpBlock ( * FormatStruct my_struct, * int element_types, * int exceptions); * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: * ******************************************************************************/ static int CleanUpBlock( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { /* * Go back to piece meal allocation. */ my_struct->malloc_size = 1; return 0; } /* End CleanUpBlock */ /****************************************************************************** * Function: int RegisterLink ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int RegisterLink( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { int winType = _DtCvWindowHint_CurrentWindow; SDLId rid = _DtCvContainerIdOfSeg(my_struct->add_seg); if (SDLSearchMask(process_mask, SdlElementLink) == False) return 0; switch (ElWindow(my_struct)) { case SdlWindowNew: winType = _DtCvWindowHint_NewWindow; break; case SdlWindowPopup: winType = _DtCvWindowHint_PopupWindow; break; } my_struct->cur_link = _DtLinkDbAddLink(my_struct->my_links, NULL, rid, _DtCvLinkType_SameVolume, winType, NULL); if (rid == NULL || my_struct->cur_link < 0) return -1; /* * indicate that at least a blank should be saved for the link */ my_struct->save_blank = True; return 0; } /* End RegisterLink */ /****************************************************************************** * Function: int ResolveIf (FormatStruct my_struct) * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int ResolveIf( FormatStruct *my_struct, _DtCvSegment *prev_data) { _DtCvSegment *ifSeg = my_struct->add_seg; _DtCvSegment *condSeg = _DtCvContainerListOfSeg(ifSeg); _DtCvSegment *condDataSeg = _DtCvContainerListOfSeg(condSeg); _DtCvSegment *thenSeg = _DtCvNextSeg(condSeg); _DtCvSegment *elseSeg = _DtCvNextSeg(thenSeg); _DtCvSegment *resolveSeg = NULL; _DtCvSegment *nextDisp = NULL; _DtCvSegment *el = NULL; char *ifData = NULL; char *interpStr; interpStr = GetInterpCmd(ElInterp(my_struct)); if (NULL == interpStr) return -1; if (_DtCvRunInterp(my_struct->ui_info->exec_filter, my_struct->ui_info->client_data, interpStr, _DtCvStringOfStringSeg(condDataSeg), &ifData) == 0) { /* * Get the pointer to the next displayable item in the 'then' * list. This usually will point into the 'then' list, * but may point into the 'else' list. */ if (my_struct->then_prev != NULL) nextDisp = my_struct->then_prev->next_disp; /* * use the 'then' data */ if (atoi (ifData) != 0) { el = thenSeg; /* * check to make sure that the next_disp is NOT into the * 'else' list (because it's about to become a dangling * next_disp if it is!). */ if (elseSeg != NULL) { /* * if the next displayable segment is in the 'else' * list, null out the next displayable segement since * there isn't anything in the 'then' list. */ if (my_struct->then_prev == my_struct->else_prev) nextDisp = NULL; else /* * terminate the displayable segment list * before the 'else' list. */ my_struct->else_prev->next_disp = NULL; } } else if (elseSeg != NULL) { /* * use the 'else' data. */ el = elseSeg; /* * Get the next displayable item in the 'else' list. */ if (my_struct->else_prev != NULL) nextDisp = my_struct->else_prev->next_disp; } if (el != NULL) { resolveSeg = _DtCvContainerListOfSeg(el); _DtCvContainerListOfSeg(el) = NULL; } free(ifData); } /* * set the true next displayable pointer. */ if (prev_data != NULL) prev_data->next_disp = nextDisp; /* * set the previous displayable segment to the last displayable * segment in the 'if' clause; in case more displayable segments * follow. */ my_struct->prev_data = nextDisp; /* * free the no longer needed if construct */ _DtHelpFreeSegments(my_struct->add_seg, _DtCvFALSE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); /* * set the add segment to the result of the if */ my_struct->add_seg = resolveSeg; return 0; } /* End ResolveIf */ /****************************************************************************** * Function: int ZeroOrOne ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int ZeroOrOne( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { int result = 0; if (my_struct->parsed == SdlElementNone) result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList, SDLSearchMask(element_types, SdlElementCdata), &(my_struct->parsed), &(my_struct->remember), &(my_struct->end_flag)); if (result == 0 && my_struct->end_flag == False && SDLSearchMask(element_types, my_struct->parsed) == True) { /* * check to make sure this is *not* Cdata or if it is that the * PcDataFollows flag is *not* set. */ if (my_struct->parsed != SdlElementCdata || SDLSearchMask(element_types, SdlPcDataFollows) == False) result = ParseSDL(my_struct, my_struct->parsed, sig_element, exceptions, process_mask); } else if (result == 1) /* eof on compressed entry/file */ result = 0; return result; } /* End ZeroOrOne */ /****************************************************************************** * Function: int ZeroToN ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int ZeroToN( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { _DtCvValue done = False; int result = 0; while (result == 0 && !done) { if (my_struct->parsed == SdlElementNone) result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList, SDLSearchMask(element_types, SdlElementCdata), &(my_struct->parsed), &(my_struct->remember), &(my_struct->end_flag)); if (result == 0 && my_struct->end_flag == False && SDLSearchMask(element_types, my_struct->parsed) == True) { /* * check to make sure this is *not* Cdata or if it is that the * PcDataFollows flag is *not* set. */ if (my_struct->parsed != SdlElementCdata || SDLSearchMask(element_types, SdlPcDataFollows) == False) result = ParseSDL(my_struct, my_struct->parsed, sig_element, exceptions, process_mask); else done = True; } else { if (result == 1) /* eof on compressed entry/file */ result = 0; done = True; } } return result; } /* End ZeroToN */ /****************************************************************************** * Function: int OneToN ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int OneToN( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { int found = False; int result = 0; int done = False; while (result == 0 && !done) { if (my_struct->parsed == SdlElementNone) result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList, SDLSearchMask(element_types, SdlElementCdata), &(my_struct->parsed), &(my_struct->remember), &(my_struct->end_flag)); if (result == 0 && my_struct->end_flag == False && SDLSearchMask(element_types, my_struct->parsed) == True) { found = True; result = ParseSDL(my_struct, my_struct->parsed, sig_element, exceptions, process_mask); } else done = True; } if (!found) result = -1; return result; } /* End OneToN */ /****************************************************************************** * Function: int OnlyOne ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int OnlyOne( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { _DtCvValue found = False; int result = 0; if (my_struct->parsed == SdlElementNone) result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList, SDLSearchMask(element_types, SdlElementCdata), &(my_struct->parsed), &(my_struct->remember), &(my_struct->end_flag)); if (result == 0 && my_struct->end_flag == False && SDLSearchMask(element_types, my_struct->parsed) == True) { found = True; result = ParseSDL(my_struct, my_struct->parsed, sig_element, exceptions, process_mask); } if (!found) result = -1; return result; } /* End OnlyOne */ /****************************************************************************** * Function: int OnlyOneEach ( * FormatStruct my_struct, * int element_types, * int exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int OnlyOneEach( FormatStruct *my_struct, SDLMask *element_types, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { int result = 0; enum SdlElement myEl; SDLMask myMask[SDL_MASK_LEN]; SaveRestoreMask(myMask, element_types); while (result == 0 && SDLCheckMask(myMask)) { if (my_struct->parsed == SdlElementNone) result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList, SDLSearchMask(myMask, SdlElementCdata), &(my_struct->parsed), &(my_struct->remember), &(my_struct->end_flag)); if (result == 0 && my_struct->end_flag == False && SDLSearchMask(element_types, my_struct->parsed) == True) { myEl = my_struct->parsed; result = ParseSDL(my_struct, my_struct->parsed, sig_element, exceptions, process_mask); SDLStripFromMask(myMask, myEl); } else result = -1; } if (SDLCheckMask(myMask)) result = -1; return result; } /* End OnlyOneEach */ /****************************************************************************** * Function: int Cdata (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int Cdata( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { int i; int reason; int myLen = 0; int curLen = my_struct->mb_len; int multiLen = my_struct->mb_len; int saveLen = my_struct->mb_len; char nonBreakChar; char *string = NULL; char spaceStr[] = " "; char dashStr[] = "-"; SdlOption type = ElFrmtType(my_struct); _DtCvSegment *pSeg = NULL; _DtCvValue nlToSpace = True; _DtCvValue processFlag = SDLSearchMask(process_mask, SdlElementCdata); if (my_struct->ui_info->nl_to_space == 0) nlToSpace = False; if (type == SdlTypeCdata) { /* * the element requires straight cdata for processing - i.e. * the data is going to be passed off to an interperter. * Therefore it doesn't want it broken up into different * byte length segments. * * Therefore, force the string save to put all the data into * one string. */ saveLen = 1; } if (my_struct->remember != NULL) { i = 0; string = my_struct->remember; myLen = strlen(string); while (string[i] != '\0' && i < myLen) { if (multiLen != 1) curLen = mblen (&string[i], multiLen); if (curLen == 1) { if (my_struct->last_was_nl == True) { if (MoveString(&string, &myLen, &i) == -1) return -1; string[i++] = ' '; my_struct->last_was_space = True; } my_struct->last_was_nl = False; my_struct->last_was_mb = False; if (string[i] == '\t') string[i] = ' '; if (string[i] == '&') { strmove (&string[i], &string[i+1]); if (string[i] == '\0') { string[i] = BufFileGet(my_struct->my_file); if (string[i] == BUFFILEEOF) return -1; string[i+1] = '\0'; } /* * is this an SGML numeric character reference * entity? if so, it should have the format * '&#d[d[d]][;]' where 'ddd' represent characters * of '0' to '9'. The semi-colon is required iff * the next character is a numeric character of '0' * to '9'. Otherwise it is optional. */ if (string[i] == '#') { int j; int value; #define ESC_STRING_LEN 4 i++; /* * Is there enough to room to process three digits * and a possible semi-colon? */ if (myLen - i < ESC_STRING_LEN) { /* * lengthen the string so that it can contain * the information */ myLen += ESC_STRING_LEN; string = (char *) realloc(string, sizeof(char) * (myLen + 1)); if (string == NULL) return -1; } /* * now make sure that the entire numeric entity * exists in the string. */ j = i; while ('0' <= string[i] && string[i] <= '9') i++; /* * run into the end of string before running * into a delimiter? Fill out the escaped * numeric character. */ if (string[i] == '\0') { do { string[i] = BufFileGet(my_struct->my_file); if (string[i] == BUFFILEEOF) return -1; i++; } while (i < myLen && '0' <= string[i-1] && string[i-1] <= '9'); /* * end the string and back up to the last * character */ string[i] = '\0'; i--; } /* * the fourth character is a numeric, error */ if ('0' <= string[i] && string[i] <= '9') return -1; if (string[i] == ';') i++; value = atoi(&string[j]); if (value > 255) return -1; /* * smash over the pound sign with the 'real' value * and copy the rest of the string to after it. */ string[j-1] = (char) value; strmove (&string[j], &string[i]); i = j; } if (string[i] == '\n') { if (ProcessString(my_struct, True, True, True, True, processFlag, string, saveLen, &i) != 0) return -1; } else if (string[i] == ' ') { if (ProcessNonBreakChar(my_struct, processFlag, spaceStr, string, saveLen, &i) != 0) return -1; } else if (string[i] == '-') { if (ProcessNonBreakChar(my_struct, processFlag, dashStr, string, saveLen, &i) != 0) return -1; } else my_struct->last_was_space = False; i++; } else if (string[i] == '\n') { /* * want to keep the newlines */ if (type == SdlTypeCdata) i++; else if (type == SdlTypeDynamic || type == SdlTypeUnlinedLiteral) { if (my_struct->last_was_space == False) my_struct->last_was_nl = True; strmove (&string[i], &string[i+1]); } else { string[i] = '\0'; if (processFlag == True && MySaveString(&(my_struct->seg_list), my_struct, string, my_struct->cur_link, saveLen, True) != 0) { MyFree(string); return -1; } strmove (string, &string[i+1]); i = 0; } } else if (string[i] == ' ') { if (False == my_struct->save_blank && type != SdlTypeLiteral && type != SdlTypeUnlinedLiteral && my_struct->last_was_space == True) strmove (&string[i], &string[i+1]); else i++; my_struct->last_was_space = True; } else { my_struct->last_was_space = False; i++; } } else if (curLen > 0) { if (my_struct->last_was_nl == True) { if (nlToSpace == True || my_struct->last_was_mb == False) { if (MoveString(&string, &myLen, &i) == -1) return -1; string[i++] = ' '; } else /* the last was a multibyte character, tighten up */ { i--; strmove (&string[i], &string[i+1]); } } my_struct->last_was_space = False; my_struct->last_was_nl = False; my_struct->last_was_mb = True; i += curLen; } else if (curLen == 0) return -1; else /* if (curLen < 0) */ { /* * must finish up the character */ int len = 0; myLen = strlen(string); string = (char *) realloc(string, myLen + multiLen + 1); if (string == NULL) return -1; while (curLen < 0 && len < multiLen) { string[myLen] = BufFileGet(my_struct->my_file); if (string[myLen] == BUFFILEEOF) return -1; string[myLen + 1] = '\0'; curLen = mblen(&string[i], multiLen); ++len; ++myLen; } if (curLen < 0) return -1; } } if (processFlag == False) { free(string); string = NULL; myLen = 0; } my_struct->remember = NULL; } do { my_struct->parsed = SdlElementNone; reason = _DtHelpCeGetSdlCdata(my_struct->my_file, type, multiLen, nlToSpace, &my_struct->last_was_space, &my_struct->last_was_nl, &my_struct->last_was_mb, &nonBreakChar, (processFlag == True ? &string : ((char**)NULL)), &myLen); if (reason < 0) return -1; if (string != NULL && *string != '\0') { /* * save the string. */ if (MySaveString(&(my_struct->seg_list), my_struct, string, my_struct->cur_link, saveLen, (1 == reason ? True : False)) != 0) { MyFree(string); return -1; } /* * indicate that a string was saved for the current link */ my_struct->save_blank = False; /* * null the temp buffer. */ string[0] = '\0'; /* * reset flags if we stopped because of a newline. */ if (1 == reason && (SdlTypeLiteral == type || SdlTypeLined == type)) { my_struct->last_was_space = True; my_struct->last_was_nl = False; } } else if (reason == 1) /* stopped because of newline */ { pSeg = my_struct->prev_data; if (pSeg == NULL || _DtCvIsSegNewLine(pSeg)) { if (_DtHelpCeAllocSegment(my_struct->malloc_size, &(my_struct->alloc_size), &(my_struct->block_list), &pSeg) != 0) return -1; pSeg->type = _DtCvSetTypeToNoop(pSeg->type); if (my_struct->prev_data != NULL) my_struct->prev_data->next_disp = pSeg; my_struct->prev_data = pSeg; _DtHelpCeAddSegToList(pSeg, &(my_struct->seg_list), &(my_struct->last_seg)); } pSeg->type = _DtCvSetTypeToNewLine(pSeg->type); my_struct->last_was_space = True; my_struct->last_was_nl = False; } /* * did we stop because of a non-breaking character? */ if (2 == reason && True == processFlag) { /* * copy the non breaking character into a buffer. */ if (1 > myLen) { string = (char *) malloc (sizeof(char) * 32); myLen = 32; } string[0] = nonBreakChar; string[1] = '\0'; /* * save the string. */ my_struct->flags = _DtCvSetTypeToNonBreak(my_struct->flags); if (MySaveString(&(my_struct->seg_list), my_struct, string, my_struct->cur_link, saveLen, False) != 0) { MyFree(string); return -1; } my_struct->flags = my_struct->flags & ~(_DtCvNON_BREAK); /* * indicate that the non-breaking character is considered * non-white space. */ my_struct->last_was_space = False; /* * indicate that a string was saved for the current link */ my_struct->save_blank = False; /* * null the temp buffer. */ string[0] = '\0'; } } while (reason > 0); MyFree(string); return 0; } /* End Cdata */ /****************************************************************************** * Function: int ProcessEnterAttr ( * FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: * ******************************************************************************/ static int ProcessEnterAttr( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { /* * save the enter string as part of this element's segment list */ if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_ENTER) && ((int)strlen(ElEnter(my_struct))) > 0 && MySaveString(&(my_struct->seg_list), my_struct, ElEnter(my_struct), my_struct->cur_link, my_struct->mb_len, False) != 0) return -1; return 0; } /* End ProcessEnterAttr */ /****************************************************************************** * Function: int ProcessExitAttr ( * FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: * ******************************************************************************/ static int ProcessExitAttr( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { /* * save the exit string as part of this element's segment list */ if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_EXIT) && ((int)strlen(ElExit(my_struct))) > 0 && MySaveString(&(my_struct->seg_list), my_struct, ElExit(my_struct), my_struct->cur_link, my_struct->mb_len, False) != 0) return -1; return 0; } /* End ProcessExitAttr */ /****************************************************************************** * Function: int FakeEnd (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int FakeEnd( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { my_struct->end_flag = True; my_struct->faked_end = True; MaskToValue(cur_element, my_struct->parsed); return 0; } /* End FakeEnd */ /****************************************************************************** * Function: int AddRowToTable (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int AddRowToTable( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { if (SDLSearchMask(process_mask, SdlElementFrowvec) != False) { ElTableCellIds(my_struct) = (char **) _DtCvAddPtrToArray( (void **) ElTableCellIds(my_struct), ElTableCellId(my_struct)); if (NULL == ElTableCellIds(my_struct)) return -1; ClearAttrFlag(my_struct->el_info, SDL_ATTR_CELLS); } return 0; } /* End AddRowToTable */ /****************************************************************************** * Function: int SaveLangCharSet ( * FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int SaveLangCharSet( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { char **info; if (SDLSearchMask(process_mask, SdlElementText) == False || !(SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LANGUAGE) || SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CHARSET))) return 0; info = (char **) calloc (2, sizeof(char *)); if (NULL == info) return -1; if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LANGUAGE)) info[0] = ElLanguage(my_struct); if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CHARSET)) info[1] = ElCharSet(my_struct); ClearAttrFlag(my_struct->el_info, SDL_ATTR_LANGUAGE); ClearAttrFlag(my_struct->el_info, SDL_ATTR_CHARSET); _SdlSegLangChar(my_struct->add_seg) = (void *) info; return 0; } /* End SaveLangCharSet */ /****************************************************************************** * Function: int CopyDocInfo (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int CopyDocInfo( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { SDLDocInfo *docInfo; if (SDLSearchMask(process_mask, SdlElementSdlDoc) == False) return 0; docInfo = (SDLDocInfo *) malloc (sizeof(SDLDocInfo)); if (NULL == docInfo) return -1; *(docInfo) = ElDocInfo(my_struct); _SdlDocInfoPtrLanguage(docInfo) = strdup(ElLanguage(my_struct)); _SdlDocInfoPtrCharSet(docInfo) = strdup(ElCharSet(my_struct)); ClearAttrFlag(my_struct->el_info, SDL_ATTR_DOCID); ClearAttrFlag(my_struct->el_info, SDL_ATTR_SDLDTD); ClearAttrFlag(my_struct->el_info, SDL_ATTR_TIMESTAMP); ClearAttrFlag(my_struct->el_info, SDL_ATTR_FRST_PG); ClearAttrFlag(my_struct->el_info, SDL_ATTR_VERSION); FrmtPrivInfoPtr(my_struct->add_seg)->doc_info = (void *) docInfo; return 0; } /* End CopyDocInfo */ /****************************************************************************** * Function: int CopyAnchorId (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int CopyAnchorId( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { _DtCvSegment *mySeg = my_struct->add_seg; /* * if we're not suppose to process this, skip. */ if (SDLSearchMask(process_mask, SdlElementAnchor) == False) return 0; /* * copy the id. */ _DtCvIdOfMarkerSeg(mySeg) = ElId(my_struct); /* * clear the flag so that it don't get freed. */ ClearAttrFlag(my_struct->el_info, SDL_ATTR_ID); return 0; } /* End CopyDocInfo */ /****************************************************************************** * Function: int LoadGraphic ( * FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int LoadGraphic( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { int result = 0; if (SDLSearchMask(process_mask, SdlElementGraphic) != False) { /* * get my container segment. */ _DtCvSegment *mySeg = my_struct->add_seg; _DtCvSegment *cvRegion; /* Canvas Engine Region */ result = -1; /* * allocate a Canvas Engine region. */ if (_DtHelpCeAllocSegment(1, NULL, NULL, &cvRegion) == 0) { /* * got memory for a region, now fill out the information. * * even if the load fails, we should just throw away * the graphic and continue. */ result = 0; if (NULL != my_struct->ui_info->load_graphic && (*(my_struct->ui_info->load_graphic))( my_struct->ui_info->client_data, my_struct->vol_name, my_struct->id_string, ElSnbXid(my_struct), ElSnbFormat(my_struct), ElSnbMethod(my_struct), &(_DtCvWidthOfRegionSeg(cvRegion)), &(_DtCvHeightOfRegionSeg(cvRegion)), &(_DtCvInfoOfRegionSeg(cvRegion))) == 0) { /* * set the type on the region! And its ascent! */ cvRegion->type = _DtCvSetTypeToRegion(cvRegion->type); _DtCvAscentOfRegionSeg(cvRegion) = -1; /* * set the seg list for the wrapper container. */ _DtCvContainerListOfSeg(mySeg) = cvRegion; /* * indicate the link has been fixed up */ my_struct->save_blank = True; } else { /* * problems loading the graphic. Clean up! */ MyFree(cvRegion); } } } return result; } /* End LoadGraphic */ /****************************************************************************** * Function: int ColInfoToTableInfo ( * FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int ColInfoToTableInfo( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { if (SDLSearchMask(process_mask, SdlElementForm) != False) { int i; int mySize = ElTableColNum(my_struct); const char *next; const char *start = NULL; const char *last = NULL; char **colWidths = NULL; _DtCvFrmtOption *colJust; colWidths = (char **) malloc (sizeof(char *) * mySize); colJust = (_DtCvFrmtOption *) malloc (sizeof(_DtCvFrmtOption)*mySize); if (NULL == colWidths || NULL == colJust) { MyFree(colWidths); MyFree(colJust); return -1; } /* * now process the column width specification. */ next = ElTableColWStr(my_struct); if (NULL == next || '\0' == *next) next = "1"; for (i = 0; i < mySize; i++) { /* skip the leading spaces */ while (' ' == *next) next++; /* if the string really moved */ if (last != next) start = next; /* go to the end of this specification */ while (' ' != *next && '\0' != *next) next++; /* duplicate the specification */ colWidths[i] = strdup(start); if (NULL == colWidths[i]) return -1; /* mark the end of the string */ last = next; } /* * now process the column justify specification. */ next = ElTableColJStr(my_struct); if (NULL == next || '\0' == *next) next = NullOption; for (i = 0; i < mySize; i++) { /* skip the leading spaces */ while (' ' == *next) next++; /* if the string really moved */ if (last != next) start = next; /* go to the end of this specification */ while (' ' != *next && '\0' != *next) next++; /* determine the justification */ switch (*start) { case 'r': case 'R': colJust[i] = _DtCvJUSTIFY_RIGHT; break; case 'c': case 'C': colJust[i] = _DtCvJUSTIFY_CENTER; break; case 'd': case 'D': colJust[i] = _DtCvJUSTIFY_NUM; break; case 'l': case 'L': colJust[i] = _DtCvJUSTIFY_LEFT; break; default : colJust[i] = _DtCvJUSTIFY_LEFT; if (NullOption == start) colJust[i] = _DtCvINHERIT; break; } /* mark the end of the string */ last = next; } ElTableColWidths(my_struct) = colWidths; ElTableColJust(my_struct) = colJust; } return 0; } /* End ColInfoToTableInfo */ /****************************************************************************** * Function: int CopyIdInfo (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int CopyIdInfo( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { SDLIdInfo *idInfo; if (SDLSearchMask(process_mask, SdlElementId) == False) return 0; idInfo = (SDLIdInfo *) malloc (sizeof(SDLIdInfo)); if (NULL == idInfo) return -1; *(idInfo) = ElIdInfo(my_struct); _SdlIdInfoPtrType(idInfo) = ElFrmtType(my_struct); _SdlIdInfoPtrOffset(idInfo) = ElOffset(my_struct); _SdlIdInfoPtrRlevel(idInfo) = ElLevel(my_struct); _SdlIdInfoPtrRssi(idInfo) = ElSsi(my_struct); ClearAttrFlag(my_struct->el_info, SDL_ATTR_RID); ClearAttrFlag(my_struct->el_info, SDL_ATTR_RSSI); FrmtPrivInfoPtr(my_struct->add_seg)->id_info = (void *) idInfo; return 0; } /* End CopyIdInfo */ /****************************************************************************** * Function: int RegisterSnbLink (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int RegisterSnbLink( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { int linkType; int len = 0; char buffer[64] = ""; char *fileSpec = NULL; if (SDLSearchMask(process_mask, ElType(my_struct)) == False) return 0; fileSpec = ElSnbXid(my_struct); switch (ElType(my_struct)) { case SdlElementCrossDoc: linkType = _DtCvLinkType_CrossLink; break; case SdlElementManPage: linkType = _DtCvLinkType_ManPage; break; case SdlElementTextFile: if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_OFFSET)) { sprintf(buffer, " %d", ElOffset(my_struct)); len += strlen(buffer); } if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_FORMAT)) len += strlen(ElSnbFormat(my_struct)); /* * create a new file spec for the link */ if (0 < len) { len += strlen(ElSnbXid(my_struct) + 1); fileSpec = malloc(sizeof(char) * len); if (NULL == fileSpec) return -1; strcpy(fileSpec, ElSnbXid(my_struct)); strcat(fileSpec, buffer); strcat(fileSpec, ElSnbFormat(my_struct)); } linkType = _DtCvLinkType_TextFile; break; case SdlElementSysCmd: linkType = _DtCvLinkType_Execute; break; case SdlElementCallback: linkType = _DtCvLinkType_AppDefine; break; default: return -1; } if (0 > _DtLinkDbAddLink(my_struct->my_links, _DtCvContainerIdOfSeg(my_struct->add_seg), fileSpec, linkType, _DtCvWindowHint_Original, NULL)) return -1; if (fileSpec != ElSnbXid(my_struct)) free(fileSpec); return 0; } /* End RegisterSnbLink */ /****************************************************************************** * Function: int RegisterSwitch (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int RegisterSwitch( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { int result = -1; char *interpStr; if (SDLSearchMask(process_mask, ElType(my_struct)) == False) return 0; interpStr = GetInterpCmd(ElInterp(my_struct)); if (NULL != interpStr) interpStr = strdup(interpStr); if (NULL != interpStr) { if (0 == _DtLinkDbAddSwitch(my_struct->my_links, _DtCvContainerIdOfSeg(my_struct->add_seg), interpStr, _DtCvStringOfStringSeg(my_struct->add_seg), ElSwitchBranches(my_struct))) result = 0; free(my_struct->add_seg); my_struct->add_seg = NULL; } return result; } /* End RegisterSwitch */ /****************************************************************************** * Function: int ResolveSpcInfo (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int ResolveSpcInfo( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { _DtCvSegment *mySeg = my_struct->add_seg; if (SDLSearchMask(process_mask, ElType(my_struct)) != False) { /* * set the non break character flag so that the layout routines * will only wrap this to the next line if there is a space * before it. * * Also set the inline flag so that the layout routines don't * think that the region is a figure. */ mySeg->type = _DtCvSetTypeToNonBreak(mySeg->type); mySeg->type = _DtCvSetTypeToInLine(mySeg->type); /* * now establish the proper display linking. */ if (my_struct->prev_data != NULL) my_struct->prev_data->next_disp = mySeg; my_struct->prev_data = mySeg; my_struct->save_blank = False; /* * resolve the font hints. */ if (_SdlFontModeResolve == my_struct->resolve_font) (*(my_struct->ui_info->resolve_spc))( my_struct->ui_info->client_data, ElLanguage(my_struct), ElCharSet(my_struct), *(my_struct->my_fonts), ElSpcName(my_struct), &(_DtCvInfoOfRegionSeg(my_struct->add_seg)), &(_DtCvWidthOfRegionSeg(my_struct->add_seg)), &(_DtCvHeightOfRegionSeg(my_struct->add_seg)), &(_DtCvAscentOfRegionSeg(my_struct->add_seg))); else { _DtHelpDARegion *pReg; _DtHelpDASpcInfo *spcInfo; /* * malloc a structure to hold the spc */ pReg = (_DtHelpDARegion *) malloc (sizeof(_DtHelpDARegion)); if (NULL == pReg) return -1; /* * malloc the structure to hold the information needed to * create the spc later. */ spcInfo = (_DtHelpDASpcInfo *) calloc (1, sizeof(_DtHelpDASpcInfo)); if (NULL == spcInfo) { free(pReg); return -1; } /* * remember the spc's name and fonts */ spcInfo->name = ElSpcName(my_struct); if (_SdlFontModeSave == my_struct->resolve_font) { spcInfo->spc_fonts = *(my_struct->my_fonts); _DtHelpFontHintsLang(spcInfo->spc_fonts) = ElLanguage(my_struct); _DtHelpFontHintsCharSet(spcInfo->spc_fonts) = ElCharSet(my_struct); if (-1 == _DtHelpDupFontHints(&(spcInfo->spc_fonts))) return -1; } /* * remember the spc's name */ pReg->inited = False; pReg->type = _DtHelpDASpc; pReg->handle = (_DtCvPointer) spcInfo; _DtCvInfoOfRegionSeg(mySeg) = (_DtCvPointer) pReg; ClearAttrFlag(my_struct->el_info, SDL_ATTR_NAME); } } return 0; } /* End ResolveSpcInfo */ /****************************************************************************** * Function: int CopyTossInfo (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int CopyTossInfo( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { SDLTossInfo *tossInfo; if (SDLSearchMask(process_mask, ElType(my_struct)) == False) return 0; tossInfo = (SDLTossInfo *) malloc (sizeof(SDLTossInfo)); if (NULL == tossInfo) return -1; /* * save the flags */ _SdlTossInfoPtrFlag1(tossInfo) = ElFlag1(my_struct); _SdlTossInfoPtrFlag2(tossInfo) = ElFlag2(my_struct); _SdlTossInfoPtrFlag3(tossInfo) = ElFlag3(my_struct); _SdlTossInfoPtrFlag4(tossInfo) = ElFlag4(my_struct); /* * save the match data - level, ssi and class/clan. */ _SdlTossInfoPtrRlevel(tossInfo) = ElLevel(my_struct); _SdlTossInfoPtrSsi(tossInfo) = ElSsi(my_struct); _SdlTossInfoPtrClan(tossInfo) = ElClan(my_struct); /* * save the table information (colj, colw) or the keystyle * enter/exit data. */ _SdlTossInfoPtrStr1(tossInfo) = ElString1(my_struct); _SdlTossInfoPtrStr2(tossInfo) = ElString2(my_struct); /* * save the element type. */ _SdlTossInfoPtrType(tossInfo) = ElType(my_struct); /* * save the fonts - even if this toss style doesn't specify fonts. */ _SdlTossInfoPtrFontSpecs(tossInfo) = *(my_struct->my_fonts); /* * now clear string attributes */ ClearAttrFlag(my_struct->el_info, SDL_ATTR_SSI); /* * table specs. */ ClearAttrFlag(my_struct->el_info, SDL_ATTR_COLW); ClearAttrFlag(my_struct->el_info, SDL_ATTR_COLJ); /* * key style specs. */ ClearAttrFlag(my_struct->el_info, SDL_ATTR_ENTER); ClearAttrFlag(my_struct->el_info, SDL_ATTR_EXIT); /* * font specs */ ClearAttrFlag(my_struct->el_info, SDL_ATTR_COLOR); ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFD); ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFDI); ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFDB); ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFDIB); ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAM); ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAMI); ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAMB); ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAMIB); /* * set the internal pointer */ _SdlSegTossInfo(my_struct->add_seg) = (void *) tossInfo; /* * now re-initialize the font specifications back to the original * values */ *(my_struct->my_fonts) = DefFontInfo; return 0; } /* End CopyTossInfo */ /****************************************************************************** * Function: int CopyEntryInfo (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int CopyEntryInfo( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { SDLEntryInfo *entryInfo; if (SDLSearchMask(process_mask, ElType(my_struct)) == False) return 0; entryInfo = (SDLEntryInfo *) malloc (sizeof(SDLEntryInfo)); if (NULL == entryInfo) return -1; /* * save the strings. */ *entryInfo = ElEntryInfo(my_struct); /* * now clear the attributes */ ClearAttrFlag(my_struct->el_info, SDL_ATTR_MAIN); ClearAttrFlag(my_struct->el_info, SDL_ATTR_LOCS); ClearAttrFlag(my_struct->el_info, SDL_ATTR_SYNS); ClearAttrFlag(my_struct->el_info, SDL_ATTR_SORT); /* * set the internal pointer */ _SdlSegEntryInfo(my_struct->add_seg) = (void *) entryInfo; return 0; } /* End CopyEntryInfo */ /****************************************************************************** * Function: int InitLast (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int InitLast( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { /* * set the parsing flags */ my_struct->last_was_space = True; my_struct->last_was_mb = False; my_struct->last_was_nl = False; /* * set the container type correctly. */ if (NULL != my_struct->add_seg && (SdlTypeLiteral == ElFrmtType(my_struct) || SdlTypeLined == ElFrmtType(my_struct))) _DtCvContainerTypeOfSeg(my_struct->add_seg) = _DtCvLITERAL; return 0; } /* End InitLast */ /****************************************************************************** * Function: int SetTransit (FormatStruct my_struct, * int cur_element, exceptions); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Looks for the virtual page attributes. * ******************************************************************************/ static int SetTransit( FormatStruct *my_struct, SDLMask *cur_element, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { if (ElTiming(my_struct) == SdlTimingAsync) my_struct->resolve_font = _SdlFontModeNone; return 0; } /* End SetTransit */ /****************************************************************************** * * Main Parsing Functions * *****************************************************************************/ /****************************************************************************** * Function: int ParseSDL (FormatStruct my_struct, * int cur_element, int cur_execpt); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Parses a set of rules. * ******************************************************************************/ static int ParseSDL( FormatStruct *my_struct, enum SdlElement cur_element, enum SdlElement sig_element, SDLMask *cur_except, SDLMask *process_mask) { int i = 0; int result = 0; int oldLink = my_struct->cur_link; enum SdlElement oldElType = ElType(my_struct); _DtCvSegment *oldCurSeg = my_struct->last_seg; _DtCvSegment *oldSeglist = my_struct->seg_list; _DtCvSegment *oldAddSeg = my_struct->add_seg; _DtCvSegment *ifPrevData = my_struct->prev_data; _SdlFontMode saveFontMode = my_struct->resolve_font; ElementInfo saveElInfo = my_struct->el_info; _DtHelpFontHints *oldFontInfo = my_struct->my_fonts; const SDLContent *content; _DtCvContainer *activeFrmt = my_struct->active_frmt; SDLMask oldMask[SDL_MASK_LEN]; SDLMask oldExcept[SDL_MASK_LEN]; _DtCvValue oldBlank = my_struct->save_blank; _DtCvValue processFlag = SDLSearchMask(process_mask, SdlElementCdata); /* * While this element is allowed normally in the content of * the parent element, it it currently allowed? */ if (SDLSearchMask(cur_except, cur_element) == True) return -1; /* * special processing for CDATA elements */ if (cur_element != SdlElementCdata) { my_struct->seg_list = NULL; my_struct->last_seg = NULL; my_struct->add_seg = NULL; } /* * look in the master list for this element */ while (i < MaxSDLElements && SdlElementList[i].sdl_element != cur_element) i++; /* * Didn't find this element in the master list. */ if (i >= MaxSDLElements) return -1; /* * merge this element's exceptions with parent's list. * save the old process mask. */ SaveRestoreMask(oldExcept, cur_except); MergeMasks(cur_except, SdlElementList[i].exceptions); SaveRestoreMask(oldMask, process_mask); /* * the content for this element is... */ content = SdlElementList[i].content; /* * check to see if we want to process this element * If sig_element is set, parse the element and its content. */ if (sig_element != SdlElementNone) { processFlag = False; if (sig_element == cur_element) { processFlag = True; sig_element = SdlElementNone; SaveRestoreMask(process_mask, AllMaskSet); } } /* * If not CDATA, then have to get the element start string, attributes * and ending markup tag. */ if (cur_element != SdlElementCdata) { if (ParseElementStart(my_struct,SdlElementList[i],processFlag) != 0 || ParseElementAttr(my_struct, cur_element, SdlElementList[i].attrib_list, SdlElementList[i].cdata_flag, processFlag) != 0) result = -1; } /* * now parse the element's content */ my_struct->faked_end = False; ElType(my_struct) = cur_element; while (result == 0 && content != NULL && SDLSearchMask(content->mask, SdlElementNone) == False) { result = (*(content->model))(my_struct, content->mask, sig_element, cur_except, process_mask); content++; } /* * If not CDATA, get the element end markup and adjust some pointers */ SaveRestoreMask(process_mask, oldMask); SaveRestoreMask(cur_except , oldExcept); if (cur_element != SdlElementCdata) { if (result == 0 && SdlElementList[i].element_end_str != NULL) result = ParseElementEnd(my_struct, ifPrevData, SdlElementList[i], processFlag, my_struct->faked_end); else { /* * free the attributes for this element. */ FreeAttributes(ElType(my_struct), &(my_struct->el_info), my_struct->my_fonts); if (SdlElementList[i].new_fonts && FreeFontInfo(my_struct) == -1) result = -1; } my_struct->last_seg = oldCurSeg; my_struct->seg_list = oldSeglist; if (result == 0 && my_struct->add_seg != NULL) _DtHelpCeAddSegToList(my_struct->add_seg, &(my_struct->seg_list), &(my_struct->last_seg)); my_struct->add_seg = oldAddSeg; my_struct->cur_link = oldLink; if (SdlElementLink == cur_element) my_struct->save_blank = oldBlank; my_struct->el_info = saveElInfo; my_struct->my_fonts = oldFontInfo; } my_struct->active_frmt = activeFrmt; my_struct->resolve_font = saveFontMode; ElType(my_struct) = oldElType; return result; } /* End ParseSDL */ /****************************************************************************** * Function: int ProcessSDLMarkup (FormatStruct my_struct, * int cur_element, int cur_execpt); * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Parses a set of rules, looks through the result and changes * bad options into good. * ******************************************************************************/ static int ProcessSDLMarkup( FormatStruct *my_struct, enum SdlElement cur_element, enum SdlElement sig_element, SDLMask *cur_except, SDLMask *process_mask) { int result = ParseSDL (my_struct, cur_element, sig_element, cur_except, process_mask); if (-1 != result) PropagateJustification(my_struct->seg_list, _DtCvJUSTIFY_LEFT); return result; } /****************************************************************************** * Function: int ProcessContent ( * FormatStruct *my_struct, * const SDLContent *content, * SDLMask *exceptions, * SDLMask *process_mask); * * Parameters: * my_struct Specifies specific informationg for this parse. * content Specifies the content model to parse. * exceptions Specifies the current elements excepted * from being in the current content. * process_mask Specifies which elements to save in memory. * * Returns: 0 if successful, -1 if errors * * Purpose: ******************************************************************************/ static int ProcessContent( FormatStruct *my_struct, const SDLContent *content, enum SdlElement sig_element, SDLMask *exceptions, SDLMask *process_mask) { int result = 0; while (result == 0 && content != NULL && SDLSearchMask(content->mask, SdlElementNone) == False) { result = (*(content->model))(my_struct, content->mask, sig_element, exceptions, process_mask); content++; } if (-1 != result) PropagateJustification(my_struct->seg_list, _DtCvJUSTIFY_LEFT); return result; } /****************************************************************************** * Function: int SearchForController (_DtCvSegment p_seg, * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Parses a set of rules. * ******************************************************************************/ static _DtCvSegment * SearchForController( _DtCvSegment *p_seg) { while (NULL != p_seg && !(_DtCvIsSegContainer(p_seg) && _DtCvIsSegController(p_seg))) p_seg = _DtCvNextSeg(p_seg); return p_seg; } /* End SearchForController */ /****************************************************************************** * Function: int FormatSDLTitle ( * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: Parses a set of rules. * ******************************************************************************/ static int FormatSDLTitle( char *filename, int offset, int fd, FormatStruct *my_struct) { int result = 0; SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits; /* SDLMask processMask[SDL_MASK_LEN] = SDLInitMaskEleven( \ SdlElementTitle , SdlElementHead , \ SdlElementKey , SdlElementSphrase, \ SdlElementRev , SdlElementIf , \ SdlElementSpc , SdlElementAnchor , \ SdlElementLink , SdlElementSnRef , \ SdlElementCdata); */ SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone); /* * set the volume name for the graphics. */ my_struct->vol_name = filename; /* * can we seek to the correct place? */ result = _DtHelpCeFileOpenAndSeek(filename, offset, fd, &(my_struct->my_file), NULL); if (result != -1) { result = ProcessSDLMarkup (my_struct, SdlElementTitle, SdlElementNone, startExcept, processMask); _DtHelpCeBufFileClose (my_struct->my_file, (fd == -1 ? True : False)); } return result; } /* End FormatSDLTitle */ /****************************************************************************** * Function: void SetGhostLink ( * * Parameters: * * Returns: * * Purpose: * ******************************************************************************/ static int SetGhostLink( _DtCvLinkDb link_data, _DtCvSegment *segments, int link_idx) { while (segments != NULL) { if (!(_DtCvIsSegContainer(segments))) { if (_DtCvIsSegHyperText(segments)) { _DtLinkDbRemoveLink(link_data, segments->link_idx); segments->type = ClearSegLinks(segments); } segments->type = _DtCvSetTypeToGhostLink(segments->type); segments->link_idx = link_idx; } else /* if (_DtCvIsSegContainer(segments)) */ SetGhostLink (link_data, _DtCvContainerListOfSeg(segments), link_idx); segments = _DtCvNextSeg(segments); } } /* End SetGhostLink */ /****************************************************************************** * Function: void CreateAsciiString () * * Parameters: * * Returns: * * Purpose: * ******************************************************************************/ static void CreateAsciiString( _DtCvSegment *p_seg, _DtCvSegment *snb, _DtCvValue *nl_flag, char **ret_string) { int newLen; int len; while (p_seg != NULL) { len = 1; if (_DtCvIsSegString(p_seg)) { if (*nl_flag == True) { if (*ret_string != NULL && (*ret_string)[strlen(*ret_string)-1] != ' ') len++; else *nl_flag = False; } newLen = _DtCvStrLen(_DtCvStringOfStringSeg(p_seg), _DtCvIsSegWideChar(p_seg)); if (_DtCvIsSegWideChar(p_seg)) newLen = newLen * MB_CUR_MAX; len += newLen; if (*ret_string == NULL) { *ret_string = (char *) malloc (len); **ret_string = '\0'; } else { len += strlen(*ret_string); *ret_string = (char *) realloc (*ret_string, len); } if (*nl_flag == True) strcat(*ret_string, " "); /* * back up to the insertion point. */ len -= newLen; len--; /* * wide char or single byte? */ if (_DtCvIsSegWideChar(p_seg)) wcstombs(&((*ret_string)[len]), (wchar_t *) _DtCvStringOfStringSeg(p_seg), newLen + 1); else strcpy (&((*ret_string)[len]), _DtCvStringOfStringSeg(p_seg)); *nl_flag = False; if (p_seg->next_disp == NULL) *nl_flag = True; } else if (_DtCvIsSegContainer(p_seg) && !(_DtCvIsSegController(p_seg))) CreateAsciiString(_DtCvContainerListOfSeg(p_seg), snb, nl_flag, ret_string); p_seg = _DtCvNextSeg(p_seg); } } /****************************************************************************** * Function: void CreateAsciiAbbrev () * * Parameters: * * Returns: * * Purpose: * ******************************************************************************/ static void CreateAsciiAbbrev( _DtCvSegment *p_el, char **ret_abbrev) { *ret_abbrev = NULL; if (NULL != AbbrevOfSeg(p_el) && strlen ((char *) AbbrevOfSeg(p_el))) *ret_abbrev = strdup((char *) AbbrevOfSeg(p_el)); } /****************************************************************************** * Function: void CleanUpToc () * * Parameters: * my_struct Specifies current formatting information. * p_seg Specifies the current segment list to modify. * level Specifes the parent element's level. * lnk_indx Specifies the link index to use for the * ghost link. * * Returns: nothing * * Purpose: Modifies the formatting information for conform to what * it should be for a TOC and sets the ghost link. * ******************************************************************************/ static void CleanUpToc( FormatStruct *my_struct, _DtCvSegment *p_seg, int level, _DtCvValue target) { level--; if (level < 0) level = 0; while (p_seg != NULL) { if (_DtCvIsSegNewLine(p_seg)) p_seg->type = p_seg->type & ~(_DtCvNEW_LINE); if (_DtCvIsSegContainer(p_seg)) { _DtCvContainerPercentOfSeg(p_seg) = DefPercent; _DtCvContainerOrientOfSeg(p_seg) = _DtCvJUSTIFY_LEFT_MARGIN; _DtCvContainerFlowOfSeg(p_seg) = _DtCvWRAP_NONE; _DtCvContainerTypeOfSeg(p_seg) = _DtCvLITERAL; _DtCvContainerVJustifyOfSeg(p_seg) = _DtCvJUSTIFY_TOP; _DtCvContainerJustifyOfSeg(p_seg) = _DtCvJUSTIFY_LEFT; _DtCvContainerFMarginOfSeg(p_seg) = 0; _DtCvContainerLMarginOfSeg(p_seg) = level * 2 * my_struct->ui_info->avg_char; _DtCvContainerRMarginOfSeg(p_seg) = 0; _DtCvContainerTMarginOfSeg(p_seg) = 0; _DtCvContainerBMarginOfSeg(p_seg) = 0; CleanUpToc(my_struct, _DtCvContainerListOfSeg(p_seg), level, target); } else if (_DtCvIsSegString(p_seg)) { _DtHelpFontHints *font_specs = (_DtHelpFontHints *)_DtCvFontOfStringSeg(p_seg); _DtHelpFontPtrPtSize(font_specs) = 10; _DtHelpFontPtrWeight(font_specs) = _DtHelpFontWeightMedium; if (target == True) _DtHelpFontPtrWeight(font_specs) = _DtHelpFontWeightBold; (my_struct->ui_info->load_font)(my_struct->ui_info->client_data, _DtHelpFontHintsLang(*font_specs), _DtHelpFontHintsCharSet(*font_specs), *font_specs, &(_DtCvFontOfStringSeg(p_seg))); free(font_specs); } else if (_DtCvIsSegRegion(p_seg)) { int result; _DtHelpDARegion *pReg = (_DtHelpDARegion *) _DtCvInfoOfRegionSeg(p_seg); if (_DtHelpDASpc == pReg->type) { _DtHelpDASpcInfo *pSpc = (_DtHelpDASpcInfo *) pReg->handle; _DtHelpFontHintsPtSize(pSpc->spc_fonts) = 10; _DtHelpFontHintsWeight(pSpc->spc_fonts) = _DtHelpFontWeightMedium; if (True == target) _DtHelpFontHintsWeight(pSpc->spc_fonts) = _DtHelpFontWeightBold; result = (*(my_struct->ui_info->resolve_spc))( my_struct->ui_info->client_data, _DtHelpFontHintsLang(pSpc->spc_fonts), _DtHelpFontHintsCharSet(pSpc->spc_fonts), pSpc->spc_fonts, pSpc->name, &(_DtCvInfoOfRegionSeg(p_seg)), &(_DtCvWidthOfRegionSeg(p_seg)), &(_DtCvHeightOfRegionSeg(p_seg)), &(_DtCvAscentOfRegionSeg(p_seg))); if (0 != result) p_seg->type = _DtCvSetTypeToNoop(p_seg->type); free(pSpc->name); _DtHelpFreeFontHints(&(pSpc->spc_fonts)); free(pSpc); free(pReg); } } p_seg = _DtCvNextSeg(p_seg); } } /****************************************************************************** * Function: int AddEntryToToc () * * Parameters: * * Returns: * * Purpose: * ******************************************************************************/ static int AddEntryToToc( FormatStruct *my_struct, _DtHelpVolumeHdl volume, int fd, int level, char *lang, const char *char_set, _DtCvSegment *toss, _DtCvSegment *info_seg, _DtCvValue target, _DtCvSegment **ret_snb, _DtCvSegment **seg_list, _DtCvSegment **prev_list) { int result = 0; _DtCvLinkDb saveLinks; SDLIdInfo *info; /* * initialize the structure * save some information that's going to be destroyed in the setup. */ saveLinks = my_struct->my_links; if (SetUp(NULL,NULL,my_struct,toss,my_struct->ui_info,fd,False,False) != 0) return -1; /* * Initialize the standard/default to use */ _DtHelpFontHintsLang(*(my_struct->my_fonts)) = lang; _DtHelpFontHintsCharSet(*(my_struct->my_fonts)) = (char *) char_set; /* * free the new link database and restore the old one. * set font mode to save and the id for graphics. */ _DtLinkDbDestroy(my_struct->my_links); my_struct->my_links = saveLinks; my_struct->resolve_font = _SdlFontModeSave; info = FrmtPrivInfoPtr(info_seg)->id_info; result = FormatSDLTitle(_DtHelpCeGetVolumeName(volume), _SdlIdInfoPtrOffset(info), fd, my_struct); /* * if no errors, continue */ if (result != -1) { _DtCvSegment *headEl = NULL; /* * find the actual head element */ if (my_struct->seg_list != NULL) headEl = SearchForController( _DtCvContainerListOfSeg(my_struct->seg_list)); /* * If there isn't a head element, use the id. */ if (headEl == NULL) { _DtCvSegment *addSeg = NULL; if (MySaveString(&(addSeg), my_struct, _DtCvContainerIdOfSeg(info_seg), -1, my_struct->mb_len, False) != 0) { /* * free the segments */ _DtHelpFreeSegments(my_struct->seg_list, _DtCvTRUE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); my_struct->seg_list = NULL; DestroyFontInfo(my_struct); return -1; } /* * if there is a virpage, attach the segment to it. * I.e. just reuse the container. */ if (NULL != my_struct->seg_list) { /* * free the container original list */ _DtHelpFreeSegments( _DtCvContainerListOfSeg(my_struct->seg_list), _DtCvTRUE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); } else { /* * create a container for the segment. */ if (_DtHelpCeAllocSegment(my_struct->malloc_size, &(my_struct->alloc_size), &(my_struct->block_list), &(my_struct->seg_list)) != 0) { _DtHelpFreeSegments(addSeg, _DtCvTRUE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); DestroyFontInfo(my_struct); return -1; } /* * set the container flag and initialize its formatting * information to the default. */ my_struct->seg_list->type = _DtCvSetTypeToContainer(my_struct->seg_list->type); _DtCvContainerOfSeg(my_struct->seg_list) = DefFrmtSpecs; _DtCvContainerLeadingOfSeg(my_struct->seg_list) = my_struct->ui_info->leading; } _DtCvContainerListOfSeg(my_struct->seg_list) = addSeg; headEl = my_struct->seg_list; } /* * there was a empty head, use the abbreviation or the id. */ else if (_DtCvContainerListOfSeg(headEl) == NULL) { char *myPtr = (char *) AbbrevOfSeg(headEl); if (NULL == myPtr) myPtr = _DtCvContainerIdOfSeg(info_seg); if (MySaveString(&(_DtCvContainerListOfSeg(headEl)), my_struct, myPtr, -1, my_struct->mb_len, False) != 0) { /* * free the segments */ _DtHelpFreeSegments(my_struct->seg_list, _DtCvTRUE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); my_struct->seg_list = NULL; DestroyFontInfo(my_struct); return -1; } } /* * Make sure we only use the first head. * first make sure that the segment list is not the head already. */ if (headEl != my_struct->seg_list) { _DtCvSegment *prevSeg; /* * destroy the segments after this one. */ _DtHelpFreeSegments(_DtCvNextSeg(headEl), _DtCvTRUE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); /* * break the link to the freed segments */ _DtCvNextSeg(headEl) = NULL; /* * destroy the segments before this one. */ prevSeg = _DtCvContainerListOfSeg(my_struct->seg_list); if (prevSeg != headEl) { /* * search for the previous segment before the head. */ while (_DtCvNextSeg(prevSeg) != headEl) prevSeg = _DtCvNextSeg(prevSeg); /* * break the link to the head element */ _DtCvNextSeg(prevSeg) = NULL; } else _DtCvContainerListOfSeg(my_struct->seg_list) = NULL; /* * free the segments before the head and virpage container. */ _DtHelpFreeSegments(my_struct->seg_list, _DtCvTRUE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); my_struct->seg_list = headEl; } if (headEl != NULL) { int linkIndex = _DtLinkDbAddLink(my_struct->my_links, NULL, _DtCvContainerIdOfSeg(info_seg), _DtCvLinkType_SameVolume, _DtCvWindowHint_CurrentWindow, NULL); CleanUpToc(my_struct, headEl, level, target); SetGhostLink(my_struct->my_links, headEl, linkIndex); } } if (result != -1) { /* * now tack this segment onto the end of the list */ if ((*seg_list) == NULL) (*seg_list) = my_struct->seg_list; else _DtCvNextSeg((*prev_list)) = my_struct->seg_list; *prev_list = my_struct->seg_list; while ((*prev_list) != NULL && _DtCvNextSeg((*prev_list)) != NULL) *prev_list = _DtCvNextSeg((*prev_list)); } /* * if the snb for this topic was read, free it now. */ if (my_struct->snb != NULL) { _DtHelpFreeSegments(my_struct->snb, _DtCvTRUE, my_struct->ui_info->destroy_region, my_struct->ui_info->client_data); my_struct->snb = NULL; } /* * free the font structures allocated */ DestroyFontInfo(my_struct); return result; } /****************************************************************************** * Function: int ExpandToc () * * Parameters: * * Returns: * * Purpose: * ******************************************************************************/ static int ExpandToc( FormatStruct *my_struct, _DtHelpVolumeHdl volume, int fd, char *lang, const char *char_set, _DtCvSegment *toss, int level, char **path_list, _DtCvSegment **id_seg, _DtCvSegment **ret_snb, _DtCvSegment **seg_list, _DtCvSegment **prev_list) { int result = 0; int segLev; int tst = 1; _DtCvSegment *pEl; _DtCvValue done = False; _DtCvValue found = False; /* * skip anything that isn't a virpage and of the correct level. */ while ((*id_seg) != NULL && _SdlSegToSdlIdInfoType(*id_seg) != SdlIdVirpage && _SdlSegToSdlIdInfoLevel(*id_seg) != level) *id_seg = _DtCvNextSeg((*id_seg)); /* * process any virpage that has the correct level */ while ((*id_seg) != NULL && done == False && result == 0) { pEl = (*id_seg); segLev = _SdlSegToSdlIdInfoLevel(pEl); if (_SdlSegToSdlIdInfoType(pEl) == SdlIdVirpage) { if (segLev == level) { /* * If the virpage in the path list has not been found, * test the next virpage. Otherwise skip. */ if (found == False && *path_list != NULL && _DtCvContainerIdOfSeg(pEl) != NULL) tst = _DtCvStrCaseCmpLatin1(*path_list, _DtCvContainerIdOfSeg(pEl)); /* * the only time tst == 0 is when the next item in the * path_list matches this element. Check to see if the * next item in the path_list is null. If so, that * means this is the location the user has desired. */ result = AddEntryToToc(my_struct, volume, fd, segLev, lang, char_set, toss, pEl, (tst == 0 && path_list[1] == NULL ? True : False), ret_snb, seg_list, prev_list); /* * increment the segment pointer to the next item */ *id_seg = _DtCvNextSeg((*id_seg)); /* * The only time tst is zero is if the current virpage * matches the next item in the list. Expand it's children. * and set tst to non-zero so that AddEntryToToc does not * special case the siblings following this one. */ if (tst == 0) { result = ExpandToc(my_struct, volume, fd, lang, char_set, toss, segLev + 1, &path_list[1], id_seg, ret_snb, seg_list, prev_list); found = True; tst = 1; } } else if (segLev < level) done = True; else *id_seg = _DtCvNextSeg((*id_seg)); } else *id_seg = _DtCvNextSeg((*id_seg)); } return result; } /* ExpandToc */ /****************************************************************************** * Function: void CreateTitleChunks () * * Parameters: * * Returns: * * Purpose: * ******************************************************************************/ static int CreateTitleChunks( _DtCvSegment *toss, _DtCvSegment *p_seg, _DtCvSegment *snb, SDLMask *stop_mask, const char *lang, const char *char_set, _DtCvValue (*resolve_spc)(), _DtCvPointer client_data, int *ret_cnt, void ***ret_chunks) { long type; int cnt; int result = 0; const char *myLang; const char *mySet; void *ptr; _DtHelpDARegion *daRegion; while (result != -1 && p_seg != NULL) { myLang = lang; mySet = char_set; cnt = *ret_cnt; if (_DtCvIsSegString(p_seg)) { if (*ret_cnt == 0) *ret_cnt = 1; else cnt--; *ret_cnt = *ret_cnt + 3; if (*ret_chunks == NULL) *ret_chunks = (void **) malloc (sizeof(void *) * (*ret_cnt)); else *ret_chunks = (void **) realloc (*ret_chunks, sizeof(void *) * (*ret_cnt)); if (*ret_chunks == NULL) return -1; type = DT_HELP_CE_FONT_PTR | DT_HELP_CE_STRING; ptr = _DtCvFontOfStringSeg(p_seg); if (p_seg->next_disp == NULL || _DtCvIsSegNewLine(p_seg)) type |= DT_HELP_CE_NEWLINE; (*ret_chunks)[cnt++] = (void *) type; (*ret_chunks)[cnt++] = (void *) ptr; if (_DtCvIsSegWideChar(p_seg)) { int len = _DtCvStrLen(_DtCvStringOfStringSeg(p_seg), 1) * MB_CUR_MAX + 1; ptr = malloc (sizeof(char *) * len); if (NULL != ptr) wcstombs((char *) ptr, (wchar_t *) _DtCvStringOfStringSeg(p_seg), len); } else ptr = strdup(_DtCvStringOfStringSeg(p_seg)); (*ret_chunks)[cnt++] = (void *) ptr; if ((*ret_chunks)[cnt-1] == NULL) return -1; (*ret_chunks)[cnt++] = (void *) DT_HELP_CE_END; } else if (_DtCvIsSegRegion(p_seg)) { daRegion = (_DtHelpDARegion *) _DtCvInfoOfRegionSeg(p_seg); if (_DtHelpDASpc == daRegion->type) { if (False == daRegion->inited) { _DtHelpDASpcInfo *pSpc = (_DtHelpDASpcInfo *) daRegion->handle; /* * allocate the spc! */ result = (*(resolve_spc))( client_data, _DtHelpFontHintsLang(pSpc->spc_fonts), _DtHelpFontHintsCharSet(pSpc->spc_fonts), pSpc->spc_fonts, pSpc->name, &(_DtCvInfoOfRegionSeg(p_seg)), &(_DtCvWidthOfRegionSeg(p_seg)), &(_DtCvHeightOfRegionSeg(p_seg)), &(_DtCvAscentOfRegionSeg(p_seg))); free(pSpc->name); _DtHelpFreeFontHints(&(pSpc->spc_fonts)); free(pSpc); free(daRegion); if (0 != result) return -1; daRegion = (_DtHelpDARegion *) _DtCvInfoOfRegionSeg(p_seg); } if (*ret_cnt == 0) *ret_cnt = 1; else cnt--; *ret_cnt = *ret_cnt + 2; if (*ret_chunks == NULL) *ret_chunks = (void **) malloc (sizeof(void *) * *ret_cnt); else *ret_chunks = (void **) realloc (*ret_chunks, sizeof(void *) * *ret_cnt); if (*ret_chunks == NULL) return -1; type = DT_HELP_CE_SPC; if (p_seg->next_disp == NULL || _DtCvIsSegNewLine(p_seg)) type |= DT_HELP_CE_NEWLINE; (*ret_chunks)[cnt++] = (void *) type; (*ret_chunks)[cnt++] = (void *) daRegion->handle; (*ret_chunks)[cnt++] = (void *) DT_HELP_CE_END; } result = 0; } else if (_DtCvIsSegContainer(p_seg) && !(_DtCvIsSegController(p_seg))) result = CreateTitleChunks(toss, _DtCvContainerListOfSeg(p_seg), snb, stop_mask, myLang, mySet, resolve_spc, client_data, ret_cnt, ret_chunks); p_seg = _DtCvNextSeg(p_seg); } return result; } /****************************************************************************** * Function: int ProcessSegmentsToChunks () * * Parameters: * * Returns: 0 if created a chunk, -1 if errors * * Purpose: * ******************************************************************************/ static int ProcessSegmentsToChunks( _DtCvSegment *toss, _DtCvSegment *head_el, _DtCvSegment *snb_el, SDLMask *stop_mask, const char *lang, const char *char_set, _DtCvValue (*resolve_spc)(), _DtCvPointer client_data, void ***ret_chunks) { int cnt = 0; int result = 0; result = CreateTitleChunks(toss, _DtCvContainerListOfSeg(head_el), snb_el, stop_mask, lang, char_set, resolve_spc, client_data, &cnt, ret_chunks); if ((result != 0 || cnt == 0) && NULL != AbbrevOfSeg(head_el) && strlen ((char *) AbbrevOfSeg(head_el))) { *ret_chunks = (void **) malloc (sizeof(void *) * 4); if (*ret_chunks == NULL) return -1; (*ret_chunks)[0] = (void *) DT_HELP_CE_CHARSET; (*ret_chunks)[1] = (void *) strdup(char_set); (*ret_chunks)[2] = (void *) strdup(AbbrevOfSeg(head_el)); (*ret_chunks)[3] = (void *) DT_HELP_CE_END; } return result; } /****************************************************************************** * Function: _DtCvSegment *GetSdlDocSnb ( * _DtHelpVolumeHdl volume) * Parameters: * volume Specifies the volume. * * Returns: 0 if successful, -1 if errors * * Purpose: If the title has been parsed and it used snrefs, * this function will return the snb specified in the * sdldoc element. ******************************************************************************/ static _DtCvSegment * GetSdlDocSnb( _DtHelpVolumeHdl volume) { _DtCvSegment *retEl = NULL; CESDLVolume *sdlVol; sdlVol = _DtHelpCeGetSdlVolumePtr(volume); if (sdlVol != NULL && sdlVol->snb != NULL) retEl = (sdlVol->snb); return retEl; } /****************************************************************************** * Function: int GetDocumentTitle ( * _DtHelpVolumeHdl volume, * _DtCvValue flag, * _DtCvSegment **ret_seg) * Parameters: * volume Specifies the volume. * flag Specifies if the toss is needed. * ret_seg Returns sdlVol->title. * * Returns: 0 if successful, -1 if errors, -2 if there is no title. * * Purpose: This will fill in the 'title' and 'snb' elements of * the CESDLVolume structure and return 'title' in 'ret_seg'. ******************************************************************************/ static int GetDocumentTitle( _DtHelpVolumeHdl volume, _FrmtUiInfo *ui_info, _SdlFontMode mode, _DtCvValue flag, _DtCvSegment **ret_seg) { int result = -1; short procFlag = True; CESDLVolume *sdlVol; FormatStruct frmtStruct; _DtCvSegment *toss = NULL; SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits; SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits; SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone); sdlVol = _DtHelpCeGetSdlVolumePtr(volume); if (sdlVol == NULL) return -1; if (sdlVol->title_processed == False) { if (flag == True) toss = _DtHelpCeGetSdlVolToss(volume, -1); if (SetUp(volume,NULL,&frmtStruct,toss,ui_info,-1,True,False) !=0 ) return -1; /* * now set up correct font mode. */ frmtStruct.resolve_font = mode; /* * now get the title. */ if (_DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, -1, &(frmtStruct.my_file), NULL) != -1) { if (ProcessContent(&frmtStruct, SDLDocumentContent, SdlElementNone, startExcept, skipMask) != -1 && ProcessSDLMarkup(&frmtStruct, SdlElementVStruct, SdlElementNone, startExcept, skipMask) != -1 && ProcessContent(&frmtStruct, HeadAndSnb, SdlElementNone, startExcept, processMask) != -1) { sdlVol->title = frmtStruct.seg_list; sdlVol->snb = frmtStruct.snb; sdlVol->client_data = ui_info->client_data; sdlVol->destroy_region = ui_info->destroy_region; result = 0; /* * if the volume doesn't have a head, set the * appropriate flags. */ if (NULL == sdlVol->title) { procFlag = -1; /* processed with no errors */ result = -2; /* but no title */ } } else /* free the segments */ _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE, ui_info->destroy_region, ui_info->client_data); _DtHelpCeBufFileClose (frmtStruct.my_file, True); } /* * free the font structures allocated */ DestroyFontInfo(&frmtStruct); /* * destroy the link database */ _DtLinkDbDestroy(frmtStruct.my_links); sdlVol->title_processed = procFlag; } /* * if we have a title, good */ else if (sdlVol->title != NULL) result = 0; /* * we haven't processed a title. Is is because the volume * doesn't have one or because of problems accessing the volume? */ else if (-1 == sdlVol->title_processed) result = -2; /* volume doesn't have a title */ *ret_seg = sdlVol->title; return result; } /****************************************************************************** * * Semi-Private Functions * *****************************************************************************/ /****************************************************************************** * Function: SDLAttribute *_DtHelpCeGetSdlAttributeList(void) * * Parameters: * * Returns: ptr or NULL; * * Purpose: ******************************************************************************/ const SDLAttribute * _DtHelpCeGetSdlAttributeList(void) { const SDLAttribute *ptr = SDLAttributeList; return ptr; } /****************************************************************************** * * Semi-Public Functions * *****************************************************************************/ /****************************************************************************** * Function: int _DtHelpCeFrmtSDLPathAndChildren ( * _DtHelpVolumeHdl volume, char *filename, * int offset, char *id_string, * _DtCvTopicPtr *ret_handle) * * Parameters: * volume Specifies the Help Volume the information * is associated with. * filename Specifies the file containing the Help Topic * desired. * offset Specifies the offset into 'filename' to * the Help Topic desired. * id_string Specifies the location id to look for or NULL. * ret_handle Returns a handle to the topic information * including the number of paragraphs and the * id match segment. * * Returns: 0 if successful, -1 if errors, 1 if the path is empty. * ******************************************************************************/ int _DtHelpCeFrmtSdlPathAndChildren( _DtHelpVolumeHdl volume, _FrmtUiInfo *ui_info, int fd, char *target_id, _DtCvTopicPtr *ret_handle) { char *lang; const char *charSet; char **topicMap; int result = 0; int pathCnt; FormatStruct frmtStruct; _DtCvTopicInfo *topicHandle; _DtCvSegment *mySegList = NULL; _DtCvSegment *myPrevSeg = NULL; _DtCvSegment *loids; _DtCvSegment *snb = NULL; SDLIdInfo *info; *ret_handle = NULL; /* * look for the heading for each virpage */ frmtStruct = DefFormatStruct; frmtStruct.ui_info = ui_info; frmtStruct.my_links = _DtLinkDbCreate(); frmtStruct.vol_name = _DtHelpCeGetVolumeName(volume); frmtStruct.id_string = target_id; /* * get the path from the target to the top. */ pathCnt = _DtHelpCeGetSdlIdPath(volume, target_id, &topicMap); if (pathCnt == -1) return -1; /* * get the beginning of the path */ loids = _DtHelpCeMapSdlIdToSegment(volume, *topicMap, fd); if (loids == NULL) { _DtCvFreeArray((void **) topicMap); return -1; } /* * format the top topic entry. */ info = FrmtPrivInfoPtr(loids)->id_info; if (_SdlIdInfoPtrRlevel(info) > 0) { /* * Put the top topic in the table of contents. */ lang = _DtHelpCeGetSdlVolLanguage(volume); charSet = _DtHelpCeGetSdlVolCharSet(volume); result = AddEntryToToc(&frmtStruct, volume, fd, _SdlIdInfoPtrRlevel(info), lang, charSet, _DtHelpCeGetSdlVolToss(volume, fd), loids, (topicMap[1] == NULL ? True : False), &snb, &mySegList, &myPrevSeg); /* * format the children. */ if (result != -1 && _DtCvNextSeg(loids) != NULL) { loids = _DtCvNextSeg(loids); result = ExpandToc(&frmtStruct, volume, fd, lang, charSet, _DtHelpCeGetSdlVolToss(volume, fd), _SdlIdInfoPtrRlevel(info) + 1, &topicMap[1], &loids, &snb, &mySegList, &myPrevSeg); } } if (result != -1) { topicHandle = (_DtCvTopicInfo *) malloc (sizeof(_DtCvTopicInfo)); if (topicHandle != NULL) { topicHandle->id_str = NULL; topicHandle->mark_list = NULL; topicHandle->link_data = frmtStruct.my_links; topicHandle->seg_list = (void *) mySegList; /* * let the top level know that there isn't a path */ if (NULL == mySegList) result = 1; *ret_handle = (void *) topicHandle; } else result = -1; } _DtCvFreeArray((void **) topicMap); return result; } /* End _DtHelpCeFrmtSDLPathAndChildren */ /****************************************************************************** * Function: int _DtHelpCeFrmtSdlVolumeInfo (char *filename, * _DtCvTopicPtr *ret_handle) * * Parameters: * filename Specifies the file containing the Help Topic * desired. * ret_handle Returns a handle to the topic information * including the number of paragraphs and the * id match segment. * * Returns: 0 if successful, -1 if errors * * Purpose: _DtHelpCeFrmtSdlVolumeInfo processes the SDL volume looking * for the generated items. * ******************************************************************************/ int _DtHelpCeFrmtSdlVolumeInfo( char *filename, _DtHelpVolumeHdl volume, time_t *ret_time) { int result = 0; char *numPtr; CESDLVolume *sdlVol; FormatStruct frmtStruct; SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits; SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone); if (SetUp(volume,&sdlVol,&frmtStruct,NULL,&DefUiInfo,-1,True,False) != 0) return -1; /* * now set up correct font mode. */ frmtStruct.resolve_font = _SdlFontModeNone; if (result == 0) { result = _DtHelpCeFileOpenAndSeek(filename, 0, -1, &(frmtStruct.my_file), ret_time); if (result != -1) { result = ProcessContent(&frmtStruct, SDLDocumentContent, SdlElementNone, startExcept, processMask); _DtHelpCeBufFileClose (frmtStruct.my_file, True); if (frmtStruct.remember != NULL) free(frmtStruct.remember); } if (result != -1) { /* * attach the information to this volume. */ sdlVol->sdl_info = (SDLDocInfo *) FrmtPrivInfoPtr(frmtStruct.seg_list)->doc_info; /* * check the major and minor numbers. */ numPtr = _SdlDocInfoPtrSdlDtd(sdlVol->sdl_info); while (*numPtr < '0' || *numPtr > '9') numPtr++; if (atoi(numPtr) != SDL_DTD_VERSION) result = -1; else { while (*numPtr != '.' && *numPtr != '\0') numPtr++; if (*numPtr == '.') numPtr++; sdlVol->minor_no = atoi(numPtr); } /* * free the container */ FrmtPrivInfoPtr(frmtStruct.seg_list)->doc_info = NULL; _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE, NULL, NULL); } } _DtLinkDbDestroy(frmtStruct.my_links); /* * free the font structures allocated */ DestroyFontInfo(&frmtStruct); return result; } /****************************************************************************** * Function: int _DtHelpCeFrmtSDLTitleToAscii ( * char *filename, * int offset, * char **ret_title, char **ret_abbrev) * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: ******************************************************************************/ int _DtHelpCeFrmtSDLTitleToAscii( _DtHelpVolumeHdl volume, int offset, char **ret_title, char **ret_abbrev) { int result = 0; FormatStruct frmtStruct; if (SetUp(volume,NULL,&frmtStruct,NULL,&DefUiInfo,-1,True,False) != 0) return -1; *ret_title = NULL; if (ret_abbrev != NULL) *ret_abbrev = NULL; /* * now set up correct font mode. */ frmtStruct.resolve_font = _SdlFontModeNone; /* * get the title. */ result = FormatSDLTitle(frmtStruct.vol_name, offset, -1, &frmtStruct); if (result != -1 && frmtStruct.seg_list != NULL) { _DtCvSegment *pHeadSeg; _DtCvValue nlFlag = False; pHeadSeg = _DtCvContainerListOfSeg(frmtStruct.seg_list); if (pHeadSeg != NULL) { CreateAsciiString(_DtCvContainerListOfSeg(pHeadSeg), frmtStruct.snb, &nlFlag, ret_title); CreateAsciiAbbrev(pHeadSeg, ret_abbrev); } else result = -1; } else result = -1; if (frmtStruct.seg_list != NULL) _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE, NULL, NULL); /* * free the font structures allocated */ DestroyFontInfo(&frmtStruct); return result; } /* End _DtHelpCeFrmtSDLTitleToAscii */ /****************************************************************************** * Function: char *_DtHelpCeFrmtSdlVolumeAbstractToAscii( * _DtHelpVolumeHdl volume) * * Parameters: * volume Specifies the Help Volume the information * is associated with. * * Returns: 0 if successful, -1 if errors * * Purpose: _DtHelpCeFrmtSdlVolumeAbstractToAscii formats Help Files * with formatting information into a CEVirtualPage * ******************************************************************************/ char * _DtHelpCeFrmtSdlVolumeAbstractToAscii( _DtHelpVolumeHdl volume) { int offset; char *abstr = NULL; _DtCvSegment *pSeg; _DtCvSegment *pSnb; _DtCvValue nlFlag = False; _DtHelpCeLockInfo lockInfo; if (_DtHelpCeLockVolume(volume, &lockInfo) != 0) return NULL; if (_DtHelpCeFindSdlId(volume,"_abstract",lockInfo.fd,NULL,&offset) == True) { int result = 0; SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone); SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits; FormatStruct frmtStruct; CESDLVolume *sdlVol; if (SetUp(volume, &sdlVol, &frmtStruct, NULL, &DefUiInfo, lockInfo.fd, True, False) != 0) return NULL; /* * now set up correct font mode. */ frmtStruct.resolve_font = _SdlFontModeNone; /* * open the volume and seek to the virpage */ result = _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), offset, lockInfo.fd, &(frmtStruct.my_file), NULL); if (result != -1) { result = ProcessSDLMarkup (&frmtStruct, SdlElementVirpage, SdlElementNone, startExcept, processMask); _DtHelpCeBufFileClose (frmtStruct.my_file, (lockInfo.fd == -1 ? True : False)); } if (result != -1) { pSeg = frmtStruct.seg_list; pSnb = frmtStruct.snb; CreateAsciiString(pSeg, pSnb, &nlFlag, &abstr); _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE, NULL, NULL); _DtHelpFreeSegments(frmtStruct.snb, _DtCvFALSE, NULL, NULL); } /* * free the font structures allocated */ DestroyFontInfo(&frmtStruct); } _DtHelpCeUnlockVolume(lockInfo); return abstr; } /* End _DtHelpCeFrmtSdlVolumeAbstractToAscii */ /****************************************************************************** * Function: int _DtHelpCeFrmtSDLVolTitleToAscii ( * char *filename, * int offset, * char **ret_title, char **ret_abbrev) * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: ******************************************************************************/ int _DtHelpCeFrmtSDLVolTitleToAscii( _DtHelpVolumeHdl volume, _FrmtUiInfo *ui_info, char **ret_title) { char *abbrev = NULL; int result = 0; _DtCvSegment *pHeadSeg; _DtHelpCeLockInfo lockInfo; *ret_title = NULL; /* * get the head element */ if (_DtHelpCeLockVolume(volume, &lockInfo) != 0) return -1; result = GetDocumentTitle(volume,ui_info, _SdlFontModeNone, False, &pHeadSeg); _DtHelpCeUnlockVolume(lockInfo); if (result == 0) { /* * get the abbreviation of the head */ result = -2; if (pHeadSeg != NULL) { CreateAsciiAbbrev(pHeadSeg, &abbrev); if (abbrev != NULL && *abbrev != '\0') { *ret_title = abbrev; result = 0; } } /* * if there wasn't an abbreviation, use the head itself, stripping * all special items and graphics. */ if (0 != result && pHeadSeg != NULL && NULL != _DtCvContainerListOfSeg(pHeadSeg)) { _DtCvValue nlFlag = False; CreateAsciiString(_DtCvContainerListOfSeg(pHeadSeg), GetSdlDocSnb(volume), &nlFlag, ret_title); if (abbrev != NULL) free(abbrev); result = 0; } } /* * if there isn't an abbreviation on the document, and there isn't * a head, then try for the title page. After that, try the * hometopic's title. */ if (-2 == result) { result = 0; if (_DtHelpGetTopicTitle(volume, "_title", ret_title) != 0) result = _DtHelpGetTopicTitle(volume, "_hometopic", ret_title); } return result; } /* End _DtHelpCeFrmtSDLVolTitleToAscii */ /****************************************************************************** * Function: int _DtHelpCeGetSdlTopicTitleChunks ( * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: ******************************************************************************/ int _DtHelpCeGetSdlTitleChunks( _DtHelpVolumeHdl volume, char *loc_id, _FrmtUiInfo *ui_info, void ***ret_chunks) { int result = 0; int offset; FormatStruct frmtStruct; CESDLVolume *sdlVol; SDLMask stopMask[SDL_MASK_LEN] = SDLInitMask(SdlElementSubHead); *ret_chunks = NULL; if (_DtHelpCeFindSdlId(volume, loc_id, -1, NULL, &offset) != True) return -1; if (SetUp(volume, &sdlVol, &frmtStruct, NULL, ui_info, -1, True, True) != 0) return -1; result = FormatSDLTitle(frmtStruct.vol_name, offset, -1, &frmtStruct); if (result != -1 && frmtStruct.seg_list != NULL) { _DtCvSegment *headEl; _DtCvSegment *pSnbEl = NULL; result = -1; headEl = _DtCvContainerListOfSeg(frmtStruct.seg_list); /* * A virpage contains a zero or more heads as it's first * content. Therefore, if the the first item is not a * container and a controller (heads get the controller flag * put on them), then this virpage does not have a title. */ if (NULL != headEl && _DtCvIsSegContainer(headEl) && _DtCvIsSegController(headEl)) { result = ProcessSegmentsToChunks(frmtStruct.toss, headEl, pSnbEl, stopMask, _DtHelpCeGetSdlVolLanguage(volume), _DtHelpCeGetSdlVolCharSet(volume), ui_info->resolve_spc, ui_info->client_data, ret_chunks); } } else result = -1; if (frmtStruct.seg_list != NULL) _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE, ui_info->destroy_region, ui_info->client_data); if (frmtStruct.snb != NULL) _DtHelpFreeSegments(frmtStruct.snb, _DtCvFALSE, ui_info->destroy_region, ui_info->client_data); /* * free the font structures allocated */ DestroyFontInfo(&frmtStruct); /* * destroy the link database */ _DtLinkDbDestroy(frmtStruct.my_links); return result; } /* End _DtHelpCeGetSdlTitleChunks */ /****************************************************************************** * Function: int _DtHelpCeGetSdlVolTitleChunks ( * * Parameters: * * Returns: 0 if successful, -1 if errors * * Purpose: ******************************************************************************/ int _DtHelpCeGetSdlVolTitleChunks( _DtHelpVolumeHdl volume_handle, _FrmtUiInfo *ui_info, void ***ret_chunks) { int result = -2; _DtCvSegment *pHeadSeg; CESDLVolume *sdlVol; SDLMask stopMask[SDL_MASK_LEN] = SDLInitMask(SdlElementSubHead); /* * get the sdl volume pointer. */ sdlVol = _DtHelpCeGetSdlVolumePtr(volume_handle); if (sdlVol == NULL) return -1; /* * find the document attributes */ if (NULL == sdlVol->sdl_info) return -1; /* * get the head element */ if (GetDocumentTitle(volume_handle, ui_info, _SdlFontModeResolve, True, &pHeadSeg) == -1) return -1; /* * process it */ if (pHeadSeg != NULL) result = ProcessSegmentsToChunks( _DtHelpCeGetSdlVolToss(volume_handle, -1), pHeadSeg, GetSdlDocSnb(volume_handle), stopMask, _DtHelpCeGetSdlVolLanguage(volume_handle), _DtHelpCeGetSdlVolCharSet(volume_handle), ui_info->resolve_spc, ui_info->client_data, ret_chunks); if (result != 0) { result = _DtHelpCeGetSdlTitleChunks(volume_handle, "_title", ui_info, ret_chunks); if (result != 0) result = _DtHelpCeGetSdlTitleChunks(volume_handle, "_hometopic", ui_info, ret_chunks); } return result; } /* End _DtHelpCeGetSdlVolTitleChunks */ /****************************************************************************** * Function: int _DtHelpCeGetSdlVolToss ( * _DtHelpVolumeHdl volume, * Parameters: * volume Specifies the volume to read/parse. * * Returns: 0 if successful, -1 if errors * * Purpose: Get the toss from a volume. ******************************************************************************/ _DtCvSegment * _DtHelpCeGetSdlVolToss( _DtHelpVolumeHdl volume, int fd) { CESDLVolume *sdlVol; FormatStruct frmtStruct; SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits; SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone); /* * get the sdl volume pointer. */ sdlVol = _DtHelpCeGetSdlVolumePtr(volume); if (sdlVol == NULL) return NULL; if (sdlVol->toss == NULL && SetUp(volume,NULL,&frmtStruct,NULL,&DefUiInfo,fd,True,False) == 0 && _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, fd, &(frmtStruct.my_file), NULL) != -1) { if (ProcessContent(&frmtStruct, SDLDocumentContent, SdlElementNone, startExcept, skipMask) != -1 && ProcessSDLMarkup(&frmtStruct, SdlElementVStruct, SdlElementToss, startExcept, skipMask) != -1) sdlVol->toss = frmtStruct.seg_list; _DtHelpCeBufFileClose (frmtStruct.my_file, (fd == -1 ? True : False)); /* * free the font structures allocated */ DestroyFontInfo(&frmtStruct); /* * destroy the link database */ _DtLinkDbDestroy(frmtStruct.my_links); } if (sdlVol->toss != NULL) return (_DtCvContainerListOfSeg(sdlVol->toss)); return NULL; } /* End _DtHelpCeGetSdlVolToss */ /****************************************************************************** * Function: int _DtHelpCeGetSdlVolIndex ( * _DtHelpVolumeHdl volume, * Parameters: * volume Specifies the volume to read/parse. * * Returns: 0 if successful, -1 if errors * * Purpose: Get the index from a volume. ******************************************************************************/ int _DtHelpCeGetSdlVolIndex( _DtHelpVolumeHdl volume) { int result = -1; CESDLVolume *sdlVol; FormatStruct frmtStruct; SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits; SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone); sdlVol = _DtHelpCeGetSdlVolumePtr(volume); if (sdlVol == NULL) return -1; if (sdlVol->index != NULL) return 0; if (SetUp(volume, NULL, &frmtStruct, NULL, &DefUiInfo, -1, True, True) != 0) return -1; /* * now set up correct font mode. */ frmtStruct.resolve_font = _SdlFontModeNone; if (_DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, -1, &(frmtStruct.my_file), NULL) != -1) { if (ProcessContent(&frmtStruct, SDLDocumentContent, SdlElementNone, startExcept, skipMask) != -1 && ProcessSDLMarkup(&frmtStruct, SdlElementVStruct, SdlElementIndex, startExcept, skipMask) != -1) { sdlVol->index = frmtStruct.seg_list; result = 0; } _DtHelpCeBufFileClose (frmtStruct.my_file, True); } /* * destroy the link database */ _DtLinkDbDestroy(frmtStruct.my_links); /* * free the font structures allocated */ DestroyFontInfo(&frmtStruct); return result; } /* End _DtHelpCeGetSdlVolIndex */ /****************************************************************************** * Function: int _DtHelpCeGetSdlVolIds ( * _DtHelpVolumeHdl volume, * _DtCvSegment **ret_ids * Parameters: * volume Specifies the volume to read/parse. * * Returns: 0 if successful, -1 if errors * * Purpose: Get the loids from a volume. ******************************************************************************/ int _DtHelpCeGetSdlVolIds( _DtHelpVolumeHdl volume, int fd, _DtCvSegment **ret_ids) { int result = 0; CESDLVolume *sdlVol; FormatStruct frmtStruct; SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits; SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone); *ret_ids = NULL; sdlVol = _DtHelpCeGetSdlVolumePtr(volume); if (sdlVol == NULL) return -1; if (sdlVol->loids == NULL) { result = -1; if (SetUp(NULL,NULL,&frmtStruct,NULL,&DefUiInfo,-1,False,False) != -1 && _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, fd, &(frmtStruct.my_file), NULL) != -1) { if (ProcessContent(&frmtStruct, SDLDocumentContent, SdlElementNone, startExcept, skipMask) != -1) { if (ProcessSDLMarkup(&frmtStruct, SdlElementVStruct, SdlElementLoids, startExcept, skipMask) != -1) { sdlVol->loids = frmtStruct.seg_list; result = 0; } } /* * free the font structures allocated */ DestroyFontInfo(&frmtStruct); /* * destroy the link database */ _DtLinkDbDestroy(frmtStruct.my_links); _DtHelpCeBufFileClose(frmtStruct.my_file,(fd == -1 ? True : False)); } } if (sdlVol->loids != NULL) *ret_ids = _DtCvContainerListOfSeg(sdlVol->loids); return result; } /* End _DtHelpCeGetSdlVolIds */ /****************************************************************************** * Function: int _DtHelpCeParseSdlTopic (_DtHelpVolumeHdl volume, * int offset, char *id_string, * _DtCvTopicPtr *ret_handle) * * Parameters: * volume Specifies the Help Volume the information * is associated with. * offset Specifies the offset into 'filename' to * the Help Topic desired. * id_string Specifies the location id to look for or NULL. * ret_handle Returns a handle to the topic information * including the number of paragraphs and the * id match segment. * * Returns: 0 if successful, -1 if errors * * Purpose: _DtHelpCeParseSdlTopic formats Help Files with formatting * information into a CEVirtualPage * ******************************************************************************/ int _DtHelpCeParseSdlTopic( _DtHelpVolumeHdl volume, _FrmtUiInfo *ui_info, int fd, int offset, char *id_string, int rich_text, _DtCvTopicPtr *ret_handle) { int result = 0; SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone); SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits; FormatStruct frmtStruct; _DtCvTopicInfo *topicHandle; CESDLVolume *sdlVol; *ret_handle = NULL; if (SetUp(volume,&sdlVol,&frmtStruct,NULL,ui_info,fd,True,rich_text) != 0) return -1; /* * remember the id for graphics */ frmtStruct.id_string = id_string; result = _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), offset, fd, &(frmtStruct.my_file), NULL); if (result != -1) { result = ProcessSDLMarkup (&frmtStruct, SdlElementVirpage, SdlElementNone, startExcept, processMask); _DtHelpCeBufFileClose (frmtStruct.my_file, (fd == -1 ? True : False)); } /* * free the async blocks */ _DtHelpFreeSegments(frmtStruct.async_blks, _DtCvFALSE, ui_info->destroy_region, ui_info->client_data); /* * free the system notation blocks */ _DtHelpFreeSegments(frmtStruct.snb, _DtCvFALSE, ui_info->destroy_region, ui_info->client_data); if (result != -1) { topicHandle = (_DtCvTopicInfo *) malloc (sizeof(_DtCvTopicInfo)); if (topicHandle != NULL) { topicHandle->mark_list = NULL; topicHandle->id_str = NULL; if (id_string != NULL) topicHandle->id_str = strdup(id_string); topicHandle->link_data = frmtStruct.my_links; topicHandle->seg_list = frmtStruct.seg_list; *ret_handle = (void *) topicHandle; } else result = -1; } /* * free the allocated font structures */ DestroyFontInfo(&frmtStruct); return result; } /* End _DtHelpCeParseSdlTopic */