dtdocbook: merge dtinfogen into dtdocbook.

This commit is contained in:
Liang Chang
2022-01-12 04:04:33 +08:00
parent f9e02f163b
commit c6661c92c9
161 changed files with 1884 additions and 2390 deletions

View File

@@ -1,7 +1,14 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = instant locales sgml tcl tpt
SUBDIRS = doc_utils dtsr instant locales sgml spec tcl tpt
include dtdocbook.am
bin_SCRIPTS = dtdocbook2man dtdocbook2sdl
bin_PROGRAMS = dtdocbook2infolib
AM_LDFLAGS = $(XTOOLLIB) $(DTCLIENTLIBS)
dtdocbook2infolib_CPPFLAGS = \
-DDTDCBK_DATAROOTDIR=\"$(dtdcbk_datarootdir)\" \
-DINFOLIB_LIBEXECDIR=\"$(PWD)\"

View File

@@ -0,0 +1,71 @@
MAINTAINERCLEANFILES = Makefile.in
include ../dtdocbook.am
infolib = ../infolib
SUBDIRS = $(infolib) ../dtsr
noinst_PROGRAMS = \
dtdocbook2infolib \
MixedGen \
NCFGen \
NodeParser \
StyleUpdate \
dbdrv \
valBase \
validator
noinst_SCRIPTS = dtdocbook2man dtdocbook2sdl
AM_CXXFLAGS = -DCDE_NEXT -I$(top_builddir)/lib/DtMmdb
AM_LDFLAGS = $(XTOOLLIB) $(LIBMMDB) $(DTCLIENTLIBS)
dtdcbk_datarootdir = $(abs_top_srcdir)/programs/dtdocbook
AM_CPPFLAGS = \
-DDTDCBK_DATAROOTDIR=\"$(dtdcbk_datarootdir)\" \
-DINFOLIB_LIBEXECDIR=\"$(PWD)\"
validator_SOURCES = validator.C
CLEANFILES = $(noinst_SCRIPTS) $(validator_SOURCES) dtdocbook2infolib.c
dtdocbook2infolib.c: ../dtdocbook2infolib.c
$(RM) $@ && $(LN_S) $<
validator.C: $(infolib)/validator.C
$(RM) $@ && $(LN_S) $<
MixedGen$(EXEEXT): $(infolib)/MixedGen$(EXEEXT)
$(RM) $@ && $(LN_S) $<
NCFGen$(EXEEXT): $(infolib)/NCFGen$(EXEEXT)
$(RM) $@ && $(LN_S) $<
NodeParser$(EXEEXT): $(infolib)/NodeParser$(EXEEXT)
$(RM) $@ && $(LN_S) $<
StyleUpdate$(EXEEXT): $(infolib)/StyleUpdate$(EXEEXT)
$(RM) $@ && $(LN_S) $<
dbdrv$(EXEEXT): $(infolib)/dbdrv$(EXEEXT)
$(RM) $@ && $(LN_S) $<
valBase$(EXEEXT): $(infolib)/valBase$(EXEEXT)
$(RM) $@ && $(LN_S) $<
dtdocbook2man: ../dtdocbook2man
echo "#!/bin/sh" > $@ && chmod +x $@
echo "dtdcbk_libexecdir=$(dtdcbk_datarootdir) \
dtdcbk_datarootdir=$(dtdcbk_datarootdir) \
sh $(PWD)/$< \$$@" >> $@
dtdocbook2sdl: ../dtdocbook2sdl
echo "#!$(KSH)" > $@ && chmod +x $@
echo "dtdcbk_libdir=$(dtdcbk_datarootdir) \
dtdcbk_libexecdir=$(dtdcbk_datarootdir) \
dtdcbk_datarootdir=$(dtdcbk_datarootdir) \
$(KSH) $(PWD)/$< \$$@" >> $@
install:

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,6 @@ exec_prefix="@exec_prefix@"
dcbk_name="@PACKAGE_TARNAME@/dtdocbook"
dtdcbk_libdir="${dtdcbk_libdir:-@libdir@/${dcbk_name}}"
dtdcbk_libexecdir="${dtdcbk_libexecdir:-@libexecdir@/${dcbk_name}}"
dtdcbk_datarootdir="${dtdcbk_datarootdir:-@datarootdir@/${dcbk_name}}"
@@ -68,7 +67,7 @@ if [ $# -eq 3 ]
then dclfile=$1
reffile=$2
manfile=$3
else echo "usage: dbtoman [-c] dcl-file ref-src-file man-dst-file"
else echo "usage: dtdocbook2man [-c] dcl-file ref-src-file man-dst-file"
exit 1
fi

View File

@@ -321,8 +321,12 @@ if [[ -a $basename.$$.esis ]] then
fi
fi
if (( $verbose )); then
echo "${sgmls} -deglru$catfiles ${sgml_dir}/docbook.dcl $iname > $basename.$$.esis"
${sgmls} -deglru$catfiles ${sgml_dir}/docbook.dcl $iname > $basename.$$.esis
echo "${sgmls} -deglru$catfiles ${sgml_dir}/docbook.dcl $iname | \
sed 's/\&\&/\\|\[amp \]\\|/g' | sed 's/\&</\\|\[lt \]\\|/g' \
> $basename.$$.esis"
${sgmls} -deglru$catfiles ${sgml_dir}/docbook.dcl $iname | \
sed 's/\&\&/\\|\[amp \]\\|/g' | sed 's/\&</\\|\[lt \]\\|/g' \
> $basename.$$.esis
if (( $? )); then
if (( !$debug )); then
echo "rm -f $basename.$$.esis"
@@ -331,8 +335,9 @@ if (( $verbose )); then
fatalError "Error processing $iname by $parser"
fi
else
${sgmls} -deglru$catfiles ${sgml_dir}/docbook.dcl $iname \
> $basename.$$.esis 2> $basename.$$.log
${sgmls} -deglru$catfiles ${sgml_dir}/docbook.dcl $iname | \
sed 's/\&\&/\\|\[amp \]\\|/g' | sed 's/\&</\\|\[lt \]\\|/g' \
> $basename.$$.esis 2> $basename.$$.log
if (( $? )); then
if (( !$debug )); then
rm -f $basename.$$.esis

View File

@@ -0,0 +1,34 @@
MAINTAINERCLEANFILES = Makefile.in
include ../dtdocbook.am
dtsrdir = $(dtdocbookdatadir)/dtsr
dtsr_DATA = \
dtsearch.dbd \
deu.sfx \
deu.stp \
eng.sfx \
eng.stp \
esp.sfx \
esp.stp \
fra.sfx \
fra.stp \
ita.sfx \
ita.stp \
jpn.knj
noinst_PROGRAMS = mkdbd
dtsearch = ../../../lib/DtSearch
mkdbd_CPPFLAGS = -DBASE_FILE_NAME=\"dtsearch\"
mkdbd_CFLAGS = $(DT_INCDIR) -I$(dtsearch)/raima
CLEANFILES = dtsearch.dbd mkdbd.c
mkdbd.c: $(dtsearch)/tiny.c
$(RM) $@ && $(LN_S) $< $@
dtsearch.dbd: mkdbd
./$< > $@

View File

@@ -0,0 +1,70 @@
# $XConsortium: deu.sfx /main/1 1996/10/12 16:58:10 cde-ibm $
#
# (c) Copyright 1996 Digital Equipment Corporation.
# (c) Copyright 1996 Hewlett-Packard Company.
# (c) Copyright 1996 International Business Machines Corp.
# (c) Copyright 1996 Sun Microsystems, Inc.
# (c) Copyright 1996 Novell, Inc.
# (c) Copyright 1996 FUJITSU LIMITED.
# (c) Copyright 1996 Hitachi.
#
#
# COMPONENT_NAME: austext
#
# FUNCTIONS: none
#
# ORIGINS: 27
#
# (C) COPYRIGHT International Business Machines Corp. 1996
# All Rights Reserved
# Licensed Materials - Property of IBM
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
DNE 3 > ANSCHLIEßEND --> ANSCHLIEß
EGÄ 3 AG $ intrage --> intrag
ETSATE 6 $
ETSAT 5 $ ABBRUCHTASTE --> ABBRUCH
ETE 3 >
ET 2 > fragte --> frag
E * 1 > arbeite --> arbeit
GNU 3 > ANORDNUNG --> ANORDN
HCSI 4 $ wunderbarisch --> wunderbar
HCIL 4 $ gemutlich --> gemut
IE 2 > ANWENDUNGSDATEI--> ANWENDUNGSDAT
KCÜ 3 UCK $ DRÜCK --> DRUCK
LHÄ 3 AHL $ GEWÄHL --> GEWAHL
MUÄ 3 AUM $
ME 2 > WÄHLTEM --> WAHLT
NETE 4 > arbeiteten --> arbeit
NET 3 > BESTIMMTEN --> BESTIMM
NE 2 > antworten --> antworte May not work for some cases
NRE 3 > glasern --> glas **** the first a is umlaut
NIEL 4 > buchlein --> buch
# N * 1 >
RET 3 >
REI 3 >
RE 2 > manner --> mann **** the first a is umlaut
RAB 3 > wunderbar --> wunder
SI 2 >
SET 3 $
SE 2 > armes --> arm May not work for some cases
SNE 2 > friedens --> fried
S * 1 >
TE 2 > arbeitet --> arbeit
TTI 3 ITT $
TREI 4 >
TRE 3 > AKTUALISIERT --> AKTUALISI
TZ 1 > tazt --> tanz
TIEK 4 > gemutlichkeit --> gemutlich
TIEH 4 > freiheit --> frei
TSETE 5 > arbeitetest --> arbeit
TSE 3 > arbeitest --> arbeit
TS 2 > stehst --> steh
TTÄ 3 AT $ BLÄTT --> BLAT
TLÄ 3 AL $ HÄLT --> HAL
TÄ 2 AT $
TRHÄ 4 AHRT $ FÄHRT --> FAHRT
T * 1 >

View File

@@ -0,0 +1,234 @@
# $XConsortium: deu.stp /main/4 1996/10/29 20:10:16 cde-ibm $
#
# (c) Copyright 1996 Digital Equipment Corporation.
# (c) Copyright 1996 Hewlett-Packard Company.
# (c) Copyright 1996 International Business Machines Corp.
# (c) Copyright 1996 Sun Microsystems, Inc.
# (c) Copyright 1996 Novell, Inc.
# (c) Copyright 1996 FUJITSU LIMITED.
# (c) Copyright 1996 Hitachi.
#
#
# COMPONENT_NAME: austext
#
# FUNCTIONS: none
#
# ORIGINS: 27
#
# (C) COPYRIGHT International Business Machines Corp. 1996
# All Rights Reserved
# Licensed Materials - Property of IBM
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
DIE * 515
DER * 385
DEN * 313
DAS * 295
DES * 246
UND * 243
FÜR * 223
WERDEN * 205
WIRD * 169
ORDNER * 132
AUF * 129
DEM * 111
ODER * 106
EIN * 102
KANN * 93
MIT * 87
VON * 84
BENUTZER * 72
IST * 66
AUS * 61
SIEHE * 60
ORDNERS * 53
EINE * 53
NACH * 52
ZUR * 48
ZUM * 47
DIESES * 47
ANZEIGEN * 46
AUCH * 44
DURCH * 43
WENN * 41
SIND * 40
EINEN * 39
ALLE * 39
EINES * 35
DIESE * 34
EINER * 32
EINZELNEN * 31
ERSTELLT * 30
EINGEBEN * 30
LISTE * 29
ERSTELLEN * 27
ENTHÄLT * 27
NUR * 26
ANDEREN * 26
BEI * 25
VERWENDEN * 24
ENTHALTEN * 23
NICHT * 21
ANDERE * 21
ALS * 21
VOM * 20
EINEM * 20
TEMPORÄR * 19
SICH * 19
ZULETZT * 18
KÖNNEN * 18
DAß * 18
WIE * 17
DIESER * 17
ZUERST * 16
WURDEN * 16
BEREICH * 16
SIE * 15
NEUE * 15
DIESEM * 15
DANN * 15
DABEI * 15
BIS * 15
BENUTZERS * 15
ZURÜCK * 14
VERWEIS * 14
WENDET * 13
ANZEIGE * 13
WURDE * 12
WELCHE * 12
ORDNERN * 12
DOPPELT * 11
DIES * 11
SEHEN * 10
GRÖßE * 10
ALLES * 10
ÜBER * 9
RECHTS * 9
FÜHRT * 9
ENDE * 9
BEIM * 9
ANZAHL * 9
UNTEREN * 8
TEIL * 8
SOWIE * 8
SETZT * 8
INDEM * 8
IHN * 8
GRÖßTE * 8
GENAU * 8
ERSTELLUNG * 8
EINZELNE * 8
IHREM * 7
STEHEN * 6
SEIN * 6
OHNE * 6
MEHR * 6
EIGENEN * 6
WIEDER * 5
WEITERE * 5
UNTER * 5
KEINE * 5
DIESEN * 5
DEREN * 5
ZWEI * 4
ZAHL * 4
WÄHREND * 4
HABEN * 4
WORT * 3
WERTE * 3
NÄCHSTE * 3
NICHTS * 3
LÄßT * 3
ALLER * 3
ABER * 3
WERT * 2
SEI * 2
NOCH * 2
MUSTERN * 2
MAL * 2
HEUTE * 2
ERST * 2
EIGENE * 2
DENN * 2
ZIEL * 1
WANN * 1
KENNEN * 1
KEINEN * 1
DORT * 1
DENEN * 1
DAR * 1
DANACH * 1
DAMIT * 1
DAFÜR * 1
BEKANNT * 1
BEIDEN * 1
ALTEN * 1
ALLEN * 1
ZU
WIR
WES
WELCHES
WELCHER
WELCH
WAS
VOR
VOLLEN
VOLLE
VOLL
VIELES
VIELER
VIELEN
VIELE
VIEL
UNSER
UEBER
SEINES
SEINER
SEINEN
SEHR
NÄCHST
NEU
NEIN
NEBEN
MEININ
MEINES
MEINEM
MEINE
MEIN
MAN
KEINES
KEIN
JEDES
JEDER
JEDEN
JEDE
JE
JA
IM
IHRIGE
IHRES
IHRERE
IHRER
IHREN
IHRE
IHR
IHNEN
IHM
ICH
HOHE
HERR
GMBH
FUER
FRAU
ES
ER
EIGENES
EIGEN
DU
DA
BIST
BIN
ANDERER

View File

@@ -0,0 +1,161 @@
#
# COMPONENT_NAME: austext
#
# FUNCTIONS: none
#
# ORIGINS: 27
#
# (C) COPYRIGHT International Business Machines Corp. 1993,1996
# All Rights Reserved
# Licensed Materials - Property of IBM
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
#***************** ENG.SFX *******************
# $XConsortium: eng.sfx /main/3 1996/10/29 20:12:24 cde-ibm $
# Paice Stemmer Suffix Removal Rules, Ascii English
# July 1993.
# File Format:
# One rule per line.
# Empty lines and lines beginning with punctuation are comments.
# Lines must be sorted lexicographically by FIRST CHAR only ('A' - 'Z').
# Within a char section, rules sorted sequentially as applied.
# Token #1: Required, UPPERCASE suffix string, reading backwards.
# Token #2: Optional, single asterisk (*). Rule is applied only
# if original word "is intact", ie this is first rule applied.
# Token #3: Required, 'remove' count. How much of suffix to remove.
# Zero is permissable and terminates stemming.
# Token #4: Optional, append string, reading correctly. Applied
# after suffix is removed.
# Token #5: Required, continuation symbol '>' or '$'.
# If '$', stemming terminates, else continues.
#
# $Log$
# Revision 2.3 1996/02/01 19:02:05 miker
# Restored some rules inadvertently deleted.
#
# Revision 2.2 1996/02/01 18:50:18 miker
# AusText 2.1.11, DtSearch 0.3: Changed .sfx format so certain
# values are not hardcoded in lang.c.
#
AI * 2 $
A * 1 $
BB 1 $
CITY 3 S $
CI 2 >
CN 1 T >
DD 1 $
DEI 3 Y >
DEEC 2 SS $
DEE 1 $
DE 2 >
DOOH 4 >
E 1 >
FEIL 1 V $
FI 2 >
GNI 3 >
GAI 3 Y $
GANAM 0 $
GA 2 >
GG 1 $
HT * 2 $
HSIUG 5 CT $
HSI 3 >
I * 1 $
I 1 Y >
JI 1 D $
JUF 1 S $
JU 1 D $
JO 1 D $
JEH 1 R $
JREV 1 T $
JSIM 2 T $
JN 1 D $
J 1 S $
LBAIFI 6 $
LBAI 4 Y $
LBA 3 >
LBI 3 $
LIB 2 L >
LC 1 $
LUFI 4 Y $
LUF 3 >
LU 2 $
LAI 3 >
LAU 3 >
LA 2 >
LL 1 $
MUI 3 $
MU * 2 $
MSI 3 >
MM 1 $
NOIS 4 J >
NOIX 4 CT $
NOI 3 >
NAI 3 >
NA 2 >
NEE 0 $
NE 2 >
NN 1 $
PIHS 4 >
PP 1 $
RE 2 >
RAE 0 $
RA 2 $
RO 2 >
RU 2 >
RR 1 $
RT 1 >
REI 3 Y >
SEI 3 Y >
SIS 2 $
SI 2 >
SSEN 4 >
SS 0 $
SUO 3 >
SU * 2 $
S * 1 >
S 0 $
TACILP 4 Y $
TA 2 >
TNEM 4 >
TNE 3 >
TNA 3 >
TPIR 2 B $
TPRO 2 B $
TCUD 1 $
TPMUS 2 $
TPEC 2 IV $
TULO * 2 OLV $
TSIS 0 $
TSI 3 >
TT 1 $
UQI 3 $
UGO 1 $
VIS 3 J >
VIE 0 $
VI 2 >
YLB 1 >
YLI 3 Y >
YLP 0 $
YL 2 >
YGO 1 $
YHP 1 $
YMO 1 $
YPO 1 $
YTISOR 6 $
YTISO 5 >
YTI 3 >
YTE 3 >
YTL 2 $
YRTSI 5 $
YRA 3 >
YRO 3 >
YFI 3 $
YCN 2 T >
YCA 3 >
Y * 1 $
Y 1 $
ZI 2 >
ZY 1 S $

View File

@@ -0,0 +1,267 @@
# ENG.STP
#
# COMPONENT_NAME: austext
#
# FUNCTIONS: none
#
# ORIGINS: 27
#
# (C) COPYRIGHT International Business Machines Corp. 1993,1996
# All Rights Reserved
# Licensed Materials - Property of IBM
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
# $XConsortium: eng.stp /main/2 1996/07/18 15:29:49 drk $
THE * 30083
AND * 12772
FOR * 6533
THAT * 5749
YOU * 4392
WITH * 4222
ARE * 3330
THIS * 3084
HAVE * 2975
CAN * 2722
FROM * 2245
NOT * 2203
BUT * 2124
WILL * 1969
HAS * 1567
WHICH * 1477
ONE * 1475
USE * 1354
ALL * 1350
WAS * 1338
THEY * 1300
YOUR * 1288
MORE * 1231
THERE * 1228
ANY * 1176
ALSO * 1165
SOME * 1088
OTHER * 1085
WHEN * 1084
WOULD * 1044
THAN * 1015
WHAT * 998
NEW * 997
ITS * 944
ONLY * 931
ABOUT * 871
THESE * 842
MAY * 805
THEIR * 798
GET * 781
USED * 747
INTO * 746
THEN * 731
DOES * 728
SUCH * 707
OUT * 698
MOST * 688
JUST * 668
TWO * 656
THEM * 655
HOW * 636
EACH * 634
NEED * 633
SHOULD * 610
SAME * 602
BEEN * 600
INC * 587
HAD * 553
MANY * 550
COULD * 533
NOW * 524
WAY * 516
BECAUSE * 506
BOTH * 490
SEE * 473
ANYONE * 468
WERE * 467
EVEN * 466
WANT * 465
SAID * 446
VERY * 440
WHILE * 422
WELL * 416
MUCH * 404
HOWEVER * 398
STILL * 382
UNDER * 381
BETWEEN * 379
OUR * 372
ANOTHER * 359
MUST * 357
WHERE * 348
SINCE * 344
OVER * 331
THROUGH * 318
AFTER * 317
SEVERAL * 315
THINK * 313
MIGHT * 305
WITHOUT * 298
BEING * 295
THOSE * 295
BETTER * 290
TRY * 280
USES * 277
HERE * 276
TAKE * 272
LAST * 263
OFF * 258
EITHER * 252
LET * 252
BEFORE * 250
END * 250
DID * 237
TOO * 236
ETC * 231
SOMETHING * 230
LESS * 227
FEW * 226
NEXT * 220
AROUND * 210
SURE * 208
BEST * 207
YEARS * 207
PUT * 205
ALREADY * 202
REALLY * 202
YEAR * 199
WHY * 193
OWN * 190
OLD * 189
ONCE * 189
SOMEONE * 188
EVERY * 187
RATHER * 186
COME * 183
LEAST * 179
NEEDS * 178
THOUGH * 178
YET * 174
COMES * 170
SAY * 170
HAVING * 168
OFTEN * 168
GIVE * 167
WITHIN * 165
WHETHER * 164
ALTHOUGH * 156
DONE * 154
INSTEAD * 153
ABOVE * 152
ANYTHING * 148
ENOUGH * 146
AGAIN * 145
HIS * 145
GIVEN * 141
SAYS * 139
THINGS * 138
THING * 133
TODAY * 132
ALWAYS * 131
NEEDED * 131
UNTIL * 130
CANNOT * 126
NEVER * 123
OTHERS * 120
ELSE * 119
ACROSS * 118
LETS * 114
AMONG * 113
VIA * 113
SEEM * 111
DURING * 110
DOING * 106
EVERYTHING * 104
BECOME * 101
WEEK * 101
TOGETHER * 100
WAYS * 99
ALONG * 97
ITSELF * 97
THOUGHT * 93
PERHAPS * 91
GETS * 85
SOMETIMES * 85
ALMOST * 84
EXCEPT * 81
DAYS * 80
EARLY * 80
MONTH * 77
MONTHS * 77
FURTHER * 75
GIVES * 75
ONTO * 74
EVER * 73
DAY * 72
THEREFORE * 72
AWAY * 70
BELOW * 68
UNLESS * 63
THUS * 62
BECOMES * 61
TOOK * 61
UPON * 57
NOTHING * 56
AGAINST * 54
BEYOND * 54
OLDER * 54
WHOLE * 54
WANTED * 52
WHATEVER * 51
SHE * 50
TOWARD * 50
HIM * 49
WHENEVER * 47
NEWER * 46
NONE * 46
NOR * 44
WANTS * 44
WENT * 44
EVERYONE * 43
THEMSELVES * 43
NEITHER * 41
TAKEN * 41
OTHERWISE * 40
WEEKS * 38
WHOSE * 38
MOSTLY * 37
BEGAN * 35
BEHIND * 31
THROUGHOUT * 29
ALONE * 28
INDEED * 27
ANYWHERE * 26
BESIDES * 26
HER * 26
ENDS * 25
BECAME * 24
HENCE * 24
BECOMING * 21
WHEREAS * 20
FORMER * 19
YOURSELF * 18
THRU * 17
ELSEWHERE * 16
NOBODY * 16
SEES * 13
THEREBY * 10
MOREOVER * 7
SHALL * 7
TOWARDS * 6
FORMERLY * 5
NAMELY * 5
YOURS * 5
SOMETIME * 4
THEREAFTER * 4
WHOM * 4
EVENLY * 3
NEEDING * 3
WHEREVER * 3
BESIDE * 2
YOUNGER * 2

View File

@@ -0,0 +1,116 @@
# $XConsortium: esp.sfx /main/1 1996/10/12 16:56:57 cde-ibm $
#
# (c) Copyright 1996 Digital Equipment Corporation.
# (c) Copyright 1996 Hewlett-Packard Company.
# (c) Copyright 1996 International Business Machines Corp.
# (c) Copyright 1996 Sun Microsystems, Inc.
# (c) Copyright 1996 Novell, Inc.
# (c) Copyright 1996 FUJITSU LIMITED.
# (c) Copyright 1996 Hitachi.
#
#
# COMPONENT_NAME: austext
#
# FUNCTIONS: none
#
# ORIGINS: 27
#
# (C) COPYRIGHT International Business Machines Corp. 1996
# All Rights Reserved
# Licensed Materials - Property of IBM
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
ABA 3 $
ACZ 3 C $
ADA 3 $
ADI 3 $
AICNA 5 $
AICNE 5 $
ALRA 4 $
ARA 3 $
ARU 3 $
AÍRA 4 $
A 1 >
Á 1 >
BEURP 5 PROB $
CITSÍ 5 >
DADI 4 >
DA 2 $
ELBI 4 >
ELRA 4 $
ERA 3 $
ETNEM 5 >
ETNEI 5 >
ETNE 4 >
ETSA 4 $
EUQ 3 C $
ES 2 >
E 1 >
ÉRA 3 $
É 1 >
GNET 4 TEN $
LANOIC 6 $
NABA 4 $
NARA 4 $
NAÍRA 5 $
NA 2 >
NÁRA 4 $
NÁRE 4 $
NÁRI 4 $
NÁ 2 $
NEIT 4 TEN $
NE 2 >
NOIC 4 >
NÓIC 4 >
NÓ 2 ON >
NORA 4 $
ODNA 4 >
ODNEI 5 $
ODA 3 $
ODI 3 $
OD 2 >
OL 2 >
OIRO 4 >
O 1 >
Ó 1 >
RAZI 4 $
RA 2 $
RE 2 $
RI 2 $
RODA 4 $
RODE 4 $
RODI 4 $
ROD 3 >
SABA 4 $
SARA 4 $
SAÍRA 5 $
SA 2 >
SÁRA 4 $
SERA 4 $
SIABA 5 $
SIARA 5 $
SIAÍRA 6 $
SIA 3 $
SIÁ 3 $
SIETSA 6 $
SIERA 5 $
SIÉRA 5 $
SIÉ 3 $
SOD 3 >
SOIRO 5 >
SOLRA 5 $
SOMABÁ 6 $
SOMAÍRA 7 $
SOMERA 6 $
SOMERÁ 6 $
SOMA 4 $
SOME 4 $
SO 2 >
S * 1 >
S 0 $
TNEIM 5 >
Ú 1 U $
ZI 2 $

View File

@@ -0,0 +1,159 @@
# $XConsortium: esp.stp /main/4 1996/10/29 20:10:31 cde-ibm $
#
# (c) Copyright 1996 Digital Equipment Corporation.
# (c) Copyright 1996 Hewlett-Packard Company.
# (c) Copyright 1996 International Business Machines Corp.
# (c) Copyright 1996 Sun Microsystems, Inc.
# (c) Copyright 1996 Novell, Inc.
# (c) Copyright 1996 FUJITSU LIMITED.
# (c) Copyright 1996 Hitachi.
#
#
# COMPONENT_NAME: austext
#
# FUNCTIONS: none
#
# ORIGINS: 27
#
# (C) COPYRIGHT International Business Machines Corp. 1996
# All Rights Reserved
# Licensed Materials - Property of IBM
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
DEL * 381
QUE * 361
PARA * 297
LOS * 205
CUADRO * 203
UNA * 187
NOMBRE * 162
NOMBRES * 11
LAS * 120
POR * 102
ESTE * 78
PUEDE * 70
CON * 52
NUEVO * 50
MÁS * 50
CUANDO * 44
TAMBIÉN * 43
ESTÁ * 42
ESPECIFICA * 38
COMO * 35
SÓLO * 26
LO
NUEVA * 26
MES * 26
ME
VEZ * 24
FINAL * 24
NÚMERO * 23
DONDE * 21
TODOS * 19
TODAS * 19
SOBRE * 18
OTROS * 16
PUEDEN * 15
DESDE * 15
ALTURA * 15
TU
UNO * 14
SUS * 14
OTRA * 14
VER * 13
GRANDE * 13
DEBE * 13
DEBAJO
CÓMO * 13
TODO * 12
QUÉ * 12
DOBLE * 12
SON * 11
YO
SIGUIENTE * 11
PEQUEÑO * 11
OTRO * 11
HAY * 11
DENTRO * 11
CUADROS * 11
ESTÁN * 10
ESTA * 10
ES
TIENEN * 9
SIN * 9
PONER * 9
HACER * 9
TIENE * 8
PUEDA * 7
PARTE * 7
HACE * 7
DOS * 7
DESPUÉS * 7
CUALQUIER * 7
CUALQUIERA
SOY
ERES
MISMO * 6
MISMAS * 6
HASTA * 6
ESTOS * 6
ECHAR * 6
CUÁL * 6
TRES * 5
TANTO * 5
NINGUNA * 5
HAYA * 5
HAN * 5
HACIA * 5
DURANTE * 5
USTED * 4
PUEDAN * 4
PERO * 4
PEQUEÑOS * 4
OTRAS * 4
MISMOS * 4
SOMOS
NOSOTROS
ESTÉN * 4
TODA * 3
SER * 3
NUNCA * 3
NUEVOS * 3
MISMA * 3
MIENTRAS * 3
ESTÉ * 3
ESTO * 3
ÉSTA * 2
SOLO * 2
PORQUE * 2
PASO * 2
NUEVAS * 2
MUCHOS * 2
HAYAN * 2
ESTARÁ * 2
ESTAS
ALGÚN * 2
ALGUNA * 2
ALGUIEN
ALGUNOS
ALGUNAS
ÉSTE * 1
UNAS * 1
SOLA * 1
PODRÁ * 1
PODER * 1
PARAR * 1
NINGÚN * 1
NINGUNO
MUY * 1
CUÁNDO * 1
BAJO * 1
NO
SI
LA
EL
ELLA
ELLAS

View File

@@ -0,0 +1,276 @@
# $XConsortium: fra.sfx /main/1 1996/10/12 16:53:28 cde-ibm $
#
# (c) Copyright 1996 Digital Equipment Corporation.
# (c) Copyright 1996 Hewlett-Packard Company.
# (c) Copyright 1996 International Business Machines Corp.
# (c) Copyright 1996 Sun Microsystems, Inc.
# (c) Copyright 1996 Novell, Inc.
# (c) Copyright 1996 FUJITSU LIMITED.
# (c) Copyright 1996 Hitachi.
#
#
# COMPONENT_NAME: austext
#
# FUNCTIONS: none
#
# ORIGINS: 27
#
# (C) COPYRIGHT International Business Machines Corp. 1996
# All Rights Reserved
# Licensed Materials - Property of IBM
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
#
ARELL * 4 $
ARETT * 4 $
ARE * 3 >
ARI * 3 $
AE * 2 $
A * 1 >
CNA 3 >
CNE 3 >
Ç 1 C $
ECIRTA 6 $
ECIRT 5 $
EGAC 3 >
EGAÇ 4 C >
EGAG 3 $
EGASSI 6 $
EGA 3 >
EIG 2 $
EINN 3 $
EIREFF 5 $
EIRENN 5 $
EIRESSI 7 $
EIRESSA 7 $
EIRESS 5 $
EIRE 4 $
EI 2 >
ELL * 2 $
ELA 3 >
ELBAC 4 >
ELBAÇ 5 C >
ELBAEG 5 $
ELBAG 4 $
ELBASSI 7 $
ELBA 4 >
ELBISSI 7 $
ELBI 4 >
EMSIC 4 $
EMSILAI 7 $
EMSILIBI 8 $
EMSILIBA 8 $
EMSINAI 7 $
EMSINA 6 $
EMSINN 5 >
EMSI 4 >
ENN 2 >
ERD * 3 $
ERI 3 $
ESSAE * 5 $
ESSA 4 >
ESSERE 6 $
ESSI 4 >
ESUE 4 >
ETT 2 >
ÉTIC 3 >
ÉTILAI 6 $
ÉTILA 5 $
ÉTILIBA 7 $
ÉTILIBI 7 $
ÉTIRA 5 $
ÉTIROI 6 $
ÉTISO 5 $
ÉTIVI 5 $
ÉTUA 4 $
ÉTI 3 $
ÉTÉ 3 $
É 1 >
EÉ 2 >
ETSILA 6 $
ETSINN 5 >
ETSIRA 6 $
ETSIRO 6 $
ETSIVI 6 $
ETSI 4 >
EUQA 4 E >
EUQINN 5 >
EUQITA 6 $
EUQI 4 $
EVI 2 F >
E * 1 >
FISSI 5 $
FITA 4 $
FITI 4 $
FI 2 >
GA 2 >
IARELL * 5 $
IARETT * 5 $
IARE * 4 >
IARI * 4 $
IAE * 3 $
IA * 2 >
I * 1 >
LAC 2 $
LAÇ 3 C $
LAIRA 5 $
LANN 3 >
LAVI 4 $
LA 2 >
LEIRA 5 $
LEIRO 5 $
LEITN 3 >
LEI 3 >
LENN 3 >
NIA 3 >
NOITACI 5 >
NOITAC 5 >
NOITA 5 >
NOITAIC 6 >
NOITC 4 $
NOIX 3 X $
NOITI 5 >
NOI 3 >
NN 1 >
RELL * 3 >
RETT * 3 >
REUQ * 4 C $
REI 3 >
ERÈI 5 >
RE 2 >
RIO * 3 >
RIA 3 >
RI * 2 >
RUENN 4 >
RUESSI 5 $
RUESS 4 >
RUETAC 6 $
RUETAIC 6 $
RUETA 5 >
RUETE 5 >
RUETI 5 >
RUE 3 >
SAE * 3 $
SARELL * 5 $
SARETT * 5 $
SARE * 4 >
SARI * 4 $
SA * 2 >
SELL * 3 >
SEMÂE * 5 $
SEMÂ * 4 >
SEMÎ * 4 >
SENN * 3 >
SESSAE * 6 $
SESIA * 5 $
SETÂE * 5 $
SETÂ * 4 >
SETÎ * 4 $
SUE * 3 >
SEI * 3 >
SIAE * 4 $
SIARELL * 6 $
SIARETT * 6 $
SIARE * 5 >
SIARI * 5 $
SIASSI * 6 $
SIA * 3 >
SI 2 >
SE * 2 >
SNOE * 4 $
SNOIRELL * 7 $
SNOIRETT * 7 $
SNOIRE * 6 >
SNOIRI * 6 $
SNOISSAE * 8 $
SNOISSI * 7 $
SNOITACI 6 >
SNOITAC 6 >
SNOITA 6 >
SNOITAIC 7 >
SNOITC 6 X $
SNOIX 4 X $
SNOITI 6 >
SNOI * 4 >
SNORELL * 6 $
SNORETT * 6 $
SNORE * 5 >
SNORI * 5 $
SNOSSI * 6 $
SNO * 3 >
S * 1 >
SUE 3 >
TÂE * 3 $
TÂ 2 >
TIAE * 4 $
TIARELL * 6 $
TIARETT * 6 $
TIARE * 5 >
TIARI * 5 $
TIASSI * 6 $
TIA * 3 >
TI * 2 >
TNAC 3 $
TNAÇ 4 C $
TNAEG 5 $
TNAG 3 $
TNARO 5 $
TNASI 5 >
TNASSI 6 $
TNA 3 >
TNEIAE 6 $
TNEIARELL 8 $
TNEIARETT 8 $
TNEIASSI 7 $
TNEIARE 7 >
TNEIARI 6 $
TNEIA 5 >
TNELL 4 $
TNEMELL 6 >
TNEMENN 6 >
TNEMESSI 8 $
TNEMESS 7 >
TNEMESUE 8 >
TNEMES 6 >
TNEMETT 6 >
TNEMEVI 7 >
TNEMI 5 >
TNEMMA 6 >
TNEMME 6 >
TNERÈ 5 >
TNERI 5 $
TNESSAE 7 $
TNESSI 6 $
TNETT 4 $
TNEME 5 >
TNEM 4 >
TNE 3 >
TNORE * 5 >
TNORELL * 6 $
TNORETT * 6 $
TNORI * 5 $
TSI 3 >
UQ 2 C $
VI 2 $
XUAE * 4 $
XUE * 3 >
XUA * 3 >
X * 1 $
Y 1 I >
ZEIRELL * 6 $
ZEIRETT * 6 $
ZEIRE * 5 >
ZEIRI * 5 $
ZEISSAE * 7 $
ZEISSA * 6 >
ZEISSI * 6 $
ZEI * 3 >
ZERELL * 5 $
ZERETT * 5 $
ZERE * 4 >
ZERI * 4 $
ZESSI * 5 $
ZE * 2 >

View File

@@ -0,0 +1,92 @@
# $XConsortium: fra.stp /main/6 1996/10/29 20:10:44 cde-ibm $
#
# (c) Copyright 1996 Digital Equipment Corporation.
# (c) Copyright 1996 Hewlett-Packard Company.
# (c) Copyright 1996 International Business Machines Corp.
# (c) Copyright 1996 Sun Microsystems, Inc.
# (c) Copyright 1996 Novell, Inc.
# (c) Copyright 1996 FUJITSU LIMITED.
# (c) Copyright 1996 Hitachi.
#
#
# COMPONENT_NAME: austext
#
# FUNCTIONS: none
#
# ORIGINS: 27
#
# (C) COPYRIGHT International Business Machines Corp. 1996
# All Rights Reserved
# Licensed Materials - Property of IBM
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
quelle
mais
aux
elle
zéro
seulement
avec
bien
que
non
vous
leurs
premier
sous
sont
vue
plus
ils
autre
toutes
très
dans
sur
bonjour
pour
par
avons
out
cela
après
bon
elles
qui
tout
cette
êtes
nous
premières
ici
quoi
toi
les
nom
combien
sommes
des
quand
tous
me
est
cet
suis
près
deux
quel
quelque
pas
alors
première
avez
zero
une
moi
bonne
ton
déjà
oui

View File

@@ -0,0 +1,111 @@
# $XConsortium: ita.sfx /main/1 1996/10/12 16:50:00 cde-ibm $
#
# (c) Copyright 1996 Digital Equipment Corporation.
# (c) Copyright 1996 Hewlett-Packard Company.
# (c) Copyright 1996 International Business Machines Corp.
# (c) Copyright 1996 Sun Microsystems, Inc.
# (c) Copyright 1996 Novell, Inc.
# (c) Copyright 1996 FUJITSU LIMITED.
# (c) Copyright 1996 Hitachi.
#
#
# COMPONENT_NAME: austext
#
# FUNCTIONS: none
#
# ORIGINS: 27
#
# (C) COPYRIGHT International Business Machines Corp. 1996
# All Rights Reserved
# Licensed Materials - Property of IBM
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
AICCA 5 >
AI 1 $
ALRA 4 $
ALRE 4 $
ALRI 4 $
ANI 3 >
ANO 3 >
ATA 3 $
ATI 3 $
ATU 3 $
A 1 >
ÀRE 3 $
ÀRI 3 $
ECSI 4 $
EHC 2 A >
EHG 2 A >
EI 1 $
ELRA 4 $
ELRE 4 $
ELRI 4 $
ENODNA 6 $
ENOIZA 6 $
ENO 3 >
ERA 3 $
ERE 3 $
ERI 3 $
ESRA 4 $
ESRE 4 $
ESRI 4 $
ETA 3 $
ETERE 5 $
ETERI 5 $
ETE 3 $
ETI 3 $
ETNEMA 6 $
ETNEME 6 $
ETNEMI 6 $
ETNEM 5 $
ETNE 4 $
E 1 >
IARE 4 $
IARI 4 $
ICSI 4 $
IHC 2 O >
IHG 2 O >
ILRA 4 $
ILRE 4 $
ILRI 4 $
INOIZA 6 $
ITA 3 $
ITI 3 $
ITNEMA 6 $
ITNEME 6 $
ITNEMI 6 $
ITU 3 $
I 1 >
OCSI 4 $
ODNA 4 >
ODNE 4 $
OICCA 5 >
OI 1 $
OLRA 4 $
OLRE 4 $
OLRI 4 $
OMAIHC 5 $
OMAIHG 5 $
OMAI 4 $
OMERE 5 $
OMERI 5 $
ONNARE 6 $
ONNARI 6 $
ONOCSI 6 $
ONA 3 $
ONI 3 >
ONO 3 $
ONNARE 6 $
OTA 3 $
OTI 3 $
OTNEMA 6 $
OTNEME 6 $
OTNEMI 6 $
OTU 3 $
O 1 >
ÀRE 3 $
ÀRI 3 $
TNEM 4 >

View File

@@ -0,0 +1,196 @@
# $XConsortium: ita.stp /main/4 1996/10/29 20:11:01 cde-ibm $
#
# (c) Copyright 1996 Digital Equipment Corporation.
# (c) Copyright 1996 Hewlett-Packard Company.
# (c) Copyright 1996 International Business Machines Corp.
# (c) Copyright 1996 Sun Microsystems, Inc.
# (c) Copyright 1996 Novell, Inc.
# (c) Copyright 1996 FUJITSU LIMITED.
# (c) Copyright 1996 Hitachi.
#
#
# COMPONENT_NAME: austext
#
# FUNCTIONS: none
#
# ORIGINS: 27
#
# (C) COPYRIGHT International Business Machines Corp. 1996
# All Rights Reserved
# Licensed Materials - Property of IBM
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
PER * 235
DELLA * 206
DEL * 172
DELL * 149
CHE * 85
CON * 77
GLI * 76
UNA * 73
DEGLI * 69
NELLA * 65
NEL * 60
DELLE * 57
DAL * 54
QUESTO * 53
SUL * 51
DEI * 44
ESSERE * 43
NON * 40
FARE * 36
QUESTA * 35
PUÒ * 32
ALLA * 32
NUOVO * 29
SOLO * 28
NUOVA * 28
NELL * 27
DALLA * 27
SONO * 23
SULL * 22
COME * 20
QUANDO * 19
OGNI * 19
ALTRO * 17
ALTRI * 17
CREARE * 16
QUINDI * 15
DALL * 15
AGLI * 14
NELLO * 13
DELLO * 13
ALLE * 12
QUELLA * 11
USO * 10
TRA * 10
QUELLO * 10
BASE * 10
UNO * 9
DOVE * 9
DOPO * 9
CREA * 9
DUE * 8
ALTRA * 8
QUESTE * 7
ANDARE * 7
TRE * 6
SUI * 6
QUEL * 6
DURATA * 6
UNICO * 5
SECONDO * 5
SECONDARIE * 5
QUESTI * 5
PRIMA * 5
NOTI * 5
AVERE * 5
SUO * 4
SUE * 4
PRIMO * 4
NUOVI * 4
NELLE * 4
NEI * 4
DURANTE * 4
SULLO * 3
SUA * 3
QUELLI * 3
QUELL * 3
QUALI * 3
QUALE * 3
PICCOLO * 3
PICCOLA * 3
NUOVAMENTE * 3
FREQUENTE * 3
ALTRE * 3
ZERO * 2
SUGLI * 2
SOPRA * 2
QUI * 2
QUEST * 2
DOVRÀ * 2
DALLO * 2
AVER * 2
SEMPRE * 1
PRIME * 1
NEGLI * 1
MOLTO * 1
MOLTI * 1
MENTRE * 1
FRA * 1
COSÌ * 1
ALCUNI * 1
ALCUNE * 1
VOSTRO
VOSTRI
VOSTRE
VOSTRA
VOI
VI
UNA
UN
TUTTO
TUTTI
TUTTE
TUTTA
TUOI
TUO
TUE
TUA
TU
TI
SUOI
SULLE
SULLA
SI
QUELLE
QUEI
QUEGLI
QUANTO
QUANTI
QUANTE
QUANTA
NOSTRO
NOSTRI
NOSTRE
NOSTRA
NOI
NESSUNO
NESSUNA
NESSUN
NE
MIO
MIEI
MIE
MIA
MI
LUI
LORO
LO
LI
LEI
LE
LA
L
IO
IL
I
DALLE
DAI
DAGLI
CUI
CI
CHI
CE
BUONO
BUONI
BUONE
BUONA
BUON
ALLO
ALL
AL
AI

View File

@@ -0,0 +1,550 @@
#
# COMPONENT_NAME: austext
#
# FUNCTIONS: none
#
# ORIGINS: 27
#
#
# (C) COPYRIGHT International Business Machines Corp. 1995
# All Rights Reserved
# Licensed Materials - Property of IBM
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
#**************** JPN.KNJ *******************
# $XConsortium: jpn.knj /main/2 1996/07/18 15:31:58 drk $
# September 1995.
# Most frequent contiguous strings of 2 or more kanji characters
# from 32456 USENET (fj group) articles). The comment is the number
# of times that particular kanji compound occurred in the corpus.
# Derived from an original list by Tim Buress from a study
# for TWICS Co. Ltd. and International Education Center, Tokyo.
#
# $Log$
# Revision 2.2 1995/10/25 22:54:21 miker
# Added prolog.
#
# Revision 2.1 1995/09/22 20:57:48 miker
# Freeze DtSearch 0.1, AusText 2.1.8
#
# Revision 1.1 1995/09/19 21:22:47 miker
# Initial revision
#
場合 * 7840
問題 * 5745
記事 * 4636
日本 * 4627
情報 * 4291
自分 * 4197
必要 * 3827
意味 * 3573
最近 * 3331
議論 * 2922
質問 * 2799
投稿 * 2642
以下 * 2624
名前 * 2584
時間 * 2576
本当 * 2567
現在 * 2486
関係 * 2418
方法 * 2208
最後 * 2164
出来 * 2138
最初 * 2102
話題 * 2058
結果 * 2039
日本語 * 2029
実際 * 2013
普通 * 1970
試合 * 1953
以上 * 1930
今回 * 1905
存在 * 1883
理由 * 1856
以前 * 1856
内容 * 1823
使用 * 1795
今年 * 1778
東京 * 1773
部分 * 1765
間違 * 1756
人間 * 1697
意見 * 1670
面白 * 1619
説明 * 1571
投票 * 1566
株式会社 * 1555
非常 * 1549
期待 * 1546
以外 * 1515
簡単 * 1513
利用 * 1504
作成 * 1472
程度 * 1436
場所 * 1391
映画 * 1359
記憶 * 1351
設定 * 1345
結構 * 1329
参加 * 1319
状態 * 1312
表示 * 1305
番組 * 1302
文字 * 1293
可能性 * 1265
結局 * 1261
漢字 * 1259
存知 * 1256
相手 * 1244
主張 * 1233
残念 * 1233
対応 * 1227
理解 * 1221
世界 * 1201
研究所 * 1191
今日 * 1186
当然 * 1177
状況 * 1163
東大 * 1152
可能 * 1130
変更 * 1118
子供 * 1110
予定 * 1088
紹介 * 1085
興味 * 1085
確認 * 1078
同様 * 1065
女性 * 1051
英語 * 1050
機能 * 1032
指定 * 1031
出力 * 0996
原因 * 0991
判断 * 0981
一緒 * 0978
東工大 * 0977
注意 * 0974
作品 * 0964
定義 * 0961
変換 * 0945
無理 * 0933
数学 * 0923
京大 * 0902
表現 * 0900
友人 * 0896
電話 * 0889
値段 * 0880
疑問 * 0863
実行 * 0862
言語 * 0859
参考 * 0843
音楽 * 0840
放送 * 0839
購入 * 0836
先日 * 0833
一度 * 0831
選手 * 0822
上記 * 0819
目的 * 0817
勝手 * 0817
会社 * 0816
十分 * 0812
今度 * 0811
交換 * 0811
一部 * 0808
大丈夫 * 0804
条件 * 0803
一人 * 0803
完全 * 0797
経験 * 0795
納得 * 0790
基本的 * 0790
評価 * 0785
大変 * 0781
研究室 * 0775
雑誌 * 0773
個人的 * 0772
記述 * 0754
多分 * 0753
開発 * 0749
途中 * 0747
万円 * 0745
気持 * 0744
環境 * 0739
発表 * 0735
影響 * 0735
解釈 * 0734
重要 * 0733
中村 * 0731
引用 * 0725
日本人 * 0717
事実 * 0717
通信 * 0716
発売 * 0715
鈴木 * 0708
報告 * 0706
動作 * 0703
自由 * 0703
指摘 * 0695
来年 * 0692
一応 * 0692
関西 * 0687
一般 * 0680
選択 * 0679
阪大 * 0677
仕事 * 0675
研究 * 0671
太田 * 0665
予想 * 0660
結論 * 0659
認識 * 0658
構成 * 0656
去年 * 0650
入力 * 0644
全部 * 0643
感想 * 0643
大阪 * 0642
無視 * 0640
写真 * 0638
東京大学 * 0634
反対 * 0633
一番 * 0628
便利 * 0627
処理 * 0626
計算 * 0625
駄目 * 0624
危険 * 0622
今後 * 0621
頑張 * 0615
田中 * 0612
具体的 * 0612
責任 * 0607
昨日 * 0607
入手 * 0605
賛成 * 0605
過去 * 0603
正確 * 0601
山本 * 0600
登場 * 0598
大学 * 0595
画面 * 0594
安全 * 0591
不思議 * 0589
中略 * 0581
差別 * 0576
管理人 * 0576
接続 * 0573
仕方 * 0571
心配 * 0570
種類 * 0570
発生 * 0568
印象 * 0568
通常 * 0566
彼女 * 0565
同時 * 0565
形式 * 0564
失礼 * 0559
一般的 * 0558
位置 * 0558
効果 * 0557
演奏 * 0556
対象 * 0554
違法 * 0553
連絡 * 0548
池田 * 0548
両方 * 0547
当時 * 0546
適当 * 0546
行為 * 0546
趣味 * 0543
現状 * 0543
奥山 * 0541
新聞 * 0540
比較 * 0539
時代 * 0536
有名 * 0535
情報工学科 * 0532
運転 * 0530
技術 * 0522
年前 * 0519
個人 * 0516
会場 * 0513
決定 * 0512
森口博子 * 0509
提供 * 0508
予約 * 0505
事故 * 0504
想像 * 0502
絶対 * 0502
文章 * 0501
知識 * 0500
自体 * 0500
横浜 * 0499
結婚 * 0498
伊藤 * 0493
小方 * 0491
文字列 * 0490
他人 * 0490
何度 * 0490
発言 * 0486
西田 * 0484
中心 * 0483
時期 * 0483
優勝 * 0481
展開 * 0481
関東 * 0480
失敗 * 0479
解説 * 0479
希望 * 0478
立場 * 0477
小林 * 0474
提案 * 0472
電通大 * 0469
最高 * 0467
佐藤 * 0467
管理 * 0467
雰囲気 * 0466
長谷川 * 0466
電総研 * 0465
用意 * 0464
二人 * 0464
速度 * 0464
昨年 * 0462
井上 * 0461
複数 * 0460
自然 * 0459
関連 * 0459
操作 * 0457
全体 * 0456
神野 * 0454
酒井法子 * 0454
何故 * 0454
工学部 * 0452
日本電気 * 0451
誤解 * 0451
免許 * 0450
区別 * 0450
初心者 * 0449
週間 * 0449
岡田 * 0449
元気 * 0448
部屋 * 0447
有効 * 0444
範囲 * 0443
清水 * 0443
概念 * 0443
反応 * 0441
電子 * 0441
時点 * 0441
解決 * 0439
納豆 * 0436
情報交換 * 0435
実現 * 0435
否定 * 0434
番号 * 0433
開発部 * 0433
本人 * 0432
根拠 * 0431
変化 * 0430
現象 * 0430
関数 * 0429
河野 * 0429
皆様 * 0428
人気 * 0427
発音 * 0426
西村知美 * 0425
製品 * 0424
苦労 * 0423
料理 * 0422
順位 * 0421
社会 * 0421
北海道 * 0418
反論 * 0418
東芝 * 0418
意識 * 0418
前田 * 0417
面倒 * 0416
参照 * 0416
高橋由美子 * 0414
仕様 * 0413
旅行 * 0409
登録 * 0409
科学 * 0409
一方 * 0408
資料 * 0406
方向 * 0405
京都 * 0404
記録 * 0404
機会 * 0402
下記 * 0402
円滑 * 0402
手元 * 0401
海外 * 0400
省略 * 0398
競馬 * 0397
三菱電機 * 0396
今週 * 0396
攻撃 * 0396
価値 * 0396
月号 * 0393
不幸 * 0392
先生 * 0392
自転車 * 0392
学生 * 0392
返事 * 0391
筑波大 * 0390
教育 * 0390
電車 * 0389
実験 * 0387
起動 * 0387
法律 * 0386
直接 * 0386
方式 * 0385
発見 * 0385
修正 * 0385
研究部 * 0385
禁止 * 0385
辞書 * 0384
案内 * 0384
勉強 * 0383
大井 * 0383
日立 * 0382
内線 * 0382
大阪大学 * 0380
松下電器 * 0380
文句 * 0378
不安 * 0377
距離 * 0377
価格 * 0376
迷惑 * 0373
是非 * 0373
能力 * 0370
数字 * 0370
平成 * 0369
標準 * 0369
本来 * 0368
自信 * 0368
筑波大学 * 0365
相当 * 0365
移動 * 0365
開催 * 0364
漫画 * 0363
富士通 * 0363
練習 * 0359
友達 * 0359
松下 * 0359
現実 * 0359
所属 * 0356
石田 * 0355
症状 * 0355
公開 * 0354
設計 * 0353
切符 * 0353
日文酔夢 * 0352
合意 * 0352
要求 * 0351
本体 * 0350
復活 * 0350
駐車場 * 0349
確実 * 0349
以降 * 0349
努力 * 0348
行動 * 0348
感動 * 0348
名古屋 * 0347
斉藤 * 0346
機械 * 0345
列車 * 0344
特別 * 0344
前提 * 0344
研究会 * 0344
明日 * 0343
藤本 * 0343
参加者 * 0343
気分 * 0343
態度 * 0342
活動 * 0342
木村 * 0341
全然 * 0341
感覚 * 0339
修理 * 0338
山崎 * 0338
配布 * 0337
追加 * 0337
論文 * 0336
人達 * 0336
訂正 * 0335
自身 * 0335
事業部 * 0335
不明 * 0334
一言 * 0334
事情 * 0333
基本 * 0333
特定 * 0332
制限 * 0332
高橋 * 0332
料金 * 0331
富士通研究所 * 0331
転送 * 0330
早見優 * 0330
終了 * 0330
後半 * 0329
中嶋 * 0328
男性 * 0328
国内 * 0328
先週 * 0327
機種 * 0327
富士通研 * 0324
富士 * 0324
詳細 * 0324
構造 * 0324
午後 * 0324
確保 * 0323
近藤 * 0321
録音 * 0319
大好 * 0319
新幹線 * 0319
世話 * 0318
信号 * 0318
収録 * 0318
職業 * 0316
小川範子 * 0316
意図 * 0316
変数 * 0315
早稲田大学 * 0315
岡本 * 0315
違反 * 0315
歴史 * 0313
和田 * 0311
記号 * 0311
命令 * 0310
同感 * 0310
考慮 * 0310
京都大学 * 0310
単純 * 0308
住所 * 0308
突然 * 0307
証明 * 0305
手引 * 0305
文化 * 0304
美味 * 0303
鉄道 * 0303
阪神 * 0303
明確 * 0302
応援 * 0302
東京工業大学 * 0301
前川 * 0301
女子高生 * 0301
共通 * 0301
前回 * 0300
制御 * 0299
基準 * 0299
後者 * 0298
日時 * 0297
最大 * 0297
正常 * 0296
性格 * 0295
森高千里 * 0295
#**************** JPN.KNJ *******************

View File

@@ -0,0 +1,81 @@
/*
* 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
*/
/* $XConsortium: AttributeData.cc /main/2 1996/07/18 16:07:35 drk $ */
/* exported interfaces */
#include "AttributeData.h"
/* imported interfaces */
#include "SGMLName.h"
#include "Token.h"
#include "Dispatch.h"
//-------------------------------------------------------------------------
AttributeData::AttributeData( const Token &t,
int attr_name,
ActionType mode ):BaseData(t, mode)
{
const char *str;
if ( (str = attribute_value( t, attr_name )) ) {
data_complete = 1;
ValueBuffer.writeStr( str );
}
else {
data_avail = 0;
}
}
//-------------------------------------------------------------------------
const char *
AttributeData::attribute_value( const Token &t, int attributeName )
{
const AttributeRec *tmp;
int att_type;
tmp = t.LookupAttr( attributeName );
if ( !tmp ) {
return 0;
}
att_type = tmp->getAttrType();
if ( att_type == SGMLName::ENTITY ) {
SGMLDefn *sgml_defn = Dispatch::entity_ref( tmp->getAttrValueString() );
if ( !sgml_defn ) {
throw(Unexpected("no entity declaration for this entity"));
}
/*
* Use the file name
*/
return ( sgml_defn->getFileName() );
}
else if ( att_type == SGMLName::CDATA ||
att_type == SGMLName::TOKEN ){
return ( tmp->getAttrValueString() );
}
else {
return 0;
}
}

View File

@@ -0,0 +1,45 @@
/*
* 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
*/
/* $XConsortium: AttributeData.h /main/2 1996/07/18 16:36:49 drk $ */
#ifndef __attr_Data__
#define __attr_Data__
#include "BaseDataCollect.h"
class Token;
class AttributeData : public BaseData {
friend class FirstOf;
friend class OL_Data;
friend class Concat;
private:
const char *attribute_value( const Token &t, int attr_name );
protected:
AttributeData( const Token &t, int attr_name, ActionType mode );
};
#endif

View File

@@ -0,0 +1,138 @@
/*
* 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
*/
/* $XConsortium: AttributeList.C /main/3 1996/08/21 15:45:57 drk $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
#include <assert.h>
#include "AttributeRec.h"
#include "AttributeList.h"
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
static int dbgLevel;
//---------------------------------------------------------
// ValList : Constructor
OL_AttributeList::OL_AttributeList()
{
DBG(10) cerr << "(DEBUG) Invoking OL_AttributeList::OL_AttributeList()\n";
dbgLevel=-1;
char *dbgStr;
head = NULL;
tail = NULL;
dbgStr = getenv("OL_DEBUG");
dbgLevel = ( dbgStr ? atoi(dbgStr):0);
}
//---------------------------------------------------------
// OL_AttributeList::OL_AttributeList
OL_AttributeList::~OL_AttributeList()
{
AttributeRec *pt = head;
while ( pt ) {
AttributeRec *tmp = pt;
pt = pt->next;
delete tmp;
}
}
//---------------------------------------------------------
// OL_AttributeList:lookup
AttributeRec *OL_AttributeList::lookup( int attName ) const
{
DBG(10) cerr << "(DEBUG) Invoking OL_AttributeList::lookup()\n";
DBG(10) cerr << " with attName = " << attName << endl;
AttributeRec *pt = head;
while ( pt ) {
if ( pt->attName == attName ) {
return ( pt );
}
pt = pt->next;
}
return ( NULL );
}
//---------------------------------------------------------
// OL_AttributeList::add
void OL_AttributeList::insert ( AttributeRec *entry )
{
if ( !tail ) {
head = tail = entry;
}
else {
tail->next = entry;
tail = entry;
}
}
//---------------------------------------------------------
const AttributeRec *OL_AttributeList::GetFirstAttr() const
{
return( head );
}
//---------------------------------------------------------
const AttributeRec *
OL_AttributeList::GetNextAttr( const AttributeRec *attRec) const
{
assert( attRec != NULL );
return( attRec->next );
}

View File

@@ -0,0 +1,54 @@
/*
* 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
*/
/* $XConsortium: AttributeList.h /main/3 1996/08/21 15:46:01 drk $ */
//---------------------------------------------------------
// AttributeList.h
#ifndef ATT_LIST_HDR
#define ATT_LIST_HDR
#include <stdio.h>
#include "AttributeRec.h"
class OL_AttributeList {
friend class Token;
protected:
AttributeRec *head;
AttributeRec *tail;
AttributeRec *lookup ( int ) const;
void insert(AttributeRec * );
const AttributeRec *GetFirstAttr() const;
const AttributeRec *GetNextAttr( const AttributeRec *) const;
OL_AttributeList();
~OL_AttributeList();
};
#endif

View File

@@ -0,0 +1,90 @@
/*
* 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
*/
/* $XConsortium: AttributeRec.cc /main/4 1996/07/18 16:08:22 drk $ */
#include <string.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
#include <assert.h>
#include "SGMLDefn.h"
#include "SGMLName.h"
#include "AttributeRec.h"
#ifdef FISH_DEBUG
#include <dbug.h>
#endif
//---------------------------------------------------------------------
AttributeRec::AttributeRec( const char *name,
const char *value,
int type )
{
#ifdef FISH_DEBUG
DBUG_PRINT("AttributeRec", ("name = %s\n"
"value = %s\n"
"type = %d", name, value, type));
#endif
int len;
next=NULL;
attName = SGMLName::intern( name );
switch(attType = type){
case SGMLName::TOKEN:
case SGMLName::NOTATION:
case SGMLName::ENTITY:
attValue = SGMLName::intern( value );
attValueString = SGMLName::lookup(attValue);
copy = NULL;
#ifdef FISH_DEBUG
DBUG_PRINT("AttributeRec", ("attValue after the intern: %d", attValue));
#endif
break;
case SGMLName::CDATA:
attValue = -1;
len = strlen(value);
attValueString = copy = new char[len + 1];
*((char *) memcpy(copy, value, len) + len) = '\0';
break;
default:
abort();
}
}
//---------------------------------------------------------------------
AttributeRec::~AttributeRec()
{
delete copy;
}
//---------------------------------------------------------------------
int
AttributeRec::getAttrName() const
{
return(attName);
}

View File

@@ -0,0 +1,70 @@
/*
* 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
*/
/* $XConsortium: AttributeRec.h /main/3 1996/08/21 15:46:05 drk $ */
//----------------------------------------------
// AttributeRec.h
#ifndef ATT_REC_HDR
#define ATT_REC_HDR
#include "SGMLName.h"
class SGMLDefn;
class AttributeRec {
friend class OL_AttributeList;
friend class Token;
private:
int attName;
int attType;
const char *attValueString;
char *copy;
int attValue;
AttributeRec *next;
protected:
AttributeRec( const char * name, const char *value,
int type );
~AttributeRec();
public:
int getAttrName() const;
/* use this for CDATA attributes */
const char *getAttrValueString() const { return(attValueString); }
/* use this for NAME, NOTATION, ENTITY attributes */
int getAttValue() const { return(attValue); }
int getAttrType() const { return(attType); }
int operator== ( AttributeRec & s ) {
return ( attName == s.attName );
}
};
#endif

View File

@@ -0,0 +1,134 @@
/*
* 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
*/
/* $XConsortium: AttributeStore.C /main/3 1996/08/21 15:46:08 drk $ */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
#include "List.h"
#include "AttributeRec.h"
#include "AttributeStore.h"
#include "HashBucketEntry.h"
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
//---------------------------------------------------------
// AttributeStore : Constructor
AttributeStore::AttributeStore( int sz ):NumBuckets(sz)
{
char *dbgStr;
dbgStr = getenv("OL_DEBUG");
dbgLevel = ( dbgStr ? atoi(dbgStr):0);
HashTable = new HashBucketEntry * [ NumBuckets ];
if ( !HashTable ) {
cerr << "(ERROR) Unable to allocate memory for HashTable\n";
exit(1);
}
for ( int i=0; i < sz; i++) {
HashTable[i] = NULL;
}
}
//---------------------------------------------------------
// AttributeStore : Destructor
AttributeStore::~AttributeStore()
{
for ( int i=0; i < NumBuckets; i++ ) {
delete HashTable[i];
}
}
//---------------------------------------------------------
// AttributeStore::hash()
int AttributeStore::hash( char *HashKeyStr )
{
DBG(10) cerr << "(DEBUG) Invoking hash function with HashKeyStr = "
<< HashKeyStr << endl;
int sum=0;
// This is a simple hash function
for ( char *ptr=HashKeyStr; *ptr; ptr++ ) {
sum += *ptr;
}
sum = sum % NumBuckets;
DBG(10) cerr << "(DEBUG) returning value for hash function = "
<< sum << endl;
return ( sum );
}
//---------------------------------------------------------
// AttributeStore::lookup
char *AttributeStore::lookup( Token *ThisToken, char *aName )
{
int HashValue;
AttributeRec *aRecPtr;
HashValue=hash( aName );
aRecPtr = HashTable[ HashValue ]->lookup( aName );
return ( aRecPtr->GetAttributeValue( ThisToken ) );
}
//---------------------------------------------------------
// AttributeStore::add
int AttributeStore::insert ( AttributeRec *att )
{
int HashValue;
HashBucketEntry *BucketEntry;
HashValue = hash ( att->name );
BucketEntry = HashTable [ HashValue ];
if ( BucketEntry->lookup ( att->name ) ) {
return(0);
}
else {
BucketEntry->insert( att );
return(1);
}
}

View File

@@ -0,0 +1,56 @@
/*
* 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
*/
/* $XConsortium: AttributeStore.h /main/2 1996/07/18 16:38:25 drk $ */
//---------------------------------------------------------
// AttributeSore.h
#ifndef ATT_STORE
#define ATT_STORE
#include "AttributeRec.h"
class AttributeStore {
private:
AttributeRec *head;
AttributeRec *current;
public:
char *lookup ( char * );
int add ( AttributeRec * );
AttributeRec *getNext() {
AttributeRec *ptr;
if ( current ) {
ptr = current;
current = current->next;
return (ptr );
}
else {
return ( NULL );
}
}
AttributeStore();
~AttributeStore();
};
#endif

View File

@@ -0,0 +1,264 @@
/*
* 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
*/
/* $XConsortium: AusText.C /main/3 1996/09/10 16:04:23 cde-hal $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
/* imported interfaces */
#include "OL_Data.h"
#include "Task.h"
#include "FlexBuffer.h"
#include "Token.h"
#include "OLAF.h"
#include "BookCaseDB.h"
#include "BookTasks.h"
#include "NodeData.h"
#include "NodeTask.h"
#include "GraphicsTask.h"
#include "BookTasks.h"
#include "Dispatch.h"
#include "SGMLName.h"
#include "DataRepository.h"
#include "AusTextStorage.h"
/* exported interfaces */
#include "AusText.h"
const unsigned char WORD_SEP = ' ';
// charater strings
const int OLIAS_SCOPE_TITLE = OLAF::Title;
const int OLIAS_SCOPE_EXAMPLE = OLAF::Example;
const int OLIAS_SCOPE_INDEX = OLAF::Index;
const int OLIAS_SCOPE_TABLE = OLAF::Table;
const int OLIAS_SCOPE_GRAPHIC = OLAF::Graphic;
//-----------------------------------------------------------------------
AusText::AusText(NodeData *f_node, const Token &t):SearchEngine(f_node, t)
{
store = new DataRepository;
f_search_store = NULL;
// NOTE: We need to activate default zone here because AusText::markup
// is not being called for the top element in the section.
// Do not forget to deactivate it on the other end!
store->ActivateZone ( DataRepository::Default, t.level() );
}
//-----------------------------------------------------------------------
AusText::~AusText()
{
store->deActivateZone ( f_base );
delete store;
if ( f_search_store ) { delete f_search_store; }
}
//-----------------------------------------------------------------------
void
AusText::write_start_tag ( const Token &t)
{
const AttributeRec *a;
int level = t.level();
if ( (a = t.LookupAttr( OLAF::OL_scope )) ) {
switch ( a->getAttValue() ) {
case OLIAS_SCOPE_EXAMPLE :
store->ActivateZone( DataRepository::Example, level );
break;
case OLIAS_SCOPE_GRAPHIC :
store->ActivateZone( DataRepository::Graphic, level );
break;
case OLIAS_SCOPE_INDEX :
store->ActivateZone( DataRepository::Index, level );
break;
case OLIAS_SCOPE_TABLE :
store->ActivateZone( DataRepository::Table, level );
break;
case OLIAS_SCOPE_TITLE :
store->ActivateZone( DataRepository::Head, level );
break;
default : throw(Unexpected("Not a valid zone"));
}
}
#if 0
else {
store->ActivateZone ( DataRepository::Default, level );
}
#endif
store->put( WORD_SEP );
}
//------------------------------------------------------------------------
void
AusText::write_end_tag( const Token & t)
{
store->deActivateZone( t.level() );
store->put( WORD_SEP );
}
//------------------------------------------------------------------------
void
AusText::write_terms( FlexBuffer *termsbuf )
{
int bufsize = termsbuf->GetSize();
const char *buffer = termsbuf->GetBuffer();
store->write( buffer, bufsize );
termsBuffer = termsbuf;
}
//------------------------------------------------------------------------
void
AusText::write_buffer()
{
BookCaseTask *f_bc = f_parent->node()->book()->bookcase();
const char *BookCaseName = f_bc->bookcasename();
const char *pathname = f_bc->database()->path();
f_search_store = new AusTextStore( pathname, BookCaseName );
assert(f_search_store != NULL);
const char *book_short_title = f_parent->node()->book()->book_short_title();
const char *book_id = f_parent->node()->book()->locator();
const char *nodelocator = f_parent->node()->locator();
const char *node_title = f_parent->node()->title();
f_search_store->insert(book_short_title,
book_id,
nodelocator,
node_title,
store
);
}
//------------------------------------------------------------------------
void
AusText::markup( const Token & t )
{
if ( f_base > 0 ) {
ComplexTask::markup(t);
if ( t.type() == START ) {
if ( Dispatch::OutsideIgnoreScope() ) {
if ( t.LookupAttr( OLAF::OL_Graphic ) ) {
CollectObject = t.level();
f_graphics = new GraphicsTask ( this, t );
assert ( f_graphics != NULL );
addSubTask( f_graphics );
}
#if TABLES
else if( t.LookupAttr( OLAF::OL_Table ) ) {
CollectObject = t.level();
addSubTask(new SearchableTableTask(this, t));
}
#endif
write_start_tag ( t );
}
}
else if ( t.type() == END ) {
if ( Dispatch::OutsideIgnoreScope() ) {
if ( CollectObject >= 0 ) {
if ( CollectObject == t.level() ) {
CollectObject = -1;
if ( f_graphics ) {
if ( f_graphics->HasSearchTerms() ) {
hasTerms = 1;
FlexBuffer *buf = (FlexBuffer *)f_graphics->GetTerms();
write_terms ( buf );
}
KILLSUBTASK( f_graphics );
}
}
}
write_end_tag( t );
if ( f_base == t.level() ) {
f_base = -1;
write_buffer();
}
} /* OutsideIgnoreScope */
} /* if ( t.type() == END ) */
} /* if ( f_base > 0 ) */
}
//---------------------------------------------------------------------
void
AusText::data ( const char *str, size_t sz )
{
if ( f_base > 0 ) {
ComplexTask::data( str, sz );
if ( Dispatch::OutsideIgnoreScope() ) {
/* @@ for tables, this isn't quite right... */
if ( CollectObject < 0 ) {
if ( sz == 0 ) { return; }
store->write( str, sz );
}
}
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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
*/
/* $XConsortium: AusText.h /main/2 1996/07/18 16:38:54 drk $ */
// AusText.h - Specific implementation for AusText search engine
#ifndef AUSTEXT_HEADER
#define AUSTEXT_HEADER
#include "SearchEng.h"
class Token;
class AusTextStore;
class NodeData;
class DataRepository;
class AusText : public SearchEngine {
private:
DataRepository *store;
AusTextStore *f_search_store;
protected:
void write_start_tag ( const Token &);
void write_end_tag ( const Token & );
void write_terms ( FlexBuffer *termsbuf );
void write_buffer();
public:
void markup( const Token & );
void data( const char *, size_t );
public:
AusText(NodeData *, const Token &);
~AusText();
};
#endif

View File

@@ -0,0 +1,368 @@
/*
* 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
*/
/* $XConsortium: AusTextStorage.cc /main/5 1996/07/23 18:08:29 cde-hal $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#include <stdio.h>
#include <stddef.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <sstream>
using namespace std;
/* imported interfaces */
#include <misc/unique_id.h>
#include "FlexBuffer.h"
#include "Task.h"
#include "DataBase.h"
#include "DataRepository.h"
#include "api/utility.h"
/* exported interfaces */
#include "AusTextStorage.h"
#ifdef DTSR_USE_CNTR_L
const char CNTR_L = '\014'; /* This is for ascii system only */
#endif
// If NodeParser ever gets setup to run on all bookcases at one time, we
// will need a reset() function for this member.
unsigned long AusTextStore::f_recordcount = 0;
#ifdef DTSR_LIKES_FGETS
const int LINE_SIZE = 80; /* this is the line size allowed for data in
* the *.fzk file
*/
/* Most of the non-alphanumeric character in ascii code set */
const char *DELIMITER_SET = "\t\n !@#$%^&*()_-=+\\|~[]{};:,.<>/?";
enum EucCodeSet {
CodeSetInv = -1,
CodeSet0 = 0,
CodeSet1 = 1,
CodeSet2 = 2,
CodeSet3 = 3
};
/*
* charcspn determines if ch is found in the set
* returns 1 if so, 0 if otherwise
*/
/*
* @@ charset is expensive, alternative approach is to use a
* static array
* static char char_tab[] = { 0, 0, 0, 1,...... }
* where 1 indicates the character is in the delimiter character set
* however, this might not be portable for character set other than
* ascii , so this has to be done carefully
* If the format of the fzk is changed, all this will no longer be
* required. So, I am not going to do anything at this point
*/
//-----------------------------------------------------------------
static int charset ( const char ch, const char *set)
{
for ( const char *ptr = set;
*ptr != '\0';
ptr++ ) {
if ( ch == *ptr ) return 1;
}
return 0;
}
/*
* getline returns the no. of bytes that should be read as a line.
* Normally it should read line_size, but if there is a token that
* spans 2 lines, getline need to determine the line size such that
* at the end of the line, no token should be spanning the next line.
*/
/*
* start_ptr is the start of the buffer and end_ptr is the end of the buffer
* it is similar to fread except that end_ptr is supplied as the bounding
* condition as opposed to the EOF in fread. Besides, no actual character
* is read , only the number of characters that should be read as a line.
*/
//--------------------------------------------------------------------------
static unsigned int DefaultGetLine ( const char *start_ptr,
const char *end_ptr,
int line_size )
{
if ( start_ptr > end_ptr ) { return 0; }
if ( start_ptr + line_size - 1 <= end_ptr ) { // not @ the end yet
/*
* FIrst see if there is a token that spans multiple lines
*/
const char *ptr = start_ptr + line_size - 1;
if ( ptr == end_ptr ) { return line_size; }
if ( charset( *(ptr+1), DELIMITER_SET ) || charset ( *ptr, DELIMITER_SET ) ) {
return ( line_size );
}
/* That means found a token that spans 2 lines */
/* So now loop back until *ptr is not in DELIMITER_SET */
const char *new_end_ptr;
for ( new_end_ptr = ptr;
new_end_ptr > start_ptr && !charset( *new_end_ptr , DELIMITER_SET );
new_end_ptr-- );
return( new_end_ptr - start_ptr + 1 );
}
else {
// last chunk of line
return ( end_ptr - start_ptr + 1 );
}
}
inline EucCodeSet JpEucCodeSet(const unsigned char* text)
{
EucCodeSet codeset;
if (text == NULL)
codeset = CodeSetInv;
else if (*text < 0x80)
codeset = CodeSet0;
else if (*text == 0x8E)
codeset = CodeSet2;
else if (*text == 0x8F)
codeset = CodeSet3;
else {
assert( *text > 0xA0 && *text < 0xFF);
codeset = CodeSet1;
}
return codeset;
}
static unsigned int JpGetLine ( const char *start_ptr,
const char *end_ptr,
int line_size )
{
if (start_ptr > end_ptr)
return 0;
if (end_ptr - start_ptr + 1 <= line_size)
return (end_ptr - start_ptr + 1);
// reference limit
const char* limit = start_ptr + line_size;
EucCodeSet codeset = JpEucCodeSet((const unsigned char*)start_ptr);
int len;
const char* p;
for (p = start_ptr; p < limit; p += len) {
if (JpEucCodeSet((const unsigned char*)p) != codeset)
break;
if (codeset == CodeSet0)
len = 1;
else if ((codeset == CodeSet1) || (codeset == CodeSet2))
len = 2;
else if (codeset == CodeSet3)
len = 3;
else
len = 0;
if ((len == 0) || (p + len - 1 > end_ptr))
break;
}
return (p - start_ptr);
}
#endif // DTSR_LIKES_FGETS
//-----------------------------------------------------------------------
static int isdir(const char* filename)
{
int ret = 0;
struct stat sb;
if(stat(filename, &sb) == 0){
if(S_ISDIR(sb.st_mode)){
ret = 1;
}
}
return ret;
}
//-----------------------------------------------------------------------
static void makedir(const char *path) /* throw(PosixError) */
{
if(mkdir((char*)path, 0775) != 0){
throw(PosixError(errno, path));
}
}
//-----------------------------------------------------------------------
AusTextStore::AusTextStore( const char *path, const char *name )
{
if ( !isdir(path) ) {
makedir(path);
}
int textlen = strlen(path) + 1 + strlen("dtsearch") + 1;
austext_path = new char [ textlen ];
/*
* throw(ResourceExhausted)
*
*/
assert ( austext_path != NULL );
snprintf( austext_path, textlen, "%s/dtsearch", path );
if ( !isdir(austext_path) ) {
makedir(austext_path);
}
char *fzk = form("%s/%s.fzk", austext_path, name );
/* Use append instead because this fzk file is going to be appended
* all the time
*/
afp = fopen ( fzk, "a" );
if ( !afp ) {
throw(PosixError(errno, form("unable to open fzk file %s\n", fzk) ) );
}
}
//-----------------------------------------------------------------------
void
AusTextStore::insert( const char *BookShortTitle,
const char *BookID,
const char *SectionID,
const char *SectionTitle,
DataRepository *store
)
{
/* write the abstract and record stuff in the fzk file */
if ( afp ) {
f_recordcount++;
/* Record type ie for all the zone content */
FlexBuffer **table = store->tabbuf();
for ( int pos=store->Default;
pos < store->Total;
pos++ ) {
if ( table[pos] ) {
if ( table[pos]->GetSize() > 0 ) {
fprintf(afp, " 0,2\n");
/* abstract includes SectionID\tBookShortTitle\tSectionTitle */
fprintf(afp, "ABSTRACT: %s\t%s\t%s\n", SectionID,
BookShortTitle,
SectionTitle );
// first the record type
// The following was unique, but there is a limit to the size of
// the key, so let's just use a simple counter.
// fprintf(afp, "%s%s%s\n", store->get_zone_name(pos), BookID, SectionID);
fprintf(afp, "%s%d\n", store->get_zone_name(pos), (int)f_recordcount);
fprintf(afp, "0/0/0~0:0\n"); // null date
// Now the actual buffer
const char *start_ptr = table[pos]->GetBuffer();
const char *end_ptr = start_ptr + table[pos]->GetSize() - 1;
#ifdef DTSR_LIKES_FGETS
unsigned int (*getline)(const char *, const char *, int);
const char* lang = getenv("LANG");
if (lang && !strncmp(lang, "ja", strlen("ja")))
getline = JpGetLine;
else
getline = DefaultGetLine;
int num_byte;
while ( num_byte = getline(start_ptr, end_ptr, LINE_SIZE) ) {
if ( !fwrite(start_ptr, num_byte, 1, afp ) )
{
throw(PosixError(errno, "unable to write to fzk file\n" ) );
}
fputc('\n', afp );
start_ptr += num_byte;
}
// for current section and book level scopes, place the book and
// section ids into the indexed data.
fprintf(afp, "\n%s\n%s\n", BookID, SectionID);
#else
char *ptr = (char*)start_ptr;
for (; ptr <= end_ptr; ptr++) {
if (*ptr == '\n')
*ptr = ' ';
}
if (fwrite(start_ptr, table[pos]->GetSize(), 1, afp) == 0)
throw(PosixError(errno, "unable to write to fzk file\n"));
// for current section and book level scopes, place the book and
// section ids into the indexed data.
fprintf(afp, "\t%s\t%s", BookID, SectionID);
#endif
#ifdef DTSR_USE_CNTR_L
// Then the ^L character at the end
fprintf(afp, "\n%c\n", CNTR_L );
#else
fprintf(afp, "\n");
#endif
}
}
}
}
}
//-----------------------------------------------------------------------
AusTextStore::~AusTextStore()
{
if ( afp ) { fclose(afp); }
if ( austext_path ) { delete [] austext_path; }
}

View File

@@ -0,0 +1,59 @@
/*
* 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
*/
/* $XConsortium: AusTextStorage.h /main/3 1996/07/18 16:39:21 drk $ */
#ifndef AUSTEXT_STOR_HDR
#define AUSTEXT_STOR_HDR
class DataRepository;
class AusTextStore {
private:
FILE *afp;
char *austext_path;
static unsigned long f_recordcount;
public:
AusTextStore( const char *BookCasePath, const char *BookCaseName );
/*
* insert ( "This Book Case Name", 2,
* "XmyLcfhalklkoop",
* "This is the text that the indexing machine will see",
* 51 );
*
*/
void insert( const char *BookShortTitle,
const char *BookID,
const char *SectionID,
const char *SectionTitle,
DataRepository *store
);
~AusTextStore();
};
#endif

View File

@@ -0,0 +1,50 @@
/*
* 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
*/
/* $XConsortium: BTCollectable.cc /main/2 1996/07/18 16:09:37 drk $ */
#include <string.h>
// exported interfaces
#include "BTCollectable.h"
//--------------------------------------------------------------------
BTCollectable::BTCollectable():f_name(0), line_num(0), value(0)
{
}
//--------------------------------------------------------------------
BTCollectable::BTCollectable(
const char *filename, int line_no, const char *val
)
{
f_name = strdup( filename );
line_num = line_no;
value = strdup( val );
}
//--------------------------------------------------------------------
BTCollectable::~BTCollectable()
{
delete f_name;
delete value;
}

View File

@@ -0,0 +1,48 @@
/*
* 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
*/
/* $XConsortium: BTCollectable.h /main/2 1996/07/18 16:39:46 drk $ */
#ifndef BT_COLLECT
#define BT_COLLECT
class BTCollectable
{
public:
BTCollectable();
BTCollectable( const char *filename, int line_no, const char *val=NULL );
~BTCollectable();
char *filename() { return(f_name); }
int linenum() { return(line_num); }
char *get_value() { return( value ); }
private:
char *f_name;
int line_num;
char *value;
};
#endif

View File

@@ -0,0 +1,64 @@
/*
* 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
*/
/* $XConsortium: BaseDataCollect.h /main/2 1996/07/18 16:40:12 drk $ */
#ifndef __BaseDataCollect_h
#define __BaseDataCollect_h
#include "Task.h"
#include "Token.h"
#include "FlexBuffer.h"
enum ActionType {
DEFAULT_ACTION=0,
IGNORE_ON=1,
REMOVE_SPACES=2,
GENERATE_ID=4
};
class BaseData : public ComplexTask {
protected:
int f_base;
FlexBuffer ValueBuffer;
int data_avail;
int data_complete;
int ignore_status;
protected:
BaseData( const Token &t, ActionType istat) {
f_base = t.level();
data_avail = 1;
data_complete = 0;
ignore_status = istat & IGNORE_ON;
}
public:
int ContentIsEmpty() { return ( ValueBuffer.GetSize() == 0 ); }
const char *content() { return( ValueBuffer.GetBuffer() ); }
int content_size() { return( ValueBuffer.GetSize() ); }
int DataWillBeAvailable() { return( data_avail ); }
int DataIsComplete() { return( data_complete ); }
};
#endif

View File

@@ -0,0 +1,103 @@
/*
* 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
*/
/* $XConsortium: BookCaseDB.C /main/4 1996/10/26 18:17:13 cde-hal $ */
#include "BookCaseDB.h"
#include <assert.h>
/*--------------------------------------------------------------------
*
* The BookCase is represented as a database (a directory) containing
* several tables (files).
*
* As the tables are shared by many tasks within the bookcase task,
* they are accessed through the bookcase, and created here...
*
*--------------------------------------------------------------------*/
/* This will be placed in a global .h file eventually */
#define LINK_CODE 1333
BookCaseDB::BookCaseDB(const char *dir)
: DB(dir)
{
for(int i = 0; i < TableQty; i++){
f_tables[i] = NULL;
}
}
//--------------------------------------------------------------------
struct Schema{
int id;
const char *name;
int code;
int cols;
};
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
//--------------------------------------------------------------------
DBTable*
BookCaseDB::table(int tid, int a)
{
static Schema schema[] = {
{ BookMeta, "BookMeta", DOC_CODE, 6 },
{ NodeMeta, "NodeMeta", NODE_CODE, 8 },
{ NodeSGML, "NodeSGML", SGML_CONTENT_CODE, 3 },
{ Link, "Link", LINK_CODE, 3 },
{ Locator, "Locator", LOCATOR_CODE, 5 },
{ TOCTree, "ContentsTree", TOC_CODE, 5 },
{ TOCPath, "ContentsPath", DLP_CODE, 4 },
{ Graphics, "Graphics", GRAPHIC_CODE, 7 },
{ StyleSheet, "StyleSheet", NODE_CODE, 3 },
{ XRef, "XRef", XREF_CODE, 4 },
};
assert(tid >= 0 && tid < TableQty);
assert(schema[tid].id == tid); /* just be sure the code doesn't get out
* of sync.
*/
if(!f_tables[tid]){
f_tables[tid] = DB::table(schema[tid].name,
schema[tid].code,
schema[tid].cols,
a);
}
return f_tables[tid];
}
BookCaseDB::~BookCaseDB()
{
for( int i = 0; i < TableQty; i++ ) {
if ( f_tables[i] ) {
delete f_tables[i]; f_tables[i] = 0;
}
}
}

View File

@@ -0,0 +1,54 @@
/*
* 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
*/
/* $XConsortium: BookCaseDB.h /main/3 1996/09/23 22:23:30 cde-hal $ -*- c++ -*- */
#ifndef __BookCaseDB_h
#define __BookCaseDB_h
#include "DataBase.h"
class BookCaseDB : public DB{
public:
BookCaseDB(const char *dir);
~BookCaseDB();
/*
* Enumeration of tables...
*/
typedef enum {
BookMeta,
NodeMeta, NodeSGML, Link, Locator,
TOCTree, TOCPath,
Graphics,
StyleSheet,
XRef,
TableQty
}TableID;
DBTable *table(int, int access = DB::CREATE);
DBTable *f_tables[TableQty];
};
#endif /* __BookCaseDB_h */

View File

@@ -0,0 +1,684 @@
/*
* 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
*/
/* $XConsortium: BookTasks.cc /main/5 1996/05/29 12:36:58 rcs $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#include <sstream>
using namespace std;
/* import... */
#include <assert.h>
#include <string.h>
#include "Dispatch.h"
#include "Token.h"
#include "OLAF.h"
#include "NodeTask.h"
#include "TOCTask.h"
#include "BookCaseDB.h"
#include "OL_Data.h"
#include "StringList.h"
#include "StyleTask.h"
#include "api/utility.h"
/* export... */
#include "BookTasks.h"
#ifdef LICENSE_MANAGEMENT
#include "cryptlib/lterms.h"
#endif
#ifdef FISH_DEBUG
#include "dbug.h" /* ala Fred Fish's dbug package from uunet */
#endif
#ifdef LICENSE_MANAGEMENT
const int A_FEATURE = OLAF::Feature;
const int A_VEN_CODE = OLAF::VenCode;
const int A_VERSION = OLAF::Version;
const int A_GROUPING = OLAF::Grouping;
const int A_DEMO_TERMS = OLAF::DemoTerms;
const int A_DEFAULT_SECTION = OLAF::DefaultSection;
#endif
/***********************************
*
* BookCaseTask
*
***********************************/
BookCaseTask::BookCaseTask(const char *infolib)
{
int len = strlen(infolib);
library = new char[len + 1];
*((char *) memcpy(library, infolib, len) + len) = '\0';
f_base = -1;
bookCaseName = NULL;
bookCaseDesc = NULL;
f_db = NULL;
if ( !Dispatch::RunTocGenOnly() ) {
style = new StyleTaskDB(this);
addSubTask(style);
} else {
style = NULL;
}
book = new BookTask(this);
addSubTask(book);
f_style = NULL;
f_search_storage = NULL;
}
//--------------------------------------------------------------------
BookCaseDB*
BookCaseTask::database()
{
if(!f_db){
f_db = new BookCaseDB(library);
}
return f_db;
}
//--------------------------------------------------------------------
DBTable *
BookCaseTask::table(int tid)
{
return database()->table(tid);
}
//--------------------------------------------------------------------
const char *
BookCaseTask::bookcasename()
{
if ( !bookCaseName ) {
throw(Unexpected("BookCase name not available yet."));
}
return ( bookCaseName->content() );
}
/*
//--------------------------------------------------------------------
void
BookCaseTask::write_full_text_record( const char *str,
int sz,
const char *nodelocator,
const char *node_title
)
{
const char *BookCaseName = bookcasename();
if ( !f_search_storage ) {
const char *pathname = database()->path();
f_search_storage = new FulcrumStore( pathname , BookCaseName);
assert ( f_search_storage );
}
const int BookNum = book->sequencenum();
const char *BookShortTitle = book->book_short_title();
f_search_storage->insert( BookCaseName,
BookNum,
BookShortTitle,
nodelocator,
node_title,
str,
sz );
}
*/
/*
//--------------------------------------------------------------------
void
BookCaseTask::write_full_text_record(DataRepository *store,
const char *nodelocator,
const char *node_title
)
{
const char *BookCaseName = bookcasename();
if ( !f_search_storage ) {
const char *pathname = database()->path();
f_search_storage = new AusTextStore( pathname, BookCaseName );
assert( f_search_storage );
}
const char *BookShortTitle = book->book_short_title();
f_search_storage->insert( BookShortTitle,
nodelocator,
node_title,
store
);
}
*/
//--------------------------------------------------------------------
void BookCaseTask::markup(const Token &t)
{
ComplexTask::markup(t);
if (t.type() == START){
if(t.olaf() == OLAF::Bookcase){
if(f_base >= 0){
throw(Unexpected("second (illegal) BookCase element found"));
}
f_base = t.level();
}
if(f_base >= 0){
switch(t.olaf()){
case OLAF::BcName:
if(bookCaseName){
throw(Unexpected("second (illegal) bookcase name element found"));
}
bookCaseName = new OL_Data(t, OLAF::OL_data);
addSubTask(bookCaseName);
break;
case OLAF::BcDesc:
if(bookCaseDesc){
throw(Unexpected("second (illegal) bookcase description element found"));
}
bookCaseDesc = new OL_Data(t, OLAF::OL_data);
addSubTask(bookCaseDesc);
break;
}
if(!f_style && t.LookupAttr(OLAF::OL_style)){
OL_Data *tmp_style = new OL_Data(t, OLAF::OL_style);
if ( tmp_style->DataWillBeAvailable() ) {
f_style = tmp_style;
addSubTask(f_style);
}
else {
delete tmp_style;
}
}
}
}
else if(t.type() == END){
if(t.level() == f_base){
const char *name;
const char *desc;
if(bookCaseName){
name = bookCaseName->content();
}else{
throw(Unexpected("No bookcase name element in Bookcase element."));
}
if(bookCaseDesc){
desc = bookCaseDesc->content();
}else{
desc = "";
}
printf("BookCase name: `%s' desc: `%s'\n", name, desc);
}
/* @# warn if no bookcase ever found? */
}
}
const char *
BookCaseTask::styleName()
{
const char *ret;
if ( Dispatch::RunTocGenOnly() ) {
return("");
}
if(!f_style) {
throw(Unexpected ("No style architectural form defined for bookcase."));
}
ret = f_style->content();
#ifdef FISH_DEBUG
DBUG_PRINT("Style", ("bookcase style is: %s", ret));
#endif
if(!style->exist(ret)){
#ifdef FISH_DEBUG
DBUG_PRINT("Error", ("style `%s' not found", ret));
#endif
Token::signalError(Token::User, Token::Fatal, NULL, 0,
"An undeclared style sheet name `%s' was found in the bookcase specification.\n", ret);
}
return ret;
}
/*****************
*
* BookTask
*
*****************/
BookTask::BookTask(BookCaseTask *bc)
{
f_base = 0;
f_seq_no = 1;
f_toc = NULL;
f_bookcase = bc;
tocLocator = NULL;
shortTitle = NULL;
title = NULL;
tabName = NULL;
tabLocator = NULL;
tabNames = new StringList();
tabLocators = new StringList();
tabLines = new StringList();
tabFiles = new StringList();
f_node = new NodeTask(this, NULL);
addSubTask(f_node);
f_style = NULL;
e_string = NULL;
e_len = 0;
}
BookTask::~BookTask()
{
KILLSUBTASK(f_node);
delete tabLocators;
KILLSUBTASK(title);
KILLSUBTASK(shortTitle);
KILLSUBTASK(tabName);
KILLSUBTASK(tabLocator);
}
//------------------------------------------------------------------
void
BookTask::encrypt( const Token &t )
{
/*
* Grab all the strings that are required by the encryption API
*/
char buf[ 256 ];
#ifdef LICENSE_MANAGEMENT
LTerms lt;
char *a_val;
for ( const AttributeRec *arec = t.GetFirstAttr();
arec;
arec = t.GetNextAttr( arec ) ) {
a_val = ( char * )arec->getAttrValueString();
#ifdef FISH_DEBUG
DBUG_PRINT("BookTasks", ("access attribute value %s", a_val) );
#endif
switch ( arec->getAttrName() ) {
case A_FEATURE :
if ( lt.add_feature( a_val ) != 0 ) {
throw(Unexpected("invalid access feature syntax"));
}
break;
case A_VEN_CODE :
if ( lt.add_ven_code( a_val ) != 0 ) {
throw(Unexpected("invalid access ven_code syntax") );
}
break;
case A_VERSION :
if ( lt.add_version( a_val ) != 0 ) {
throw(Unexpected("invalid access version syntax"));
}
break;
case A_GROUPING :
if ( lt.add_grouping( a_val ) != 0 ) {
throw(Unexpected("invalid access grouping syntax"));
}
break;
case A_DEMO_TERMS :
if ( lt.add_demo_terms( a_val ) != 0 ) {
throw(Unexpected("invalid access demo_terms syntax"));
}
break;
case A_DEFAULT_SECTION :
if ( lt.add_noaccess_locator( a_val ) != 0 ) {
throw(Unexpected("invalid default section ID syntax"));
}
break;
}
}
if ( lt.pack( buf, 256 ) ) {
throw(Unexpected("Unable to pack the string for encryption"));
}
int len = 256;
if ( e_terms( &lt, buf, len ) ) {
throw(Unexpected("Unable to encrypt string for access control"));
}
#else
int len = 256;
(void) memset(buf, '\0', len);
#endif
e_string = (char *)malloc(len);
(void)memcpy(e_string, buf, len); // Cannot use strdup - embedded NULs
e_len = len;
}
//----------------------------------------------------------------------
void BookTask::markup(const Token &t)
{
ComplexTask::markup(t);
if(t.type() == START){
if(t.olaf() == OLAF::Book){
if(f_base > 0){
throw(Unexpected("illegal nested BOOK architectural form"));
}
f_base = t.level();
}
if(f_base >= 0){
switch(t.olaf()){
case OLAF::BkSTitle:
if(shortTitle){
throw(Unexpected("BkSTitle already found"));
}
shortTitle = new OL_Data(t, OLAF::OL_data);
addSubTask(shortTitle);
break;
case OLAF::BkTitle:
if(title){
throw(Unexpected("BkTitle already found"));
}
title = new OL_Data(t, OLAF::OL_data);
addSubTask(title);
break;
case OLAF::Tab:
if(tabName){
tabNames->append(tabName->content());
tabLocators->append(tabLocator->content());
tabLines->append( form("%d", tabLocator->line_no()) );
tabFiles->append( tabLocator->filename() );
KILLSUBTASK(tabName);
KILLSUBTASK(tabLocator);
}
tabName = new OL_Data(t, OLAF::OL_data);
tabLocator = new OL_Data(t, OLAF::OL_idref, REMOVE_SPACES);
addSubTask(tabName);
addSubTask(tabLocator);
break;
case OLAF::BookAccess:
encrypt( t );
break;
}
if ( t.LookupAttr( OLAF::OL_ToC ) ) {
if ( f_toc ) {
throw(Unexpected("An illegal TOC was found.\n"));
}
f_toc = new TOCTask(t, this);
addSubTask(f_toc);
}
if(f_base >= 0 && !f_style && t.LookupAttr(OLAF::OL_style)){
OL_Data *tmp_style = new OL_Data(t, OLAF::OL_style);
if ( tmp_style->DataWillBeAvailable() ) {
f_style = tmp_style;
addSubTask(f_style);
}
else {
delete tmp_style;
}
}
}
}
else if(t.type() == END){
if(t.level() == f_base){ /* found end of book... write out CCF data */
if ( !Dispatch::RunTocGenOnly() ) {
write_record();
}
reset();
}
}
}
//----------------------------------------------------------------------
void BookTask::write_record(void)
{
StringList tablines;
/* finish any pending tab */
if(tabName){
tabNames->append(tabName->content());
tabLocators->append(tabLocator->content());
tabLines->append( form("%d", tabLocator->line_no()) );
tabFiles->append(tabLocator->filename());
}
for(unsigned int i = 0; i < tabNames->qty(); i++){
const char *name = tabNames->item(i);
const char *loc = tabLocators->item(i);
const char *line = tabLines->item(i);
const char *file = tabFiles->item(i);
int plen = strlen(name) + 1 + strlen(loc) + 1
+ strlen(line) + 1 + strlen(file) + 1;
char *p = new char [plen];
snprintf(p, plen, "%s\t%s\t%s\t%s", name, loc, line, file);
tablines.append(p);
delete [] p;
}
const char *bk_title;
if(title){
bk_title = title->content();
}else{
throw(Unexpected("Required Title form missing from Book"));
}
const char *bk_stitle = bk_title;
if ( shortTitle ) {
bk_stitle = shortTitle->content();
}
DBTable *tbl = bookcase()->table(BookCaseDB::BookMeta);
tbl->insert(STRING_CODE, locator(),
STRING_CODE, bk_stitle,
STRING_CODE, bk_title,
INTEGER_CODE, f_seq_no,
SHORT_LIST_CODE, tablines.qty(), STRING_CODE, tablines.array(),
-STRING_CODE, e_string , (size_t)e_len,
NULL);
#ifdef FISH_DEBUG
DBUG_PRINT("Book", ("Book... title: `%s' short title: `%s'\n",
bk_title,
bk_stitle));
#endif
}
void BookTask::reset()
{
KILLSUBTASK(shortTitle);
KILLSUBTASK(title);
KILLSUBTASK(f_toc);
KILLSUBTASK(f_style);
delete tabNames; tabNames = new StringList();
delete tabLocators; tabLocators = new StringList();
tabName = tabLocator = NULL;
delete tabLines; tabLines = new StringList();
delete tabFiles; tabFiles = new StringList();
delete [] tocLocator; tocLocator = NULL;
f_seq_no ++;
f_base = 0;
}
const char *BookTask::locator()
{
if ( Dispatch::RunTocGenOnly() ) {
return ("");
}
if(!tocLocator){
/* this is the first time anybody asked for the book's locator...
* it must be the TOC node asking for the book locator, which
* is the TOC node locator!
*/
const char *l = f_node->locator();
int len = strlen(l);
tocLocator = new char[len + 1];
*((char *) memcpy(tocLocator, l, len) + len) = '\0';
}
return tocLocator;
}
const char *
BookTask::styleName()
{
if ( Dispatch::RunTocGenOnly() ) {
return("");
}
const char *ret;
if(f_style){
ret = f_style->content();
if(f_bookcase->styleTask()->exist(ret)){
#ifdef FISH_DEBUG
DBUG_PRINT("Style", ("book style is: %s", ret));
#endif
}else{
Token::signalError(Token::User, Token::Continuable, NULL, 0,
"no such style `%s'\n", ret);
ret = f_bookcase->styleName();
}
}else{
ret = f_bookcase->styleName();
}
return ret;
}
//--------------------------------------------------------------
const char *
BookTask::book_title()
{
if ( !title ) {
throw(Unexpected("Book title is not available yet"));
}
return( title->content() );
}
//--------------------------------------------------------------
const char *
BookTask::book_short_title()
{
if ( !shortTitle ) {
return( book_title() );
}
return( shortTitle->content() );
}

View File

@@ -0,0 +1,135 @@
/*
* 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
*/
/* $XConsortium: BookTasks.h /main/3 1996/07/18 15:15:19 drk $ */
#ifndef __BookTasks_h
#define __BookTasks_h
#include "Task.h"
class BookTask;
class NodeTask;
class StyleTask;
class OL_Data;
class DBTable;
class DB;
class SearchStorage;
class BookCaseDB;
class BookCaseTask : public ComplexTask{
public:
BookCaseTask(const char* infolib);
void markup(const Token&);
BookCaseDB *database(); /* throw(Unexpected) */
DBTable *table(int); /* throw(Unexpected) */
const char *bookcasename(); /* throw(Unexpected) */
void write_full_text_record( const char *str,
int sz,
const char *nodelocator,
const char *node_title
);
const char *styleName(); /* throw(Unexpected) */
StyleTask *styleTask() { return style; };
private:
char *library;
int f_base;
BookCaseDB *f_db;
StyleTask *style;
BookTask *book;
SearchStorage *f_search_storage;
OL_Data *bookCaseName;
OL_Data *bookCaseDesc;
OL_Data *f_style;
};
class BookTask : public ComplexTask{
public:
BookTask(BookCaseTask *);
~BookTask();
void reset(void);
void markup(const Token&);
BookCaseTask *bookcase() { return f_bookcase; };
int sequencenum() const { return f_seq_no; }
const char *locator(); /* Locator for this book, i.e.
* for the TOC node for this book
*/
const char *styleName(); /* throw(Unexpected) */
const char *book_short_title(); /* throw(Unexpected) */
const char *book_title(); /* throw(Unexpected) */
protected:
void write_record(void);
private:
int f_base; /* tag nesting level of <BOOK> elt */
int f_seq_no; /* fulltext index document sequence number */
BookCaseTask *f_bookcase; /* 'parent' bookcase object */
OL_Data *shortTitle; /* short title collection task */
OL_Data *title; /* title collection task */
char *tocLocator; /* locator of TOC node */
OL_Data *tabName;
OL_Data *tabLocator;
class StringList *tabNames;
class StringList *tabLocators;
class StringList *tabLines;
class StringList *tabFiles;
NodeTask *f_node;
Task *f_toc;
OL_Data *f_style;
void encrypt( const Token & );
char *e_string; /*
* The encrypted string that is associated
* with the access permission for this book
*/
int e_len;
};
#endif /* __BookTasks_h */

View File

@@ -0,0 +1,24 @@
#!/bin/sh
## ChangeCaseTitle $SrcLibDir $BookCaseName $BookCaseTitle
if [ $# -lt 3 ]; then
echo "(ERROR) Usage : ChangCaseTitle SrcLibDir BookCaseName BookCaseTitle"
exit 1
fi
SrcLibDir=$1
BookCaseName=$2
BookCaseTitle=$3
MMDBMAP=bookcase.map
## first grab the entry out from the $MMDBMAP ##
awk ' BEGIN { FS="\t" }
{ if ( $1 == BookCaseName && NR > 1 )
printf("%s\t%s\t%s\t%s\t%d\t%d\n", $1, BookCaseTitle, $3, $4, $5, $6);
else { print $0 }
}' BookCaseName=$BookCaseName BookCaseTitle="$BookCaseTitle" < $SrcLibDir/$MMDBMAP > $SrcLibDir/$MMDBMAP.$$
mv $SrcLibDir/$MMDBMAP.$$ $SrcLibDir/$MMDBMAP
exit $?

View File

@@ -0,0 +1,85 @@
/*
* 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
*/
/* $XConsortium: ConcatTask.C /main/3 1996/08/21 15:46:12 drk $ */
/* exported interfaces */
#include "ConcatTask.h"
/* imported interfaces */
#include "Expression.h"
#include "ExprList.h"
#include "Token.h"
#include "AttributeData.h"
#include "Content.h"
#include "FirstOf.h"
#include "GenericId.h"
#include "Literal.h"
Concat::Concat( const Token &t,
ExprList *elist,
ActionType mode):OL_Data(t, mode)
{
for ( OL_Expression *eptr = elist->first();
eptr;
eptr = elist->next(eptr) ) {
switch ( eptr->type() ) {
case REFERENCE:
addSubTask( new AttributeData( t, eptr->name(), mode ));
break;
case CONTENT:
addSubTask( new Content(t,mode) );
break;
case CONCAT:
addSubTask( new Concat( t,
(ExprList *)eptr->data_list(),
mode) );
break;
case FIRSTOF:
addSubTask( new FirstOf( t,
(ExprList *)eptr->data_list(),
mode) );
break;
case GENERIC_ID:
addSubTask( new GenericId( t,
eptr->name(),
mode) );
break;
case LITERAL:
addSubTask( new Literal( t,
( const char *)eptr->data_list(),
mode) );
break;
default:
abort();
}
}
}

View File

@@ -0,0 +1,45 @@
/*
* 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
*/
/* $XConsortium: ConcatTask.h /main/2 1996/07/18 16:40:43 drk $ */
#ifndef __Concat_h__
#define __Concat_h__
#include "Task.h"
#include "OL_Data.h"
class ExprList;
class Token;
class Concat : public OL_Data {
friend class FirstOf;
friend class OL_Data;
protected:
Concat( const Token &t, ExprList *elist, ActionType mode );
void markup( const Token &t ) { OL_Data::markup(t); }
void data( const char *str, size_t sz ) { OL_Data::data(str, sz); }
};
#endif

View File

@@ -0,0 +1,77 @@
/*
* 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
*/
/* $XConsortium: Content.cc /main/2 1996/07/18 16:10:34 drk $ */
/* exported interfaces */
#include "Content.h"
/* imported interfaces */
#include "Dispatch.h"
#include "OL_Data.h"
#include "Token.h"
#include "SGMLName.h"
void
Content::markup( const Token &t )
{
if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
if ( t.type() == END ) {
if ( f_base == t.level() ) {
f_base = -1;
data_complete=1;
}
}
else if ( t.type() == EXTERNAL_ENTITY ) {
data_avail = 1;
ValueBuffer.writeStr( t.getEntityFileName() );
}
else if ( t.type() == INTERNAL_ENTITY ) {
data_avail = 1;
ValueBuffer.put( '&' );
ValueBuffer.writeStr( SGMLName::lookup( t.getEntityName() ) );
ValueBuffer.put( ';' );
}
}
}
void
Content::data( const char *str, size_t sz )
{
if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
ValueBuffer.write ( str, sz );
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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
*/
/* $XConsortium: Content.h /main/2 1996/07/18 16:41:08 drk $ */
#ifndef __Cont_h__
#define __Cont_h__
#include "BaseDataCollect.h"
class Token;
class Content : public BaseData {
friend class FirstOf;
friend class OL_Data;
friend class Concat;
protected:
Content( const Token &t , ActionType mode);
void markup( const Token &t );
void data( const char *str, size_t sz );
};
inline
Content::Content( const Token &t, ActionType mode ):BaseData(t, mode) {}
#endif

View File

@@ -0,0 +1,56 @@
/*
* 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
*/
/* $XConsortium: ContentRec.h /main/2 1996/07/18 16:41:34 drk $ */
#ifndef __CRec_hdr__
#define __CRec_hdr__
#include "VarElementList.h"
class ContentRec {
friend class OL_Data;
friend int ol_dataparse();
friend class ContentType;
private:
int data_type;
int attr_name;
VarElementList var_list;
ContentRec *next;
public:
void Init ( int dtype, int aname=0, VarElement *vList=0 );
ContentRec() { attr_name = -1; data_type=-1, next = 0; }
};
/*--------------------------------------------------------*/
inline
void
ContentRec::Init( int dtype, int aname, VarElement *vlist )
{
data_type = dtype;
attr_name = aname;
var_list.insert ( vlist );
}
#endif

View File

@@ -0,0 +1,50 @@
/*
* 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
*/
/* $XConsortium: ContentType.h /main/3 1996/08/21 15:46:16 drk $ */
#ifndef __Content_Type_h__
#define __Content_Type_h__
#include <assert.h>
class OL_Expression;
class ContentType {
friend class OL_Data;
private:
OL_Expression *exprlist;
protected:
void Parse( char *str );
ContentType();
~ContentType();
public:
void init ( OL_Expression *elist ); // Construct a ExprList object
};
#endif

View File

@@ -0,0 +1,212 @@
%option noyywrap
%{
/* $XConsortium: ContentType.l /main/2 1996/11/19 16:54:22 drk $ */
#include <iostream>
#include <sstream>
using namespace std;
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "dti_excs/Exceptions.hh"
#include "Task.h"
#include "SGMLName.h"
#include "ExprList.h"
#include "Expression.h"
#include "OL_DataExpr.tab.h"
#include "ContentType.h"
#include "api/utility.h"
/* CurrentContentPtr is used as the communication media between
* ol_dataparse and ContentType::Parse()
*/
ContentType *CurrentContentPtr;
/*
* Forward declaration for my_input
*/
static int my_input ( char *, int );
extern int ol_dataparse();
#undef YY_INPUT
#define YY_INPUT(b, r, ms ) ( r=my_input( ( char *)b,ms) )
static char *myinput;
static char *myinputptr;
static char *myinputlim;
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
static int dbgLevel = -1;
%}
%%
"@"[a-zA-Z0-9]+ {
ol_datalval.name = SGMLName::intern((const char *)yytext+1 ,1);
return( Reference );
}
["][^"]*["] {
if ( *(yytext + 1) != '"' ) {
// get rid of the 2 quotes
int len = strlen(( const char *)yytext)-2;
char *lit_str = new char [ len + 1 ];
strncpy ( lit_str,
(const char *)yytext + 1,
len );
*(lit_str + len) = '\0';
ol_datalval.string = lit_str;
}
else {
ol_datalval.string = 0;
}
DBG(50) cerr << "(DEBUG) literal \"string\" = "
<< ol_datalval.string << endl;
return( Literal );
}
['][^']*['] {
if ( *(yytext + 1) != '\'' ) {
// get rid of the 2 quotes
int len = strlen(( const char *)yytext)-2;
char *lit_str = new char [ len + 1 ];
strncpy ( lit_str,
(const char *)yytext + 1,
len );
*(lit_str + len) = '\0';
ol_datalval.string = lit_str;
}
else {
ol_datalval.string = 0;
}
DBG(50) cerr << "(DEBUG) literal 'string' = "
<< ol_datalval.string << endl;
return( Literal );
}
[Aa][Tt][Tt][Rr] { return( Attr ); }
[Cc][Oo][Nn][Cc][Aa][Tt] { return( Concat ); }
[Ff][Ii][Rr][Ss][Tt][Oo][Ff] { return( FirstOf); }
"#"[Cc][Oo][Nn][Tt][Ee][Nn][Tt] { return( Content ); }
[^(,)\n\t ]+ {
ol_datalval.name = SGMLName::intern((const char *)yytext,1);
DBG(10) cerr << "(DEBUG) matches"
<< (char *)SGMLName::lookup(ol_datalval.name)
<< endl;
return ( Id );
}
[(,)] {
DBG(10) cerr << "(DEBUG) matches"
<< (char *)yytext
<< endl;
return ( yytext[0] );
}
[\n\t ]+ ;
. {
throw(Unexpected(
"Syntax error in value expression"));
}
%%
static int
my_input ( char *buf, int max_size )
{
int remain = myinputlim - myinputptr;
int n = ( max_size > remain ? remain : max_size );
if ( n > 0 ) {
memcpy ( buf, myinputptr, n );
myinputptr += n;
}
return n;
}
//--------------------------------------------------------------
void
ol_dataerror(const char *str)
{
throw(Unexpected(form("Syntax error in %s", myinput)));
}
//--------------------------------------------------------------
ContentType::ContentType()
{
char *dbgStr;
dbgStr = getenv ("OL_DEBUG");
dbgLevel = ( dbgStr ? atoi ( dbgStr ) : 0 );
exprlist = 0;
}
//--------------------------------------------------------------
ContentType::~ContentType()
{
OL_Expression *eptr = exprlist;
while ( eptr ) {
OL_Expression *tmp = eptr;
eptr = eptr->next;
delete tmp;
}
}
//--------------------------------------------------------------
void
ContentType::Parse( char *str )
{
DBG(10) cerr << "(DEBUG) ContentType::Parse() str = " << str << endl;
myinput = str;
myinputptr = str;
myinputlim = str + strlen(str);
CurrentContentPtr = this;
ol_dataparse();
BEGIN INITIAL;
yyrestart(NULL);
}
//--------------------------------------------------------------
void
ContentType::init( OL_Expression *expr )
{
assert(expr);
if ( expr->next ) {
/*
* The same as CONCAT
*/
ExprList *elist = new ExprList( expr );
OL_Expression *new_expr = new OL_Expression ( CONCAT, -1, elist );
assert(new_expr);
exprlist = new_expr;
}
else {
exprlist = expr;
}
}

View File

@@ -0,0 +1,662 @@
/*
* 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: DataBase.C /main/5 1998/04/17 11:43:17 mgreess $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
/* imported interfaces... */
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "StringList.h"
#include "Token.h"
/* exported interfaces... */
#include "DataBase.h"
#define FRIENDLY_ASSERT(e) \
if(!(e)) Token::signalError(Token::Internal, Token::Fatal, \
__FILE__, __LINE__, \
"assertion failed: " #e);
DB::DB(const char *name)
{
int len = strlen(name);
f_name = new char[len + 1];
*((char *) memcpy(f_name, name, len) + len) = '\0';
}
static int isdir(const char* filename)
{
int ret = 0;
struct stat sb;
if(stat(filename, &sb) == 0){
if(S_ISDIR(sb.st_mode)){
ret = 1;
}
}
return ret;
}
static void makedir(const char *path) /* throw(PosixError) */
{
if(mkdir((char*)path, DATABASE_DIRECTORY_MODE) != 0){
throw(PosixError(errno, path));
}
}
DBTable *DB::table(const char *tname, int scode, int cols,
int access)
/* throw(PosixError); */
{
DBTable *ret = 0; /* keep compiler happy */
switch(access){
case CREATE:
if(!isdir(f_name)){
makedir(f_name);
}
ret = new DBTable(this, scode, cols, tname);
break;
case READ:
ret = new DBTable(this, scode, cols, tname);
ret->file(DB::READ);
break;
default:
abort();
}
return ret;
}
DBTable::DBTable(DB *database, int schema_code, int cols, const char *name)
{
f_database = database;
f_schema_code = schema_code;
f_cols = cols;
int len = strlen(name);
f_name = new char[len + 1];
*((char *) memcpy(f_name, name, len) + len) = '\0';
f_file = NULL;
f_start = 0;
}
DBTable::~DBTable()
{
if(f_file && strcmp(f_name, DATABASE_STDIO) != 0) fclose(f_file);
delete f_name;
}
FILE *
DBTable::file(DB::Access access)
{
if(!f_file){
if(strcmp(f_name, DATABASE_STDIO) == 0){
f_file = access == DB::CREATE ? stdout : stdin;
}else{
const char *p = f_database->path();
int pathlen = strlen(p) + 1 + strlen(f_name) + 1;
char *path = new char[pathlen];
snprintf(path, pathlen, "%s/%s", p, f_name);
f_file = fopen(path, access == DB::CREATE ? "w" : "r");
if(!f_file){
throw(PosixError(errno, path));
}
delete [] path;
}
}
return f_file;
}
//----------------------------------------------------------
void DBTable::insert(int typecode, ...)
{
FILE *out = file(DB::CREATE);
va_list ap;
va_start(ap, typecode);
fprintf(out, "%d\n%d\n", f_schema_code, f_cols);
int cols_found = 0;
while(typecode != 0){
switch(typecode){
case STRING_CODE:
{
const char *str = va_arg(ap, const char*);
fprintf(out, "%d\n%ld\t%s\n", STRING_CODE, (long)strlen(str), str);
}
break;
case -STRING_CODE:
{
const char *str = va_arg(ap, const char*);
size_t len = va_arg(ap, size_t);
fprintf(out, "%d\n%ld\t", STRING_CODE, (long)len );
fwrite ( str, len, 1, out );
fputc( '\n', out);
}
break;
case COMPRESSED_STRING_CODE:
{
const char *comp_agent = va_arg(ap, const char* );
const char *str = va_arg(ap, const char* );
fprintf(out, "%d\n%s\n%ld\t%s\n", COMPRESSED_STRING_CODE,comp_agent,
(long)strlen(str), str );
}
break;
case -COMPRESSED_STRING_CODE:
{
const char *comp_agent = va_arg(ap, const char* );
const char *str = va_arg(ap, const char* );
size_t len = va_arg(ap, size_t );
fprintf(out, "%d\n%s\n%ld\t", COMPRESSED_STRING_CODE,
comp_agent,
(long)len
);
fwrite( str, len, 1, out );
fputc('\n', out);
}
break;
case OID_CODE:
{
const char *oid = va_arg(ap, const char*);
fprintf(out, "%d\n%s\n", OID_CODE, oid);
}
break;
case INTEGER_CODE:
{
int x = va_arg(ap, int);
fprintf(out, "%d\n%d\n", INTEGER_CODE, x);
}
break;
case SHORT_LIST_CODE:
{
int qty = va_arg(ap, int);
int code = va_arg(ap, int);
fprintf(out, "%d\n#\n", SHORT_LIST_CODE);
switch(code){
case INTEGER_CODE:
{
int *items = va_arg(ap, int*);
for(int i = 0; i < qty; i++){
fprintf(out, "%d\n%d\n", code, items[i]);
}
}
break;
case STRING_CODE:
{
const char **items = va_arg(ap, const char**);
for(int i = 0; i < qty; i++){
fprintf(out, "%d\n%ld\t%s\n",
code, (long)strlen(items[i]), items[i]);
}
}
break;
case OID_CODE:
{
const char **items = va_arg(ap, const char**);
for(int i = 0; i < qty; i++){
fprintf(out, "%d\n%s\n",
code, items[i]);
}
}
break;
default:
fprintf(stderr, "Internal error: unknown database type code: %d\n",
code);
abort();
}
fprintf(out, "#\n");
break;
}
case OID_LIST_CODE:
{
int qty = va_arg(ap, int);
fprintf(out, "%d\n#\n", OID_LIST_CODE);
const char **items = va_arg(ap, const char**);
for(int i = 0; i < qty; i++){
fprintf(out, "%s\n", items[i]);
}
fprintf(out, "#\n");
break;
}
default:
fprintf(stderr, "Internal error: unknown database type code: %d\n",
typecode);
abort();
}
cols_found++;
typecode = va_arg(ap, int);
}
va_end(ap);
fflush(out); /* @# some routines are sloppy and don't
* close their tables!
*/
assert(cols_found == f_cols);
}
//----------------------------------------------------------
void DBTable::insert_untagged(int typecode, ...)
{
FILE *out = file(DB::CREATE);
va_list ap;
va_start(ap, typecode);
fprintf(out, "%d\n", f_schema_code);
if(f_start){
fprintf(out, "+");
f_start = 0;
}
int cols_found = 0;
while(typecode != 0){
switch(typecode){
case STRING_CODE:
{
const char *str = va_arg(ap, const char*);
fprintf(out, "%ld\t%s\n", (long)strlen(str), str);
}
break;
case -STRING_CODE:
{
const char *str = va_arg(ap, const char*);
size_t len = va_arg(ap, size_t);
fprintf(out, "%ld\t", (long)len );
fwrite ( str, len, 1, out );
fputc( '\n', out);
}
break;
case OID_CODE:
{
const char *oid = va_arg(ap, const char*);
fprintf(out, "%s\n", oid);
}
break;
case INTEGER_CODE:
{
int x = va_arg(ap, int);
fprintf(out, "%d\n", x);
}
break;
default:
fprintf(stderr, "Internal error: unknown database type code: %d\n",
typecode);
abort();
}
cols_found++;
typecode = va_arg(ap, int);
}
va_end(ap);
fflush(out); /* @# some routines are sloppy and don't
* close their tables!
*/
assert(cols_found == f_cols);
}
//----------------------------------------------------------
void DBTable::start_list()
{
this->f_start = 1;
}
//----------------------------------------------------------
void DBTable::end_list()
{
fprintf(file(DB::CREATE), "-\n");
f_start = 0;
}
//----------------------------------------------------------
DBCursor::DBCursor(DBTable &t)
{
f_table = &t;
f_start = -1;
f_fields = new StringList();
f_list = NULL;
}
//----------------------------------------------------------
DBCursor::~DBCursor()
{
// this is for the last record
delete f_fields;
if ( f_list ) delete f_list;
}
//----------------------------------------------------------
void DBCursor::string_field(FILE *fp, char **out, int *lenOut)
{
int len = 0;
int io;
/* fscanf is weird, so we do it ourselves... */
while(isdigit(io = fgetc(fp))){
len = len * 10 + (io - '0');
}
FRIENDLY_ASSERT(io == '\t');
char *str = new char[len + 1];
io = fread(str, sizeof(str[0]), len+1, fp); /* read \n also */
FRIENDLY_ASSERT(io == len+1);
str[len] = 0; /* replace \n with 0 (just in case...) */
if(out){
f_fields->add(str);
*out = str;
if(lenOut) *lenOut = len;
}else{
delete [] str;
}
}
void DBCursor::int_field(FILE *fp, int *out)
{
int an_int;
int io;
io = fscanf(fp, "%d\n", &an_int);
FRIENDLY_ASSERT(io == 1);
if(out) *out = an_int;
}
void DBCursor::short_list(FILE *fp, int *qout, int ltype, void *out)
{
int c;
int ret;
c = fgetc(fp);
FRIENDLY_ASSERT(c == '#');
c = fgetc(fp);
FRIENDLY_ASSERT(c == '\n');
switch(ltype){
case STRING_CODE:
{
typedef const char** ccpp;
ccpp *cpout = (ccpp*)out;
assert(f_list == NULL); /* only one SHORT_LIST per record supported */
f_list = new StringList;
while((c = fgetc(fp)) != '#'){
char *item;
int ftype;
ungetc(c, fp);
ret = fscanf(fp, "%d\n", &ftype);
if(ret == 0) throw(PosixError(errno, "Unable to fscanf\n"));
FRIENDLY_ASSERT(ftype == STRING_CODE);
string_field(fp, &item, NULL);
f_list->append(item);
}
*cpout = f_list->array();
*qout = f_list->qty();
}
break;
default:
abort(); /* only strings supported */
}
c = fgetc(fp);
FRIENDLY_ASSERT(c == '\n');
}
int DBCursor::next(int typeCode, ...)
{
int ret = 1;
FILE *fp = f_table->file(DB::READ);
int io;
int recordClass;
if(f_start < 0){ /* on first call to next(), reset the file */
rewind(fp);
}
f_start = ftell(fp);
io = fscanf(fp, "%d\n", &recordClass); /* get record code */
if(io != EOF){ /* got any data? */
FRIENDLY_ASSERT(io == 1);
// clean up previous fields first if they exist
f_fields->reset();
delete f_list; f_list = NULL;
va_list ap;
va_start(ap, typeCode);
int fieldQty;
io = fscanf(fp, "%d\n", &fieldQty); /* get field count */
FRIENDLY_ASSERT(io == 1);
/* iterate over fields in the input stream... */
while(fieldQty--){
int fieldCode;
io = fscanf(fp, "%d\n", &fieldCode); /* get field type */
FRIENDLY_ASSERT(io == 1);
assert(typeCode); /* make sure caller didn't give too few args */
switch(fieldCode){
case STRING_CODE:
{
char **data = NULL;
int *len = NULL;
if (fieldCode == typeCode || (fieldCode + typeCode) == 0) {
data = va_arg(ap, char**);
if (fieldCode != typeCode) {
len = va_arg(ap, int*);
}
}
string_field(fp, data, len);
}
break;
case INTEGER_CODE:
int_field(fp, fieldCode == typeCode ? va_arg(ap, int*) : 0);
break;
case SHORT_LIST_CODE:
{
int *qout = va_arg(ap, int *);
int ltype = va_arg(ap, int);
void *out = va_arg(ap, void*);
short_list(fp, qout, ltype, out);
}
break;
default:
abort();
}
typeCode = va_arg(ap, int);
}
assert(typeCode == 0); /* check for end marker */
va_end(ap);
}else{
ret = 0; /* EOF found... no record */
}
return ret;
}
void DBCursor::undoNext()
{
FILE *fp = f_table->file(DB::READ);
if(f_start >= 0){
if(fseek(fp, f_start, 0) < 0){
throw(PosixError(errno, f_table->name()));
}
}else{
abort(); /* @# throw("no next to undo!") */
}
}
//----------------------------------------------------------------
void DBCursor::local_rewind()
{
f_start = -1;
}
//----------------------------------------------------------------
int DBCursor::tell()
{
if ( f_start == -1 ) {
return(0);
}
else {
return f_start;
}
}
//----------------------------------------------------------------
void DBCursor::seekToRec( int pos )
{
FILE *fp = f_table->file(DB::READ);
if ( pos >= 0 ){
if (fseek(fp, pos, 0) < 0 ) {
throw(PosixError(errno, f_table->name()));
}
}
else{
abort();
}
}

View File

@@ -0,0 +1,185 @@
/*
* 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
*/
/* $XConsortium: DataBase.h /main/6 1996/10/26 18:17:26 cde-hal $ -*- c++ -*- */
#ifndef __DataBase_h
#define __DataBase_h
#include "dti_excs/Exceptions.hh"
#include "object/c_codes.h" /* mmdb codes */
#include "oliasdb/olias_consts.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
class PosixError : public Exception{
public:
enum { MAXMSG = 200 };
PosixError(int error_no, const char *msg)
{ f_errno = error_no;
strncpy(f_msg, msg, MAXMSG+1); };
const char *msg(void) const { return f_msg; };
int error_no(void) const { return f_errno; };
DECLARE_EXCEPTION(PosixError, Exception)
private:
char f_msg[MAXMSG+1];
int f_errno;
};
#define DATABASE_DIRECTORY_MODE 0775
#define DATABASE_STDIO "-"
class DBTable;
class DB{
public:
/*
* USE: const char *dir = "/some/dir/for/all/the/tables";
* DB *db = DB(dir);
* assert(strcmp(db->path(), dir) == 0);
*/
DB(const char *name); /* a directory, for now */
~DB() { if ( f_name ) delete f_name; }
const char *path(void) { return f_name; };
typedef enum { READ, CREATE
#if DB_UPDATE
, UPDATE
#endif
} Access;
/*
* USE: DBTable *t = db->table("NodeMeta", NODE_CODE, 4, CREATE);
* where NODE_CODE is an MMDB object code, and 4
* is the number of "columns" in the table, i.e. the
* number of items you're going to pass to each call to
* insert()
*
* CREATE creates a file named "NodeMeta" in db's directory.
* READ opens a file named "NodeMeta" in db's directory.
*/
DBTable *table(const char *name,
int schema_code, int cols,
int a = READ); /* throw PosixError */
private:
char *f_name;
};
#define BT_NUM_DOC_FIELDS 6
#define BT_NUM_LOCATOR_FIELDS 3
#define BT_NUM_GRAPHIC_FIELDS 6
#define BT_NUM_STYLESHEET_FIELDS 3
#define BT_NUM_OLIAS_NODE_FIELDS 7
class DBTable{
friend class DB;
friend class DBCursor;
public:
~DBTable();
/*
* USE: int intlist = 4;
* table->insert(INTEGER_CODE, 4,
* STRING_CODE, "xyz",
* -STRING_CODE, "abcd", 4,
* SHORT_LIST_CODE, 1, INTEGER_CODE, &intlist,
* NULL);
*/
void insert(int typecode, ...);
void insert_untagged(int typecode, ...);
const char *name() { return f_name; };
void start_list();
void end_list();
protected:
DBTable(DB* database, int schema_code, int cols, const char *name);
FILE *file(DB::Access);
private:
FILE *f_file;
DB *f_database;
int f_schema_code;
int f_cols;
char *f_name;
int f_start; /* at start of linked list */
};
class DBCursor{
public:
DBCursor(DBTable &t);
~DBCursor();
/*
* USE: DBTable t(...);
* DBCurcor c(t);
* const char *f1;
* int f2
*
* while(c.next(STRING_CODE, &f1,
* INTEGER_CODE, &f2,
* NULL)){
* ...use f1, f2...
* }
*/
int next(int code, ...);
void undoNext(); /* seek back to the beginning of the last record read
* throw(PosixError) on unseekable device
*/
void local_rewind(); /* restart at the beginning of the table file */
int tell(); /* current position of the file */
void seekToRec( int pos ); /* seek directly to pos */
protected:
void string_field(FILE *, char **, int *);
void int_field(FILE *, int *);
void short_list(FILE *, int *, int, void*);
private:
DBTable *f_table;
class StringList *f_fields;
class StringList *f_list;
long f_start;
};
#endif /* __DataBase_h */

View File

@@ -0,0 +1,127 @@
/*
* 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
*/
/* $XConsortium: DataRepository.C /main/3 1996/08/21 15:46:21 drk $ */
#include "dti_cc/CC_Stack.h"
#include "dti_cc/CC_Slist.h"
/* Imported Interfaces */
#include "Task.h"
#include "FlexBuffer.h"
#include "DataRepository.h"
//-------------Initializer for the zone_name mapping ----------------
static const char *zone_name[] = {
"D",
"H",
"G",
"E",
"I",
"T"
};
//------------------------------------------------------------------
DataRepository::DataRepository()
{
for ( int i = 0; i < Total; i++ ) {
table[i] = NULL;
}
zone_stack = new Stack<Rec>;
current_buf = NULL;
}
//------------------------------------------------------------------
DataRepository::~DataRepository()
{
delete zone_stack;
// destroy the table
for ( int i = 0; i < Total; i++ ) {
delete table[i];
}
}
//------------------------------------------------------------------
void
DataRepository::ActivateZone( int zt, int level )
{
if ( !table[zt] ) {
table[zt] = new FlexBuffer;
}
// prepare a buffer to be written
Rec rec( level, table[zt] );
zone_stack->push ( rec );
current_buf = table[zt];
}
//------------------------------------------------------------------
void
DataRepository::deActivateZone( int level )
{
if ( zone_stack->empty() ) {
return;
}
if ( zone_stack->top().level != level ) {
return;
}
zone_stack->pop();
// update the current_buf
if ( !zone_stack->empty() ) {
current_buf = zone_stack->top().Buf;
}
}
//------------------------------------------------------------------
void
DataRepository::put(char ch)
{
if ( current_buf ) {
current_buf->put( ch );
}
}
//------------------------------------------------------------------
void
DataRepository::write( const char *str, size_t n )
{
current_buf->write( str, n );
}
//-------------------------------------------------------------------
const char *
DataRepository::get_zone_name( int zt )
{
if ( zt >= Total ) {
return NULL;
}
return ( zone_name[zt] );
}

View File

@@ -0,0 +1,98 @@
/*
* 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
*/
/* $XConsortium: DataRepository.h /main/2 1996/07/18 16:42:32 drk $ */
// DataRepository.h -- used to store all the full-text content
#ifndef DataRP_HEADER
#define DataRP_HEADER
#include <stddef.h>
/* Forward declaration */
class FlexBuffer;
template <class T> class Stack;
template <class T> class CC_TPtrSlist;
class Rec {
friend class DataRepository;
private:
int level;
FlexBuffer *Buf;
public:
Rec(int l, FlexBuffer *buf):level(l),Buf(buf){}
Rec():level(-1),Buf(NULL){}
Rec( const Rec &t ) {
if ( this != &t ) {
this->level = t.level;
this->Buf = t.Buf;
} else {
this->level = -1;
this->Buf = NULL;
}
}
Rec & operator=( Rec &t ) {
if ( this != &t ) {
this->level = t.level;
this->Buf = t.Buf;
}
return *this;
}
};
class DataRepository {
public:
typedef enum
{ Default=0, Head, Graphic, Example, Index, Table, Total} ZoneType;
private:
FlexBuffer *table[Total]; // zone buffer
Stack<Rec> *zone_stack;
FlexBuffer *current_buf;
public:
DataRepository();
~DataRepository();
void ActivateZone( int zone_type, int level ); // throw Exception
void deActivateZone( int level ); // throw Exception
void put( char );
void write ( const char *, size_t );
FlexBuffer **tabbuf() { return ( table ); }
const char *get_zone_name( int zone_type );
};
#endif

View File

@@ -0,0 +1,71 @@
/*
* 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
*/
/* $XConsortium: DataTask.C /main/3 1996/08/21 15:46:25 drk $ */
/* exported interfaces... */
#include "DataTask.h"
/* imported interfaces... */
#include "Token.h"
DataTask::DataTask(const Token&) : buf()
{
level = 1;
}
void DataTask::markup(const Token &t)
{
switch(t.type()){
case START:
/*
* be careful not to start collecting again after the relavent
* element is done!
*/
if(level > 0) level++;
break;
case END:
if(level > 0) level--;
break;
default:
break;
}
}
void DataTask::data(const char *chars, size_t len)
{
if(level > 0){
buf.write(chars, len);
}
}
const char * DataTask::content(size_t *len)
{
if(len) *len = buf.GetSize();
return buf.GetBuffer();
}

View File

@@ -0,0 +1,62 @@
/*
* 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
*/
/* $XConsortium: DataTask.h /main/2 1996/07/18 16:42:57 drk $ */
/* $Id: DataTask.h /main/2 1996/07/18 16:42:57 drk $ */
#ifndef __DataTask_h
#define __DataTask_h
#include <stddef.h>
#include "Task.h"
#include "FlexBuffer.h"
class DataTask : public Task{
/*
* A DataTask collects all the data for an element.
*
* USE:
* if(t.type() == START && t.attrMatch(OLAF::OLIAS, OLAF::Title)){
* titleTask = addSubTask(new DataTask());
*
* ... (more markup(), data() calls) ...
*
* const char *title = titleTask.content()
*/
public:
DataTask(const Token& t);
virtual void markup(const Token& t) /* throw(Unexpected) */;
virtual void data(const char *chars,
size_t len) /* throw(ResourcesExhausted) */;
const char *content(size_t *length_return = NULL);
private:
int level; /* how far nested are we? */
FlexBuffer buf;
};
#endif /* __DataTask_h */

View File

@@ -0,0 +1,80 @@
#!/bin/sh
##############################################################
# DeInstallBase #
# #
# Performs de-installation for the bookcase from an info #
# library. #
# #
##############################################################
#### Parse the argument ####
if [ $# -lt 2 ]; then
echo "Usage : $0 [ bookcase ] [ info-library ] " >&2
exit 1
fi
BookCase=$1
InfoLib=$2
NAMES_MMDB=$InfoLib/bookcase.map
### Validate if both bookcase and info-library is valid ###
if [ ! -f $NAMES_MMDB ]; then
echo "(ERROR) $InfoLib is not a valid info-library" >&2
exit 1
fi
if [ ! -w $NAMES_MMDB ]; then
echo "(ERROR) No write permission to de-install $BookCase "
exit 1
fi
##### Check to see if bookcase is already existing in the infolibrary
TSTSTRING=
TSTSTRING=`awk '{
if ( NR > 1 && $1 == bookcasename ) { print bookcasename }
}' bookcasename=$BookCase $NAMES_MMDB`
if [ -z "$TSTSTRING" ]; then
echo "(ERROR) $BookCase does not already exist in $InfoLib" >&2
exit 2
fi
### remove the entry in the names.mmdb file ###
TMP_NAMES_MMDB=$NAMES_MMDB.tmp
awk '{
if ( NR == 1 || $1 != bookcasename ) { print $0 }
}' bookcasename=$BookCase $NAMES_MMDB > $TMP_NAMES_MMDB
mv $TMP_NAMES_MMDB $NAMES_MMDB
### remove the physical storage of bookcase from info-lib ###
if [ ! -d $InfoLib/$BookCase ]; then
echo "(ERROR) $BookCase is not found under $InfoLib"
exit 1
fi
rm -fr $InfoLib/$BookCase
if [ $? -ne 0 ]; then
echo "(ERROR) Failed to remove $InfoLib/$BookCase" >&2
exit 1
fi
exit 0

View File

@@ -0,0 +1,219 @@
/*
* 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
*/
/* $XConsortium: Dispatch.cc /main/2 1996/06/11 16:49:03 cde-hal $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
/* exported interfaces... */
#include "Dispatch.h"
/* imported interfaces... */
#include <assert.h>
#include <string.h>
#include "SGMLName.h"
#include "EntityScope.h"
#include "Token.h"
#include "FlexBuffer.h"
#include "SGMLDefn.h"
#include "SearchPath.h"
#include "OLAF.h"
Task *Dispatch::TaskObject = NULL;
Stack<int> *Dispatch::IgnoreStack = NULL;
int Dispatch::level = 0;
static EntityScope entity_stack;
Token* Dispatch::tok = new Token();
char* Dispatch::f_file = NULL;
int Dispatch::f_line = 0;
const char *Dispatch::tmpdir = NULL;
const char *Dispatch::srcdir = NULL;
SearchPath *Dispatch::search_path_table = NULL;
int Dispatch::tocgen_only = 0;
//---------------------------------------------------------------------
void
Dispatch::token(TOKEN_TYPE tokType, unsigned char *Name )
{
tok->setFileLine(f_file, f_line);
switch(tokType){
case START:
level++;
tok->StoreStartTag( Name, level );
if ( tok->LookupAttr( OLAF::OL_Ignore )
|| tok->LookupAttr( OLAF::OL_ShortTitle ) ) {
IgnoreStack->push ( level );
}
break;
case END:
tok->StoreEndTag ( Name, level );
level--;
break;
case INTERNAL_ENTITY:
tok->StoreEntity( Name , INTERNAL_ENTITY);
break;
case EXTERNAL_ENTITY:
tok->StoreEntity( Name , EXTERNAL_ENTITY);
SGMLDefn *sgml_rec;
sgml_rec = entity_stack.LookupEntity( SGMLName::intern((char*)Name) );
if(sgml_rec){
tok->SetEntityValue( sgml_rec );
}else{
tok->reportError(Token::Internal, Token::Fatal,
"Unable to find entity definition for %.50s", Name);
}
break;
default:
break;
}
TaskObject->markup( *tok );
if ( tokType == END ) {
if ( !IgnoreStack->empty() ) {
int topelement = IgnoreStack->top();
if ( topelement == tok->level() ) {
topelement = IgnoreStack->pop();
}
}
}
delete tok;
tok = new Token();
}
//---------------------------------------------------------------------
void Dispatch::setRoot( Task *t, Stack<int> *istack)
{
assert(TaskObject == NULL);
TaskObject = t;
assert(IgnoreStack == NULL);
IgnoreStack = istack;
}
//---------------------------------------------------------------------
SGMLDefn *
Dispatch::entity_ref( const char *ent_name )
{
int ent_num;
ent_num = SGMLName::intern(ent_name);
SGMLDefn *sgml_rec = entity_stack.LookupEntity( ent_num );
return sgml_rec;
}
//---------------------------------------------------------------------
void
Dispatch::entity_decl( SGMLDefn *defn )
{
EntityList *escope = entity_stack.GetTopEntities();
assert(escope != NULL);
/*
* first clone up an SGMLDefn record for storage purposes
*/
SGMLDefn *sgmlRec = new SGMLDefn();
*sgmlRec = *defn;
escope->insert( sgmlRec );
}
//---------------------------------------------------------------------
void
Dispatch::file(const char *f)
{
int len = strlen(f);
delete f_file;
f_file = new char[len + 1];
*((char *) memcpy(f_file, f, len) + len) = '\0';
/*
* put directory of f_file into the search path also
*/
if(search_path_table){
// perform dirname first
char *dirname = strdup( f_file );
char *p = strrchr( dirname, '/' );
if ( p ) {
*p = '\0';
}
else {
len = MIN(strlen(dirname), 1);
*((char *) memcpy(dirname, ".", len) + len) = '\0';
}
search_path_table->replace_file_scope( dirname );
free(dirname);
}
}
//---------------------------------------------------------------------
void
Dispatch::subdoc_start()
{
EntityList *newrec = new EntityList();
entity_stack.push ( newrec );
}
//---------------------------------------------------------------------
void
Dispatch::subdoc_end()
{
EntityList *rec = entity_stack.pop();
if ( !rec ) {
throw(Unexpected("SUBDOC end tag is not matched"));
}
delete rec;
}

View File

@@ -0,0 +1,98 @@
/*
* 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
*/
/* $XConsortium: Dispatch.h /main/3 1996/08/21 15:46:29 drk $ -*- c++ -*- */
/* $XConsortium: Dispatch.h /main/3 1996/08/21 15:46:29 drk $ -*- c++ -*- */
//---------------------------------------------------------------------
// Dispatch Functions
//---------------------------------------------------------------------
#ifndef DISPATCH_HEADER
#define DISPATCH_HEADER
#include "Token.h"
#include "Task.h"
#include "FlexBuffer.h"
#include "dti_cc/CC_Stack.h"
class SGMLDefn;
class SearchPath;
class Dispatch {
friend int yylex();
friend int main(int argc, char **argv);
protected:
static Token *tok;
static const char *tmpdir;
static const char *srcdir;
static SearchPath *search_path_table;
static int tocgen_only;
static void token ( TOKEN_TYPE, unsigned char * );
static void subdoc_start();
static void subdoc_end();
static void data ( FlexBuffer * );
static void setRoot( Task *t, Stack<int> *istack);
static void setTempDir ( const char *tmpdir );
static void setSrcDir ( const char *srcdir );
static void entity_decl( SGMLDefn *);
static void file(const char *);
static void line(int l) { f_line = l; };
static void newline() { f_line++; };
private:
static Task *TaskObject;
static int level;
static Stack<int> *IgnoreStack;
static char *f_file;
static int f_line;
public:
static SGMLDefn *entity_ref ( const char *ename );
static int OutsideIgnoreScope() { return IgnoreStack->empty(); }
static int RunTocGenOnly() { return(tocgen_only); }
#ifdef SC3
static const char *GetTmpDir() { return( tmpdir ); }
static const char *GetSrcDir() { return( srcdir ); }
static SearchPath *GetSearchPath() { return ( search_path_table ); }
#else
static const char *GetTmpDir() { return( tmpdir ); }
static const char *GetSrcDir() { return( srcdir ); }
static SearchPath *GetSearchPath() { return ( search_path_table ); }
#endif
};
inline
void
Dispatch::data( FlexBuffer *buf )
{
TaskObject->data( (const char *)( buf->GetBuffer() ),
buf->GetSize() );
}
#endif

View File

@@ -0,0 +1,86 @@
/*
* 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
*/
/* $XConsortium: EntityList.cc /main/2 1996/07/18 16:11:54 drk $ */
/* exported interfaces */
#include "EntityList.h"
/* imported interfaces */
#include <stdio.h>
#include "SGMLName.h"
#include "SGMLDefn.h"
//---------------------------------------------------------
EntityList::EntityList()
{
head = NULL;
tail = NULL;
next = NULL;
}
//---------------------------------------------------------
EntityList::~EntityList()
{
SGMLDefn *pt = head;
while ( pt ) {
SGMLDefn *tmp = pt;
pt = pt->next;
delete tmp;
}
}
//---------------------------------------------------------
// EntityList:lookup
SGMLDefn *
EntityList::lookup(int ename ) const
{
SGMLDefn *pt = head;
while ( pt ) {
if ( pt->getName() == ename ) {
return ( pt );
}
pt = pt->next;
}
return ( NULL );
}
//---------------------------------------------------------
// EntityList::add
void
EntityList::insert( SGMLDefn *entry )
{
if ( !tail ) {
head = tail = entry;
}
else {
tail->next = entry;
tail = entry;
}
}

View File

@@ -0,0 +1,51 @@
/*
* 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
*/
/* $XConsortium: EntityList.h /main/2 1996/07/18 16:43:25 drk $ */
#ifndef ENT_LIST_HDR
#define ENT_LIST_HDR
#include "SGMLDefn.h"
class EntityList {
friend class EntityScope;
friend class Dispatch;
protected:
SGMLDefn *head;
SGMLDefn *tail;
EntityList *next;
SGMLDefn *lookup( int ) const;
void insert ( SGMLDefn * );
// SGMLDefn *GetFirstAttr() const;
// SGMLDefn *GetNextAttr( const SGMLDefn *) const;
EntityList();
~EntityList();
};
#endif

View File

@@ -0,0 +1,88 @@
/*
* 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
*/
/* $XConsortium: EntityScope.h /main/2 1996/07/18 16:43:47 drk $ */
#ifndef ENT_SCOPE_HDR
#define ENT_SCOPE_HDR
#include "EntityList.h"
class EntityScope {
private:
EntityList *currentEntityScope;
public:
void push ( EntityList *escope ) {
escope->next = currentEntityScope;
currentEntityScope = escope;
}
EntityList *pop();
EntityList *GetTopEntities() const { return(currentEntityScope); }
SGMLDefn *LookupEntity( int ename );
/*
* Constructor EntityScope creates a topmost entitylist
* so the stack will contain an element after it is constructed
*/
EntityScope() { currentEntityScope = new EntityList(); }
~EntityScope();
};
//----------------------------------------------------------------
inline
SGMLDefn *
EntityScope::LookupEntity( int ename )
{
return ( currentEntityScope->lookup( ename ) );
}
//-----------------------------------------------------------------
inline
EntityList *
EntityScope::pop()
{
EntityList *ptr;
ptr = currentEntityScope;
currentEntityScope = ptr->next;
return ( ptr );
}
//-----------------------------------------------------------------
inline
EntityScope::~EntityScope()
{
EntityList *pt = currentEntityScope;
while( pt ) {
EntityList *tmp = pt;
pt = pt->next;
delete tmp;
}
}
#endif

View File

@@ -0,0 +1,66 @@
/*
* 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
*/
/* $XConsortium: ExprList.C /main/3 1996/08/21 15:46:33 drk $ */
/* imported interfaces */
/* exported interfaces */
#include "Expression.h"
#include "ExprList.h"
//------------------------------------------------------------------
ExprList::ExprList()
{
head = 0;
}
//------------------------------------------------------------------
ExprList::ExprList( OL_Expression *elist )
{
head = elist;
}
//------------------------------------------------------------------
ExprList::~ExprList()
{
OL_Expression *ptr = head;
while ( ptr ) {
OL_Expression *tmp = ptr;
ptr = ptr->next;
delete tmp;
}
}
//------------------------------------------------------------------
OL_Expression *
ExprList::first()
{
return ( head );
}
//------------------------------------------------------------------
OL_Expression *
ExprList::next( OL_Expression *ptr )
{
if ( ptr ) { return(ptr->next); }
else { return 0; }
}

View File

@@ -0,0 +1,44 @@
/*
* 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
*/
/* $XConsortium: ExprList.h /main/3 1996/08/21 15:46:37 drk $ */
#ifndef __ExprList__
#define __ExprList__
class OL_Expression;
class ExprList {
private:
OL_Expression *head;
public:
ExprList();
ExprList( OL_Expression *elist);
~ExprList();
OL_Expression *first();
OL_Expression *next( OL_Expression *elem );
};
#endif

View File

@@ -0,0 +1,42 @@
/*
* 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
*/
/* $XConsortium: Expression.C /main/3 1996/08/21 15:46:40 drk $ */
/* imported interfaces */
#include "Expression.h"
#include "ExprList.h"
OL_Expression::~OL_Expression()
{
/* This is a hack right now to eliminate the memory leak
*/
if ( data_type == CONCAT || data_type == FIRSTOF ) {
ExprList *vlist = ( ExprList * )value_list;
delete vlist;
}
else if ( data_type == LITERAL ) {
char *vlist = (char *)value_list;
delete vlist;
}
}

View File

@@ -0,0 +1,67 @@
/*
* 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
*/
/* $XConsortium: Expression.h /main/3 1996/08/21 15:46:44 drk $ */
#ifndef __CRec_hdr__
#define __CRec_hdr__
enum OL_DATA_TYPE {
INVALID_OL_TYPE,
CONTENT,
CONCAT,
FIRSTOF,
GENERIC_ID,
LITERAL,
REFERENCE
};
class OL_Expression {
friend class OL_Data;
friend class FirstOf;
friend class Concat;
friend int ol_dataparse();
friend class ContentType;
friend class ExprList;
private:
OL_DATA_TYPE data_type;
int ename;
void *value_list;
OL_Expression *next;
public:
OL_Expression( OL_DATA_TYPE dtype=INVALID_OL_TYPE,
int dname=-1,
void *vlist=0) {
data_type = dtype; ename = dname; value_list = vlist; next = 0;
}
~OL_Expression();
OL_DATA_TYPE type() const { return data_type; }
int name() const { return ename; }
void *data_list() const { return value_list; }
};
#endif

View File

@@ -0,0 +1,139 @@
/*
* 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
*/
/* $XConsortium: FirstOf.C /main/3 1996/08/21 15:46:47 drk $ */
/* exported interfaces */
#include "FirstOf.h"
/* imported interfaces */
#include "Dispatch.h"
#include "OLAF.h"
#include "ExprList.h"
#include "Expression.h"
#include "Token.h"
#include "OL_Data.h"
#include "ConcatTask.h"
#include "Content.h"
#include "AttributeData.h"
#include "GenericId.h"
#include "Literal.h"
//---------------------------------------------------------------------
FirstOf::FirstOf( const Token &t,
ExprList *el,
ActionType mode ):BaseData(t,mode)
{
f_base = t.level();
for ( OL_Expression *local_list = el->first();
local_list;
local_list = el->next(local_list) ) {
switch ( local_list->type() ) {
case CONTENT :
addSubTask( new Content( t,mode) );
break;
case CONCAT :
addSubTask( new Concat ( t,
(ExprList *) local_list->data_list(),
mode) );
break;
case FIRSTOF :
addSubTask( new FirstOf( t,
(ExprList *)local_list->data_list(),
mode) );
break;
case GENERIC_ID :
addSubTask( new GenericId(t,
local_list->name(),
mode) );
break;
case LITERAL :
addSubTask( new Literal( t,
(const char *)local_list->data_list(),
mode) );
break;
case REFERENCE :
addSubTask( new AttributeData( t,
local_list->name(),
mode ));
break;
default:
abort();
}
}
elist = NULL;
}
//--------------------------------------------------------------------------
void
FirstOf::markup( const Token &t )
{
if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
ComplexTask::markup( t );
if ( t.type() == END ) {
if ( t.level() == f_base ) {
data_complete = 1;
for ( int i = 0; i < ComplexTask::used; i++ ) {
BaseData *task = ( BaseData *)ComplexTask::subtask(i);
if ( task->DataIsComplete() ) {
ValueBuffer.writeStr( task->content() );
break;
}
}
f_base = -1;
ComplexTask::removeAllSubTasks();
}
}
}
}

View File

@@ -0,0 +1,49 @@
/*
* 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
*/
/* $XConsortium: FirstOf.h /main/3 1996/08/21 15:46:51 drk $ */
#ifndef __FirstOfHdr__
#define __FirstOfHdr__
#include "Task.h"
#include "BaseDataCollect.h"
class Token;
class OL_Expression;
class ExprList;
class FirstOf : public BaseData {
friend class OL_Data;
friend class Concat;
private:
OL_Expression *elist;
protected:
FirstOf( const Token &t, ExprList *el,ActionType mode );
void markup( const Token &t );
void data( const char *str, size_t sz ) { ComplexTask::data( str, sz ); }
};
#endif

View File

@@ -0,0 +1,96 @@
/*
* 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
*/
/* $XConsortium: FlexBuffer.cc /main/2 1996/07/18 16:13:49 drk $ */
#include <iostream>
using namespace std;
#include <memory.h>
#include <string.h>
#include "FlexBuffer.h"
//---------------------------------------------------------
FlexBuffer::FlexBuffer()
{
HeadPtr = 0;
maxSize = pos = 0;
}
//---------------------------------------------------------
//FlexBuffer::~FlexBuffer()
//{
// delete HeadPtr;
//}
//---------------------------------------------------------
void
FlexBuffer::grow(size_t needed)
{
if(needed + 1 > (size_t) maxSize){
char *born = new char[maxSize = needed * 3 / 2 + 10];
if(pos){
memcpy(born, HeadPtr, pos);
delete [] HeadPtr;
}
HeadPtr = born;
}
}
//---------------------------------------------------------
void
FlexBuffer::write(const char *d, size_t n)
{
grow(pos + n);
memcpy(HeadPtr + pos, d, n);
pos += n;
}
//---------------------------------------------------------
void
FlexBuffer::writeStr(const char *str )
{
int n = strlen(str);
grow( pos + n );
memcpy ( HeadPtr + pos, str, n );
pos += n;
}
//---------------------------------------------------------
FlexBuffer &
FlexBuffer::operator+( FlexBuffer & fb )
{
grow( pos + fb.GetSize() );
memcpy(HeadPtr + pos , fb.HeadPtr, fb.GetSize() );
pos += fb.GetSize();
return ( *this );
}
//---------------------------------------------------------
ostream &
operator<< ( ostream &os, FlexBuffer &fb )
{
os << fb.GetBuffer();
return os;
}

View File

@@ -0,0 +1,66 @@
/*
* 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
*/
/* $XConsortium: FlexBuffer.h /main/2 1996/07/18 16:45:28 drk $ */
#ifndef FLEX_BFR_HDR
#define FLEX_BFR_HDR
#include <stddef.h>
#include <iostream>
using namespace std;
class FlexBuffer {
friend ostream &operator<< ( ostream &s, FlexBuffer &);
private:
int pos;
int maxSize;
char *HeadPtr;
void grow(size_t);
public:
void write( const char *ch, size_t n );
void writeStr ( const char *ch );
void put( char );
void reset() { pos = 0; };
int GetSize() { return( pos ); }
const char *GetBuffer() { grow(pos); HeadPtr[pos] = 0; return(HeadPtr); }
FlexBuffer();
~FlexBuffer() { delete [] HeadPtr; }
FlexBuffer &operator+ ( FlexBuffer & );
};
inline void FlexBuffer::put( char c )
{
grow( pos + 1 );
*(HeadPtr + pos) = c;
pos += 1;
}
#endif

View File

@@ -0,0 +1,117 @@
/*
* 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
*/
/* $XConsortium: GenericId.cc /main/5 1996/07/18 16:14:18 drk $ */
/* exported interfaces */
#include "GenericId.h"
/* imported interfaces */
#include "Dispatch.h"
#include "SGMLName.h"
#include "OLAF.h"
#include "OL_Data.h"
#include "Token.h"
#ifdef FISH_DEBUG
#include "dbug.h"
#endif
//-------------------------------------------------------------------------
GenericId::GenericId( const Token &t,
int name,
ActionType mode ):BaseData(t,mode)
{
#ifdef FISH_DEBUG
DBUG_PRINT("GenericId", (" name = %s", SGMLName::lookup(name)) );
#endif
giname = name;
f_data = NULL;
done = 0;
f_base = -1;
}
//-------------------------------------------------------------------------
void
GenericId::markup( const Token &t )
{
#ifdef FISH_DEBUG
DBUG_PRINT( "GenericId", (" token t = %s",SGMLName::lookup(t.Gi()) ) );
#endif
if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_data ) {
f_data->markup( t );
}
if ( t.type() == START ) {
/* first time we see the GI */
if ( t.Gi() == giname && f_base < 0 && !done ) {
/* fork off the OL_Data class for this GI */
f_data = new OL_Data ( t, OLAF::OL_data, (ActionType)ignore_status );
assert ( f_data != NULL );
f_base = t.level();
}
}
else if ( t.type() == END ) {
if ( f_base == t.level() && !done ) {
if ( (data_complete = f_data->DataIsComplete()) ) {
ValueBuffer.writeStr( f_data->content() );
}
delete f_data; f_data = NULL;
done = 1;
}
}
}
//-------------------------------------------------------------------------
void
GenericId::data( const char *str, size_t sz )
{
if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
if ( f_data ) {
f_data->data( str, sz );
}
}
}

View File

@@ -0,0 +1,51 @@
/*
* 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
*/
/* $XConsortium: GenericId.h /main/2 1996/07/18 16:45:48 drk $ */
#ifndef __gen_Id__
#define __gen_Id__
#include "BaseDataCollect.h"
class Token;
class OL_Data;
class GenericId : public BaseData {
friend class FirstOf;
friend class OL_Data;
friend class Concat;
private:
int giname;
int done;
OL_Data *f_data;
protected:
GenericId( const Token &t, int giname,ActionType mode);
void markup( const Token &t );
void data( const char *str, size_t sz );
};
#endif

View File

@@ -0,0 +1,318 @@
/*
* 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
*/
/* $XConsortium: GraphicsTask.cc /main/8 1996/08/14 16:59:38 rcs $ */
#include <assert.h>
#include <sstream>
#include <iostream>
using namespace std;
#include <sys/types.h>
#include <netinet/in.h>
#include "GraphicsTask.h"
#include "Dispatch.h"
#include "FlexBuffer.h"
#include "OLAF.h"
#include "OL_Data.h"
#include "Token.h"
#include "SearchEng.h"
#include "BookTasks.h"
#include "NodeData.h"
#include "NodeTask.h"
#include "DataBase.h"
#include "BookCaseDB.h"
#ifndef DtinfoClient
#include "PostScript.h"
#endif
#include "SearchPath.h"
#include "utility/funcs.h"
#include <X11/XWDFile.h>
GR_TYPE gtype;
extern FILE *graphics_taskin;
extern void get_type ();
const int GR_ENCODING_TEXT = 1;
//-------------------------------------------------------------------------
#if __GNUC__ == 4 && __GNUC_MINOR__ == 4
GR_TYPE __attribute__((optimize("O0")))
#else
GR_TYPE
#endif
GraphicsTask::graphics_type( const char *gname )
{
gtype = GR_TYPE_UNKNOWN;
if ( !(graphics_taskin = fopen( gname, "r" )) ) {
throw(PosixError( errno, form("cannot open graphics file %s\n", gname)));
}
get_type();
if (gtype == GR_TYPE_UNKNOWN) {
if ((strstr(gname, ".cgm") != NULL) ||
(strstr(gname, ".CGM") != NULL))
{
gtype = GR_TYPE_CGM;
}
}
fclose(graphics_taskin);
// If the file is not cgm and if the lexer couldn't detect the graphics type,
// see if the graphic is an XWD file.
if (gtype == GR_TYPE_UNKNOWN) {
// Create header container
CARD32 header[sz_XWDheader];
XWDFileHeader *hdrptr;
FILE *fp;
if ( !(fp = fopen( gname, "r" )) ) {
throw(PosixError( errno,
form("cannot reopen graphics file %s\n", gname)));
}
hdrptr = (XWDFileHeader *)(void*)header;
// Initialize the structure
for (CARD32 ndx = 0; ndx < sz_XWDheader; ndx++) {
header[ndx] = (CARD32) 0;
}
if ( fread( &header[0], sizeof(*hdrptr), 1, fp ) == 1 ) {
// Normal fields into host byte-order
hdrptr->file_version = ntohl(hdrptr->file_version);
hdrptr->header_size = ntohl(hdrptr->header_size);
hdrptr->pixmap_width = ntohl(hdrptr->pixmap_width);
hdrptr->pixmap_height = ntohl(hdrptr->pixmap_height);
// Check some of the structure members to confirm the file type.
if ((hdrptr->file_version == XWD_FILE_VERSION) &&
(hdrptr->header_size > 0) &&
(hdrptr->pixmap_width > 0) &&
(hdrptr->pixmap_height > 0)) {
gtype = GR_TYPE_XWD;
}
}
fclose( fp );
}
return ( gtype );
}
//-------------------------------------------------------------------------
GraphicsTask::GraphicsTask( SearchEngine *parent, const Token &t )
{
f_base = t.level();
graphics_data = NULL;
f_parent = parent;
termsbuf = NULL;
f_title = 0;
if ( Dispatch::OutsideIgnoreScope() ) {
graphics_data = new OL_Data ( t, OLAF::OL_Graphic );
addSubTask( graphics_data );
if ( t.LookupAttr( OLAF::OL_Title ) ) {
f_title = new OL_Data(t, OLAF::OL_Title, IGNORE_ON );
if ( !f_title->DataWillBeAvailable() ) {
delete f_title;
f_title = 0;
}
else {
addSubTask(f_title);
}
}
}
}
//-------------------------------------------------------------------------
void
GraphicsTask::markup( const Token &t )
{
if ( f_base > 0 ) {
ComplexTask::markup( t );
if ( t.type() == START && !f_title ) {
if ( t.LookupAttr( OLAF::OL_Title ) ) {
f_title = new OL_Data(t, OLAF::OL_Title, IGNORE_ON );
if ( !f_title->DataWillBeAvailable() ) {
delete f_title;
f_title = 0;
}
else {
addSubTask(f_title);
}
}
}
if ( t.type() == END ) {
if ( Dispatch::OutsideIgnoreScope() ) {
if ( f_base == t.level() ) {
write_record( t );
KILLSUBTASK( graphics_data );
f_base = -1;
}
}
}
}
}
//-------------------------------------------------------------------------
void
GraphicsTask::write_record( const Token &t )
{
/*
* It is up to the client of graphics_data to determine how to
* interpret the content() , which will be treated as file name
*/
SearchPath *spath = Dispatch::GetSearchPath();
const char *file_name = graphics_data->content();
const char *grFileName = spath->get_real_path( file_name );
const char *bounding_box = "0.0.0.0";
GR_TYPE gr_type = GR_TYPE_UNKNOWN;
/*
* assuming that grFileName is actually corresponding to the
* final file where the graphical content is stored
*/
FlexBuffer graphics_buffer;
const char *size_info = NULL;
int graphics_available = 0;
FILE *gp;
if ( grFileName ) {
gp = fopen ( grFileName, "r" );
if ( gp ) {
graphics_available=1;
int c;
while ( ( c=getc(gp) ) != EOF ) {
graphics_buffer.put(c);
}
fclose(gp);
switch ( (gr_type = graphics_type( grFileName )) ) {
case GR_TYPE_UNKNOWN :
{
cerr << "(WARNING) Unsupported graphics type found in "
<< grFileName << endl
<< " It is included in file " << t.file() << endl
<< " at line " << t.line() << endl;
}
break;
case GR_TYPE_POSTSCRIPT :
{
#ifndef DtinfoClient
PostScript *ps_store = new PostScript( grFileName );
bounding_box = ps_store->GetBoundingBox();
if ( ps_store->HasSearchTerms() ) {
termsbuf = ps_store->GetTermsBuffer();
}
delete ps_store;
#else
cerr << "(WARNING) Unsupported PostScript graphic found in "
<< grFileName << endl
<< " It is included in file " << t.file() << endl
<< " at line " << t.line() << endl;
#endif
}
break;
default:
break;
}
size_info = form("%d.%d.%s",
gr_type,
GR_ENCODING_TEXT,
bounding_box );
}
}
else {
cerr << "(WARNING) graphical file = " << file_name << endl
<< " included in file = " << t.file() << endl
<< " at line = " << t.line() << endl
<< " is not found, a zero length graphical data is used\n\n";
}
/* dump the graphics record */
NodeData *nodeData = f_parent->node_data();
const char *gid = nodeData->graphics_id();
BookTask *book = nodeData->node()->book();
const char *bookLocator = book->locator();
DBTable *gtab = book->bookcase()->table(BookCaseDB::Graphics);
gtab->insert( STRING_CODE, bookLocator,
STRING_CODE, gid,
STRING_CODE, "",
STRING_CODE, "v0",
STRING_CODE, graphics_available?size_info : "0.0.0.0.0.0",
-STRING_CODE, graphics_buffer.GetBuffer(),
(size_t)graphics_buffer.GetSize(),
STRING_CODE, f_title?f_title->content():"",
NULL);
/*
if ( compress ) {
gtab->insert(STRING_CODE, gid,
STRING_CODE, "@@ graphcis name",
STRING_CODE, "v0",
STRING_CODE, "@@ type info",
COMPRESSED_STRING_CODE, "@@ CompressedAgent",
-STRING_CODE, graphics_buffer.GetBuffer(),
(size_t)graphics_buffer.GetBSize(),
STRING_CODE, "@@ graphics title" );
}
*/
}

View File

@@ -0,0 +1,75 @@
/*
* 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
*/
/* $XConsortium: GraphicsTask.h /main/3 1996/07/18 16:46:09 drk $ */
#ifndef GRAPHICS_TASK_HDR
#define GRAPHICS_TASK_HDR
#include "Task.h"
#include "FlexBuffer.h"
#include "oliasdb/olias_consts.h"
class Token;
class SearchEngine;
class OL_Data;
class GraphicsTask : public ComplexTask {
private:
int f_base;
SearchEngine *f_parent;
const FlexBuffer *termsbuf;
OL_Data *graphics_data;
OL_Data *f_title;
void write_record( const Token & );
GR_TYPE graphics_type( const char * );
public:
int IsDone() { return( f_base == -1 ); }
int HasSearchTerms() const;
const FlexBuffer *GetTerms() { return(termsbuf); }
public:
void markup ( const Token & );
GraphicsTask( SearchEngine *parent, const Token &t);
};
inline
int
GraphicsTask::HasSearchTerms() const
{
if ( !termsbuf ) {
return 0;
}
else {
FlexBuffer *tmpBuffer = ( FlexBuffer *)termsbuf;
return( tmpBuffer->GetSize() );
}
}
#endif

View File

@@ -0,0 +1,32 @@
/*
* 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
*/
/* $XConsortium: Handler.cc /main/2 1996/07/18 16:15:12 drk $ */
#include <stdio.h>
#include <stdlib.h>
//---------------------------------------------------------------------
void FreeStoreException()
{
fprintf(stderr,"(ERROR) Memory exhausted\n");
exit(1);
}

View File

@@ -0,0 +1,30 @@
/*
* 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
*/
/* $XConsortium: Handler.h /main/2 1996/07/18 16:46:29 drk $ */
#ifndef __HandlerH__
#define __HandlerH__
#include <new>
extern void FreeStoreException();
#endif

View File

@@ -0,0 +1,159 @@
#!/bin/sh
##############################################################
# InstallBase #
# #
# Performs installation for bookcase #
# #
##############################################################
#### Parse the argument ####
INSTALL_BOOKCASE=
while getopts p:b:i OPTS
do
case $OPTS in
p) # position to install the bookcase
Position=$OPTARG
;;
b) # grap the bookcase
BookCase=$OPTARG
## Make sure it doesn't have any trailing / ###
BookCase=`echo $BookCase | sed "s/\(.*\)\/$/\1/g"`
;;
i) # Install the bookcase even if it already exists in the InfoLib
INSTALL_BOOKCASE="YES"
;;
\?) # Unrecognized option - exit with 1
usage_f
exit 1
;;
esac
done
if [ "$OPTIND" -gt "$#" -o -z "$BookCase" ]; then
echo "Usage : $0 [ -i ] [ -p position ] -b bookcase info-lib " >&2
exit 1
fi
shift `expr $OPTIND - 1`
if [ $? -ne 0 ]; then
echo "(ERROR) shift failed" >&2
exit 1
fi
InfoLib=$1
BookCaseName=`basename $BookCase`
NAMES_MMDB=$InfoLib/names.mmdb
NAMES_MMDB_TMP=$InfoLib/names.mmdb.$$
if [ -z "$Position" ]; then
Position="END"
fi
### first check if bookcase exists ###
if [ ! -f $NAMES_MMDB ]; then
echo "(ERROR) $InfoLib is not a valid info-library" >&2
exit 1
fi
TSTSTRING=
TSTSTRING=`awk '{
if ( $1 == bookcasename ) { print bookcasename }
}' bookcasename=$BookCaseName $NAMES_MMDB`
if [ -n "$TSTSTRING" ]; then
if [ -z "$INSTALL_BOOKCASE" ]; then
echo "$BookCaseName already exists in $InfoLib, no installation takes place" >&2
exit 2
fi
### Prepare names.mmdb file for update
awk '{
if ( $1 != bookcasename ) { print $0 }
}' bookcasename=$BookCaseName $NAMES_MMDB > $NAMES_MMDB_TMP
### Clean up everything there before proceeding ###
( cd $InfoLib/$BookCaseName ; rm -r ./* )
else
cp $NAMES_MMDB $NAMES_MMDB_TMP
fi
### perform validation for the bookcase against the infolibrary ###
# InfoValidate $BookCase $InfoLib
if [ $? -ne 0 ]; then
exit 1
fi
### Grap the entry line for the bookcase
BaseDir=`dirname $BookCase`
if [ -z "$BaseDir" ]; then
echo "(ERROR) Info-library for $BookCase is not found" >&2
exit 1
fi
if [ ! -f $BaseDir/names.mmdb ]; then
echo "(ERROR) BaseDir/names.mmdb does not exist in $InfoLib" >&2
exit 1
fi
BookEntryLine=`awk '{
if ( $1 == bookcasename ) { print $0 }
}' bookcasename=$BookCaseName $BaseDir/names.mmdb`
if [ -z "$BookEntryLine" ]; then
echo "(ERROR) $BookCase does not exist in $InfoLib" >&2
exit 1
fi
### Update the names.mmdb file with the new entry ###
if [ "$Position" != "END" ]; then
awk '{
if ( NR != position ) { print $0 }
if ( NR == position ) { print bookcaseEntry; print $0 }
}' position=$Position bookcaseEntry="$BookEntryLine" $NAMES_MMDB_TMP > \
$NAMES_MMDB
else
echo "$BookEntryLine" >> $NAMES_MMDB_TMP
mv $NAMES_MMDB_TMP $NAMES_MMDB
fi
rm -f $NAMES_MMDB_TMP
### Copy the physical data to the infolib
( cd $BaseDir ; tar cf - $BookCaseName ) | ( cd $InfoLib; tar xof - )
if [ $? -ne 0 ]; then
echo "(ERROR) Unable to install $BookCase to $InfoLib" >&2
exit 1
fi
exit 0

View File

@@ -0,0 +1,136 @@
/*
* 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
*/
/* $XConsortium: LcfTask.C /main/3 1996/10/26 18:17:58 cde-hal $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
/* exported interfaces */
#include "LcfTask.h"
/* imported interfaces */
#include <assert.h>
#include "Token.h"
#include "NodeTask.h"
#include "DataBase.h"
#include "OL_Data.h"
#include "OLAF.h"
#include "BookTasks.h"
#include "BookCaseDB.h"
//--------------------------------------------------------------------
LcfTask::LcfTask( NodeTask *f_parent, const Token &t )
{
assert( f_parent != NULL );
f_node = f_parent;
f_base = t.level();
}
//--------------------------------------------------------------------
void
LcfTask::markup( const Token &t )
{
ComplexTask::markup(t);
if ( t.type() == START ) {
if ( t.LookupAttr( OLAF::OL_id ) ) {
OL_Data *LocData = new OL_Data ( t, OLAF::OL_id, REMOVE_SPACES );
/*
* Add subtask only if I know Data will be available
*/
if ( LocData->DataWillBeAvailable() ) {
addSubTask( LocData );
OL_Data *RefData = new OL_Data(t, OLAF::OL_XRefLabel, IGNORE_ON);
addSubTask( RefData );
}
else { delete LocData; }
}
}
else if ( t.type() == END ) {
/* only write out all the locator if I am at the end f_node */
if ( t.level() == f_base ) {
write_record();
reset();
}
}
}
//--------------------------------------------------------------------
void
LcfTask::reset()
{
ComplexTask::removeAllSubTasks();
}
//--------------------------------------------------------------------
void
LcfTask::write_record()
{
const char *NodeLocator = f_node->locator();
#if 0
for ( int i = 0; i < ComplexTask::used; i++ ) {
OL_Data *task = (OL_Data * )subtask(i);
if ( !task->ContentIsEmpty() ) {
DBTable *tbl = f_node->book()->bookcase()->table(BookCaseDB::Locator);
tbl->insert( STRING_CODE, task->content(),
STRING_CODE, NodeLocator,
STRING_CODE, task->filename(),
INTEGER_CODE, task->line_no(),
NULL);
}
}
#else
for ( int i = 0; i < ComplexTask::used; i+=2 ) {
OL_Data* task = (OL_Data * )subtask(i);
OL_Data* reftask = (OL_Data * )subtask(i+1);
if ( !task->ContentIsEmpty() ) {
DBTable *tbl = f_node->book()->bookcase()->table(BookCaseDB::Locator);
const char* reflabel = "";
if ( !reftask->ContentIsEmpty() ) {
const char* content = reftask->content();
if (strlen(content) < 256)
reflabel = content;
}
tbl->insert( STRING_CODE, task->content(),
STRING_CODE, NodeLocator,
STRING_CODE, reflabel,
STRING_CODE, task->filename(),
INTEGER_CODE, task->line_no(),
NULL);
}
}
#endif
}

View File

@@ -0,0 +1,49 @@
/*
* 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
*/
/* $XConsortium: LcfTask.h /main/2 1996/07/18 16:46:47 drk $ */
#ifndef LCF_TASK_H
#define LCF_TASK_H
#include "Task.h"
class NodeTask;
class LcfTask : public ComplexTask{
friend class NodeTask;
public:
LcfTask( NodeTask *f_parent , const Token &t );
void markup(const Token& t);
protected:
void reset();
void write_record();
// void setNode(NodeTask *n) { f_node = n; }
private:
NodeTask *f_node;
int f_base;
};
#endif /* LcfTask.h */

View File

@@ -0,0 +1,770 @@
#!/bin/sh
set -h
###############################################################################
#
# Set up shell traps
#
###############################################################################
USERPATH=$PATH
PATH=/bin:/usr/bin:/usr/sbin
RETCODE=0
trap '\
RETCODE=${RETCODE:-$?} ;\
/bin/rm -rf $BogusInfoLibDir ;\
/bin/rm -f $SRCLIBPATH/$MMDBMAP.1.$$ ;\
/bin/rm -f $SRCLIBPATH/$MMDBMAP.2.$$ ;\
exit $RETCODE \
' 0 1 2 3 4 5 6 7 8 10 12 15
###############################################################################
ECHOCMD="echo"
ECHOSUF='\\c'
if [ -n "`eval $ECHOCMD $ECHOSUF`" ]; then
ECHOCMD="echo -n"
ECHOSUF=""
fi
echo_f() {
eval $ECHOCMD "$1$ECHOSUF"
}
###############################################################################
confirm_f() {
YorN=
echo ""
echo_f "\ \ \ \ Is \[$1] correct? \[ynq\]\ "
read YorN
if [ "$YorN" = "q" -o "$YorN" = "Q" ] ; then
exit 0
fi
if [ -z "$YorN" -o "$YorN" = "y" -o "$YorN" = "Y" ] ; then
return 1
else
return 0
fi
}
###############################################################################
read_f() {
ANSWER=
read ANSWER
if [ "$ANSWER" = "q" -o "$ANSWER" = "Q" ] ; then
exit 0
fi
}
###############################################################################
DisplayMenu() {
clear
echo "
1) List bookcases in a library
2) Copy a bookcase from another library
3) Rename a bookcase
4) Rearrange bookcases in a library
5) Remove a bookcase
6) Exit
"
echo_f "Please enter your choice \[1-6\]\ "
}
###############################################################################
### Listing of all bookcases available in $1
ListCatalog () {
# list all the bookcases available in the infolib parameter
echo "
The bookcases available in [$1] are:
"
awk 'BEGIN { FS="\t" }
{ if (NR > 1) printf (" %d) %s\t[%s]\n", NR-1, $1, $2 ) }' \
< $1/$MMDBMAP
}
###############################################################################
MoveCatalog () {
# list all the bookcases available in the infolib parameter
echo "
The order of the bookcase(s) without [$BOOKCASENAME1] is:
"
awk 'BEGIN { FS="\t" }
{ if (NR > 1) printf (" %d) %s\t[%s]\n", NR-1, $1, $2 ) }' \
< $1
}
###############################################################################
ValidateInfolibPath () {
INFOLIB=$1
if [ -z "$INFOLIB" -o ! -d $INFOLIB ] ; then
echo "(ERROR) $INFOLIB is not a valid information library" >&2
INFOLIB=""
return
fi
cd $INFOLIB
INFOLIB=`pwd`
cd $CURDIR
}
###############################################################################
ListLibrary() {
SRCLIBPATH=
while [ -z "$SRCLIBPATH" ] ; do
echo "
Enter the path for the library to view.
This can be a relative or absolute path, or to exit, type 'q'."
echo_f "\ \ \ \ --\>\ "
read_f
ValidateInfolibPath $ANSWER
SRCLIBPATH=$INFOLIB
done
### prompt for name of bookcase that is going to be installed ###
LIBDESC=`awk 'BEGIN { FS="\t" }
{ if (NR == 1) print ($1) }' \
< $SRCLIBPATH/$MMDBMAP`
echo ""
echo " Description: [$LIBDESC]"
ListCatalog $SRCLIBPATH
if [ $? -ne 0 ] ; then
exit 1
fi
echo ""
echo_f "\ \ \ \ Hit any key to continue or type 'q' to quit\ "
read_f
}
###############################################################################
CopyBookcase() {
### prompt for infolib and bookcase ###
SRCLIBPATH=
while [ -z "$SRCLIBPATH" ] ; do
echo "
Enter the path for the library from which you want to copy a bookcase.
This can be a relative or absolute path, or to exit, type 'q'."
echo_f "\ \ \ \ --\>\ "
read_f
SRCLIBPATH=$ANSWER
ValidateInfolibPath $SRCLIBPATH
SRCLIBPATH=$INFOLIB
done
BOOKCASENAME=
while [ -z "$BOOKCASENAME" ] ; do
### prompt for name of bookcase that is going to be installed ###
ListCatalog $SRCLIBPATH
if [ $? -ne 0 ] ; then
exit 1
fi
SRCBOOKCASELIST=`awk '{ if (NR > 1) print $1 }' < $SRCLIBPATH/$MMDBMAP `
NUMPOS=`awk 'END { print NR-1 }' < $SRCLIBPATH/$MMDBMAP `
if [ $? -ne 0 ] ; then
echo "(ERROR) Cannot display bookcase #" >&2
exit 1
fi
echo ""
echo_f "\ \ \ \ Enter the number of the bookcase to copy \[1-$NUMPOS\]\ "
read_f
POSITION=$ANSWER
if [ -z "$POSITION" ] ; then
continue
fi
if [ "$POSITION" -lt 1 -o "$POSITION" -gt "$NUMPOS" ]; then
echo "(ERROR) Invalid choice [$POSITION], please try again"
sleep 2
continue
fi
### Confirm the selection with the user
BOOKCASENAME=`awk '{
if ( NR == position+1 ) { print $1 }
}' position=$POSITION < $SRCLIBPATH/$MMDBMAP`
confirm_f "$BOOKCASENAME"
if [ $? -eq 0 ] ; then
BOOKCASENAME=""
fi
done
DESTLIBPATH=
while [ -z "$DESTLIBPATH" ] ; do
echo "
Enter the path for the destination library.
This can be a relative or absolute path, or to exit, type 'q'."
echo_f "\ \ \ \ --\>\ "
read_f
DESTLIBPATH=$ANSWER
ValidateInfolibPath $DESTLIBPATH
DESTLIBPATH=$INFOLIB
### Check if BookCaseName already exists ###
TSTSTRING=
TSTSTRING=`awk '{
if ( $1 == bcname ) { print $1 }
}' bcname=$BOOKCASENAME < $DESTLIBPATH/$MMDBMAP`
if [ -n "$TSTSTRING" ] ; then
echo "\ \ \ \ $BOOKCASENAME already exists in $DESTLIBPATH"
echo_f "\ \ \ \ Do you want to override it? \[ynq\]\ "
read_f
RESPONSE=$ANSWER
OVERRIDE=
if [ "$RESPONSE" = "y" ] ; then
OVERRIDE=-i
DeInstallBase $BOOKCASENAME $DESTLIBPATH
if [ $? -ne 0 ] ; then
echo "(ERROR) Unable to remove $BOOKCASENAME from $DESTLIBPATH"
exit 1
fi
elif [ "$RESPONSE" = "n" ]; then
break
fi
fi
done
### Prompt for parameter verification ###
echo "
You specified this information.
Copy [$BOOKCASENAME] from: $SRCLIBPATH
to : $DESTLIBPATH
"
echo_f "\ \ \ \ Is this correct? [ynq]\ "
read_f
echo ""
RESPONSE=$ANSWER
if [ "$RESPONSE" = "n" ]; then
return
fi
### Grab the bookcase entry line
BCENTRY=`awk '{
if ( NR > 1 && $1 == bookcasename ) { print $0 }
}' bookcasename=$BOOKCASENAME $SRCLIBPATH/$MMDBMAP`
if [ -z "$BCENTRY" ]; then
echo "(ERROR) $BOOKCASENAME does not exist in $SRCLIBPATH"
exit 1
fi
if [ ! -d $BogusInfoLibDir ]; then
mkdir -p $BogusInfoLibDir
else
echo "(ERROR) $BogusInfoLibDir already exists, cannot proceed" >&2
exit 1
fi
cd $BogusInfoLibDir
MMDB_PATH=$BogusInfoLibDir
### set up the bogus link to fool MMDB into believing that
### it is an info-lib
DESTBCLIST=`awk '{ if (NR > 1) print $1 }' < $DESTLIBPATH/$MMDBMAP `
for CurBookCase in $DESTBCLIST; do
ln -s $DESTLIBPATH/$CurBookCase $CurBookCase
done
if [ $? -ne 0 ]; then
echo "(ERROR) Failed to link bookcases from $DESTLIBPATH" >&2
exit 1
fi
### Link the new bookcase to be installed ###
ln -s $SRCLIBPATH/$BOOKCASENAME $BOOKCASENAME
cp $DESTLIBPATH/$MMDBMAP $MMDBMAP
### Update the new $MMDBMAP file with the new entry
echo "$BCENTRY" >> $MMDBMAP
### actually perform the validation ###
echo " Validating bookcases...please wait"
### Generate the BookCaseList ###
BookCaseList=`awk '{if (NR > 1) print $1 }' < $MMDBMAP`
for CurBookCase in $BookCaseList; do
if [ "$BOOKCASENAME" != "$CurBookCase" ]; then
echo " ...Validating $BOOKCASENAME against $CurBookCase"
valBase $BOOKCASENAME $CurBookCase
fi
if [ $? -ne 0 ]; then
echo "(ERROR) No copying is performed because of errors found in validation" >&2
rm -rf $BogusInfoLibDir
sleep 2
return
fi
done
echo " Validation complete."
### clean up the bogus infolib directory ###
cd $CURDIR
rm -r $BogusInfoLibDir
echo "
Copying bookcase... please wait
"
cd $DESTLIBPATH
(cd $SRCLIBPATH ; tar cf - $BOOKCASENAME) | tar xpf -
if [ $? -ne 0 ]; then
echo "(ERROR) Copying failed" >&2
exit 1
fi
echo "$BCENTRY" >> $MMDBMAP
echo " Bookcase copied."
echo ""
echo_f "\ \ \ \ Hit any key to continue or type 'q' to quit\ "
read_f
}
###############################################################################
RenameBookcase() {
### prompt for bookcase to be renamed ###
SRCLIBPATH=
while [ -z "$SRCLIBPATH" ] ; do
echo "
Enter the path for the library to modify.
This can be a relative or absolute path, or to exit, type 'q'."
echo_f "\ \ \ \ --\>\ "
read_f
ValidateInfolibPath $ANSWER
SRCLIBPATH=$INFOLIB
done
BOOKCASENAME=
while [ -z "$BOOKCASENAME" ] ; do
### prompt for name of bookcase that is going to be installed ###
ListCatalog $SRCLIBPATH
if [ $? -ne 0 ] ; then
exit 1
fi
SRCBOOKCASELIST=`awk '{ if (NR > 1) print $1 }' < $SRCLIBPATH/$MMDBMAP `
NUMPOS=`awk 'END { print NR-1 }' < $SRCLIBPATH/$MMDBMAP `
if [ $? -ne 0 ] ; then
echo "(ERROR) Cannot display bookcase #" >&2
exit 1
fi
echo ""
echo_f "\ \ \ \ Enter the number of the bookcase to rename \[1-$NUMPOS\]\ "
read_f
POSITION=$ANSWER
if [ -z "$POSITION" ] ; then
continue
fi
if [ "$POSITION" -lt 1 -o "$POSITION" -gt "$NUMPOS" ]; then
echo "(ERROR) Invalid choice [$POSITION], please try again"
sleep 2
continue
fi
### Confirm the selection with the user
BOOKCASENAME=`awk '{
if ( NR == position+1 ) { print $1 }
}' position=$POSITION < $SRCLIBPATH/$MMDBMAP`
confirm_f "$BOOKCASENAME"
if [ $? -eq 0 ] ; then
BOOKCASENAME=""
fi
done
BookCaseTitle=""
while [ -z "$BookCaseTitle" ] ; do
echo "
Enter the new description for $BOOKCASENAME, or type 'q' to quit."
echo_f "\ \ \ \ --\>\ "
read_f
BookCaseTitle=$ANSWER
### Confirm the title with the user ###
confirm_f "$BookCaseTitle"
if [ $? -eq 0 ] ; then
BOOKCASENAME=""
continue
fi
ChangeCaseTitle $SRCLIBPATH $BOOKCASENAME "$BookCaseTitle"
if [ $? -ne 0 ]; then
exit 1
fi
done
echo " Bookcase renamed."
echo ""
echo_f "\ \ \ \ Hit any key to continue or type 'q' to quit\ "
read_f
}
###############################################################################
RearrangeBookcase() {
### prompt for source information library ###
SRCLIBPATH=
while [ -z "$SRCLIBPATH" ] ; do
echo "
Enter the path for the library to modify.
This can be a relative or absolute path, or to exit, type 'q'."
echo_f "\ \ \ \ --\>\ "
read_f
ValidateInfolibPath $ANSWER
SRCLIBPATH=$INFOLIB
done
BOOKCASENAME1=
while [ -z "$BOOKCASENAME1" ] ; do
SRCBOOKCASELIST=`awk '{ if (NR > 1) print $1 }' < $SRCLIBPATH/$MMDBMAP `
NUMPOS=`awk 'END { print NR-1 }' < $SRCLIBPATH/$MMDBMAP `
if [ $NUMPOS -lt 2 ] ; then
echo " No bookcases to rearrange only $NUMPOS available."
sleep 2
return
fi
### prompt for name of bookcase that is going to be moved ###
ListCatalog $SRCLIBPATH
if [ $? -ne 0 ] ; then
exit 1
fi
echo ""
echo_f "\ \ \ \ Enter the number of the bookcase to move \[1-$NUMPOS\]\ "
read_f
POSITION=$ANSWER
if [ -z "$POSITION" ] ; then
continue
fi
if [ "$POSITION" -lt 1 -o "$POSITION" -gt "$NUMPOS" ]; then
echo "(ERROR) Invalid choice [$POSITION], please try again"
sleep 2
continue
fi
### Confirm the selection with the user
BOOKCASENAME1=`awk '{
if ( NR == position+1 ) { print $1 }
}' position=$POSITION < $SRCLIBPATH/$MMDBMAP`
confirm_f "$BOOKCASENAME1"
if [ $? -eq 0 ] ; then
BOOKCASENAME1=""
fi
done
### Grab the entry line for the bookcase
BCENTRY=`awk '{
if ( NR > 1 && $1 == bookcasename ) { print $0 }
}' bookcasename=$BOOKCASENAME1 $SRCLIBPATH/$MMDBMAP`
if [ -z "$BCENTRY" ]; then
echo "(ERROR) $BOOKCASENAME1 does not exist in $SRCLIBPATH"
exit 1
fi
### Prepare $MMDBMAP for rearrangement ###
awk '{
if ( NR == 1 || $1 != BookCaseName ) { print $0 }
}' BookCaseName=$BOOKCASENAME1 \
< $SRCLIBPATH/$MMDBMAP > $SRCLIBPATH/$MMDBMAP.1.$$
POSITION=
while [ -z "$POSITION" ] ; do
MoveCatalog $SRCLIBPATH/$MMDBMAP.1.$$
echo "
Enter the number corresponding to the position you want [$BOOKCASENAME1]
to occupy. If another bookcase already occupies the position you
choose, the bookcase you are moving takes its place, and the original
bookcase moves one place down in the list."
echo_f "\ \ \ \ Default is $NUMPOS, or type 'q' to quit. \[1-$NUMPOS\]\ "
read_f
POSITION=$ANSWER
if [ -z "$POSITION" ] ; then
POSITION=$NUMPOS
fi
if [ $POSITION -lt 1 -o $POSITION -gt $NUMPOS ]; then
echo "(ERROR) Invalid choice [$POSITION], try again"
continue
fi
### Prompt for parameter verification ###
echo "
You specified this order for the bookcases :
"
if [ "$POSITION" != "$NUMPOS" ]; then
awk ' {
if ( NR != POSITION+1 ) { print $0 }
if ( NR == POSITION+1 ) { print BookCaseEntry; print $0 }
}' POSITION="$POSITION" BookCaseEntry="$BCENTRY" < \
$SRCLIBPATH/$MMDBMAP.1.$$ > $SRCLIBPATH/$MMDBMAP.2.$$
else
cp $SRCLIBPATH/$MMDBMAP.1.$$ $SRCLIBPATH/$MMDBMAP.2.$$
echo "$BCENTRY" >> $SRCLIBPATH/$MMDBMAP.2.$$
fi
awk 'BEGIN { FS="\t" }
{ if (NR > 1) {printf(" %d) %s\t[%s]\n", NR-1, $1, $2); }}
' < $SRCLIBPATH/$MMDBMAP.2.$$
echo ""
echo_f "\ \ \ \ Is this correct? \[ynq\]\ "
read_f
Response=$ANSWER
if [ "$Response" = "n" ]; then
POSITION=
continue
fi
## move the file with new order to $MMDBMAP ###
mv $SRCLIBPATH/$MMDBMAP.2.$$ $SRCLIBPATH/$MMDBMAP
rm -f $SRCLIBPATH/$MMDBMAP.1.$$
done
echo " Bookcase rearranged."
echo ""
echo_f "\ \ \ \ Hit any key to continue or type 'q' to quit\ "
read_f
}
###############################################################################
RemoveBookcase() {
### prompt for bookcase to be removed ###
SRCLIBPATH=
while [ -z "$SRCLIBPATH" ] ; do
echo "
Enter the path for the library to modify.
This can be a relative or absolute path, or to exit, type 'q'."
echo_f "\ \ \ \ --\>\ "
read_f
ValidateInfolibPath $ANSWER
SRCLIBPATH=$INFOLIB
done
BOOKCASENAME=
while [ -z "$BOOKCASENAME" ] ; do
### prompt for name of bookcase that is going to be installed ###
ListCatalog $SRCLIBPATH
if [ $? -ne 0 ] ; then
exit 1
fi
SRCBOOKCASELIST=`awk '{ if (NR > 1) print $1 }' < $SRCLIBPATH/$MMDBMAP `
NUMPOS=`awk 'END { print NR-1 }' < $SRCLIBPATH/$MMDBMAP `
if [ $? -ne 0 ] ; then
echo "(ERROR) Cannot display bookcase #" >&2
exit 1
fi
echo ""
echo_f "\ \ \ \ Enter the number of the bookcase to remove \[1-$NUMPOS\]\ "
read_f
POSITION=$ANSWER
if [ -z "$POSITION" ] ; then
continue
fi
if [ "$POSITION" -lt 1 -o "$POSITION" -gt "$NUMPOS" ]; then
echo "(ERROR) Invalid choice [$POSITION], please try again"
sleep 2
continue
fi
### Confirm the selection with the user
BOOKCASENAME=`awk '{
if ( NR == position+1 ) { print $1 }
}' position=$POSITION < $SRCLIBPATH/$MMDBMAP`
confirm_f "$BOOKCASENAME"
if [ $? -eq 0 ] ; then
BOOKCASENAME=""
fi
done
### Actually perform the de-installation ###
echo " Removing $BOOKCASENAME...please wait"
DeInstallBase $BOOKCASENAME $SRCLIBPATH
if [ $? -ne 0 ]; then
echo "(ERROR) Bookcase is not removed because of errors found in De-Installation utility" >&2
exit 1
fi
echo " Bookcase removed."
echo ""
echo_f "\ \ \ \ Hit any key to continue or type 'q' to quit\ "
read_f
}
###############################################################################
CURDIR=`pwd`
if [ -z "$OLIASDDKBIN" ]; then
NewDir=`dirname $0`
cd $NewDir
OLIASDDKBIN=`pwd`
cd $CURDIR
fi
export MMDB_PATH PATH TMPDIR
TMPDIR=${TMPDIR:-/usr/tmp}
PATH=/bin:/usr/bin:/usr/sbin:${OLIASDDKBIN}
MMDBMAP=bookcase.map
### set up bogus info-lib directory for validation
BogusInfoLibDir=$TMPDIR/infolib$$
###############################################################################
## Get the task option ###
CHOICE=
while [ -z "$CHOICE" ] ; do
DisplayMenu
read CHOICE
case "$CHOICE" in
1)
ListLibrary
;;
2)
CopyBookcase
;;
3)
RenameBookcase
;;
4)
RearrangeBookcase
;;
5)
RemoveBookcase
;;
q|Q|6)
exit 0
;;
*)
echo "
*** Invalid choice, please try again ***
" >&2
sleep 2
;;
esac
cd $CURDIR
CHOICE=
done

View File

@@ -0,0 +1,54 @@
/*
* 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
*/
/* $XConsortium: Literal.h /main/2 1996/07/18 16:47:09 drk $ */
#ifndef __Lithdr__
#define __Lithdr__
#include "BaseDataCollect.h"
#include "FlexBuffer.h"
class Token;
class Literal : public BaseData {
friend class FirstOf;
friend class OL_Data;
friend class Concat;
protected:
Literal( const Token &t, const char *str, ActionType mode );
};
inline
Literal::Literal( const Token &t,
const char *str,
ActionType mode ):BaseData(t, mode)
{
data_complete = 1;
if ( str ) {
ValueBuffer.writeStr( str );
}
}
#endif

View File

@@ -0,0 +1,154 @@
MAINTAINERCLEANFILES = Makefile.in
include ../dtdocbook.am
infolibdir = $(dtdocbooklibexecdir)/infolib
infolib_PROGRAMS = \
MixedGen \
NCFGen \
NodeParser \
StyleUpdate \
dbdrv \
valBase \
validator
infolib_SCRIPTS = ChangeCaseTitle DeInstallBase Librarian
noinst_PROGRAMS = restore
AM_LFLAGS = -Cf -L -8 -s
AM_YFLAGS = -d
AM_CXXFLAGS = \
-DCDE_NEXT \
-DDTDCBK_DATAROOTDIR=\"$(dtdocbookdatadir)\" \
-DDTSEARCH \
-DDtinfoClient \
-DEXPAND_TEMPLATES \
-I$(top_builddir)/lib/DtMmdb
AM_LDFLAGS = $(XTOOLLIB) $(LIBMMDB) $(DTCLIENTLIBS)
MixedGen_SOURCES = \
MixedGen.C \
AttributeList.C \
AttributeRec.C \
BTCollectable.C \
BookCaseDB.C \
DataBase.C \
FlexBuffer.C \
Handler.C \
RemoteId.C \
SGMLName.C \
StringList.C \
Token.C
NCFGen_SOURCES = \
NCFGen.C \
AttributeList.C \
AttributeRec.C \
BTCollectable.C \
BookCaseDB.C \
DataBase.C \
Handler.C \
SGMLName.C \
StringList.C \
StyleValidate.C \
Token.C
NodeParser_SOURCES = \
NodeParser.C \
AttributeData.C \
AttributeList.C \
AttributeRec.C \
AusText.C \
AusTextStorage.C \
BookCaseDB.C \
BookTasks.C \
ConcatTask.C \
Content.C \
ContentType.C \
DataBase.C \
DataRepository.C \
Dispatch.C \
EntityList.C \
ExprList.C \
Expression.C \
FirstOf.C \
FlexBuffer.C \
GenericId.C \
GraphicsTask.C \
Handler.C \
LcfTask.C \
NodeData.C \
NodeTask.C \
OLAF.C \
OL_Data.C \
OL_DataExpr.C \
ReplaceIdIdref.C \
SGMLDefn.C \
SGMLName.C \
SearchEng.C \
SearchPath.C \
StringList.C \
StyleTask.C \
StyleTaskDB.C \
TOCTask.C \
Task.C \
Token.C \
gr_type.C \
lex.ll
StyleUpdate_SOURCES = \
StyleUpdate.C \
AttributeData.C \
AttributeList.C \
AttributeRec.C \
ConcatTask.C \
Content.C \
ContentType.C \
Dispatch.C \
EntityList.C \
ExprList.C \
Expression.C \
FirstOf.C \
FlexBuffer.C \
GenericId.C \
Handler.C \
OLAF.C \
OL_Data.C \
OL_DataExpr.C \
SGMLDefn.C \
SGMLName.C \
SearchPath.C \
StyleTask.C \
StyleValidate.C \
Task.C \
Token.C \
lex.ll
CLEANFILES = \
OL_DataExpr.C \
OL_DataExpr.tab.h \
ContentType.C \
ReplaceIdIdref.C \
RemoteId.C \
gr_type.C \
lex.cc
OL_DataExpr.C: OL_DataExpr.yy
$(YACC) $(AM_YFLAGS) -p ol_data -b OL_DataExpr $<
mv OL_DataExpr.tab.c $@
ContentType.C: ContentType.ll OL_DataExpr.C
$(LEX) $(AM_LFLAGS) -P ol_data -o $@ $<
ReplaceIdIdref.C: ReplaceIdIdref.ll
$(LEX) $(AM_LFLAGS) -P nodedata -o $@ $<
RemoteId.C: RemoteId.ll
$(LEX) $(AM_LFLAGS) -P remote -o $@ $<
gr_type.C: gr_type.ll
$(LEX) $(AM_LFLAGS) -P graphics_task -o $@ $<

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,367 @@
/*
* 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
*/
/* $XConsortium: NCFGen.C /main/9 1996/08/21 15:47:02 drk $ */
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <sstream>
using namespace std;
#include "dti_excs/Exceptions.hh"
#include "DataBase.h"
#include "BookCaseDB.h"
#include "Task.h"
#include "Handler.h"
#include "StyleValidate.h"
#include "Token.h"
/* MMDB interfaces */
#include "oliasdb/mmdb.h"
#include "oliasdb/asciiIn_filters.h"
#include "oliasdb/olias_consts.h"
#include "oliasdb/stylesheet_hd.h"
/* Hash table interfaces */
#include "dti_cc/CC_String.h"
#include "dti_cc/cc_hdict.h"
#include "BTCollectable.h"
#ifdef FISH_DEBUG
#include "dbug.h"
#endif
#define SKIP_CODE -1
static unsigned hash_func(const CC_String &str)
{
return str.hash();
}
//-------------------------------------------------------------------------
static void
writeStyleSheets(BookCaseDB& db)
{
DBTable *out = db.DB::table(DATABASE_STDIO,
STYLESHEET_CODE, BT_NUM_STYLESHEET_FIELDS,
DB::CREATE);
DBTable *in = db.table(BookCaseDB::StyleSheet, DB::READ);
DBCursor cursor(*in);
const char *name;
const char *online;
int len_o;
const char *print;
int len_p;
int statusO = 0;
int statusP = 0;
while(cursor.next(STRING_CODE, &name,
-STRING_CODE, &online, &len_o,
-STRING_CODE, &print, &len_p,
NULL)){
if( (statusO=validate_stylesheet( online, len_o, ONLINE ))){
Token::signalError(Token::User, Token::Continuable, 0, 0,
"Online style sheet for `%s' is invalid.", name);
}
if( (statusP=validate_stylesheet( print, len_p, PRINT ))){
Token::signalError(Token::User, Token::Continuable, 0, 0,
"Print style sheet for `%s' is invalid.", name);
}
if ( statusO || statusP ) {
throw(Unexpected("Style sheet validation failed\n"));
}
out->insert(STRING_CODE, name,
-STRING_CODE, online, (size_t)len_o,
-STRING_CODE, print, (size_t)len_p,
NULL);
}
delete out;
}
//-------------------------------------------------------------------------
static void
buildNCF(BookCaseDB& db, const char *base_name, int compressed)
{
DBTable *ncf = db.DB::table(DATABASE_STDIO,
OLIAS_NODE_CODE, BT_NUM_OLIAS_NODE_FIELDS,
DB::CREATE);
DBTable *nodeMeta = db.table(BookCaseDB::NodeMeta, DB::READ);
DBCursor cursor(*nodeMeta);
const char *bookLocator;
const char *nodeLocator;
const char *filename;
int line_num;
const char *title;
const char *stitle;
const char *style;
int dupID = 0;
string outstr;
OLIAS_DB mmdb_handle;
info_lib *mmdb =
mmdb_handle.openInfoLib(getenv("MMDB_PATH"), (char*)base_name);
info_base *base_ptr = mmdb->get_info_base(base_name);
const int BUFSIZE=30;
hashTable<CC_String,BTCollectable> node_dict(hash_func); // Hash table...
if ( compressed ) {
// 30 will be enough for now.
const int COMPRESSED_AGENT_SIZE=30;
char comp_agent[COMPRESSED_AGENT_SIZE];
// was bzero before, but unable to find bzero on solaris
for ( int i = 0; i < COMPRESSED_AGENT_SIZE; i++ ) {
comp_agent[i] = 0;
}
ostringstream str_buf( comp_agent );
handler *x = (base_ptr->get_obj_dict()).get_handler(
form("%s.%s", base_name, "sgml.dict"));
x->its_oid().asciiOut(str_buf);
memcpy(comp_agent, str_buf.str().c_str(), COMPRESSED_AGENT_SIZE);
while(cursor.next(STRING_CODE, &bookLocator,
STRING_CODE, &nodeLocator,
STRING_CODE, &filename,
INTEGER_CODE, &line_num,
SKIP_CODE, /* TOC num */
STRING_CODE, &title,
STRING_CODE, &stitle,
STRING_CODE, &style,
NULL)){
CC_String *key = new CC_String(nodeLocator);
// check for duplicate node locator
BTCollectable *val = node_dict.findValue( key );
if ( val ) {
delete key;
dupID++;
cerr << "(ERROR) Duplicate section ID = " << nodeLocator << endl
<< " found in file = " << filename << endl
<< " at line = " << line_num << endl
<< " is in conflict with " << endl
<< " section ID = " << nodeLocator << endl
<< " in file = " << val->filename() << endl
<< " at line = " << val->linenum() << "\n\n";
}
else {
BTCollectable *val = new BTCollectable( filename,
line_num,
bookLocator);
node_dict.insertKeyAndValue( key, val );
}
stylesheet_smart_ptr sheet(base_ptr, style);
ostringstream strout;
sheet.its_oid().asciiOut(strout);
outstr = strout.str();
ncf->insert(STRING_CODE, nodeLocator,
STRING_CODE, title,
STRING_CODE, stitle,
COMPRESSED_STRING_CODE, comp_agent, "",
STRING_CODE, bookLocator,
OID_CODE, "0.0", /* pointer to Book/CCF/DOC object */
OID_CODE, (char *)outstr.c_str(),
NULL);
}
}
else {
while(cursor.next(STRING_CODE, &bookLocator,
STRING_CODE, &nodeLocator,
STRING_CODE, &filename,
INTEGER_CODE, &line_num,
SKIP_CODE, /* TOC num */
STRING_CODE, &title,
STRING_CODE, &stitle,
STRING_CODE, &style,
NULL)){
CC_String *key = new CC_String(nodeLocator);
// check for duplicate node locator
BTCollectable *val = node_dict.findValue( key );
if ( val ) {
delete key;
dupID++;
cerr << "(ERROR) Duplicate section ID = " << nodeLocator << endl
<< " found in file = " << filename << endl
<< " at line = " << line_num << endl
<< " is in conflict with " << endl
<< " section ID = " << nodeLocator << endl
<< " in file = " << val->filename() << endl
<< " at line = " << val->linenum() << "\n\n";
}
else {
BTCollectable *val = new BTCollectable( filename,
line_num,
bookLocator );
node_dict.insertKeyAndValue( key , val );
}
stylesheet_smart_ptr sheet(base_ptr, style);
char oid_buf[BUFSIZE];
ostringstream strout(oid_buf);
sheet.its_oid().asciiOut(strout);
strout << ends;
memcpy(oid_buf, strout.str().c_str(), BUFSIZE);
ncf->insert(STRING_CODE, nodeLocator,
STRING_CODE, title,
STRING_CODE, stitle,
STRING_CODE, "",
STRING_CODE, bookLocator,
OID_CODE, "0.0", /* pointer to Book/CCF/DOC object */
OID_CODE, oid_buf,
NULL);
}
}
if ( dupID ) {
throw(Unexpected(
form("Number of duplicated section ID found = %d", dupID)
));
}
delete ncf;
node_dict.clearAndDestroy();
}
//-------------------------------------------------------------------------
static void
usage(const char *progname)
{
fprintf(stderr, "usage: %s [-compressed] [-load-style] <bookcasename> <bookcasedir>\n", progname);
exit(1);
}
//-------------------------------------------------------------------------
int main(int argc, char **argv)
{
INIT_EXCEPTIONS();
set_new_handler( FreeStoreException );
int ret = 1;
const char *progname = argv[0];
int compressed = 0;
int load_style_only = 0;
#ifdef FISH_DEBUG
DBUG_PROCESS(argv[0]);
if(getenv("FISH_DBUG")) DBUG_PUSH(getenv("FISH_DBUG"));
#endif
argv++;
argc--;
while(argc > 0 && argv[0][0] == '-'){
const char *opt = argv[0];
argv++;
argc--;
if(strcmp(opt, "-compressed") == 0){
compressed = 1;
}
else if ( strcmp(opt, "-load-style") == 0 ) {
load_style_only = 1;
}
else {
usage(progname);
}
}
if(argc == 2){
const char *base_name = argv[0];
const char *bookcaseDir = argv[1];
mtry{
BookCaseDB db(bookcaseDir);
if ( load_style_only ) {
writeStyleSheets(db);
}
else {
buildNCF(db, base_name, compressed);
}
ret = 0;
}
mcatch(PosixError&, pe){
fprintf(stderr, "%s: error on %s: %s\n",
progname, bookcaseDir, pe.msg());
}
mcatch(Unexpected&, pe) {
fprintf(stderr, "(ERROR) %s\n\n", pe.msg() );
}
mcatch(mmdbException&, e) {
cerr << e;
}
mcatch_any() {
fprintf(stderr, "*** Internal Error ***: unexpected exception\n");
abort();
}end_try;
}else{
usage(progname);
}
return ret;
}

View File

@@ -0,0 +1,458 @@
/*
* 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
*/
/* $XConsortium: NodeData.C /main/4 1996/09/24 16:55:25 cde-hal $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
/* exported interfaces... */
#include "NodeData.h"
/* imported interfaces... */
#include <iostream>
#include <sstream>
using namespace std;
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "Token.h"
#include "FlexBuffer.h"
#include "NodeTask.h"
#include "SearchEng.h"
#include "OLAF.h"
#include "SGMLName.h"
#include "OL_Data.h"
#include "BookTasks.h"
#include "DataBase.h"
#include "BookCaseDB.h"
#include "GraphicsTask.h"
#include "Dispatch.h"
#include "api/utility.h"
#ifdef UseQSearch
#include "QSearch.h"
#else
#ifdef FULCRUM
#include "Fulcrum.h"
#else
#ifdef DTSEARCH
#include "AusText.h"
#endif
#endif
#endif
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
static int dbgLevel=-1;
extern void ReplaceIdIdRef( NodeData *, char *, int );
//----------------------------------------------------------------
void
replace_entity( FlexBuffer *buf , const char *str)
{
int len = strlen( str );
int i;
const char *ptr;
for ( i = 0, ptr = str;
i < len;
i++, ptr++ ) {
switch ( *ptr )
{
case '\n':
buf->writeStr("&lnfeed;");
break;
case '&':
buf->writeStr("&amp;");
break;
case '<':
buf->writeStr("&lt;");
break;
default:
buf->put( *ptr );
}
}
}
//--------------------------------------------------------------------
void
NodeData::write_start_tag( const Token &t, FlexBuffer *buffer )
{
const AttributeRec *LinkRec = t.LookupAttr( OLAF::OL_idref );
const AttributeRec *IdRec = t.LookupAttr( OLAF::OL_id );
const AttributeRec *XRefRec = t.LookupAttr( OLAF::OL_XRef );
const AttributeRec *GraphicExist = t.LookupAttr( OLAF::OL_Graphic );
if ( t.LookupAttr( OLAF::OL_Ignore ) ) {
if ( IdRec ) {
buffer->writeStr("<%BOGUS><#><#OL-ID>");
char *str = form("%d", seq_no );
buffer->writeStr( str );
buffer->writeStr( "</#OL-ID><#LAST>0</#LAST></#></%BOGUS>" );
seq_no++;
addSubTask( new OL_Data ( t, OLAF::OL_id, REMOVE_SPACES ) );
return;
}
}
if ( Dispatch::OutsideIgnoreScope() ) {
/* write the start tag */
char *str = form("<%s>", t.giName() );
buffer->writeStr( str );
/* write out all the attribute name and value */
// if ( t.GetFirstAttr() || LinkRec || IdRec || GraphicExist ) {
// Always output the attribute tag container because we'll always have
// position data.
buffer->writeStr ( "<#>" );
// }
for ( const AttributeRec *a = t.GetFirstAttr();
a;
a = t.GetNextAttr(a) ) {
/* write the start tag */
const char *attName = SGMLName::lookup( a->getAttrName() );
/* write the attribute start tag */
char *start_tag = form("<%s>",attName);
buffer->writeStr( start_tag );
/* write the attribute value */
replace_entity ( buffer, a->getAttrValueString() );
/* write the attribute end tag */
char *end_tag = form("</%s>", attName );
buffer->writeStr( end_tag );
}
if ( LinkRec ) {
char *str = form ( "<#OL-IDREF>%d</#OL-IDREF>", seq_no );
buffer->writeStr(str);
seq_no++;
addSubTask( new OL_Data ( t, OLAF::OL_idref, REMOVE_SPACES ) );
}
if ( GraphicExist ) {
char *str = form("<#GRAPHIC>%d</#GRAPHIC>", seq_no );
buffer->writeStr( str );
seq_no++;
current_graphics_id = new OL_Data(t, OLAF::OL_id, GENERATE_ID);
addSubTask( current_graphics_id );
}
if ( IdRec ) {
char *str = form("<#OL-ID>%d</#OL-ID>", seq_no );
buffer->writeStr( str );
seq_no++;
addSubTask( new OL_Data ( t, OLAF::OL_id, REMOVE_SPACES ) );
}
if ( XRefRec ) {
char *str = form("<#OL-XREF>%d</#OL-XREF>", seq_no );
buffer->writeStr( str );
seq_no++;
addSubTask( new OL_Data ( t, OLAF::OL_XRef, REMOVE_SPACES ) );
}
if ( GraphicExist ) {
/*
* delay the writing of </#> until potential search terms are generated
*/
return;
}
// if ( t.GetFirstAttr() || LinkRec || IdRec ) {
buffer->writeStr("<#LAST>0</#LAST></#>");
// }
}
}
//---------------------------------------------------------------------
static void
write_end_tag( const Token &t, FlexBuffer *buffer)
{
if ( Dispatch::OutsideIgnoreScope() ) {
char *str = form("</%s>", t.giName() );
buffer->writeStr( str );
}
}
//---------------------------------------------------------------------
NodeData::NodeData( NodeTask *parent, const Token &t)
{
char *dbgStr;
dbgStr = getenv ( "OL_DEBUG");
dbgLevel = ( dbgStr ? atoi(dbgStr) : 0 );
f_node = parent;
f_base = t.level();
CollectObject = -1;
NodeBuffer = new FlexBuffer();
DbBuffer = new FlexBuffer();
seq_no = 0;
current_graphics_id = NULL;
/* f_search is managed explicitly */
/* This probably has to be #ifdef FULCRUM */
#ifdef FULCRUM
f_search = new Fulcrum ( this, t );
#else
#ifdef UseQSearch
f_search = new QSearch ( this, t );
#else
#ifdef DTSEARCH
f_search = new AusText( this, t );
#endif
#endif
#endif
write_start_tag ( t, NodeBuffer );
internal_buffer = NULL;
}
//---------------------------------------------------------------------
NodeData::~NodeData()
{
assert(f_base < 0); /* for debugging NodeTask/NodeData interaction */
reset();
delete NodeBuffer;
delete DbBuffer;
}
//---------------------------------------------------------------------
void
NodeData::markup( const Token &t )
{
if ( f_base > 0 ) {
ComplexTask::markup(t);
if ( f_search ) {
f_search->markup( t );
}
if ( t.type() == START ) {
if ( CollectObject >= 0 ) {
write_start_tag ( t, internal_buffer );
}
else {
if ( t.LookupAttr( OLAF::OL_Graphic ) ) {
CollectObject = t.level();
internal_buffer = new FlexBuffer();
assert(internal_buffer != NULL);
}
write_start_tag ( t, NodeBuffer );
}
}
else if ( t.type() == END ) {
if ( Dispatch::OutsideIgnoreScope() ) {
if ( CollectObject >= 0 ) {
if ( t.level() == CollectObject ) {
if ( f_search->HasSearchTerms() ) {
FlexBuffer *buffer = (FlexBuffer *)
f_search->DumpSearchTerms();
/*
* write out the searchable terms in attribute format
*/
NodeBuffer->writeStr("<#TERMS>");
NodeBuffer->write ( buffer->GetBuffer(),
buffer->GetSize() );
NodeBuffer->writeStr("</#TERMS>");
}
NodeBuffer->writeStr("<#LAST>0</#LAST></#>");
/* write out all the other data/tags that are found within the
* graphic tags
*/
*NodeBuffer = *NodeBuffer + *internal_buffer;
write_end_tag ( t, NodeBuffer );
current_graphics_id = NULL;
CollectObject = -1;
delete internal_buffer;
}
else {
write_end_tag ( t, internal_buffer );
}
}
else { /* ie not collecting oject */
write_end_tag( t , NodeBuffer);
}
if ( f_base == t.level() ) {
write_record();
reset();
}
}
} /* if ( t.type() == END ) */
} /* if ( f_base > 0 ) */
}
//---------------------------------------------------------------------
void
NodeData::reset()
{
f_base = -1;
NodeBuffer->reset();
DbBuffer->reset();
if ( f_search ) {
delete f_search;
f_search = NULL;
}
ComplexTask::removeAllSubTasks();
}
//---------------------------------------------------------------------
void
NodeData::data ( const char *str, size_t t )
{
if ( f_base > 0 ) {
ComplexTask::data( str, t );
if ( f_search ) {
f_search->data( str, t );
}
if ( Dispatch::OutsideIgnoreScope() ) {
if (CollectObject < 0) {
replace_entity( NodeBuffer, str );
}
else {
replace_entity( internal_buffer, str );
}
}
}
}
//---------------------------------------------------------------------
void
NodeData::write_record()
{
DBG(20) printf("Node Before replacement is %s\n", NodeBuffer->GetBuffer());
ReplaceIdIdRef( this, (char *)NodeBuffer->GetBuffer(),
NodeBuffer->GetSize() );
/*
* write out the whole record
*/
const char *TocLocator = f_node->book()->locator();
const char *NodeLocator = f_node->locator();
DBTable *tbl = f_node->book()->bookcase()->table(BookCaseDB::NodeSGML);
tbl->insert(STRING_CODE, TocLocator,
STRING_CODE, NodeLocator,
-STRING_CODE, DbBuffer->GetBuffer(), (size_t)DbBuffer->GetSize(),
NULL);
/*
DBTable *ltab = f_node->book()->bookcase()->table(BookCaseDB::Link);
for ( int i = 0; i < ComplexTask::used; i++ ) {
OL_Data *Task = ( OL_Data * )ComplexTask::subtask(i);
ltab->insert( STRING_CODE, NodeLocator,
INTEGER_CODE, StartingSeqNo + i,
STRING_CODE, Task->content(),
NULL
);
}
*/
}
//---------------------------------------------------------------------
const char *
NodeData::graphics_id()
{
if ( !current_graphics_id ) {
throw(Unexpected("Graphics ID not available"));
}
if ( current_graphics_id->ContentIsEmpty() ) {
throw(Unexpected("An ID could not be found for the graphical object"));
}
return ( current_graphics_id->content() );
}

View File

@@ -0,0 +1,68 @@
/*
* 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
*/
/* $XConsortium: NodeData.h /main/2 1996/07/18 16:47:34 drk $ */
// NodeData.h
#ifndef NODEDATA_HEADER
#define NODEDATA_HEADER
#include "Task.h"
class Token;
class FlexBuffer;
class NodeTask;
class SearchEngine;
class OL_Data;
class NodeData : public ComplexTask {
friend int nodedatalex();
public:
NodeData( NodeTask *, const Token & );
~NodeData();
void markup( const Token & );
void data(const char *, size_t );
NodeTask *node() const { return f_node; }
const char *graphics_id();
protected:
NodeTask *f_node;
FlexBuffer *NodeBuffer;
int CollectObject;
int f_base;
SearchEngine *f_search;
void write_record();
void reset();
private:
int seq_no;
FlexBuffer *DbBuffer;
FlexBuffer *internal_buffer;
OL_Data *current_graphics_id;
void write_start_tag( const Token &t, FlexBuffer *buf );
};
#endif

View File

@@ -0,0 +1,133 @@
/*
* 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
*/
/* $XConsortium: NodeParser.C /main/6 1996/08/21 15:47:06 drk $ */
#include <stdio.h>
#include "dti_cc/CC_Stack.h"
#include "dti_excs/Exceptions.hh"
#include "DataBase.h"
#include "Dispatch.h"
#include "SearchPath.h"
#include "Task.h"
#include "BookTasks.h"
#include "OLAF.h"
#ifdef FISH_DEBUG
#include "dbug.h" /* Fred Fish's dbug.h */
#endif
#include "Handler.h"
//---------------------------------------------------------------------
int main(int argc, char **argv)
{
INIT_EXCEPTIONS();
/* can't seem to get C++ initialization stuff to do this... */
OLAF::init();
set_new_handler( FreeStoreException );
int ret = 1;
#ifdef FISH_DEBUG
DBUG_PROCESS(argv[0]);
if(getenv("FISH_DBUG")) DBUG_PUSH(getenv("FISH_DBUG"));
#endif
if(argc == 4){
const char *toc_option = argv[1];
const char *infolib = argv[2];
const char *srcdir = argv[3];
Dispatch::tmpdir = infolib;
Dispatch::srcdir = srcdir;
if ( !strcmp(toc_option, "toc") ) {
Dispatch::tocgen_only = 1;
}
else if ( !strcmp(toc_option, "all") ) {
Dispatch::tocgen_only = 0;
}
else {
fprintf(stderr, "usage: NodeParse [ tocgen_only | all ] <database-dir> <source-dir>\n");
exit(1);
}
/*
* Add the . directory as a default if the file is not found in scrdir
*/
SearchPath *sptable = new SearchPath( srcdir, ".", 0 );
Dispatch::search_path_table = sptable;
Task *t = new BookCaseTask( infolib );
Stack<int> *istack = new Stack<int>;
Dispatch::setRoot(t, istack);
mtry{
extern int yylex();
yylex();
ret = 0;
}
mcatch(Unexpected&, u)
{
mtry {
Dispatch::tok->reportError(Token::User, Token::Fatal,
"markup error: %s", u.msg());
}
mcatch(ErrorReported&, e)
{
if ( e.f_severity == Token::Fatal ) {
exit(1);
}
}end_try;
}
mcatch(PosixError&, pe)
{
fprintf(stderr, "(ERROR) %s\n", pe.msg() );
exit(1);
}
mcatch(ErrorReported&, e)
{
if ( e.f_severity == Token::Fatal ) {
exit(1);
}
}end_try;
}else{
fprintf(stderr, "usage: NodeParse [ tocgen_only | all ] <database-dir> <source-dir>\n");
}
return ret;
}

View File

@@ -0,0 +1,497 @@
/*
* 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
*/
/* $XConsortium: NodeTask.C /main/6 1996/10/26 18:18:31 cde-hal $ */
/* $Id */
#include <sstream>
using namespace std;
/* exported interfaces... */
#include "NodeTask.h"
/* imported interfaces... */
#include <assert.h>
#include <assert.h>
#include <ctype.h>
#include "Dispatch.h"
#include "Token.h"
#include "LcfTask.h"
#include "OLAF.h"
#include "BookTasks.h"
#include "BookCaseDB.h"
#include "DataBase.h"
#include "OL_Data.h"
#include "NodeData.h"
#include "StyleTask.h"
#include "api/utility.h"
#ifdef FISH_DEBUG
#include "dbug.h" /* Fred Fish's dbug.h */
#endif
#define NUM_FIELDS 5
#define NULLTOEMPTY(x) ((x) ? (x) : "")
static int findDigits( int num )
{
char str[NUM_FIELDS+1];
snprintf( str, NUM_FIELDS+1, "%d", num );
return( strlen(str) );
}
//--------------------------------------------------------------------
NodeTask::NodeTask(BookTask *book, NodeTask *parent)
{
f_book = book;
f_parent = parent;
f_base = -1;
section_element_name = NULL;
ord = 1;
f_title = NULL;
f_shortTitle = NULL;
f_locator = NULL;
/* LCF task is managed explicitly instead of being pushed on the ComplexTask
* list. It is to ensure that f_locator is available whenever f_lcf needs
* it.
*/
f_lcf = NULL;
subnode_pending = 0;
f_subnode = NULL;
f_data = NULL;
f_style = NULL;
}
//--------------------------------------------------------------------
NodeTask::~NodeTask()
{
KILLSUBTASK(f_title);
KILLSUBTASK(f_shortTitle);
KILLSUBTASK(f_locator);
if ( f_lcf ) {
delete f_lcf;
f_lcf = 0;
}
ComplexTask::removeAllSubTasks();
}
int NodeTask::checkNodeAF(const Token& t)
{
int ret = 0;
if(t.LookupAttr( OLAF::OL_Section )
|| t.LookupAttr( OLAF::OL_ToC ) ){
#ifdef FISH_DEBUG
DBUG_PRINT("NodeTask", ("%lx <SECTION> found", this));
#endif
ret = 1;
if(f_base <= 0){ /* are we "idle"? */
f_base = t.level();
section_element_name = strdup(t.giName()); /*@# could be NULL! */
if ( !Dispatch::RunTocGenOnly() ) {
f_lcf = new LcfTask( this , t );
}
/*
* first time we see OL-ID="...", spawn an OL_Data to collect the id
*/
if(f_base > 0 && f_locator == NULL
&& t.LookupAttr(OLAF::OL_id) ){
f_locator = new OL_Data(t, OLAF::OL_id, REMOVE_SPACES);
if ( f_locator->DataWillBeAvailable() ) {
addSubTask( f_locator );
}
else {
delete f_locator;
f_locator = NULL;
}
}
if ( t.LookupAttr( OLAF::OL_Title ) && f_title == NULL ) {
f_title = new OL_Data(t, OLAF::OL_Title, IGNORE_ON );
if ( f_title->DataWillBeAvailable() ) {
addSubTask( f_title );
}
else {
delete f_title;
f_title = 0;
}
}
if ( !Dispatch::RunTocGenOnly() ) {
addSubTask ( f_data = new NodeData ( this, t ) );
}
}else{ /* not idle... must be in the middle of a node */
if(!f_subnode){
f_subnode = new NodeTask(f_book, this);
#ifdef FISH_DEBUG
DBUG_PRINT("NodeTask", ("%lx spawned subnode %lx\n",
this, f_subnode));
#endif
}
subnode_pending = 1;
f_subnode->markup(t);
}
}
return ret;
}
//--------------------------------------------------------------------
void NodeTask::markup(const Token& t)
{
if(subnode_pending){
f_subnode->markup(t);
}else{
ComplexTask::markup(t);
if(t.type() == START){
/*
* Process Node element start tags...
*/
if(checkNodeAF(t)){
/* work done in above routine */
}
/*
* Process Node title start tags...
*/
else {
if ( t.LookupAttr( OLAF::OL_ShortTitle ) ) {
if(f_base > 0 && f_shortTitle == NULL){
f_shortTitle = new OL_Data(t, OLAF::OL_ShortTitle, IGNORE_ON );
if ( !f_shortTitle->DataWillBeAvailable() ) {
delete f_shortTitle;
f_shortTitle = 0;
}
else {
addSubTask(f_shortTitle);
}
}
}
if ( t.LookupAttr( OLAF::OL_Title ) ) {
/* only grab the first title in a node */
if(f_base > 0 && f_title == NULL){
f_title = new OL_Data(t, OLAF::OL_Title, IGNORE_ON );
if ( !f_title->DataWillBeAvailable() ) {
delete f_title;
f_title = 0;
}
else {
addSubTask(f_title);
}
}
}
}
if(f_base >= 0 && !f_style && t.LookupAttr(OLAF::OL_style)
&& !subnode_pending ){
OL_Data *tmp_style = new OL_Data(t, OLAF::OL_style, IGNORE_ON);
if ( tmp_style->DataWillBeAvailable() ) {
f_style = tmp_style;
addSubTask(f_style);
}
else {
delete tmp_style;
}
}
/*
* first time we see OL-ID="...", spawn an OL_Data to collect the id
*/
if(f_base > 0 && f_locator == NULL
&& t.LookupAttr( OLAF::OL_id ) && !subnode_pending ){
f_locator = new OL_Data(t, OLAF::OL_id, REMOVE_SPACES);
if ( f_locator->DataWillBeAvailable() ) {
addSubTask( f_locator );
}
else {
delete f_locator;
f_locator = NULL;
}
}
}
/*
* Let LCF task do its thing
*/
if ( f_base > 0 && !subnode_pending && !Dispatch::RunTocGenOnly() ) {
f_lcf->markup(t);
}
/*
* End Tags... track nesting level, ...
*/
if(t.type() == END){
if(f_base > 0){
if(t.level() == f_base){ /* found end of node...
* write out node meta data */
write_record();
reset();
if(f_parent){
f_parent->endSubNode(t);
}
}
}
}
}
}
void NodeTask::endSubNode(const Token& t)
{
// f_lcf->setNode(this);
subnode_pending = 0;
markup(t);
}
int NodeTask::formatOrd(char * buf, int max)
{
int ret;
int ord_len = findDigits( ord );
if ( ord_len > NUM_FIELDS ) {
throw(Unexpected(form("No. of sections = %d have exceeded"
" the maximum number of sections allowed"
" at one level\n", ord )));
}
if(f_parent == NULL){
int buflen = strlen(buf);
assert( buflen + NUM_FIELDS < max );
snprintf(buf, NUM_FIELDS + 1, "%05d", ord); /* we assume max is big
* enough to format one int
*/
ret = buflen + NUM_FIELDS;
}else{
ret = f_parent->formatOrd(buf, max);
int buflen = ret;
assert ( buflen + NUM_FIELDS + 1< max );
snprintf(buf + buflen, NUM_FIELDS + 2, ".%05d", ord);
ret = buflen + NUM_FIELDS + 1;
}
return ret;
}
void NodeTask::write_record()
{
if(f_title){
const char *title = f_title->content();
const char *stitle = title;
char num[1024]; num[0]='\0';
const char *style = styleName();
if(f_shortTitle){
stitle = f_shortTitle->content();
}
formatOrd(num, sizeof(num));
#ifdef FISH_DEBUG
DBUG_PRINT("NodeTask", ("%lx loc=%s ord=%s title=`%s'\n",
this, locator(), num, title));
#endif
DBTable *tbl = f_book->bookcase()->table(BookCaseDB::NodeMeta);
tbl->insert(STRING_CODE, f_book->locator(),
STRING_CODE, locator(),
STRING_CODE, f_locator->filename(),
INTEGER_CODE, f_locator->line_no(),
STRING_CODE, num,
STRING_CODE, title,
STRING_CODE, stitle,
STRING_CODE, style,
NULL);
}else{
throw(Unexpected(form(
"No section title available for the section element [%s]\n",
NULLTOEMPTY(section_element_name))));
}
}
void NodeTask::reset()
{
f_base = -1;
delete section_element_name;
ord++;
KILLSUBTASK(f_title);
KILLSUBTASK(f_locator);
KILLSUBTASK(f_shortTitle);
KILLSUBTASK(f_data);
KILLSUBTASK(f_style);
if ( f_lcf ) {
delete f_lcf;
f_lcf = 0;
}
if(f_subnode) f_subnode->ord = 1;
}
void NodeTask::data( const char *str, size_t sz)
{
if(subnode_pending){
f_subnode->data(str, sz);
}else{
ComplexTask::data(str, sz);
if ( f_base > 0 && !Dispatch::RunTocGenOnly() ) {
f_lcf->data(str, sz);
}
}
}
const char *NodeTask::locator()
{
if(!f_locator) throw(Unexpected(form(
"No ID available for the section element [%s]\n",
NULLTOEMPTY(section_element_name)
)));
if ( !f_locator->DataIsComplete() ) {
throw(Unexpected(form(
"ID collection is not done yet for the section element [%s]\n",
NULLTOEMPTY(section_element_name)
)));
}
return ( f_locator->content() );
}
const char *
NodeTask::styleName()
{
if ( Dispatch::RunTocGenOnly() ) {
return("");
}
const char *ret;
if(f_style){
ret = f_style->content();
/* This is a hack to get the name of the style sheet right
* Because sgmls can change the case sensitivity of the actual
* style sheet name, I am going to use the case sensitive version
* of the string first, if it doesn't exist, I will try the case
* insensitive one, i.e. all uppercase
*/
if(f_book->bookcase()->styleTask()->exist(ret)){
#ifdef FISH_DEBUG
DBUG_PRINT("Style", ("node style is: %s", ret));
#endif
}
else {
char *local_str = (char *)ret;
for ( char *ptr = local_str; *ptr != '\0'; ptr++ ) {
*ptr = toupper( *ptr );
}
/* try again */
if ( f_book->bookcase()->styleTask()->exist(ret) ) {
#ifdef FISH_DEBUG
DBUG_PRINT("Style", ("node style is: %s", ret));
#endif
}
else{
Token::signalError(Token::User, Token::Continuable,
f_style->filename(), f_style->line_no(),
form("Style `%s' not available\n", ret) );
if ( f_parent ) { ret = f_parent->styleName(); }
else { ret = f_book->styleName(); }
}
}
}
else{
if ( f_parent ) { ret = f_parent->styleName(); }
else { ret = f_book->styleName(); }
}
return ret;
}
//------------------------------------------------------------
const char *
NodeTask::title()
{
if (!f_title) {
throw(Unexpected(
form(
"No section title available for the section element [%s]\n",
NULLTOEMPTY(section_element_name )
)
));
}
return( f_title->content() );
}

View File

@@ -0,0 +1,99 @@
/*
* 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
*/
/* $XConsortium: NodeTask.h /main/3 1996/07/18 15:16:53 drk $ */
#ifndef __NodeTask_h
#define __NodeTask_h
#include "Task.h"
class LcfTask;
class SearchStorage;
class BookCaseTask;
class BookTask;
class OL_Data;
class NodeData;
class NodeTask : public ComplexTask{
/*
* The NodeTask builds the NodeMeta table:
*
* Table name: NodeMeta
* Fields:
* STRING node contents ("balanced tag" string) -- "" on first pass
* STRING book/toc locator
* STRING node locator
* STRING node "ordinal", e.g. 2.3.1
* STRING node title
* STRING node stitle
*/
public:
NodeTask(BookTask *book, class NodeTask *parent);
~NodeTask();
void markup(const Token& t);
void data( const char *, size_t);
const char *locator(); /* throw(Unexpected) if no locator yet */
BookTask *book() { return ( f_book ); }
const char *styleName();
const char *title(); /* throw(Unexpected) if no title available yet */
int start_node_level() const { return(f_base); }
protected:
void write_record();
void reset();
void endSubNode(const Token& t);
int checkNodeAF(const Token& t);
int formatOrd(char * buf, int max); /* for TOC gen, debugging */
private:
int f_base;
char *section_element_name;
int ord; /* for TOC gen, debugging */
BookTask *f_book;
LcfTask *f_lcf;
OL_Data *f_shortTitle;
OL_Data *f_title;
OL_Data *f_locator;
int subnode_pending;
NodeTask *f_subnode;
NodeTask *f_parent;
NodeData *f_data;
OL_Data *f_style;
};
#endif /* __NodeTask_h */

View File

@@ -0,0 +1,118 @@
/*
* 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
*/
/* $XConsortium: OLAF.C /main/4 1996/09/24 16:55:40 cde-hal $
*
* OLAF -- OLIAS Architectural Forms
*/
#include <assert.h>
#include "OLAF.h"
#include "SGMLName.h"
static int init = OLAF::init();
const int NAMECASE = 1; /* Only one SGML Decl. supported */
int
OLAF::init()
{
static int done = 0;
if(done) return 0;
done = 1;
#define INTERN(n) SGMLName::intern(#n, NAMECASE);
SGMLName::init();
/* The order of calls to SGMLName::intern _MUST_ match the
* enumeration in OLAF.h
*/
INTERN(OLIAS);
INTERN(OLIAS.Value);
INTERN(OLIAS.ID);
INTERN(OLIAS.IDREF);
INTERN(OLIAS.Scope);
INTERN(OLIAS.Style);
INTERN(OLIAS.Choice);
INTERN(OLIAS.TOC);
INTERN(OLIAS.TOCEntry);
INTERN(OLIAS.TOClevel);
INTERN(OLIAS.Section);
INTERN(OLIAS.Title);
INTERN(OLIAS.ShortTitle);
INTERN(OLIAS.Ignore);
INTERN(OLIAS.Graphic);
INTERN(OLIAS.Table);
INTERN(OLIAS.XRefLabel);
INTERN(OLIAS.XRef);
INTERN(Example);
INTERN(Graphic);
INTERN(Index);
INTERN(Table);
INTERN(Title);
INTERN(BookcaseDesc);
INTERN(BookcaseName);
INTERN(BookShortTitle);
INTERN(BookTitle);
INTERN(Book);
INTERN(Bookcase);
INTERN(Style);
INTERN(Stylesheet);
INTERN(BookTab);
INTERN(Feature);
INTERN(Online);
INTERN(Print);
INTERN(Path);
INTERN(Select);
INTERN(FeatureSet);
INTERN(FeatureText);
INTERN(AutoNumber);
INTERN(AutoRef);
INTERN(BookAccess);
assert(SGMLName::intern("Feature", NAMECASE) == OLAF::Feature);
SGMLName::intern("lnfeed");
SGMLName::intern("nbsp");
SGMLName::intern("amp");
SGMLName::intern("lt");
assert(SGMLName::intern("lnfeed") == OLAF::lnfeed);
INTERN(VenCode);
INTERN(Version);
INTERN(Grouping);
INTERN(DemoTerms);
INTERN(DefaultSection);
assert( SGMLName::intern("Grouping", NAMECASE) == OLAF::Grouping );
return 0;
}

View File

@@ -0,0 +1,109 @@
/*
* 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
*/
/* $XConsortium: OLAF.h /main/4 1996/09/24 16:55:57 cde-hal $
*
* OLAF -- OLIAS Architectural Forms
*/
#ifndef __OLAF_h
#define __OLAF_h
#include "SGMLName.h"
class OLAF{
public:
/* you can call this whenever you like. Only the first call has
* any effect.
*/
static int init();
enum {
/* Architectural form namespaces... */
OLIAS = SGMLName::qty,
OL_data,
OL_id,
OL_idref,
OL_scope,
OL_style,
OL_Choice,
OL_ToC,
OL_ToCEntry,
OL_TOClevel,
OL_Section,
OL_Title,
OL_ShortTitle,
OL_Ignore,
OL_Graphic,
OL_Table,
OL_XRefLabel,
OL_XRef,
Example,
Graphic,
Index,
Table,
Title,
BcDesc,
BcName,
BkSTitle,
BkTitle,
Book,
Bookcase,
Style,
Stylesheet,
Tab,
Feature,
Online,
Print,
Path,
Select,
FeatureSet,
FeatureText,
AutoNumber,
AutoRef,
BookAccess,
/*
* The following names are for entities , shouldn't be inside OLAF
* namespace. But ...
*/
lnfeed,
nbsp,
amp,
lt,
/*
* The following are attribute names used in the access control element
*/
VenCode,
Version,
Grouping,
DemoTerms,
DefaultSection
};
};
#endif /* __OLAF_h */

View File

@@ -0,0 +1,270 @@
/*
* 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
*/
/* $XConsortium: OL_Data.C /main/4 1996/08/21 15:47:10 drk $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
/* exported interfaces */
#include "OL_Data.h"
/* imported interfaces */
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <misc/unique_id.h>
#include "Expression.h"
#include "AttributeRec.h"
#include "OLAF.h"
#include "SGMLName.h"
#include "Token.h"
#include "Task.h"
#include "Dispatch.h"
#include "SGMLDefn.h"
#include "AttributeData.h"
#include "Content.h"
#include "FirstOf.h"
#include "GenericId.h"
#include "Literal.h"
#include "ConcatTask.h"
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
static int dbgLevel=-1;
//---------------------------------------------------------------------------
static char *
FilteredSpaces( const char *str )
{
char *head;
char *tail = (char *)str + strlen( str ) - 1;
char *ptr = (char *)str;
while (1) {
if ( *ptr != ' ' && *ptr != '\n' && *ptr != '\t' ) {
head = ptr;
break;
}
else {
ptr++;
}
}
while (1) {
if ( *tail != ' ' && *tail != '\n' && *tail != '\t' ) {
*(tail + 1) = '\0';
break;
}
else { tail--; }
}
return ( head );
}
//-------------------------------------------------------------------------
OL_Data::OL_Data( const Token &t,
int DataType,
ActionType mode ):BaseData(t,mode)
{
char *dbgStr;
dbgStr = getenv("OL_DEBUG");
dbgLevel = ( dbgStr ? atoi ( dbgStr ) : 0 );
/* first generate grep all the mode info */
istat = mode & IGNORE_ON;
removeSpaces = mode & REMOVE_SPACES;
f_name = strdup( t.file() );
line_num = t.line();
if ( istat && !Dispatch::OutsideIgnoreScope() ) {
data_avail = 0;
return;
}
const AttributeRec *attRec;
if ( !(attRec = t.LookupAttr( DataType )) ) {
if ( mode & GENERATE_ID ) {
const char *str = unique_id();
ValueBuffer.writeStr( str );
data_avail = 1;
data_complete = 1;
}
else {
/*
* The default rule kicks in, i.e use #CONTENT
*/
addSubTask( new Content( t, mode) );
}
return;
}
tokContent.Parse( ( char *)attRec->getAttrValueString() );
const OL_Expression *eptr = tokContent.exprlist;
assert(eptr != NULL);
switch ( eptr->type() ) {
case REFERENCE:
{
BaseData *sub_data = new AttributeData(t, eptr->name(), mode );
if ( sub_data ) {
if ( (data_avail= sub_data->DataWillBeAvailable()) ) {
ValueBuffer.write( sub_data->content(),
sub_data->content_size() );
data_complete = 1;
}
delete sub_data;
}
}
break;
case CONTENT:
addSubTask( new Content(t, mode) );
break;
case CONCAT:
addSubTask( new Concat( t,
(ExprList *)eptr->data_list(),
mode) );
break;
case FIRSTOF:
addSubTask( new FirstOf( t,
(ExprList *)eptr->data_list(),
mode) );
break;
case GENERIC_ID:
addSubTask( new GenericId( t,
eptr->name(),
mode) );
break;
case LITERAL:
data_avail = 1;
data_complete = 1;
ValueBuffer.writeStr( ( const char *)eptr->data_list() );
break;
default:
abort();
}
}
//-------------------------------------------------------------------------
void
OL_Data::markup( const Token &t )
{
DBG(80) cerr << "(DEBUG) OL_Data::markup() " << endl;
DBG(80) cerr << " t.giName() = " << t.giName() << endl;
if ( istat && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
ComplexTask::markup( t );
if ( t.type() == END ) {
if ( f_base == t.level() ) {
data_complete = 1;
for ( int i=0; i < ComplexTask::used; i++ ) {
BaseData *task = ( BaseData *)ComplexTask::subtask(i);
ValueBuffer.write( task->content(), task->content_size() );
}
if ( removeSpaces && ValueBuffer.GetSize() > 0 ) {
const char *filtered_string = FilteredSpaces( ValueBuffer.GetBuffer() );
/* rewrite ValueBuffer with the filtered string */
ValueBuffer.reset();
ValueBuffer.writeStr( filtered_string );
}
DBG(10) printf("Data for <%s> = %s\n", t.giName(),
ValueBuffer.GetBuffer() );
reset();
}
}
} /* if level > 0 */
}
//-------------------------------------------------------------------------
void
OL_Data::data( const char *str, size_t t )
{
if ( istat && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
ComplexTask::data( str, t );
}
}
//-------------------------------------------------------------------------
void
OL_Data::reset()
{
f_base = -1;
istat = removeSpaces = 0;
removeAllSubTasks();
}

View File

@@ -0,0 +1,86 @@
/*
* 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
*/
/* $XConsortium: OL_Data.h /main/2 1996/07/18 16:47:56 drk $ */
#ifndef OL_DATA_H
#define OL_DATA_H
#include <string.h>
#include "ContentType.h"
#include "Token.h"
#include "BaseDataCollect.h"
class OL_Data : public BaseData {
friend class FirstOf;
private:
ContentType tokContent;
char *f_name;
int line_num;
int istat; /* These are status info */
int removeSpaces;
void reset();
protected:
/*
* This constructor is used by the derived class of OL_Data only
*/
OL_Data( const Token &t, ActionType ignore=DEFAULT_ACTION );
public:
/*
* istat is controlled by the invoker to determine if OL_Data should really
* ignore the OLIAS IGNORE attribute. The reason that such action is
* controlled by the invoker of the class is that the corresponding
* behavior of IGNORE is controlled by the invoker, not by the OL_Data class
*/
OL_Data( const Token &t,
int aType,
ActionType mode=DEFAULT_ACTION);
/* no action takes place by default */
~OL_Data() { delete f_name; }
public:
void markup( const Token & );
void data( const char *, size_t );
char *filename() { return ( f_name ); }
int line_no() { return ( line_num ); }
};
inline
OL_Data::OL_Data(const Token &t, ActionType mode):BaseData(t,mode)
{
istat = mode & IGNORE_ON;
removeSpaces = mode & REMOVE_SPACES;
f_name = strdup( t.file() );
line_num = t.line();
}
#endif

View File

@@ -0,0 +1,103 @@
/* $XConsortium: OL_DataExpr.y /main/2 1996/11/11 11:51:54 drk $ */
%{
#include <stdio.h>
#include "ExprList.h"
#include "Expression.h"
#include "ContentType.h"
extern int yylex();
extern void yyerror( const char *str );
extern ContentType *CurrentContentPtr;
%}
%union {
int name;
char *string;
OL_Expression *eptr;
}
%token <name> Reference
%token <name> Id
%token <string> Literal
%token Content
%token Concat
%token Attr
%token FirstOf
%type <eptr> Expr
%type <eptr> ExprList
%start ValList
%%
ValList : ExprList
{
CurrentContentPtr->init($1);
}
;
ExprList : Expr
{
$$ = $1;
}
| Expr ',' ExprList
{
$1->next = $3;
$$ = $1;
}
;
Expr : Id
{
OL_Expression *expr = new OL_Expression( GENERIC_ID, $1);
$$ = expr;
}
| Content
{
OL_Expression *expr = new OL_Expression( CONTENT );
$$ = expr;
}
| Concat '(' ExprList ')'
{
ExprList *elist = new ExprList( $3 );
OL_Expression *expr = new OL_Expression( CONCAT, -1, elist);
$$ = expr;
}
| Attr '(' Id ')'
{
OL_Expression *expr = new OL_Expression( REFERENCE, $3);
$$ = expr;
}
| FirstOf '(' ExprList ')'
{
ExprList *elist = new ExprList ( $3 );
OL_Expression *expr = new OL_Expression( FIRSTOF, -1, elist );
$$ = expr;
}
| Literal
{
OL_Expression *expr = new OL_Expression( LITERAL, -1, $1 );
$$ = expr;
}
| Reference
{
OL_Expression *expr = new OL_Expression( REFERENCE, $1 );
$$ = expr;
}
;
%%

View File

@@ -0,0 +1,157 @@
%option noyywrap
%{
/* $XConsortium: RemoteId.l /main/3 1996/11/19 16:54:33 drk $ */
/* imported interfaces */
#include "FlexBuffer.h"
#include "BTCollectable.h"
#include "dti_cc/CC_String.h"
#include "dti_cc/cc_hdict.h"
static int my_input ( char *, int );
#undef YY_INPUT
#define YY_INPUT(b, r, ms ) ( r=my_input( ( char *)b,ms) )
static char *myinput;
static char *myinputptr;
static char *myinputlim;
static FlexBuffer *NodeBuffer;
static FlexBuffer *idref_buffer;
static hashTable<CC_String,BTCollectable> *hd;
static int NeedRemote = 0;
static int current_line_num = 0;
static char *current_file_name;
%}
%x OLIDREF OLIDREF_LINE OLIDREF_FILE
%%
"<#OL-IDREF>" {
BEGIN( OLIDREF );
NodeBuffer->writeStr("<#OL-IDREF>");
}
<OLIDREF>"<#L>" {
BEGIN(OLIDREF_LINE);
}
<OLIDREF_LINE>[^<]+ {
const char *line = (const char *)yytext;
current_line_num = atoi( line );
}
<OLIDREF_LINE>"</#L>" {
BEGIN( OLIDREF );
}
<OLIDREF>"<#F>" {
BEGIN ( OLIDREF_FILE );
}
<OLIDREF_FILE>[^<]+ {
current_file_name = strdup( (const char *)yytext);
}
<OLIDREF_FILE>"</#F>" {
BEGIN ( OLIDREF );
}
<OLIDREF>"&lt;" {
// Perform the entity resolution
idref_buffer->put('<');
NodeBuffer->writeStr( "&lt;" );
}
<OLIDREF>"&amp;" {
idref_buffer->put('&');
NodeBuffer->writeStr( "&amp;" );
}
<OLIDREF>"</#OL-IDREF>" {
/*
* test if the link value found in
* #OL-IDREF is resolved in the bookcase
*/
CC_String key( (const char *)idref_buffer->GetBuffer() );
CC_String *val = (CC_String *)hd->findValue( &key );
if ( !val ) {
NeedRemote = 1;
cerr << "(WARNING) Unresolved link = " << (const char *)key << endl
<< " file = " << current_file_name << endl
<< " line no. = " << current_line_num << "\n\n";
}
// cleanup and reset
delete current_file_name; current_file_name = 0;
idref_buffer->reset();
NodeBuffer->writeStr("</#OL-IDREF>");
if ( NeedRemote ) {
NodeBuffer->writeStr("<#REMOTE></#REMOTE>");
NeedRemote = 0;
}
BEGIN ( 0 );
}
<OLIDREF>[^&<]+ {
const char *str = (const char *)yytext;
idref_buffer->writeStr( str );
NodeBuffer->writeStr( str );
}
. |
\n {
NodeBuffer->put( yytext[0] );
}
%%
static int
my_input ( char *buf, int max_size )
{
int remain = myinputlim - myinputptr;
int n = ( max_size > remain ? remain : max_size );
if ( n > 0 ) {
memcpy ( buf, myinputptr, n );
myinputptr += n;
}
return n;
}
//------------------------------------------------------------
void insert_remotelink( hashTable<CC_String,BTCollectable> *dictionary,
char *data,
size_t datalen,
FlexBuffer *result_buf)
{
myinput = data;
myinputptr = data;
myinputlim = data + datalen;
NodeBuffer = result_buf;
hd = dictionary;
idref_buffer = new FlexBuffer();
yylex();
delete idref_buffer;
BEGIN INITIAL;
yyrestart(NULL);
}
void bogus(int)
{
cout << "bogus\n";
}

View File

@@ -0,0 +1,193 @@
%option noyywrap
%{ /* -*- c++ -*- */
/* $XConsortium: ReplaceIdIdref.l /main/3 1996/11/19 16:54:45 drk $ */
/* exported interfaces... */
#include "NodeData.h"
/* imported interfaces... */
#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "misc/unique_id.h"
#include "Token.h"
#include "FlexBuffer.h"
#include "NodeTask.h"
#include "SearchEng.h"
#include "OLAF.h"
#include "SGMLName.h"
#include "OL_Data.h"
#include "BookTasks.h"
#include "DataBase.h"
#include "BookCaseDB.h"
#include "GraphicsTask.h"
#include "Dispatch.h"
#include "api/utility.h"
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
static int dbgLevel=-1;
/*
* Forward declaration for my_input
*/
static int my_input ( char *, int );
#undef YY_INPUT
#define YY_INPUT(b, r, ms ) ( r=my_input( ( char *)b,ms) )
static char *myinput;
static char *myinputptr;
static char *myinputlim;
NodeData *CurrentNodeData;
extern void replace_entity ( FlexBuffer *, const char *);
%}
%x OLID OLIDREF GRAPHIC XREF
%%
"<#OL-XREF>" {
BEGIN ( XREF );
}
<XREF>[0-9]+ {
const char *str = ( const char *)yytext;
OL_Data *idref =
(OL_Data *)CurrentNodeData->subtask( atoi(str) );
if ( !idref->ContentIsEmpty() ) {
const char *idrefval = idref->content();
FlexBuffer *db_buf = CurrentNodeData->DbBuffer;
db_buf->writeStr("<#OL-XREF>");
replace_entity ( db_buf, idrefval );
db_buf->writeStr("</#OL-XREF>");
}
}
<XREF>"</#OL-XREF>" {
BEGIN ( 0 );
}
"<#OL-ID>" {
BEGIN ( OLID );
}
<OLID>[0-9]+ {
/*
* query the array for the real no.
*/
const char *str = ( const char *)yytext;
OL_Data *id =
(OL_Data *)CurrentNodeData->subtask( atoi(str) );
if ( !id->ContentIsEmpty() ) {
const char *idval = id->content();
FlexBuffer *db_buf = CurrentNodeData->DbBuffer;
db_buf->writeStr("<#OL-ID>");
replace_entity( db_buf, idval );
db_buf->writeStr("</#OL-ID>");
}
}
<OLID>"</#OL-ID>" {
BEGIN ( 0 );
}
"<#OL-IDREF>" {
BEGIN( OLIDREF );
}
<OLIDREF>[0-9]+ {
const char *str = (const char *)yytext;
OL_Data *idref =
(OL_Data *)CurrentNodeData->subtask(atoi(str));
if ( !idref->ContentIsEmpty() ) {
const char *idrefval = idref->content();
int line_num = idref->line_no();
const char *filename = idref->filename();
FlexBuffer *db_buf = CurrentNodeData->DbBuffer;
db_buf->writeStr("<#OL-IDREF>");
db_buf->writeStr(form("<#L>%d</#L>", line_num));
db_buf->writeStr(form("<#F>%s</#F>", filename));
replace_entity ( db_buf, idrefval );
db_buf->writeStr("</#OL-IDREF>");
}
}
<OLIDREF>"</#OL-IDREF>" {
BEGIN( 0 );
}
"<#GRAPHIC>" {
BEGIN( GRAPHIC );
}
<GRAPHIC>[0-9]+ {
const char *str = (const char *)yytext;
OL_Data *graphic_id =
(OL_Data *)CurrentNodeData->subtask(atoi(str));
if ( !graphic_id->ContentIsEmpty() ) {
const char *graphic_id_val =
graphic_id->content();
CurrentNodeData->DbBuffer->writeStr("<#GRAPHIC>");
replace_entity (CurrentNodeData->DbBuffer,
graphic_id_val);
CurrentNodeData->DbBuffer->writeStr("</#GRAPHIC>");
}
}
<GRAPHIC>"</#GRAPHIC>" {
BEGIN(0);
}
. |
\n {
CurrentNodeData->DbBuffer->put( yytext[0] );
}
%%
//-----------------------------------------------------------------------
static int
my_input ( char *buf, int max_size )
{
int remain = myinputlim - myinputptr;
int n = ( max_size > remain ? remain : max_size );
if ( n > 0 ) {
memcpy ( buf, myinputptr, n );
myinputptr += n;
}
return n;
}
//----------------------------------------------------------------------
void ReplaceIdIdRef( NodeData *nd , char *buffer, int sz )
{
CurrentNodeData = nd;
myinput = buffer;
myinputptr = buffer;
myinputlim = buffer + sz;
yylex();
BEGIN INITIAL;
yyrestart(NULL);
}

View File

@@ -0,0 +1,126 @@
/*
* 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
*/
/* $XConsortium: SGMLDefn.cc /main/2 1996/06/04 16:44:32 rcs $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#include <assert.h>
#include <string.h>
#include "SGMLName.h"
#include "SGMLDefn.h"
SGMLDefn::SGMLDefn()
{
sys_id = NULL;
pub_id = NULL;
file_name = NULL;
name = -1;
next = NULL;
type = INVALID;
}
SGMLDefn::~SGMLDefn()
{
delete [] sys_id;
delete [] pub_id;
delete [] file_name;
}
void
SGMLDefn::store_sys_id( char *sid )
{
if ( sid ) {
delete [] sys_id;
int len = strlen(sid);
sys_id = new char [len + 1];
assert(sys_id != NULL);
*((char *) memcpy(sys_id, sid, len) + len) = '\0';
}
}
void
SGMLDefn::store_pub_id( char *pid )
{
if ( pid ) {
delete [] pub_id;
int len = strlen(pid);
pub_id = new char [len + 1];
assert(pub_id != NULL);
*((char *) memcpy(pub_id, pid, len) + len) = '\0';
}
}
void
SGMLDefn::store_defn( DEFN_TYPE dt, char *defnStr )
{
if ( dt == ENTITY_TYPE ) {
type = dt;
char *tmp = strtok( defnStr, "\n\t ");
name = SGMLName::intern(tmp);
}
}
void
SGMLDefn::store_file_name( char *fname )
{
if ( fname ) {
delete [] file_name;
int len = strlen(fname);
file_name = new char [len + 1];
assert(file_name != NULL);
*((char *) memcpy(file_name, fname, len) + len) = '\0';
}
}
SGMLDefn &
SGMLDefn::operator=( SGMLDefn &defn )
{
store_sys_id( defn.sys_id );
store_pub_id( defn.pub_id );
store_file_name( defn.file_name );
type = defn.type;
name = defn.name;
next = NULL;
return (*this);
}

View File

@@ -0,0 +1,70 @@
/*
* 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
*/
/* $XConsortium: SGMLDefn.h /main/2 1996/07/18 16:48:35 drk $ */
#ifndef SGML_DEFN_HDR
#define SGML_DEFN_HDR
enum DEFN_TYPE {
INVALID=-1,
ENTITY_TYPE,
NOTATION_TYPE,
SUBDOC_TYPE
};
class SGMLDefn {
friend int yylex();
friend class Dispatch;
friend class EntityList;
private:
char *sys_id;
char *pub_id;
char *file_name;
int name;
DEFN_TYPE type;
SGMLDefn *next;
protected:
void store_sys_id( char *sid );
void store_pub_id( char *pid );
void store_defn( DEFN_TYPE, char * );
void store_file_name( char *file_name );
SGMLDefn &operator=( SGMLDefn & );
public:
int getName() const { return(name); }
char *getFileName() const { return(file_name); }
SGMLDefn();
~SGMLDefn();
};
#endif

View File

@@ -0,0 +1,242 @@
/*
* 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: SGMLName.C /main/3 1998/04/17 11:23:18 mgreess $ */
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "SGMLName.h"
/****** private interface *******/
typedef struct {
char *string;
int code;
}Item;
class StringToInt{
public:
StringToInt();
int intern(const char* name);
const char* lookup(int);
protected:
void grow(size_t);
private:
Item *items;
size_t used;
size_t total;
};
static int
whichString (const char * target,
const Item * table,
int qty);
/****** implementation *******/
static StringToInt *theTable = NULL;
int
SGMLName::intern(const char *name, int upcase)
{
static char *buf = 0;
static size_t buflen = 0;
const char *n;
if(!theTable) theTable = new StringToInt();
if(upcase){
size_t nlen = strlen(name);
if(buflen < nlen + 1){
delete buf;
buf = new char[buflen = nlen * 3 / 2 + 10];
}
const char *src;
char *dest;
for(src = name, dest=buf; *src; src++, dest++){
*dest = toupper((unsigned char) *src);
}
*dest = 0;
n = buf;
}else{
n = name;
}
return theTable->intern(n);
}
const char*
SGMLName::lookup(int indx)
{
return theTable->lookup(indx);
}
StringToInt::StringToInt()
{
items = 0;
total = used = 0;
}
int
StringToInt::intern(const char *name)
{
int indx;
if( (indx = whichString(name, items, used)) < 0){
grow(used + 1);
int len = strlen(name);
char *p = new char[len + 1];
*((char *) memcpy(p, name, len) + len) = '\0';
indx = used;
while(indx > 0 && strcmp(name, items[indx-1].string) < 0){
items[indx] = items[indx-1];
indx--;
}
items[indx].string = p;
items[indx].code = used;
used++;
}
return items[indx].code;
}
void StringToInt::grow(size_t needed)
{
if(total < needed){
Item *born = new Item[total = needed * 3 / 2 + 10];
if(used){
memcpy(born, items, sizeof(Item) * used);
delete items;
}
items = born;
}
}
const char* StringToInt::lookup(int indx)
{
unsigned int i;
for(i = 0; i < used; i++){
if (items[i].code == indx) return items[i].string;
}
abort();
return NULL; /* avoid compiler warning */
}
/*
** Binary search for an array of strings for a given string.
** return index into the table, or -1 if not found.
*/
static int
whichString (const char * target,
const Item * table,
int qty)
{
int low = 0;
int high = qty;
int i, diff;
while(high > 0){
i = (high + low)/2;
diff = strcmp(table[i].string, target);
if(diff == 0) { /* success: found it */
return i;
}else if(low + 1 >= high) break;
else if(diff > 0) high = i;
else low = i;
}
return -1;
}
const int NAMECASE = 1; /* Only one SGML Decl. supported */
void SGMLName::init()
{
#define INTERN(n) intern(#n, NAMECASE);
INTERN(IMPLIED);
INTERN(CDATA);
INTERN(NOTATION);
INTERN(TOKEN);
INTERN(ENTITY);
}
#ifdef TEST
#include <stdio.h>
int
main(int argc, char **)
{
char buf[100];
int upcase = 0;
if(argc > 1) upcase = 1;
while(fgets(buf, sizeof(buf)-1, stdin) != NULL){
int indx;
printf("intern: %d\n", indx = SGMLName::intern(buf, upcase));
printf("lookup: %s\n", SGMLName::lookup(indx));
}
}
#endif

View File

@@ -0,0 +1,40 @@
/*
* 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
*/
/* $XConsortium: SGMLName.h /main/2 1996/07/18 15:19:02 drk $ */
#ifndef __SGMLName_h
#define __SGMLName_h
class SGMLName{
public:
static int intern(const char*, int upcase = 0);
static const char *lookup(int) /* throw(KeyError) */;
enum DeclaredValue { IMPLIED, CDATA, NOTATION, TOKEN, ENTITY, qty };
static void init();
};
#endif

View File

@@ -0,0 +1,67 @@
/*
* 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
*/
/* $XConsortium: SearchEng.C /main/3 1996/08/21 15:47:17 drk $ */
/* imported interfaces */
#include "dti_cc/CC_Stack.h"
#include "OL_Data.h"
#include "Task.h"
#include "FlexBuffer.h"
#include "Token.h"
#include "OLAF.h"
#include "NodeData.h"
#include "NodeTask.h"
#include "GraphicsTask.h"
#include "BookTasks.h"
#include "Dispatch.h"
#include "SGMLName.h"
// exported interfaces
#include "SearchEng.h"
//---------------------------------------------------------------------
SearchEngine::SearchEngine( NodeData *parent , const Token & t )
{
f_base = t.level();
f_graphics = 0;
CollectObject = -1;
hasTerms = 0;
f_parent = parent;
termsBuffer = NULL;
}
//---------------------------------------------------------------------
int
SearchEngine::GraphicsIsDone() const
{
if ( f_graphics ) { return ( f_graphics->IsDone() ); }
else {
return 0;
}
}

View File

@@ -0,0 +1,108 @@
/*
* 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
*/
/* $XConsortium: SearchEng.h /main/2 1996/07/18 16:48:56 drk $ */
// SearchEngine.h - This serves as a base class for different search engine
#ifndef SRH_ENG_HEADER
#define SRH_ENG_HEADER
#include "FlexBuffer.h"
template <class Type> class Stack;
class ComplexTask;
class Token;
class NodeData;
class GraphicsTask;
class SearchEngine : public ComplexTask {
protected:
const FlexBuffer *termsBuffer;
int f_base;
int hasTerms;
int CollectObject;
NodeData *f_parent;
GraphicsTask *f_graphics;
protected:
virtual void write_start_tag ( const Token & ) = 0;
virtual void write_end_tag ( const Token & ) = 0;
virtual void write_terms ( FlexBuffer *termsbuf ) = 0;
virtual void write_buffer() = 0; /*
* This corresponds to the
* write_fulcrum_buffer, write_qsearch_buffer
*/
public:
/* The following 2 are pure virtual, so that each derived class has to
* redefine them
*/
virtual void markup( const Token &) = 0;
virtual void data ( const char *, size_t ) = 0;
/* default will be used if not redefined by the derived class
*/
virtual int HasSearchTerms() const;
virtual const FlexBuffer *DumpSearchTerms();
virtual int GraphicsIsDone() const;
virtual NodeData *node_data() { return f_parent; }
protected:
SearchEngine( NodeData *, const Token &); /* This is not intended to be
* used as a constructor for
* instantiation an object
* but used as a common point
* of initialization of all the
* base classes for SearchEng
*/
public:
virtual ~SearchEngine() {}
};
inline
int
SearchEngine::HasSearchTerms() const
{
return( hasTerms );
}
//---------------------------------------------------------------------
inline
const FlexBuffer *
SearchEngine::DumpSearchTerms()
{
hasTerms = 0;
return ( termsBuffer );
}
#endif

View File

@@ -0,0 +1,175 @@
/*
* 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
*/
/* $XConsortium: SearchPath.C /main/7 1996/08/21 15:47:21 drk $ */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <strings.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sstream>
using namespace std;
#include "dti_excs/Exceptions.hh"
#include "Task.h"
#include "api/utility.h"
/* exported interface */
#include "SearchPath.h"
#ifdef NEED_STRCASECMP
#include <ctype.h>
/*
* In case strcasecmp and strncasecmp are not provided by the system
* here are ones which do the trick.
*/
int
strcasecmp(const char *s1,
const char *s2)
{
int c1, c2;
while (*s1 && *s2) {
c1 = isupper(*s1) ? tolower(*s1) : *s1;
c2 = isupper(*s2) ? tolower(*s2) : *s2;
if (c1 != c2)
return (c1 - c2);
s1++;
s2++;
}
return (int) (*s1 - *s2);
}
int
strncasecmp(const char *s1,
const char *s2,
size_t count)
{
int c1, c2;
if (!count)
return 0;
while (*s1 && *s2) {
c1 = isupper(*s1) ? tolower(*s1) : *s1;
c2 = isupper(*s2) ? tolower(*s2) : *s2;
if ((c1 != c2) || (! --count))
return (c1 - c2);
s1++;
s2++;
}
return (int) (*s1 - *s2);
}
#endif
//--------------------------------------------------------------------
static int isdir(char* filename)
{
int ret = 0;
struct stat sb;
if(stat(filename, &sb) == 0){
if(S_ISDIR(sb.st_mode)){
ret = 1;
}
}
return ret;
}
//-------------------------------------------------------------------
SearchPath::SearchPath( const char *path, ... )
{
search_path_table = new CC_TPtrSlist<CC_String>;
new_path = 0;
va_list ap;
va_start ( ap , path);
const char *spath = path;
while ( spath ) {
CC_String *key = new CC_String(spath);
search_path_table->append( key );
spath = va_arg ( ap, const char * );
}
va_end ( ap );
}
//-------------------------------------------------------------------
char *
SearchPath::get_real_path( const char *file_name )
{
CC_TPtrSlistIterator<CC_String> path_it( *search_path_table );
FILE *fp = NULL;
if (file_name == NULL || *file_name == '\0')
return NULL;
// remove storage object specifier
if (strncasecmp(file_name, "<OSFILE", 7) == 0) {
if ((file_name = strchr(file_name, '>')))
file_name++;
else
return NULL;
}
while ( path_it() ) {
const char *path = (const char *)*path_it.key();
char *full_path_name = form( "%s/%s", path, file_name );
if (( fp = fopen( full_path_name , "r" )) && !isdir(full_path_name) ) {
fclose( fp );
return ( full_path_name );
}
if(fp) {
fclose( fp );
}
}
return NULL;
}
//-------------------------------------------------------------------
void
SearchPath::replace_file_scope( const char *f_path )
{
if ( new_path ) {
if ( !search_path_table->remove( new_path ) ) {
throw(Unexpected("Cannot replace file scope\n"));
}
delete new_path; new_path = 0;
}
new_path = new CC_String(f_path);
search_path_table->prepend( new_path );
}

View File

@@ -0,0 +1,72 @@
/*
* 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
*/
/* $XConsortium: SearchPath.h /main/3 1996/08/21 15:47:25 drk $ */
// SearchPath.h
#ifndef SRH_PATH_HDR
#define SRH_PATH_HDR
#include <stdarg.h>
#include "dti_cc/CC_Slist.h"
#include "dti_cc/CC_String.h"
class SearchPath {
private:
CC_TPtrSlist<CC_String> *search_path_table;
CC_String *new_path;
public:
/* the search path order is significant because they are searched in that
* order
*/
/*
* Usage :: SearchPath *ptr = new SearchPath ( "dir1", "dir2", "dir3" );
* and later on when I invoked ptr->get_real_path( "file_name" );
* dir1, dir2 and dir3 will be searched in order to determine if file_name
* exists in any one of the directories.
*
* The first directory which contains "file_name" will be returned by
* get_real_path( "file_name" );
*
*/
SearchPath(const char *path, ... );
/*
* Usage: replace_file_scope checks if we are in a file that is outside the
* the build directory and the source directory, if so , it will
* get rid of that directory, and prepend the new one at the front
* of the search path table list. This is primarily tied to the
* the ESIS format for the display of current file name and line
* number.
*
*/
void replace_file_scope( const char *path );
char *get_real_path( const char *file_name );
~SearchPath() { if ( search_path_table ) delete search_path_table; }
};
#endif

View File

@@ -0,0 +1,196 @@
/*
* 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
*/
/* $XConsortium: SearchStorage.cc /main/4 1996/07/23 18:10:39 cde-hal $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#include <stdio.h>
#include <stddef.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <sstream>
using namespace std;
/* imported interfaces */
#include <misc/unique_id.h>
#include "FlexBuffer.h"
#include "Task.h"
#include "DataBase.h"
#include "api/utility.h"
/* exported interfaces */
#include "SearchStorage.h"
//-----------------------------------------------------------------------
static int isdir(const char* filename)
{
int ret = 0;
struct stat sb;
if(stat(filename, &sb) == 0){
if(S_ISDIR(sb.st_mode)){
ret = 1;
}
}
return ret;
}
//-----------------------------------------------------------------------
static void makedir(const char *path) /* throw(PosixError) */
{
if(mkdir((char*)path, 0775) != 0){
throw(PosixError(errno, path));
}
}
//-----------------------------------------------------------------------
static const char *FilteredString( FlexBuffer &f_buf, const char *str )
{
for ( const char *ptr = str; *ptr != 0; ptr++ ) {
if ( *ptr == '\"' ) {
f_buf.writeStr ( "\\\"" );
}
else if ( *ptr == '\\' ) {
f_buf.writeStr ( "\\\\" );
}
else {
f_buf.put ( *ptr );
}
}
return ( f_buf.GetBuffer() );
}
//-----------------------------------------------------------------------
SearchStorage::SearchStorage( const char *path, const char *name )
{
if ( !isdir(path) ) {
makedir(path);
}
int pathlen = strlen(path) + 1 + strlen("filtered") + 1;
filteredPath = new char [pathlen];
/*
* throw(ResourceExhausted)
*
*/
assert ( filteredPath != NULL );
snprintf( filteredPath, pathlen, "%s/filtered", path );
if ( !isdir(filteredPath) ) {
makedir(filteredPath);
}
/* construct the fulcrum path */
char *fulcrumpath = form("%s/fulcrum", path );
if ( !isdir(fulcrumpath) ) {
makedir(fulcrumpath);
}
char *catalogname = form("%s/%s.cin", fulcrumpath, name );
catalogfile = fopen ( catalogname, "w" );
if ( !catalogfile ) {
throw(PosixError(errno, form("unable to open catalog %s\n", catalogname) ) );
}
}
//-----------------------------------------------------------------------
void
SearchStorage::insert( const char *BookCaseName,
const int BookNum,
const char *BookShortTitle,
const char *SectionID,
const char *SectionTitle,
const char *buffer,
int size
)
{
// write the search buffer to a file with name "NodeLocator" under
// fulcrumpath
// we use a unique_id() as the file name, in order to avoid spaces, /
// and stuffs like that.....
const char *filtered_file_name = unique_id();
char *filename = form("%s/%s", filteredPath, filtered_file_name );
FILE *fp = fopen( filename, "w" );
if ( !fp ) {
throw(PosixError(errno, form("Unable to open %s", filename) ) );
}
if ( !fwrite ( buffer, size, 1, fp ) ) {
throw(PosixError(errno, "unable to write to buffer\n" ) );
}
fclose(fp);
FlexBuffer new_section_id;
FlexBuffer new_book_short_title;
FlexBuffer new_section_title;
FlexBuffer new_book_case_name;
// append to the catalog file
if ( catalogfile ) {
fprintf( catalogfile, "{\ns %s s 32 1;\n", filtered_file_name );
fprintf( catalogfile, "f 100 \"%s\" ;\n",
FilteredString( new_section_id, SectionID ) );
fprintf( catalogfile, "f 127 \"%s\" ;\n" ,
FilteredString( new_book_short_title, BookShortTitle ) );
fprintf( catalogfile, "f 128 \"%s\" ;\n",
FilteredString( new_section_title, SectionTitle ) );
fprintf( catalogfile, "f 130 \"%d\";\n", BookNum );
fprintf( catalogfile, "f 131 \"%s\";\n",
FilteredString( new_book_case_name, BookCaseName) );
fprintf( catalogfile, "}\n");
}
}
//-----------------------------------------------------------------------
SearchStorage::~SearchStorage()
{
if ( catalogfile ) { fclose(catalogfile); }
if ( filteredPath ) { delete [] filteredPath; }
}

View File

@@ -0,0 +1,60 @@
/*
* 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
*/
/* $XConsortium: SearchStorage.h /main/3 1996/07/18 16:49:38 drk $ */
#ifndef SRCH_STOR_HDR
#define SRCH_STOR_HDR
#include <stdio.h>
class SearchStorage {
private:
FILE *catalogfile;
char *filteredPath;
public:
SearchStorage( const char *BookCasePath, const char *BookCaseName );
/*
* insert ( "This Book Case Name", 2,
* "XmyLcfhalklkoop",
* "This is the text that the indexing machine will see",
* 51 );
*
*/
void insert( const char *BookCaseName,
const int BookNum,
const char *BookShortTitle,
const char *SectionID,
const char *SectionTitle,
const char *buffer,
int size
);
~SearchStorage();
};
#endif

Some files were not shown because too many files have changed in this diff Show More