FormatSDL.c 310 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these librararies and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $TOG: FormatSDL.c /main/18 1999/10/14 13:18:42 mgreess $ */
  24. /************************************<+>*************************************
  25. ****************************************************************************
  26. **
  27. ** File: FormatSDL.c
  28. **
  29. ** Project: CDE Help System
  30. **
  31. ** Description: This code formats information in an SDL volume into
  32. ** an into internal format.
  33. **
  34. ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
  35. **
  36. ** (c) Copyright 1993, 1994 Hewlett-Packard Company
  37. ** (c) Copyright 1993, 1994 International Business Machines Corp.
  38. ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  39. ** (c) Copyright 1993, 1994 Novell, Inc.
  40. **
  41. ****************************************************************************
  42. ************************************<+>*************************************/
  43. /*
  44. * system includes
  45. */
  46. #include <ctype.h>
  47. #include <limits.h>
  48. #include <string.h>
  49. #include <stdio.h>
  50. #include <stdlib.h>
  51. #include <sys/stat.h>
  52. /*
  53. * Core Engine includes
  54. */
  55. #include "CanvasP.h"
  56. #include "CanvasSegP.h"
  57. #include "LinkMgrP.h"
  58. /*
  59. * private includes
  60. */
  61. #include "bufioI.h"
  62. #include "CanvasOsI.h"
  63. #include "CleanUpI.h"
  64. #include "CvStringI.h"
  65. #include "CvtToArrayP.h"
  66. #include "FontAttrI.h"
  67. #include "Access.h"
  68. #include "AccessI.h"
  69. #include "AccessSDLP.h"
  70. #include "AccessSDLI.h"
  71. #include "FormatUtilI.h"
  72. #include "FormatSDLI.h"
  73. #include "StringFuncsI.h"
  74. #include "SDLI.h"
  75. #include "UtilSDLI.h"
  76. #include "RegionI.h"
  77. #ifdef NLS16
  78. #endif
  79. /******************************************************************************
  80. * Private structures
  81. ******************************************************************************/
  82. typedef struct _snbLinkInfo {
  83. SDLCdata xid; /* also used for data & command */
  84. SDLCdata format;
  85. SDLCdata method;
  86. SDLNumber offset;
  87. } SnbLinkInfo;
  88. typedef struct _elementInfo {
  89. unsigned long enum_values;
  90. unsigned long num_values;
  91. unsigned long str1_values;
  92. unsigned long str2_values;
  93. enum SdlElement el_type; /* the current element */
  94. SdlOption timing; /* the current timing type */
  95. SdlOption sdl_type; /* dynamic, lined, literal, etc */
  96. SdlOption window;
  97. SdlOption interp;
  98. union
  99. {
  100. SDLNumber count;
  101. SDLNumber offset;
  102. } nums;
  103. SDLCdata language;
  104. SDLCdata char_set;
  105. SDLCdata id;
  106. SDLCdata elstr1;
  107. SDLCdata elstr2;
  108. union
  109. {
  110. SDLDocInfo doc_info; /* <sdldoc> */
  111. SDLIdInfo id_info; /* <id> */
  112. SnbLinkInfo snb_info; /* <callback>, <crossdoc>,
  113. <man-page>, <textfile>, <sys-cmd> */
  114. _DtCvSegment *table_info; /* <form> */
  115. SDLEntryInfo entry_info; /* <entry */
  116. } w;
  117. SdlMatchData match;
  118. } ElementInfo, *ElementInfoPtr;
  119. typedef struct _unresSnref {
  120. int cur_link;
  121. char *id;
  122. _DtCvSegment *seg;
  123. _DtHelpFontHints fonts;
  124. } UnresSnref;
  125. typedef struct _formatStruct {
  126. _DtCvValue end_flag;
  127. _DtCvValue last_was_space;
  128. _DtCvValue last_was_mb;
  129. _DtCvValue last_was_nl;
  130. _DtCvValue snref_used;
  131. _DtCvValue faked_end;
  132. _DtCvValue save_snref;
  133. _DtCvValue save_blank;
  134. _SdlFontMode resolve_font;
  135. enum SdlElement parsed;
  136. char *remember;
  137. char *vol_name;
  138. char *id_string;
  139. int cur_link;
  140. int mb_len;
  141. int flags;
  142. int malloc_size;
  143. int alloc_size;
  144. int free_cnt;
  145. int free_max;
  146. int snref_cnt;
  147. const _FrmtUiInfo *ui_info;
  148. _DtCvSegment *block_list;
  149. _DtCvSegment *add_seg;
  150. _DtCvSegment *last_seg;
  151. _DtCvSegment *seg_list;
  152. _DtCvSegment *prev_data;
  153. _DtCvSegment *toss;
  154. _DtCvSegment *async_blks;
  155. _DtCvSegment *snb;
  156. _DtCvSegment *else_prev;
  157. _DtCvSegment *then_prev;
  158. _DtCvContainer *active_frmt;
  159. _DtCvLinkDb my_links;
  160. ElementInfo el_info;
  161. _DtHelpFontHints *my_fonts;
  162. _DtHelpFontHints **free_fonts;
  163. UnresSnref *un_snrefs;
  164. BufFilePtr my_file;
  165. } FormatStruct;
  166. /******************************************************************************
  167. * Private Function Declarations
  168. ******************************************************************************/
  169. static int AddRowToTable(
  170. FormatStruct *my_struct,
  171. SDLMask *element_types,
  172. enum SdlElement sig_element,
  173. SDLMask *exceptions,
  174. SDLMask *process_mask);
  175. static int AllocateBlock(
  176. FormatStruct *my_struct,
  177. SDLMask *element_types,
  178. enum SdlElement sig_element,
  179. SDLMask *exceptions,
  180. SDLMask *process_mask);
  181. static int Cdata(
  182. FormatStruct *my_struct,
  183. SDLMask *element_types,
  184. enum SdlElement sig_element,
  185. SDLMask *exceptions,
  186. SDLMask *process_mask);
  187. static int CheckForSnb(
  188. FormatStruct *my_struct,
  189. SDLMask *element_types,
  190. enum SdlElement sig_element,
  191. SDLMask *exceptions,
  192. SDLMask *process_mask);
  193. static int CheckType(
  194. FormatStruct *my_struct,
  195. SDLMask *element_types,
  196. enum SdlElement sig_element,
  197. SDLMask *exceptions,
  198. SDLMask *process_mask);
  199. static int CleanUpBlock(
  200. FormatStruct *my_struct,
  201. SDLMask *element_types,
  202. enum SdlElement sig_element,
  203. SDLMask *exceptions,
  204. SDLMask *process_mask);
  205. static int ClearAndCheckSnref(
  206. FormatStruct *my_struct,
  207. SDLMask *element_types,
  208. enum SdlElement sig_element,
  209. SDLMask *exceptions,
  210. SDLMask *process_mask);
  211. static int ColInfoToTableInfo(
  212. FormatStruct *my_struct,
  213. SDLMask *element_types,
  214. enum SdlElement sig_element,
  215. SDLMask *exceptions,
  216. SDLMask *process_mask);
  217. static int CopyAnchorId(
  218. FormatStruct *my_struct,
  219. SDLMask *element_types,
  220. enum SdlElement sig_element,
  221. SDLMask *exceptions,
  222. SDLMask *process_mask);
  223. static int CopyDocInfo(
  224. FormatStruct *my_struct,
  225. SDLMask *element_types,
  226. enum SdlElement sig_element,
  227. SDLMask *exceptions,
  228. SDLMask *process_mask);
  229. static int CopyIdInfo(
  230. FormatStruct *my_struct,
  231. SDLMask *element_types,
  232. enum SdlElement sig_element,
  233. SDLMask *exceptions,
  234. SDLMask *process_mask);
  235. static int ResolveSpcInfo(
  236. FormatStruct *my_struct,
  237. SDLMask *element_types,
  238. enum SdlElement sig_element,
  239. SDLMask *exceptions,
  240. SDLMask *process_mask);
  241. static int CopyEntryInfo(
  242. FormatStruct *my_struct,
  243. SDLMask *element_types,
  244. enum SdlElement sig_element,
  245. SDLMask *exceptions,
  246. SDLMask *process_mask);
  247. static int CopyTossInfo(
  248. FormatStruct *my_struct,
  249. SDLMask *element_types,
  250. enum SdlElement sig_element,
  251. SDLMask *exceptions,
  252. SDLMask *process_mask);
  253. static int FakeEnd(
  254. FormatStruct *my_struct,
  255. SDLMask *element_types,
  256. enum SdlElement sig_element,
  257. SDLMask *exceptions,
  258. SDLMask *process_mask);
  259. static _DtCvSegment *FindSnbEntry(
  260. _DtCvSegment *snb,
  261. char *target);
  262. static char *GetInterpCmd(SdlOption interp_type);
  263. static int IfInfo(
  264. FormatStruct *my_struct,
  265. SDLMask *element_types,
  266. enum SdlElement sig_element,
  267. SDLMask *exceptions,
  268. SDLMask *process_mask);
  269. static int InitLast(
  270. FormatStruct *my_struct,
  271. SDLMask *element_types,
  272. enum SdlElement sig_element,
  273. SDLMask *exceptions,
  274. SDLMask *process_mask);
  275. static int LoadGraphic(
  276. FormatStruct *my_struct,
  277. SDLMask *element_types,
  278. enum SdlElement sig_element,
  279. SDLMask *exceptions,
  280. SDLMask *process_mask);
  281. static int MarkFound(
  282. FormatStruct *my_struct,
  283. SDLMask *element_types,
  284. enum SdlElement sig_element,
  285. SDLMask *exceptions,
  286. SDLMask *process_mask);
  287. static int OnlyOne(
  288. FormatStruct *my_struct,
  289. SDLMask *element_types,
  290. enum SdlElement sig_element,
  291. SDLMask *exceptions,
  292. SDLMask *process_mask);
  293. static int OnlyOneEach(
  294. FormatStruct *my_struct,
  295. SDLMask *element_types,
  296. enum SdlElement sig_element,
  297. SDLMask *exceptions,
  298. SDLMask *process_mask);
  299. static int OneToN(
  300. FormatStruct *my_struct,
  301. SDLMask *element_types,
  302. enum SdlElement sig_element,
  303. SDLMask *exceptions,
  304. SDLMask *process_mask);
  305. static int ParseSDL(
  306. FormatStruct *my_struct,
  307. enum SdlElement cur_element,
  308. enum SdlElement sig_element,
  309. SDLMask *cur_except,
  310. SDLMask *process_mask);
  311. static int ProcessEnterAttr(
  312. FormatStruct *my_struct,
  313. SDLMask *element_types,
  314. enum SdlElement sig_element,
  315. SDLMask *cur_except,
  316. SDLMask *process_mask);
  317. static int ProcessExitAttr(
  318. FormatStruct *my_struct,
  319. SDLMask *element_types,
  320. enum SdlElement sig_element,
  321. SDLMask *cur_except,
  322. SDLMask *process_mask);
  323. static int ProcessSDLMarkup(
  324. FormatStruct *my_struct,
  325. enum SdlElement cur_element,
  326. enum SdlElement sig_element,
  327. SDLMask *cur_except,
  328. SDLMask *process_mask);
  329. static int RegisterLink(
  330. FormatStruct *my_struct,
  331. SDLMask *element_types,
  332. enum SdlElement sig_element,
  333. SDLMask *exceptions,
  334. SDLMask *process_mask);
  335. static int RegisterSnbLink(
  336. FormatStruct *my_struct,
  337. SDLMask *element_types,
  338. enum SdlElement sig_element,
  339. SDLMask *exceptions,
  340. SDLMask *process_mask);
  341. static int RegisterSwitch(
  342. FormatStruct *my_struct,
  343. SDLMask *element_types,
  344. enum SdlElement sig_element,
  345. SDLMask *exceptions,
  346. SDLMask *process_mask);
  347. static int ResolveIf(
  348. FormatStruct *my_struct,
  349. _DtCvSegment *prev_data);
  350. static int SaveItemInfo(
  351. FormatStruct *my_struct,
  352. SDLMask *element_types,
  353. enum SdlElement sig_element,
  354. SDLMask *exceptions,
  355. SDLMask *process_mask);
  356. static int SaveLangCharSet(
  357. FormatStruct *my_struct,
  358. SDLMask *element_types,
  359. enum SdlElement sig_element,
  360. SDLMask *exceptions,
  361. SDLMask *process_mask);
  362. static int SetSaveSnref(
  363. FormatStruct *my_struct,
  364. SDLMask *element_types,
  365. enum SdlElement sig_element,
  366. SDLMask *exceptions,
  367. SDLMask *process_mask);
  368. static int SetTransit(
  369. FormatStruct *my_struct,
  370. SDLMask *element_types,
  371. enum SdlElement sig_element,
  372. SDLMask *exceptions,
  373. SDLMask *process_mask);
  374. static int SetType(
  375. FormatStruct *my_struct,
  376. SDLMask *element_types,
  377. enum SdlElement sig_element,
  378. SDLMask *exceptions,
  379. SDLMask *process_mask);
  380. static int ZeroOrOne(
  381. FormatStruct *my_struct,
  382. SDLMask *element_types,
  383. enum SdlElement sig_element,
  384. SDLMask *exceptions,
  385. SDLMask *process_mask);
  386. static int ZeroToN(
  387. FormatStruct *my_struct,
  388. SDLMask *element_types,
  389. enum SdlElement sig_element,
  390. SDLMask *exceptions,
  391. SDLMask *process_mask);
  392. /******** End Public Function Declarations ********/
  393. /******************************************************************************
  394. * Private Defines
  395. *****************************************************************************/
  396. #define GROW_SIZE 5
  397. #define MAX_ATTRIBUTE_LENGTH 30
  398. /******************************************************************************
  399. * Private Macros
  400. *****************************************************************************/
  401. #define DefPercent 10000
  402. #define ElCharSet(x) ((x)->el_info.char_set)
  403. #define ElClan(x) ((x)->el_info.match.clan)
  404. #define ElCount(x) ((x)->el_info.nums.count)
  405. #define ElFlag1(x) ((x)->el_info.enum_values)
  406. #define ElFlag2(x) ((x)->el_info.num_values)
  407. #define ElFlag3(x) ((x)->el_info.str1_values)
  408. #define ElFlag4(x) ((x)->el_info.str2_values)
  409. #define ElFrmtType(x) ((x)->el_info.sdl_type)
  410. #define ElId(x) ((x)->el_info.id)
  411. #define ElInterp(x) ((x)->el_info.interp)
  412. #define ElLanguage(x) ((x)->el_info.language)
  413. #define ElLevel(x) ((x)->el_info.match.level)
  414. #define ElOffset(x) ((x)->el_info.nums.offset)
  415. #define ElSsi(x) ((x)->el_info.match.ssi)
  416. #define ElTiming(x) ((x)->el_info.timing)
  417. #define ElType(x) ((x)->el_info.el_type)
  418. #define ElWindow(x) ((x)->el_info.window)
  419. #define ElInfoClan(x) ((x)->match.clan)
  420. #define ElDocInfo(x) ((x)->el_info.w.doc_info)
  421. #define ElEntryInfo(x) ((x)->el_info.w.entry_info)
  422. #define ElIdInfo(x) ((x)->el_info.w.id_info)
  423. #define ElSnbXid(x) ((x)->el_info.w.snb_info.xid)
  424. #define ElSnbFormat(x) ((x)->el_info.w.snb_info.format)
  425. #define ElSnbMethod(x) ((x)->el_info.w.snb_info.method)
  426. #define ElSwitchBranches(x) ((x)->el_info.elstr1)
  427. #define ElTable(x) ((x)->el_info.w.table_info)
  428. #define ElTableCellIds(x) \
  429. _DtCvCellIdsOfTableSeg(((x)->el_info.w.table_info))
  430. #define ElTableColNum(x) \
  431. _DtCvNumColsOfTableSeg(((x)->el_info.w.table_info))
  432. #define ElTableColWidths(x) \
  433. _DtCvColWOfTableSeg(((x)->el_info.w.table_info))
  434. #define ElTableColJust(x) \
  435. _DtCvColJustifyOfTableSeg(((x)->el_info.w.table_info))
  436. #define ElTableList(x) \
  437. _DtCvCellsOfTableSeg(((x)->el_info.w.table_info))
  438. #define ElString1(x) ((x)->el_info.elstr1)
  439. #define ElString2(x) ((x)->el_info.elstr2)
  440. #define ElAbbrev(x) ((x)->el_info.elstr1)
  441. #define ElEnter(x) ((x)->el_info.elstr1)
  442. #define ElExit(x) ((x)->el_info.elstr2)
  443. #define ElSpcName(x) ((x)->el_info.elstr1)
  444. #define ElTableCellId(x) ((x)->el_info.elstr1)
  445. #define ElTableColJStr(x) ((x)->el_info.elstr1)
  446. #define ElTableColWStr(x) ((x)->el_info.elstr2)
  447. #define SnbOffset(x) ((x)->offset)
  448. #define BMarginOfSeg(x) _DtCvContainerBMarginOfSeg(x)
  449. #define TMarginOfSeg(x) _DtCvContainerTMarginOfSeg(x)
  450. #define MySaveString(seg_list,my_struct,string,cur_link,multi_len,nl_flag)\
  451. _DtHelpCeSaveString(my_struct->ui_info->client_data, \
  452. seg_list, \
  453. &(my_struct->last_seg), \
  454. &(my_struct->prev_data), \
  455. string, \
  456. my_struct->my_fonts, \
  457. cur_link, \
  458. multi_len, \
  459. my_struct->flags, \
  460. my_struct->ui_info->load_font, \
  461. my_struct->resolve_font, \
  462. nl_flag)
  463. #define SDL_WRAPPER _DtCvAPP_FLAG1
  464. #define SetSdlWrapper(x) _DtCvSetAppFlag1(x)
  465. #define IsSdlWrapper(x) ((x) & SDL_WRAPPER)
  466. #define SetDupFlag(x) \
  467. (FrmtPrivInfoPtr(x)->dup_flag = True)
  468. #define ClearDupFlag(x) \
  469. (FrmtPrivInfoPtr(x)->dup_flag = False)
  470. #define AbbrevOfSeg(x) ((FrmtPrivInfoPtr(x))->abbrev)
  471. #define ContainerPtrToType(x) ((x)->type)
  472. #define ContainerPtrToVJustify(x) ((x)->vjustify)
  473. #define ContainerPtrToJustify(x) ((x)->justify)
  474. #define ClearSegLinks(x) \
  475. (((x)->type) & ~(_DtCvHYPER_TEXT | _DtCvGHOST_LINK))
  476. #define SegMatchData(x) ((FrmtPrivInfoPtr(x))->match_info)
  477. #define SegMatchDataPtr(x) ((SdlMatchData *) SegMatchData(x))
  478. /******************************************************************************
  479. * Private Strings
  480. *****************************************************************************/
  481. static const char AllStr[] = "all";
  482. static const char AnchorStr[] = "<anchor";
  483. static const char AnimateStr[] = "<animate";
  484. static const char ASyncStr[] = "async";
  485. static const char AudioStr[] = "<audio";
  486. static const char BlockStr[] = "<block";
  487. static const char ButtonStr[] = "button";
  488. static const char CallbackStr[] = "<callback";
  489. static const char CenterJustifyStr[]= "center-justify";
  490. static const char CenterOrientStr[] = "center-orient";
  491. static const char CParaStr[] = "<cp";
  492. static const char CrossdocStr[] = "<crossdoc";
  493. static const char DynamicStr[] = "dynamic";
  494. static const char GraphicStr[] = "<graphic";
  495. static const char FormStr[] = "<form";
  496. static const char HeadStr[] = "<head";
  497. static const char IsoStr[] = "ISO-8859-1";
  498. static const char LeftJustifyStr[] = "left-justify";
  499. static const char ManpageStr[] = "<man-page";
  500. static const char NameStr[] = "name";
  501. static const char NegativeOneStr[] = "-1";
  502. static const char NoBorderStr[] = "no-border";
  503. static const char OneStr[] = "1";
  504. static const char ProductStr[] = "product";
  505. static const char ParaStr[] = "<p";
  506. static const char ParentStr[] = "parent";
  507. static const char RightJustifyStr[] = "right-justify";
  508. static const char ScriptStr[] = "<script";
  509. static const char SnrefStr[] = "<snref";
  510. static const char SubHeadStr[] = "<subhead";
  511. static const char SwitchStr[] = "<switch";
  512. static const char SyscmdStr[] = "<sys-cmd";
  513. static const char TenStr[] = "10";
  514. static const char TenThousandStr[] = "10000";
  515. static const char TextStr[] = "<text";
  516. static const char TextfileStr[] = "<textfile";
  517. static const char TopVJustStr[] = "top-vjust";
  518. static const char TopVOrientStr[] = "top-vorient";
  519. static const char UdefKeyStr[] = "udefkey";
  520. static const char VideoStr[] = "<video";
  521. static const char VirpageStr[] = "<virpage";
  522. static const char NoWrapStr[] = "nowrap";
  523. static const char ZeroStr[] = "0";
  524. static const char *NullOption = "null_option";
  525. static const SDLMask AllMaskSet[SDL_MASK_LEN] = SDLSetAllBits;
  526. static FormatStruct DefFormatStruct =
  527. {
  528. False, /* end_flag */
  529. True, /* last_was_space */
  530. False, /* last_was_mb */
  531. False, /* last_was_nl */
  532. False, /* snref_used */
  533. False, /* faked_end */
  534. _DtCvFALSE, /* save_snref */
  535. _DtCvFALSE, /* save_blank */
  536. _SdlFontModeResolve, /* resolve_font*/
  537. SdlElementNone, /* parsed */
  538. NULL, /* remember */
  539. NULL, /* vol_name */
  540. NULL, /* id_string */
  541. -1, /* cur_link */
  542. 1, /* mb_len */
  543. 0, /* flags */
  544. 1, /* malloc_size */
  545. 0, /* alloc_size */
  546. 0, /* free_cnt */
  547. 0, /* free_max */
  548. 0, /* snref_cnt */
  549. NULL, /* *ui_info */
  550. NULL, /* block_list */
  551. NULL, /* add_seg */
  552. NULL, /* last_seg */
  553. NULL, /* seg_list */
  554. NULL, /* prev_data */
  555. NULL, /* toss */
  556. NULL, /* snb */
  557. NULL, /* else_prev */
  558. NULL, /* then_prev */
  559. NULL, /* async_blks */
  560. NULL, /* active_frmt */
  561. NULL, /* my_links */
  562. { /* ElementInfo el_info; */
  563. 0,
  564. 0,
  565. 0,
  566. 0,
  567. SdlElementNone, /* enum SdlElement el_type */
  568. SdlTimingSync, /* SdlOption timing; */
  569. SdlTypeDynamic, /* SdlOption sdl_type */
  570. SdlWindowCurrent, /* SdlOption window; */
  571. SdlInterpKsh, /* SdlOption interp; */
  572. { 0 }, /* SDLNumber count/offset; */
  573. NULL, /* SDLCdata language; */
  574. NULL, /* SDLCdata char_set; */
  575. NULL, /* SDLCdata id; */
  576. NULL, /* SDLCdata elstr1; */
  577. NULL, /* SDLCdata elstr2; */
  578. { /* SDLDocInfo doc_info; */
  579. {
  580. NULL, /* SDLCdata language; */
  581. NULL, /* SDLCdata char_set; */
  582. NULL, /* SDLId first_pg; */
  583. NULL, /* SDLCdata doc-id; */
  584. NULL, /* SDLCdata timestamp; */
  585. NULL, /* SDLCdata sdldtd; */
  586. },
  587. },
  588. { /* SdlMatchData */
  589. SdlClassText, /* SdlOption clan; */
  590. -1, /* SDLNumber level; */
  591. NULL, /* SDLCdata ssi; */
  592. },
  593. },
  594. NULL, /* _DtHelpFontHints my_fonts; */
  595. NULL, /* _DtHelpFontHints free_fonts; */
  596. NULL, /* UnresSnref *un_snregs; */
  597. };
  598. static const _DtHelpFontHints DefFontInfo =
  599. {
  600. "C", /* char *language; */
  601. (char *)IsoStr, /* char *charset */
  602. 10, /* int pointsz; */
  603. 10, /* int set_width */
  604. NULL, /* char *color; */
  605. NULL, /* char *xlfd; */
  606. NULL, /* char *xlfdb; */
  607. NULL, /* char *xlfdi; */
  608. NULL, /* char *xlfdib; */
  609. NULL, /* char *typenam; */
  610. NULL, /* char *typenamb; */
  611. NULL, /* char *typenami; */
  612. NULL, /* char *typenamib; */
  613. _DtHelpFontStyleSanSerif, /* char *style; */
  614. _DtHelpFontSpacingMono, /* char *spacing; */
  615. _DtHelpFontWeightMedium, /* char *weight; */
  616. _DtHelpFontSlantRoman, /* char *slant; */
  617. _DtHelpFontSpecialNone, /* char *special; */
  618. NULL, /* void *expand; */
  619. };
  620. static const _DtCvContainer DefFrmtSpecs =
  621. {
  622. NULL, /* char *id */
  623. NULL, /* char *justify_char */
  624. _DtCvDYNAMIC, /* _DtCvFrmtOption type */
  625. _DtCvBORDER_NONE, /* _DtCvFrmtOption border */
  626. _DtCvINHERIT, /* _DtCvFrmtOption justify */
  627. _DtCvJUSTIFY_TOP, /* _DtCvFrmtOption vjustify */
  628. _DtCvJUSTIFY_CENTER, /* _DtCvFrmtOption orient */
  629. _DtCvJUSTIFY_TOP, /* _DtCvFrmtOption vorient */
  630. _DtCvWRAP_NONE, /* _DtCvFrmtOption flow */
  631. DefPercent, /* int percent */
  632. 0, /* _DtCvUnit leading */
  633. 0, /* _DtCvUnit fmargin */
  634. 0, /* _DtCvUnit lmargin */
  635. 0, /* _DtCvUnit rmargin */
  636. 0, /* _DtCvUnit tmargin */
  637. 0, /* _DtCvUnit bmargin */
  638. {0, NULL}, /* _DtCvLine bdr_info; */
  639. NULL, /* _DtCvSegment *seg_list */
  640. };
  641. static const _FrmtUiInfo DefUiInfo =
  642. {
  643. NULL, /* load_graphic */
  644. NULL, /* resolve_spc */
  645. NULL, /* load_font */
  646. NULL, /* exec_filter */
  647. NULL, /* destroy_region */
  648. NULL, /* client_data */
  649. 0, /* line_width */
  650. 0, /* line_height */
  651. 0, /* leading */
  652. 0, /* avg_char */
  653. True, /* nl_to_space */
  654. };
  655. /******************************************************************************
  656. * Entity Defines
  657. *****************************************************************************/
  658. /*-----------------------------------------------------------------------------
  659. <!ENTITY % system-notations "(graphic | text | audio | video |
  660. animate | crossdoc | man-page | textfile |
  661. sys-cmd | callback | script | switch)" >
  662. -----------------------------------------------------------------------------*/
  663. #define SDL_ENTITY_SYSTEM_NOTATIONS \
  664. SDLInitMaskTwelve(SdlElementGraphic, \
  665. SdlElementText, \
  666. SdlElementAudio, \
  667. SdlElementVideo, \
  668. SdlElementAnimate, \
  669. SdlElementCrossDoc, \
  670. SdlElementManPage, \
  671. SdlElementTextFile, \
  672. SdlElementSysCmd, \
  673. SdlElementCallback, \
  674. SdlElementScript, \
  675. SdlElementSwitch)
  676. /*-----------------------------------------------------------------------------
  677. <!ENTITY % generated-elements "(loids, toss?, lophrases?, index?, rel-docs?,
  678. rel-file?, notes?)" >
  679. -----------------------------------------------------------------------------*/
  680. #define SDL_ENTITY_GENERATED_ELEMENTS \
  681. { SDLInitMask(SdlElementLoids) , OnlyOne }, \
  682. { SDLInitMask(SdlElementToss) , ZeroOrOne }, \
  683. { SDLInitMask(SdlElementLoPhrases), ZeroOrOne }, \
  684. { SDLInitMask(SdlElementIndex) , ZeroOrOne }, \
  685. { SDLInitMask(SdlElementRelDocs) , ZeroOrOne }, \
  686. { SDLInitMask(SdlElementRelFile) , ZeroOrOne }, \
  687. { SDLInitMask(SdlElementNotes) , ZeroOrOne },
  688. /*-----------------------------------------------------------------------------
  689. <!ENTITY % key-class "acro | book | emph | jargon |
  690. l10n | name | quote | product |
  691. termdef | term | mach-in | mach-out |
  692. mach-cont | pub-lit | udefkey" >
  693. -----------------------------------------------------------------------------*/
  694. #define SDL_ENTITY_CLASSK \
  695. { "acro" , SdlClassAcro }, \
  696. { "book" , SdlClassBook }, \
  697. { "emph" , SdlClassEmph }, \
  698. { "jargon" , SdlClassJargon }, \
  699. { "l10n" , SdlClassL10n }, \
  700. { NameStr , SdlClassName }, \
  701. { "quote" , SdlClassQuote }, \
  702. { ProductStr , SdlClassProduct }, \
  703. { "termdef" , SdlClassTermdef }, \
  704. { "term" , SdlClassTerm }, \
  705. { "mach-in" , SdlClassMachIn }, \
  706. { "mach-out" , SdlClassMachOut }, \
  707. { "mach-cont", SdlClassMachCont }, \
  708. { "pub-lit" , SdlClassPubLit }, \
  709. { UdefKeyStr , SdlClassUdefkey }
  710. /*-----------------------------------------------------------------------------
  711. <!ENTITY % head-class "label | head | caption | annotation |
  712. phead | udefhead" >
  713. -----------------------------------------------------------------------------*/
  714. #define SDL_ENTITY_CLASSH \
  715. { "label" , SdlClassLabel }, \
  716. { (HeadStr+1) , SdlClassHead }, \
  717. { "caption" , SdlClassCaption }, \
  718. { "annotation", SdlClassAnnotation }, \
  719. { "phead" , SdlClassPHead }, \
  720. { "udefhead" , SdlClassUdefhead }
  721. /*-----------------------------------------------------------------------------
  722. <!ENTITY % format-class "table | cell | list | item |
  723. text | udeffrmt" >
  724. -----------------------------------------------------------------------------*/
  725. #define SDL_ENTITY_CLASSF \
  726. { "table" , SdlClassTable }, \
  727. { "cell" , SdlClassCell }, \
  728. { "list" , SdlClassList }, \
  729. { "item" , SdlClassItem }, \
  730. { (TextStr+1), SdlClassText }, \
  731. { "udeffrmt" , SdlClassUdeffrmt }
  732. /*-----------------------------------------------------------------------------
  733. <!ENTITY % graphic-class "figure | in-line | button | icon |
  734. udefgrph" >
  735. -----------------------------------------------------------------------------*/
  736. #define SDL_ENTITY_CLASSG \
  737. { "figure" , SdlClassFigure }, \
  738. { "in-line" , SdlClassInLine }, \
  739. { ButtonStr , SdlClassButton }, \
  740. { "icon" , SdlClassIcon }, \
  741. { "udefgraph" , SdlClassUdefgraph }
  742. /*-----------------------------------------------------------------------------
  743. <!ENTITY % phrase-class "( super | sub )" >
  744. -----------------------------------------------------------------------------*/
  745. #define SDL_ENTITY_CLASSP \
  746. { "super" , SdlClassSuper }, \
  747. { "sub" , SdlClassSub }
  748. /*-----------------------------------------------------------------------------
  749. <!ENTITY % font-styles
  750. '-- height of font in points; main body is 10 point --
  751. pointsz NUMBER #IMPLIED
  752. -- width of font in points; defaults to point size --
  753. -- similar to point size but refers to relative --
  754. -- width rather than height (e.g., an 8 point font --
  755. -- based on a square would be 8 pt, 8 set) --
  756. set-width NUMBER #IMPLIED
  757. -- one of 42 CDE colors or "RGB:rrrr/gggg/bbbb" --
  758. color CDATA #IMPLIED
  759. -- XLFD typeface name for use on X Window System --
  760. -- e.g., "-adobe-helvetica-bold-i-narrow-*-" --
  761. -- One each of normal, italic, bold and bold --
  762. -- italic must be specified. --
  763. -- These should only be specified if the author is --
  764. -- sure of exactly what font is desired. In the --
  765. -- usual case, only the logical typeface spec. --
  766. -- defined below will be given. --
  767. xlfd CDATA #IMPLIED
  768. xlfdi CDATA #IMPLIED
  769. xlfdb CDATA #IMPLIED
  770. xlfdib CDATA #IMPLIED
  771. -- MS-Windows typeface name (maximum of 32 chars) --
  772. -- One each of normal, italic, bold and bold --
  773. -- italic must be specified. --
  774. -- As for the XLFD specification above, these --
  775. -- should only be provided if an author knows the --
  776. -- exact font desired. --
  777. typenam CDATA #IMPLIED
  778. typenami CDATA #IMPLIED
  779. typenamb CDATA #IMPLIED
  780. typenamib CDATA #IMPLIED
  781. -- Logical typeface spec (allows mapping into one --
  782. -- of the 13 PostScript typefaces). This spec. is --
  783. -- used if an exact match XLFD or Windows type- --
  784. -- face name attribute is missing or cannot be --
  785. -- found. In the usual case, these will be --
  786. -- specified in preference to specifying an exact --
  787. -- font. --
  788. -- processor should default style to "sans-serif" --
  789. style ( serif |
  790. sans-serif |
  791. symbol ) #IMPLIED
  792. -- processor should deflt spacing to "monospace" --
  793. spacing ( monospace |
  794. propspace ) #IMPLIED
  795. -- processor should default weight to "medium" --
  796. weight ( medium |
  797. bold ) #IMPLIED
  798. -- processor should default slant to "roman" --
  799. slant ( roman |
  800. italic |
  801. rev-italic ) #IMPLIED
  802. -- processor should default special to "none" --
  803. special ( underline |
  804. strikeout |
  805. none ) #IMPLIED' >
  806. -----------------------------------------------------------------------------*/
  807. #define font_stylesAttrList \
  808. { SDL_ATTR_POINTSZ , SdlAttrValueImplied , TenStr }, \
  809. { SDL_ATTR_SETWIDTH , SdlAttrValueImplied , TenStr }, \
  810. { SDL_ATTR_COLOR , SdlAttrValueImpliedDef , NULL }, \
  811. { SDL_ATTR_XLFD , SdlAttrValueImpliedDef , NULL }, \
  812. { SDL_ATTR_XLFDI , SdlAttrValueImpliedDef , NULL }, \
  813. { SDL_ATTR_XLFDB , SdlAttrValueImpliedDef , NULL }, \
  814. { SDL_ATTR_XLFDIB , SdlAttrValueImpliedDef , NULL }, \
  815. { SDL_ATTR_TYPENAM , SdlAttrValueImpliedDef , NULL }, \
  816. { SDL_ATTR_TYPENAMI , SdlAttrValueImpliedDef , NULL }, \
  817. { SDL_ATTR_TYPENAMB , SdlAttrValueImpliedDef , NULL }, \
  818. { SDL_ATTR_TYPENAMIB, SdlAttrValueImpliedDef , NULL }, \
  819. { SDL_ATTR_STYLE , SdlAttrValueImplied , "sans-serif" }, \
  820. { SDL_ATTR_SPACING , SdlAttrValueImplied , "monospace" }, \
  821. { SDL_ATTR_WEIGHT , SdlAttrValueImplied , "medium" }, \
  822. { SDL_ATTR_SLANT , SdlAttrValueImplied , "roman" }, \
  823. { SDL_ATTR_SPECIAL , SdlAttrValueImplied , "none" }
  824. /*-----------------------------------------------------------------------------
  825. <!ENTITY % format-styles
  826. '-- left and right margins are additive and measured --
  827. -- in character widths defaulting to "0" --
  828. l-margin NUMBER #IMPLIED
  829. r-margin NUMBER #IMPLIED
  830. -- top and bottom margins merely take the maximum and --
  831. -- are measured in lines defaulting to "0" --
  832. t-margin NUMBER #IMPLIED
  833. b-margin NUMBER #IMPLIED
  834. -- border specifies the decoration type --
  835. -- processor should default border to "no-border" --
  836. border ( no-border |
  837. full-border |
  838. horizontal-border |
  839. vertical-border |
  840. top-border |
  841. bottom-border |
  842. left-border |
  843. right-border ) #IMPLIED
  844. -- applies to the text in the element, not the element --
  845. -- itself. --
  846. -- processor should default vjust to "top-vjust" --
  847. vjust ( top-vjust |
  848. bottom-vjust |
  849. center-vjust ) #IMPLIED' >
  850. -----------------------------------------------------------------------------*/
  851. #define formt_stylesAttrList \
  852. { SDL_ATTR_LMARGIN , SdlAttrValueImplied , ZeroStr }, \
  853. { SDL_ATTR_RMARGIN , SdlAttrValueImplied , ZeroStr }, \
  854. { SDL_ATTR_TMARGIN , SdlAttrValueImplied , ZeroStr }, \
  855. { SDL_ATTR_BMARGIN , SdlAttrValueImplied , ZeroStr }, \
  856. { SDL_ATTR_BORDER , SdlAttrValueImplied , NoBorderStr }, \
  857. { SDL_ATTR_VJUST , SdlAttrValueImplied , TopVJustStr }
  858. /*-----------------------------------------------------------------------------
  859. <!ENTITY % linkage "anchor | link" >
  860. <!ENTITY % reference "snref" >
  861. <!ENTITY % simple "key | sphrase | rev | if | spc | %reference;" >
  862. -----------------------------------------------------------------------------*/
  863. #define SDL_ENTITY_SIMPLE \
  864. SDLInitMaskSeven( \
  865. SdlElementKey , SdlElementSphrase, SdlElementRev , \
  866. SdlElementIf , SdlElementSpc , SdlElementSnRef, \
  867. SdlElementCdata)
  868. /*-----------------------------------------------------------------------------
  869. <!ENTITY % atomic "( %simple; | %linkage; )" >
  870. -----------------------------------------------------------------------------*/
  871. #define SDL_ENTITY_ATOMIC \
  872. SDLInitMaskNine( \
  873. SdlElementKey , SdlElementSphrase, SdlElementRev , \
  874. SdlElementIf , SdlElementSpc , SdlElementSnRef , \
  875. SdlElementAnchor, SdlElementLink , SdlElementCdata)
  876. /*-----------------------------------------------------------------------------
  877. <!NOTATION tcl SYSTEM "embedded tcl interpreter">
  878. <!NOTATION sh SYSTEM "/bin/sh">
  879. <!NOTATION csh SYSTEM "/bin/csh">
  880. <!NOTATION ksh SYSTEM "/bin/ksh">
  881. -----------------------------------------------------------------------------*/
  882. typedef struct _ceInterpData {
  883. SdlOption type;
  884. char *cmd;
  885. } _CEInterpData;
  886. static _CEInterpData InterpData[] =
  887. {
  888. { SdlInterpKsh, "ksh" },
  889. { SdlInterpCsh, "csh" },
  890. { SdlInterpSh , "sh" },
  891. { SdlInterpTcl, "tcl" },
  892. { _DtCvOPTION_BAD, NULL },
  893. };
  894. /******************************************************************************
  895. * Private Variables
  896. *****************************************************************************/
  897. static OptionList hclass[] = { SDL_ENTITY_CLASSH, {NULL, _DtCvOPTION_BAD}};
  898. static OptionList fclass[] = { SDL_ENTITY_CLASSF, {NULL, _DtCvOPTION_BAD}};
  899. static OptionList kclass[] = { SDL_ENTITY_CLASSK, {NULL, _DtCvOPTION_BAD}};
  900. static OptionList pclass[] = { SDL_ENTITY_CLASSP, {NULL, _DtCvOPTION_BAD}};
  901. static OptionList gclass[] = { SDL_ENTITY_CLASSG, {NULL, _DtCvOPTION_BAD}};
  902. static OptionList fgclass[] =
  903. { SDL_ENTITY_CLASSF, SDL_ENTITY_CLASSG, {NULL, _DtCvOPTION_BAD}};
  904. static OptionList apps[] =
  905. {
  906. { AllStr , SdlAppAll },
  907. { "help" , SdlAppHelp },
  908. { "tutorial", SdlAppTutorial },
  909. { "ref" , SdlAppRef },
  910. { "sys" , SdlAppSys },
  911. { NULL , _DtCvOPTION_BAD }
  912. };
  913. static OptionList timing[] =
  914. {
  915. { (ASyncStr+1), SdlTimingSync },
  916. { ASyncStr , SdlTimingAsync },
  917. { NULL , _DtCvOPTION_BAD },
  918. };
  919. static OptionList frmtTypes[] =
  920. {
  921. { "literal" , SdlTypeLiteral },
  922. { "lined" , SdlTypeLined },
  923. { DynamicStr, SdlTypeDynamic },
  924. { NULL , _DtCvOPTION_BAD }
  925. };
  926. static OptionList idTypes[] =
  927. {
  928. { (VirpageStr+1) , SdlIdVirpage },
  929. { (BlockStr+1) , SdlIdBlock },
  930. { (FormStr+1) , SdlIdForm },
  931. { (ParaStr+1) , SdlIdPara },
  932. { (CParaStr+1) , SdlIdCPara },
  933. { (HeadStr+1) , SdlIdHead },
  934. { (SubHeadStr+1) , SdlIdSubHead },
  935. { (AnchorStr+1) , SdlIdAnchor },
  936. { (SwitchStr+1) , SdlIdSwitch },
  937. { (SnrefStr+1) , SdlIdSnRef },
  938. { (GraphicStr+1) , SdlIdGraphic },
  939. { (TextStr+1) , SdlIdText },
  940. { (AudioStr+1) , SdlIdAudio },
  941. { (VideoStr+1) , SdlIdVideo },
  942. { (AnimateStr+1) , SdlIdAnimate },
  943. { (CrossdocStr+1), SdlIdCrossDoc },
  944. { (ManpageStr+1) , SdlIdManPage },
  945. { (TextfileStr+1), SdlIdTextFile },
  946. { (SyscmdStr+1) , SdlIdSysCmd },
  947. { (ScriptStr+1) , SdlIdScript },
  948. { (CallbackStr+1), SdlIdCallback },
  949. { NULL , _DtCvOPTION_BAD },
  950. };
  951. static OptionList bool_types[] =
  952. {
  953. { "YES", SdlBoolYes },
  954. { "NO" , SdlBoolNo },
  955. { NULL , _DtCvOPTION_BAD },
  956. };
  957. static OptionList borders[] =
  958. {
  959. { NoBorderStr , _DtCvBORDER_NONE },
  960. { "full-border" , _DtCvBORDER_FULL },
  961. { "horizontal-border", _DtCvBORDER_HORZ },
  962. { "vertical-border" , _DtCvBORDER_VERT },
  963. { "top-border" , _DtCvBORDER_TOP },
  964. { "bottom-border" , _DtCvBORDER_BOTTOM },
  965. { "left-border" , _DtCvBORDER_LEFT },
  966. { "right-border" , _DtCvBORDER_RIGHT },
  967. { NULL , _DtCvOPTION_BAD },
  968. };
  969. static OptionList justify1[] =
  970. {
  971. { LeftJustifyStr , _DtCvJUSTIFY_LEFT },
  972. { RightJustifyStr , _DtCvJUSTIFY_RIGHT },
  973. { CenterJustifyStr , _DtCvJUSTIFY_CENTER },
  974. { "numeric-justify", _DtCvJUSTIFY_NUM },
  975. { NULL , _DtCvOPTION_BAD },
  976. };
  977. static OptionList justify2[] =
  978. {
  979. { LeftJustifyStr , _DtCvJUSTIFY_LEFT },
  980. { RightJustifyStr , _DtCvJUSTIFY_RIGHT },
  981. { CenterJustifyStr , _DtCvJUSTIFY_CENTER },
  982. { NULL , _DtCvOPTION_BAD },
  983. };
  984. static OptionList vjust[] =
  985. {
  986. { TopVJustStr , _DtCvJUSTIFY_TOP },
  987. { "bottom-vjust", _DtCvJUSTIFY_BOTTOM },
  988. { "center-vjust", _DtCvJUSTIFY_CENTER },
  989. { NULL , _DtCvOPTION_BAD },
  990. };
  991. static OptionList orient[] =
  992. {
  993. { "left-orient" , _DtCvJUSTIFY_LEFT },
  994. { CenterOrientStr , _DtCvJUSTIFY_CENTER },
  995. { "right-orient" , _DtCvJUSTIFY_RIGHT },
  996. { "left-margin-orient" , _DtCvJUSTIFY_LEFT_MARGIN },
  997. { "right-margin-orient", _DtCvJUSTIFY_RIGHT_MARGIN},
  998. { "left-corner-orient" , _DtCvJUSTIFY_LEFT_CORNER },
  999. { "right-corner-orient", _DtCvJUSTIFY_RIGHT_CORNER},
  1000. { NULL , _DtCvOPTION_BAD },
  1001. };
  1002. static OptionList vorient[] =
  1003. {
  1004. { TopVOrientStr , _DtCvJUSTIFY_TOP },
  1005. { "bottom-vorient", _DtCvJUSTIFY_BOTTOM },
  1006. { "center-vorient", _DtCvJUSTIFY_CENTER },
  1007. { NULL , _DtCvOPTION_BAD },
  1008. };
  1009. static OptionList placement[] =
  1010. {
  1011. { "object" , SdlPlaceObject },
  1012. { ParentStr , SdlPlaceParent },
  1013. { NULL , _DtCvOPTION_BAD },
  1014. };
  1015. static OptionList stacking[] =
  1016. {
  1017. { "horiz" , SdlStackHoriz },
  1018. { "vert" , SdlStackVert },
  1019. { NULL , _DtCvOPTION_BAD },
  1020. };
  1021. static OptionList flow[] =
  1022. {
  1023. { (NoWrapStr+2), _DtCvWRAP },
  1024. { NoWrapStr , _DtCvWRAP_NONE },
  1025. { "join" , _DtCvWRAP_JOIN },
  1026. { NULL , _DtCvOPTION_BAD },
  1027. };
  1028. static OptionList window[] =
  1029. {
  1030. { "current", SdlWindowCurrent },
  1031. { "new" , SdlWindowNew },
  1032. { "popup" , SdlWindowPopup },
  1033. { NULL , _DtCvOPTION_BAD },
  1034. };
  1035. static OptionList traversal[] =
  1036. {
  1037. { "return" , SdlTraversalReturn },
  1038. { "noreturn", SdlTraversalNoReturn },
  1039. { NULL , _DtCvOPTION_BAD },
  1040. };
  1041. static OptionList interpreters[] =
  1042. {
  1043. { "ksh" , SdlInterpKsh },
  1044. { "tcl" , SdlInterpTcl },
  1045. { "csh" , SdlInterpCsh },
  1046. { "sh" , SdlInterpSh },
  1047. { NULL , _DtCvOPTION_BAD },
  1048. };
  1049. static SDLAttributeOptions SDLOptionsList[] =
  1050. {
  1051. {SDL_ATTR_CLASSH , hclass },
  1052. {SDL_ATTR_CLASSF , fclass },
  1053. {SDL_ATTR_CLASSK , kclass },
  1054. {SDL_ATTR_CLASSFG , fgclass },
  1055. {SDL_ATTR_CLASSP , pclass },
  1056. {SDL_ATTR_CLASSG , gclass },
  1057. {SDL_ATTR_HDR , bool_types },
  1058. {SDL_ATTR_APP , apps },
  1059. {SDL_ATTR_TIMING , timing },
  1060. {SDL_ATTR_TYPEFRMT , frmtTypes },
  1061. {SDL_ATTR_BORDER , borders },
  1062. {SDL_ATTR_JUSTIFY1 , justify1 },
  1063. {SDL_ATTR_JUSTIFY2 , justify2 },
  1064. {SDL_ATTR_VJUST , vjust },
  1065. {SDL_ATTR_ORIENT , orient },
  1066. {SDL_ATTR_VORIENT , vorient },
  1067. {SDL_ATTR_PLACEMENT, placement },
  1068. {SDL_ATTR_STACK , stacking },
  1069. {SDL_ATTR_FLOW , flow },
  1070. {SDL_ATTR_WINDOW , window },
  1071. {SDL_ATTR_TRAVERSAL, traversal },
  1072. {SDL_ATTR_TYPEID , idTypes },
  1073. {SDL_ATTR_INTERP , interpreters },
  1074. {(unsigned long) -1, NULL }
  1075. };
  1076. static FontSpecOption styles[] =
  1077. {
  1078. { "serif" , _DtHelpFontStyleSerif },
  1079. { "sans-serif", _DtHelpFontStyleSanSerif },
  1080. { "symbol" , _DtHelpFontStyleSymbol },
  1081. { NULL , _DtHelpFontValueBad },
  1082. };
  1083. static FontSpecOption spacing[] =
  1084. {
  1085. { "monospace" , _DtHelpFontSpacingMono},
  1086. { "propspace" , _DtHelpFontSpacingProp},
  1087. { NULL , _DtHelpFontValueBad },
  1088. };
  1089. static FontSpecOption weights[] =
  1090. {
  1091. { "medium" , _DtHelpFontWeightMedium },
  1092. { "bold" , _DtHelpFontWeightBold },
  1093. { NULL , _DtHelpFontValueBad },
  1094. };
  1095. static FontSpecOption slants[] =
  1096. {
  1097. { "roman" , _DtHelpFontSlantRoman },
  1098. { "italic" , _DtHelpFontSlantItalic },
  1099. { "rev-italic", _DtHelpFontSlantRevItalic},
  1100. { NULL , _DtHelpFontValueBad },
  1101. };
  1102. static FontSpecOption special[] =
  1103. {
  1104. { "none" , _DtHelpFontSpecialNone },
  1105. { "underline" , _DtHelpFontSpecialUnderLine },
  1106. { "strikeout" , _DtHelpFontSpecialStrikeOut },
  1107. { NULL , _DtHelpFontValueBad },
  1108. };
  1109. static SDLFontSpecList SDLFontList[] =
  1110. {
  1111. {SDL_ATTR_STYLE , styles },
  1112. {SDL_ATTR_SPACING , spacing },
  1113. {SDL_ATTR_WEIGHT , weights },
  1114. {SDL_ATTR_SLANT , slants },
  1115. {SDL_ATTR_SPECIAL , special },
  1116. {(unsigned long) -1, NULL }
  1117. };
  1118. /*
  1119. * Make sure the attribute names are in lower case.
  1120. * The read routine to find an attribute automatically changes it to lower
  1121. * case.
  1122. */
  1123. #ifndef _DtCvContainerPtr
  1124. typedef _DtCvContainer * _DtCvContainerPtr;
  1125. #endif
  1126. #ifndef _DtCvSegmentPtr
  1127. typedef _DtCvSegment * _DtCvSegmentPtr;
  1128. #endif
  1129. static SDLAttribute SDLAttributeList[] =
  1130. {
  1131. { "abbrev" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1132. SDL_ATTR_ABBREV ,
  1133. SDLAttrOffset(ElementInfoPtr,elstr1) },
  1134. { "app" , SdlAttrDataTypeEnum , SdlIgnore ,
  1135. SDL_ATTR_APP ,
  1136. 0 },
  1137. { "author" , SdlAttrDataTypeCdata , SdlIgnore ,
  1138. SDL_ATTR_AUTHOR ,
  1139. 0 },
  1140. { "b-margin" , SdlAttrDataTypeNumber, SdlContainerSpecific ,
  1141. SDL_ATTR_BMARGIN,
  1142. SDLAttrOffset(_DtCvContainerPtr,bmargin) },
  1143. { "border" , SdlAttrDataTypeEnum , SdlContainerSpecific ,
  1144. SDL_ATTR_BORDER,
  1145. SDLAttrOffset(_DtCvContainerPtr,border) },
  1146. { "branches" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1147. SDL_ATTR_BRANCHES ,
  1148. SDLAttrOffset(ElementInfoPtr,elstr1) },
  1149. { ButtonStr , SdlAttrDataTypeId , SdlIgnore ,
  1150. SDL_ATTR_BUTTON,
  1151. 0 },
  1152. { "cells" , SdlAttrDataTypeId , SdlElementSpecific,
  1153. SDL_ATTR_CELLS,
  1154. SDLAttrOffset(ElementInfoPtr,elstr1) },
  1155. { "charset" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1156. SDL_ATTR_CHARSET,
  1157. SDLAttrOffset(ElementInfoPtr,char_set) },
  1158. { "class" , SdlAttrDataTypeEnum , SdlElementSpecific,
  1159. SDL_ATTR_CLASS ,
  1160. SDLAttrOffset(ElementInfoPtr,match.clan) },
  1161. { "colj" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1162. SDL_ATTR_COLJ ,
  1163. SDLAttrOffset(ElementInfoPtr,elstr1) },
  1164. { "color" , SdlAttrDataTypeCdata , SdlFontSpecific,
  1165. SDL_ATTR_COLOR ,
  1166. SDLAttrOffset(_DtHelpFontHintPtr,color) },
  1167. { "colw" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1168. SDL_ATTR_COLW ,
  1169. SDLAttrOffset(ElementInfoPtr,elstr2) },
  1170. { "command" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1171. SDL_ATTR_COMMAND ,
  1172. SDLAttrOffset(ElementInfoPtr,w.snb_info.xid) },
  1173. { "count" , SdlAttrDataTypeNumber, SdlElementSpecific,
  1174. SDL_ATTR_COUNT ,
  1175. SDLAttrOffset(ElementInfoPtr,nums.count) },
  1176. { "data" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1177. SDL_ATTR_DATA ,
  1178. SDLAttrOffset(ElementInfoPtr,w.snb_info.xid) },
  1179. { "descript" , SdlAttrDataTypeCdata , SdlIgnore ,
  1180. SDL_ATTR_DESCRIPT,
  1181. 0 },
  1182. { "doc-id" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1183. SDL_ATTR_DOCID ,
  1184. SDLAttrOffset(ElementInfoPtr,w.doc_info.doc_id) },
  1185. { "enter" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1186. SDL_ATTR_ENTER ,
  1187. SDLAttrOffset(ElementInfoPtr,elstr1) },
  1188. { "exit" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1189. SDL_ATTR_EXIT ,
  1190. SDLAttrOffset(ElementInfoPtr,elstr2) },
  1191. { "first-page" , SdlAttrDataTypeId , SdlElementSpecific,
  1192. SDL_ATTR_FRST_PG,
  1193. SDLAttrOffset(ElementInfoPtr,w.doc_info.first_pg) },
  1194. { "flow" , SdlAttrDataTypeEnum , SdlContainerSpecific ,
  1195. SDL_ATTR_FLOW ,
  1196. SDLAttrOffset(_DtCvContainerPtr,flow) },
  1197. { "f-margin" , SdlAttrDataTypeNumber, SdlContainerSpecific ,
  1198. SDL_ATTR_FMARGIN,
  1199. SDLAttrOffset(_DtCvContainerPtr,fmargin) },
  1200. { "format" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1201. SDL_ATTR_FORMAT ,
  1202. SDLAttrOffset(ElementInfoPtr,w.snb_info.format) },
  1203. { "hdr" , SdlAttrDataTypeEnum , SdlIgnore ,
  1204. SDL_ATTR_HDR ,
  1205. 0 },
  1206. { "headw" , SdlAttrDataTypeNumber , SdlContainerSpecific ,
  1207. SDL_ATTR_HEADWDTH,
  1208. SDLAttrOffset(_DtCvContainerPtr,percent) },
  1209. { "id" , SdlAttrDataTypeId , SdlElementSpecific,
  1210. SDL_ATTR_ID ,
  1211. SDLAttrOffset(ElementInfoPtr,id) },
  1212. { "interp" , SdlAttrDataTypeEnum , SdlElementSpecific,
  1213. SDL_ATTR_INTERP ,
  1214. SDLAttrOffset(ElementInfoPtr,interp) },
  1215. { "justify" , SdlAttrDataTypeEnum , SdlContainerSpecific ,
  1216. SDL_ATTR_JUSTIFY,
  1217. SDLAttrOffset(_DtCvContainerPtr,justify) },
  1218. { "l-margin" , SdlAttrDataTypeNumber, SdlContainerSpecific ,
  1219. SDL_ATTR_LMARGIN,
  1220. SDLAttrOffset(_DtCvContainerPtr,lmargin) },
  1221. { "language" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1222. SDL_ATTR_LANGUAGE ,
  1223. SDLAttrOffset(ElementInfoPtr,language) },
  1224. { "length" , SdlAttrDataTypeNumber, SdlIgnore ,
  1225. SDL_ATTR_LENGTH ,
  1226. 0 },
  1227. { "level" , SdlAttrDataTypeNumber, SdlElementSpecific,
  1228. SDL_ATTR_LEVEL ,
  1229. SDLAttrOffset(ElementInfoPtr,match.level) },
  1230. { "license" , SdlAttrDataTypeCdata , SdlIgnore ,
  1231. SDL_ATTR_LICENSE ,
  1232. 0 },
  1233. { "linkinfo" , SdlAttrDataTypeCdata , SdlIgnore ,
  1234. SDL_ATTR_LINKINFO,
  1235. 0 },
  1236. { "locs" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1237. SDL_ATTR_LOCS ,
  1238. SDLAttrOffset(ElementInfoPtr,w.entry_info.locs) },
  1239. { "main" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1240. SDL_ATTR_MAIN ,
  1241. SDLAttrOffset(ElementInfoPtr,w.entry_info.main) },
  1242. { "method" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1243. SDL_ATTR_METHOD ,
  1244. SDLAttrOffset(ElementInfoPtr,w.snb_info.method) },
  1245. { NameStr , SdlAttrDataTypeCdata , SdlElementSpecific,
  1246. SDL_ATTR_NAME ,
  1247. SDLAttrOffset(ElementInfoPtr,elstr1) },
  1248. { "ncols" , SdlAttrDataTypeNumber, SdlTableSpecific,
  1249. SDL_ATTR_NCOLS ,
  1250. SDLAttrOffset(_DtCvSegmentPtr, handle.table.num_cols) },
  1251. { "offset" , SdlAttrDataTypeNumber, SdlElementSpecific,
  1252. SDL_ATTR_OFFSET ,
  1253. SDLAttrOffset(ElementInfoPtr,nums.offset) },
  1254. {(TopVOrientStr+5), SdlAttrDataTypeEnum , SdlContainerSpecific ,
  1255. SDL_ATTR_ORIENT ,
  1256. SDLAttrOffset(_DtCvContainerPtr,orient) },
  1257. { "placement" , SdlAttrDataTypeEnum , SdlIgnore ,
  1258. SDL_ATTR_PLACEMENT,
  1259. 0 },
  1260. { "phrase" , SdlAttrDataTypeCdata , SdlIgnore ,
  1261. SDL_ATTR_PHRASE ,
  1262. 0 },
  1263. { "pointsz" , SdlAttrDataTypeNumber, SdlFontSpecific,
  1264. SDL_ATTR_POINTSZ ,
  1265. SDLAttrOffset(_DtHelpFontHintPtr,pointsz) },
  1266. { "pub-id" , SdlAttrDataTypeCdata , SdlIgnore ,
  1267. SDL_ATTR_PUBID ,
  1268. 0 },
  1269. { "prodpn" , SdlAttrDataTypeCdata , SdlIgnore ,
  1270. SDL_ATTR_PRODPN ,
  1271. 0 },
  1272. { ProductStr , SdlAttrDataTypeCdata , SdlIgnore ,
  1273. SDL_ATTR_PRODUCT,
  1274. 0 },
  1275. { "prodver" , SdlAttrDataTypeCdata , SdlIgnore ,
  1276. SDL_ATTR_PRODVER,
  1277. 0 },
  1278. { "r-margin" , SdlAttrDataTypeNumber, SdlContainerSpecific ,
  1279. SDL_ATTR_RMARGIN,
  1280. SDLAttrOffset(_DtCvContainerPtr,rmargin) },
  1281. { "rid" , SdlAttrDataTypeId , SdlElementSpecific ,
  1282. SDL_ATTR_RID ,
  1283. SDLAttrOffset(ElementInfoPtr,id) },
  1284. { "rlevel" , SdlAttrDataTypeNumber, SdlElementSpecific,
  1285. SDL_ATTR_RLEVEL ,
  1286. SDLAttrOffset(ElementInfoPtr,match.level) },
  1287. { "rssi" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1288. SDL_ATTR_RSSI ,
  1289. SDLAttrOffset(ElementInfoPtr,match.ssi) },
  1290. { "sdldtd" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1291. SDL_ATTR_SDLDTD ,
  1292. SDLAttrOffset(ElementInfoPtr,w.doc_info.sdldtd) },
  1293. { "set-width" , SdlAttrDataTypeNumber, SdlFontSpecific,
  1294. SDL_ATTR_SETWIDTH,
  1295. SDLAttrOffset(_DtHelpFontHintPtr,set_width)},
  1296. { "slant" , SdlAttrDataTypeFont , SdlFontSpecific ,
  1297. SDL_ATTR_SLANT,
  1298. SDLAttrOffset(_DtHelpFontHintPtr,slant) },
  1299. { "sort" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1300. SDL_ATTR_SORT ,
  1301. SDLAttrOffset(ElementInfoPtr,w.entry_info.sort) },
  1302. { "spacing" , SdlAttrDataTypeFont , SdlFontSpecific ,
  1303. SDL_ATTR_SPACING,
  1304. SDLAttrOffset(_DtHelpFontHintPtr,spacing) },
  1305. { "special" , SdlAttrDataTypeFont , SdlFontSpecific ,
  1306. SDL_ATTR_SPECIAL,
  1307. SDLAttrOffset(_DtHelpFontHintPtr,special) },
  1308. { "srcdtd" , SdlAttrDataTypeCdata , SdlIgnore ,
  1309. SDL_ATTR_SRCDTD ,
  1310. 0 },
  1311. { "srch-wt" , SdlAttrDataTypeNumber, SdlIgnore ,
  1312. SDL_ATTR_SRCHWT ,
  1313. 0 },
  1314. { "ssi" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1315. SDL_ATTR_SSI ,
  1316. SDLAttrOffset(ElementInfoPtr,match.ssi) },
  1317. { "stack" , SdlAttrDataTypeEnum , SdlIgnore ,
  1318. SDL_ATTR_STACK,
  1319. 0 },
  1320. { "style" , SdlAttrDataTypeFont , SdlFontSpecific ,
  1321. SDL_ATTR_STYLE,
  1322. SDLAttrOffset(_DtHelpFontHintPtr,style) },
  1323. { "syns" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1324. SDL_ATTR_SYNS ,
  1325. SDLAttrOffset(ElementInfoPtr,w.entry_info.syns) },
  1326. { "t-margin" , SdlAttrDataTypeNumber, SdlContainerSpecific ,
  1327. SDL_ATTR_TMARGIN,
  1328. SDLAttrOffset(_DtCvContainerPtr,tmargin) },
  1329. { (TextStr+1) , SdlAttrDataTypeCdata , SdlIgnore,
  1330. SDL_ATTR_TEXT ,
  1331. 0 },
  1332. { "timestmp" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1333. SDL_ATTR_TIMESTAMP,
  1334. SDLAttrOffset(ElementInfoPtr,w.doc_info.timestamp) },
  1335. { "timing" , SdlAttrDataTypeEnum , SdlElementSpecific,
  1336. SDL_ATTR_TIMING ,
  1337. SDLAttrOffset(ElementInfoPtr,timing) },
  1338. { "type" , SdlAttrDataTypeEnum , SdlElementSpecific,
  1339. SDL_ATTR_TYPE ,
  1340. SDLAttrOffset(ElementInfoPtr,sdl_type) },
  1341. { "traversal" , SdlAttrDataTypeEnum , SdlIgnore ,
  1342. SDL_ATTR_TRAVERSAL,
  1343. 0 },
  1344. { "typenam" , SdlAttrDataTypeCdata , SdlFontSpecific ,
  1345. SDL_ATTR_TYPENAM,
  1346. SDLAttrOffset(_DtHelpFontHintPtr,typenam) },
  1347. { "typenamb" , SdlAttrDataTypeCdata , SdlFontSpecific ,
  1348. SDL_ATTR_TYPENAMB,
  1349. SDLAttrOffset(_DtHelpFontHintPtr,typenamb) },
  1350. { "typenami" , SdlAttrDataTypeCdata , SdlFontSpecific ,
  1351. SDL_ATTR_TYPENAMI,
  1352. SDLAttrOffset(_DtHelpFontHintPtr,typenami) },
  1353. { "typenamib" , SdlAttrDataTypeCdata , SdlFontSpecific ,
  1354. SDL_ATTR_TYPENAMIB,
  1355. SDLAttrOffset(_DtHelpFontHintPtr,typenamib) },
  1356. { "version" , SdlAttrDataTypeCdata , SdlIgnore ,
  1357. SDL_ATTR_VERSION,
  1358. 0 },
  1359. {(TopVJustStr+4) , SdlAttrDataTypeEnum , SdlContainerSpecific ,
  1360. SDL_ATTR_VJUST,
  1361. SDLAttrOffset(_DtCvContainerPtr,vjustify) },
  1362. {(TopVOrientStr+4), SdlAttrDataTypeEnum , SdlContainerSpecific ,
  1363. SDL_ATTR_VORIENT ,
  1364. SDLAttrOffset(_DtCvContainerPtr,vorient) },
  1365. { "weight" , SdlAttrDataTypeFont , SdlFontSpecific ,
  1366. SDL_ATTR_WEIGHT,
  1367. SDLAttrOffset(_DtHelpFontHintPtr,weight) },
  1368. { "window" , SdlAttrDataTypeEnum , SdlElementSpecific,
  1369. SDL_ATTR_WINDOW,
  1370. SDLAttrOffset(ElementInfoPtr,window) },
  1371. { "xid" , SdlAttrDataTypeCdata , SdlElementSpecific,
  1372. SDL_ATTR_XID ,
  1373. SDLAttrOffset(ElementInfoPtr,w.snb_info.xid) },
  1374. { "xlfd" , SdlAttrDataTypeCdata , SdlFontSpecific ,
  1375. SDL_ATTR_XLFD ,
  1376. SDLAttrOffset(_DtHelpFontHintPtr,xlfd) },
  1377. { "xlfdb" , SdlAttrDataTypeCdata , SdlFontSpecific ,
  1378. SDL_ATTR_XLFDB ,
  1379. SDLAttrOffset(_DtHelpFontHintPtr,xlfdb) },
  1380. { "xlfdi" , SdlAttrDataTypeCdata , SdlFontSpecific ,
  1381. SDL_ATTR_XLFDI ,
  1382. SDLAttrOffset(_DtHelpFontHintPtr,xlfdi) },
  1383. { "xlfdib" , SdlAttrDataTypeCdata , SdlFontSpecific ,
  1384. SDL_ATTR_XLFDIB ,
  1385. SDLAttrOffset(_DtHelpFontHintPtr,xlfdib) },
  1386. { 0 , SdlAttrDataTypeInvalid, -1, 0 },
  1387. };
  1388. /******************************************************************************
  1389. * Element Content
  1390. *****************************************************************************/
  1391. /*-----------------------------------------------------------------------------
  1392. <!-- Document Hierarchy _____________________________________________-->
  1393. <!-- The root element is a pageless document, sdldoc.
  1394. - A sdldoc contains one or more virtual pages.
  1395. - A Virtual page is the smallest display unit.
  1396. - A Block is a unit of a given style.
  1397. - A Paragraph is a unit of character formatting.
  1398. -->
  1399. <!ELEMENT sdldoc - - (vstruct, head*, snb?, virpage+)>
  1400. <!ATTLIST sdldoc pub-id CDATA #REQUIRED
  1401. doc-id CDATA #REQUIRED
  1402. timestmp CDATA #REQUIRED
  1403. first-page IDREF #IMPLIED
  1404. product CDATA #IMPLIED
  1405. prodpn CDATA #IMPLIED
  1406. prodver CDATA #IMPLIED
  1407. license CDATA #IMPLIED
  1408. language CDATA #IMPLIED
  1409. charset CDATA #IMPLIED
  1410. author CDATA #IMPLIED
  1411. version CDATA #IMPLIED
  1412. sdldtd CDATA #REQUIRED
  1413. srcdtd CDATA #IMPLIED >
  1414. -----------------------------------------------------------------------------*/
  1415. static SDLContent SdlDocContent[] =
  1416. {
  1417. /*
  1418. { SDLInitMask(SdlElementVStruct), OnlyOne },
  1419. * Do not want to parse the entire document.
  1420. * Want to only read enought to work with.
  1421. */
  1422. { SDLInitMask(SdlElementSdlDoc) , FakeEnd },
  1423. { SDLInitMask(SdlElementSdlDoc) , CopyDocInfo },
  1424. { SDLInitMask(SdlElementNone) , NULL },
  1425. };
  1426. static SDLElementAttrList SdlDocAttrList[] =
  1427. {
  1428. { SDL_ATTR_PUBID , SdlAttrValueRequired, NULL },
  1429. { SDL_ATTR_DOCID , SdlAttrValueRequired, NULL },
  1430. { SDL_ATTR_TIMESTAMP, SdlAttrValueRequired, NULL },
  1431. { SDL_ATTR_PRODUCT , SdlAttrValueImplied , NULL },
  1432. { SDL_ATTR_PRODPN , SdlAttrValueImplied , NULL },
  1433. { SDL_ATTR_PRODVER , SdlAttrValueImplied , NULL },
  1434. { SDL_ATTR_LICENSE , SdlAttrValueImplied , NULL },
  1435. { SDL_ATTR_LANGUAGE , SdlAttrValueImplied , "C" },
  1436. { SDL_ATTR_CHARSET , SdlAttrValueImplied , IsoStr },
  1437. { SDL_ATTR_AUTHOR , SdlAttrValueImplied , NULL },
  1438. { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL },
  1439. { SDL_ATTR_FRST_PG , SdlAttrValueImplied , NULL },
  1440. { SDL_ATTR_SDLDTD , SdlAttrValueRequired, NULL },
  1441. { SDL_ATTR_SRCDTD , SdlAttrValueImplied , NULL },
  1442. { -1 , SdlAttrValueBad , NULL }
  1443. };
  1444. /*-----------------------------------------------------------------------------
  1445. <!ELEMENT vstruct - - (%generated-elements;) >
  1446. <!ATTLIST vstruct version CDATA #IMPLIED
  1447. doc-id CDATA #REQUIRED >
  1448. -----------------------------------------------------------------------------*/
  1449. static SDLContent VStructContent[] =
  1450. {
  1451. SDL_ENTITY_GENERATED_ELEMENTS
  1452. { SDLInitMask(SdlElementNone) , NULL },
  1453. };
  1454. static SDLElementAttrList VStructAttrList[] =
  1455. {
  1456. { SDL_ATTR_DOCID , SdlAttrValueImplied , NULL },
  1457. { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL },
  1458. { -1 , SdlAttrValueBad , NULL }
  1459. };
  1460. /*-----------------------------------------------------------------------------
  1461. <!ELEMENT virpage - - (head*, snb?, (block | form)*) >
  1462. <!ATTLIST virpage id ID #REQUIRED
  1463. level NUMBER #REQUIRED
  1464. version CDATA #IMPLIED
  1465. language CDATA #IMPLIED
  1466. charset CDATA #IMPLIED
  1467. doc-id CDATA #REQUIRED
  1468. ssi CDATA #IMPLIED >
  1469. -----------------------------------------------------------------------------*/
  1470. static SDLContent VirpageContent[] =
  1471. {
  1472. { SDLInitMask(SdlElementHead) , SetSaveSnref },
  1473. { SDLInitMask(SdlElementHead) , ZeroToN },
  1474. { SDLInitMask(SdlElementSnb) , ZeroOrOne },
  1475. { SDLInitMask(SdlElementHead) , ClearAndCheckSnref},
  1476. { SDLInitMaskTwo(SdlElementBlock, \
  1477. SdlElementForm), ZeroToN },
  1478. { SDLInitMask(SdlElementNone) , NULL },
  1479. };
  1480. static SDLContent VirpageHeadContent[] =
  1481. {
  1482. { SDLInitMask(SdlElementHead) , SetSaveSnref},
  1483. { SDLInitMask(SdlElementHead) , ZeroToN },
  1484. { SDLInitMask(SdlElementVirpage) , CheckForSnb },
  1485. { SDLInitMask(SdlElementTitle) , FakeEnd },
  1486. { SDLInitMask(SdlElementNone) , NULL },
  1487. };
  1488. static SDLContent HeadAndSnb[] =
  1489. {
  1490. { SDLInitMask(SdlElementHead) , SetSaveSnref},
  1491. { SDLInitMask(SdlElementHead) , ZeroToN },
  1492. { SDLInitMask(SdlElementHead) , CheckForSnb },
  1493. { SDLInitMask(SdlElementNone) , NULL },
  1494. };
  1495. static SDLElementAttrList VirpageAttrList[] =
  1496. {
  1497. { SDL_ATTR_ID , SdlAttrValueRequired , NULL },
  1498. { SDL_ATTR_LEVEL , SdlAttrValueRequired , NULL },
  1499. { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL },
  1500. { SDL_ATTR_LANGUAGE, SdlAttrValueImplied , NULL },
  1501. { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL },
  1502. { SDL_ATTR_DOCID , SdlAttrValueRequired , NULL },
  1503. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  1504. { -1 , SdlAttrValueBad , NULL }
  1505. };
  1506. /*-----------------------------------------------------------------------------
  1507. <!ELEMENT snb - - (head?, (%system-notations;)+) >
  1508. <!ATTLIST snb version CDATA #IMPLIED >
  1509. -----------------------------------------------------------------------------*/
  1510. static SDLContent SnbContent[] =
  1511. {
  1512. { SDLInitMask(SdlElementHead) , ZeroOrOne },
  1513. { SDL_ENTITY_SYSTEM_NOTATIONS , OneToN },
  1514. { SDLInitMask(SdlElementNone) , NULL },
  1515. };
  1516. static SDLElementAttrList SnbAttrList[] =
  1517. {
  1518. { SDL_ATTR_VERSION, SdlAttrValueImplied , NULL },
  1519. { -1 ,SdlAttrValueBad , NULL }
  1520. };
  1521. /*-----------------------------------------------------------------------------
  1522. <!ELEMENT block - - (head*, (p | cp)*) >
  1523. <!ATTLIST block id ID #IMPLIED
  1524. -- processor should default level to "1" --
  1525. level NUMBER #IMPLIED
  1526. version CDATA #IMPLIED
  1527. class (%format-class;) #IMPLIED
  1528. language CDATA #IMPLIED
  1529. -- processor shld deflt charset to "ISO-8859-1" --
  1530. charset CDATA #IMPLIED
  1531. length NUMBER #IMPLIED
  1532. -- processor should default app to "all" --
  1533. app ( all |
  1534. help |
  1535. tutorial |
  1536. ref |
  1537. sys ) #IMPLIED
  1538. -- processor should default timing to "sync" --
  1539. timing ( sync | async ) #IMPLIED
  1540. ssi CDATA #IMPLIED >
  1541. -----------------------------------------------------------------------------*/
  1542. static SDLContent BlockContent[] =
  1543. {
  1544. { SDLInitMask(SdlElementBlock) , SetTransit},
  1545. { SDLInitMask(SdlElementHead) , ZeroToN },
  1546. { SDLInitMaskTwo(SdlElementPara, SdlElementCPara), ZeroToN },
  1547. { SDLInitMask(SdlElementNone) , NULL },
  1548. };
  1549. static SDLElementAttrList BlockAttrList[] =
  1550. {
  1551. { SDL_ATTR_ID , SdlAttrValueImpliedDef , NULL },
  1552. { SDL_ATTR_LEVEL , SdlAttrValueImpliedDef , OneStr },
  1553. { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL },
  1554. { SDL_ATTR_CLASSF , SdlAttrValueImplied , (TextStr+1) },
  1555. { SDL_ATTR_LANGUAGE, SdlAttrValueImplied , NULL },
  1556. { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL },
  1557. { SDL_ATTR_LENGTH , SdlAttrValueImplied , NegativeOneStr },
  1558. { SDL_ATTR_APP , SdlAttrValueImplied , AllStr },
  1559. { SDL_ATTR_TIMING , SdlAttrValueImplied , (ASyncStr+1) },
  1560. { SDL_ATTR_SSI , SdlAttrValueImpliedDef , NULL },
  1561. { -1 , SdlAttrValueBad , NULL }
  1562. };
  1563. /*-----------------------------------------------------------------------------
  1564. <!ELEMENT form - - (head*, ((fstyle, fdata) | (fdata, fstyle))) >
  1565. <!ATTLIST form id ID #IMPLIED
  1566. -- processor shld deflt level to nest of form --
  1567. level NUMBER #IMPLIED
  1568. version CDATA #IMPLIED
  1569. class (%format-class;) #IMPLIED
  1570. language CDATA #IMPLIED
  1571. -- processor shld deflt charset to "ISO-8859-1" --
  1572. charset CDATA #IMPLIED
  1573. length NUMBER #IMPLIED
  1574. -- processor should default app to "all" --
  1575. app ( all |
  1576. help |
  1577. tutorial |
  1578. ref |
  1579. sys ) #IMPLIED
  1580. ssi CDATA #IMPLIED >
  1581. -----------------------------------------------------------------------------*/
  1582. static SDLContent FormContent[] =
  1583. {
  1584. { SDLInitMask(SdlElementHead) , ZeroToN },
  1585. { SDLInitMaskTwo(SdlElementFstyle, SdlElementFdata),
  1586. OnlyOneEach },
  1587. { SDLInitMask(SdlElementForm) , ColInfoToTableInfo },
  1588. { SDLInitMask(SdlElementNone) , NULL },
  1589. };
  1590. static SDLElementAttrList FormAttrList[] =
  1591. {
  1592. { SDL_ATTR_ID , SdlAttrValueImpliedDef, NULL },
  1593. { SDL_ATTR_LEVEL , SdlAttrValueImplied , OneStr },
  1594. { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL },
  1595. { SDL_ATTR_CLASSF , SdlAttrValueImplied , (TextStr+1) },
  1596. { SDL_ATTR_LANGUAGE, SdlAttrValueImplied , NULL },
  1597. { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL },
  1598. { SDL_ATTR_LENGTH , SdlAttrValueImplied , NegativeOneStr },
  1599. { SDL_ATTR_APP , SdlAttrValueImplied , AllStr },
  1600. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  1601. { -1 ,SdlAttrValueBad , NULL }
  1602. };
  1603. /*-----------------------------------------------------------------------------
  1604. <!ELEMENT fstyle - - (frowvec+) >
  1605. <!ATTLIST fstyle -- The number of columns in this form, ncols, --
  1606. -- should be a number greater than zero. --
  1607. -- Unless overridden by a "colw" (column --
  1608. -- width) specification in a formstyle, the --
  1609. -- available space is divided evenly among --
  1610. -- the columns. Unless overriden by a "colj" --
  1611. -- specification in a formstyle, the columns --
  1612. -- are all left justified. --
  1613. -- processor should default ncols to 1 --
  1614. ncols NUMBER #IMPLIED >
  1615. -----------------------------------------------------------------------------*/
  1616. static SDLContent FstyleContent[] =
  1617. {
  1618. { SDLInitMask(SdlElementFrowvec), OneToN },
  1619. { SDLInitMask(SdlElementNone) , NULL },
  1620. };
  1621. static SDLElementAttrList FstyleAttrList[] =
  1622. {
  1623. { SDL_ATTR_NCOLS , SdlAttrValueImpliedDef , OneStr },
  1624. { -1 , SdlAttrValueBad , NULL }
  1625. };
  1626. /*-----------------------------------------------------------------------------
  1627. <!ELEMENT frowvec - O EMPTY >
  1628. <!ATTLIST frowvec -- processor should default hdr to "NO" --
  1629. hdr (YES | NO) #IMPLIED
  1630. -- Ids of cell contents. One id per cell. --
  1631. -- Each id must refer to either a block or a --
  1632. -- form. --
  1633. cells IDREFS #REQUIRED >
  1634. -----------------------------------------------------------------------------*/
  1635. static SDLContent FrowvecContent[] =
  1636. {
  1637. { SDLInitMask(SdlElementFrowvec), AddRowToTable},
  1638. { SDLInitMask(SdlElementNone) , NULL },
  1639. };
  1640. static SDLElementAttrList FrowvecAttrList[] =
  1641. {
  1642. { SDL_ATTR_HDR , SdlAttrValueImplied , "NO" },
  1643. { SDL_ATTR_CELLS , SdlAttrValueRequired, NULL },
  1644. { -1 , SdlAttrValueBad , NULL }
  1645. };
  1646. /*-----------------------------------------------------------------------------
  1647. <!ELEMENT fdata - - ((block | form)*) >
  1648. -----------------------------------------------------------------------------*/
  1649. static SDLContent FdataContent[] =
  1650. {
  1651. { SDLInitMaskTwo(SdlElementBlock, SdlElementForm), ZeroToN },
  1652. { SDLInitMask(SdlElementNone) , NULL },
  1653. };
  1654. /*-----------------------------------------------------------------------------
  1655. <!-- Containers ______________________________________________________-->
  1656. <!ELEMENT p - - (head*, (%atomic | #PCDATA)+) >
  1657. <!ATTLIST p id ID #IMPLIED
  1658. version CDATA #IMPLIED
  1659. -- processor should default type to "dynamic" --
  1660. type (literal |
  1661. lined |
  1662. dynamic ) #IMPLIED
  1663. ssi CDATA #IMPLIED >
  1664. -----------------------------------------------------------------------------*/
  1665. static SDLContent ParaContent[] =
  1666. {
  1667. /*
  1668. * This is optional and followed by potential PCDATA, therefore include
  1669. * the SdlElementCdata & SdlPcDataFollows flag.
  1670. */
  1671. { SDLInitMaskThree(SdlElementHead, SdlPcDataFollows, SdlElementCdata),
  1672. ZeroToN },
  1673. { SDLInitMask(SdlElementPara), InitLast },
  1674. /*
  1675. * PCDATA is described as 0 to n characters,
  1676. * therefore, while the content says 'one to n' of (%atomic | #PCDATA)
  1677. * we need to specify ZeroToN to work for PCDATA
  1678. { SDL_ENTITY_ATOMIC , OneToN },
  1679. */
  1680. { SDL_ENTITY_ATOMIC , ZeroToN },
  1681. { SDLInitMask(SdlElementNone), NULL },
  1682. };
  1683. static SDLElementAttrList ParaAttrList[] =
  1684. {
  1685. { SDL_ATTR_ID , SdlAttrValueImpliedDef, NULL },
  1686. { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL },
  1687. { SDL_ATTR_TYPEFRMT, SdlAttrValueImplied , DynamicStr},
  1688. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  1689. { -1 , SdlAttrValueBad , NULL }
  1690. };
  1691. /*-----------------------------------------------------------------------------
  1692. <!ELEMENT cp - - CDATA >
  1693. <!ATTLIST cp id ID #IMPLIED
  1694. version CDATA #IMPLIED
  1695. -- processor should default type to "dynamic" --
  1696. type (literal |
  1697. lined |
  1698. dynamic ) #IMPLIED
  1699. ssi CDATA #IMPLIED >
  1700. -----------------------------------------------------------------------------*/
  1701. static SDLContent CParaContent[] =
  1702. {
  1703. { SDLInitMask(SdlElementCPara), InitLast },
  1704. { SDLInitMask(SdlElementCdata), ZeroOrOne },
  1705. { SDLInitMask(SdlElementNone) , NULL },
  1706. };
  1707. /* uses the same attributes as <p> */
  1708. /*-----------------------------------------------------------------------------
  1709. <!-- Heads may have multiple sub-heads -->
  1710. <!ELEMENT head - - ((%atomic; | #PCDATA)*, subhead*) >
  1711. <!ELEMENT subhead - - ((%atomic | #PCDATA)*) >
  1712. <!ATTLIST (head | subhead)
  1713. id ID #IMPLIED
  1714. version CDATA #IMPLIED
  1715. -- processor should default class to "head" --
  1716. class (%head-class;) #IMPLIED
  1717. language CDATA #IMPLIED
  1718. -- processor shld deflt charset to "ISO-8859-1" --
  1719. charset CDATA #IMPLIED
  1720. -- processor should default type to "dynamic" --
  1721. type (literal |
  1722. lined |
  1723. dynamic ) #IMPLIED
  1724. abbrev CDATA #IMPLIED
  1725. ssi CDATA #IMPLIED >
  1726. -----------------------------------------------------------------------------*/
  1727. static SDLContent HeadContent[] =
  1728. {
  1729. { SDLInitMask(SdlElementHead) , InitLast },
  1730. { SDL_ENTITY_ATOMIC , ZeroToN },
  1731. { SDLInitMask(SdlElementSubHead), ZeroToN },
  1732. { SDLInitMask(SdlElementNone) , NULL },
  1733. };
  1734. static SDLContent SubHeadContent[] =
  1735. {
  1736. { SDLInitMask(SdlElementSubHead), InitLast },
  1737. { SDL_ENTITY_ATOMIC , ZeroToN },
  1738. { SDLInitMask(SdlElementNone) , NULL },
  1739. };
  1740. static SDLElementAttrList HeadAttrList[] =
  1741. {
  1742. { SDL_ATTR_ID , SdlAttrValueImpliedDef, NULL },
  1743. { SDL_ATTR_VERSION , SdlAttrValueImplied , NULL },
  1744. { SDL_ATTR_CLASSH , SdlAttrValueImplied , (HeadStr+1)},
  1745. { SDL_ATTR_LANGUAGE, SdlAttrValueImplied , NULL },
  1746. { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL },
  1747. { SDL_ATTR_TYPEFRMT, SdlAttrValueImplied , DynamicStr },
  1748. { SDL_ATTR_ABBREV , SdlAttrValueImplied , NULL },
  1749. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  1750. { -1 , SdlAttrValueBad , NULL }
  1751. };
  1752. /*-----------------------------------------------------------------------------
  1753. <!-- Atomic Link Elements ____________________________________________-->
  1754. <!ELEMENT anchor - O EMPTY -- Just marks the spot to jump to -->
  1755. <!ATTLIST anchor id ID #REQUIRED >
  1756. -----------------------------------------------------------------------------*/
  1757. static SDLElementAttrList AnchorAttrList[] =
  1758. {
  1759. { SDL_ATTR_ID , SdlAttrValueRequired, NULL },
  1760. { -1 , SdlAttrValueBad , NULL }
  1761. };
  1762. static SDLContent AnchorContent[] =
  1763. {
  1764. { SDLInitMask(SdlElementAnchor) , CopyAnchorId },
  1765. { SDLInitMask(SdlElementNone) , NULL },
  1766. };
  1767. /*-----------------------------------------------------------------------------
  1768. <!ELEMENT link - - ((%atomic; | #PCDATA)+) -(link)>
  1769. <!ATTLIST link -- rid is to id in this document or to a link --
  1770. -- type element such as crossdoc in the snb --
  1771. -- of the current virpage --
  1772. rid IDREF #REQUIRED
  1773. -- button should be a graphic in the snb --
  1774. button IDREF #IMPLIED
  1775. linkinfo CDATA #IMPLIED
  1776. descript CDATA #IMPLIED
  1777. -- processor shld default window to "current" --
  1778. window (current |
  1779. new |
  1780. popup ) #IMPLIED
  1781. -- procssr shld dflt traversal to "noreturn" --
  1782. traversal (return |
  1783. noreturn ) #IMPLIED >
  1784. -----------------------------------------------------------------------------*/
  1785. static SDLContent LinkContent[] =
  1786. {
  1787. { SDLInitMask(SdlElementLink) , RegisterLink },
  1788. /*
  1789. * PCDATA is described as 0 to n characters,
  1790. * therefore, while the content says 'one to n' of (%atomic | #PCDATA)
  1791. * we need to specify ZeroToN to work for PCDATA
  1792. { SDL_ENTITY_ATOMIC , OneToN },
  1793. */
  1794. { SDL_ENTITY_ATOMIC , ZeroToN },
  1795. { SDLInitMask(SdlElementNone) , NULL },
  1796. };
  1797. static SDLElementAttrList LinkAttrList[] =
  1798. {
  1799. { SDL_ATTR_RID , SdlAttrValueRequired , NULL },
  1800. { SDL_ATTR_BUTTON , SdlAttrValueImpliedDef, NULL },
  1801. { SDL_ATTR_WINDOW , SdlAttrValueImplied , "current" },
  1802. { SDL_ATTR_TRAVERSAL, SdlAttrValueImplied , "noreturn"},
  1803. { SDL_ATTR_DESCRIPT , SdlAttrValueImpliedDef, NULL },
  1804. { SDL_ATTR_LINKINFO , SdlAttrValueImpliedDef, NULL },
  1805. { -1 , SdlAttrValueBad , NULL }
  1806. };
  1807. /*-----------------------------------------------------------------------------
  1808. <!-- reference to an element or alternates in the system notation block -->
  1809. <!ELEMENT snref - - (refitem+, alttext?) >
  1810. <!ATTLIST snref id ID #IMPLIED >
  1811. -----------------------------------------------------------------------------*/
  1812. static SDLContent SnrefContent[] =
  1813. {
  1814. { SDLInitMask(SdlElementSnRef) , MarkFound },
  1815. { SDLInitMask(SdlElementRefItem), OneToN },
  1816. { SDLInitMask(SdlElementAltText), ZeroOrOne },
  1817. { SDLInitMask(SdlElementNone) , NULL },
  1818. };
  1819. static SDLElementAttrList SnrefAttrList[] =
  1820. {
  1821. { SDL_ATTR_ID, SdlAttrValueImpliedDef, NULL },
  1822. { -1 , SdlAttrValueBad , NULL }
  1823. };
  1824. /*-----------------------------------------------------------------------------
  1825. <!-- Each refitem is tried in turn until one can be successfully
  1826. - formatted. The button is used to request display of the refitem
  1827. - on systems where display of the item would be slow or expensive
  1828. - in some other way, i.e., the button is displayed and the refitem
  1829. - is only displayed on activiation of the button.
  1830. -->
  1831. <!ELEMENT refitem - - (head*) >
  1832. <!ATTLIST refitem -- rid should point to a representational --
  1833. -- element in the system notation block --
  1834. rid IDREF #REQUIRED
  1835. class (%graphic-class; |
  1836. %format-class; ) #REQUIRED
  1837. -- button should be a graphic in the snb --
  1838. button IDREF #IMPLIED
  1839. ssi CDATA #IMPLIED >
  1840. -----------------------------------------------------------------------------*/
  1841. static SDLContent RefItemContent[] =
  1842. {
  1843. { SDLInitMask(SdlElementHead) , ZeroOrOne },
  1844. { SDLInitMask(SdlElementRefItem) , SaveItemInfo },
  1845. { SDLInitMask(SdlElementNone) , NULL },
  1846. };
  1847. static SDLElementAttrList RefItemAttrList[] =
  1848. {
  1849. { SDL_ATTR_RID , SdlAttrValueRequired , NULL },
  1850. { SDL_ATTR_CLASSFG, SdlAttrValueRequired , NULL },
  1851. { SDL_ATTR_BUTTON , SdlAttrValueImplied , NULL },
  1852. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  1853. { -1 , SdlAttrValueBad , NULL }
  1854. };
  1855. /*-----------------------------------------------------------------------------
  1856. <!-- simple text to use if all else fails -->
  1857. <!ELEMENT alttext - - CDATA >
  1858. -----------------------------------------------------------------------------*/
  1859. static SDLContent AltTextContent[] =
  1860. {
  1861. { SDLInitMask(SdlElementCdata), ZeroOrOne },
  1862. { SDLInitMask(SdlElementNone) , NULL },
  1863. };
  1864. /*-----------------------------------------------------------------------------
  1865. <!-- Atomic Text Elements ____________________________________________-->
  1866. <!-- empty rev implies delete -->
  1867. <!ELEMENT rev - - ((%atomic; | #PCDATA)*) -(rev) >
  1868. -----------------------------------------------------------------------------*/
  1869. static SDLContent RevContent[] =
  1870. {
  1871. { SDL_ENTITY_ATOMIC , ZeroToN },
  1872. { SDLInitMask(SdlElementNone), NULL },
  1873. };
  1874. /*-----------------------------------------------------------------------------
  1875. <!-- font changes -->
  1876. <!ELEMENT key - - ((%atomic; | #PCDATA)*) -(link) >
  1877. <!ATTLIST key -- processor shld deflt charset to "ISO-8859-1" --
  1878. charset CDATA #IMPLIED
  1879. class (%key-class;) #REQUIRED
  1880. ssi CDATA #IMPLIED >
  1881. -----------------------------------------------------------------------------*/
  1882. static SDLContent KeyContent[] =
  1883. {
  1884. { SDLInitMask(SdlElementKey) , ProcessEnterAttr },
  1885. { SDL_ENTITY_ATOMIC , ZeroToN },
  1886. { SDLInitMask(SdlElementKey) , ProcessExitAttr },
  1887. { SDLInitMask(SdlElementNone), NULL },
  1888. };
  1889. static SDLElementAttrList KeyAttrList[] =
  1890. {
  1891. { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL },
  1892. { SDL_ATTR_CLASSK , SdlAttrValueRequired , NULL },
  1893. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  1894. { -1 , SdlAttrValueBad , NULL }
  1895. };
  1896. /*-----------------------------------------------------------------------------
  1897. <!-- super or subscripted phrase -->
  1898. <!ELEMENT sphrase - - (spc | #PCDATA)* >
  1899. <!ATTLIST sphrase class %phrase-class #REQUIRED
  1900. ssi CDATA #IMPLIED >
  1901. -----------------------------------------------------------------------------*/
  1902. static SDLContent SphraseContent[] =
  1903. {
  1904. { SDLInitMask(SdlElementSphrase), CheckType },
  1905. { SDLInitMaskTwo(SdlElementSpc, SdlElementCdata), ZeroToN },
  1906. { SDLInitMask(SdlElementSphrase), SetType },
  1907. { SDLInitMask(SdlElementNone) , NULL },
  1908. };
  1909. static SDLElementAttrList SphraseAttrList[] =
  1910. {
  1911. { SDL_ATTR_CLASSP , SdlAttrValueRequired , NULL },
  1912. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  1913. { -1 , SdlAttrValueBad , NULL }
  1914. };
  1915. /*-----------------------------------------------------------------------------
  1916. <!-- conditional inclusion of text -->
  1917. <!ELEMENT if - - (cond, then, else?) >
  1918. -----------------------------------------------------------------------------*/
  1919. static SDLContent IfContent[] =
  1920. {
  1921. { SDLInitMask(SdlElementIf) , IfInfo },
  1922. { SDLInitMask(SdlElementCond), OnlyOne },
  1923. { SDLInitMask(SdlElementThen), OnlyOne },
  1924. { SDLInitMask(SdlElementElse), ZeroOrOne },
  1925. { SDLInitMask(SdlElementNone), NULL },
  1926. };
  1927. /*-----------------------------------------------------------------------------
  1928. <!-- call "interp" passing CDATA -->
  1929. <!ELEMENT cond - - CDATA >
  1930. <!ATTLIST cond -- processor should default interp to "ksh" --
  1931. interp NOTATION
  1932. (tcl |
  1933. sh |
  1934. ksh |
  1935. csh ) #IMPLIED >
  1936. -----------------------------------------------------------------------------*/
  1937. static SDLContent CondContent[] =
  1938. {
  1939. { SDLInitMask(SdlElementCond) , SetType },
  1940. { SDLInitMask(SdlElementCdata), ZeroOrOne },
  1941. { SDLInitMask(SdlElementNone) , NULL },
  1942. };
  1943. static SDLElementAttrList CondAttrList[] =
  1944. {
  1945. { SDL_ATTR_INTERP , SdlAttrValueImplied , "ksh" },
  1946. { -1 , SdlAttrValueBad , NULL }
  1947. };
  1948. /*-----------------------------------------------------------------------------
  1949. <!-- include this text if "cond" returns non-zero -->
  1950. <!ELEMENT then - - ((%atomic; | #PCDATA)*) >
  1951. <!-- include this text if "cond" returns zero -->
  1952. <!ELEMENT else - - ((%atomic; | #PCDATA)*) >
  1953. -----------------------------------------------------------------------------*/
  1954. static SDLContent ThenElseContent[] =
  1955. {
  1956. { SDLInitMask(SdlElementIf) , IfInfo },
  1957. { SDL_ENTITY_ATOMIC , ZeroToN },
  1958. { SDLInitMask(SdlElementNone), NULL },
  1959. };
  1960. /*-----------------------------------------------------------------------------
  1961. <!-- special characters: the "name" attribute must be one of the special
  1962. - character names, e.g., [bull ] (bullet), defined in the public
  1963. - character entities such as ISOpub, "ISO 8879:1986//ENTITIES
  1964. - Publishing//EN"; these entities are defined in sections D.4.2.1
  1965. - through D.4.5.6 of The SGML Handbook (Goldfarb).
  1966. -->
  1967. <!ELEMENT spc - O EMPTY >
  1968. <!ATTLIST spc name CDATA #REQUIRED >
  1969. -----------------------------------------------------------------------------*/
  1970. static SDLContent SpcContent[] =
  1971. {
  1972. { SDLInitMask(SdlElementSpc) , ResolveSpcInfo },
  1973. { SDLInitMask(SdlElementNone), NULL },
  1974. };
  1975. static SDLElementAttrList SpcAttrList[] =
  1976. {
  1977. { SDL_ATTR_NAME, SdlAttrValueRequired, NULL },
  1978. { -1 ,SdlAttrValueBad , NULL }
  1979. };
  1980. /*-----------------------------------------------------------------------------
  1981. <!-- Notation Elements _______________________________________________-->
  1982. <!-- The first group are representaional - referenced via <snref> -->
  1983. <!-- Only one graphic element is declared. The "class" attribute in
  1984. - the refitem of the referring snref is used to distinguish between
  1985. - figure, in-line or button.
  1986. -->
  1987. <!ELEMENT graphic - O EMPTY >
  1988. <!ATTLIST graphic id ID #REQUIRED
  1989. format CDATA #IMPLIED
  1990. method IDREF #IMPLIED
  1991. xid CDATA #REQUIRED >
  1992. -----------------------------------------------------------------------------*/
  1993. static SDLContent GraphicContent[] =
  1994. {
  1995. { SDLInitMask(SdlElementGraphic), LoadGraphic },
  1996. { SDLInitMask(SdlElementNone) , NULL },
  1997. };
  1998. static SDLElementAttrList NotationAttrList[] =
  1999. {
  2000. { SDL_ATTR_ID , SdlAttrValueRequired, NULL },
  2001. { SDL_ATTR_FORMAT, SdlAttrValueImplied , NULL },
  2002. { SDL_ATTR_METHOD, SdlAttrValueImplied , NULL },
  2003. { SDL_ATTR_XID , SdlAttrValueRequired, NULL },
  2004. { -1 ,SdlAttrValueBad , NULL }
  2005. };
  2006. /*-----------------------------------------------------------------------------
  2007. <!-- alternate rich text for use in a list of refitems in snref -->
  2008. <!ELEMENT text - - ((p | cp)*) >
  2009. <!ATTLIST text id ID #REQUIRED
  2010. language CDATA #IMPLIED
  2011. -- processor shld dflt charset to "ISO-8859-1" --
  2012. charset CDATA #IMPLIED >
  2013. -----------------------------------------------------------------------------*/
  2014. static SDLContent TextContent[] =
  2015. {
  2016. { SDLInitMask(SdlElementText) , SaveLangCharSet },
  2017. { SDLInitMaskTwo(SdlElementPara, SdlElementCPara), ZeroToN },
  2018. { SDLInitMask(SdlElementNone) , NULL },
  2019. };
  2020. static SDLElementAttrList TextAttrList[] =
  2021. {
  2022. { SDL_ATTR_ID , SdlAttrValueRequired, NULL },
  2023. { SDL_ATTR_LANGUAGE, SdlAttrValueImplied , NULL },
  2024. { SDL_ATTR_CHARSET , SdlAttrValueImplied , NULL },
  2025. { -1 , SdlAttrValueBad , NULL }
  2026. };
  2027. /*-----------------------------------------------------------------------------
  2028. <!ELEMENT audio - O EMPTY >
  2029. <!ATTLIST audio id ID #REQUIRED
  2030. format CDATA #IMPLIED
  2031. method IDREF #IMPLIED
  2032. xid CDATA #REQUIRED >
  2033. <!ELEMENT video - O EMPTY >
  2034. <!ATTLIST video id ID #REQUIRED
  2035. format CDATA #IMPLIED
  2036. method IDREF #IMPLIED
  2037. xid CDATA #REQUIRED >
  2038. <!ELEMENT animate - O EMPTY >
  2039. <!ATTLIST animate id ID #REQUIRED
  2040. format CDATA #IMPLIED
  2041. method IDREF #IMPLIED
  2042. xid CDATA #REQUIRED >
  2043. /----
  2044. /- The audio, video, and animate use the NotationAttrList
  2045. /- structure defined under graphic.
  2046. /---
  2047. -----------------------------------------------------------------------------*/
  2048. /*-----------------------------------------------------------------------------
  2049. <!-- Execute the content of this element using the specified "interp"
  2050. - whenever the script element is referenced via an snref. If the
  2051. - script returns a value, that value effectively becomes the CDATA
  2052. - content of the script element and is interpolated into the document
  2053. - at the point of the snref.
  2054. -->
  2055. <!ELEMENT script - - CDATA >
  2056. <!ATTLIST script id ID #REQUIRED
  2057. -- processor should default interp to "ksh" --
  2058. interp NOTATION
  2059. (tcl |
  2060. sh |
  2061. ksh |
  2062. csh ) #IMPLIED >
  2063. -----------------------------------------------------------------------------*/
  2064. static SDLContent ScriptContent[] =
  2065. {
  2066. { SDLInitMask(SdlElementScript) , SetType },
  2067. { SDLInitMask(SdlElementCdata) , ZeroOrOne },
  2068. { SDLInitMask(SdlElementNone) , NULL },
  2069. };
  2070. static SDLElementAttrList ScriptAttrList[] =
  2071. {
  2072. { SDL_ATTR_ID , SdlAttrValueRequired, NULL },
  2073. { SDL_ATTR_INTERP , SdlAttrValueImplied , "ksh" },
  2074. { -1 ,SdlAttrValueBad , NULL }
  2075. };
  2076. /*-----------------------------------------------------------------------------
  2077. <!-- The second group in the snb is linkage - referenced via <link> -->
  2078. <!ELEMENT crossdoc - O EMPTY >
  2079. <!ATTLIST crossdoc id ID #REQUIRED
  2080. -- cross document link - doc & id --
  2081. xid CDATA #REQUIRED >
  2082. <!ELEMENT man-page - O EMPTY >
  2083. <!ATTLIST man-page id ID #REQUIRED
  2084. xid CDATA #REQUIRED >
  2085. -----------------------------------------------------------------------------*/
  2086. static SDLContent CrossDocContent[] =
  2087. {
  2088. { SDLInitMask(SdlElementCrossDoc) , RegisterSnbLink },
  2089. { SDLInitMask(SdlElementNone) , NULL },
  2090. };
  2091. static SDLContent ManPageContent[] =
  2092. {
  2093. { SDLInitMask(SdlElementManPage) , RegisterSnbLink },
  2094. { SDLInitMask(SdlElementNone) , NULL },
  2095. };
  2096. static SDLElementAttrList IdAndXidAttrList[] =
  2097. {
  2098. { SDL_ATTR_ID , SdlAttrValueRequired, NULL },
  2099. { SDL_ATTR_XID , SdlAttrValueRequired, NULL },
  2100. { -1 ,SdlAttrValueBad , NULL }
  2101. };
  2102. /*-----------------------------------------------------------------------------
  2103. <!ELEMENT textfile - O EMPTY >
  2104. <!ATTLIST textfile id ID #REQUIRED
  2105. xid CDATA #REQUIRED
  2106. offset CDATA #IMPLIED
  2107. format CDATA #IMPLIED >
  2108. -----------------------------------------------------------------------------*/
  2109. static SDLContent TextFileContent[] =
  2110. {
  2111. { SDLInitMask(SdlElementTextFile) , RegisterSnbLink },
  2112. { SDLInitMask(SdlElementNone) , NULL },
  2113. };
  2114. static SDLElementAttrList TextFileAttrList[] =
  2115. {
  2116. { SDL_ATTR_ID , SdlAttrValueRequired, NULL },
  2117. { SDL_ATTR_XID , SdlAttrValueRequired, NULL },
  2118. { SDL_ATTR_OFFSET , SdlAttrValueImplied , ZeroStr },
  2119. { SDL_ATTR_FORMAT , SdlAttrValueImplied , NULL },
  2120. { -1 ,SdlAttrValueBad , NULL }
  2121. };
  2122. /*-----------------------------------------------------------------------------
  2123. <!ELEMENT sys-cmd - O EMPTY >
  2124. <!ATTLIST sys-cmd id ID #REQUIRED
  2125. command CDATA #REQUIRED >
  2126. -----------------------------------------------------------------------------*/
  2127. static SDLContent SysCmdContent[] =
  2128. {
  2129. { SDLInitMask(SdlElementSysCmd) , RegisterSnbLink },
  2130. { SDLInitMask(SdlElementNone) , NULL },
  2131. };
  2132. static SDLElementAttrList SysCmdAttrList[] =
  2133. {
  2134. { SDL_ATTR_ID , SdlAttrValueRequired, NULL },
  2135. { SDL_ATTR_COMMAND , SdlAttrValueRequired, NULL },
  2136. { -1 ,SdlAttrValueBad , NULL }
  2137. };
  2138. /*-----------------------------------------------------------------------------
  2139. <!ELEMENT callback - O EMPTY >
  2140. <!ATTLIST callback id ID #REQUIRED
  2141. data CDATA #IMPLIED >
  2142. -----------------------------------------------------------------------------*/
  2143. static SDLContent CallbackContent[] =
  2144. {
  2145. { SDLInitMask(SdlElementCallback) , RegisterSnbLink },
  2146. { SDLInitMask(SdlElementNone) , NULL },
  2147. };
  2148. static SDLElementAttrList CallbackAttrList[] =
  2149. {
  2150. { SDL_ATTR_ID , SdlAttrValueRequired, NULL },
  2151. { SDL_ATTR_DATA , SdlAttrValueImplied , NULL },
  2152. { -1 ,SdlAttrValueBad , NULL }
  2153. };
  2154. /*-----------------------------------------------------------------------------
  2155. <!-- The switch element is always hyperlinked to. The interpreter,
  2156. - interp, is called passing the CDATA content and returning a number
  2157. - 0 to n. The return value of the interpreter is used to index into
  2158. - the list of branches and the hyperlink is continued to that ID. A
  2159. - return value less than zero or greater than the number of IDs minus
  2160. - 1 causes the hyperlink to continue to branch 0.
  2161. -->
  2162. <!ELEMENT switch - - CDATA >
  2163. <!ATTLIST switch id ID #REQUIRED
  2164. -- processor should default interp to "ksh" --
  2165. interp NOTATION
  2166. (tcl |
  2167. sh |
  2168. ksh |
  2169. csh ) #IMPLIED
  2170. branches IDREFS #REQUIRED >
  2171. -----------------------------------------------------------------------------*/
  2172. static SDLContent SwitchContent[] =
  2173. {
  2174. { SDLInitMask(SdlElementSwitch), SetType },
  2175. { SDLInitMask(SdlElementCdata) , ZeroOrOne },
  2176. { SDLInitMask(SdlElementSwitch), RegisterSwitch },
  2177. { SDLInitMask(SdlElementNone) , NULL },
  2178. };
  2179. static SDLElementAttrList SwitchAttrList[] =
  2180. {
  2181. { SDL_ATTR_ID , SdlAttrValueRequired, NULL },
  2182. { SDL_ATTR_INTERP , SdlAttrValueImplied , "ksh" },
  2183. { SDL_ATTR_BRANCHES , SdlAttrValueRequired, NULL },
  2184. { -1 , SdlAttrValueBad , NULL }
  2185. };
  2186. /*-----------------------------------------------------------------------------
  2187. <!-- Generated Elements ______________________________________________-->
  2188. <!ELEMENT rel-docs - O EMPTY >
  2189. <!ELEMENT rel-file - O EMPTY >
  2190. <!ELEMENT notes - O EMPTY >
  2191. <!-- The list of identifiers, loids, element is a list of ids in this
  2192. document in the order they are defined. The "count" attribute of
  2193. loids is the number of ids it contains. The higher level DTD to
  2194. SDL translator may precompute "count" to enable the processor to
  2195. preallocate space for the ids. If "count" is not present, the
  2196. processor must compute the number itself from the document. The
  2197. "type" attribute of id is the name of the element to which the
  2198. id belongs. The "rid" (referenced identifier) attribute is the
  2199. identifier being listed. The "rssi" (referenced source semantic
  2200. identifier) is the "ssi" of the element to which the identifier
  2201. belongs. Similarly, the "rlevel" (referenced level) attribute
  2202. is the "level" of the element to which the identifier belongs.
  2203. Finally, the "offset" attribute is the byte offset in the document
  2204. to the start of the virtual page containing the identifier. -->
  2205. <!ELEMENT loids - - (id*) >
  2206. <!ATTLIST loids count NUMBER #IMPLIED >
  2207. -----------------------------------------------------------------------------*/
  2208. static SDLContent LoidsContent[] = {
  2209. { SDLInitMask(SdlElementLoids), AllocateBlock },
  2210. { SDLInitMask(SdlElementId) , ZeroToN },
  2211. { SDLInitMask(SdlElementLoids), CleanUpBlock },
  2212. { SDLInitMask(SdlElementNone) , NULL },
  2213. };
  2214. static SDLElementAttrList LoidsAttrList[] =
  2215. {
  2216. { SDL_ATTR_COUNT, SdlAttrValueImplied, NULL },
  2217. { -1 , SdlAttrValueBad , NULL }
  2218. };
  2219. /*-----------------------------------------------------------------------------
  2220. <!ELEMENT id - O EMPTY >
  2221. <!ATTLIST id type (virpage |
  2222. block |
  2223. form |
  2224. p |
  2225. cp |
  2226. head |
  2227. subhead |
  2228. anchor |
  2229. switch |
  2230. snref |
  2231. graphic |
  2232. text |
  2233. audio |
  2234. video |
  2235. animate |
  2236. crossdoc |
  2237. man-page |
  2238. textfile |
  2239. sys-cmd |
  2240. script |
  2241. callback ) #REQUIRED
  2242. rid IDREF #REQUIRED
  2243. rssi CDATA #IMPLIED
  2244. rlevel NUMBER #IMPLIED
  2245. offset NUMBER #REQUIRED >
  2246. -----------------------------------------------------------------------------*/
  2247. static SDLContent IdContent[] = {
  2248. { SDLInitMask(SdlElementId) , CopyIdInfo },
  2249. { SDLInitMask(SdlElementNone) , NULL },
  2250. };
  2251. static SDLElementAttrList IdAttrList[] =
  2252. {
  2253. { SDL_ATTR_TYPEID , SdlAttrValueRequired, NULL },
  2254. { SDL_ATTR_RID , SdlAttrValueRequired, NULL },
  2255. { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr },
  2256. { SDL_ATTR_RSSI , SdlAttrValueImpliedDef, NULL },
  2257. { SDL_ATTR_OFFSET , SdlAttrValueRequired, NULL },
  2258. { -1 , SdlAttrValueBad , NULL }
  2259. };
  2260. /*-----------------------------------------------------------------------------
  2261. <!-- An index consists of zero or more entries. Each entry contains
  2262. the indexed (rich) text. The "count" attribute of index is the
  2263. number of entries (recursively) it contains. The higher level
  2264. DTD to SDL translator may precompute "count" to enable the
  2265. processor to preallocate space for the entries. If "count" is
  2266. not present, the processor must compute the number itself from
  2267. the document. The "locs" and "main" attributes of an entry are
  2268. lists of ids where the entry may be found. Those ids found on
  2269. the "main" list may be highlighted or emphasized in some way to
  2270. indicate a greater importance than the ids found on the "locs"
  2271. list - a definition, for example. Otherwise, ids found on the
  2272. "locs" list and the "main" list behave identically. The "syns"
  2273. attribute of an entry is another list of ids that refer to other
  2274. entry elements and correspond to a "See also" or synonym type
  2275. reference in an index. The "sort" attribute is an optional sort
  2276. key to be used if the indexed entry is to be sorted other than
  2277. by its content. The index should be pre-sorted although the
  2278. optional sort keys are preserved in case multiple indexes need
  2279. to be merged at some later date. An entry element may also
  2280. contain other entries to allow a hierarchical index to be
  2281. generated. -->
  2282. <!ELEMENT index - - (entry*) >
  2283. <!ATTLIST index head CDATA #IMPLIED
  2284. count NUMBER #IMPLIED >
  2285. -----------------------------------------------------------------------------*/
  2286. static SDLContent IndexContent[] = {
  2287. { SDLInitMask(SdlElementEntry), ZeroToN },
  2288. { SDLInitMask(SdlElementNone) , NULL },
  2289. };
  2290. static SDLElementAttrList IndexAttrList[] =
  2291. {
  2292. { SDL_ATTR_COUNT, SdlAttrValueImplied, NULL },
  2293. { -1 , SdlAttrValueBad , NULL }
  2294. };
  2295. /*-----------------------------------------------------------------------------
  2296. <!ELEMENT entry - - ((%simple; | #PCDATA)*, entry*) >
  2297. <!ATTLIST entry id ID #IMPLIED
  2298. main IDREFS #IMPLIED
  2299. locs IDREFS #IMPLIED
  2300. syns IDREFS #IMPLIED
  2301. sort CDATA #IMPLIED >
  2302. -----------------------------------------------------------------------------*/
  2303. static SDLContent EntryContent[] = {
  2304. { SDLInitMask(SdlElementEntry), CopyEntryInfo },
  2305. { SDL_ENTITY_SIMPLE , ZeroToN },
  2306. { SDLInitMask(SdlElementEntry), ZeroToN },
  2307. { SDLInitMask(SdlElementNone) , NULL },
  2308. };
  2309. static SDLElementAttrList EntryAttrList[] =
  2310. {
  2311. { SDL_ATTR_ID ,SdlAttrValueImpliedDef , NULL },
  2312. { SDL_ATTR_MAIN ,SdlAttrValueImpliedDef , NULL },
  2313. { SDL_ATTR_LOCS ,SdlAttrValueImpliedDef , NULL },
  2314. { SDL_ATTR_SYNS ,SdlAttrValueImpliedDef , NULL },
  2315. { SDL_ATTR_SORT ,SdlAttrValueImpliedDef , NULL },
  2316. { -1 ,SdlAttrValueBad , NULL }
  2317. };
  2318. /*-----------------------------------------------------------------------------
  2319. <!-- The lophrases (list of phrases) element is generated by the
  2320. higher level DTD to SDL translator. It is a list of phrases used
  2321. from the toss element content in this document. The phrases are
  2322. used to map the users knowledge domain into the constructs used
  2323. in SDL. This information can be used to to pass the phrases
  2324. available for structured/semantic searches to a browser or viewer
  2325. to allow that browser or viewer to offer that information to the
  2326. user. The "count" attribute of lophrases is the number of phrases
  2327. it contains. The higher level DTD to SDL translator may precompute
  2328. "count" to enable the processor to preallocate space for the
  2329. phrases. If "count" is not present, the processor must compute
  2330. the number itself from the document. -->
  2331. <!ELEMENT lophrases - - (phrase+) >
  2332. <!ATTLIST lophrases count NUMBER #IMPLIED >
  2333. -----------------------------------------------------------------------------*/
  2334. static SDLContent LoPhraseContent[] =
  2335. {
  2336. { SDLInitMask(SdlElementPhrase) , OneToN },
  2337. { SDLInitMask(SdlElementNone) , NULL },
  2338. };
  2339. static SDLElementAttrList LoPhraseAttrList[] =
  2340. {
  2341. { SDL_ATTR_COUNT, SdlAttrValueImplied, NULL },
  2342. { -1 , SdlAttrValueBad , NULL }
  2343. };
  2344. /*-----------------------------------------------------------------------------
  2345. <!ELEMENT phrase - O EMPTY >
  2346. <!ATTLIST phrase text CDATA #REQUIRED >
  2347. -----------------------------------------------------------------------------*/
  2348. static SDLElementAttrList PhraseAttrList[] =
  2349. {
  2350. { SDL_ATTR_TEXT , SdlAttrValueRequired, NULL },
  2351. { -1 ,SdlAttrValueBad , NULL }
  2352. };
  2353. /*-----------------------------------------------------------------------------
  2354. <!-- The following element, toss (table of semantics and styles), is
  2355. generated by the higher level DTD to SDL translator. The "count"
  2356. attribute of toss is the number of styles it contains. The
  2357. translator may precompute "count" to enable the processor to
  2358. preallocate space for the styles. If "count" is not present, the
  2359. processor must compute the number itself from the document. The
  2360. first three attributes of each sub-element are used for lookup in
  2361. the toss. When formatting an element, the toss is searched for a
  2362. With the exception of the XLFD and Windows typeface name, an
  2363. unspecified attribute implies inheritance.
  2364. The "phrase" attribute is an English (or natural language) phrase
  2365. describing the intended use (semantics) of an element of this
  2366. style. -->
  2367. <!ELEMENT toss - - (keystyle*,
  2368. headstyle*,
  2369. formstyle*,
  2370. frmtstyle*,
  2371. grphstyle*) >
  2372. <!ATTLIST toss count NUMBER #IMPLIED >
  2373. -----------------------------------------------------------------------------*/
  2374. static SDLContent TossContent[] = {
  2375. { SDLInitMask(SdlElementToss) , AllocateBlock },
  2376. { SDLInitMask(SdlElementKeyStyle) , ZeroToN },
  2377. { SDLInitMask(SdlElementHeadStyle), ZeroToN },
  2378. { SDLInitMask(SdlElementFormStyle), ZeroToN },
  2379. { SDLInitMask(SdlElementFrmtStyle), ZeroToN },
  2380. { SDLInitMask(SdlElementGrphStyle), ZeroToN },
  2381. { SDLInitMask(SdlElementToss) , CleanUpBlock },
  2382. { SDLInitMask(SdlElementNone) , NULL },
  2383. };
  2384. static SDLElementAttrList TossAttrList[] =
  2385. {
  2386. { SDL_ATTR_COUNT, SdlAttrValueImplied, NULL },
  2387. { -1 , SdlAttrValueBad , NULL }
  2388. };
  2389. /*-----------------------------------------------------------------------------
  2390. <!ELEMENT keystyle - O EMPTY >
  2391. <!ATTLIST keystyle class (%key-class;) #REQUIRED
  2392. ssi CDATA #IMPLIED
  2393. -- the level of the element being described --
  2394. rlevel NUMBER #IMPLIED
  2395. phrase CDATA #IMPLIED
  2396. -- likelihood that this element contains an --
  2397. -- actual hit when doing a full text search --
  2398. srch-wt NUMBER #IMPLIED
  2399. -- strings to emit on entry and exit from key --
  2400. enter CDATA #IMPLIED
  2401. exit CDATA #IMPLIED
  2402. %font-styles; >
  2403. -----------------------------------------------------------------------------*/
  2404. static SDLContent KeyStyleContent[] = {
  2405. { SDLInitMask(SdlElementKeyStyle) , CopyTossInfo },
  2406. { SDLInitMask(SdlElementNone) , NULL },
  2407. };
  2408. static SDLElementAttrList KeyStyleAttrList[] =
  2409. {
  2410. { SDL_ATTR_CLASSK , SdlAttrValueRequired , NULL },
  2411. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  2412. { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr },
  2413. { SDL_ATTR_PHRASE , SdlAttrValueImpliedDef, NULL },
  2414. { SDL_ATTR_SRCHWT , SdlAttrValueImplied , NegativeOneStr },
  2415. { SDL_ATTR_ENTER , SdlAttrValueImpliedDef, NULL },
  2416. { SDL_ATTR_EXIT , SdlAttrValueImpliedDef, NULL },
  2417. font_stylesAttrList,
  2418. { -1 , SdlAttrValueBad , NULL }
  2419. };
  2420. /*-----------------------------------------------------------------------------
  2421. <!ELEMENT headstyle - O EMPTY >
  2422. <!ATTLIST headstyle class (%head-class;) #REQUIRED
  2423. ssi CDATA #IMPLIED
  2424. -- the level of the element being described --
  2425. rlevel NUMBER #IMPLIED
  2426. phrase CDATA #IMPLIED
  2427. -- likelihood that this element contains an --
  2428. -- actual hit when doing a full text search --
  2429. srch-wt NUMBER #IMPLIED
  2430. -- horizontal orientation of the head with --
  2431. -- respect to its associated document, --
  2432. -- vstruct, virpage, snb, block, form, or p; --
  2433. -- or of the subhead with respect to its --
  2434. -- head. --
  2435. -- procsr shld dflt orient to "center-orient" --
  2436. orient (left-orient |
  2437. center-orient |
  2438. right-orient |
  2439. left-margin-orient |
  2440. right-margin-orient |
  2441. left-corner-orient |
  2442. right-corner-orient )
  2443. #IMPLIED
  2444. -- vertical orientation of the head or --
  2445. -- subhead with respect to its parent. --
  2446. -- procsor shld dflt vorient to "top-vorient" --
  2447. vorient (top-vorient |
  2448. bottom-vorient |
  2449. center-vorient ) #IMPLIED
  2450. -- This attribute applies to head elements --
  2451. -- only, since subheads cannot contain more --
  2452. -- subheads. The attribute determines --
  2453. -- whether the vorient attribute applies to --
  2454. -- the head only or to the entire head object --
  2455. -- including its subheads. --
  2456. -- processor shld deflt placement to "parent" --
  2457. placement (object | parent) #IMPLIED
  2458. -- Head width is the percent of the --
  2459. -- available space for this element that --
  2460. -- should be given to its head or the percent --
  2461. -- of the head that should be given to a --
  2462. -- subhead. It is expressed as a fixed point --
  2463. -- number 1 to 10000 with an implied decimal --
  2464. -- point two places to the left of the right --
  2465. -- side. --
  2466. -- processor should default headw to "10000" --
  2467. headw CDATA #IMPLIED
  2468. -- where to put this head or subhead if it --
  2469. -- collides with one already placed. --
  2470. -- Horizontal stacking means place this one --
  2471. -- under the other. Vertical stacking means --
  2472. -- place this one to the right of the other. --
  2473. -- processor should default stack to "vert" --
  2474. stack (horiz | vert) #IMPLIED
  2475. -- does the body wrap around the head text? --
  2476. -- "join" implies starting the content of the --
  2477. -- surrounding element immediatly after this --
  2478. -- head (i.e., on the same line as the bottom --
  2479. -- of this head).
  2480. -- processor should default flow to "nowrap" --
  2481. flow (wrap |
  2482. nowrap |
  2483. join) #IMPLIED
  2484. %font-styles;
  2485. %format-styles;
  2486. -- applies to the text in the element, not --
  2487. -- the element itself. --
  2488. -- prcsr shld dflt justify to "left-justify" --
  2489. justify ( left-justify |
  2490. right-justify |
  2491. center-justify |
  2492. numeric-justify ) #IMPLIED >
  2493. -----------------------------------------------------------------------------*/
  2494. static SDLContent HeadStyleContent[] = {
  2495. { SDLInitMask(SdlElementHeadStyle), CopyTossInfo },
  2496. { SDLInitMask(SdlElementNone) , NULL },
  2497. };
  2498. static SDLElementAttrList HeadStyleAttrList[] =
  2499. {
  2500. { SDL_ATTR_CLASSH , SdlAttrValueRequired , NULL },
  2501. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  2502. { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr },
  2503. { SDL_ATTR_PHRASE , SdlAttrValueImplied , NULL },
  2504. { SDL_ATTR_SRCHWT , SdlAttrValueImplied , NegativeOneStr },
  2505. { SDL_ATTR_ORIENT , SdlAttrValueImplied , CenterOrientStr},
  2506. { SDL_ATTR_VORIENT , SdlAttrValueImplied , TopVOrientStr },
  2507. { SDL_ATTR_HEADWDTH , SdlAttrValueImplied , TenThousandStr },
  2508. { SDL_ATTR_PLACEMENT, SdlAttrValueImpliedDef, ParentStr },
  2509. { SDL_ATTR_STACK , SdlAttrValueImpliedDef, "vert" },
  2510. { SDL_ATTR_FLOW , SdlAttrValueImplied , NoWrapStr },
  2511. font_stylesAttrList ,
  2512. formt_stylesAttrList,
  2513. { SDL_ATTR_JUSTIFY1 , SdlAttrValueImplied , LeftJustifyStr },
  2514. { -1 , SdlAttrValueBad , NULL }
  2515. };
  2516. /*-----------------------------------------------------------------------------
  2517. <!ELEMENT formstyle - O EMPTY >
  2518. <!ATTLIST formstyle class (%format-class;) #REQUIRED
  2519. ssi CDATA #IMPLIED
  2520. -- the level of the element being described --
  2521. rlevel NUMBER #IMPLIED
  2522. phrase CDATA #IMPLIED
  2523. -- likelihood that this element contains an --
  2524. -- actual hit when doing a full text search --
  2525. srch-wt NUMBER #IMPLIED
  2526. -- The widths of the columns in this form, --
  2527. -- colw, is a space separated list of comma --
  2528. -- separated integral triples. If only two --
  2529. -- comma separated numbers in a triple are --
  2530. -- given, the second is replicated to make --
  2531. -- three. If only one number is given, the --
  2532. -- other two are assumed to be 0. The first --
  2533. -- number of a triple is the optimally --
  2534. -- desired width. The second number is how --
  2535. -- much the column is willing to grow --
  2536. -- relative to the other columns. The third --
  2537. -- number is how much the column is willing --
  2538. -- to shrink relative to the other columns. --
  2539. -- The numbers are summed and the total is --
  2540. -- taken as 100 percent of available space. --
  2541. -- That space is then divided among the --
  2542. -- columns. The process of summing and --
  2543. -- dividing is repeated until all the --
  2544. -- desired/shrink/grow constraints are met or --
  2545. -- it is known to be impossible to meet them. --
  2546. -- If meeting the constraints is impossible, --
  2547. -- the column is handled similarly to a --
  2548. -- graphic that will not fit, e.g., a scroll- --
  2549. -- bar may be added to allow the form to be --
  2550. -- larger than the size of the viewing area. --
  2551. -- There should be as many triples as given --
  2552. -- in the value "ncols" in the "fstyle" sub- --
  2553. -- element of the form element to which this --
  2554. -- "formstyle" is being applied. Extra --
  2555. -- triples are ignored. If less than "ncols" --
  2556. -- triples are provided, the last triple is --
  2557. -- replicated. --
  2558. colw CDATA #IMPLIED
  2559. -- Column justification, taken from one of --
  2560. -- l | r | c | d (left, right, centered and --
  2561. -- decimal), separated by spaces, for each --
  2562. -- column of the form. Extras are ignored. --
  2563. -- If there are fewer than the number of --
  2564. -- columns specified by the "ncols" attribute --
  2565. -- of the "fstyle" subelement of the "form" --
  2566. -- to which this "formstyle" is being --
  2567. -- applied, the last value is replicated. --
  2568. -- The value defaults to "l" (left justified) --
  2569. colj CDATA #IMPLIED
  2570. %font-styles;
  2571. %format-styles; >
  2572. -----------------------------------------------------------------------------*/
  2573. static SDLContent FormStyleContent[] = {
  2574. { SDLInitMask(SdlElementFormStyle), CopyTossInfo },
  2575. { SDLInitMask(SdlElementNone) , NULL },
  2576. };
  2577. static SDLElementAttrList FormStyleAttrList[] =
  2578. {
  2579. { SDL_ATTR_CLASSF , SdlAttrValueRequired , NULL },
  2580. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  2581. { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr },
  2582. { SDL_ATTR_PHRASE , SdlAttrValueImplied , NULL },
  2583. { SDL_ATTR_SRCHWT , SdlAttrValueImplied , NegativeOneStr },
  2584. { SDL_ATTR_COLW , SdlAttrValueImpliedDef, NULL },
  2585. { SDL_ATTR_COLJ , SdlAttrValueImpliedDef, NULL },
  2586. font_stylesAttrList,
  2587. formt_stylesAttrList,
  2588. { -1 , SdlAttrValueBad , NULL }
  2589. };
  2590. /*-----------------------------------------------------------------------------
  2591. <!ELEMENT frmtstyle - O EMPTY >
  2592. <!ATTLIST frmtstyle class (%format-class;) #REQUIRED
  2593. ssi CDATA #IMPLIED
  2594. -- the level of the element being described --
  2595. rlevel NUMBER #IMPLIED
  2596. phrase CDATA #IMPLIED
  2597. -- first line lmargin may be negative but --
  2598. -- it's a number used to indicate extension --
  2599. -- or indentation at start --
  2600. -- processor should default f-margin to "0" --
  2601. f-margin CDATA #IMPLIED
  2602. -- likelihood that this element contains an --
  2603. -- actual hit when doing a full text search --
  2604. srch-wt NUMBER #IMPLIED
  2605. %font-styles;
  2606. %format-styles;
  2607. -- applies to the text in the element, not --
  2608. -- the element itself. --
  2609. -- prcsr shld dflt justify to "left-justify" --
  2610. justify ( left-justify |
  2611. right-justify |
  2612. center-justify |
  2613. numeric-justify ) #IMPLIED >
  2614. -----------------------------------------------------------------------------*/
  2615. static SDLContent FrmtStyleContent[] = {
  2616. { SDLInitMask(SdlElementFrmtStyle), CopyTossInfo },
  2617. { SDLInitMask(SdlElementNone) , NULL },
  2618. };
  2619. static SDLElementAttrList FrmtStyleAttrList[] =
  2620. {
  2621. { SDL_ATTR_CLASSF , SdlAttrValueRequired , NULL },
  2622. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  2623. { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr },
  2624. { SDL_ATTR_PHRASE , SdlAttrValueImplied , NULL },
  2625. { SDL_ATTR_SRCHWT , SdlAttrValueImplied , NegativeOneStr },
  2626. { SDL_ATTR_FMARGIN , SdlAttrValueImplied , ZeroStr },
  2627. font_stylesAttrList ,
  2628. formt_stylesAttrList,
  2629. { SDL_ATTR_JUSTIFY1 , SdlAttrValueImplied , LeftJustifyStr },
  2630. { -1 , SdlAttrValueBad , NULL }
  2631. };
  2632. /*----------------------------------------------------------------------------- <!ELEMENT grphstyle - O EMPTY >
  2633. <!ATTLIST grphstyle class (%graphic-class;) #REQUIRED
  2634. ssi CDATA #IMPLIED
  2635. -- the level of the element being described --
  2636. rlevel NUMBER #IMPLIED
  2637. phrase CDATA #IMPLIED
  2638. %format-styles;
  2639. -- applies to the text in the element, not --
  2640. -- the element itself. --
  2641. -- prcsr shld dflt justify to "left-justify" --
  2642. justify ( left-justify |
  2643. right-justify |
  2644. center-justify ) #IMPLIED >
  2645. ] >
  2646. -----------------------------------------------------------------------------*/
  2647. static SDLContent GrphStyleContent[] = {
  2648. { SDLInitMask(SdlElementGrphStyle), CopyTossInfo },
  2649. { SDLInitMask(SdlElementNone) , NULL },
  2650. };
  2651. static SDLElementAttrList GrphStyleAttrList[] =
  2652. {
  2653. { SDL_ATTR_CLASSG , SdlAttrValueRequired , NULL },
  2654. { SDL_ATTR_SSI , SdlAttrValueImpliedDef, NULL },
  2655. { SDL_ATTR_RLEVEL , SdlAttrValueImplied , NegativeOneStr },
  2656. { SDL_ATTR_PHRASE , SdlAttrValueImplied , NULL },
  2657. formt_stylesAttrList,
  2658. { SDL_ATTR_JUSTIFY2 , SdlAttrValueImplied , LeftJustifyStr },
  2659. { -1 , SdlAttrValueBad , NULL }
  2660. };
  2661. static SDLContent CdataContent[] = {
  2662. { SDLInitMask(SdlElementCdata), Cdata },
  2663. { SDLInitMask(SdlElementNone) , NULL },
  2664. };
  2665. static SDLContent SDLDocumentContent[] = {
  2666. { SDLInitMask(SdlElementSgml) , ZeroOrOne },
  2667. { SDLInitMask(SdlElementDocType), ZeroOrOne },
  2668. { SDLInitMask(SdlElementSdlDoc) , OnlyOne },
  2669. { SDLInitMask(SdlElementNone) , NULL },
  2670. };
  2671. /*
  2672. * entries in this structure:
  2673. * all 'element strings' must start with '<'
  2674. * all 'element end strings' must start with '</'
  2675. *
  2676. * If they don't, _DtHelpCeReturnSdlElement will fail
  2677. */
  2678. static SDLElementInfo SdlElementList[] =
  2679. {
  2680. {"<alttext" , "</alttext" , 3, 3,
  2681. SdlElementAltText ,
  2682. SDLInitMask(SdlElementNone),
  2683. NULL , AltTextContent ,
  2684. False, False, False , False, SdlToSnb },
  2685. {AnchorStr , NULL , 4, 0,
  2686. SdlElementAnchor ,
  2687. SDLInitMask(SdlElementNone),
  2688. AnchorAttrList , AnchorContent ,
  2689. False, True , False , False, SdlToMarker },
  2690. {AnimateStr , NULL , 4, 0,
  2691. SdlElementAnimate ,
  2692. SDLInitMask(SdlElementNone),
  2693. NotationAttrList , NULL ,
  2694. False, True , False , False, SdlToNone },
  2695. {AudioStr , NULL , 3, 0,
  2696. SdlElementAudio ,
  2697. SDLInitMask(SdlElementNone),
  2698. NotationAttrList , NULL ,
  2699. False, True , False , False, SdlToNone },
  2700. {BlockStr , "</block" , 2, 3,
  2701. SdlElementBlock ,
  2702. SDLInitMask(SdlElementNone),
  2703. BlockAttrList , BlockContent ,
  2704. False, True, True , True , SdlToContainer },
  2705. {CallbackStr , NULL , 3, 0,
  2706. SdlElementCallback ,
  2707. SDLInitMask(SdlElementNone),
  2708. CallbackAttrList , CallbackContent ,
  2709. True , False, False , False, SdlToContainer },
  2710. {"<cond" , "</cond" , 3, 4,
  2711. SdlElementCond ,
  2712. SDLInitMask(SdlElementNone),
  2713. CondAttrList , CondContent ,
  2714. False, True , False , False, SdlToContainer },
  2715. {CParaStr , "</cp" , 3, 3,
  2716. SdlElementCPara ,
  2717. SDLInitMask(SdlElementNone),
  2718. ParaAttrList , CParaContent ,
  2719. True , True, True , True , SdlToContainer },
  2720. {CrossdocStr , NULL , 3, 0,
  2721. SdlElementCrossDoc ,
  2722. SDLInitMask(SdlElementNone),
  2723. IdAndXidAttrList , CrossDocContent ,
  2724. True , True , False , False, SdlToContainer },
  2725. {"<else" , "</else" , 3, 4,
  2726. SdlElementElse ,
  2727. SDLInitMask(SdlElementNone),
  2728. NULL , ThenElseContent ,
  2729. False, False, False , False, SdlToContainer },
  2730. {"<entry" , "</entry" , 3, 4,
  2731. SdlElementEntry ,
  2732. SDLInitMask(SdlElementNone),
  2733. EntryAttrList , EntryContent ,
  2734. False, True , False , False, SdlToContainer },
  2735. {"<fdata" , "</fdata" , 3, 4,
  2736. SdlElementFdata ,
  2737. SDLInitMask(SdlElementNone),
  2738. NULL , FdataContent ,
  2739. False, False, False , False, SdlToNone },
  2740. /*
  2741. * when one element is a short version of another, put the longer element
  2742. * before the short element so that tests will check it first.
  2743. */
  2744. {"<formstyle", NULL , 6, 0,
  2745. SdlElementFormStyle ,
  2746. SDLInitMask(SdlElementNone),
  2747. FormStyleAttrList , FormStyleContent,
  2748. False, True , False , False, SdlToContainer },
  2749. {FormStr , "</form" , 5, 4,
  2750. SdlElementForm ,
  2751. SDLInitMask(SdlElementNone),
  2752. FormAttrList , FormContent ,
  2753. False, True , False , True , SdlToContainer },
  2754. {"<frmtstyle", NULL , 4, 0,
  2755. SdlElementFrmtStyle ,
  2756. SDLInitMask(SdlElementNone),
  2757. FrmtStyleAttrList , FrmtStyleContent,
  2758. False, True , False , False, SdlToContainer },
  2759. {"<frowvec" , NULL , 4, 0,
  2760. SdlElementFrowvec ,
  2761. SDLInitMask(SdlElementNone),
  2762. FrowvecAttrList , FrowvecContent ,
  2763. False, True , False , False, SdlToNone },
  2764. {"<fstyle" , "</fstyle" , 3, 4,
  2765. SdlElementFstyle ,
  2766. SDLInitMask(SdlElementNone),
  2767. FstyleAttrList , FstyleContent ,
  2768. False, True , False , False, SdlToNone },
  2769. { GraphicStr , NULL , 4, 0,
  2770. SdlElementGraphic ,
  2771. SDLInitMask(SdlElementNone),
  2772. NotationAttrList , GraphicContent ,
  2773. True , True , False , False, SdlToSnb },
  2774. {"<grphstyle", NULL , 4, 0,
  2775. SdlElementGrphStyle ,
  2776. SDLInitMask(SdlElementNone),
  2777. GrphStyleAttrList , GrphStyleContent,
  2778. False, True , False , False, SdlToContainer },
  2779. /*
  2780. * when one element is a short version of another, put the longer element
  2781. * before the short element so that tests will check it first.
  2782. */
  2783. {"<headstyle", NULL , 6, 0,
  2784. SdlElementHeadStyle ,
  2785. SDLInitMask(SdlElementNone),
  2786. HeadStyleAttrList , HeadStyleContent,
  2787. False, True , True , False, SdlToContainer },
  2788. { HeadStr , "</head" , 5, 6,
  2789. SdlElementHead ,
  2790. SDLInitMask(SdlElementNone),
  2791. HeadAttrList , HeadContent ,
  2792. False, True , True , True , SdlToContainer },
  2793. {"<id" , NULL , 3, 0,
  2794. SdlElementId ,
  2795. SDLInitMask(SdlElementNone),
  2796. IdAttrList , IdContent ,
  2797. False, True , False , False, SdlToContainer },
  2798. {"<if" , "</if" , 3, 4,
  2799. SdlElementIf ,
  2800. SDLInitMask(SdlElementNone),
  2801. NULL , IfContent ,
  2802. False, False, False , False, SdlToContainer },
  2803. {"<index" , "</index" , 3, 4,
  2804. SdlElementIndex ,
  2805. SDLInitMask(SdlElementNone),
  2806. IndexAttrList , IndexContent ,
  2807. False, True , False , False, SdlToContainer },
  2808. {"<keystyle" , NULL , 6, 0,
  2809. SdlElementKeyStyle ,
  2810. SDLInitMask(SdlElementNone),
  2811. KeyStyleAttrList , KeyStyleContent ,
  2812. False, True , False , False, SdlToContainer },
  2813. {"<key" , "</key" , 4, 3,
  2814. SdlElementKey ,
  2815. SDLInitMask(SdlElementLink),
  2816. KeyAttrList , KeyContent ,
  2817. True , True , False , True , SdlToContainer },
  2818. {"<link" , "</link" , 3, 4,
  2819. SdlElementLink ,
  2820. SDLInitMask(SdlElementLink),
  2821. LinkAttrList , LinkContent,
  2822. False, True , False , False, SdlToContainer },
  2823. {"<loids" , "</loids" , 4, 5,
  2824. SdlElementLoids ,
  2825. SDLInitMask(SdlElementNone),
  2826. LoidsAttrList , LoidsContent,
  2827. False, True , False , False, SdlToContainer },
  2828. {"<lophrases", "</lophrases", 4, 5,
  2829. SdlElementLoPhrases ,
  2830. SDLInitMask(SdlElementNone),
  2831. LoPhraseAttrList , LoPhraseContent,
  2832. False, True , False , False, SdlToNone },
  2833. {ManpageStr , NULL , 2, 0,
  2834. SdlElementManPage ,
  2835. SDLInitMask(SdlElementNone),
  2836. IdAndXidAttrList , ManPageContent,
  2837. True , True , False , False, SdlToContainer },
  2838. {"<notes" , NULL , 2, 0,
  2839. SdlElementNotes ,
  2840. SDLInitMask(SdlElementNone),
  2841. NULL , NULL ,
  2842. False, True , False , False, SdlToNone },
  2843. {"<phrase" , NULL , 3, 0,
  2844. SdlElementPhrase ,
  2845. SDLInitMask(SdlElementNone),
  2846. PhraseAttrList , NULL ,
  2847. False, True , False , False, SdlToNone },
  2848. {ParaStr , "</p" , 2, 3,
  2849. SdlElementPara ,
  2850. SDLInitMask(SdlElementNone),
  2851. ParaAttrList , ParaContent,
  2852. True , True , False , True , SdlToContainer },
  2853. {"<refitem" , "</refitem" , 4, 5,
  2854. SdlElementRefItem ,
  2855. SDLInitMask(SdlElementNone),
  2856. RefItemAttrList , RefItemContent,
  2857. False, True , False , True , SdlToSnb },
  2858. {"<rel-docs" , NULL , 6, 0,
  2859. SdlElementRelDocs ,
  2860. SDLInitMask(SdlElementNone),
  2861. NULL , NULL ,
  2862. False, False, False , False, SdlToNone },
  2863. {"<rel-file" , NULL , 6, 0,
  2864. SdlElementRelFile ,
  2865. SDLInitMask(SdlElementNone),
  2866. NULL , NULL ,
  2867. False, False, False , False, SdlToNone },
  2868. {"<rev" , "</rev" , 4, 5,
  2869. SdlElementRev ,
  2870. SDLInitMask(SdlElementRev),
  2871. NULL , RevContent ,
  2872. True , False, False , False, SdlToNone },
  2873. {ScriptStr , "</script" , 3, 4,
  2874. SdlElementScript ,
  2875. SDLInitMask(SdlElementNone),
  2876. ScriptAttrList , ScriptContent ,
  2877. False, True , False , False, SdlToSnb },
  2878. {"<sdldoc" , "</sdldoc" , 3, 4,
  2879. SdlElementSdlDoc ,
  2880. SDLInitMask(SdlElementNone),
  2881. SdlDocAttrList , SdlDocContent ,
  2882. False, True , False , False, SdlToContainer },
  2883. {"<snb" , "</snb" , 4, 5,
  2884. SdlElementSnb ,
  2885. SDLInitMask(SdlElementNone),
  2886. SnbAttrList , SnbContent ,
  2887. False, True , False , False, SdlToContainer },
  2888. {SnrefStr , "</snref" , 4, 5,
  2889. SdlElementSnRef ,
  2890. SDLInitMask(SdlElementNone),
  2891. SnrefAttrList , SnrefContent ,
  2892. False, True , False , False, SdlToContainer },
  2893. {"<spc" , NULL , 4, 0,
  2894. SdlElementSpc ,
  2895. SDLInitMask(SdlElementNone),
  2896. SpcAttrList , SpcContent ,
  2897. False, True , False , False, SdlToSpc },
  2898. {"<sphrase" , "</sphrase>", 4, 4,
  2899. SdlElementSphrase ,
  2900. SDLInitMask(SdlElementNone),
  2901. SphraseAttrList , SphraseContent ,
  2902. False, True , False , True , SdlToContainer },
  2903. { SubHeadStr , "</subhead" , 3, 4,
  2904. SdlElementSubHead ,
  2905. SDLInitMask(SdlElementNone),
  2906. HeadAttrList , SubHeadContent,
  2907. False, True , True , True , SdlToContainer },
  2908. { SwitchStr , "</switch" , 3, 4,
  2909. SdlElementSwitch ,
  2910. SDLInitMask(SdlElementNone),
  2911. SwitchAttrList , SwitchContent ,
  2912. True , True , False , False, SdlToContainer },
  2913. {SyscmdStr , NULL , 3, 0,
  2914. SdlElementSysCmd ,
  2915. SDLInitMask(SdlElementNone),
  2916. SysCmdAttrList , SysCmdContent ,
  2917. True , True , False , False, SdlToContainer },
  2918. {TextfileStr , NULL , 6, 0,
  2919. SdlElementTextFile ,
  2920. SDLInitMask(SdlElementNone),
  2921. TextFileAttrList , TextFileContent,
  2922. True , True , False , False, SdlToContainer },
  2923. {TextStr , "</text" , 4, 4,
  2924. SdlElementText ,
  2925. SDLInitMask(SdlElementNone),
  2926. TextAttrList , TextContent ,
  2927. True , False, False , False, SdlToSnb },
  2928. {"<then" , "</then" , 3, 4,
  2929. SdlElementThen ,
  2930. SDLInitMask(SdlElementNone),
  2931. NULL , ThenElseContent,
  2932. False, False, False , False, SdlToContainer },
  2933. {"<toss" , "</toss" , 3, 4,
  2934. SdlElementToss ,
  2935. SDLInitMask(SdlElementNone),
  2936. TossAttrList , TossContent ,
  2937. False, True , False , False, SdlToContainer },
  2938. {VideoStr , NULL , 4, 0,
  2939. SdlElementVideo ,
  2940. SDLInitMask(SdlElementNone),
  2941. NotationAttrList , NULL ,
  2942. False, True , False , False, SdlToNone },
  2943. {VirpageStr , "</virpage" , 4, 4,
  2944. SdlElementVirpage ,
  2945. SDLInitMask(SdlElementNone),
  2946. VirpageAttrList , VirpageContent,
  2947. False, True , False , True , SdlToContainer },
  2948. {VirpageStr , "</virpage" , 4, 4,
  2949. SdlElementTitle ,
  2950. SDLInitMask(SdlElementNone),
  2951. VirpageAttrList , VirpageHeadContent,
  2952. False, True , False , True , SdlToContainer },
  2953. {"<vstruct" , "</vstruct" , 3, 4,
  2954. SdlElementVStruct ,
  2955. SDLInitMask(SdlElementNone),
  2956. VStructAttrList , VStructContent,
  2957. False, True , False , False, SdlToNone },
  2958. {"<!--" , NULL , 3, 0,
  2959. SdlElementComment ,
  2960. SDLInitMask(SdlElementNone),
  2961. NULL , NULL ,
  2962. False, True , False , False, SdlToNone },
  2963. {"<!doctype" , NULL , 3, 0,
  2964. SdlElementDocType ,
  2965. SDLInitMask(SdlElementNone),
  2966. NULL , NULL ,
  2967. False, True , False , False, SdlToNone },
  2968. {"<!sgml" , NULL , 3, 0,
  2969. SdlElementSgml ,
  2970. SDLInitMask(SdlElementNone),
  2971. NULL , NULL ,
  2972. False, True , False , False, SdlToNone },
  2973. { NULL , NULL , 0, 0,
  2974. SdlElementCdata ,
  2975. SDLInitMask(SdlElementNone),
  2976. NULL , CdataContent ,
  2977. False, False, False , False, SdlToNone },
  2978. };
  2979. static int MaxSDLElements = sizeof (SdlElementList) / sizeof (SDLElementInfo);
  2980. /******************************************************************************
  2981. * Private Macros
  2982. *****************************************************************************/
  2983. #define MyFree(x) if ((char *)(x) != NULL) free(x)
  2984. #define SaveRestoreMask(x,y) \
  2985. { register int myI;\
  2986. for (myI = 0; myI < SDL_MASK_LEN; myI++) \
  2987. x[myI] = y[myI]; \
  2988. }
  2989. #define MergeMasks(x,y) \
  2990. { register int myI;\
  2991. for (myI = 0; myI < SDL_MASK_LEN; myI++) \
  2992. x[myI] |= y[myI]; \
  2993. }
  2994. #define RemoveMasks(x,y) \
  2995. { register int myI;\
  2996. for (myI = 0; myI < SDL_MASK_LEN; myI++) \
  2997. x[myI] &= (~(y[myI])); \
  2998. }
  2999. #define MaskToValue(x,y) \
  3000. { register int myI;\
  3001. register SDLMask myMask;\
  3002. for (myI = 0, y = 0; myI < SDL_MASK_LEN; myI++) \
  3003. if (x[myI] == 0) \
  3004. y += SDL_MASK_SIZE; \
  3005. else \
  3006. { \
  3007. myMask = x[myI]; \
  3008. while (myMask > 1) \
  3009. { \
  3010. myMask = myMask >> 1; y++; \
  3011. } \
  3012. myI = SDL_MASK_LEN; \
  3013. } \
  3014. }
  3015. #define ClearAttrFlag(pa, attr) \
  3016. { \
  3017. int mask = attr & VALUE_MASK; \
  3018. int flag = ~(attr & (~VALUE_MASK)); \
  3019. \
  3020. if (mask == ENUM_VALUE) \
  3021. (pa).enum_values = (pa).enum_values & flag; \
  3022. else if (mask == NUMBER_VALUE) \
  3023. (pa).num_values = (pa).num_values & flag; \
  3024. else if (mask == STRING1_VALUE) \
  3025. (pa).str1_values = (pa).str1_values & flag; \
  3026. else if (mask == STRING2_VALUE) \
  3027. (pa).str2_values = (pa).str2_values & flag; \
  3028. }
  3029. /******************************************************************************
  3030. *
  3031. * Private Functions
  3032. *
  3033. *****************************************************************************/
  3034. /******************************************************************************
  3035. * Function: CompressTable
  3036. *
  3037. *****************************************************************************/
  3038. static _DtCvSegment *
  3039. CompressTable(
  3040. FormatStruct *my_struct,
  3041. _DtCvSegment *seg)
  3042. {
  3043. _DtCvSegment *retSeg = seg;
  3044. _DtCvSegment **tableSegs;
  3045. char **rowIds;
  3046. /*
  3047. * make sure we're working with a non-null segment.
  3048. */
  3049. if (NULL != seg)
  3050. {
  3051. /*
  3052. * get the row ids.
  3053. */
  3054. rowIds = _DtCvCellIdsOfTableSeg(seg);
  3055. /*
  3056. * if there is only one column and zero to one rows,
  3057. * compress out the table
  3058. */
  3059. if (1 == _DtCvNumColsOfTableSeg(seg) &&
  3060. (NULL == rowIds || NULL == *rowIds || NULL == rowIds[1]))
  3061. {
  3062. /*
  3063. * get the list of table segments.
  3064. */
  3065. tableSegs = _DtCvCellsOfTableSeg(seg);
  3066. /*
  3067. * now find the correct segment. Start out with a null return.
  3068. */
  3069. retSeg = NULL;
  3070. if (NULL != rowIds && NULL != *rowIds)
  3071. {
  3072. _DtCvSegment *prevSeg = NULL;
  3073. /*
  3074. * look through the table's list for the one segment
  3075. * to fill the one column/row table.
  3076. */
  3077. while (NULL != tableSegs && NULL != *tableSegs &&
  3078. _DtCvStrCaseCmpLatin1(*rowIds, _DtCvContainerIdOfSeg(*tableSegs)))
  3079. {
  3080. prevSeg = *tableSegs;
  3081. tableSegs++;
  3082. }
  3083. /*
  3084. * does the segment exist in the table's list?
  3085. */
  3086. if (NULL != tableSegs && NULL != *tableSegs)
  3087. {
  3088. /*
  3089. * set the return value.
  3090. */
  3091. retSeg = *tableSegs;
  3092. /*
  3093. * now propagate the justification.
  3094. */
  3095. if (_DtCvINHERIT == _DtCvContainerJustifyOfSeg(retSeg)
  3096. && NULL != _DtCvColJustifyOfTableSeg(seg))
  3097. _DtCvContainerJustifyOfSeg(retSeg) =
  3098. *(_DtCvColJustifyOfTableSeg(seg));
  3099. /*
  3100. * now move up any other table segments, whereby
  3101. * eliminating this segment from the list so it
  3102. * won't be freed via _DtHelpFreeSegments().
  3103. */
  3104. while (NULL != *tableSegs)
  3105. {
  3106. *tableSegs = tableSegs[1];
  3107. tableSegs++;
  3108. }
  3109. }
  3110. }
  3111. /*
  3112. * Now free the table segment
  3113. */
  3114. _DtHelpFreeSegments(seg, _DtCvFALSE,
  3115. my_struct->ui_info->destroy_region,
  3116. my_struct->ui_info->client_data);
  3117. }
  3118. }
  3119. return retSeg;
  3120. }
  3121. /******************************************************************************
  3122. * Function: PropagateJustification
  3123. *
  3124. *****************************************************************************/
  3125. static void
  3126. PropagateJustification(
  3127. _DtCvSegment *seg,
  3128. _DtCvFrmtOption justify)
  3129. {
  3130. if (NULL != seg && _DtCvIsSegContainer(seg) &&
  3131. _DtCvINHERIT == _DtCvContainerJustifyOfSeg(seg))
  3132. _DtCvContainerJustifyOfSeg(seg) = justify;
  3133. }
  3134. /******************************************************************************
  3135. * Function: void FreeAttributes (enum SdlElement element,
  3136. * CESDLAttrStruct *attributes)
  3137. *
  3138. * Parameters:
  3139. *
  3140. * Returns:
  3141. *
  3142. * Purpose:
  3143. *
  3144. ******************************************************************************/
  3145. static void
  3146. FreeAttributes(
  3147. enum SdlElement element,
  3148. ElementInfo *cur_info,
  3149. _DtHelpFontHints *font_specs)
  3150. {
  3151. register int i = 0;
  3152. const SDLElementAttrList *myList;
  3153. const SDLAttribute *attrib;
  3154. char *varOffset;
  3155. char **strPtr;
  3156. while (i < MaxSDLElements && SdlElementList[i].sdl_element != element)
  3157. i++;
  3158. myList = SdlElementList[i].attrib_list;
  3159. if (myList != NULL &&
  3160. (cur_info->str1_values != 0 || cur_info->str2_values != 0))
  3161. {
  3162. while (myList->sdl_attr_define != -1)
  3163. {
  3164. if (SDLIsStrAttrSet(*cur_info, myList->sdl_attr_define) &&
  3165. SDLIsAttrSet(*cur_info, myList->sdl_attr_define))
  3166. {
  3167. attrib = SDLAttributeList;
  3168. while (attrib->sdl_attr_define != -1 &&
  3169. !ATTRS_EQUAL(attrib->data_type,
  3170. myList->sdl_attr_define,
  3171. attrib->sdl_attr_define))
  3172. attrib++;
  3173. if (attrib->struct_type == SdlFontSpecific ||
  3174. attrib->struct_type == SdlElementSpecific)
  3175. {
  3176. if (attrib->struct_type == SdlFontSpecific)
  3177. varOffset = ((char *) font_specs);
  3178. else if (attrib->struct_type == SdlElementSpecific)
  3179. varOffset = ((char *) cur_info);
  3180. varOffset = varOffset + attrib->field_ptr;
  3181. strPtr = (char **) varOffset;
  3182. if (NULL != *strPtr)
  3183. free (*strPtr);
  3184. }
  3185. }
  3186. myList++;
  3187. }
  3188. }
  3189. }
  3190. /******************************************************************************
  3191. * Function: DuplicateElement
  3192. *
  3193. *****************************************************************************/
  3194. static _DtCvSegment *
  3195. DuplicateElement(
  3196. _DtCvPointer client_data,
  3197. _DtCvSegment *toss,
  3198. _DtCvSegment *src_seg,
  3199. _DtCvSegment **prev_data,
  3200. _DtCvSegment **last_seg,
  3201. void (*load_font)(),
  3202. _DtCvValue (*resolve_spc)(),
  3203. _DtCvUnit line_height,
  3204. int ave_char,
  3205. _DtHelpFontHints srcFonts,
  3206. int link_idx,
  3207. _DtCvValue vis_link)
  3208. {
  3209. int oldIndex = link_idx;
  3210. _DtCvSegment *topSeg = NULL;
  3211. _DtCvSegment *prevData = NULL;
  3212. _DtCvSegment *lastSeg = NULL;
  3213. _DtCvSegment *newSeg;
  3214. _DtHelpFontHints curFonts;
  3215. SdlMatchData *match;
  3216. _DtHelpDARegion *region;
  3217. FrmtPrivateInfo *priv;
  3218. if (NULL != prev_data)
  3219. prevData = *prev_data;
  3220. if (NULL != last_seg)
  3221. lastSeg = *last_seg;
  3222. while (src_seg != NULL)
  3223. {
  3224. curFonts = srcFonts;
  3225. link_idx = oldIndex;
  3226. if (_DtCvIsSegHyperText(src_seg) || _DtCvIsSegGhostLink(src_seg))
  3227. {
  3228. link_idx = src_seg->link_idx;
  3229. if (_DtCvIsSegHyperText(src_seg))
  3230. vis_link = True;
  3231. }
  3232. if (_DtHelpCeAllocSegment(1, NULL, NULL, &newSeg) != 0)
  3233. return NULL;
  3234. /*
  3235. * copy over the information. (But don't blow away the private
  3236. * information, except - keep the dup flag.)
  3237. */
  3238. priv = FrmtPrivInfoPtr(newSeg);
  3239. *newSeg = *src_seg;
  3240. newSeg->client_use = priv;
  3241. priv->dup_flag = FrmtPrivInfoPtr(src_seg)->dup_flag;
  3242. /*
  3243. * set the duplicate on the source seg. That way, allocated memory
  3244. * now belongs to the new segment.
  3245. */
  3246. SetDupFlag(src_seg);
  3247. /*
  3248. * now re-set some information pertinent to this flow of control
  3249. */
  3250. newSeg->link_idx = link_idx;
  3251. newSeg->type = ClearSegLinks(newSeg);
  3252. if (link_idx != -1)
  3253. {
  3254. if (vis_link == True)
  3255. newSeg->type = _DtCvSetTypeToHyperText(newSeg->type);
  3256. else
  3257. newSeg->type = _DtCvSetTypeToGhostLink(newSeg->type);
  3258. }
  3259. _DtCvNextSeg(newSeg) = NULL;
  3260. newSeg->next_disp = NULL;
  3261. /*
  3262. * put this segment into the list.
  3263. */
  3264. if (NULL != lastSeg)
  3265. _DtCvNextSeg(lastSeg) = newSeg;
  3266. /*
  3267. * type cast the internal structure to a match data struct
  3268. * now, since more than one element may use it.
  3269. */
  3270. match = SegMatchDataPtr(src_seg);
  3271. switch (_DtCvPrimaryTypeOfSeg(newSeg))
  3272. {
  3273. case _DtCvCONTAINER:
  3274. /*
  3275. * merge the attributes into the new elements.
  3276. */
  3277. if (NULL != match)
  3278. {
  3279. if (NULL != toss)
  3280. {
  3281. _DtHelpCeMergeSdlAttribInfo(
  3282. _DtHelpCeMatchSemanticStyle(
  3283. toss,
  3284. match->clan,
  3285. match->level,
  3286. match->ssi),
  3287. newSeg,
  3288. &curFonts,
  3289. NULL,
  3290. NULL,
  3291. NULL);
  3292. /*
  3293. * set the margins to absolute values
  3294. */
  3295. if (ave_char > 0)
  3296. {
  3297. _DtCvContainerLMarginOfSeg(newSeg) =
  3298. _DtCvContainerLMarginOfSeg(newSeg) * ave_char;
  3299. _DtCvContainerRMarginOfSeg(newSeg) =
  3300. _DtCvContainerRMarginOfSeg(newSeg) * ave_char;
  3301. _DtCvContainerFMarginOfSeg(newSeg) =
  3302. _DtCvContainerFMarginOfSeg(newSeg) * ave_char;
  3303. }
  3304. /*
  3305. * set the top and bottom margins to absolute values
  3306. */
  3307. if (line_height > 0)
  3308. {
  3309. TMarginOfSeg(newSeg) =
  3310. TMarginOfSeg(newSeg) * line_height;
  3311. BMarginOfSeg(newSeg) =
  3312. BMarginOfSeg(newSeg) * line_height;
  3313. }
  3314. }
  3315. }
  3316. _DtCvContainerListOfSeg(newSeg) = DuplicateElement(
  3317. client_data,
  3318. toss,
  3319. _DtCvContainerListOfSeg(src_seg),
  3320. &prevData,
  3321. &lastSeg,
  3322. load_font,
  3323. resolve_spc,
  3324. line_height,
  3325. ave_char,
  3326. curFonts,
  3327. link_idx,
  3328. vis_link);
  3329. if (NULL == _DtCvContainerListOfSeg(newSeg))
  3330. {
  3331. free(newSeg);
  3332. return NULL;
  3333. }
  3334. /*
  3335. * if this is a wrapper, throw it away
  3336. */
  3337. if (IsSdlWrapper(newSeg->type))
  3338. {
  3339. _DtCvSegment *tmpSeg = newSeg;
  3340. newSeg = _DtCvContainerListOfSeg(newSeg);
  3341. free(tmpSeg);
  3342. }
  3343. break;
  3344. case _DtCvSTRING:
  3345. /*
  3346. * now load the font for this element
  3347. */
  3348. (load_font)(client_data,
  3349. _DtHelpFontHintsLang(curFonts),
  3350. _DtHelpFontHintsCharSet(curFonts),
  3351. curFonts,
  3352. &(_DtCvFontOfStringSeg(newSeg)));
  3353. /*
  3354. * put this segment in the display list.
  3355. */
  3356. if (NULL != prevData)
  3357. prevData->next_disp = newSeg;
  3358. prevData = newSeg;
  3359. break;
  3360. case _DtCvREGION:
  3361. region = (_DtHelpDARegion *) _DtCvInfoOfRegionSeg(src_seg);
  3362. if (False == region->inited)
  3363. {
  3364. _DtHelpDASpcInfo *spcInfo =
  3365. (_DtHelpDASpcInfo *) region->handle;
  3366. (resolve_spc)(client_data,
  3367. _DtHelpFontHintsLang(curFonts),
  3368. _DtHelpFontHintsCharSet(curFonts),
  3369. curFonts,
  3370. spcInfo->name,
  3371. &(_DtCvInfoOfRegionSeg(newSeg)),
  3372. &(_DtCvWidthOfRegionSeg(newSeg)),
  3373. &(_DtCvHeightOfRegionSeg(newSeg)),
  3374. &(_DtCvAscentOfRegionSeg(newSeg)));
  3375. ClearDupFlag(src_seg);
  3376. }
  3377. /*
  3378. * check for in-line flags on this item.
  3379. */
  3380. if (NULL != match &&
  3381. (SdlClassInLine == match->clan ||
  3382. SdlClassButton == match->clan ||
  3383. SdlClassIcon == match->clan))
  3384. newSeg->type = _DtCvSetTypeToInLine(newSeg->type);
  3385. /*
  3386. * put this segment in the display list.
  3387. */
  3388. if (NULL != prevData)
  3389. prevData->next_disp = newSeg;
  3390. prevData = newSeg;
  3391. break;
  3392. }
  3393. if (topSeg == NULL)
  3394. topSeg = newSeg;
  3395. lastSeg = newSeg;
  3396. src_seg = _DtCvNextSeg(src_seg);
  3397. }
  3398. if (NULL != prev_data)
  3399. *prev_data = prevData;
  3400. if (NULL != last_seg)
  3401. *last_seg = lastSeg;
  3402. return topSeg;
  3403. }
  3404. /******************************************************************************
  3405. * Function: _DtCvSegment *ResolveSnref (FormatStruct my_struct,
  3406. * int element_types,
  3407. * int exceptions);
  3408. *
  3409. * Parameters:
  3410. *
  3411. * Returns: 0 if successful, -1 if errors
  3412. *
  3413. * Purpose: Looks for the virtual page attributes.
  3414. *
  3415. ******************************************************************************/
  3416. static _DtCvSegment *
  3417. ResolveSnref(
  3418. FormatStruct *my_struct,
  3419. _DtCvSegment *snref,
  3420. char *snref_id)
  3421. {
  3422. _DtCvValue found = False;
  3423. _DtCvSegment *snbEntry = NULL;
  3424. _DtCvSegment *altText = NULL;
  3425. _DtCvSegment *newSeg = NULL;
  3426. _DtCvSegment *refItem = _DtCvContainerListOfSeg(snref);
  3427. FrmtPrivateInfo *priv;
  3428. _DtHelpFontHints saveFonts = *(my_struct->my_fonts);
  3429. /*
  3430. * Check to see if a snb has been found yet. If not, put off resolving
  3431. * refitems.
  3432. */
  3433. if (NULL != my_struct->snb)
  3434. {
  3435. /*
  3436. * check each refitem to see if it can be resolved
  3437. */
  3438. while (False == found && NULL != refItem)
  3439. {
  3440. /*
  3441. * assume the refitem will be found in the snb
  3442. */
  3443. found = True;
  3444. snbEntry = NULL;
  3445. if (NULL != _DtCvContainerIdOfSeg(refItem))
  3446. snbEntry = FindSnbEntry(my_struct->snb,
  3447. _DtCvContainerIdOfSeg(refItem));
  3448. else
  3449. /* the <alttext> container */
  3450. altText = refItem;
  3451. if (NULL == snbEntry)
  3452. {
  3453. /*
  3454. * didn't find the refitem, so set the flag
  3455. * for another loop.
  3456. */
  3457. found = False;
  3458. refItem = _DtCvNextSeg(refItem);
  3459. }
  3460. }
  3461. /*
  3462. * was a system notation block item found?
  3463. */
  3464. if (True == found)
  3465. {
  3466. /*
  3467. * an refitem can be a region (graphic, audio, video, animate),
  3468. * text or a script. If a script, need to process it differently.
  3469. */
  3470. priv = FrmtPrivInfoPtr(snbEntry);
  3471. if (SdlElementScript == priv->sdl_el_type)
  3472. {
  3473. /*
  3474. * NULL variables, get the interpretor.
  3475. */
  3476. SdlMatchData *match;
  3477. char *runData;
  3478. char *newData = NULL;
  3479. char *interpStr = GetInterpCmd((SdlOption) (priv->interp));
  3480. /*
  3481. * get the data to run
  3482. */
  3483. runData = _DtCvStringOfStringSeg(
  3484. _DtCvContainerListOfSeg(snbEntry));
  3485. if (NULL == interpStr
  3486. || -1 == _DtCvRunInterp(my_struct->ui_info->exec_filter,
  3487. my_struct->ui_info->client_data,
  3488. interpStr, runData, &newData)
  3489. || NULL == newData || 0 == strlen(newData))
  3490. return NULL;
  3491. /*
  3492. * set the match data for toss lookup
  3493. */
  3494. match = SegMatchDataPtr(refItem);
  3495. if (NULL != match && NULL != my_struct->toss)
  3496. _DtHelpCeMergeSdlAttribInfo(
  3497. _DtHelpCeMatchSemanticStyle(
  3498. my_struct->toss,
  3499. match->clan,
  3500. match->level,
  3501. match->ssi),
  3502. newSeg,
  3503. my_struct->my_fonts,
  3504. NULL,
  3505. NULL,
  3506. NULL);
  3507. if (0 != MySaveString(&newSeg, my_struct, newData,
  3508. my_struct->cur_link, my_struct->mb_len,
  3509. False))
  3510. return NULL;
  3511. free(newData);
  3512. }
  3513. else
  3514. {
  3515. /*
  3516. * strip the container wrapper from the snbEntry before
  3517. * duplication.
  3518. *
  3519. * Also, include the toss match data for this segment
  3520. * in the snbEntry.
  3521. */
  3522. snbEntry = _DtCvContainerListOfSeg(snbEntry);
  3523. if (NULL != snbEntry)
  3524. {
  3525. SegMatchData(snbEntry) = SegMatchData(refItem);
  3526. newSeg = DuplicateElement(my_struct->ui_info->client_data,
  3527. my_struct->toss,
  3528. snbEntry,
  3529. &(my_struct->prev_data),
  3530. NULL,
  3531. my_struct->ui_info->load_font,
  3532. my_struct->ui_info->resolve_spc,
  3533. my_struct->ui_info->line_height / 2,
  3534. my_struct->ui_info->avg_char,
  3535. *(my_struct->my_fonts),
  3536. my_struct->cur_link, True);
  3537. SegMatchData(snbEntry) = NULL;
  3538. if (NULL == newSeg)
  3539. return NULL;
  3540. /*
  3541. * if the only item in the list for the snb entry is
  3542. * a region, then assume it is a graphic, video, etc.
  3543. * Check to see if the region is in-line or a figure.
  3544. * If in-line, ignore any heads with the refitem. If a
  3545. * figure, include them (they may be a caption to the
  3546. * region).
  3547. */
  3548. if (_DtCvIsSegRegion(newSeg) && NULL == _DtCvNextSeg(newSeg))
  3549. {
  3550. SdlMatchData *info = SegMatchDataPtr(refItem);
  3551. /*
  3552. * is this a figure?
  3553. */
  3554. if (SdlClassFigure == info->clan)
  3555. {
  3556. _DtCvNextSeg(newSeg) = _DtCvContainerListOfSeg(refItem);
  3557. _DtCvContainerListOfSeg(refItem) = NULL;
  3558. }
  3559. }
  3560. }
  3561. }
  3562. }
  3563. /*
  3564. * was there alternate text?
  3565. */
  3566. else if (NULL != altText && NULL != _DtCvContainerListOfSeg(altText))
  3567. {
  3568. /*
  3569. * the new segment becomes the contents of the <alttext>
  3570. * container - why copy? Just null the <alttext> pointer
  3571. * to prevent the free from destroying the contents.
  3572. */
  3573. newSeg = _DtCvContainerListOfSeg(altText);
  3574. _DtCvContainerListOfSeg(altText) = NULL;
  3575. /*
  3576. * load the font for this snref.
  3577. */
  3578. (my_struct->ui_info->load_font)(my_struct->ui_info->client_data,
  3579. _DtHelpFontHintsLang(*(my_struct->my_fonts)),
  3580. _DtHelpFontHintsCharSet(*(my_struct->my_fonts)),
  3581. *(my_struct->my_fonts),
  3582. &(_DtCvFontOfStringSeg(newSeg)));
  3583. }
  3584. if (my_struct->prev_data != NULL)
  3585. my_struct->prev_data->next_disp = newSeg;
  3586. my_struct->last_was_space = False;
  3587. my_struct->last_was_mb = False;
  3588. my_struct->last_was_nl = False;
  3589. if (NULL != newSeg)
  3590. my_struct->prev_data = newSeg;
  3591. }
  3592. else if (_DtCvTRUE == my_struct->save_snref)
  3593. {
  3594. int count = my_struct->snref_cnt;
  3595. if (NULL == my_struct->un_snrefs)
  3596. my_struct->un_snrefs = (UnresSnref *) malloc (sizeof(UnresSnref));
  3597. else
  3598. my_struct->un_snrefs = (UnresSnref *) realloc (
  3599. (void *) my_struct->un_snrefs,
  3600. (sizeof(UnresSnref) * (count + 1)));
  3601. if (NULL != my_struct->un_snrefs)
  3602. {
  3603. my_struct->un_snrefs[count].id = snref_id;
  3604. my_struct->un_snrefs[count].seg = snref;
  3605. my_struct->un_snrefs[count].cur_link = my_struct->cur_link;
  3606. my_struct->un_snrefs[count].fonts = *(my_struct->my_fonts);
  3607. my_struct->snref_cnt++;
  3608. /*
  3609. * return the snref segment as our new segment to act as a
  3610. * place holder, otherwise it gets squeezed
  3611. * out.
  3612. */
  3613. newSeg = snref;
  3614. if (my_struct->prev_data != NULL)
  3615. my_struct->prev_data->next_disp = newSeg;
  3616. my_struct->prev_data = newSeg;
  3617. /*
  3618. * make the snref a noop so it gets the proper next/last
  3619. * display pointers.
  3620. */
  3621. newSeg->type = _DtCvSetTypeToNoop(newSeg->type);
  3622. }
  3623. }
  3624. *(my_struct->my_fonts) = saveFonts;
  3625. return newSeg;
  3626. } /* End ResolveSnref */
  3627. /******************************************************************************
  3628. * Function: static CEFontSpecs AllocateFontInfo(my_struct);
  3629. *
  3630. * Parameters:
  3631. *
  3632. * Returns: non-null if successful, NULL if errors
  3633. *
  3634. * Purpose: Allocates a FontInfo structure and intializes it to
  3635. * the current fonts hints.
  3636. *
  3637. ******************************************************************************/
  3638. static _DtHelpFontHints *
  3639. AllocateFontInfo(
  3640. FormatStruct *my_struct)
  3641. {
  3642. _DtHelpFontHints *retFont = NULL;
  3643. if (my_struct->free_cnt > 0)
  3644. retFont = my_struct->free_fonts[--my_struct->free_cnt];
  3645. else
  3646. {
  3647. /*
  3648. * malloc and initialize the starting font information
  3649. */
  3650. retFont = (_DtHelpFontHints *) malloc (sizeof(_DtHelpFontHints));
  3651. if (NULL == retFont)
  3652. return NULL;
  3653. }
  3654. /*
  3655. * initialize the font structure
  3656. */
  3657. if (NULL != my_struct->my_fonts)
  3658. *retFont = *(my_struct->my_fonts);
  3659. else
  3660. *retFont = DefFontInfo;
  3661. return retFont;
  3662. }
  3663. /******************************************************************************
  3664. * Function: static _DtCvSegment **ConvertToList(segs);
  3665. *
  3666. * Parameters:
  3667. *
  3668. * Returns: non-null if successful, NULL if errors
  3669. *
  3670. * Purpose: Allocates a list of null terminated _DtCvSegment pointers.
  3671. *
  3672. ******************************************************************************/
  3673. static _DtCvSegment **
  3674. ConvertToList(_DtCvSegment *segs)
  3675. {
  3676. _DtCvSegment **ptr = NULL;
  3677. /*
  3678. * count the segments
  3679. */
  3680. while (NULL != segs)
  3681. {
  3682. _DtCvSegment *next;
  3683. ptr = (_DtCvSegment **) _DtCvAddPtrToArray ((void **) ptr,
  3684. (void *) segs);
  3685. next = _DtCvNextSeg(segs);
  3686. _DtCvNextSeg(segs) = NULL;
  3687. segs = next;
  3688. }
  3689. return (ptr);
  3690. }
  3691. /******************************************************************************
  3692. * Function: static int DestroyFontInfo(my_struct);
  3693. *
  3694. * Parameters:
  3695. *
  3696. * Returns: 0 if successful, -1 if errors
  3697. *
  3698. * Purpose: Places the font structure in the free list for re-use.
  3699. *
  3700. ******************************************************************************/
  3701. static void
  3702. DestroyFontInfo(
  3703. FormatStruct *my_struct)
  3704. {
  3705. /*
  3706. * free the font structures allocated
  3707. */
  3708. while (0 < my_struct->free_cnt)
  3709. {
  3710. my_struct->free_cnt--;
  3711. free(my_struct->free_fonts[my_struct->free_cnt]);
  3712. }
  3713. if (NULL != my_struct->free_fonts)
  3714. free(my_struct->free_fonts);
  3715. my_struct->free_fonts = NULL;
  3716. if (NULL != my_struct->my_fonts)
  3717. free(my_struct->my_fonts);
  3718. }
  3719. /******************************************************************************
  3720. * Function: static int FreeFontInfo(my_struct);
  3721. *
  3722. * Parameters:
  3723. *
  3724. * Returns: 0 if successful, -1 if errors
  3725. *
  3726. * Purpose: Places the font structure in the free list for re-use.
  3727. *
  3728. ******************************************************************************/
  3729. static int
  3730. FreeFontInfo(
  3731. FormatStruct *my_struct)
  3732. {
  3733. if (my_struct->free_cnt >= my_struct->free_max)
  3734. {
  3735. my_struct->free_max += GROW_SIZE;
  3736. if (NULL != my_struct->free_fonts)
  3737. my_struct->free_fonts = (_DtHelpFontHints **) realloc (
  3738. my_struct->free_fonts,
  3739. sizeof(_DtHelpFontHints *) * my_struct->free_max);
  3740. else
  3741. my_struct->free_fonts = (_DtHelpFontHints **) malloc (
  3742. sizeof(_DtHelpFontHints *) * my_struct->free_max);
  3743. if (NULL == my_struct->free_fonts)
  3744. return -1;
  3745. }
  3746. my_struct->free_fonts[my_struct->free_cnt++] = my_struct->my_fonts;
  3747. return 0;
  3748. }
  3749. /******************************************************************************
  3750. * Function: static int ResolveAsyncBlock(my_struct, table_seg);
  3751. *
  3752. * Parameters:
  3753. *
  3754. * Returns: 0 if successful, -1 if errors
  3755. *
  3756. * Purpose:
  3757. *
  3758. ******************************************************************************/
  3759. static int
  3760. ResolveAsyncBlock(
  3761. FormatStruct *my_struct,
  3762. _DtCvSegment *table_seg)
  3763. {
  3764. char c;
  3765. char *next;
  3766. char *start = NULL;
  3767. char **rowIds = _DtCvCellIdsOfTableSeg(table_seg);
  3768. _DtCvFrmtOption *colJ;
  3769. _DtCvSegment **cellSegs;
  3770. _DtCvSegment *newSeg;
  3771. _DtCvSegment *asyncSegs;
  3772. _DtCvValue found;
  3773. while (NULL != rowIds && NULL != *rowIds)
  3774. {
  3775. /*
  3776. * get the start of the row ids
  3777. */
  3778. next = *rowIds;
  3779. colJ = _DtCvColJustifyOfTableSeg(table_seg);
  3780. while (NULL != next && '\0' != *next)
  3781. {
  3782. /*
  3783. * skip leading spaces
  3784. */
  3785. while (' ' == *next) next++;
  3786. /*
  3787. * set the starting pointer.
  3788. */
  3789. start = next;
  3790. /*
  3791. * skip to the next delimitter.
  3792. */
  3793. while (' ' != *next && '\0' != *next) next++;
  3794. /*
  3795. * check for the id in the set of segments.
  3796. */
  3797. if (start != next)
  3798. {
  3799. /*
  3800. * save and replace the last character with a null byte.
  3801. */
  3802. c = *next;
  3803. *next = '\0';
  3804. /*
  3805. * get the cells in the table
  3806. */
  3807. cellSegs = _DtCvCellsOfTableSeg(table_seg);
  3808. /*
  3809. * check that one of these cells matches the id
  3810. */
  3811. found = False;
  3812. if (NULL != cellSegs)
  3813. {
  3814. while (False == found && NULL != *cellSegs)
  3815. {
  3816. if (_DtCvStrCaseCmpLatin1(
  3817. _DtCvContainerIdOfSeg(*cellSegs),
  3818. start) == 0)
  3819. found = True;
  3820. else
  3821. cellSegs++;
  3822. }
  3823. newSeg = *cellSegs;
  3824. }
  3825. /*
  3826. * the id did not match any of the cells in the table
  3827. * Look in the async list.
  3828. */
  3829. if (False == found)
  3830. {
  3831. asyncSegs = my_struct->async_blks;
  3832. while (False == found && NULL != asyncSegs)
  3833. {
  3834. if (_DtCvStrCaseCmpLatin1(
  3835. _DtCvContainerIdOfSeg(asyncSegs),
  3836. start) == 0)
  3837. found = True;
  3838. else
  3839. asyncSegs = _DtCvNextSeg(asyncSegs);
  3840. }
  3841. /*
  3842. * found one in the aysnc blocks
  3843. * Duplicate it.
  3844. */
  3845. if (True == found)
  3846. {
  3847. _DtCvSegment *lastSrc = NULL;
  3848. _DtCvSegment *lastNext = NULL;
  3849. /*
  3850. * break the link to the next segment
  3851. * or we'll copy this segment and all
  3852. * the next segments.
  3853. */
  3854. _DtCvSegment *nextSeg = _DtCvNextSeg(asyncSegs);
  3855. _DtCvNextSeg(asyncSegs) = NULL;
  3856. /*
  3857. * allocate a new segment for this async block.
  3858. */
  3859. newSeg = DuplicateElement(
  3860. my_struct->ui_info->client_data,
  3861. my_struct->toss,
  3862. asyncSegs, &lastSrc, &lastNext,
  3863. my_struct->ui_info->load_font,
  3864. my_struct->ui_info->resolve_spc,
  3865. my_struct->ui_info->line_height / 2,
  3866. my_struct->ui_info->avg_char,
  3867. *(my_struct->my_fonts),
  3868. -1, False);
  3869. /*
  3870. * restore the async seg linked list
  3871. */
  3872. _DtCvNextSeg(asyncSegs) = nextSeg;
  3873. /*
  3874. * check to see if anything was copied
  3875. */
  3876. if (NULL == newSeg)
  3877. return -1;
  3878. /*
  3879. * now place this segment in the list.
  3880. */
  3881. _DtCvCellsOfTableSeg(table_seg) = (_DtCvSegment **)
  3882. _DtCvAddPtrToArray(
  3883. (void **) _DtCvCellsOfTableSeg(table_seg),
  3884. (void *) newSeg);
  3885. }
  3886. }
  3887. /*
  3888. * replace the character.
  3889. */
  3890. *next = c;
  3891. }
  3892. colJ++;
  3893. }
  3894. /*
  3895. * check the next row
  3896. */
  3897. rowIds++;
  3898. }
  3899. return 0;
  3900. }
  3901. /******************************************************************************
  3902. * Function: static int FindSnb(my_struct, id);
  3903. *
  3904. * Parameters:
  3905. *
  3906. * Returns: 0 if successful, -1 if errors
  3907. *
  3908. * Purpose:
  3909. *
  3910. ******************************************************************************/
  3911. static _DtCvSegment *
  3912. FindSnbEntry(
  3913. _DtCvSegment *snb,
  3914. char *target)
  3915. {
  3916. char *id;
  3917. _DtCvSegment *retEntry;
  3918. if (NULL != snb)
  3919. {
  3920. retEntry = _DtCvContainerListOfSeg(snb);
  3921. while (NULL != retEntry)
  3922. {
  3923. id = NULL;
  3924. if (_DtCvIsSegContainer(retEntry))
  3925. id = _DtCvContainerIdOfSeg(retEntry);
  3926. if (NULL != id && _DtCvStrCaseCmpLatin1(target, id) == 0)
  3927. return retEntry;
  3928. retEntry = _DtCvNextSeg(retEntry);
  3929. }
  3930. }
  3931. return NULL;
  3932. }
  3933. /* A little helper function, acts like strcpy
  3934. * but safe for overlapping regions.
  3935. */
  3936. static void *strmove(void *dest, const void *src) {
  3937. memmove(dest, src, strlen(src) + 1);
  3938. }
  3939. /******************************************************************************
  3940. * Function: static int ProcessString(string, int idx);
  3941. *
  3942. * Parameters:
  3943. *
  3944. * Returns: 0 if successful, -1 if errors
  3945. *
  3946. * Purpose:
  3947. *
  3948. ******************************************************************************/
  3949. static int
  3950. ProcessString(
  3951. FormatStruct *my_struct,
  3952. _DtCvValue last_flag,
  3953. _DtCvValue nl_flag,
  3954. _DtCvValue mod_str,
  3955. _DtCvValue cpy_str,
  3956. _DtCvValue process_flag,
  3957. char *string,
  3958. int byte_len,
  3959. int *idx)
  3960. {
  3961. if (mod_str == True)
  3962. string[*idx] = '\0';
  3963. if (process_flag == True && MySaveString(&(my_struct->seg_list),
  3964. my_struct, string, my_struct->cur_link,
  3965. byte_len, nl_flag) != 0)
  3966. {
  3967. MyFree(string);
  3968. return -1;
  3969. }
  3970. my_struct->last_was_space = last_flag;
  3971. if (cpy_str == True)
  3972. {
  3973. strmove (string, &string[*idx+1]);
  3974. *idx = -1;
  3975. }
  3976. return 0;
  3977. }
  3978. /******************************************************************************
  3979. * Function: static void CompressLinkSeg(seg);
  3980. *
  3981. * Parameters:
  3982. *
  3983. * Returns: nothing
  3984. *
  3985. * Purpose: Check to see if there is a blank at the beginning of the
  3986. * segment and if it is needed.
  3987. *
  3988. ******************************************************************************/
  3989. static void
  3990. CompressLinkSeg(
  3991. _DtCvSegment *p_seg)
  3992. {
  3993. void *pChar;
  3994. int wcFlag;
  3995. /*
  3996. * check to see if the first segment is a string.
  3997. */
  3998. while (NULL != p_seg && _DtCvIsSegNoop(p_seg))
  3999. p_seg = _DtCvNextSeg(p_seg);
  4000. if (NULL == p_seg)
  4001. return;
  4002. if (_DtCvIsSegString(p_seg))
  4003. {
  4004. wcFlag = _DtCvIsSegWideChar(p_seg);
  4005. pChar = _DtCvStrPtr(_DtCvStringOfStringSeg(p_seg), wcFlag, 0);
  4006. /*
  4007. * is this the only segment in the link?
  4008. * Is it only one character in size?
  4009. */
  4010. if (NULL == _DtCvNextDisp(p_seg) && 1 <= _DtCvStrLen(pChar, wcFlag))
  4011. return;
  4012. /*
  4013. * is it a blank? (wide char and single char codes are equal
  4014. * for blanks - ISO standard)
  4015. */
  4016. if ((_DtCvIsSegWideChar(p_seg) && ' ' == *((wchar_t *) pChar)) ||
  4017. (_DtCvIsSegRegChar(p_seg) && ' ' == *((char *) pChar)))
  4018. {
  4019. /*
  4020. * compress out the blank
  4021. *
  4022. * is this a single byte string? If so, use strcpy to move
  4023. * the string.
  4024. */
  4025. if (_DtCvIsSegRegChar(p_seg))
  4026. strmove(((char *)pChar), &(((char *)pChar)[1]));
  4027. else
  4028. {
  4029. wchar_t *wcChar = (wchar_t *) pChar;
  4030. while (0 != wcChar[0])
  4031. {
  4032. wcChar[0] = wcChar[1];
  4033. wcChar++;
  4034. }
  4035. }
  4036. }
  4037. }
  4038. }
  4039. /******************************************************************************
  4040. * Function: static int ProcessNonBreakChar(string, int idx);
  4041. *
  4042. * Parameters:
  4043. *
  4044. * Returns: 0 if successful, -1 if errors
  4045. *
  4046. * Purpose:
  4047. *
  4048. ******************************************************************************/
  4049. static int
  4050. ProcessNonBreakChar(
  4051. FormatStruct *my_struct,
  4052. _DtCvValue process_flag,
  4053. char *break_str,
  4054. char *string,
  4055. int byte_len,
  4056. int *idx)
  4057. {
  4058. if (ProcessString(my_struct, False, False, True, False,
  4059. process_flag, string, byte_len, idx) != 0)
  4060. return -1;
  4061. my_struct->flags = _DtCvSetTypeToNonBreak(my_struct->flags);
  4062. if (ProcessString(my_struct, False, False, False, False,
  4063. process_flag, break_str, byte_len, idx) != 0)
  4064. return -1;
  4065. my_struct->flags = my_struct->flags & ~(_DtCvNON_BREAK);
  4066. strmove (string, &string[*idx+1]);
  4067. *idx = -1;
  4068. return 0;
  4069. }
  4070. /******************************************************************************
  4071. * Function: static int MoveString(string, int idx);
  4072. *
  4073. * Parameters:
  4074. *
  4075. * Returns: 0 if successful, -1 if errors
  4076. *
  4077. * Purpose:
  4078. *
  4079. ******************************************************************************/
  4080. static int
  4081. MoveString(
  4082. char **string,
  4083. int *max_len,
  4084. int *idx)
  4085. {
  4086. int i = *idx;
  4087. int myLen = *max_len;
  4088. char *src = *string;
  4089. i--;
  4090. if (i == -1)
  4091. {
  4092. if (strlen(src) == myLen)
  4093. {
  4094. src = (char *) realloc (src, myLen + 2);
  4095. if (src == NULL)
  4096. return -1;
  4097. myLen++;
  4098. *string = src;
  4099. *max_len = myLen;
  4100. }
  4101. for (i = myLen; i > 0; i--)
  4102. src[i] = src[i-1];
  4103. }
  4104. *idx = i;
  4105. return 0;
  4106. }
  4107. /******************************************************************************
  4108. * Function: int SetUp (_DtHelpVolumeHdl volume,
  4109. * CESDLVolume **sdl_vol,
  4110. * FormatStruct *frmt_struct,
  4111. * _DtCvSegment *toss,
  4112. * _DtCvSegment *cur_frmt,
  4113. * _DtCvValue lang
  4114. *
  4115. * Parameters:
  4116. * volume Specifies the volume handle. If non-NULL,
  4117. * create and return the sdl volume pointer
  4118. * in 'sdl_vol'.
  4119. * sdl_vol If not NULL, returns the sdl volume pointer.
  4120. * frmt_struct Specifies the formatting structure to use.
  4121. * toss Specifies the toss to use. If NULL and
  4122. * sdl_vol asked for and flag == True, the
  4123. * sdl_vol->toss will be used.
  4124. * lang Specifies if the language/charset should
  4125. * be set using information from the volume.
  4126. * flag Specifies if to get/use the sdl_vol->toss
  4127. * if toss is NULL.
  4128. *
  4129. * Returns: 0 if no failures, -1 if errors.
  4130. *
  4131. * Purpose: Set up the formatting structure to use.
  4132. *
  4133. *****************************************************************************/
  4134. static int
  4135. SetUp (
  4136. _DtHelpVolumeHdl volume,
  4137. CESDLVolume **sdl_vol,
  4138. FormatStruct *frmt_struct,
  4139. _DtCvSegment *toss,
  4140. const _FrmtUiInfo *ui_info,
  4141. int fd,
  4142. _DtCvValue lang,
  4143. _DtCvValue flag)
  4144. {
  4145. *frmt_struct = DefFormatStruct;
  4146. frmt_struct->my_links = _DtLinkDbCreate();
  4147. if (NULL == frmt_struct->my_links)
  4148. return -1;
  4149. if (volume != NULL && sdl_vol != NULL)
  4150. {
  4151. *sdl_vol = _DtHelpCeGetSdlVolumePtr(volume);
  4152. if (*sdl_vol == NULL)
  4153. {
  4154. _DtLinkDbDestroy(frmt_struct->my_links);
  4155. return -1;
  4156. }
  4157. }
  4158. /*
  4159. * malloc and initialize the starting font information
  4160. */
  4161. frmt_struct->my_fonts = AllocateFontInfo(frmt_struct);
  4162. if (NULL == frmt_struct->my_fonts)
  4163. {
  4164. _DtLinkDbDestroy(frmt_struct->my_links);
  4165. return -1;
  4166. }
  4167. if (volume != NULL)
  4168. {
  4169. frmt_struct->vol_name = _DtHelpCeGetVolumeName(volume);
  4170. if (toss == NULL && flag == True)
  4171. toss = _DtHelpCeGetSdlVolToss(volume, fd);
  4172. if (lang == True)
  4173. {
  4174. _DtHelpFontHintsLang(*(frmt_struct->my_fonts)) =
  4175. _DtHelpCeGetSdlVolLanguage(volume);
  4176. _DtHelpFontHintsCharSet(*(frmt_struct->my_fonts)) =
  4177. (char *) _DtHelpCeGetSdlVolCharSet(volume);
  4178. }
  4179. }
  4180. /*
  4181. * determine mb_len should be based on lang/charset.
  4182. */
  4183. frmt_struct->mb_len = _DtHelpCeGetMbLen(
  4184. _DtHelpFontHintsLang(*(frmt_struct->my_fonts)),
  4185. _DtHelpFontHintsCharSet(*(frmt_struct->my_fonts)));
  4186. frmt_struct->toss = toss;
  4187. frmt_struct->ui_info = ui_info;
  4188. return 0;
  4189. }
  4190. /******************************************************************************
  4191. * Function: void AddToAsyncList (_DtCvSegment *seg_list)
  4192. *
  4193. * Parameters:
  4194. *
  4195. * Returns Nothing
  4196. *
  4197. * Purpose: Add a segment block to the async list.
  4198. *
  4199. *****************************************************************************/
  4200. static void
  4201. AddToAsyncList (
  4202. FormatStruct *my_struct,
  4203. _DtCvSegment *block_seg)
  4204. {
  4205. if (my_struct->async_blks != NULL)
  4206. {
  4207. _DtCvSegment *pSeg = my_struct->async_blks;
  4208. while (_DtCvNextSeg(pSeg) != NULL)
  4209. pSeg = _DtCvNextSeg(pSeg);
  4210. _DtCvNextSeg(pSeg) = block_seg;
  4211. }
  4212. else
  4213. my_struct->async_blks = block_seg;
  4214. }
  4215. /******************************************************************************
  4216. * Function: int CheckOptionList (int attr_value_type, const char *attr,
  4217. * _DtCvValue check_flag,
  4218. * SdlOption cur_num,
  4219. * SdlOption *num);
  4220. *
  4221. * Parameters:
  4222. *
  4223. * Returns: 0 if successful, -1 if errors
  4224. *
  4225. * Purpose: If found, returns the enum value.
  4226. *
  4227. ******************************************************************************/
  4228. static int
  4229. CheckOptionList(
  4230. int attr_value_type,
  4231. const char *attr,
  4232. _DtCvValue check,
  4233. SdlOption cur_num,
  4234. SdlOption *num)
  4235. {
  4236. int i = 0;
  4237. int lowerChar;
  4238. int result = -1;
  4239. const OptionList *option;
  4240. _DtCvValue found = False;
  4241. _DtCvValue cmpFnd = False;
  4242. while (SDLOptionsList[i].attr_value != -1 &&
  4243. SDLOptionsList[i].attr_value != attr_value_type)
  4244. i++;
  4245. if (SDLOptionsList[i].attr_value != -1)
  4246. {
  4247. option = SDLOptionsList[i].options;
  4248. lowerChar = _DtHelpCeToLower(*attr);
  4249. while (option != NULL && option->string != NULL &&
  4250. (check == True || cmpFnd == False))
  4251. {
  4252. /*
  4253. * check to see if the current option is in the list
  4254. * of valid options for this attribute.
  4255. */
  4256. if (check && cur_num == option->option_value)
  4257. {
  4258. /*
  4259. * okay, it's been found, don't check anymore.
  4260. */
  4261. found = True;
  4262. check = False;
  4263. }
  4264. /*
  4265. * otherwise, find out if this value is a valid option
  4266. * for the attribute.
  4267. */
  4268. else if (cmpFnd == False &&
  4269. lowerChar == _DtHelpCeToLower(*(option->string)) &&
  4270. _DtCvStrCaseCmpLatin1(option->string, attr) == 0)
  4271. {
  4272. cmpFnd = True;
  4273. *num = option->option_value;
  4274. }
  4275. option++;
  4276. }
  4277. }
  4278. /*
  4279. * if found is true, means check was originally set to true and
  4280. * we found the current value in the option list for this attribute.
  4281. */
  4282. if (found == True)
  4283. *num = cur_num;
  4284. /*
  4285. * if we found that the current value was valid or that the string
  4286. * was a valid option in the list for the attribute, return no error.
  4287. */
  4288. if (found == True || cmpFnd == True)
  4289. result = 0;
  4290. return result;
  4291. }
  4292. /******************************************************************************
  4293. * Function: int CheckFontList (int attr_value_type, char *attr,
  4294. * enum CEFontSpec *num);
  4295. *
  4296. * Parameters:
  4297. *
  4298. * Returns: 0 if successful, -1 if errors
  4299. *
  4300. * Purpose: If found, returns the enum value.
  4301. *
  4302. ******************************************************************************/
  4303. static int
  4304. CheckFontList(
  4305. int attr_value_type,
  4306. char *attr,
  4307. _DtHelpFontValue *num)
  4308. {
  4309. int i = 0;
  4310. const FontSpecOption *option;
  4311. while (SDLFontList[i].attr_value != -1 &&
  4312. SDLFontList[i].attr_value != attr_value_type)
  4313. i++;
  4314. if (SDLFontList[i].attr_value != -1)
  4315. {
  4316. option = SDLFontList[i].options;
  4317. while (option != NULL && option->string != NULL)
  4318. {
  4319. if (_DtCvStrCaseCmpLatin1(option->string, attr) == 0)
  4320. {
  4321. *num = option->option_value;
  4322. return 0;
  4323. }
  4324. option++;
  4325. }
  4326. }
  4327. return -1;
  4328. }
  4329. /******************************************************************************
  4330. * Function: int LookAhead (FormatStruct my_struct, int token_value,
  4331. * int remove_flag);
  4332. *
  4333. * Parameters:
  4334. * my_struct Specifies the parsing structure.
  4335. * token_value Specifies the token to match
  4336. * remove_flag Specifies whether to clear the look ahead
  4337. * value. If True, will set the look ahead
  4338. * parsed value to invalid iff token_value
  4339. * equals the parsed look ahead value.
  4340. *
  4341. * Returns: 0 if token_value matched parsed value,
  4342. * 1 if parsed value is invalid.
  4343. * -1 if parsed value is valid but token_value did not match.
  4344. *
  4345. * Purpose:
  4346. *
  4347. ******************************************************************************/
  4348. static int
  4349. TestLookAhead(
  4350. FormatStruct *my_struct,
  4351. enum SdlElement token_value,
  4352. _DtCvValue end_flag,
  4353. int remove_flag)
  4354. {
  4355. if (my_struct->parsed == SdlElementNone)
  4356. return 1;
  4357. if (my_struct->parsed == token_value && my_struct->end_flag == end_flag)
  4358. {
  4359. if (remove_flag == True)
  4360. {
  4361. my_struct->parsed = SdlElementNone;
  4362. if (my_struct->remember != NULL)
  4363. {
  4364. free (my_struct->remember);
  4365. my_struct->remember = NULL;
  4366. }
  4367. }
  4368. return 0;
  4369. }
  4370. return -1;
  4371. }
  4372. /******************************************************************************
  4373. * Function: int MatchSDLElement (FormatStruct my_struct, sdl_string,
  4374. * int sdl_element, sig_chars)
  4375. *
  4376. * Parameters:
  4377. *
  4378. * Returns: 0 if successful, -1 if errors
  4379. *
  4380. * Purpose: Looks for the specific element.
  4381. *
  4382. ******************************************************************************/
  4383. static int
  4384. MatchSDLElement(
  4385. FormatStruct *my_struct,
  4386. const char *sdl_string,
  4387. enum SdlElement sdl_element,
  4388. int sig_chars,
  4389. _DtCvValue end_flag)
  4390. {
  4391. int i;
  4392. i = TestLookAhead(my_struct, sdl_element, end_flag, True);
  4393. if ( i != 1)
  4394. return i;
  4395. return (_DtHelpCeMatchSdlElement(my_struct->my_file,sdl_string,sig_chars));
  4396. }
  4397. /******************************************************************************
  4398. * Function: void SetAttributeFlag (
  4399. *
  4400. ******************************************************************************/
  4401. static void
  4402. SetAttributeFlag(
  4403. ElementInfoPtr cur_info,
  4404. unsigned long attr_define)
  4405. {
  4406. unsigned long flag = attr_define & ~(VALUE_MASK);
  4407. switch (attr_define & VALUE_MASK)
  4408. {
  4409. case ENUM_VALUE:
  4410. cur_info->enum_values |= flag;
  4411. break;
  4412. case STRING1_VALUE:
  4413. cur_info->str1_values |= flag;
  4414. break;
  4415. case STRING2_VALUE:
  4416. cur_info->str2_values |= flag;
  4417. break;
  4418. case NUMBER_VALUE:
  4419. cur_info->num_values |= flag;
  4420. break;
  4421. }
  4422. }
  4423. /******************************************************************************
  4424. * Function: void InitAttributes(SDLAttrStruct *as,
  4425. * SDLElementAttrList *attr_list)
  4426. *
  4427. * Parameters:
  4428. *
  4429. * Returns: Attribute Processed if successful, -1 if errors
  4430. *
  4431. * Purpose: Looks for the virtual page beginning.
  4432. *
  4433. ******************************************************************************/
  4434. static void
  4435. InitAttributes(
  4436. _DtCvSegment *p_seg,
  4437. _DtHelpFontHints *font_specs,
  4438. ElementInfo *element_info,
  4439. const SDLElementAttrList *attr_list)
  4440. {
  4441. char **strPtr1;
  4442. char *varOffset1;
  4443. SDLNumber *numPtr1;
  4444. SdlOption *enumPtr1;
  4445. SdlOption defNum = _DtCvOPTION_BAD;
  4446. const SDLAttribute *pAttr;
  4447. while (attr_list->sdl_attr_define != -1)
  4448. {
  4449. if (attr_list->def_string != NULL ||
  4450. attr_list->sdl_value == SdlAttrValueImpliedDef)
  4451. {
  4452. pAttr = SDLAttributeList;
  4453. while (pAttr->data_type != SdlAttrDataTypeInvalid &&
  4454. !(ATTRS_EQUAL(pAttr->data_type,
  4455. pAttr->sdl_attr_define, attr_list->sdl_attr_define)))
  4456. pAttr++;
  4457. if (pAttr->struct_type != SdlIgnore &&
  4458. pAttr->data_type != SdlAttrDataTypeInvalid &&
  4459. SDLIsAttrSet(*element_info, pAttr->sdl_attr_define) == False)
  4460. {
  4461. /*
  4462. * determine which structure the information goes in
  4463. */
  4464. if (pAttr->struct_type == SdlFontSpecific)
  4465. varOffset1 = ((char *) font_specs);
  4466. else if (pAttr->struct_type == SdlContainerSpecific)
  4467. varOffset1 = ((char *)_SdlContainerPtrOfSeg(p_seg));
  4468. else if (pAttr->struct_type == SdlElementSpecific)
  4469. varOffset1 = ((char *) element_info);
  4470. else if (pAttr->struct_type == SdlTableSpecific)
  4471. varOffset1 = ((char *) element_info->w.table_info);
  4472. varOffset1 = varOffset1 + pAttr->field_ptr;
  4473. if (pAttr->data_type == SdlAttrDataTypeNumber)
  4474. {
  4475. numPtr1 = (SDLNumber *) varOffset1;
  4476. *numPtr1 = ((SDLNumber)atoi(attr_list->def_string));
  4477. }
  4478. else if (pAttr->data_type == SdlAttrDataTypeEnum)
  4479. {
  4480. enumPtr1 = (SdlOption *) varOffset1;
  4481. (void) CheckOptionList (attr_list->sdl_attr_define,
  4482. attr_list->def_string,
  4483. ((attr_list->sdl_attr_define & SDL_ATTR_CLASS) ? True : False),
  4484. ElInfoClan(element_info),
  4485. &defNum);
  4486. if ((attr_list->sdl_attr_define & SDL_ATTR_CLASS & ~(VALUE_MASK))
  4487. && ElInfoClan(element_info) != defNum)
  4488. SetAttributeFlag(element_info,
  4489. attr_list->sdl_attr_define);
  4490. *enumPtr1 = defNum;
  4491. }
  4492. else if (SDLIsString1(pAttr->sdl_attr_define)
  4493. ||
  4494. SDLIsString2(pAttr->sdl_attr_define))
  4495. {
  4496. strPtr1 = (char **) varOffset1;
  4497. *strPtr1 = (char *) attr_list->def_string;
  4498. }
  4499. }
  4500. }
  4501. attr_list++;
  4502. }
  4503. }
  4504. #ifdef DEBUG
  4505. static char *
  4506. ElToName(enum SdlElement el)
  4507. {
  4508. switch (el)
  4509. {
  4510. case SdlElementNone: return ("None");
  4511. case SdlElementComment: return ("Comment");
  4512. case SdlElementSdlDoc: return ("SdlDoc");
  4513. case SdlElementVStruct: return ("VStruct");
  4514. case SdlElementVirpage: return ("Virpage");
  4515. case SdlElementHead: return ("Head");
  4516. case SdlElementSubHead: return ("SubHead");
  4517. case SdlElementSnb: return ("Snb");
  4518. case SdlElementBlock: return ("Block");
  4519. case SdlElementForm: return ("Form");
  4520. case SdlElementPara: return ("Para");
  4521. case SdlElementCPara: return ("CPara");
  4522. case SdlElementFdata: return ("Fdata");
  4523. case SdlElementFstyle: return ("Fstyle");
  4524. case SdlElementFrowvec: return ("Frowvec");
  4525. case SdlElementKey: return ("Key");
  4526. case SdlElementCdata: return ("Cdata");
  4527. case SdlElementGraphic: return ("Graphic");
  4528. case SdlElementText: return ("Text");
  4529. case SdlElementAudio: return ("Audio");
  4530. case SdlElementVideo: return ("Video");
  4531. case SdlElementAnimate: return ("Animate");
  4532. case SdlElementCrossDoc: return ("CrossDoc");
  4533. case SdlElementManPage: return ("ManPage");
  4534. case SdlElementTextFile: return ("TextFile");
  4535. case SdlElementSysCmd: return ("SysCmd");
  4536. case SdlElementCallback: return ("Callback");
  4537. case SdlElementScript: return ("Script");
  4538. case SdlElementAnchor: return ("Anchor");
  4539. case SdlElementLink: return ("Link");
  4540. case SdlElementSwitch: return ("Switch");
  4541. case SdlElementSnRef: return ("SnRef");
  4542. case SdlElementRefItem: return ("RefItem");
  4543. case SdlElementAltText: return ("AltText");
  4544. case SdlElementSphrase: return ("Sphrase");
  4545. case SdlElementRev: return ("Rev");
  4546. case SdlElementSpc: return ("Spc");
  4547. case SdlElementIf: return ("If");
  4548. case SdlElementCond: return ("Cond");
  4549. case SdlElementThen: return ("Then");
  4550. case SdlElementElse: return ("Else");
  4551. case SdlElementDocument: return ("Document");
  4552. case SdlElementSgml: return ("Sgml");
  4553. case SdlElementDocType: return ("DocType");
  4554. case SdlElementLoids: return ("Loids");
  4555. case SdlElementToss: return ("Toss");
  4556. case SdlElementLoPhrases: return ("LoPhrases");
  4557. case SdlElementPhrase: return ("Phrase");
  4558. case SdlElementIndex: return ("Index");
  4559. case SdlElementEntry: return ("Entry");
  4560. case SdlElementRelDocs: return ("RelDocs");
  4561. case SdlElementRelFile: return ("RelFile");
  4562. case SdlElementNotes: return ("Notes");
  4563. case SdlElementKeyStyle: return ("KeyStyle");
  4564. case SdlElementHeadStyle: return ("HeadStyle");
  4565. case SdlElementFormStyle: return ("FormStyle");
  4566. case SdlElementFrmtStyle: return ("FrmtStyle");
  4567. case SdlElementGrphStyle: return ("GrphStyle");
  4568. case SdlElementId: return ("Id");
  4569. case SdlElementBlockAsync: return ("BlockAsync");
  4570. case SdlElementTitle: return ("Title");
  4571. case SdlPcDataFollows: return ("Follows");
  4572. }
  4573. return ("Unknown");
  4574. }
  4575. #endif /* DEBUG */
  4576. /******************************************************************************
  4577. * Function: int ProcessSDLAttribute(FormatStruct my_struct,
  4578. * SDLAttrStruct *cur_attr,
  4579. * SDLElementAttrList *attr_list,
  4580. * char *attr_name,
  4581. *
  4582. * Parameters:
  4583. *
  4584. * Returns: 0 if successful, -1 if errors
  4585. *
  4586. * Purpose: Looks for the virtual page beginning.
  4587. *
  4588. ******************************************************************************/
  4589. static int
  4590. ProcessSDLAttribute(
  4591. FormatStruct *my_struct,
  4592. _DtCvSegment *p_seg,
  4593. _DtHelpFontHints *font_specs,
  4594. ElementInfo *element_info,
  4595. const SDLElementAttrList *attr_list,
  4596. char *attr_name)
  4597. {
  4598. int result;
  4599. char *attrValue;
  4600. char **strPtr;
  4601. char numBuf[DTD_NAMELEN+1];
  4602. char *varOffset1;
  4603. SDLNumber *numPtr1;
  4604. SdlOption *enumPtr1;
  4605. SdlOption attrNum;
  4606. _DtHelpFontValue fontNum;
  4607. _DtHelpFontValue *fontPtr1;
  4608. const SDLAttribute *pAttr = SDLAttributeList;
  4609. /*
  4610. * find the attribute in the list of SDL attributes
  4611. * assumes that 'attr_name' has been lower cased, since all the
  4612. * attribute names in SDLAttributeList are already lower case.
  4613. */
  4614. while (pAttr->data_type != SdlAttrDataTypeInvalid &&
  4615. (*(pAttr->name) != *attr_name || strcmp(pAttr->name, attr_name)))
  4616. pAttr++;
  4617. if (pAttr->data_type != SdlAttrDataTypeInvalid)
  4618. {
  4619. /*
  4620. * Check to see if this element contains an attribute with
  4621. * the found value.
  4622. */
  4623. while (attr_list->sdl_attr_define != -1 &&
  4624. !ATTRS_EQUAL(pAttr->data_type, pAttr->sdl_attr_define,
  4625. attr_list->sdl_attr_define))
  4626. attr_list++;
  4627. if (attr_list->sdl_attr_define == -1)
  4628. return -1;
  4629. }
  4630. /*
  4631. * check it against the ones that are allowed for this element
  4632. */
  4633. if (pAttr->data_type != SdlAttrDataTypeInvalid)
  4634. {
  4635. switch (pAttr->data_type)
  4636. {
  4637. case SdlAttrDataTypeId:
  4638. result = _DtHelpCeGetSdlId(my_struct->my_file, &attrValue);
  4639. break;
  4640. case SdlAttrDataTypeNumber:
  4641. result = _DtHelpCeGetSdlNumber(my_struct->my_file, numBuf);
  4642. break;
  4643. case SdlAttrDataTypeCdata:
  4644. result = _DtHelpCeGetSdlAttributeCdata(my_struct->my_file,
  4645. False, &attrValue);
  4646. break;
  4647. case SdlAttrDataTypeFont:
  4648. result = _DtHelpCeGetSdlAttributeCdata(my_struct->my_file,
  4649. False, &attrValue);
  4650. if (result != -1)
  4651. result = CheckFontList (attr_list->sdl_attr_define,
  4652. attrValue, &fontNum);
  4653. break;
  4654. case SdlAttrDataTypeEnum:
  4655. result = _DtHelpCeGetSdlAttributeCdata(my_struct->my_file,
  4656. False, &attrValue);
  4657. if (result != -1)
  4658. result = CheckOptionList (attr_list->sdl_attr_define,
  4659. attrValue, False,
  4660. (SdlOption) _DtCvOPTION_BAD,
  4661. &attrNum);
  4662. break;
  4663. default:
  4664. printf ("hit unknown in processing attribute\n");
  4665. result = -1;
  4666. break;
  4667. }
  4668. if (result == 0)
  4669. {
  4670. if (pAttr->struct_type != SdlIgnore)
  4671. {
  4672. /*
  4673. * determine which structure the information goes in
  4674. */
  4675. if (pAttr->struct_type == SdlFontSpecific)
  4676. varOffset1 = ((char *) font_specs);
  4677. else if (pAttr->struct_type == SdlContainerSpecific)
  4678. varOffset1 = ((char *)_SdlContainerPtrOfSeg(p_seg));
  4679. else if (pAttr->struct_type == SdlElementSpecific)
  4680. varOffset1 = ((char *) element_info);
  4681. else if (pAttr->struct_type == SdlTableSpecific)
  4682. varOffset1 = ((char *) element_info->w.table_info);
  4683. varOffset1 = varOffset1 + pAttr->field_ptr;
  4684. if (pAttr->data_type == SdlAttrDataTypeNumber)
  4685. {
  4686. numPtr1 = (SDLNumber *) varOffset1;
  4687. *numPtr1 = ((SDLNumber) atoi(numBuf));
  4688. }
  4689. else if (pAttr->data_type == SdlAttrDataTypeEnum)
  4690. {
  4691. enumPtr1 = (SdlOption *) varOffset1;
  4692. *enumPtr1 = attrNum;
  4693. free(attrValue);
  4694. }
  4695. else if (pAttr->data_type == SdlAttrDataTypeFont)
  4696. {
  4697. fontPtr1 = (_DtHelpFontValue *) varOffset1;
  4698. *fontPtr1 = fontNum;
  4699. free(attrValue);
  4700. }
  4701. else
  4702. {
  4703. strPtr = (char **) varOffset1;
  4704. *strPtr = attrValue;
  4705. }
  4706. }
  4707. else if (SdlAttrDataTypeNumber != pAttr->data_type)
  4708. free(attrValue);
  4709. SetAttributeFlag(element_info, pAttr->sdl_attr_define);
  4710. }
  4711. return result;
  4712. }
  4713. return -1;
  4714. }
  4715. /******************************************************************************
  4716. * Function: int VerifyAttrList (
  4717. * SDLElementAttrList *attr_list)
  4718. *
  4719. * Parameters:
  4720. *
  4721. * Returns: Attribute Processed if successful, -1 if errors
  4722. *
  4723. * Purpose: Looks for the virtual page beginning.
  4724. *
  4725. ******************************************************************************/
  4726. static int
  4727. VerifyAttrList(
  4728. ElementInfoPtr el_info,
  4729. const SDLElementAttrList *attr_list)
  4730. {
  4731. long value;
  4732. while (attr_list->sdl_attr_define != -1)
  4733. {
  4734. if (attr_list->sdl_value == SdlAttrValueRequired)
  4735. {
  4736. switch (attr_list->sdl_attr_define & VALUE_MASK)
  4737. {
  4738. case ENUM_VALUE:
  4739. /*
  4740. * mask off the minor number
  4741. */
  4742. value = el_info->enum_values & ~(MINOR_MASK);
  4743. break;
  4744. case STRING1_VALUE:
  4745. value = el_info->str1_values;
  4746. break;
  4747. case STRING2_VALUE:
  4748. value = el_info->str2_values;
  4749. break;
  4750. case NUMBER_VALUE:
  4751. value = el_info->num_values;
  4752. break;
  4753. }
  4754. if (!(attr_list->sdl_attr_define & value))
  4755. return -1;
  4756. }
  4757. attr_list++;
  4758. }
  4759. return 0;
  4760. }
  4761. /******************************************************************************
  4762. * Function: void MergeTossInfo (
  4763. * _DtCvSegment *cur_element,
  4764. * FormatStruct my_struct);
  4765. *
  4766. * Parameters:
  4767. *
  4768. * Returns: nothing
  4769. *
  4770. * Purpose: Looks for the virtual page beginning.
  4771. *
  4772. ******************************************************************************/
  4773. static void
  4774. MergeTossInfo(
  4775. FormatStruct *my_struct,
  4776. _DtCvSegment *cur_contain,
  4777. _DtHelpFontHints *font_specs)
  4778. {
  4779. _DtCvSegment *tossSeg;
  4780. if (my_struct->toss == NULL)
  4781. return;
  4782. tossSeg = _DtHelpCeMatchSemanticStyle (my_struct->toss,
  4783. ElClan(my_struct),
  4784. ElLevel(my_struct),
  4785. ElSsi(my_struct));
  4786. _DtHelpCeMergeSdlAttribInfo(tossSeg, cur_contain, font_specs,
  4787. &(my_struct->el_info),
  4788. &(my_struct->el_info.str1_values),
  4789. &(my_struct->el_info.str2_values));
  4790. return;
  4791. }
  4792. /*------------------------- Element Processing ------------------------------*/
  4793. /******************************************************************************
  4794. * Function: int ParseElementStart (
  4795. * FormatStruct my_struct,
  4796. * int element, _DtCvValue process_flag);
  4797. *
  4798. * Parameters:
  4799. *
  4800. * Returns: 0 if successful, -1 if errors
  4801. *
  4802. * Purpose: Looks for the virtual page beginning.
  4803. *
  4804. ******************************************************************************/
  4805. static int
  4806. ParseElementStart(
  4807. FormatStruct *my_struct,
  4808. SDLElementInfo element,
  4809. _DtCvValue process_flag)
  4810. {
  4811. _DtCvSegment *segPtr;
  4812. _DtCvSegment *newSeg;
  4813. FrmtPrivateInfo *priv;
  4814. if (MatchSDLElement (my_struct, element.element_str, element.sdl_element,
  4815. element.str_sig_chars, False) != 0)
  4816. return -1;
  4817. /*
  4818. * remember what we are currently parsing
  4819. */
  4820. ElType(my_struct) = element.sdl_element;
  4821. /*
  4822. * does this element possibly pull in different fonts?
  4823. * if so, allocate a new font structure.
  4824. */
  4825. if (True == process_flag && element.new_fonts)
  4826. {
  4827. my_struct->my_fonts = AllocateFontInfo(my_struct);
  4828. if (NULL == my_struct->my_fonts)
  4829. return -1;
  4830. }
  4831. /*
  4832. * if Cdata or skipping information don't do anything else
  4833. */
  4834. if (element.sdl_to_gen == SdlToNone || process_flag == False)
  4835. return 0;
  4836. /*
  4837. * allocate a segment for this element
  4838. */
  4839. if (_DtHelpCeAllocSegment(my_struct->malloc_size,
  4840. &(my_struct->alloc_size),
  4841. &(my_struct->block_list), &segPtr) != 0)
  4842. return -1;
  4843. /*
  4844. * add this segment to the list when done
  4845. */
  4846. my_struct->add_seg = segPtr;
  4847. /*
  4848. * Set the flags and initialize variables depending on the
  4849. * type of general segment this element becomes.
  4850. */
  4851. switch (element.sdl_to_gen)
  4852. {
  4853. case SdlToContainer:
  4854. /*
  4855. * set the container flag and initialize its formatting
  4856. * information to the default.
  4857. */
  4858. segPtr->type = _DtCvSetTypeToContainer(segPtr->type);
  4859. _DtCvContainerOfSeg(segPtr) = DefFrmtSpecs;
  4860. _DtCvContainerLeadingOfSeg(segPtr) =
  4861. my_struct->ui_info->leading;
  4862. /*
  4863. * if this is a formatting type container, do some more work.
  4864. */
  4865. if (element.formatting)
  4866. {
  4867. const _DtCvContainer *active = my_struct->active_frmt;
  4868. if (NULL == active) active = &DefFrmtSpecs;
  4869. /*
  4870. * The margin information - it gets zero'ed
  4871. */
  4872. _DtCvContainerLMarginOfSeg(segPtr) = 0;
  4873. _DtCvContainerRMarginOfSeg(segPtr) = 0;
  4874. _DtCvContainerFMarginOfSeg(segPtr) = 0;
  4875. _DtCvContainerTMarginOfSeg(segPtr) = 0;
  4876. _DtCvContainerBMarginOfSeg(segPtr) = 0;
  4877. /*
  4878. * inherit some of the formatting directives
  4879. */
  4880. _DtCvContainerVJustifyOfSeg(segPtr) =
  4881. ContainerPtrToVJustify(active);
  4882. _DtCvContainerJustifyOfSeg(segPtr) =
  4883. ContainerPtrToJustify(active);
  4884. /*
  4885. * break the connection with the previous data.
  4886. */
  4887. my_struct->prev_data = NULL;
  4888. _DtCvContainerListOfSeg(segPtr) = NULL;
  4889. /*
  4890. * check to see if these are controllers.
  4891. */
  4892. if (element.sdl_element == SdlElementHead ||
  4893. SdlElementSubHead == element.sdl_element)
  4894. segPtr->type = _DtCvSetTypeToController(segPtr->type);
  4895. /*
  4896. * make this the currently active formatting information
  4897. */
  4898. my_struct->active_frmt = &(_DtCvContainerOfSeg(segPtr));
  4899. }
  4900. break;
  4901. case SdlToMarker:
  4902. /*
  4903. * set the type; the attribute processing will set the id.
  4904. */
  4905. segPtr->type = _DtCvSetTypeToMarker(segPtr->type);
  4906. break;
  4907. case SdlToSnb:
  4908. /*
  4909. * set the type; the attribute processing will set the id.
  4910. * graphics only exist in a snb. You have to keep the
  4911. * id around until the graphic get resolved. So a graphic
  4912. * is a container with a region.
  4913. */
  4914. segPtr->type = _DtCvSetTypeToContainer(segPtr->type);
  4915. /*
  4916. * remember the refitem type.
  4917. */
  4918. priv = FrmtPrivInfoPtr(segPtr);
  4919. priv->sdl_el_type = ElType(my_struct);
  4920. break;
  4921. case SdlToSpc:
  4922. /*
  4923. * set the type; the attribute processing will set the id.
  4924. */
  4925. segPtr->type = _DtCvSetTypeToRegion(segPtr->type);
  4926. break;
  4927. }
  4928. if (my_struct->cur_link != -1)
  4929. {
  4930. segPtr->type = _DtCvSetTypeToHyperText(segPtr->type);
  4931. segPtr->link_idx = my_struct->cur_link;
  4932. }
  4933. switch (element.sdl_element)
  4934. {
  4935. case SdlElementSnb:
  4936. my_struct->resolve_font = _SdlFontModeNone;
  4937. my_struct->snb = segPtr;
  4938. my_struct->prev_data = NULL;
  4939. break;
  4940. case SdlElementAltText:
  4941. segPtr->type = _DtCvSetTypeToNonBreak(segPtr->type);
  4942. break;
  4943. case SdlElementForm:
  4944. /*
  4945. * allocate a table for all the information
  4946. */
  4947. if (_DtHelpCeAllocSegment(my_struct->malloc_size,
  4948. &(my_struct->alloc_size),
  4949. &(my_struct->block_list), &newSeg) != 0)
  4950. return -1;
  4951. newSeg->type = _DtCvSetTypeToTable(newSeg->type);
  4952. _DtCvJustifyCharsOfTableSeg(newSeg) = NULL;
  4953. /*
  4954. * set the my_struct pointer to this table so that
  4955. * as the fstyle and frowec elements are parsed, the
  4956. * data goes directly into this table.
  4957. */
  4958. ElTable(my_struct) = newSeg;
  4959. break;
  4960. }
  4961. return 0;
  4962. } /* End ParseElementStart */
  4963. /******************************************************************************
  4964. * Function: int ParseElementAttr (
  4965. * FormatStruct my_struct,
  4966. * SDLElementAttrList *attribs)
  4967. *
  4968. * Parameters:
  4969. *
  4970. * Returns: 0 if successful, -1 if errors
  4971. *
  4972. * Purpose: Looks for the virtual page attributes.
  4973. *
  4974. ******************************************************************************/
  4975. static int
  4976. ParseElementAttr(
  4977. FormatStruct *my_struct,
  4978. enum SdlElement cur_element,
  4979. const SDLElementAttrList *attribs,
  4980. _DtCvValue flag,
  4981. _DtCvValue process_flag)
  4982. {
  4983. int result = 0;
  4984. char attribName[MAX_ATTRIBUTE_LENGTH + 2];
  4985. _DtCvSegment *mySeg;
  4986. if (attribs == NULL || process_flag == False)
  4987. {
  4988. /*
  4989. * No attributes - is there cdata in here?
  4990. */
  4991. if (flag || attribs != NULL)
  4992. result = _DtHelpCeSkipCdata (my_struct->my_file,
  4993. (cur_element == SdlElementDocType ? True : False));
  4994. /*
  4995. * get the element's end.
  4996. */
  4997. if (result != -1)
  4998. result = _DtHelpCeGetSdlAttribute(my_struct->my_file,
  4999. MAX_ATTRIBUTE_LENGTH,
  5000. attribName);
  5001. /*
  5002. * _DtHelpCeGetSdlAttribute should return 1, meaning it found
  5003. * the >
  5004. */
  5005. if (result != 1)
  5006. return -1;
  5007. return 0;
  5008. }
  5009. /*
  5010. * clean and initialize the attributes for this element.
  5011. */
  5012. my_struct->el_info.enum_values = 0;
  5013. my_struct->el_info.num_values = 0;
  5014. my_struct->el_info.str1_values = 0;
  5015. my_struct->el_info.str2_values = 0;
  5016. mySeg = my_struct->add_seg;
  5017. InitAttributes(mySeg, my_struct->my_fonts, &(my_struct->el_info), attribs);
  5018. /*
  5019. * clear the colJ and colW
  5020. */
  5021. if (SdlElementForm == ElType(my_struct))
  5022. {
  5023. ElTableColJStr(my_struct) = NULL;
  5024. ElTableColWStr(my_struct) = NULL;
  5025. }
  5026. /*
  5027. * force the default of subheading orientation to heads as below the head.
  5028. */
  5029. if (ElType(my_struct) == SdlElementSubHead)
  5030. _DtCvContainerVOrientOfSeg(mySeg) = _DtCvJUSTIFY_BOTTOM;
  5031. do {
  5032. result = _DtHelpCeGetSdlAttribute(my_struct->my_file,
  5033. MAX_ATTRIBUTE_LENGTH,
  5034. attribName);
  5035. if (result == 0)
  5036. result = ProcessSDLAttribute(my_struct, mySeg,
  5037. my_struct->my_fonts,
  5038. &(my_struct->el_info),
  5039. attribs,
  5040. attribName);
  5041. } while (result == 0);
  5042. if (result != -1)
  5043. result = VerifyAttrList(&(my_struct->el_info), attribs);
  5044. if (result != -1)
  5045. {
  5046. if (cur_element == SdlElementVirpage
  5047. ||
  5048. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CLASS)
  5049. ||
  5050. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_SSI)
  5051. ||
  5052. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LEVEL))
  5053. MergeTossInfo(my_struct, mySeg, my_struct->my_fonts);
  5054. if (SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_LANGUAGE)
  5055. || SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_CHARSET))
  5056. my_struct->mb_len = _DtHelpCeGetMbLen(
  5057. _DtHelpFontHintsLang(*(my_struct->my_fonts)),
  5058. _DtHelpFontHintsCharSet(*(my_struct->my_fonts)));
  5059. /*
  5060. * Do some specific work for containers.
  5061. */
  5062. if (NULL != mySeg && _DtCvIsSegContainer(mySeg))
  5063. {
  5064. /*
  5065. * transfer any id or rid that got specified
  5066. */
  5067. if (SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_ID) ||
  5068. SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_RID))
  5069. {
  5070. _DtCvContainerIdOfSeg(mySeg) = ElId(my_struct);
  5071. ClearAttrFlag(my_struct->el_info, SDL_ATTR_ID);
  5072. ClearAttrFlag(my_struct->el_info, SDL_ATTR_RID);
  5073. }
  5074. /*
  5075. * set the margins to absolute values
  5076. */
  5077. if (my_struct->ui_info->avg_char > 0)
  5078. {
  5079. _DtCvContainerLMarginOfSeg(mySeg) =
  5080. _DtCvContainerLMarginOfSeg(mySeg) *
  5081. my_struct->ui_info->avg_char;
  5082. _DtCvContainerRMarginOfSeg(mySeg) =
  5083. _DtCvContainerRMarginOfSeg(mySeg) *
  5084. my_struct->ui_info->avg_char;
  5085. _DtCvContainerFMarginOfSeg(mySeg) =
  5086. _DtCvContainerFMarginOfSeg(mySeg) *
  5087. my_struct->ui_info->avg_char;
  5088. }
  5089. /*
  5090. * set the container spacing to absolute values
  5091. */
  5092. if (my_struct->ui_info->line_height / 2 > 0)
  5093. {
  5094. /*
  5095. * TODO .... take maximum! of spacing.
  5096. */
  5097. TMarginOfSeg(mySeg) = TMarginOfSeg(mySeg) *
  5098. (my_struct->ui_info->line_height / 2);
  5099. BMarginOfSeg(mySeg) = BMarginOfSeg(mySeg) *
  5100. (my_struct->ui_info->line_height / 2);
  5101. }
  5102. /*
  5103. * set the border width information
  5104. */
  5105. if (_DtCvBORDER_NONE != _DtCvContainerBorderOfSeg(mySeg))
  5106. _DtCvContainerLineWidthOfSeg(mySeg) =
  5107. my_struct->ui_info->line_width;
  5108. }
  5109. }
  5110. if (result == 1)
  5111. result = 0;
  5112. return result;
  5113. } /* End ParseElementAttr */
  5114. /******************************************************************************
  5115. * Function: int ParseElementEnd (
  5116. * FormatStruct my_struct,
  5117. * int el_type);
  5118. *
  5119. * Parameters:
  5120. *
  5121. * Returns: 0 if successful, -1 if errors
  5122. *
  5123. * Purpose: Looks for the virtual page beginning.
  5124. *
  5125. ******************************************************************************/
  5126. static int
  5127. ParseElementEnd(
  5128. FormatStruct *my_struct,
  5129. _DtCvSegment *if_prev,
  5130. SDLElementInfo element,
  5131. _DtCvValue process_flag,
  5132. _DtCvValue end_flag)
  5133. {
  5134. char *id;
  5135. _DtCvSegment *newSeg;
  5136. _DtCvSegment *segList;
  5137. if (MatchSDLElement (my_struct, element.element_end_str,
  5138. element.sdl_element, element.end_sig_chars, True) != 0 ||
  5139. (end_flag == False &&
  5140. _DtHelpCeFindSkipSdlElementEnd(my_struct->my_file) != 0))
  5141. return -1;
  5142. if (process_flag == True)
  5143. {
  5144. _DtCvSegment *pElement = my_struct->add_seg;
  5145. /*
  5146. * if we aren't resolving the fonts for this element,
  5147. * we need to save the toss information for later
  5148. * when the element gets used in a table or snref.
  5149. */
  5150. if (_SdlFontModeResolve != my_struct->resolve_font &&
  5151. (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CLASS)
  5152. ||
  5153. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_SSI)
  5154. ||
  5155. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LEVEL)))
  5156. {
  5157. SdlMatchData *match;
  5158. /*
  5159. * was a segment allocated for this element?
  5160. * if not, we'll have to put our own special segment
  5161. * around the segment list so the correct font inheritance
  5162. * occurs. Later, this special segment will have to be
  5163. * stripped out when the async blocks or snref item
  5164. * is resolved.
  5165. */
  5166. if (NULL == pElement)
  5167. {
  5168. if (_DtHelpCeAllocSegment(1, NULL, NULL, &pElement) != 0)
  5169. return -1;
  5170. pElement->type = _DtCvSetTypeToContainer(pElement->type);
  5171. pElement->type = SetSdlWrapper(pElement->type);
  5172. _DtCvContainerListOfSeg(pElement) = my_struct->seg_list;
  5173. my_struct->seg_list = pElement;
  5174. }
  5175. /*
  5176. * has match data already been allocated for this element?
  5177. */
  5178. match = SegMatchDataPtr(pElement);
  5179. if (NULL == match)
  5180. {
  5181. match = (SdlMatchData *) malloc(sizeof(SdlMatchData));
  5182. if (NULL == match)
  5183. return -1;
  5184. }
  5185. /*
  5186. * save the clan, level and ssi of this element.
  5187. */
  5188. *match = my_struct->el_info.match;
  5189. SegMatchData(pElement) = (void *) match;
  5190. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SSI);
  5191. }
  5192. /*
  5193. * attach the current segment list to the container's list
  5194. */
  5195. if (NULL != pElement && _DtCvIsSegContainer(pElement))
  5196. _DtCvContainerListOfSeg(pElement) = my_struct->seg_list;
  5197. /*
  5198. * check to see if the element has any data.
  5199. * If not, can it (the element) be eleminated and free up memory?
  5200. */
  5201. if (NULL != pElement && my_struct->seg_list == NULL
  5202. && element.elim_flag == True
  5203. && ElType(my_struct) != SdlElementKey
  5204. && TMarginOfSeg(pElement) == 0 && BMarginOfSeg(pElement) == 0)
  5205. {
  5206. _DtHelpFreeSegments(my_struct->add_seg, _DtCvFALSE,
  5207. my_struct->ui_info->destroy_region,
  5208. my_struct->ui_info->client_data);
  5209. if (ElType(my_struct) == SdlElementLink)
  5210. _DtLinkDbRemoveLink(my_struct->my_links,
  5211. my_struct->cur_link);
  5212. my_struct->add_seg = NULL;
  5213. }
  5214. else
  5215. {
  5216. switch(ElType(my_struct))
  5217. {
  5218. case SdlElementSnb:
  5219. my_struct->add_seg = NULL;
  5220. break;
  5221. case SdlElementBlock:
  5222. if (ElTiming(my_struct) == SdlTimingAsync)
  5223. {
  5224. if (NULL != my_struct->add_seg)
  5225. AddToAsyncList(my_struct, my_struct->add_seg);
  5226. my_struct->add_seg = NULL;
  5227. }
  5228. break;
  5229. case SdlElementHead:
  5230. case SdlElementSubHead:
  5231. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_ABBREV)
  5232. && ElAbbrev(my_struct) != NULL
  5233. && strlen(ElAbbrev(my_struct)))
  5234. {
  5235. AbbrevOfSeg(my_struct->add_seg) =
  5236. (void *) ElAbbrev(my_struct);
  5237. ClearAttrFlag(my_struct->el_info, SDL_ATTR_ABBREV);
  5238. }
  5239. break;
  5240. case SdlElementFdata:
  5241. ElTableList(my_struct) = ConvertToList(my_struct->seg_list);
  5242. break;
  5243. case SdlElementLink:
  5244. CompressLinkSeg(my_struct->seg_list);
  5245. case SdlElementKey:
  5246. case SdlElementSphrase:
  5247. /*
  5248. * move the content of the element up.
  5249. */
  5250. my_struct->add_seg = my_struct->seg_list;
  5251. /*
  5252. * free the no longer needed segments.
  5253. */
  5254. if (NULL != pElement)
  5255. {
  5256. _DtCvContainerListOfSeg(pElement) = NULL;
  5257. _DtHelpFreeSegments(pElement, _DtCvFALSE,
  5258. my_struct->ui_info->destroy_region,
  5259. my_struct->ui_info->client_data);
  5260. }
  5261. break;
  5262. case SdlElementForm:
  5263. /*
  5264. * get the segment list.
  5265. */
  5266. newSeg = ElTable(my_struct);
  5267. /*
  5268. * include any async blocks into the table list.
  5269. */
  5270. if (ResolveAsyncBlock(my_struct, newSeg) != 0)
  5271. return -1;
  5272. /*
  5273. * compress the table if possible down to just
  5274. * a container.
  5275. */
  5276. newSeg = CompressTable(my_struct, newSeg);
  5277. /*
  5278. * add the table segment to the form's container list
  5279. * taking into account any heads for the form.
  5280. */
  5281. _DtCvNextSeg(newSeg) = _DtCvContainerListOfSeg(pElement);
  5282. _DtCvContainerListOfSeg(pElement) = newSeg;
  5283. break;
  5284. case SdlElementIf:
  5285. if (ResolveIf (my_struct, if_prev))
  5286. return -1;
  5287. break;
  5288. case SdlElementSnRef:
  5289. /*
  5290. * get the id of snref
  5291. */
  5292. id = NULL;
  5293. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_ID))
  5294. id = _DtCvContainerIdOfSeg(pElement);
  5295. /*
  5296. * Resolve the snref to one of its items
  5297. */
  5298. newSeg = ResolveSnref(my_struct, pElement, id);
  5299. /*
  5300. * if the snref got resolved, process
  5301. * otherwise, let it pass through. We'll try to
  5302. * resolve it later.
  5303. */
  5304. if (newSeg != pElement)
  5305. {
  5306. /*
  5307. * remember the segment list that we want
  5308. * to free. This includes the snref.
  5309. */
  5310. segList = pElement;
  5311. /*
  5312. * if this <snref> had an id with it, then
  5313. * expand the <snref> to a marker segment
  5314. * (with the id) and a resolved refitem.
  5315. *
  5316. * Otherwise, eliminate the container.
  5317. */
  5318. if (NULL != id)
  5319. {
  5320. /*
  5321. * remember the segment list of the container.
  5322. * Since we are re-using the snref segment,
  5323. * we want to eliminate just the refitems of
  5324. * the snref and not the actual snref.
  5325. */
  5326. segList = _DtCvContainerListOfSeg(pElement);
  5327. /*
  5328. * Move the refitem to be a sibling of the
  5329. * container.
  5330. */
  5331. _DtCvNextSeg(pElement) = newSeg;
  5332. /*
  5333. * transfer the container id to a marker id
  5334. * and change the container into a marker.
  5335. */
  5336. _DtCvIdOfMarkerSeg(pElement) =
  5337. _DtCvContainerIdOfSeg(pElement);
  5338. pElement->type =
  5339. _DtCvSetTypeToMarker(pElement->type);
  5340. newSeg = pElement;
  5341. }
  5342. /*
  5343. * free the no longer needed segments.
  5344. */
  5345. _DtHelpFreeSegments(segList, _DtCvFALSE,
  5346. my_struct->ui_info->destroy_region,
  5347. my_struct->ui_info->client_data);
  5348. }
  5349. my_struct->add_seg = newSeg;
  5350. break;
  5351. }
  5352. }
  5353. /*
  5354. * free the attributes for this element
  5355. */
  5356. FreeAttributes(ElType(my_struct),
  5357. &(my_struct->el_info), my_struct->my_fonts);
  5358. /*
  5359. * if this element can pull in new fonts, then a new font
  5360. * structure was allocated for this element. Since we are
  5361. * leaving the element, place the font structure in the
  5362. * free list for possible reuse.
  5363. */
  5364. if (element.new_fonts && FreeFontInfo(my_struct) == -1)
  5365. return -1;
  5366. }
  5367. else
  5368. my_struct->add_seg = my_struct->seg_list;
  5369. if (element.formatting == True)
  5370. my_struct->prev_data = NULL;
  5371. return 0;
  5372. } /* End ParseElementEnd */
  5373. /******************************************************************************
  5374. *
  5375. * SDL Element Content Functions
  5376. *
  5377. *****************************************************************************/
  5378. /******************************************************************************
  5379. * Function: int FindAndFix (
  5380. * _DtCvSegment *toss,
  5381. * _DtCvSegment *snb,
  5382. * _DtCvSegment *seg_list)
  5383. *
  5384. * Parameters:
  5385. *
  5386. * Returns: 0 if successful, -1 if errors
  5387. *
  5388. * Purpose:
  5389. *
  5390. ******************************************************************************/
  5391. static int
  5392. FindAndFix(
  5393. FormatStruct *my_struct)
  5394. {
  5395. int curLink = my_struct->cur_link;
  5396. _DtCvSegment *newSeg;
  5397. _DtCvSegment *prevData = my_struct->prev_data;
  5398. _DtCvSegment *lastSeg = my_struct->last_seg;
  5399. _DtCvSegment *tmpSeg;
  5400. _DtHelpFontHints *oldFonts = my_struct->my_fonts;
  5401. /*
  5402. * If the head has an snref in it, get the snb and resolve them
  5403. */
  5404. if (0 < my_struct->snref_cnt)
  5405. {
  5406. UnresSnref *snref = my_struct->un_snrefs;
  5407. while (my_struct->snref_cnt)
  5408. {
  5409. /*
  5410. * reset the structure to what it was at the time
  5411. * this snref was encountered.
  5412. */
  5413. my_struct->prev_data = NULL;
  5414. my_struct->last_seg = NULL;
  5415. my_struct->my_fonts = &(snref->fonts);
  5416. my_struct->cur_link = snref->cur_link;
  5417. /*
  5418. * resolve it.
  5419. */
  5420. newSeg = ResolveSnref(my_struct, snref->seg, NULL);
  5421. /*
  5422. * free the snref items
  5423. */
  5424. _DtHelpFreeSegments(_DtCvContainerListOfSeg(snref->seg), _DtCvFALSE,
  5425. my_struct->ui_info->destroy_region,
  5426. my_struct->ui_info->client_data);
  5427. /*
  5428. * find the end of the new segment's and have it point to
  5429. * the next segments that the old segment points to.
  5430. */
  5431. if (NULL != newSeg)
  5432. {
  5433. tmpSeg = newSeg;
  5434. while (NULL != _DtCvNextSeg(tmpSeg))
  5435. tmpSeg = _DtCvNextSeg(tmpSeg);
  5436. _DtCvNextSeg(tmpSeg) = _DtCvNextSeg(snref->seg);
  5437. _DtCvNextDisp(tmpSeg) = _DtCvNextDisp(snref->seg);
  5438. }
  5439. /*
  5440. * does the snref have an id?
  5441. */
  5442. if (NULL != snref->id)
  5443. {
  5444. /*
  5445. * re-use the old snref, turning it into a marker
  5446. */
  5447. _DtCvIdOfMarkerSeg(snref->seg) = snref->id;
  5448. snref->seg->type = _DtCvSetTypeToMarker(snref->seg->type);
  5449. /*
  5450. * set the next pointers on the old segment to
  5451. * the new segment.
  5452. */
  5453. if (NULL != newSeg)
  5454. {
  5455. _DtCvNextSeg(snref->seg) = newSeg;
  5456. _DtCvNextDisp(snref->seg) = newSeg;
  5457. }
  5458. }
  5459. /*
  5460. * else move the resolved segment on top of the old snref.
  5461. */
  5462. else if (NULL != newSeg)
  5463. {
  5464. /*
  5465. * free the private information. No longer needed.
  5466. */
  5467. free(snref->seg->client_use);
  5468. /*
  5469. * now trounce the snref segment info.
  5470. */
  5471. *(snref->seg) = *newSeg;
  5472. /*
  5473. * free the duplicate new segment.
  5474. */
  5475. if (_DtCvIsSegContainer(newSeg))
  5476. _DtCvContainerListOfSeg(newSeg) = NULL;
  5477. free(newSeg);
  5478. }
  5479. /*
  5480. * else there was no resolution, leave this segment as a NOOP.
  5481. */
  5482. /*
  5483. * go to the next unresolved snref
  5484. */
  5485. snref++;
  5486. my_struct->snref_cnt--;
  5487. }
  5488. free(my_struct->un_snrefs);
  5489. my_struct->un_snrefs = NULL;
  5490. }
  5491. my_struct->cur_link = curLink;
  5492. my_struct->prev_data = prevData;
  5493. my_struct->last_seg = lastSeg;
  5494. my_struct->my_fonts = oldFonts;
  5495. return 0;
  5496. }
  5497. /******************************************************************************
  5498. * Function: char *GetInterpCmd (SdlOption interp_type);
  5499. *
  5500. * Parameters:
  5501. *
  5502. * Returns: 0 if successful, -1 if errors
  5503. *
  5504. * Purpose: Return the command associated with the interpreter type.
  5505. *
  5506. ******************************************************************************/
  5507. static char *
  5508. GetInterpCmd(SdlOption interp_type)
  5509. {
  5510. const _CEInterpData *interp = InterpData;
  5511. while (interp->type != _DtCvOPTION_BAD)
  5512. {
  5513. if (interp->type == interp_type)
  5514. return interp->cmd;
  5515. interp++;
  5516. }
  5517. return NULL;
  5518. }
  5519. /******************************************************************************
  5520. * Function: int CheckForSnb (
  5521. * FormatStruct my_struct,
  5522. * int element_types,
  5523. * int exceptions);
  5524. *
  5525. * Parameters:
  5526. *
  5527. * Returns: 0 if successful, -1 if errors
  5528. *
  5529. * Purpose: Looks for the virtual page attributes.
  5530. *
  5531. ******************************************************************************/
  5532. static int
  5533. CheckForSnb(
  5534. FormatStruct *my_struct,
  5535. SDLMask *element_types,
  5536. enum SdlElement sig_element,
  5537. SDLMask *exceptions,
  5538. SDLMask *process_mask)
  5539. {
  5540. int result = 0;
  5541. /*
  5542. * If the head has an snref in it, get the snb and resolve them
  5543. */
  5544. if (my_struct->snref_used == True)
  5545. {
  5546. _DtCvSegment *oldSegList = my_struct->seg_list;
  5547. _DtCvSegment *oldAddSeg = my_struct->add_seg;
  5548. _DtCvSegment *oldPrevSeg = my_struct->prev_data;
  5549. _DtCvSegment *oldLastSeg = my_struct->last_seg;
  5550. my_struct->seg_list = NULL;
  5551. my_struct->add_seg = NULL;
  5552. my_struct->prev_data = NULL;
  5553. my_struct->last_seg = NULL;
  5554. result = ProcessSDLMarkup(my_struct, SdlElementSnb, SdlElementNone,
  5555. exceptions, process_mask);
  5556. my_struct->seg_list = oldSegList;
  5557. my_struct->add_seg = oldAddSeg;
  5558. my_struct->prev_data = oldPrevSeg;
  5559. my_struct->last_seg = oldLastSeg;
  5560. /*
  5561. * if no problems getting the snb, go through the items and
  5562. * resolve the snrefs.
  5563. */
  5564. if (result != -1)
  5565. result = FindAndFix(my_struct);
  5566. }
  5567. return result;
  5568. } /* End CheckForSnb */
  5569. /******************************************************************************
  5570. * Function: int SetSaveSnref (
  5571. * FormatStruct my_struct,
  5572. * int element_types,
  5573. * int exceptions);
  5574. *
  5575. * Parameters:
  5576. *
  5577. * Returns: 0 if successful, -1 if errors
  5578. *
  5579. * Purpose: Looks for the virtual page attributes.
  5580. *
  5581. ******************************************************************************/
  5582. static int
  5583. SetSaveSnref(
  5584. FormatStruct *my_struct,
  5585. SDLMask *element_types,
  5586. enum SdlElement sig_element,
  5587. SDLMask *exceptions,
  5588. SDLMask *process_mask)
  5589. {
  5590. my_struct->save_snref = _DtCvTRUE;
  5591. return 0;
  5592. } /* End SetSaveSnref */
  5593. /******************************************************************************
  5594. * Function: int ClearAndCheckSnref (
  5595. * FormatStruct my_struct,
  5596. * int element_types,
  5597. * int exceptions);
  5598. *
  5599. * Parameters:
  5600. *
  5601. * Returns: 0 if successful, -1 if errors
  5602. *
  5603. * Purpose: Looks for the virtual page attributes.
  5604. *
  5605. ******************************************************************************/
  5606. static int
  5607. ClearAndCheckSnref(
  5608. FormatStruct *my_struct,
  5609. SDLMask *element_types,
  5610. enum SdlElement sig_element,
  5611. SDLMask *exceptions,
  5612. SDLMask *process_mask)
  5613. {
  5614. int result = 0;
  5615. /*
  5616. * reset the flag for saving snref elements
  5617. */
  5618. my_struct->save_snref = _DtCvFALSE;
  5619. /*
  5620. * was any snrefs found? If so, resolve them now.
  5621. */
  5622. if (my_struct->snref_used == True)
  5623. result = FindAndFix(my_struct);
  5624. return result;
  5625. } /* End ClearAndCheckSnref */
  5626. /******************************************************************************
  5627. * Function: int CheckType (
  5628. * FormatStruct my_struct,
  5629. * int element_types,
  5630. * int exceptions);
  5631. *
  5632. * Parameters:
  5633. *
  5634. * Returns: 0 if successful, -1 if errors
  5635. *
  5636. * Purpose: Looks for the virtual page attributes.
  5637. *
  5638. ******************************************************************************/
  5639. static int
  5640. CheckType(
  5641. FormatStruct *my_struct,
  5642. SDLMask *element_types,
  5643. enum SdlElement sig_element,
  5644. SDLMask *exceptions,
  5645. SDLMask *process_mask)
  5646. {
  5647. SdlOption newOpt;
  5648. /*
  5649. * cannot honor newlines in super or sub scripts.
  5650. */
  5651. newOpt = ElFrmtType(my_struct);
  5652. if (SdlTypeLiteral == newOpt)
  5653. newOpt = SdlTypeUnlinedLiteral;
  5654. else if (SdlTypeLined == newOpt)
  5655. newOpt = SdlTypeDynamic;
  5656. ElFrmtType(my_struct) = newOpt;
  5657. if (SdlTypeDynamic != newOpt)
  5658. my_struct->flags = _DtCvSetTypeToNonBreak(my_struct->flags);
  5659. if (SdlClassSub == ElClan(my_struct))
  5660. my_struct->flags = _DtCvSetTypeToSubScript(my_struct->flags);
  5661. else if (SdlClassSuper == ElClan(my_struct))
  5662. my_struct->flags = _DtCvSetTypeToSuperScript(my_struct->flags);
  5663. /*
  5664. * strip hypertext links
  5665. */
  5666. my_struct->cur_link = -1;
  5667. return 0;
  5668. } /* End CheckType */
  5669. /******************************************************************************
  5670. * Function: int SetType (
  5671. * FormatStruct my_struct,
  5672. * int element_types,
  5673. * int exceptions);
  5674. *
  5675. * Parameters:
  5676. *
  5677. * Returns: 0 if successful, -1 if errors
  5678. *
  5679. * Purpose: Looks for the virtual page attributes.
  5680. *
  5681. ******************************************************************************/
  5682. static int
  5683. SetType(
  5684. FormatStruct *my_struct,
  5685. SDLMask *element_types,
  5686. enum SdlElement sig_element,
  5687. SDLMask *exceptions,
  5688. SDLMask *process_mask)
  5689. {
  5690. if (ElType(my_struct) == SdlElementSphrase)
  5691. {
  5692. ContainerPtrToType(my_struct->active_frmt) =
  5693. (_DtCvFrmtOption) SdlTypeLiteral;
  5694. ElFrmtType(my_struct) = SdlTypeLiteral;
  5695. my_struct->flags = 0;
  5696. }
  5697. else
  5698. ElFrmtType(my_struct) = SdlTypeCdata;
  5699. if (SdlElementScript == ElType(my_struct))
  5700. {
  5701. /*
  5702. * remember the interpretor value
  5703. */
  5704. FrmtPrivateInfo *priv = FrmtPrivInfoPtr(my_struct->add_seg);
  5705. priv->interp = ElInterp(my_struct);
  5706. }
  5707. return 0;
  5708. } /* End SetType */
  5709. /******************************************************************************
  5710. * Function: int ElseInfo (
  5711. * FormatStruct my_struct,
  5712. * int element_types,
  5713. * int exceptions);
  5714. *
  5715. * Parameters:
  5716. *
  5717. * Returns: 0 if successful, -1 if errors
  5718. *
  5719. * Purpose: Looks for the virtual page attributes.
  5720. *
  5721. ******************************************************************************/
  5722. static int
  5723. IfInfo(
  5724. FormatStruct *my_struct,
  5725. SDLMask *element_types,
  5726. enum SdlElement sig_element,
  5727. SDLMask *exceptions,
  5728. SDLMask *process_mask)
  5729. {
  5730. if (ElType(my_struct) == SdlElementIf)
  5731. {
  5732. my_struct->then_prev = NULL;
  5733. my_struct->else_prev = NULL;
  5734. }
  5735. else if (ElType(my_struct) == SdlElementThen)
  5736. my_struct->then_prev = my_struct->prev_data;
  5737. else /* if (ElType(my_struct) == SdlElementElse) */
  5738. my_struct->else_prev = my_struct->prev_data;
  5739. return 0;
  5740. } /* End IfInfo */
  5741. /******************************************************************************
  5742. * Function: int MarkFound (
  5743. * FormatStruct my_struct,
  5744. * int element_types,
  5745. * int exceptions);
  5746. *
  5747. * Parameters:
  5748. *
  5749. * Returns: 0 if successful, -1 if errors
  5750. *
  5751. * Purpose: Looks for the virtual page attributes.
  5752. *
  5753. ******************************************************************************/
  5754. static int
  5755. MarkFound(
  5756. FormatStruct *my_struct,
  5757. SDLMask *element_types,
  5758. enum SdlElement sig_element,
  5759. SDLMask *exceptions,
  5760. SDLMask *process_mask)
  5761. {
  5762. my_struct->snref_used = True;
  5763. /*
  5764. * is there a newline hanging around that needs turning into a space?
  5765. */
  5766. if (SDLSearchMask(process_mask, SdlElementCdata)
  5767. && my_struct->last_was_space == False && my_struct->last_was_nl == True)
  5768. {
  5769. _DtCvSegment *pSeg = my_struct->prev_data;
  5770. /*
  5771. * tack the space onto the end of previous string if possible.
  5772. */
  5773. if (pSeg != NULL && _DtCvIsSegString(pSeg) &&
  5774. _DtCvIsSegRegChar(pSeg) && !(_DtCvIsSegNewLine(pSeg)))
  5775. {
  5776. char *strPtr;
  5777. int len = _DtCvStrLen(_DtCvStringOfStringSeg(pSeg), 0);
  5778. _DtCvStringOfStringSeg(pSeg) = (char *) realloc(
  5779. _DtCvStringOfStringSeg(pSeg), len+2);
  5780. if (_DtCvStringOfStringSeg(pSeg) == NULL)
  5781. return -1;
  5782. strPtr = (char *) _DtCvStrPtr(_DtCvStringOfStringSeg(pSeg),
  5783. 0, len);
  5784. *strPtr++ = ' ';
  5785. *strPtr = '\0';
  5786. }
  5787. else if (MySaveString(&(my_struct->seg_list), my_struct, " ",
  5788. my_struct->cur_link, 1, False ) != 0)
  5789. return -1;
  5790. my_struct->last_was_space = True;
  5791. my_struct->last_was_nl = False;
  5792. }
  5793. return 0;
  5794. } /* End MarkFound */
  5795. /******************************************************************************
  5796. * Function: int SaveItemInfo (
  5797. * FormatStruct my_struct,
  5798. * int element_types,
  5799. * int exceptions);
  5800. *
  5801. * Parameters:
  5802. *
  5803. * Returns: 0 if successful, -1 if errors
  5804. *
  5805. * Purpose: Looks for the virtual page attributes.
  5806. *
  5807. ******************************************************************************/
  5808. static int
  5809. SaveItemInfo(
  5810. FormatStruct *my_struct,
  5811. SDLMask *element_types,
  5812. enum SdlElement sig_element,
  5813. SDLMask *exceptions,
  5814. SDLMask *process_mask)
  5815. {
  5816. _DtCvSegment *refItem = my_struct->add_seg;
  5817. SdlMatchData *info;
  5818. if (SDLSearchMask(process_mask, SdlElementRefItem) == False)
  5819. return 0;
  5820. info = (SdlMatchData *) malloc (sizeof(SdlMatchData));
  5821. if (NULL == info)
  5822. return -1;
  5823. /*
  5824. * save the clan, ssi & level of this refitem
  5825. */
  5826. *info = my_struct->el_info.match;
  5827. SegMatchData(refItem) = (void *) info;
  5828. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SSI);
  5829. return 0;
  5830. } /* End SaveItemInfo */
  5831. /******************************************************************************
  5832. * Function: int AllocateBlock (
  5833. * FormatStruct my_struct,
  5834. * int element_types,
  5835. * int exceptions);
  5836. * Parameters:
  5837. *
  5838. * Returns: 0 if successful, -1 if errors
  5839. *
  5840. * Purpose:
  5841. *
  5842. ******************************************************************************/
  5843. static int
  5844. AllocateBlock(
  5845. FormatStruct *my_struct,
  5846. SDLMask *element_types,
  5847. enum SdlElement sig_element,
  5848. SDLMask *exceptions,
  5849. SDLMask *process_mask)
  5850. {
  5851. /*
  5852. * allocate a block of information all at once for later segments.
  5853. * This, hopefully, will save processing time when later freed.
  5854. *
  5855. * Simply change the malloc_size in the formatting struct.
  5856. */
  5857. if (my_struct->add_seg != NULL)
  5858. {
  5859. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_COUNT))
  5860. my_struct->malloc_size = ElCount(my_struct);
  5861. else
  5862. {
  5863. my_struct->malloc_size = 500;
  5864. if (ElType(my_struct) == SdlElementToss)
  5865. my_struct->malloc_size = 160;
  5866. }
  5867. }
  5868. return 0;
  5869. } /* End AllocateBlock */
  5870. /******************************************************************************
  5871. * Function: int CleanUpBlock (
  5872. * FormatStruct my_struct,
  5873. * int element_types,
  5874. * int exceptions);
  5875. * Parameters:
  5876. *
  5877. * Returns: 0 if successful, -1 if errors
  5878. *
  5879. * Purpose:
  5880. *
  5881. ******************************************************************************/
  5882. static int
  5883. CleanUpBlock(
  5884. FormatStruct *my_struct,
  5885. SDLMask *element_types,
  5886. enum SdlElement sig_element,
  5887. SDLMask *exceptions,
  5888. SDLMask *process_mask)
  5889. {
  5890. /*
  5891. * Go back to piece meal allocation.
  5892. */
  5893. my_struct->malloc_size = 1;
  5894. return 0;
  5895. } /* End CleanUpBlock */
  5896. /******************************************************************************
  5897. * Function: int RegisterLink (
  5898. * FormatStruct my_struct,
  5899. * int element_types,
  5900. * int exceptions);
  5901. *
  5902. * Parameters:
  5903. *
  5904. * Returns: 0 if successful, -1 if errors
  5905. *
  5906. * Purpose: Looks for the virtual page attributes.
  5907. *
  5908. ******************************************************************************/
  5909. static int
  5910. RegisterLink(
  5911. FormatStruct *my_struct,
  5912. SDLMask *element_types,
  5913. enum SdlElement sig_element,
  5914. SDLMask *exceptions,
  5915. SDLMask *process_mask)
  5916. {
  5917. int winType = _DtCvWindowHint_CurrentWindow;
  5918. SDLId rid = _DtCvContainerIdOfSeg(my_struct->add_seg);
  5919. if (SDLSearchMask(process_mask, SdlElementLink) == False)
  5920. return 0;
  5921. switch (ElWindow(my_struct))
  5922. {
  5923. case SdlWindowNew: winType = _DtCvWindowHint_NewWindow;
  5924. break;
  5925. case SdlWindowPopup: winType = _DtCvWindowHint_PopupWindow;
  5926. break;
  5927. }
  5928. my_struct->cur_link = _DtLinkDbAddLink(my_struct->my_links, NULL, rid,
  5929. _DtCvLinkType_SameVolume, winType, NULL);
  5930. if (rid == NULL || my_struct->cur_link < 0)
  5931. return -1;
  5932. /*
  5933. * indicate that at least a blank should be saved for the link
  5934. */
  5935. my_struct->save_blank = True;
  5936. return 0;
  5937. } /* End RegisterLink */
  5938. /******************************************************************************
  5939. * Function: int ResolveIf (FormatStruct my_struct)
  5940. *
  5941. * Parameters:
  5942. *
  5943. * Returns: 0 if successful, -1 if errors
  5944. *
  5945. * Purpose: Looks for the virtual page attributes.
  5946. *
  5947. ******************************************************************************/
  5948. static int
  5949. ResolveIf(
  5950. FormatStruct *my_struct,
  5951. _DtCvSegment *prev_data)
  5952. {
  5953. _DtCvSegment *ifSeg = my_struct->add_seg;
  5954. _DtCvSegment *condSeg = _DtCvContainerListOfSeg(ifSeg);
  5955. _DtCvSegment *condDataSeg = _DtCvContainerListOfSeg(condSeg);
  5956. _DtCvSegment *thenSeg = _DtCvNextSeg(condSeg);
  5957. _DtCvSegment *elseSeg = _DtCvNextSeg(thenSeg);
  5958. _DtCvSegment *resolveSeg = NULL;
  5959. _DtCvSegment *nextDisp = NULL;
  5960. _DtCvSegment *el = NULL;
  5961. char *ifData = NULL;
  5962. char *interpStr;
  5963. interpStr = GetInterpCmd(ElInterp(my_struct));
  5964. if (NULL == interpStr)
  5965. return -1;
  5966. if (_DtCvRunInterp(my_struct->ui_info->exec_filter,
  5967. my_struct->ui_info->client_data,
  5968. interpStr,
  5969. _DtCvStringOfStringSeg(condDataSeg), &ifData) == 0)
  5970. {
  5971. /*
  5972. * Get the pointer to the next displayable item in the 'then'
  5973. * list. This usually will point into the 'then' list,
  5974. * but may point into the 'else' list.
  5975. */
  5976. if (my_struct->then_prev != NULL)
  5977. nextDisp = my_struct->then_prev->next_disp;
  5978. /*
  5979. * use the 'then' data
  5980. */
  5981. if (atoi (ifData) != 0)
  5982. {
  5983. el = thenSeg;
  5984. /*
  5985. * check to make sure that the next_disp is NOT into the
  5986. * 'else' list (because it's about to become a dangling
  5987. * next_disp if it is!).
  5988. */
  5989. if (elseSeg != NULL)
  5990. {
  5991. /*
  5992. * if the next displayable segment is in the 'else'
  5993. * list, null out the next displayable segement since
  5994. * there isn't anything in the 'then' list.
  5995. */
  5996. if (my_struct->then_prev == my_struct->else_prev)
  5997. nextDisp = NULL;
  5998. else
  5999. /*
  6000. * terminate the displayable segment list
  6001. * before the 'else' list.
  6002. */
  6003. my_struct->else_prev->next_disp = NULL;
  6004. }
  6005. }
  6006. else if (elseSeg != NULL)
  6007. {
  6008. /*
  6009. * use the 'else' data.
  6010. */
  6011. el = elseSeg;
  6012. /*
  6013. * Get the next displayable item in the 'else' list.
  6014. */
  6015. if (my_struct->else_prev != NULL)
  6016. nextDisp = my_struct->else_prev->next_disp;
  6017. }
  6018. if (el != NULL)
  6019. {
  6020. resolveSeg = _DtCvContainerListOfSeg(el);
  6021. _DtCvContainerListOfSeg(el) = NULL;
  6022. }
  6023. free(ifData);
  6024. }
  6025. /*
  6026. * set the true next displayable pointer.
  6027. */
  6028. if (prev_data != NULL)
  6029. prev_data->next_disp = nextDisp;
  6030. /*
  6031. * set the previous displayable segment to the last displayable
  6032. * segment in the 'if' clause; in case more displayable segments
  6033. * follow.
  6034. */
  6035. my_struct->prev_data = nextDisp;
  6036. /*
  6037. * free the no longer needed if construct
  6038. */
  6039. _DtHelpFreeSegments(my_struct->add_seg, _DtCvFALSE,
  6040. my_struct->ui_info->destroy_region,
  6041. my_struct->ui_info->client_data);
  6042. /*
  6043. * set the add segment to the result of the if
  6044. */
  6045. my_struct->add_seg = resolveSeg;
  6046. return 0;
  6047. } /* End ResolveIf */
  6048. /******************************************************************************
  6049. * Function: int ZeroOrOne (
  6050. * FormatStruct my_struct,
  6051. * int element_types,
  6052. * int exceptions);
  6053. *
  6054. * Parameters:
  6055. *
  6056. * Returns: 0 if successful, -1 if errors
  6057. *
  6058. * Purpose: Looks for the virtual page attributes.
  6059. *
  6060. ******************************************************************************/
  6061. static int
  6062. ZeroOrOne(
  6063. FormatStruct *my_struct,
  6064. SDLMask *element_types,
  6065. enum SdlElement sig_element,
  6066. SDLMask *exceptions,
  6067. SDLMask *process_mask)
  6068. {
  6069. int result = 0;
  6070. if (my_struct->parsed == SdlElementNone)
  6071. result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList,
  6072. SDLSearchMask(element_types, SdlElementCdata),
  6073. &(my_struct->parsed), &(my_struct->remember),
  6074. &(my_struct->end_flag));
  6075. if (result == 0 && my_struct->end_flag == False &&
  6076. SDLSearchMask(element_types, my_struct->parsed) == True)
  6077. {
  6078. /*
  6079. * check to make sure this is *not* Cdata or if it is that the
  6080. * PcDataFollows flag is *not* set.
  6081. */
  6082. if (my_struct->parsed != SdlElementCdata ||
  6083. SDLSearchMask(element_types, SdlPcDataFollows) == False)
  6084. result = ParseSDL(my_struct, my_struct->parsed, sig_element,
  6085. exceptions, process_mask);
  6086. }
  6087. else if (result == 1) /* eof on compressed entry/file */
  6088. result = 0;
  6089. return result;
  6090. } /* End ZeroOrOne */
  6091. /******************************************************************************
  6092. * Function: int ZeroToN (
  6093. * FormatStruct my_struct,
  6094. * int element_types,
  6095. * int exceptions);
  6096. *
  6097. * Parameters:
  6098. *
  6099. * Returns: 0 if successful, -1 if errors
  6100. *
  6101. * Purpose: Looks for the virtual page attributes.
  6102. *
  6103. ******************************************************************************/
  6104. static int
  6105. ZeroToN(
  6106. FormatStruct *my_struct,
  6107. SDLMask *element_types,
  6108. enum SdlElement sig_element,
  6109. SDLMask *exceptions,
  6110. SDLMask *process_mask)
  6111. {
  6112. _DtCvValue done = False;
  6113. int result = 0;
  6114. while (result == 0 && !done)
  6115. {
  6116. if (my_struct->parsed == SdlElementNone)
  6117. result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList,
  6118. SDLSearchMask(element_types, SdlElementCdata),
  6119. &(my_struct->parsed), &(my_struct->remember),
  6120. &(my_struct->end_flag));
  6121. if (result == 0 && my_struct->end_flag == False &&
  6122. SDLSearchMask(element_types, my_struct->parsed) == True)
  6123. {
  6124. /*
  6125. * check to make sure this is *not* Cdata or if it is that the
  6126. * PcDataFollows flag is *not* set.
  6127. */
  6128. if (my_struct->parsed != SdlElementCdata ||
  6129. SDLSearchMask(element_types, SdlPcDataFollows) == False)
  6130. result = ParseSDL(my_struct, my_struct->parsed,
  6131. sig_element, exceptions, process_mask);
  6132. else
  6133. done = True;
  6134. }
  6135. else
  6136. {
  6137. if (result == 1) /* eof on compressed entry/file */
  6138. result = 0;
  6139. done = True;
  6140. }
  6141. }
  6142. return result;
  6143. } /* End ZeroToN */
  6144. /******************************************************************************
  6145. * Function: int OneToN (
  6146. * FormatStruct my_struct,
  6147. * int element_types,
  6148. * int exceptions);
  6149. *
  6150. * Parameters:
  6151. *
  6152. * Returns: 0 if successful, -1 if errors
  6153. *
  6154. * Purpose: Looks for the virtual page attributes.
  6155. *
  6156. ******************************************************************************/
  6157. static int
  6158. OneToN(
  6159. FormatStruct *my_struct,
  6160. SDLMask *element_types,
  6161. enum SdlElement sig_element,
  6162. SDLMask *exceptions,
  6163. SDLMask *process_mask)
  6164. {
  6165. int found = False;
  6166. int result = 0;
  6167. int done = False;
  6168. while (result == 0 && !done)
  6169. {
  6170. if (my_struct->parsed == SdlElementNone)
  6171. result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList,
  6172. SDLSearchMask(element_types, SdlElementCdata),
  6173. &(my_struct->parsed), &(my_struct->remember),
  6174. &(my_struct->end_flag));
  6175. if (result == 0 && my_struct->end_flag == False &&
  6176. SDLSearchMask(element_types, my_struct->parsed) == True)
  6177. {
  6178. found = True;
  6179. result = ParseSDL(my_struct, my_struct->parsed, sig_element,
  6180. exceptions, process_mask);
  6181. }
  6182. else
  6183. done = True;
  6184. }
  6185. if (!found)
  6186. result = -1;
  6187. return result;
  6188. } /* End OneToN */
  6189. /******************************************************************************
  6190. * Function: int OnlyOne (
  6191. * FormatStruct my_struct,
  6192. * int element_types,
  6193. * int exceptions);
  6194. *
  6195. * Parameters:
  6196. *
  6197. * Returns: 0 if successful, -1 if errors
  6198. *
  6199. * Purpose: Looks for the virtual page attributes.
  6200. *
  6201. ******************************************************************************/
  6202. static int
  6203. OnlyOne(
  6204. FormatStruct *my_struct,
  6205. SDLMask *element_types,
  6206. enum SdlElement sig_element,
  6207. SDLMask *exceptions,
  6208. SDLMask *process_mask)
  6209. {
  6210. _DtCvValue found = False;
  6211. int result = 0;
  6212. if (my_struct->parsed == SdlElementNone)
  6213. result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList,
  6214. SDLSearchMask(element_types, SdlElementCdata),
  6215. &(my_struct->parsed), &(my_struct->remember),
  6216. &(my_struct->end_flag));
  6217. if (result == 0 && my_struct->end_flag == False &&
  6218. SDLSearchMask(element_types, my_struct->parsed) == True)
  6219. {
  6220. found = True;
  6221. result = ParseSDL(my_struct, my_struct->parsed, sig_element,
  6222. exceptions, process_mask);
  6223. }
  6224. if (!found)
  6225. result = -1;
  6226. return result;
  6227. } /* End OnlyOne */
  6228. /******************************************************************************
  6229. * Function: int OnlyOneEach (
  6230. * FormatStruct my_struct,
  6231. * int element_types,
  6232. * int exceptions);
  6233. *
  6234. * Parameters:
  6235. *
  6236. * Returns: 0 if successful, -1 if errors
  6237. *
  6238. * Purpose: Looks for the virtual page attributes.
  6239. *
  6240. ******************************************************************************/
  6241. static int
  6242. OnlyOneEach(
  6243. FormatStruct *my_struct,
  6244. SDLMask *element_types,
  6245. enum SdlElement sig_element,
  6246. SDLMask *exceptions,
  6247. SDLMask *process_mask)
  6248. {
  6249. int result = 0;
  6250. enum SdlElement myEl;
  6251. SDLMask myMask[SDL_MASK_LEN];
  6252. SaveRestoreMask(myMask, element_types);
  6253. while (result == 0 && SDLCheckMask(myMask))
  6254. {
  6255. if (my_struct->parsed == SdlElementNone)
  6256. result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList,
  6257. SDLSearchMask(myMask, SdlElementCdata),
  6258. &(my_struct->parsed), &(my_struct->remember),
  6259. &(my_struct->end_flag));
  6260. if (result == 0 && my_struct->end_flag == False &&
  6261. SDLSearchMask(element_types, my_struct->parsed) == True)
  6262. {
  6263. myEl = my_struct->parsed;
  6264. result = ParseSDL(my_struct, my_struct->parsed, sig_element,
  6265. exceptions, process_mask);
  6266. SDLStripFromMask(myMask, myEl);
  6267. }
  6268. else
  6269. result = -1;
  6270. }
  6271. if (SDLCheckMask(myMask))
  6272. result = -1;
  6273. return result;
  6274. } /* End OnlyOneEach */
  6275. /******************************************************************************
  6276. * Function: int Cdata (FormatStruct my_struct,
  6277. * int cur_element, exceptions);
  6278. *
  6279. * Parameters:
  6280. *
  6281. * Returns: 0 if successful, -1 if errors
  6282. *
  6283. * Purpose: Looks for the virtual page attributes.
  6284. *
  6285. ******************************************************************************/
  6286. static int
  6287. Cdata(
  6288. FormatStruct *my_struct,
  6289. SDLMask *cur_element,
  6290. enum SdlElement sig_element,
  6291. SDLMask *exceptions,
  6292. SDLMask *process_mask)
  6293. {
  6294. int i;
  6295. int reason;
  6296. int myLen = 0;
  6297. int curLen = my_struct->mb_len;
  6298. int multiLen = my_struct->mb_len;
  6299. int saveLen = my_struct->mb_len;
  6300. char nonBreakChar;
  6301. char *string = NULL;
  6302. char spaceStr[] = " ";
  6303. char dashStr[] = "-";
  6304. SdlOption type = ElFrmtType(my_struct);
  6305. _DtCvSegment *pSeg = NULL;
  6306. _DtCvValue nlToSpace = True;
  6307. _DtCvValue processFlag = SDLSearchMask(process_mask, SdlElementCdata);
  6308. if (my_struct->ui_info->nl_to_space == 0)
  6309. nlToSpace = False;
  6310. if (type == SdlTypeCdata)
  6311. {
  6312. /*
  6313. * the element requires straight cdata for processing - i.e.
  6314. * the data is going to be passed off to an interperter.
  6315. * Therefore it doesn't want it broken up into different
  6316. * byte length segments.
  6317. *
  6318. * Therefore, force the string save to put all the data into
  6319. * one string.
  6320. */
  6321. saveLen = 1;
  6322. }
  6323. if (my_struct->remember != NULL)
  6324. {
  6325. i = 0;
  6326. string = my_struct->remember;
  6327. myLen = strlen(string);
  6328. while (string[i] != '\0' && i < myLen)
  6329. {
  6330. if (multiLen != 1)
  6331. curLen = mblen (&string[i], multiLen);
  6332. if (curLen == 1)
  6333. {
  6334. if (my_struct->last_was_nl == True)
  6335. {
  6336. if (MoveString(&string, &myLen, &i) == -1)
  6337. return -1;
  6338. string[i++] = ' ';
  6339. my_struct->last_was_space = True;
  6340. }
  6341. my_struct->last_was_nl = False;
  6342. my_struct->last_was_mb = False;
  6343. if (string[i] == '\t')
  6344. string[i] = ' ';
  6345. if (string[i] == '&')
  6346. {
  6347. strmove (&string[i], &string[i+1]);
  6348. if (string[i] == '\0')
  6349. {
  6350. string[i] = BufFileGet(my_struct->my_file);
  6351. if (string[i] == BUFFILEEOF)
  6352. return -1;
  6353. string[i+1] = '\0';
  6354. }
  6355. /*
  6356. * is this an SGML numeric character reference
  6357. * entity? if so, it should have the format
  6358. * '&#d[d[d]][;]' where 'ddd' represent characters
  6359. * of '0' to '9'. The semi-colon is required iff
  6360. * the next character is a numeric character of '0'
  6361. * to '9'. Otherwise it is optional.
  6362. */
  6363. if (string[i] == '#')
  6364. {
  6365. int j;
  6366. int value;
  6367. #define ESC_STRING_LEN 4
  6368. i++;
  6369. /*
  6370. * Is there enough to room to process three digits
  6371. * and a possible semi-colon?
  6372. */
  6373. if (myLen - i < ESC_STRING_LEN)
  6374. {
  6375. /*
  6376. * lengthen the string so that it can contain
  6377. * the information
  6378. */
  6379. myLen += ESC_STRING_LEN;
  6380. string = (char *) realloc(string,
  6381. sizeof(char) * (myLen + 1));
  6382. if (string == NULL)
  6383. return -1;
  6384. }
  6385. /*
  6386. * now make sure that the entire numeric entity
  6387. * exists in the string.
  6388. */
  6389. j = i;
  6390. while ('0' <= string[i] && string[i] <= '9')
  6391. i++;
  6392. /*
  6393. * run into the end of string before running
  6394. * into a delimiter? Fill out the escaped
  6395. * numeric character.
  6396. */
  6397. if (string[i] == '\0')
  6398. {
  6399. do
  6400. {
  6401. string[i] = BufFileGet(my_struct->my_file);
  6402. if (string[i] == BUFFILEEOF)
  6403. return -1;
  6404. i++;
  6405. } while (i < myLen && '0' <= string[i-1]
  6406. && string[i-1] <= '9');
  6407. /*
  6408. * end the string and back up to the last
  6409. * character
  6410. */
  6411. string[i] = '\0';
  6412. i--;
  6413. }
  6414. /*
  6415. * the fourth character is a numeric, error
  6416. */
  6417. if ('0' <= string[i] && string[i] <= '9')
  6418. return -1;
  6419. if (string[i] == ';')
  6420. i++;
  6421. value = atoi(&string[j]);
  6422. if (value > 255)
  6423. return -1;
  6424. /*
  6425. * smash over the pound sign with the 'real' value
  6426. * and copy the rest of the string to after it.
  6427. */
  6428. string[j-1] = (char) value;
  6429. strmove (&string[j], &string[i]);
  6430. i = j;
  6431. }
  6432. if (string[i] == '\n')
  6433. {
  6434. if (ProcessString(my_struct, True, True, True,
  6435. True,
  6436. processFlag, string, saveLen, &i) != 0)
  6437. return -1;
  6438. }
  6439. else if (string[i] == ' ')
  6440. {
  6441. if (ProcessNonBreakChar(my_struct, processFlag,
  6442. spaceStr, string, saveLen, &i) != 0)
  6443. return -1;
  6444. }
  6445. else if (string[i] == '-')
  6446. {
  6447. if (ProcessNonBreakChar(my_struct, processFlag,
  6448. dashStr, string, saveLen, &i) != 0)
  6449. return -1;
  6450. }
  6451. else
  6452. my_struct->last_was_space = False;
  6453. i++;
  6454. }
  6455. else if (string[i] == '\n')
  6456. {
  6457. /*
  6458. * want to keep the newlines
  6459. */
  6460. if (type == SdlTypeCdata)
  6461. i++;
  6462. else if (type == SdlTypeDynamic ||
  6463. type == SdlTypeUnlinedLiteral)
  6464. {
  6465. if (my_struct->last_was_space == False)
  6466. my_struct->last_was_nl = True;
  6467. strmove (&string[i], &string[i+1]);
  6468. }
  6469. else
  6470. {
  6471. string[i] = '\0';
  6472. if (processFlag == True &&
  6473. MySaveString(&(my_struct->seg_list),
  6474. my_struct, string, my_struct->cur_link,
  6475. saveLen, True) != 0)
  6476. {
  6477. MyFree(string);
  6478. return -1;
  6479. }
  6480. strmove (string, &string[i+1]);
  6481. i = 0;
  6482. }
  6483. }
  6484. else if (string[i] == ' ')
  6485. {
  6486. if (False == my_struct->save_blank &&
  6487. type != SdlTypeLiteral && type != SdlTypeUnlinedLiteral
  6488. && my_struct->last_was_space == True)
  6489. strmove (&string[i], &string[i+1]);
  6490. else
  6491. i++;
  6492. my_struct->last_was_space = True;
  6493. }
  6494. else
  6495. {
  6496. my_struct->last_was_space = False;
  6497. i++;
  6498. }
  6499. }
  6500. else if (curLen > 0)
  6501. {
  6502. if (my_struct->last_was_nl == True)
  6503. {
  6504. if (nlToSpace == True || my_struct->last_was_mb == False)
  6505. {
  6506. if (MoveString(&string, &myLen, &i) == -1)
  6507. return -1;
  6508. string[i++] = ' ';
  6509. }
  6510. else /* the last was a multibyte character, tighten up */
  6511. {
  6512. i--;
  6513. strmove (&string[i], &string[i+1]);
  6514. }
  6515. }
  6516. my_struct->last_was_space = False;
  6517. my_struct->last_was_nl = False;
  6518. my_struct->last_was_mb = True;
  6519. i += curLen;
  6520. }
  6521. else if (curLen == 0)
  6522. return -1;
  6523. else /* if (curLen < 0) */
  6524. {
  6525. /*
  6526. * must finish up the character
  6527. */
  6528. int len = i + 1;
  6529. while (curLen < 0 && len - i < multiLen)
  6530. {
  6531. if (myLen <= len)
  6532. {
  6533. string = (char *) realloc(string, myLen + multiLen + 1);
  6534. if (string == NULL)
  6535. return -1;
  6536. myLen += multiLen;
  6537. }
  6538. string[len] = BufFileGet(my_struct->my_file);
  6539. if (string[len++] == BUFFILEEOF)
  6540. return -1;
  6541. string[len] = '\0';
  6542. curLen = mblen (&string[i], multiLen);
  6543. }
  6544. if (curLen < 0)
  6545. return -1;
  6546. }
  6547. }
  6548. if (processFlag == False)
  6549. {
  6550. free(string);
  6551. string = NULL;
  6552. myLen = 0;
  6553. }
  6554. my_struct->remember = NULL;
  6555. }
  6556. do {
  6557. my_struct->parsed = SdlElementNone;
  6558. reason = _DtHelpCeGetSdlCdata(my_struct->my_file, type, multiLen,
  6559. nlToSpace,
  6560. &my_struct->last_was_space,
  6561. &my_struct->last_was_nl,
  6562. &my_struct->last_was_mb,
  6563. &nonBreakChar,
  6564. (processFlag == True ? &string : ((char**)NULL)),
  6565. &myLen);
  6566. if (reason < 0)
  6567. return -1;
  6568. if (string != NULL && *string != '\0')
  6569. {
  6570. /*
  6571. * save the string.
  6572. */
  6573. if (MySaveString(&(my_struct->seg_list), my_struct,
  6574. string, my_struct->cur_link, saveLen,
  6575. (1 == reason ? True : False)) != 0)
  6576. {
  6577. MyFree(string);
  6578. return -1;
  6579. }
  6580. /*
  6581. * indicate that a string was saved for the current link
  6582. */
  6583. my_struct->save_blank = False;
  6584. /*
  6585. * null the temp buffer.
  6586. */
  6587. string[0] = '\0';
  6588. /*
  6589. * reset flags if we stopped because of a newline.
  6590. */
  6591. if (1 == reason && (SdlTypeLiteral == type || SdlTypeLined == type))
  6592. {
  6593. my_struct->last_was_space = True;
  6594. my_struct->last_was_nl = False;
  6595. }
  6596. }
  6597. else if (reason == 1) /* stopped because of newline */
  6598. {
  6599. pSeg = my_struct->prev_data;
  6600. if (pSeg == NULL || _DtCvIsSegNewLine(pSeg))
  6601. {
  6602. if (_DtHelpCeAllocSegment(my_struct->malloc_size,
  6603. &(my_struct->alloc_size),
  6604. &(my_struct->block_list), &pSeg) != 0)
  6605. return -1;
  6606. pSeg->type = _DtCvSetTypeToNoop(pSeg->type);
  6607. if (my_struct->prev_data != NULL)
  6608. my_struct->prev_data->next_disp = pSeg;
  6609. my_struct->prev_data = pSeg;
  6610. _DtHelpCeAddSegToList(pSeg, &(my_struct->seg_list),
  6611. &(my_struct->last_seg));
  6612. }
  6613. pSeg->type = _DtCvSetTypeToNewLine(pSeg->type);
  6614. my_struct->last_was_space = True;
  6615. my_struct->last_was_nl = False;
  6616. }
  6617. /*
  6618. * did we stop because of a non-breaking character?
  6619. */
  6620. if (2 == reason && True == processFlag)
  6621. {
  6622. /*
  6623. * copy the non breaking character into a buffer.
  6624. */
  6625. if (1 > myLen)
  6626. {
  6627. string = (char *) malloc (sizeof(char) * 32);
  6628. myLen = 32;
  6629. }
  6630. string[0] = nonBreakChar;
  6631. string[1] = '\0';
  6632. /*
  6633. * save the string.
  6634. */
  6635. my_struct->flags = _DtCvSetTypeToNonBreak(my_struct->flags);
  6636. if (MySaveString(&(my_struct->seg_list), my_struct,
  6637. string, my_struct->cur_link, saveLen, False) != 0)
  6638. {
  6639. MyFree(string);
  6640. return -1;
  6641. }
  6642. my_struct->flags = my_struct->flags & ~(_DtCvNON_BREAK);
  6643. /*
  6644. * indicate that the non-breaking character is considered
  6645. * non-white space.
  6646. */
  6647. my_struct->last_was_space = False;
  6648. /*
  6649. * indicate that a string was saved for the current link
  6650. */
  6651. my_struct->save_blank = False;
  6652. /*
  6653. * null the temp buffer.
  6654. */
  6655. string[0] = '\0';
  6656. }
  6657. } while (reason > 0);
  6658. MyFree(string);
  6659. return 0;
  6660. } /* End Cdata */
  6661. /******************************************************************************
  6662. * Function: int ProcessEnterAttr (
  6663. * FormatStruct my_struct,
  6664. * int cur_element, exceptions);
  6665. *
  6666. * Parameters:
  6667. *
  6668. * Returns: 0 if successful, -1 if errors
  6669. *
  6670. * Purpose:
  6671. *
  6672. ******************************************************************************/
  6673. static int
  6674. ProcessEnterAttr(
  6675. FormatStruct *my_struct,
  6676. SDLMask *cur_element,
  6677. enum SdlElement sig_element,
  6678. SDLMask *exceptions,
  6679. SDLMask *process_mask)
  6680. {
  6681. /*
  6682. * save the enter string as part of this element's segment list
  6683. */
  6684. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_ENTER) &&
  6685. ((int)strlen(ElEnter(my_struct))) > 0 &&
  6686. MySaveString(&(my_struct->seg_list), my_struct, ElEnter(my_struct),
  6687. my_struct->cur_link, my_struct->mb_len, False) != 0)
  6688. return -1;
  6689. return 0;
  6690. } /* End ProcessEnterAttr */
  6691. /******************************************************************************
  6692. * Function: int ProcessExitAttr (
  6693. * FormatStruct my_struct,
  6694. * int cur_element, exceptions);
  6695. *
  6696. * Parameters:
  6697. *
  6698. * Returns: 0 if successful, -1 if errors
  6699. *
  6700. * Purpose:
  6701. *
  6702. ******************************************************************************/
  6703. static int
  6704. ProcessExitAttr(
  6705. FormatStruct *my_struct,
  6706. SDLMask *cur_element,
  6707. enum SdlElement sig_element,
  6708. SDLMask *exceptions,
  6709. SDLMask *process_mask)
  6710. {
  6711. /*
  6712. * save the exit string as part of this element's segment list
  6713. */
  6714. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_EXIT) &&
  6715. ((int)strlen(ElExit(my_struct))) > 0 &&
  6716. MySaveString(&(my_struct->seg_list), my_struct, ElExit(my_struct),
  6717. my_struct->cur_link, my_struct->mb_len, False) != 0)
  6718. return -1;
  6719. return 0;
  6720. } /* End ProcessExitAttr */
  6721. /******************************************************************************
  6722. * Function: int FakeEnd (FormatStruct my_struct,
  6723. * int cur_element, exceptions);
  6724. *
  6725. * Parameters:
  6726. *
  6727. * Returns: 0 if successful, -1 if errors
  6728. *
  6729. * Purpose: Looks for the virtual page attributes.
  6730. *
  6731. ******************************************************************************/
  6732. static int
  6733. FakeEnd(
  6734. FormatStruct *my_struct,
  6735. SDLMask *cur_element,
  6736. enum SdlElement sig_element,
  6737. SDLMask *exceptions,
  6738. SDLMask *process_mask)
  6739. {
  6740. my_struct->end_flag = True;
  6741. my_struct->faked_end = True;
  6742. MaskToValue(cur_element, my_struct->parsed);
  6743. return 0;
  6744. } /* End FakeEnd */
  6745. /******************************************************************************
  6746. * Function: int AddRowToTable (FormatStruct my_struct,
  6747. * int cur_element, exceptions);
  6748. *
  6749. * Parameters:
  6750. *
  6751. * Returns: 0 if successful, -1 if errors
  6752. *
  6753. * Purpose: Looks for the virtual page attributes.
  6754. *
  6755. ******************************************************************************/
  6756. static int
  6757. AddRowToTable(
  6758. FormatStruct *my_struct,
  6759. SDLMask *cur_element,
  6760. enum SdlElement sig_element,
  6761. SDLMask *exceptions,
  6762. SDLMask *process_mask)
  6763. {
  6764. if (SDLSearchMask(process_mask, SdlElementFrowvec) != False)
  6765. {
  6766. ElTableCellIds(my_struct) = (char **) _DtCvAddPtrToArray(
  6767. (void **) ElTableCellIds(my_struct),
  6768. ElTableCellId(my_struct));
  6769. if (NULL == ElTableCellIds(my_struct))
  6770. return -1;
  6771. ClearAttrFlag(my_struct->el_info, SDL_ATTR_CELLS);
  6772. }
  6773. return 0;
  6774. } /* End AddRowToTable */
  6775. /******************************************************************************
  6776. * Function: int SaveLangCharSet (
  6777. * FormatStruct my_struct,
  6778. * int cur_element, exceptions);
  6779. *
  6780. * Parameters:
  6781. *
  6782. * Returns: 0 if successful, -1 if errors
  6783. *
  6784. * Purpose: Looks for the virtual page attributes.
  6785. *
  6786. ******************************************************************************/
  6787. static int
  6788. SaveLangCharSet(
  6789. FormatStruct *my_struct,
  6790. SDLMask *cur_element,
  6791. enum SdlElement sig_element,
  6792. SDLMask *exceptions,
  6793. SDLMask *process_mask)
  6794. {
  6795. char **info;
  6796. if (SDLSearchMask(process_mask, SdlElementText) == False ||
  6797. !(SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LANGUAGE) ||
  6798. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CHARSET)))
  6799. return 0;
  6800. info = (char **) calloc (2, sizeof(char *));
  6801. if (NULL == info)
  6802. return -1;
  6803. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LANGUAGE))
  6804. info[0] = ElLanguage(my_struct);
  6805. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CHARSET))
  6806. info[1] = ElCharSet(my_struct);
  6807. ClearAttrFlag(my_struct->el_info, SDL_ATTR_LANGUAGE);
  6808. ClearAttrFlag(my_struct->el_info, SDL_ATTR_CHARSET);
  6809. _SdlSegLangChar(my_struct->add_seg) = (void *) info;
  6810. return 0;
  6811. } /* End SaveLangCharSet */
  6812. /******************************************************************************
  6813. * Function: int CopyDocInfo (FormatStruct my_struct,
  6814. * int cur_element, exceptions);
  6815. *
  6816. * Parameters:
  6817. *
  6818. * Returns: 0 if successful, -1 if errors
  6819. *
  6820. * Purpose: Looks for the virtual page attributes.
  6821. *
  6822. ******************************************************************************/
  6823. static int
  6824. CopyDocInfo(
  6825. FormatStruct *my_struct,
  6826. SDLMask *cur_element,
  6827. enum SdlElement sig_element,
  6828. SDLMask *exceptions,
  6829. SDLMask *process_mask)
  6830. {
  6831. SDLDocInfo *docInfo;
  6832. if (SDLSearchMask(process_mask, SdlElementSdlDoc) == False)
  6833. return 0;
  6834. docInfo = (SDLDocInfo *) malloc (sizeof(SDLDocInfo));
  6835. if (NULL == docInfo)
  6836. return -1;
  6837. *(docInfo) = ElDocInfo(my_struct);
  6838. _SdlDocInfoPtrLanguage(docInfo) = strdup(ElLanguage(my_struct));
  6839. _SdlDocInfoPtrCharSet(docInfo) = strdup(ElCharSet(my_struct));
  6840. ClearAttrFlag(my_struct->el_info, SDL_ATTR_DOCID);
  6841. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SDLDTD);
  6842. ClearAttrFlag(my_struct->el_info, SDL_ATTR_TIMESTAMP);
  6843. ClearAttrFlag(my_struct->el_info, SDL_ATTR_FRST_PG);
  6844. ClearAttrFlag(my_struct->el_info, SDL_ATTR_VERSION);
  6845. FrmtPrivInfoPtr(my_struct->add_seg)->doc_info = (void *) docInfo;
  6846. return 0;
  6847. } /* End CopyDocInfo */
  6848. /******************************************************************************
  6849. * Function: int CopyAnchorId (FormatStruct my_struct,
  6850. * int cur_element, exceptions);
  6851. *
  6852. * Parameters:
  6853. *
  6854. * Returns: 0 if successful, -1 if errors
  6855. *
  6856. * Purpose: Looks for the virtual page attributes.
  6857. *
  6858. ******************************************************************************/
  6859. static int
  6860. CopyAnchorId(
  6861. FormatStruct *my_struct,
  6862. SDLMask *cur_element,
  6863. enum SdlElement sig_element,
  6864. SDLMask *exceptions,
  6865. SDLMask *process_mask)
  6866. {
  6867. _DtCvSegment *mySeg = my_struct->add_seg;
  6868. /*
  6869. * if we're not suppose to process this, skip.
  6870. */
  6871. if (SDLSearchMask(process_mask, SdlElementAnchor) == False)
  6872. return 0;
  6873. /*
  6874. * copy the id.
  6875. */
  6876. _DtCvIdOfMarkerSeg(mySeg) = ElId(my_struct);
  6877. /*
  6878. * clear the flag so that it don't get freed.
  6879. */
  6880. ClearAttrFlag(my_struct->el_info, SDL_ATTR_ID);
  6881. return 0;
  6882. } /* End CopyDocInfo */
  6883. /******************************************************************************
  6884. * Function: int LoadGraphic (
  6885. * FormatStruct my_struct,
  6886. * int cur_element, exceptions);
  6887. *
  6888. * Parameters:
  6889. *
  6890. * Returns: 0 if successful, -1 if errors
  6891. *
  6892. * Purpose: Looks for the virtual page attributes.
  6893. *
  6894. ******************************************************************************/
  6895. static int
  6896. LoadGraphic(
  6897. FormatStruct *my_struct,
  6898. SDLMask *cur_element,
  6899. enum SdlElement sig_element,
  6900. SDLMask *exceptions,
  6901. SDLMask *process_mask)
  6902. {
  6903. int result = 0;
  6904. if (SDLSearchMask(process_mask, SdlElementGraphic) != False)
  6905. {
  6906. /*
  6907. * get my container segment.
  6908. */
  6909. _DtCvSegment *mySeg = my_struct->add_seg;
  6910. _DtCvSegment *cvRegion; /* Canvas Engine Region */
  6911. result = -1;
  6912. /*
  6913. * allocate a Canvas Engine region.
  6914. */
  6915. if (_DtHelpCeAllocSegment(1, NULL, NULL, &cvRegion) == 0)
  6916. {
  6917. /*
  6918. * got memory for a region, now fill out the information.
  6919. *
  6920. * even if the load fails, we should just throw away
  6921. * the graphic and continue.
  6922. */
  6923. result = 0;
  6924. if (NULL != my_struct->ui_info->load_graphic &&
  6925. (*(my_struct->ui_info->load_graphic))(
  6926. my_struct->ui_info->client_data,
  6927. my_struct->vol_name,
  6928. my_struct->id_string,
  6929. ElSnbXid(my_struct),
  6930. ElSnbFormat(my_struct),
  6931. ElSnbMethod(my_struct),
  6932. &(_DtCvWidthOfRegionSeg(cvRegion)),
  6933. &(_DtCvHeightOfRegionSeg(cvRegion)),
  6934. &(_DtCvInfoOfRegionSeg(cvRegion))) == 0)
  6935. {
  6936. /*
  6937. * set the type on the region! And its ascent!
  6938. */
  6939. cvRegion->type = _DtCvSetTypeToRegion(cvRegion->type);
  6940. _DtCvAscentOfRegionSeg(cvRegion) = -1;
  6941. /*
  6942. * set the seg list for the wrapper container.
  6943. */
  6944. _DtCvContainerListOfSeg(mySeg) = cvRegion;
  6945. /*
  6946. * indicate the link has been fixed up
  6947. */
  6948. my_struct->save_blank = True;
  6949. }
  6950. else
  6951. {
  6952. /*
  6953. * problems loading the graphic. Clean up!
  6954. */
  6955. MyFree(cvRegion);
  6956. }
  6957. }
  6958. }
  6959. return result;
  6960. } /* End LoadGraphic */
  6961. /******************************************************************************
  6962. * Function: int ColInfoToTableInfo (
  6963. * FormatStruct my_struct,
  6964. * int cur_element, exceptions);
  6965. *
  6966. * Parameters:
  6967. *
  6968. * Returns: 0 if successful, -1 if errors
  6969. *
  6970. * Purpose: Looks for the virtual page attributes.
  6971. *
  6972. ******************************************************************************/
  6973. static int
  6974. ColInfoToTableInfo(
  6975. FormatStruct *my_struct,
  6976. SDLMask *cur_element,
  6977. enum SdlElement sig_element,
  6978. SDLMask *exceptions,
  6979. SDLMask *process_mask)
  6980. {
  6981. if (SDLSearchMask(process_mask, SdlElementForm) != False)
  6982. {
  6983. int i;
  6984. int mySize = ElTableColNum(my_struct);
  6985. const char *next;
  6986. const char *start = NULL;
  6987. const char *last = NULL;
  6988. char **colWidths = NULL;
  6989. _DtCvFrmtOption *colJust;
  6990. colWidths = (char **) malloc (sizeof(char *) * mySize);
  6991. colJust = (_DtCvFrmtOption *) malloc (sizeof(_DtCvFrmtOption)*mySize);
  6992. if (NULL == colWidths || NULL == colJust)
  6993. {
  6994. MyFree(colWidths);
  6995. MyFree(colJust);
  6996. return -1;
  6997. }
  6998. /*
  6999. * now process the column width specification.
  7000. */
  7001. next = ElTableColWStr(my_struct);
  7002. if (NULL == next || '\0' == *next)
  7003. next = "1";
  7004. for (i = 0; i < mySize; i++)
  7005. {
  7006. /* skip the leading spaces */
  7007. while (' ' == *next) next++;
  7008. /* if the string really moved */
  7009. if (last != next)
  7010. start = next;
  7011. /* go to the end of this specification */
  7012. while (' ' != *next && '\0' != *next) next++;
  7013. /* duplicate the specification */
  7014. colWidths[i] = strdup(start);
  7015. if (NULL == colWidths[i])
  7016. return -1;
  7017. /* mark the end of the string */
  7018. last = next;
  7019. }
  7020. /*
  7021. * now process the column justify specification.
  7022. */
  7023. next = ElTableColJStr(my_struct);
  7024. if (NULL == next || '\0' == *next)
  7025. next = NullOption;
  7026. for (i = 0; i < mySize; i++)
  7027. {
  7028. /* skip the leading spaces */
  7029. while (' ' == *next) next++;
  7030. /* if the string really moved */
  7031. if (last != next)
  7032. start = next;
  7033. /* go to the end of this specification */
  7034. while (' ' != *next && '\0' != *next) next++;
  7035. /* determine the justification */
  7036. switch (*start)
  7037. {
  7038. case 'r':
  7039. case 'R': colJust[i] = _DtCvJUSTIFY_RIGHT;
  7040. break;
  7041. case 'c':
  7042. case 'C': colJust[i] = _DtCvJUSTIFY_CENTER;
  7043. break;
  7044. case 'd':
  7045. case 'D': colJust[i] = _DtCvJUSTIFY_NUM;
  7046. break;
  7047. case 'l':
  7048. case 'L': colJust[i] = _DtCvJUSTIFY_LEFT;
  7049. break;
  7050. default : colJust[i] = _DtCvJUSTIFY_LEFT;
  7051. if (NullOption == start)
  7052. colJust[i] = _DtCvINHERIT;
  7053. break;
  7054. }
  7055. /* mark the end of the string */
  7056. last = next;
  7057. }
  7058. ElTableColWidths(my_struct) = colWidths;
  7059. ElTableColJust(my_struct) = colJust;
  7060. }
  7061. return 0;
  7062. } /* End ColInfoToTableInfo */
  7063. /******************************************************************************
  7064. * Function: int CopyIdInfo (FormatStruct my_struct,
  7065. * int cur_element, exceptions);
  7066. *
  7067. * Parameters:
  7068. *
  7069. * Returns: 0 if successful, -1 if errors
  7070. *
  7071. * Purpose: Looks for the virtual page attributes.
  7072. *
  7073. ******************************************************************************/
  7074. static int
  7075. CopyIdInfo(
  7076. FormatStruct *my_struct,
  7077. SDLMask *cur_element,
  7078. enum SdlElement sig_element,
  7079. SDLMask *exceptions,
  7080. SDLMask *process_mask)
  7081. {
  7082. SDLIdInfo *idInfo;
  7083. if (SDLSearchMask(process_mask, SdlElementId) == False)
  7084. return 0;
  7085. idInfo = (SDLIdInfo *) malloc (sizeof(SDLIdInfo));
  7086. if (NULL == idInfo)
  7087. return -1;
  7088. *(idInfo) = ElIdInfo(my_struct);
  7089. _SdlIdInfoPtrType(idInfo) = ElFrmtType(my_struct);
  7090. _SdlIdInfoPtrOffset(idInfo) = ElOffset(my_struct);
  7091. _SdlIdInfoPtrRlevel(idInfo) = ElLevel(my_struct);
  7092. _SdlIdInfoPtrRssi(idInfo) = ElSsi(my_struct);
  7093. ClearAttrFlag(my_struct->el_info, SDL_ATTR_RID);
  7094. ClearAttrFlag(my_struct->el_info, SDL_ATTR_RSSI);
  7095. FrmtPrivInfoPtr(my_struct->add_seg)->id_info = (void *) idInfo;
  7096. return 0;
  7097. } /* End CopyIdInfo */
  7098. /******************************************************************************
  7099. * Function: int RegisterSnbLink (FormatStruct my_struct,
  7100. * int cur_element, exceptions);
  7101. *
  7102. * Parameters:
  7103. *
  7104. * Returns: 0 if successful, -1 if errors
  7105. *
  7106. * Purpose: Looks for the virtual page attributes.
  7107. *
  7108. ******************************************************************************/
  7109. static int
  7110. RegisterSnbLink(
  7111. FormatStruct *my_struct,
  7112. SDLMask *cur_element,
  7113. enum SdlElement sig_element,
  7114. SDLMask *exceptions,
  7115. SDLMask *process_mask)
  7116. {
  7117. int linkType;
  7118. int len = 0;
  7119. char buffer[64];
  7120. char *fileSpec = NULL;
  7121. if (SDLSearchMask(process_mask, ElType(my_struct)) == False)
  7122. return 0;
  7123. fileSpec = ElSnbXid(my_struct);
  7124. switch (ElType(my_struct))
  7125. {
  7126. case SdlElementCrossDoc:
  7127. linkType = _DtCvLinkType_CrossLink;
  7128. break;
  7129. case SdlElementManPage:
  7130. linkType = _DtCvLinkType_ManPage;
  7131. break;
  7132. case SdlElementTextFile:
  7133. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_OFFSET))
  7134. {
  7135. sprintf(buffer, " %d", ElOffset(my_struct));
  7136. len += strlen(buffer);
  7137. }
  7138. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_FORMAT))
  7139. len += strlen(ElSnbFormat(my_struct));
  7140. /*
  7141. * create a new file spec for the link
  7142. */
  7143. if (0 < len)
  7144. {
  7145. len += strlen(ElSnbXid(my_struct) + 1);
  7146. fileSpec = malloc(sizeof(char) * len);
  7147. if (NULL == fileSpec)
  7148. return -1;
  7149. strcpy(fileSpec, ElSnbXid(my_struct));
  7150. strcat(fileSpec, buffer);
  7151. strcat(fileSpec, ElSnbFormat(my_struct));
  7152. }
  7153. linkType = _DtCvLinkType_TextFile;
  7154. break;
  7155. case SdlElementSysCmd:
  7156. linkType = _DtCvLinkType_Execute;
  7157. break;
  7158. case SdlElementCallback:
  7159. linkType = _DtCvLinkType_AppDefine;
  7160. break;
  7161. default: return -1;
  7162. }
  7163. if (0 > _DtLinkDbAddLink(my_struct->my_links,
  7164. _DtCvContainerIdOfSeg(my_struct->add_seg),
  7165. fileSpec,
  7166. linkType,
  7167. _DtCvWindowHint_Original,
  7168. NULL))
  7169. return -1;
  7170. if (fileSpec != ElSnbXid(my_struct))
  7171. free(fileSpec);
  7172. return 0;
  7173. } /* End RegisterSnbLink */
  7174. /******************************************************************************
  7175. * Function: int RegisterSwitch (FormatStruct my_struct,
  7176. * int cur_element, exceptions);
  7177. *
  7178. * Parameters:
  7179. *
  7180. * Returns: 0 if successful, -1 if errors
  7181. *
  7182. * Purpose: Looks for the virtual page attributes.
  7183. *
  7184. ******************************************************************************/
  7185. static int
  7186. RegisterSwitch(
  7187. FormatStruct *my_struct,
  7188. SDLMask *cur_element,
  7189. enum SdlElement sig_element,
  7190. SDLMask *exceptions,
  7191. SDLMask *process_mask)
  7192. {
  7193. int result = -1;
  7194. char *interpStr;
  7195. if (SDLSearchMask(process_mask, ElType(my_struct)) == False)
  7196. return 0;
  7197. interpStr = GetInterpCmd(ElInterp(my_struct));
  7198. if (NULL != interpStr)
  7199. interpStr = strdup(interpStr);
  7200. if (NULL != interpStr)
  7201. {
  7202. if (0 == _DtLinkDbAddSwitch(my_struct->my_links,
  7203. _DtCvContainerIdOfSeg(my_struct->add_seg),
  7204. interpStr,
  7205. _DtCvStringOfStringSeg(my_struct->add_seg),
  7206. ElSwitchBranches(my_struct)))
  7207. result = 0;
  7208. free(my_struct->add_seg);
  7209. my_struct->add_seg = NULL;
  7210. }
  7211. return result;
  7212. } /* End RegisterSwitch */
  7213. /******************************************************************************
  7214. * Function: int ResolveSpcInfo (FormatStruct my_struct,
  7215. * int cur_element, exceptions);
  7216. *
  7217. * Parameters:
  7218. *
  7219. * Returns: 0 if successful, -1 if errors
  7220. *
  7221. * Purpose: Looks for the virtual page attributes.
  7222. *
  7223. ******************************************************************************/
  7224. static int
  7225. ResolveSpcInfo(
  7226. FormatStruct *my_struct,
  7227. SDLMask *cur_element,
  7228. enum SdlElement sig_element,
  7229. SDLMask *exceptions,
  7230. SDLMask *process_mask)
  7231. {
  7232. _DtCvSegment *mySeg = my_struct->add_seg;
  7233. if (SDLSearchMask(process_mask, ElType(my_struct)) != False)
  7234. {
  7235. /*
  7236. * set the non break character flag so that the layout routines
  7237. * will only wrap this to the next line if there is a space
  7238. * before it.
  7239. *
  7240. * Also set the inline flag so that the layout routines don't
  7241. * think that the region is a figure.
  7242. */
  7243. mySeg->type = _DtCvSetTypeToNonBreak(mySeg->type);
  7244. mySeg->type = _DtCvSetTypeToInLine(mySeg->type);
  7245. /*
  7246. * now establish the proper display linking.
  7247. */
  7248. if (my_struct->prev_data != NULL)
  7249. my_struct->prev_data->next_disp = mySeg;
  7250. my_struct->prev_data = mySeg;
  7251. my_struct->save_blank = False;
  7252. /*
  7253. * resolve the font hints.
  7254. */
  7255. if (_SdlFontModeResolve == my_struct->resolve_font)
  7256. (*(my_struct->ui_info->resolve_spc))(
  7257. my_struct->ui_info->client_data,
  7258. ElLanguage(my_struct),
  7259. ElCharSet(my_struct),
  7260. *(my_struct->my_fonts),
  7261. ElSpcName(my_struct),
  7262. &(_DtCvInfoOfRegionSeg(my_struct->add_seg)),
  7263. &(_DtCvWidthOfRegionSeg(my_struct->add_seg)),
  7264. &(_DtCvHeightOfRegionSeg(my_struct->add_seg)),
  7265. &(_DtCvAscentOfRegionSeg(my_struct->add_seg)));
  7266. else
  7267. {
  7268. _DtHelpDARegion *pReg;
  7269. _DtHelpDASpcInfo *spcInfo;
  7270. /*
  7271. * malloc a structure to hold the spc
  7272. */
  7273. pReg = (_DtHelpDARegion *) malloc (sizeof(_DtHelpDARegion));
  7274. if (NULL == pReg)
  7275. return -1;
  7276. /*
  7277. * malloc the structure to hold the information needed to
  7278. * create the spc later.
  7279. */
  7280. spcInfo = (_DtHelpDASpcInfo *) calloc (1, sizeof(_DtHelpDASpcInfo));
  7281. if (NULL == spcInfo)
  7282. {
  7283. free(pReg);
  7284. return -1;
  7285. }
  7286. /*
  7287. * remember the spc's name and fonts
  7288. */
  7289. spcInfo->name = ElSpcName(my_struct);
  7290. if (_SdlFontModeSave == my_struct->resolve_font)
  7291. {
  7292. spcInfo->spc_fonts = *(my_struct->my_fonts);
  7293. _DtHelpFontHintsLang(spcInfo->spc_fonts) =
  7294. ElLanguage(my_struct);
  7295. _DtHelpFontHintsCharSet(spcInfo->spc_fonts) =
  7296. ElCharSet(my_struct);
  7297. if (-1 == _DtHelpDupFontHints(&(spcInfo->spc_fonts)))
  7298. return -1;
  7299. }
  7300. /*
  7301. * remember the spc's name
  7302. */
  7303. pReg->inited = False;
  7304. pReg->type = _DtHelpDASpc;
  7305. pReg->handle = (_DtCvPointer) spcInfo;
  7306. _DtCvInfoOfRegionSeg(mySeg) = (_DtCvPointer) pReg;
  7307. ClearAttrFlag(my_struct->el_info, SDL_ATTR_NAME);
  7308. }
  7309. }
  7310. return 0;
  7311. } /* End ResolveSpcInfo */
  7312. /******************************************************************************
  7313. * Function: int CopyTossInfo (FormatStruct my_struct,
  7314. * int cur_element, exceptions);
  7315. *
  7316. * Parameters:
  7317. *
  7318. * Returns: 0 if successful, -1 if errors
  7319. *
  7320. * Purpose: Looks for the virtual page attributes.
  7321. *
  7322. ******************************************************************************/
  7323. static int
  7324. CopyTossInfo(
  7325. FormatStruct *my_struct,
  7326. SDLMask *cur_element,
  7327. enum SdlElement sig_element,
  7328. SDLMask *exceptions,
  7329. SDLMask *process_mask)
  7330. {
  7331. SDLTossInfo *tossInfo;
  7332. if (SDLSearchMask(process_mask, ElType(my_struct)) == False)
  7333. return 0;
  7334. tossInfo = (SDLTossInfo *) malloc (sizeof(SDLTossInfo));
  7335. if (NULL == tossInfo)
  7336. return -1;
  7337. /*
  7338. * save the flags
  7339. */
  7340. _SdlTossInfoPtrFlag1(tossInfo) = ElFlag1(my_struct);
  7341. _SdlTossInfoPtrFlag2(tossInfo) = ElFlag2(my_struct);
  7342. _SdlTossInfoPtrFlag3(tossInfo) = ElFlag3(my_struct);
  7343. _SdlTossInfoPtrFlag4(tossInfo) = ElFlag4(my_struct);
  7344. /*
  7345. * save the match data - level, ssi and class/clan.
  7346. */
  7347. _SdlTossInfoPtrRlevel(tossInfo) = ElLevel(my_struct);
  7348. _SdlTossInfoPtrSsi(tossInfo) = ElSsi(my_struct);
  7349. _SdlTossInfoPtrClan(tossInfo) = ElClan(my_struct);
  7350. /*
  7351. * save the table information (colj, colw) or the keystyle
  7352. * enter/exit data.
  7353. */
  7354. _SdlTossInfoPtrStr1(tossInfo) = ElString1(my_struct);
  7355. _SdlTossInfoPtrStr2(tossInfo) = ElString2(my_struct);
  7356. /*
  7357. * save the element type.
  7358. */
  7359. _SdlTossInfoPtrType(tossInfo) = ElType(my_struct);
  7360. /*
  7361. * save the fonts - even if this toss style doesn't specify fonts.
  7362. */
  7363. _SdlTossInfoPtrFontSpecs(tossInfo) = *(my_struct->my_fonts);
  7364. /*
  7365. * now clear string attributes
  7366. */
  7367. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SSI);
  7368. /*
  7369. * table specs.
  7370. */
  7371. ClearAttrFlag(my_struct->el_info, SDL_ATTR_COLW);
  7372. ClearAttrFlag(my_struct->el_info, SDL_ATTR_COLJ);
  7373. /*
  7374. * key style specs.
  7375. */
  7376. ClearAttrFlag(my_struct->el_info, SDL_ATTR_ENTER);
  7377. ClearAttrFlag(my_struct->el_info, SDL_ATTR_EXIT);
  7378. /*
  7379. * font specs
  7380. */
  7381. ClearAttrFlag(my_struct->el_info, SDL_ATTR_COLOR);
  7382. ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFD);
  7383. ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFDI);
  7384. ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFDB);
  7385. ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFDIB);
  7386. ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAM);
  7387. ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAMI);
  7388. ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAMB);
  7389. ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAMIB);
  7390. /*
  7391. * set the internal pointer
  7392. */
  7393. _SdlSegTossInfo(my_struct->add_seg) = (void *) tossInfo;
  7394. /*
  7395. * now re-initialize the font specifications back to the original
  7396. * values
  7397. */
  7398. *(my_struct->my_fonts) = DefFontInfo;
  7399. return 0;
  7400. } /* End CopyTossInfo */
  7401. /******************************************************************************
  7402. * Function: int CopyEntryInfo (FormatStruct my_struct,
  7403. * int cur_element, exceptions);
  7404. *
  7405. * Parameters:
  7406. *
  7407. * Returns: 0 if successful, -1 if errors
  7408. *
  7409. * Purpose: Looks for the virtual page attributes.
  7410. *
  7411. ******************************************************************************/
  7412. static int
  7413. CopyEntryInfo(
  7414. FormatStruct *my_struct,
  7415. SDLMask *cur_element,
  7416. enum SdlElement sig_element,
  7417. SDLMask *exceptions,
  7418. SDLMask *process_mask)
  7419. {
  7420. SDLEntryInfo *entryInfo;
  7421. if (SDLSearchMask(process_mask, ElType(my_struct)) == False)
  7422. return 0;
  7423. entryInfo = (SDLEntryInfo *) malloc (sizeof(SDLEntryInfo));
  7424. if (NULL == entryInfo)
  7425. return -1;
  7426. /*
  7427. * save the strings.
  7428. */
  7429. *entryInfo = ElEntryInfo(my_struct);
  7430. /*
  7431. * now clear the attributes
  7432. */
  7433. ClearAttrFlag(my_struct->el_info, SDL_ATTR_MAIN);
  7434. ClearAttrFlag(my_struct->el_info, SDL_ATTR_LOCS);
  7435. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SYNS);
  7436. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SORT);
  7437. /*
  7438. * set the internal pointer
  7439. */
  7440. _SdlSegEntryInfo(my_struct->add_seg) = (void *) entryInfo;
  7441. return 0;
  7442. } /* End CopyEntryInfo */
  7443. /******************************************************************************
  7444. * Function: int InitLast (FormatStruct my_struct,
  7445. * int cur_element, exceptions);
  7446. *
  7447. * Parameters:
  7448. *
  7449. * Returns: 0 if successful, -1 if errors
  7450. *
  7451. * Purpose: Looks for the virtual page attributes.
  7452. *
  7453. ******************************************************************************/
  7454. static int
  7455. InitLast(
  7456. FormatStruct *my_struct,
  7457. SDLMask *cur_element,
  7458. enum SdlElement sig_element,
  7459. SDLMask *exceptions,
  7460. SDLMask *process_mask)
  7461. {
  7462. /*
  7463. * set the parsing flags
  7464. */
  7465. my_struct->last_was_space = True;
  7466. my_struct->last_was_mb = False;
  7467. my_struct->last_was_nl = False;
  7468. /*
  7469. * set the container type correctly.
  7470. */
  7471. if (NULL != my_struct->add_seg &&
  7472. (SdlTypeLiteral == ElFrmtType(my_struct) ||
  7473. SdlTypeLined == ElFrmtType(my_struct)))
  7474. _DtCvContainerTypeOfSeg(my_struct->add_seg) = _DtCvLITERAL;
  7475. return 0;
  7476. } /* End InitLast */
  7477. /******************************************************************************
  7478. * Function: int SetTransit (FormatStruct my_struct,
  7479. * int cur_element, exceptions);
  7480. *
  7481. * Parameters:
  7482. *
  7483. * Returns: 0 if successful, -1 if errors
  7484. *
  7485. * Purpose: Looks for the virtual page attributes.
  7486. *
  7487. ******************************************************************************/
  7488. static int
  7489. SetTransit(
  7490. FormatStruct *my_struct,
  7491. SDLMask *cur_element,
  7492. enum SdlElement sig_element,
  7493. SDLMask *exceptions,
  7494. SDLMask *process_mask)
  7495. {
  7496. if (ElTiming(my_struct) == SdlTimingAsync)
  7497. my_struct->resolve_font = _SdlFontModeNone;
  7498. return 0;
  7499. } /* End SetTransit */
  7500. /******************************************************************************
  7501. *
  7502. * Main Parsing Functions
  7503. *
  7504. *****************************************************************************/
  7505. /******************************************************************************
  7506. * Function: int ParseSDL (FormatStruct my_struct,
  7507. * int cur_element, int cur_execpt);
  7508. *
  7509. * Parameters:
  7510. *
  7511. * Returns: 0 if successful, -1 if errors
  7512. *
  7513. * Purpose: Parses a set of rules.
  7514. *
  7515. ******************************************************************************/
  7516. static int
  7517. ParseSDL(
  7518. FormatStruct *my_struct,
  7519. enum SdlElement cur_element,
  7520. enum SdlElement sig_element,
  7521. SDLMask *cur_except,
  7522. SDLMask *process_mask)
  7523. {
  7524. int i = 0;
  7525. int result = 0;
  7526. int oldLink = my_struct->cur_link;
  7527. enum SdlElement oldElType = ElType(my_struct);
  7528. _DtCvSegment *oldCurSeg = my_struct->last_seg;
  7529. _DtCvSegment *oldSeglist = my_struct->seg_list;
  7530. _DtCvSegment *oldAddSeg = my_struct->add_seg;
  7531. _DtCvSegment *ifPrevData = my_struct->prev_data;
  7532. _SdlFontMode saveFontMode = my_struct->resolve_font;
  7533. ElementInfo saveElInfo = my_struct->el_info;
  7534. _DtHelpFontHints *oldFontInfo = my_struct->my_fonts;
  7535. const SDLContent *content;
  7536. _DtCvContainer *activeFrmt = my_struct->active_frmt;
  7537. SDLMask oldMask[SDL_MASK_LEN];
  7538. SDLMask oldExcept[SDL_MASK_LEN];
  7539. _DtCvValue oldBlank = my_struct->save_blank;
  7540. _DtCvValue processFlag =
  7541. SDLSearchMask(process_mask, SdlElementCdata);
  7542. /*
  7543. * While this element is allowed normally in the content of
  7544. * the parent element, it it currently allowed?
  7545. */
  7546. if (SDLSearchMask(cur_except, cur_element) == True)
  7547. return -1;
  7548. /*
  7549. * special processing for CDATA elements
  7550. */
  7551. if (cur_element != SdlElementCdata)
  7552. {
  7553. my_struct->seg_list = NULL;
  7554. my_struct->last_seg = NULL;
  7555. my_struct->add_seg = NULL;
  7556. }
  7557. /*
  7558. * look in the master list for this element
  7559. */
  7560. while (i < MaxSDLElements && SdlElementList[i].sdl_element != cur_element)
  7561. i++;
  7562. /*
  7563. * Didn't find this element in the master list.
  7564. */
  7565. if (i >= MaxSDLElements)
  7566. return -1;
  7567. /*
  7568. * merge this element's exceptions with parent's list.
  7569. * save the old process mask.
  7570. */
  7571. SaveRestoreMask(oldExcept, cur_except);
  7572. MergeMasks(cur_except, SdlElementList[i].exceptions);
  7573. SaveRestoreMask(oldMask, process_mask);
  7574. /*
  7575. * the content for this element is...
  7576. */
  7577. content = SdlElementList[i].content;
  7578. /*
  7579. * check to see if we want to process this element
  7580. * If sig_element is set, parse the element and its content.
  7581. */
  7582. if (sig_element != SdlElementNone)
  7583. {
  7584. processFlag = False;
  7585. if (sig_element == cur_element)
  7586. {
  7587. processFlag = True;
  7588. sig_element = SdlElementNone;
  7589. SaveRestoreMask(process_mask, AllMaskSet);
  7590. }
  7591. }
  7592. /*
  7593. * If not CDATA, then have to get the element start string, attributes
  7594. * and ending markup tag.
  7595. */
  7596. if (cur_element != SdlElementCdata)
  7597. {
  7598. if (ParseElementStart(my_struct,SdlElementList[i],processFlag) != 0
  7599. ||
  7600. ParseElementAttr(my_struct,
  7601. cur_element,
  7602. SdlElementList[i].attrib_list,
  7603. SdlElementList[i].cdata_flag,
  7604. processFlag) != 0)
  7605. result = -1;
  7606. }
  7607. /*
  7608. * now parse the element's content
  7609. */
  7610. my_struct->faked_end = False;
  7611. ElType(my_struct) = cur_element;
  7612. while (result == 0 && content != NULL &&
  7613. SDLSearchMask(content->mask, SdlElementNone) == False)
  7614. {
  7615. result = (*(content->model))(my_struct, content->mask,
  7616. sig_element, cur_except, process_mask);
  7617. content++;
  7618. }
  7619. /*
  7620. * If not CDATA, get the element end markup and adjust some pointers
  7621. */
  7622. SaveRestoreMask(process_mask, oldMask);
  7623. SaveRestoreMask(cur_except , oldExcept);
  7624. if (cur_element != SdlElementCdata)
  7625. {
  7626. if (result == 0 && SdlElementList[i].element_end_str != NULL)
  7627. result = ParseElementEnd(my_struct, ifPrevData,
  7628. SdlElementList[i],
  7629. processFlag,
  7630. my_struct->faked_end);
  7631. else
  7632. {
  7633. /*
  7634. * free the attributes for this element.
  7635. */
  7636. FreeAttributes(ElType(my_struct),
  7637. &(my_struct->el_info), my_struct->my_fonts);
  7638. if (SdlElementList[i].new_fonts && FreeFontInfo(my_struct) == -1)
  7639. result = -1;
  7640. }
  7641. my_struct->last_seg = oldCurSeg;
  7642. my_struct->seg_list = oldSeglist;
  7643. if (result == 0 && my_struct->add_seg != NULL)
  7644. _DtHelpCeAddSegToList(my_struct->add_seg, &(my_struct->seg_list),
  7645. &(my_struct->last_seg));
  7646. my_struct->add_seg = oldAddSeg;
  7647. my_struct->cur_link = oldLink;
  7648. if (SdlElementLink == cur_element)
  7649. my_struct->save_blank = oldBlank;
  7650. my_struct->el_info = saveElInfo;
  7651. my_struct->my_fonts = oldFontInfo;
  7652. }
  7653. my_struct->active_frmt = activeFrmt;
  7654. my_struct->resolve_font = saveFontMode;
  7655. ElType(my_struct) = oldElType;
  7656. return result;
  7657. } /* End ParseSDL */
  7658. /******************************************************************************
  7659. * Function: int ProcessSDLMarkup (FormatStruct my_struct,
  7660. * int cur_element, int cur_execpt);
  7661. *
  7662. * Parameters:
  7663. *
  7664. * Returns: 0 if successful, -1 if errors
  7665. *
  7666. * Purpose: Parses a set of rules, looks through the result and changes
  7667. * bad options into good.
  7668. *
  7669. ******************************************************************************/
  7670. static int
  7671. ProcessSDLMarkup(
  7672. FormatStruct *my_struct,
  7673. enum SdlElement cur_element,
  7674. enum SdlElement sig_element,
  7675. SDLMask *cur_except,
  7676. SDLMask *process_mask)
  7677. {
  7678. int result = ParseSDL (my_struct, cur_element, sig_element, cur_except,
  7679. process_mask);
  7680. if (-1 != result)
  7681. PropagateJustification(my_struct->seg_list, _DtCvJUSTIFY_LEFT);
  7682. return result;
  7683. }
  7684. /******************************************************************************
  7685. * Function: int ProcessContent (
  7686. * FormatStruct *my_struct,
  7687. * const SDLContent *content,
  7688. * SDLMask *exceptions,
  7689. * SDLMask *process_mask);
  7690. *
  7691. * Parameters:
  7692. * my_struct Specifies specific informationg for this parse.
  7693. * content Specifies the content model to parse.
  7694. * exceptions Specifies the current elements excepted
  7695. * from being in the current content.
  7696. * process_mask Specifies which elements to save in memory.
  7697. *
  7698. * Returns: 0 if successful, -1 if errors
  7699. *
  7700. * Purpose:
  7701. ******************************************************************************/
  7702. static int
  7703. ProcessContent(
  7704. FormatStruct *my_struct,
  7705. const SDLContent *content,
  7706. enum SdlElement sig_element,
  7707. SDLMask *exceptions,
  7708. SDLMask *process_mask)
  7709. {
  7710. int result = 0;
  7711. while (result == 0 && content != NULL &&
  7712. SDLSearchMask(content->mask, SdlElementNone) == False)
  7713. {
  7714. result = (*(content->model))(my_struct, content->mask,
  7715. sig_element, exceptions, process_mask);
  7716. content++;
  7717. }
  7718. if (-1 != result)
  7719. PropagateJustification(my_struct->seg_list, _DtCvJUSTIFY_LEFT);
  7720. return result;
  7721. }
  7722. /******************************************************************************
  7723. * Function: int SearchForController (_DtCvSegment p_seg,
  7724. *
  7725. * Parameters:
  7726. *
  7727. * Returns: 0 if successful, -1 if errors
  7728. *
  7729. * Purpose: Parses a set of rules.
  7730. *
  7731. ******************************************************************************/
  7732. static _DtCvSegment *
  7733. SearchForController(
  7734. _DtCvSegment *p_seg)
  7735. {
  7736. while (NULL != p_seg &&
  7737. !(_DtCvIsSegContainer(p_seg) && _DtCvIsSegController(p_seg)))
  7738. p_seg = _DtCvNextSeg(p_seg);
  7739. return p_seg;
  7740. } /* End SearchForController */
  7741. /******************************************************************************
  7742. * Function: int FormatSDLTitle (
  7743. *
  7744. * Parameters:
  7745. *
  7746. * Returns: 0 if successful, -1 if errors
  7747. *
  7748. * Purpose: Parses a set of rules.
  7749. *
  7750. ******************************************************************************/
  7751. static int
  7752. FormatSDLTitle(
  7753. char *filename,
  7754. int offset,
  7755. int fd,
  7756. FormatStruct *my_struct)
  7757. {
  7758. int result = 0;
  7759. SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits;
  7760. /*
  7761. SDLMask processMask[SDL_MASK_LEN] = SDLInitMaskEleven( \
  7762. SdlElementTitle , SdlElementHead , \
  7763. SdlElementKey , SdlElementSphrase, \
  7764. SdlElementRev , SdlElementIf , \
  7765. SdlElementSpc , SdlElementAnchor , \
  7766. SdlElementLink , SdlElementSnRef , \
  7767. SdlElementCdata);
  7768. */
  7769. SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone);
  7770. /*
  7771. * set the volume name for the graphics.
  7772. */
  7773. my_struct->vol_name = filename;
  7774. /*
  7775. * can we seek to the correct place?
  7776. */
  7777. result = _DtHelpCeFileOpenAndSeek(filename, offset, fd,
  7778. &(my_struct->my_file), NULL);
  7779. if (result != -1)
  7780. {
  7781. result = ProcessSDLMarkup (my_struct, SdlElementTitle, SdlElementNone,
  7782. startExcept, processMask);
  7783. _DtHelpCeBufFileClose (my_struct->my_file, (fd == -1 ? True : False));
  7784. }
  7785. return result;
  7786. } /* End FormatSDLTitle */
  7787. /******************************************************************************
  7788. * Function: void SetGhostLink (
  7789. *
  7790. * Parameters:
  7791. *
  7792. * Returns:
  7793. *
  7794. * Purpose:
  7795. *
  7796. ******************************************************************************/
  7797. static int
  7798. SetGhostLink(
  7799. _DtCvLinkDb link_data,
  7800. _DtCvSegment *segments,
  7801. int link_idx)
  7802. {
  7803. while (segments != NULL)
  7804. {
  7805. if (!(_DtCvIsSegContainer(segments)))
  7806. {
  7807. if (_DtCvIsSegHyperText(segments))
  7808. {
  7809. _DtLinkDbRemoveLink(link_data, segments->link_idx);
  7810. segments->type = ClearSegLinks(segments);
  7811. }
  7812. segments->type = _DtCvSetTypeToGhostLink(segments->type);
  7813. segments->link_idx = link_idx;
  7814. }
  7815. else /* if (_DtCvIsSegContainer(segments)) */
  7816. SetGhostLink (link_data, _DtCvContainerListOfSeg(segments),
  7817. link_idx);
  7818. segments = _DtCvNextSeg(segments);
  7819. }
  7820. } /* End SetGhostLink */
  7821. /******************************************************************************
  7822. * Function: void CreateAsciiString ()
  7823. *
  7824. * Parameters:
  7825. *
  7826. * Returns:
  7827. *
  7828. * Purpose:
  7829. *
  7830. ******************************************************************************/
  7831. static void
  7832. CreateAsciiString(
  7833. _DtCvSegment *p_seg,
  7834. _DtCvSegment *snb,
  7835. _DtCvValue *nl_flag,
  7836. char **ret_string)
  7837. {
  7838. int newLen;
  7839. int len;
  7840. while (p_seg != NULL)
  7841. {
  7842. len = 1;
  7843. if (_DtCvIsSegString(p_seg))
  7844. {
  7845. if (*nl_flag == True)
  7846. {
  7847. if (*ret_string != NULL &&
  7848. (*ret_string)[strlen(*ret_string)-1] != ' ')
  7849. len++;
  7850. else
  7851. *nl_flag = False;
  7852. }
  7853. newLen = _DtCvStrLen(_DtCvStringOfStringSeg(p_seg),
  7854. _DtCvIsSegWideChar(p_seg));
  7855. if (_DtCvIsSegWideChar(p_seg))
  7856. newLen = newLen * MB_CUR_MAX;
  7857. len += newLen;
  7858. if (*ret_string == NULL)
  7859. {
  7860. *ret_string = (char *) malloc (len);
  7861. **ret_string = '\0';
  7862. }
  7863. else
  7864. {
  7865. len += strlen(*ret_string);
  7866. *ret_string = (char *) realloc (*ret_string, len);
  7867. }
  7868. if (*nl_flag == True)
  7869. strcat(*ret_string, " ");
  7870. /*
  7871. * back up to the insertion point.
  7872. */
  7873. len -= newLen;
  7874. len--;
  7875. /*
  7876. * wide char or single byte?
  7877. */
  7878. if (_DtCvIsSegWideChar(p_seg))
  7879. wcstombs(&((*ret_string)[len]),
  7880. (wchar_t *) _DtCvStringOfStringSeg(p_seg),
  7881. newLen + 1);
  7882. else
  7883. strcpy (&((*ret_string)[len]), _DtCvStringOfStringSeg(p_seg));
  7884. *nl_flag = False;
  7885. if (p_seg->next_disp == NULL)
  7886. *nl_flag = True;
  7887. }
  7888. else if (_DtCvIsSegContainer(p_seg) && !(_DtCvIsSegController(p_seg)))
  7889. CreateAsciiString(_DtCvContainerListOfSeg(p_seg),
  7890. snb, nl_flag, ret_string);
  7891. p_seg = _DtCvNextSeg(p_seg);
  7892. }
  7893. }
  7894. /******************************************************************************
  7895. * Function: void CreateAsciiAbbrev ()
  7896. *
  7897. * Parameters:
  7898. *
  7899. * Returns:
  7900. *
  7901. * Purpose:
  7902. *
  7903. ******************************************************************************/
  7904. static void
  7905. CreateAsciiAbbrev(
  7906. _DtCvSegment *p_el,
  7907. char **ret_abbrev)
  7908. {
  7909. *ret_abbrev = NULL;
  7910. if (NULL != AbbrevOfSeg(p_el) && strlen ((char *) AbbrevOfSeg(p_el)))
  7911. *ret_abbrev = strdup((char *) AbbrevOfSeg(p_el));
  7912. }
  7913. /******************************************************************************
  7914. * Function: void CleanUpToc ()
  7915. *
  7916. * Parameters:
  7917. * my_struct Specifies current formatting information.
  7918. * p_seg Specifies the current segment list to modify.
  7919. * level Specifes the parent element's level.
  7920. * lnk_indx Specifies the link index to use for the
  7921. * ghost link.
  7922. *
  7923. * Returns: nothing
  7924. *
  7925. * Purpose: Modifies the formatting information for conform to what
  7926. * it should be for a TOC and sets the ghost link.
  7927. *
  7928. ******************************************************************************/
  7929. static void
  7930. CleanUpToc(
  7931. FormatStruct *my_struct,
  7932. _DtCvSegment *p_seg,
  7933. int level,
  7934. _DtCvValue target)
  7935. {
  7936. level--;
  7937. if (level < 0)
  7938. level = 0;
  7939. while (p_seg != NULL)
  7940. {
  7941. if (_DtCvIsSegNewLine(p_seg))
  7942. p_seg->type = p_seg->type & ~(_DtCvNEW_LINE);
  7943. if (_DtCvIsSegContainer(p_seg))
  7944. {
  7945. _DtCvContainerPercentOfSeg(p_seg) = DefPercent;
  7946. _DtCvContainerOrientOfSeg(p_seg) = _DtCvJUSTIFY_LEFT_MARGIN;
  7947. _DtCvContainerFlowOfSeg(p_seg) = _DtCvWRAP_NONE;
  7948. _DtCvContainerTypeOfSeg(p_seg) = _DtCvLITERAL;
  7949. _DtCvContainerVJustifyOfSeg(p_seg) = _DtCvJUSTIFY_TOP;
  7950. _DtCvContainerJustifyOfSeg(p_seg) = _DtCvJUSTIFY_LEFT;
  7951. _DtCvContainerFMarginOfSeg(p_seg) = 0;
  7952. _DtCvContainerLMarginOfSeg(p_seg) =
  7953. level * 2 * my_struct->ui_info->avg_char;
  7954. _DtCvContainerRMarginOfSeg(p_seg) = 0;
  7955. _DtCvContainerTMarginOfSeg(p_seg) = 0;
  7956. _DtCvContainerBMarginOfSeg(p_seg) = 0;
  7957. CleanUpToc(my_struct, _DtCvContainerListOfSeg(p_seg),
  7958. level, target);
  7959. }
  7960. else if (_DtCvIsSegString(p_seg))
  7961. {
  7962. _DtHelpFontHints *font_specs = (_DtHelpFontHints *)_DtCvFontOfStringSeg(p_seg);
  7963. _DtHelpFontPtrPtSize(font_specs) = 10;
  7964. _DtHelpFontPtrWeight(font_specs) = _DtHelpFontWeightMedium;
  7965. if (target == True)
  7966. _DtHelpFontPtrWeight(font_specs) = _DtHelpFontWeightBold;
  7967. (my_struct->ui_info->load_font)(my_struct->ui_info->client_data,
  7968. _DtHelpFontHintsLang(*font_specs),
  7969. _DtHelpFontHintsCharSet(*font_specs),
  7970. *font_specs,
  7971. &(_DtCvFontOfStringSeg(p_seg)));
  7972. free(font_specs);
  7973. }
  7974. else if (_DtCvIsSegRegion(p_seg))
  7975. {
  7976. int result;
  7977. _DtHelpDARegion *pReg = (_DtHelpDARegion *) _DtCvInfoOfRegionSeg(p_seg);
  7978. if (_DtHelpDASpc == pReg->type)
  7979. {
  7980. _DtHelpDASpcInfo *pSpc = (_DtHelpDASpcInfo *) pReg->handle;
  7981. _DtHelpFontHintsPtSize(pSpc->spc_fonts) = 10;
  7982. _DtHelpFontHintsWeight(pSpc->spc_fonts) =
  7983. _DtHelpFontWeightMedium;
  7984. if (True == target)
  7985. _DtHelpFontHintsWeight(pSpc->spc_fonts) =
  7986. _DtHelpFontWeightBold;
  7987. result = (*(my_struct->ui_info->resolve_spc))(
  7988. my_struct->ui_info->client_data,
  7989. _DtHelpFontHintsLang(pSpc->spc_fonts),
  7990. _DtHelpFontHintsCharSet(pSpc->spc_fonts),
  7991. pSpc->spc_fonts,
  7992. pSpc->name,
  7993. &(_DtCvInfoOfRegionSeg(p_seg)),
  7994. &(_DtCvWidthOfRegionSeg(p_seg)),
  7995. &(_DtCvHeightOfRegionSeg(p_seg)),
  7996. &(_DtCvAscentOfRegionSeg(p_seg)));
  7997. if (0 != result)
  7998. p_seg->type = _DtCvSetTypeToNoop(p_seg->type);
  7999. free(pSpc->name);
  8000. _DtHelpFreeFontHints(&(pSpc->spc_fonts));
  8001. free(pSpc);
  8002. free(pReg);
  8003. }
  8004. }
  8005. p_seg = _DtCvNextSeg(p_seg);
  8006. }
  8007. }
  8008. /******************************************************************************
  8009. * Function: int AddEntryToToc ()
  8010. *
  8011. * Parameters:
  8012. *
  8013. * Returns:
  8014. *
  8015. * Purpose:
  8016. *
  8017. ******************************************************************************/
  8018. static int
  8019. AddEntryToToc(
  8020. FormatStruct *my_struct,
  8021. _DtHelpVolumeHdl volume,
  8022. int fd,
  8023. int level,
  8024. char *lang,
  8025. const char *char_set,
  8026. _DtCvSegment *toss,
  8027. _DtCvSegment *info_seg,
  8028. _DtCvValue target,
  8029. _DtCvSegment **ret_snb,
  8030. _DtCvSegment **seg_list,
  8031. _DtCvSegment **prev_list)
  8032. {
  8033. int result = 0;
  8034. _DtCvLinkDb saveLinks;
  8035. SDLIdInfo *info;
  8036. /*
  8037. * initialize the structure
  8038. * save some information that's going to be destroyed in the setup.
  8039. */
  8040. saveLinks = my_struct->my_links;
  8041. if (SetUp(NULL,NULL,my_struct,toss,my_struct->ui_info,fd,False,False) != 0)
  8042. return -1;
  8043. /*
  8044. * Initialize the standard/default to use
  8045. */
  8046. _DtHelpFontHintsLang(*(my_struct->my_fonts)) = lang;
  8047. _DtHelpFontHintsCharSet(*(my_struct->my_fonts)) = (char *) char_set;
  8048. /*
  8049. * free the new link database and restore the old one.
  8050. * set font mode to save and the id for graphics.
  8051. */
  8052. _DtLinkDbDestroy(my_struct->my_links);
  8053. my_struct->my_links = saveLinks;
  8054. my_struct->resolve_font = _SdlFontModeSave;
  8055. info = FrmtPrivInfoPtr(info_seg)->id_info;
  8056. result = FormatSDLTitle(_DtHelpCeGetVolumeName(volume),
  8057. _SdlIdInfoPtrOffset(info), fd, my_struct);
  8058. /*
  8059. * if no errors, continue
  8060. */
  8061. if (result != -1)
  8062. {
  8063. _DtCvSegment *headEl = NULL;
  8064. /*
  8065. * find the actual head element
  8066. */
  8067. if (my_struct->seg_list != NULL)
  8068. headEl = SearchForController(
  8069. _DtCvContainerListOfSeg(my_struct->seg_list));
  8070. /*
  8071. * If there isn't a head element, use the id.
  8072. */
  8073. if (headEl == NULL)
  8074. {
  8075. _DtCvSegment *addSeg = NULL;
  8076. if (MySaveString(&(addSeg), my_struct,
  8077. _DtCvContainerIdOfSeg(info_seg),
  8078. -1, my_struct->mb_len, False) != 0)
  8079. {
  8080. /*
  8081. * free the segments
  8082. */
  8083. _DtHelpFreeSegments(my_struct->seg_list, _DtCvTRUE,
  8084. my_struct->ui_info->destroy_region,
  8085. my_struct->ui_info->client_data);
  8086. my_struct->seg_list = NULL;
  8087. DestroyFontInfo(my_struct);
  8088. return -1;
  8089. }
  8090. /*
  8091. * if there is a virpage, attach the segment to it.
  8092. * I.e. just reuse the container.
  8093. */
  8094. if (NULL != my_struct->seg_list)
  8095. {
  8096. /*
  8097. * free the container original list
  8098. */
  8099. _DtHelpFreeSegments(
  8100. _DtCvContainerListOfSeg(my_struct->seg_list),
  8101. _DtCvTRUE,
  8102. my_struct->ui_info->destroy_region,
  8103. my_struct->ui_info->client_data);
  8104. }
  8105. else
  8106. {
  8107. /*
  8108. * create a container for the segment.
  8109. */
  8110. if (_DtHelpCeAllocSegment(my_struct->malloc_size,
  8111. &(my_struct->alloc_size),
  8112. &(my_struct->block_list),
  8113. &(my_struct->seg_list)) != 0)
  8114. {
  8115. _DtHelpFreeSegments(addSeg, _DtCvTRUE,
  8116. my_struct->ui_info->destroy_region,
  8117. my_struct->ui_info->client_data);
  8118. DestroyFontInfo(my_struct);
  8119. return -1;
  8120. }
  8121. /*
  8122. * set the container flag and initialize its formatting
  8123. * information to the default.
  8124. */
  8125. my_struct->seg_list->type =
  8126. _DtCvSetTypeToContainer(my_struct->seg_list->type);
  8127. _DtCvContainerOfSeg(my_struct->seg_list) = DefFrmtSpecs;
  8128. _DtCvContainerLeadingOfSeg(my_struct->seg_list) =
  8129. my_struct->ui_info->leading;
  8130. }
  8131. _DtCvContainerListOfSeg(my_struct->seg_list) = addSeg;
  8132. headEl = my_struct->seg_list;
  8133. }
  8134. /*
  8135. * there was a empty head, use the abbreviation or the id.
  8136. */
  8137. else if (_DtCvContainerListOfSeg(headEl) == NULL)
  8138. {
  8139. char *myPtr = (char *) AbbrevOfSeg(headEl);
  8140. if (NULL == myPtr)
  8141. myPtr = _DtCvContainerIdOfSeg(info_seg);
  8142. if (MySaveString(&(_DtCvContainerListOfSeg(headEl)), my_struct,
  8143. myPtr, -1, my_struct->mb_len, False) != 0)
  8144. {
  8145. /*
  8146. * free the segments
  8147. */
  8148. _DtHelpFreeSegments(my_struct->seg_list, _DtCvTRUE,
  8149. my_struct->ui_info->destroy_region,
  8150. my_struct->ui_info->client_data);
  8151. my_struct->seg_list = NULL;
  8152. DestroyFontInfo(my_struct);
  8153. return -1;
  8154. }
  8155. }
  8156. /*
  8157. * Make sure we only use the first head.
  8158. * first make sure that the segment list is not the head already.
  8159. */
  8160. if (headEl != my_struct->seg_list)
  8161. {
  8162. _DtCvSegment *prevSeg;
  8163. /*
  8164. * destroy the segments after this one.
  8165. */
  8166. _DtHelpFreeSegments(_DtCvNextSeg(headEl), _DtCvTRUE,
  8167. my_struct->ui_info->destroy_region,
  8168. my_struct->ui_info->client_data);
  8169. /*
  8170. * break the link to the freed segments
  8171. */
  8172. _DtCvNextSeg(headEl) = NULL;
  8173. /*
  8174. * destroy the segments before this one.
  8175. */
  8176. prevSeg = _DtCvContainerListOfSeg(my_struct->seg_list);
  8177. if (prevSeg != headEl)
  8178. {
  8179. /*
  8180. * search for the previous segment before the head.
  8181. */
  8182. while (_DtCvNextSeg(prevSeg) != headEl)
  8183. prevSeg = _DtCvNextSeg(prevSeg);
  8184. /*
  8185. * break the link to the head element
  8186. */
  8187. _DtCvNextSeg(prevSeg) = NULL;
  8188. }
  8189. else
  8190. _DtCvContainerListOfSeg(my_struct->seg_list) = NULL;
  8191. /*
  8192. * free the segments before the head and virpage container.
  8193. */
  8194. _DtHelpFreeSegments(my_struct->seg_list, _DtCvTRUE,
  8195. my_struct->ui_info->destroy_region,
  8196. my_struct->ui_info->client_data);
  8197. my_struct->seg_list = headEl;
  8198. }
  8199. if (headEl != NULL)
  8200. {
  8201. int linkIndex = _DtLinkDbAddLink(my_struct->my_links, NULL,
  8202. _DtCvContainerIdOfSeg(info_seg),
  8203. _DtCvLinkType_SameVolume,
  8204. _DtCvWindowHint_CurrentWindow, NULL);
  8205. CleanUpToc(my_struct, headEl, level, target);
  8206. SetGhostLink(my_struct->my_links, headEl, linkIndex);
  8207. }
  8208. }
  8209. if (result != -1)
  8210. {
  8211. /*
  8212. * now tack this segment onto the end of the list
  8213. */
  8214. if ((*seg_list) == NULL)
  8215. (*seg_list) = my_struct->seg_list;
  8216. else
  8217. _DtCvNextSeg((*prev_list)) = my_struct->seg_list;
  8218. *prev_list = my_struct->seg_list;
  8219. while ((*prev_list) != NULL && _DtCvNextSeg((*prev_list)) != NULL)
  8220. *prev_list = _DtCvNextSeg((*prev_list));
  8221. }
  8222. /*
  8223. * if the snb for this topic was read, free it now.
  8224. */
  8225. if (my_struct->snb != NULL)
  8226. {
  8227. _DtHelpFreeSegments(my_struct->snb, _DtCvTRUE,
  8228. my_struct->ui_info->destroy_region,
  8229. my_struct->ui_info->client_data);
  8230. my_struct->snb = NULL;
  8231. }
  8232. /*
  8233. * free the font structures allocated
  8234. */
  8235. DestroyFontInfo(my_struct);
  8236. return result;
  8237. }
  8238. /******************************************************************************
  8239. * Function: int ExpandToc ()
  8240. *
  8241. * Parameters:
  8242. *
  8243. * Returns:
  8244. *
  8245. * Purpose:
  8246. *
  8247. ******************************************************************************/
  8248. static int
  8249. ExpandToc(
  8250. FormatStruct *my_struct,
  8251. _DtHelpVolumeHdl volume,
  8252. int fd,
  8253. char *lang,
  8254. const char *char_set,
  8255. _DtCvSegment *toss,
  8256. int level,
  8257. char **path_list,
  8258. _DtCvSegment **id_seg,
  8259. _DtCvSegment **ret_snb,
  8260. _DtCvSegment **seg_list,
  8261. _DtCvSegment **prev_list)
  8262. {
  8263. int result = 0;
  8264. int segLev;
  8265. int tst = 1;
  8266. _DtCvSegment *pEl;
  8267. _DtCvValue done = False;
  8268. _DtCvValue found = False;
  8269. /*
  8270. * skip anything that isn't a virpage and of the correct level.
  8271. */
  8272. while ((*id_seg) != NULL && _SdlSegToSdlIdInfoType(*id_seg) != SdlIdVirpage
  8273. && _SdlSegToSdlIdInfoLevel(*id_seg) != level)
  8274. *id_seg = _DtCvNextSeg((*id_seg));
  8275. /*
  8276. * process any virpage that has the correct level
  8277. */
  8278. while ((*id_seg) != NULL && done == False && result == 0)
  8279. {
  8280. pEl = (*id_seg);
  8281. segLev = _SdlSegToSdlIdInfoLevel(pEl);
  8282. if (_SdlSegToSdlIdInfoType(pEl) == SdlIdVirpage)
  8283. {
  8284. if (segLev == level)
  8285. {
  8286. /*
  8287. * If the virpage in the path list has not been found,
  8288. * test the next virpage. Otherwise skip.
  8289. */
  8290. if (found == False && *path_list != NULL &&
  8291. _DtCvContainerIdOfSeg(pEl) != NULL)
  8292. tst = _DtCvStrCaseCmpLatin1(*path_list,
  8293. _DtCvContainerIdOfSeg(pEl));
  8294. /*
  8295. * the only time tst == 0 is when the next item in the
  8296. * path_list matches this element. Check to see if the
  8297. * next item in the path_list is null. If so, that
  8298. * means this is the location the user has desired.
  8299. */
  8300. result = AddEntryToToc(my_struct, volume, fd,
  8301. segLev, lang, char_set, toss, pEl,
  8302. (tst == 0 && path_list[1] == NULL ? True : False),
  8303. ret_snb, seg_list, prev_list);
  8304. /*
  8305. * increment the segment pointer to the next item
  8306. */
  8307. *id_seg = _DtCvNextSeg((*id_seg));
  8308. /*
  8309. * The only time tst is zero is if the current virpage
  8310. * matches the next item in the list. Expand it's children.
  8311. * and set tst to non-zero so that AddEntryToToc does not
  8312. * special case the siblings following this one.
  8313. */
  8314. if (tst == 0)
  8315. {
  8316. result = ExpandToc(my_struct, volume, fd, lang,
  8317. char_set, toss,
  8318. segLev + 1,
  8319. &path_list[1],
  8320. id_seg, ret_snb, seg_list, prev_list);
  8321. found = True;
  8322. tst = 1;
  8323. }
  8324. }
  8325. else if (segLev < level)
  8326. done = True;
  8327. else
  8328. *id_seg = _DtCvNextSeg((*id_seg));
  8329. }
  8330. else
  8331. *id_seg = _DtCvNextSeg((*id_seg));
  8332. }
  8333. return result;
  8334. } /* ExpandToc */
  8335. /******************************************************************************
  8336. * Function: void CreateTitleChunks ()
  8337. *
  8338. * Parameters:
  8339. *
  8340. * Returns:
  8341. *
  8342. * Purpose:
  8343. *
  8344. ******************************************************************************/
  8345. static int
  8346. CreateTitleChunks(
  8347. _DtCvSegment *toss,
  8348. _DtCvSegment *p_seg,
  8349. _DtCvSegment *snb,
  8350. SDLMask *stop_mask,
  8351. const char *lang,
  8352. const char *char_set,
  8353. _DtCvValue (*resolve_spc)(),
  8354. _DtCvPointer client_data,
  8355. int *ret_cnt,
  8356. void ***ret_chunks)
  8357. {
  8358. long type;
  8359. int cnt;
  8360. int result = 0;
  8361. const char *myLang;
  8362. const char *mySet;
  8363. void *ptr;
  8364. _DtHelpDARegion *daRegion;
  8365. while (result != -1 && p_seg != NULL)
  8366. {
  8367. myLang = lang;
  8368. mySet = char_set;
  8369. cnt = *ret_cnt;
  8370. if (_DtCvIsSegString(p_seg))
  8371. {
  8372. if (*ret_cnt == 0)
  8373. *ret_cnt = 1;
  8374. else
  8375. cnt--;
  8376. *ret_cnt = *ret_cnt + 3;
  8377. if (*ret_chunks == NULL)
  8378. *ret_chunks = (void **) malloc (sizeof(void *) * (*ret_cnt));
  8379. else
  8380. *ret_chunks = (void **) realloc (*ret_chunks,
  8381. sizeof(void *) * (*ret_cnt));
  8382. if (*ret_chunks == NULL)
  8383. return -1;
  8384. type = DT_HELP_CE_FONT_PTR | DT_HELP_CE_STRING;
  8385. ptr = _DtCvFontOfStringSeg(p_seg);
  8386. if (p_seg->next_disp == NULL || _DtCvIsSegNewLine(p_seg))
  8387. type |= DT_HELP_CE_NEWLINE;
  8388. (*ret_chunks)[cnt++] = (void *) type;
  8389. (*ret_chunks)[cnt++] = (void *) ptr;
  8390. if (_DtCvIsSegWideChar(p_seg))
  8391. {
  8392. int len = _DtCvStrLen(_DtCvStringOfStringSeg(p_seg), 1)
  8393. * MB_CUR_MAX + 1;
  8394. ptr = malloc (sizeof(char *) * len);
  8395. if (NULL != ptr)
  8396. wcstombs((char *) ptr,
  8397. (wchar_t *) _DtCvStringOfStringSeg(p_seg), len);
  8398. }
  8399. else
  8400. ptr = strdup(_DtCvStringOfStringSeg(p_seg));
  8401. (*ret_chunks)[cnt++] = (void *) ptr;
  8402. if ((*ret_chunks)[cnt-1] == NULL)
  8403. return -1;
  8404. (*ret_chunks)[cnt++] = (void *) DT_HELP_CE_END;
  8405. }
  8406. else if (_DtCvIsSegRegion(p_seg))
  8407. {
  8408. daRegion = (_DtHelpDARegion *) _DtCvInfoOfRegionSeg(p_seg);
  8409. if (_DtHelpDASpc == daRegion->type)
  8410. {
  8411. if (False == daRegion->inited)
  8412. {
  8413. _DtHelpDASpcInfo *pSpc =
  8414. (_DtHelpDASpcInfo *) daRegion->handle;
  8415. /*
  8416. * allocate the spc!
  8417. */
  8418. result = (*(resolve_spc))(
  8419. client_data,
  8420. _DtHelpFontHintsLang(pSpc->spc_fonts),
  8421. _DtHelpFontHintsCharSet(pSpc->spc_fonts),
  8422. pSpc->spc_fonts,
  8423. pSpc->name,
  8424. &(_DtCvInfoOfRegionSeg(p_seg)),
  8425. &(_DtCvWidthOfRegionSeg(p_seg)),
  8426. &(_DtCvHeightOfRegionSeg(p_seg)),
  8427. &(_DtCvAscentOfRegionSeg(p_seg)));
  8428. free(pSpc->name);
  8429. _DtHelpFreeFontHints(&(pSpc->spc_fonts));
  8430. free(pSpc);
  8431. free(daRegion);
  8432. if (0 != result)
  8433. return -1;
  8434. daRegion = (_DtHelpDARegion *) _DtCvInfoOfRegionSeg(p_seg);
  8435. }
  8436. if (*ret_cnt == 0)
  8437. *ret_cnt = 1;
  8438. else
  8439. cnt--;
  8440. *ret_cnt = *ret_cnt + 2;
  8441. if (*ret_chunks == NULL)
  8442. *ret_chunks = (void **) malloc (sizeof(void *) * *ret_cnt);
  8443. else
  8444. *ret_chunks = (void **) realloc (*ret_chunks,
  8445. sizeof(void *) * *ret_cnt);
  8446. if (*ret_chunks == NULL)
  8447. return -1;
  8448. type = DT_HELP_CE_SPC;
  8449. if (p_seg->next_disp == NULL || _DtCvIsSegNewLine(p_seg))
  8450. type |= DT_HELP_CE_NEWLINE;
  8451. (*ret_chunks)[cnt++] = (void *) type;
  8452. (*ret_chunks)[cnt++] = (void *) daRegion->handle;
  8453. (*ret_chunks)[cnt++] = (void *) DT_HELP_CE_END;
  8454. }
  8455. result = 0;
  8456. }
  8457. else if (_DtCvIsSegContainer(p_seg) && !(_DtCvIsSegController(p_seg)))
  8458. result = CreateTitleChunks(toss,
  8459. _DtCvContainerListOfSeg(p_seg), snb,
  8460. stop_mask,
  8461. myLang, mySet,
  8462. resolve_spc,
  8463. client_data,
  8464. ret_cnt, ret_chunks);
  8465. p_seg = _DtCvNextSeg(p_seg);
  8466. }
  8467. return result;
  8468. }
  8469. /******************************************************************************
  8470. * Function: int ProcessSegmentsToChunks ()
  8471. *
  8472. * Parameters:
  8473. *
  8474. * Returns: 0 if created a chunk, -1 if errors
  8475. *
  8476. * Purpose:
  8477. *
  8478. ******************************************************************************/
  8479. static int
  8480. ProcessSegmentsToChunks(
  8481. _DtCvSegment *toss,
  8482. _DtCvSegment *head_el,
  8483. _DtCvSegment *snb_el,
  8484. SDLMask *stop_mask,
  8485. const char *lang,
  8486. const char *char_set,
  8487. _DtCvValue (*resolve_spc)(),
  8488. _DtCvPointer client_data,
  8489. void ***ret_chunks)
  8490. {
  8491. int cnt = 0;
  8492. int result = 0;
  8493. result = CreateTitleChunks(toss, _DtCvContainerListOfSeg(head_el),
  8494. snb_el, stop_mask, lang, char_set,
  8495. resolve_spc, client_data,
  8496. &cnt, ret_chunks);
  8497. if ((result != 0 || cnt == 0) && NULL != AbbrevOfSeg(head_el)
  8498. && strlen ((char *) AbbrevOfSeg(head_el)))
  8499. {
  8500. *ret_chunks = (void **) malloc (sizeof(void *) * 4);
  8501. if (*ret_chunks == NULL)
  8502. return -1;
  8503. (*ret_chunks)[0] = (void *) DT_HELP_CE_CHARSET;
  8504. (*ret_chunks)[1] = (void *) strdup(char_set);
  8505. (*ret_chunks)[2] = (void *) strdup(AbbrevOfSeg(head_el));
  8506. (*ret_chunks)[3] = (void *) DT_HELP_CE_END;
  8507. }
  8508. return result;
  8509. }
  8510. /******************************************************************************
  8511. * Function: _DtCvSegment *GetSdlDocSnb (
  8512. * _DtHelpVolumeHdl volume)
  8513. * Parameters:
  8514. * volume Specifies the volume.
  8515. *
  8516. * Returns: 0 if successful, -1 if errors
  8517. *
  8518. * Purpose: If the title has been parsed and it used snrefs,
  8519. * this function will return the snb specified in the
  8520. * sdldoc element.
  8521. ******************************************************************************/
  8522. static _DtCvSegment *
  8523. GetSdlDocSnb(
  8524. _DtHelpVolumeHdl volume)
  8525. {
  8526. _DtCvSegment *retEl = NULL;
  8527. CESDLVolume *sdlVol;
  8528. sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
  8529. if (sdlVol != NULL && sdlVol->snb != NULL)
  8530. retEl = (sdlVol->snb);
  8531. return retEl;
  8532. }
  8533. /******************************************************************************
  8534. * Function: int GetDocumentTitle (
  8535. * _DtHelpVolumeHdl volume,
  8536. * _DtCvValue flag,
  8537. * _DtCvSegment **ret_seg)
  8538. * Parameters:
  8539. * volume Specifies the volume.
  8540. * flag Specifies if the toss is needed.
  8541. * ret_seg Returns sdlVol->title.
  8542. *
  8543. * Returns: 0 if successful, -1 if errors, -2 if there is no title.
  8544. *
  8545. * Purpose: This will fill in the 'title' and 'snb' elements of
  8546. * the CESDLVolume structure and return 'title' in 'ret_seg'.
  8547. ******************************************************************************/
  8548. static int
  8549. GetDocumentTitle(
  8550. _DtHelpVolumeHdl volume,
  8551. _FrmtUiInfo *ui_info,
  8552. _SdlFontMode mode,
  8553. _DtCvValue flag,
  8554. _DtCvSegment **ret_seg)
  8555. {
  8556. int result = -1;
  8557. short procFlag = True;
  8558. CESDLVolume *sdlVol;
  8559. FormatStruct frmtStruct;
  8560. _DtCvSegment *toss = NULL;
  8561. SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits;
  8562. SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits;
  8563. SDLMask startExcept[SDL_MASK_LEN] =
  8564. SDLInitMask(SdlElementNone);
  8565. sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
  8566. if (sdlVol == NULL)
  8567. return -1;
  8568. if (sdlVol->title_processed == False)
  8569. {
  8570. if (flag == True)
  8571. toss = _DtHelpCeGetSdlVolToss(volume, -1);
  8572. if (SetUp(volume,NULL,&frmtStruct,toss,ui_info,-1,True,False) !=0 )
  8573. return -1;
  8574. /*
  8575. * now set up correct font mode.
  8576. */
  8577. frmtStruct.resolve_font = mode;
  8578. /*
  8579. * now get the title.
  8580. */
  8581. if (_DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, -1,
  8582. &(frmtStruct.my_file), NULL) != -1)
  8583. {
  8584. if (ProcessContent(&frmtStruct, SDLDocumentContent,
  8585. SdlElementNone, startExcept, skipMask) != -1
  8586. && ProcessSDLMarkup(&frmtStruct, SdlElementVStruct,
  8587. SdlElementNone, startExcept, skipMask) != -1
  8588. && ProcessContent(&frmtStruct, HeadAndSnb,
  8589. SdlElementNone, startExcept, processMask) != -1)
  8590. {
  8591. sdlVol->title = frmtStruct.seg_list;
  8592. sdlVol->snb = frmtStruct.snb;
  8593. sdlVol->client_data = ui_info->client_data;
  8594. sdlVol->destroy_region = ui_info->destroy_region;
  8595. result = 0;
  8596. /*
  8597. * if the volume doesn't have a head, set the
  8598. * appropriate flags.
  8599. */
  8600. if (NULL == sdlVol->title)
  8601. {
  8602. procFlag = -1; /* processed with no errors */
  8603. result = -2; /* but no title */
  8604. }
  8605. }
  8606. else /* free the segments */
  8607. _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE,
  8608. ui_info->destroy_region,
  8609. ui_info->client_data);
  8610. _DtHelpCeBufFileClose (frmtStruct.my_file, True);
  8611. }
  8612. /*
  8613. * free the font structures allocated
  8614. */
  8615. DestroyFontInfo(&frmtStruct);
  8616. /*
  8617. * destroy the link database
  8618. */
  8619. _DtLinkDbDestroy(frmtStruct.my_links);
  8620. sdlVol->title_processed = procFlag;
  8621. }
  8622. /*
  8623. * if we have a title, good
  8624. */
  8625. else if (sdlVol->title != NULL)
  8626. result = 0;
  8627. /*
  8628. * we haven't processed a title. Is is because the volume
  8629. * doesn't have one or because of problems accessing the volume?
  8630. */
  8631. else if (-1 == sdlVol->title_processed)
  8632. result = -2; /* volume doesn't have a title */
  8633. *ret_seg = sdlVol->title;
  8634. return result;
  8635. }
  8636. /******************************************************************************
  8637. *
  8638. * Semi-Private Functions
  8639. *
  8640. *****************************************************************************/
  8641. /******************************************************************************
  8642. * Function: SDLAttribute *_DtHelpCeGetSdlAttributeList(void)
  8643. *
  8644. * Parameters:
  8645. *
  8646. * Returns: ptr or NULL;
  8647. *
  8648. * Purpose:
  8649. ******************************************************************************/
  8650. const SDLAttribute *
  8651. _DtHelpCeGetSdlAttributeList(void)
  8652. {
  8653. const SDLAttribute *ptr = SDLAttributeList;
  8654. return ptr;
  8655. }
  8656. /******************************************************************************
  8657. *
  8658. * Semi-Public Functions
  8659. *
  8660. *****************************************************************************/
  8661. /******************************************************************************
  8662. * Function: int _DtHelpCeFrmtSDLPathAndChildren (
  8663. * _DtHelpVolumeHdl volume, char *filename,
  8664. * int offset, char *id_string,
  8665. * _DtCvTopicPtr *ret_handle)
  8666. *
  8667. * Parameters:
  8668. * volume Specifies the Help Volume the information
  8669. * is associated with.
  8670. * filename Specifies the file containing the Help Topic
  8671. * desired.
  8672. * offset Specifies the offset into 'filename' to
  8673. * the Help Topic desired.
  8674. * id_string Specifies the location id to look for or NULL.
  8675. * ret_handle Returns a handle to the topic information
  8676. * including the number of paragraphs and the
  8677. * id match segment.
  8678. *
  8679. * Returns: 0 if successful, -1 if errors, 1 if the path is empty.
  8680. *
  8681. ******************************************************************************/
  8682. int
  8683. _DtHelpCeFrmtSdlPathAndChildren(
  8684. _DtHelpVolumeHdl volume,
  8685. _FrmtUiInfo *ui_info,
  8686. int fd,
  8687. char *target_id,
  8688. _DtCvTopicPtr *ret_handle)
  8689. {
  8690. char *lang;
  8691. const char *charSet;
  8692. char **topicMap;
  8693. int result = 0;
  8694. int pathCnt;
  8695. FormatStruct frmtStruct;
  8696. _DtCvTopicInfo *topicHandle;
  8697. _DtCvSegment *mySegList = NULL;
  8698. _DtCvSegment *myPrevSeg = NULL;
  8699. _DtCvSegment *loids;
  8700. _DtCvSegment *snb = NULL;
  8701. SDLIdInfo *info;
  8702. *ret_handle = NULL;
  8703. /*
  8704. * look for the heading for each virpage
  8705. */
  8706. frmtStruct = DefFormatStruct;
  8707. frmtStruct.ui_info = ui_info;
  8708. frmtStruct.my_links = _DtLinkDbCreate();
  8709. frmtStruct.vol_name = _DtHelpCeGetVolumeName(volume);
  8710. frmtStruct.id_string = target_id;
  8711. /*
  8712. * get the path from the target to the top.
  8713. */
  8714. pathCnt = _DtHelpCeGetSdlIdPath(volume, target_id, &topicMap);
  8715. if (pathCnt == -1)
  8716. return -1;
  8717. /*
  8718. * get the beginning of the path
  8719. */
  8720. loids = _DtHelpCeMapSdlIdToSegment(volume, *topicMap, fd);
  8721. if (loids == NULL)
  8722. {
  8723. _DtCvFreeArray((void **) topicMap);
  8724. return -1;
  8725. }
  8726. /*
  8727. * format the top topic entry.
  8728. */
  8729. info = FrmtPrivInfoPtr(loids)->id_info;
  8730. if (_SdlIdInfoPtrRlevel(info) > 0)
  8731. {
  8732. /*
  8733. * Put the top topic in the table of contents.
  8734. */
  8735. lang = _DtHelpCeGetSdlVolLanguage(volume);
  8736. charSet = _DtHelpCeGetSdlVolCharSet(volume);
  8737. result = AddEntryToToc(&frmtStruct, volume, fd,
  8738. _SdlIdInfoPtrRlevel(info), lang, charSet,
  8739. _DtHelpCeGetSdlVolToss(volume, fd),
  8740. loids, (topicMap[1] == NULL ? True : False),
  8741. &snb, &mySegList, &myPrevSeg);
  8742. /*
  8743. * format the children.
  8744. */
  8745. if (result != -1 && _DtCvNextSeg(loids) != NULL)
  8746. {
  8747. loids = _DtCvNextSeg(loids);
  8748. result = ExpandToc(&frmtStruct, volume, fd, lang, charSet,
  8749. _DtHelpCeGetSdlVolToss(volume, fd),
  8750. _SdlIdInfoPtrRlevel(info) + 1,
  8751. &topicMap[1],
  8752. &loids, &snb, &mySegList, &myPrevSeg);
  8753. }
  8754. }
  8755. if (result != -1)
  8756. {
  8757. topicHandle = (_DtCvTopicInfo *) malloc (sizeof(_DtCvTopicInfo));
  8758. if (topicHandle != NULL)
  8759. {
  8760. topicHandle->id_str = NULL;
  8761. topicHandle->mark_list = NULL;
  8762. topicHandle->link_data = frmtStruct.my_links;
  8763. topicHandle->seg_list = (void *) mySegList;
  8764. /*
  8765. * let the top level know that there isn't a path
  8766. */
  8767. if (NULL == mySegList)
  8768. result = 1;
  8769. *ret_handle = (void *) topicHandle;
  8770. }
  8771. else
  8772. result = -1;
  8773. }
  8774. _DtCvFreeArray((void **) topicMap);
  8775. return result;
  8776. } /* End _DtHelpCeFrmtSDLPathAndChildren */
  8777. /******************************************************************************
  8778. * Function: int _DtHelpCeFrmtSdlVolumeInfo (char *filename,
  8779. * _DtCvTopicPtr *ret_handle)
  8780. *
  8781. * Parameters:
  8782. * filename Specifies the file containing the Help Topic
  8783. * desired.
  8784. * ret_handle Returns a handle to the topic information
  8785. * including the number of paragraphs and the
  8786. * id match segment.
  8787. *
  8788. * Returns: 0 if successful, -1 if errors
  8789. *
  8790. * Purpose: _DtHelpCeFrmtSdlVolumeInfo processes the SDL volume looking
  8791. * for the generated items.
  8792. *
  8793. ******************************************************************************/
  8794. int
  8795. _DtHelpCeFrmtSdlVolumeInfo(
  8796. char *filename,
  8797. _DtHelpVolumeHdl volume,
  8798. time_t *ret_time)
  8799. {
  8800. int result = 0;
  8801. char *numPtr;
  8802. CESDLVolume *sdlVol;
  8803. FormatStruct frmtStruct;
  8804. SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits;
  8805. SDLMask startExcept[SDL_MASK_LEN] =
  8806. SDLInitMask(SdlElementNone);
  8807. if (SetUp(volume,&sdlVol,&frmtStruct,NULL,&DefUiInfo,-1,True,False) != 0)
  8808. return -1;
  8809. /*
  8810. * now set up correct font mode.
  8811. */
  8812. frmtStruct.resolve_font = _SdlFontModeNone;
  8813. if (result == 0)
  8814. {
  8815. result = _DtHelpCeFileOpenAndSeek(filename, 0, -1,
  8816. &(frmtStruct.my_file), ret_time);
  8817. if (result != -1)
  8818. {
  8819. result = ProcessContent(&frmtStruct, SDLDocumentContent,
  8820. SdlElementNone, startExcept, processMask);
  8821. _DtHelpCeBufFileClose (frmtStruct.my_file, True);
  8822. if (frmtStruct.remember != NULL)
  8823. free(frmtStruct.remember);
  8824. }
  8825. if (result != -1)
  8826. {
  8827. /*
  8828. * attach the information to this volume.
  8829. */
  8830. sdlVol->sdl_info = (SDLDocInfo *)
  8831. FrmtPrivInfoPtr(frmtStruct.seg_list)->doc_info;
  8832. /*
  8833. * check the major and minor numbers.
  8834. */
  8835. numPtr = _SdlDocInfoPtrSdlDtd(sdlVol->sdl_info);
  8836. while (*numPtr < '0' || *numPtr > '9')
  8837. numPtr++;
  8838. if (atoi(numPtr) != SDL_DTD_VERSION)
  8839. result = -1;
  8840. else
  8841. {
  8842. while (*numPtr != '.' && *numPtr != '\0')
  8843. numPtr++;
  8844. if (*numPtr == '.')
  8845. numPtr++;
  8846. sdlVol->minor_no = atoi(numPtr);
  8847. }
  8848. /*
  8849. * free the container
  8850. */
  8851. FrmtPrivInfoPtr(frmtStruct.seg_list)->doc_info = NULL;
  8852. _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE, NULL, NULL);
  8853. }
  8854. }
  8855. _DtLinkDbDestroy(frmtStruct.my_links);
  8856. /*
  8857. * free the font structures allocated
  8858. */
  8859. DestroyFontInfo(&frmtStruct);
  8860. return result;
  8861. }
  8862. /******************************************************************************
  8863. * Function: int _DtHelpCeFrmtSDLTitleToAscii (
  8864. * char *filename,
  8865. * int offset,
  8866. * char **ret_title, char **ret_abbrev)
  8867. *
  8868. * Parameters:
  8869. *
  8870. * Returns: 0 if successful, -1 if errors
  8871. *
  8872. * Purpose:
  8873. ******************************************************************************/
  8874. int
  8875. _DtHelpCeFrmtSDLTitleToAscii(
  8876. _DtHelpVolumeHdl volume,
  8877. int offset,
  8878. char **ret_title,
  8879. char **ret_abbrev)
  8880. {
  8881. int result = 0;
  8882. FormatStruct frmtStruct;
  8883. if (SetUp(volume,NULL,&frmtStruct,NULL,&DefUiInfo,-1,True,False) != 0)
  8884. return -1;
  8885. *ret_title = NULL;
  8886. if (ret_abbrev != NULL)
  8887. *ret_abbrev = NULL;
  8888. /*
  8889. * now set up correct font mode.
  8890. */
  8891. frmtStruct.resolve_font = _SdlFontModeNone;
  8892. /*
  8893. * get the title.
  8894. */
  8895. result = FormatSDLTitle(frmtStruct.vol_name, offset, -1, &frmtStruct);
  8896. if (result != -1 && frmtStruct.seg_list != NULL)
  8897. {
  8898. _DtCvSegment *pHeadSeg;
  8899. _DtCvValue nlFlag = False;
  8900. pHeadSeg = _DtCvContainerListOfSeg(frmtStruct.seg_list);
  8901. if (pHeadSeg != NULL)
  8902. {
  8903. CreateAsciiString(_DtCvContainerListOfSeg(pHeadSeg),
  8904. frmtStruct.snb, &nlFlag, ret_title);
  8905. CreateAsciiAbbrev(pHeadSeg, ret_abbrev);
  8906. }
  8907. else
  8908. result = -1;
  8909. }
  8910. else
  8911. result = -1;
  8912. if (frmtStruct.seg_list != NULL)
  8913. _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE, NULL, NULL);
  8914. /*
  8915. * free the font structures allocated
  8916. */
  8917. DestroyFontInfo(&frmtStruct);
  8918. return result;
  8919. } /* End _DtHelpCeFrmtSDLTitleToAscii */
  8920. /******************************************************************************
  8921. * Function: char *_DtHelpCeFrmtSdlVolumeAbstractToAscii(
  8922. * _DtHelpVolumeHdl volume)
  8923. *
  8924. * Parameters:
  8925. * volume Specifies the Help Volume the information
  8926. * is associated with.
  8927. *
  8928. * Returns: 0 if successful, -1 if errors
  8929. *
  8930. * Purpose: _DtHelpCeFrmtSdlVolumeAbstractToAscii formats Help Files
  8931. * with formatting information into a CEVirtualPage
  8932. *
  8933. ******************************************************************************/
  8934. char *
  8935. _DtHelpCeFrmtSdlVolumeAbstractToAscii(
  8936. _DtHelpVolumeHdl volume)
  8937. {
  8938. int offset;
  8939. char *abstr = NULL;
  8940. _DtCvSegment *pSeg;
  8941. _DtCvSegment *pSnb;
  8942. _DtCvValue nlFlag = False;
  8943. _DtHelpCeLockInfo lockInfo;
  8944. if (_DtHelpCeLockVolume(volume, &lockInfo) != 0)
  8945. return NULL;
  8946. if (_DtHelpCeFindSdlId(volume,"_abstract",lockInfo.fd,NULL,&offset) == True)
  8947. {
  8948. int result = 0;
  8949. SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone);
  8950. SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits;
  8951. FormatStruct frmtStruct;
  8952. CESDLVolume *sdlVol;
  8953. if (SetUp(volume, &sdlVol, &frmtStruct, NULL, &DefUiInfo,
  8954. lockInfo.fd, True, False) != 0)
  8955. return NULL;
  8956. /*
  8957. * now set up correct font mode.
  8958. */
  8959. frmtStruct.resolve_font = _SdlFontModeNone;
  8960. /*
  8961. * open the volume and seek to the virpage
  8962. */
  8963. result = _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume),
  8964. offset, lockInfo.fd,
  8965. &(frmtStruct.my_file), NULL);
  8966. if (result != -1)
  8967. {
  8968. result = ProcessSDLMarkup (&frmtStruct, SdlElementVirpage,
  8969. SdlElementNone, startExcept, processMask);
  8970. _DtHelpCeBufFileClose (frmtStruct.my_file,
  8971. (lockInfo.fd == -1 ? True : False));
  8972. }
  8973. if (result != -1)
  8974. {
  8975. pSeg = frmtStruct.seg_list;
  8976. pSnb = frmtStruct.snb;
  8977. CreateAsciiString(pSeg, pSnb, &nlFlag, &abstr);
  8978. _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE, NULL, NULL);
  8979. _DtHelpFreeSegments(frmtStruct.snb, _DtCvFALSE, NULL, NULL);
  8980. }
  8981. /*
  8982. * free the font structures allocated
  8983. */
  8984. DestroyFontInfo(&frmtStruct);
  8985. }
  8986. _DtHelpCeUnlockVolume(lockInfo);
  8987. return abstr;
  8988. } /* End _DtHelpCeFrmtSdlVolumeAbstractToAscii */
  8989. /******************************************************************************
  8990. * Function: int _DtHelpCeFrmtSDLVolTitleToAscii (
  8991. * char *filename,
  8992. * int offset,
  8993. * char **ret_title, char **ret_abbrev)
  8994. *
  8995. * Parameters:
  8996. *
  8997. * Returns: 0 if successful, -1 if errors
  8998. *
  8999. * Purpose:
  9000. ******************************************************************************/
  9001. int
  9002. _DtHelpCeFrmtSDLVolTitleToAscii(
  9003. _DtHelpVolumeHdl volume,
  9004. _FrmtUiInfo *ui_info,
  9005. char **ret_title)
  9006. {
  9007. char *abbrev = NULL;
  9008. int result = 0;
  9009. _DtCvSegment *pHeadSeg;
  9010. _DtHelpCeLockInfo lockInfo;
  9011. *ret_title = NULL;
  9012. /*
  9013. * get the head element
  9014. */
  9015. if (_DtHelpCeLockVolume(volume, &lockInfo) != 0)
  9016. return -1;
  9017. result = GetDocumentTitle(volume,ui_info, _SdlFontModeNone, False, &pHeadSeg);
  9018. _DtHelpCeUnlockVolume(lockInfo);
  9019. if (result == 0)
  9020. {
  9021. /*
  9022. * get the abbreviation of the head
  9023. */
  9024. result = -2;
  9025. if (pHeadSeg != NULL)
  9026. {
  9027. CreateAsciiAbbrev(pHeadSeg, &abbrev);
  9028. if (abbrev != NULL && *abbrev != '\0')
  9029. {
  9030. *ret_title = abbrev;
  9031. result = 0;
  9032. }
  9033. }
  9034. /*
  9035. * if there wasn't an abbreviation, use the head itself, stripping
  9036. * all special items and graphics.
  9037. */
  9038. if (0 != result && pHeadSeg != NULL &&
  9039. NULL != _DtCvContainerListOfSeg(pHeadSeg))
  9040. {
  9041. _DtCvValue nlFlag = False;
  9042. CreateAsciiString(_DtCvContainerListOfSeg(pHeadSeg),
  9043. GetSdlDocSnb(volume),
  9044. &nlFlag, ret_title);
  9045. if (abbrev != NULL)
  9046. free(abbrev);
  9047. result = 0;
  9048. }
  9049. }
  9050. /*
  9051. * if there isn't an abbreviation on the document, and there isn't
  9052. * a head, then try for the title page. After that, try the
  9053. * hometopic's title.
  9054. */
  9055. if (-2 == result)
  9056. {
  9057. result = 0;
  9058. if (_DtHelpGetTopicTitle(volume, "_title", ret_title) != 0)
  9059. result = _DtHelpGetTopicTitle(volume, "_hometopic", ret_title);
  9060. }
  9061. return result;
  9062. } /* End _DtHelpCeFrmtSDLVolTitleToAscii */
  9063. /******************************************************************************
  9064. * Function: int _DtHelpCeGetSdlTopicTitleChunks (
  9065. *
  9066. * Parameters:
  9067. *
  9068. * Returns: 0 if successful, -1 if errors
  9069. *
  9070. * Purpose:
  9071. ******************************************************************************/
  9072. int
  9073. _DtHelpCeGetSdlTitleChunks(
  9074. _DtHelpVolumeHdl volume,
  9075. char *loc_id,
  9076. _FrmtUiInfo *ui_info,
  9077. void ***ret_chunks)
  9078. {
  9079. int result = 0;
  9080. int offset;
  9081. FormatStruct frmtStruct;
  9082. CESDLVolume *sdlVol;
  9083. SDLMask stopMask[SDL_MASK_LEN] =
  9084. SDLInitMask(SdlElementSubHead);
  9085. *ret_chunks = NULL;
  9086. if (_DtHelpCeFindSdlId(volume, loc_id, -1, NULL, &offset) != True)
  9087. return -1;
  9088. if (SetUp(volume, &sdlVol, &frmtStruct, NULL, ui_info, -1, True, True) != 0)
  9089. return -1;
  9090. result = FormatSDLTitle(frmtStruct.vol_name, offset, -1, &frmtStruct);
  9091. if (result != -1 && frmtStruct.seg_list != NULL)
  9092. {
  9093. _DtCvSegment *headEl;
  9094. _DtCvSegment *pSnbEl = NULL;
  9095. result = -1;
  9096. headEl = _DtCvContainerListOfSeg(frmtStruct.seg_list);
  9097. /*
  9098. * A virpage contains a zero or more heads as it's first
  9099. * content. Therefore, if the the first item is not a
  9100. * container and a controller (heads get the controller flag
  9101. * put on them), then this virpage does not have a title.
  9102. */
  9103. if (NULL != headEl && _DtCvIsSegContainer(headEl) &&
  9104. _DtCvIsSegController(headEl))
  9105. {
  9106. result = ProcessSegmentsToChunks(frmtStruct.toss,
  9107. headEl,
  9108. pSnbEl, stopMask,
  9109. _DtHelpCeGetSdlVolLanguage(volume),
  9110. _DtHelpCeGetSdlVolCharSet(volume),
  9111. ui_info->resolve_spc,
  9112. ui_info->client_data,
  9113. ret_chunks);
  9114. }
  9115. }
  9116. else
  9117. result = -1;
  9118. if (frmtStruct.seg_list != NULL)
  9119. _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE,
  9120. ui_info->destroy_region,
  9121. ui_info->client_data);
  9122. if (frmtStruct.snb != NULL)
  9123. _DtHelpFreeSegments(frmtStruct.snb, _DtCvFALSE,
  9124. ui_info->destroy_region,
  9125. ui_info->client_data);
  9126. /*
  9127. * free the font structures allocated
  9128. */
  9129. DestroyFontInfo(&frmtStruct);
  9130. /*
  9131. * destroy the link database
  9132. */
  9133. _DtLinkDbDestroy(frmtStruct.my_links);
  9134. return result;
  9135. } /* End _DtHelpCeGetSdlTitleChunks */
  9136. /******************************************************************************
  9137. * Function: int _DtHelpCeGetSdlVolTitleChunks (
  9138. *
  9139. * Parameters:
  9140. *
  9141. * Returns: 0 if successful, -1 if errors
  9142. *
  9143. * Purpose:
  9144. ******************************************************************************/
  9145. int
  9146. _DtHelpCeGetSdlVolTitleChunks(
  9147. _DtHelpVolumeHdl volume_handle,
  9148. _FrmtUiInfo *ui_info,
  9149. void ***ret_chunks)
  9150. {
  9151. int result = -2;
  9152. _DtCvSegment *pHeadSeg;
  9153. CESDLVolume *sdlVol;
  9154. SDLMask stopMask[SDL_MASK_LEN] =
  9155. SDLInitMask(SdlElementSubHead);
  9156. /*
  9157. * get the sdl volume pointer.
  9158. */
  9159. sdlVol = _DtHelpCeGetSdlVolumePtr(volume_handle);
  9160. if (sdlVol == NULL)
  9161. return -1;
  9162. /*
  9163. * find the document attributes
  9164. */
  9165. if (NULL == sdlVol->sdl_info)
  9166. return -1;
  9167. /*
  9168. * get the head element
  9169. */
  9170. if (GetDocumentTitle(volume_handle, ui_info,
  9171. _SdlFontModeResolve, True, &pHeadSeg) == -1)
  9172. return -1;
  9173. /*
  9174. * process it
  9175. */
  9176. if (pHeadSeg != NULL)
  9177. result = ProcessSegmentsToChunks(
  9178. _DtHelpCeGetSdlVolToss(volume_handle, -1),
  9179. pHeadSeg,
  9180. GetSdlDocSnb(volume_handle), stopMask,
  9181. _DtHelpCeGetSdlVolLanguage(volume_handle),
  9182. _DtHelpCeGetSdlVolCharSet(volume_handle),
  9183. ui_info->resolve_spc,
  9184. ui_info->client_data,
  9185. ret_chunks);
  9186. if (result != 0)
  9187. {
  9188. result = _DtHelpCeGetSdlTitleChunks(volume_handle, "_title",
  9189. ui_info, ret_chunks);
  9190. if (result != 0)
  9191. result = _DtHelpCeGetSdlTitleChunks(volume_handle, "_hometopic",
  9192. ui_info, ret_chunks);
  9193. }
  9194. return result;
  9195. } /* End _DtHelpCeGetSdlVolTitleChunks */
  9196. /******************************************************************************
  9197. * Function: int _DtHelpCeGetSdlVolToss (
  9198. * _DtHelpVolumeHdl volume,
  9199. * Parameters:
  9200. * volume Specifies the volume to read/parse.
  9201. *
  9202. * Returns: 0 if successful, -1 if errors
  9203. *
  9204. * Purpose: Get the toss from a volume.
  9205. ******************************************************************************/
  9206. _DtCvSegment *
  9207. _DtHelpCeGetSdlVolToss(
  9208. _DtHelpVolumeHdl volume,
  9209. int fd)
  9210. {
  9211. CESDLVolume *sdlVol;
  9212. FormatStruct frmtStruct;
  9213. SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits;
  9214. SDLMask startExcept[SDL_MASK_LEN] =
  9215. SDLInitMask(SdlElementNone);
  9216. /*
  9217. * get the sdl volume pointer.
  9218. */
  9219. sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
  9220. if (sdlVol == NULL)
  9221. return NULL;
  9222. if (sdlVol->toss == NULL
  9223. && SetUp(volume,NULL,&frmtStruct,NULL,&DefUiInfo,fd,True,False) == 0
  9224. && _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, fd,
  9225. &(frmtStruct.my_file), NULL) != -1)
  9226. {
  9227. if (ProcessContent(&frmtStruct, SDLDocumentContent,
  9228. SdlElementNone, startExcept, skipMask) != -1
  9229. && ProcessSDLMarkup(&frmtStruct, SdlElementVStruct,
  9230. SdlElementToss, startExcept, skipMask) != -1)
  9231. sdlVol->toss = frmtStruct.seg_list;
  9232. _DtHelpCeBufFileClose (frmtStruct.my_file, (fd == -1 ? True : False));
  9233. /*
  9234. * free the font structures allocated
  9235. */
  9236. DestroyFontInfo(&frmtStruct);
  9237. /*
  9238. * destroy the link database
  9239. */
  9240. _DtLinkDbDestroy(frmtStruct.my_links);
  9241. }
  9242. if (sdlVol->toss != NULL)
  9243. return (_DtCvContainerListOfSeg(sdlVol->toss));
  9244. return NULL;
  9245. } /* End _DtHelpCeGetSdlVolToss */
  9246. /******************************************************************************
  9247. * Function: int _DtHelpCeGetSdlVolIndex (
  9248. * _DtHelpVolumeHdl volume,
  9249. * Parameters:
  9250. * volume Specifies the volume to read/parse.
  9251. *
  9252. * Returns: 0 if successful, -1 if errors
  9253. *
  9254. * Purpose: Get the index from a volume.
  9255. ******************************************************************************/
  9256. int
  9257. _DtHelpCeGetSdlVolIndex(
  9258. _DtHelpVolumeHdl volume)
  9259. {
  9260. int result = -1;
  9261. CESDLVolume *sdlVol;
  9262. FormatStruct frmtStruct;
  9263. SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits;
  9264. SDLMask startExcept[SDL_MASK_LEN] =
  9265. SDLInitMask(SdlElementNone);
  9266. sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
  9267. if (sdlVol == NULL)
  9268. return -1;
  9269. if (sdlVol->index != NULL)
  9270. return 0;
  9271. if (SetUp(volume, NULL, &frmtStruct, NULL, &DefUiInfo, -1, True, True) != 0)
  9272. return -1;
  9273. /*
  9274. * now set up correct font mode.
  9275. */
  9276. frmtStruct.resolve_font = _SdlFontModeNone;
  9277. if (_DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, -1,
  9278. &(frmtStruct.my_file), NULL) != -1)
  9279. {
  9280. if (ProcessContent(&frmtStruct, SDLDocumentContent,
  9281. SdlElementNone, startExcept, skipMask) != -1
  9282. && ProcessSDLMarkup(&frmtStruct, SdlElementVStruct,
  9283. SdlElementIndex, startExcept, skipMask) != -1)
  9284. {
  9285. sdlVol->index = frmtStruct.seg_list;
  9286. result = 0;
  9287. }
  9288. _DtHelpCeBufFileClose (frmtStruct.my_file, True);
  9289. }
  9290. /*
  9291. * destroy the link database
  9292. */
  9293. _DtLinkDbDestroy(frmtStruct.my_links);
  9294. /*
  9295. * free the font structures allocated
  9296. */
  9297. DestroyFontInfo(&frmtStruct);
  9298. return result;
  9299. } /* End _DtHelpCeGetSdlVolIndex */
  9300. /******************************************************************************
  9301. * Function: int _DtHelpCeGetSdlVolIds (
  9302. * _DtHelpVolumeHdl volume,
  9303. * _DtCvSegment **ret_ids
  9304. * Parameters:
  9305. * volume Specifies the volume to read/parse.
  9306. *
  9307. * Returns: 0 if successful, -1 if errors
  9308. *
  9309. * Purpose: Get the loids from a volume.
  9310. ******************************************************************************/
  9311. int
  9312. _DtHelpCeGetSdlVolIds(
  9313. _DtHelpVolumeHdl volume,
  9314. int fd,
  9315. _DtCvSegment **ret_ids)
  9316. {
  9317. int result = 0;
  9318. CESDLVolume *sdlVol;
  9319. FormatStruct frmtStruct;
  9320. SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits;
  9321. SDLMask startExcept[SDL_MASK_LEN] =
  9322. SDLInitMask(SdlElementNone);
  9323. *ret_ids = NULL;
  9324. sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
  9325. if (sdlVol == NULL)
  9326. return -1;
  9327. if (sdlVol->loids == NULL)
  9328. {
  9329. result = -1;
  9330. if (SetUp(NULL,NULL,&frmtStruct,NULL,&DefUiInfo,-1,False,False) != -1
  9331. && _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, fd,
  9332. &(frmtStruct.my_file), NULL) != -1)
  9333. {
  9334. if (ProcessContent(&frmtStruct, SDLDocumentContent,
  9335. SdlElementNone, startExcept, skipMask) != -1)
  9336. {
  9337. if (ProcessSDLMarkup(&frmtStruct, SdlElementVStruct,
  9338. SdlElementLoids, startExcept, skipMask) != -1)
  9339. {
  9340. sdlVol->loids = frmtStruct.seg_list;
  9341. result = 0;
  9342. }
  9343. }
  9344. /*
  9345. * free the font structures allocated
  9346. */
  9347. DestroyFontInfo(&frmtStruct);
  9348. /*
  9349. * destroy the link database
  9350. */
  9351. _DtLinkDbDestroy(frmtStruct.my_links);
  9352. _DtHelpCeBufFileClose(frmtStruct.my_file,(fd == -1 ? True : False));
  9353. }
  9354. }
  9355. if (sdlVol->loids != NULL)
  9356. *ret_ids = _DtCvContainerListOfSeg(sdlVol->loids);
  9357. return result;
  9358. } /* End _DtHelpCeGetSdlVolIds */
  9359. /******************************************************************************
  9360. * Function: int _DtHelpCeParseSdlTopic (_DtHelpVolumeHdl volume,
  9361. * int offset, char *id_string,
  9362. * _DtCvTopicPtr *ret_handle)
  9363. *
  9364. * Parameters:
  9365. * volume Specifies the Help Volume the information
  9366. * is associated with.
  9367. * offset Specifies the offset into 'filename' to
  9368. * the Help Topic desired.
  9369. * id_string Specifies the location id to look for or NULL.
  9370. * ret_handle Returns a handle to the topic information
  9371. * including the number of paragraphs and the
  9372. * id match segment.
  9373. *
  9374. * Returns: 0 if successful, -1 if errors
  9375. *
  9376. * Purpose: _DtHelpCeParseSdlTopic formats Help Files with formatting
  9377. * information into a CEVirtualPage
  9378. *
  9379. ******************************************************************************/
  9380. int
  9381. _DtHelpCeParseSdlTopic(
  9382. _DtHelpVolumeHdl volume,
  9383. _FrmtUiInfo *ui_info,
  9384. int fd,
  9385. int offset,
  9386. char *id_string,
  9387. int rich_text,
  9388. _DtCvTopicPtr *ret_handle)
  9389. {
  9390. int result = 0;
  9391. SDLMask startExcept[SDL_MASK_LEN] =
  9392. SDLInitMask(SdlElementNone);
  9393. SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits;
  9394. FormatStruct frmtStruct;
  9395. _DtCvTopicInfo *topicHandle;
  9396. CESDLVolume *sdlVol;
  9397. *ret_handle = NULL;
  9398. if (SetUp(volume,&sdlVol,&frmtStruct,NULL,ui_info,fd,True,rich_text) != 0)
  9399. return -1;
  9400. /*
  9401. * remember the id for graphics
  9402. */
  9403. frmtStruct.id_string = id_string;
  9404. result = _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume),
  9405. offset, fd,
  9406. &(frmtStruct.my_file), NULL);
  9407. if (result != -1)
  9408. {
  9409. result = ProcessSDLMarkup (&frmtStruct, SdlElementVirpage,
  9410. SdlElementNone, startExcept, processMask);
  9411. _DtHelpCeBufFileClose (frmtStruct.my_file, (fd == -1 ? True : False));
  9412. }
  9413. /*
  9414. * free the async blocks
  9415. */
  9416. _DtHelpFreeSegments(frmtStruct.async_blks, _DtCvFALSE,
  9417. ui_info->destroy_region,
  9418. ui_info->client_data);
  9419. /*
  9420. * free the system notation blocks
  9421. */
  9422. _DtHelpFreeSegments(frmtStruct.snb, _DtCvFALSE,
  9423. ui_info->destroy_region,
  9424. ui_info->client_data);
  9425. if (result != -1)
  9426. {
  9427. topicHandle = (_DtCvTopicInfo *) malloc (sizeof(_DtCvTopicInfo));
  9428. if (topicHandle != NULL)
  9429. {
  9430. topicHandle->mark_list = NULL;
  9431. topicHandle->id_str = NULL;
  9432. if (id_string != NULL)
  9433. topicHandle->id_str = strdup(id_string);
  9434. topicHandle->link_data = frmtStruct.my_links;
  9435. topicHandle->seg_list = frmtStruct.seg_list;
  9436. *ret_handle = (void *) topicHandle;
  9437. }
  9438. else
  9439. result = -1;
  9440. }
  9441. /*
  9442. * free the allocated font structures
  9443. */
  9444. DestroyFontInfo(&frmtStruct);
  9445. return result;
  9446. } /* End _DtHelpCeParseSdlTopic */