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 libraries 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 , "UTF-8"},
  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. { int myI;\
  2986. for (myI = 0; myI < SDL_MASK_LEN; myI++) \
  2987. x[myI] = y[myI]; \
  2988. }
  2989. #define MergeMasks(x,y) \
  2990. { int myI;\
  2991. for (myI = 0; myI < SDL_MASK_LEN; myI++) \
  2992. x[myI] |= y[myI]; \
  2993. }
  2994. #define RemoveMasks(x,y) \
  2995. { int myI;\
  2996. for (myI = 0; myI < SDL_MASK_LEN; myI++) \
  2997. x[myI] &= (~(y[myI])); \
  2998. }
  2999. #define MaskToValue(x,y) \
  3000. { int myI;\
  3001. 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. 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. {
  3491. free(newData);
  3492. return NULL;
  3493. }
  3494. /*
  3495. * set the match data for toss lookup
  3496. */
  3497. match = SegMatchDataPtr(refItem);
  3498. if (NULL != match && NULL != my_struct->toss)
  3499. _DtHelpCeMergeSdlAttribInfo(
  3500. _DtHelpCeMatchSemanticStyle(
  3501. my_struct->toss,
  3502. match->clan,
  3503. match->level,
  3504. match->ssi),
  3505. newSeg,
  3506. my_struct->my_fonts,
  3507. NULL,
  3508. NULL,
  3509. NULL);
  3510. if (0 != MySaveString(&newSeg, my_struct, newData,
  3511. my_struct->cur_link, my_struct->mb_len,
  3512. False))
  3513. {
  3514. free(newData);
  3515. return NULL;
  3516. }
  3517. free(newData);
  3518. }
  3519. else
  3520. {
  3521. /*
  3522. * strip the container wrapper from the snbEntry before
  3523. * duplication.
  3524. *
  3525. * Also, include the toss match data for this segment
  3526. * in the snbEntry.
  3527. */
  3528. snbEntry = _DtCvContainerListOfSeg(snbEntry);
  3529. if (NULL != snbEntry)
  3530. {
  3531. SegMatchData(snbEntry) = SegMatchData(refItem);
  3532. newSeg = DuplicateElement(my_struct->ui_info->client_data,
  3533. my_struct->toss,
  3534. snbEntry,
  3535. &(my_struct->prev_data),
  3536. NULL,
  3537. my_struct->ui_info->load_font,
  3538. my_struct->ui_info->resolve_spc,
  3539. my_struct->ui_info->line_height / 2,
  3540. my_struct->ui_info->avg_char,
  3541. *(my_struct->my_fonts),
  3542. my_struct->cur_link, True);
  3543. SegMatchData(snbEntry) = NULL;
  3544. if (NULL == newSeg)
  3545. return NULL;
  3546. /*
  3547. * if the only item in the list for the snb entry is
  3548. * a region, then assume it is a graphic, video, etc.
  3549. * Check to see if the region is in-line or a figure.
  3550. * If in-line, ignore any heads with the refitem. If a
  3551. * figure, include them (they may be a caption to the
  3552. * region).
  3553. */
  3554. if (_DtCvIsSegRegion(newSeg) && NULL == _DtCvNextSeg(newSeg))
  3555. {
  3556. SdlMatchData *info = SegMatchDataPtr(refItem);
  3557. /*
  3558. * is this a figure?
  3559. */
  3560. if (SdlClassFigure == info->clan)
  3561. {
  3562. _DtCvNextSeg(newSeg) = _DtCvContainerListOfSeg(refItem);
  3563. _DtCvContainerListOfSeg(refItem) = NULL;
  3564. }
  3565. }
  3566. }
  3567. }
  3568. }
  3569. /*
  3570. * was there alternate text?
  3571. */
  3572. else if (NULL != altText && NULL != _DtCvContainerListOfSeg(altText))
  3573. {
  3574. /*
  3575. * the new segment becomes the contents of the <alttext>
  3576. * container - why copy? Just null the <alttext> pointer
  3577. * to prevent the free from destroying the contents.
  3578. */
  3579. newSeg = _DtCvContainerListOfSeg(altText);
  3580. _DtCvContainerListOfSeg(altText) = NULL;
  3581. /*
  3582. * load the font for this snref.
  3583. */
  3584. (my_struct->ui_info->load_font)(my_struct->ui_info->client_data,
  3585. _DtHelpFontHintsLang(*(my_struct->my_fonts)),
  3586. _DtHelpFontHintsCharSet(*(my_struct->my_fonts)),
  3587. *(my_struct->my_fonts),
  3588. &(_DtCvFontOfStringSeg(newSeg)));
  3589. }
  3590. if (my_struct->prev_data != NULL)
  3591. my_struct->prev_data->next_disp = newSeg;
  3592. my_struct->last_was_space = False;
  3593. my_struct->last_was_mb = False;
  3594. my_struct->last_was_nl = False;
  3595. if (NULL != newSeg)
  3596. my_struct->prev_data = newSeg;
  3597. }
  3598. else if (_DtCvTRUE == my_struct->save_snref)
  3599. {
  3600. int count = my_struct->snref_cnt;
  3601. if (NULL == my_struct->un_snrefs)
  3602. my_struct->un_snrefs = (UnresSnref *) malloc (sizeof(UnresSnref));
  3603. else
  3604. my_struct->un_snrefs = (UnresSnref *) realloc (
  3605. (void *) my_struct->un_snrefs,
  3606. (sizeof(UnresSnref) * (count + 1)));
  3607. if (NULL != my_struct->un_snrefs)
  3608. {
  3609. my_struct->un_snrefs[count].id = snref_id;
  3610. my_struct->un_snrefs[count].seg = snref;
  3611. my_struct->un_snrefs[count].cur_link = my_struct->cur_link;
  3612. my_struct->un_snrefs[count].fonts = *(my_struct->my_fonts);
  3613. my_struct->snref_cnt++;
  3614. /*
  3615. * return the snref segment as our new segment to act as a
  3616. * place holder, otherwise it gets squeezed
  3617. * out.
  3618. */
  3619. newSeg = snref;
  3620. if (my_struct->prev_data != NULL)
  3621. my_struct->prev_data->next_disp = newSeg;
  3622. my_struct->prev_data = newSeg;
  3623. /*
  3624. * make the snref a noop so it gets the proper next/last
  3625. * display pointers.
  3626. */
  3627. newSeg->type = _DtCvSetTypeToNoop(newSeg->type);
  3628. }
  3629. }
  3630. *(my_struct->my_fonts) = saveFonts;
  3631. return newSeg;
  3632. } /* End ResolveSnref */
  3633. /******************************************************************************
  3634. * Function: static CEFontSpecs AllocateFontInfo(my_struct);
  3635. *
  3636. * Parameters:
  3637. *
  3638. * Returns: non-null if successful, NULL if errors
  3639. *
  3640. * Purpose: Allocates a FontInfo structure and intializes it to
  3641. * the current fonts hints.
  3642. *
  3643. ******************************************************************************/
  3644. static _DtHelpFontHints *
  3645. AllocateFontInfo(
  3646. FormatStruct *my_struct)
  3647. {
  3648. _DtHelpFontHints *retFont = NULL;
  3649. if (my_struct->free_cnt > 0)
  3650. retFont = my_struct->free_fonts[--my_struct->free_cnt];
  3651. else
  3652. {
  3653. /*
  3654. * malloc and initialize the starting font information
  3655. */
  3656. retFont = (_DtHelpFontHints *) malloc (sizeof(_DtHelpFontHints));
  3657. if (NULL == retFont)
  3658. return NULL;
  3659. }
  3660. /*
  3661. * initialize the font structure
  3662. */
  3663. if (NULL != my_struct->my_fonts)
  3664. *retFont = *(my_struct->my_fonts);
  3665. else
  3666. *retFont = DefFontInfo;
  3667. return retFont;
  3668. }
  3669. /******************************************************************************
  3670. * Function: static _DtCvSegment **ConvertToList(segs);
  3671. *
  3672. * Parameters:
  3673. *
  3674. * Returns: non-null if successful, NULL if errors
  3675. *
  3676. * Purpose: Allocates a list of null terminated _DtCvSegment pointers.
  3677. *
  3678. ******************************************************************************/
  3679. static _DtCvSegment **
  3680. ConvertToList(_DtCvSegment *segs)
  3681. {
  3682. _DtCvSegment **ptr = NULL;
  3683. /*
  3684. * count the segments
  3685. */
  3686. while (NULL != segs)
  3687. {
  3688. _DtCvSegment *next;
  3689. ptr = (_DtCvSegment **) _DtCvAddPtrToArray ((void **) ptr,
  3690. (void *) segs);
  3691. next = _DtCvNextSeg(segs);
  3692. _DtCvNextSeg(segs) = NULL;
  3693. segs = next;
  3694. }
  3695. return (ptr);
  3696. }
  3697. /******************************************************************************
  3698. * Function: static int DestroyFontInfo(my_struct);
  3699. *
  3700. * Parameters:
  3701. *
  3702. * Returns: 0 if successful, -1 if errors
  3703. *
  3704. * Purpose: Places the font structure in the free list for re-use.
  3705. *
  3706. ******************************************************************************/
  3707. static void
  3708. DestroyFontInfo(
  3709. FormatStruct *my_struct)
  3710. {
  3711. /*
  3712. * free the font structures allocated
  3713. */
  3714. while (0 < my_struct->free_cnt)
  3715. {
  3716. my_struct->free_cnt--;
  3717. free(my_struct->free_fonts[my_struct->free_cnt]);
  3718. }
  3719. if (NULL != my_struct->free_fonts)
  3720. free(my_struct->free_fonts);
  3721. my_struct->free_fonts = NULL;
  3722. if (NULL != my_struct->my_fonts)
  3723. free(my_struct->my_fonts);
  3724. }
  3725. /******************************************************************************
  3726. * Function: static int FreeFontInfo(my_struct);
  3727. *
  3728. * Parameters:
  3729. *
  3730. * Returns: 0 if successful, -1 if errors
  3731. *
  3732. * Purpose: Places the font structure in the free list for re-use.
  3733. *
  3734. ******************************************************************************/
  3735. static int
  3736. FreeFontInfo(
  3737. FormatStruct *my_struct)
  3738. {
  3739. if (my_struct->free_cnt >= my_struct->free_max)
  3740. {
  3741. my_struct->free_max += GROW_SIZE;
  3742. if (NULL != my_struct->free_fonts)
  3743. my_struct->free_fonts = (_DtHelpFontHints **) realloc (
  3744. my_struct->free_fonts,
  3745. sizeof(_DtHelpFontHints *) * my_struct->free_max);
  3746. else
  3747. my_struct->free_fonts = (_DtHelpFontHints **) malloc (
  3748. sizeof(_DtHelpFontHints *) * my_struct->free_max);
  3749. if (NULL == my_struct->free_fonts)
  3750. return -1;
  3751. }
  3752. my_struct->free_fonts[my_struct->free_cnt++] = my_struct->my_fonts;
  3753. return 0;
  3754. }
  3755. /******************************************************************************
  3756. * Function: static int ResolveAsyncBlock(my_struct, table_seg);
  3757. *
  3758. * Parameters:
  3759. *
  3760. * Returns: 0 if successful, -1 if errors
  3761. *
  3762. * Purpose:
  3763. *
  3764. ******************************************************************************/
  3765. static int
  3766. ResolveAsyncBlock(
  3767. FormatStruct *my_struct,
  3768. _DtCvSegment *table_seg)
  3769. {
  3770. char c;
  3771. char *next;
  3772. char *start = NULL;
  3773. char **rowIds = _DtCvCellIdsOfTableSeg(table_seg);
  3774. _DtCvFrmtOption *colJ;
  3775. _DtCvSegment **cellSegs;
  3776. _DtCvSegment *newSeg;
  3777. _DtCvSegment *asyncSegs;
  3778. _DtCvValue found;
  3779. while (NULL != rowIds && NULL != *rowIds)
  3780. {
  3781. /*
  3782. * get the start of the row ids
  3783. */
  3784. next = *rowIds;
  3785. colJ = _DtCvColJustifyOfTableSeg(table_seg);
  3786. while (NULL != next && '\0' != *next)
  3787. {
  3788. /*
  3789. * skip leading spaces
  3790. */
  3791. while (' ' == *next) next++;
  3792. /*
  3793. * set the starting pointer.
  3794. */
  3795. start = next;
  3796. /*
  3797. * skip to the next delimitter.
  3798. */
  3799. while (' ' != *next && '\0' != *next) next++;
  3800. /*
  3801. * check for the id in the set of segments.
  3802. */
  3803. if (start != next)
  3804. {
  3805. /*
  3806. * save and replace the last character with a null byte.
  3807. */
  3808. c = *next;
  3809. *next = '\0';
  3810. /*
  3811. * get the cells in the table
  3812. */
  3813. cellSegs = _DtCvCellsOfTableSeg(table_seg);
  3814. /*
  3815. * check that one of these cells matches the id
  3816. */
  3817. found = False;
  3818. if (NULL != cellSegs)
  3819. {
  3820. while (False == found && NULL != *cellSegs)
  3821. {
  3822. if (_DtCvStrCaseCmpLatin1(
  3823. _DtCvContainerIdOfSeg(*cellSegs),
  3824. start) == 0)
  3825. found = True;
  3826. else
  3827. cellSegs++;
  3828. }
  3829. newSeg = *cellSegs;
  3830. }
  3831. /*
  3832. * the id did not match any of the cells in the table
  3833. * Look in the async list.
  3834. */
  3835. if (False == found)
  3836. {
  3837. asyncSegs = my_struct->async_blks;
  3838. while (False == found && NULL != asyncSegs)
  3839. {
  3840. if (_DtCvStrCaseCmpLatin1(
  3841. _DtCvContainerIdOfSeg(asyncSegs),
  3842. start) == 0)
  3843. found = True;
  3844. else
  3845. asyncSegs = _DtCvNextSeg(asyncSegs);
  3846. }
  3847. /*
  3848. * found one in the aysnc blocks
  3849. * Duplicate it.
  3850. */
  3851. if (True == found)
  3852. {
  3853. _DtCvSegment *lastSrc = NULL;
  3854. _DtCvSegment *lastNext = NULL;
  3855. /*
  3856. * break the link to the next segment
  3857. * or we'll copy this segment and all
  3858. * the next segments.
  3859. */
  3860. _DtCvSegment *nextSeg = _DtCvNextSeg(asyncSegs);
  3861. _DtCvNextSeg(asyncSegs) = NULL;
  3862. /*
  3863. * allocate a new segment for this async block.
  3864. */
  3865. newSeg = DuplicateElement(
  3866. my_struct->ui_info->client_data,
  3867. my_struct->toss,
  3868. asyncSegs, &lastSrc, &lastNext,
  3869. my_struct->ui_info->load_font,
  3870. my_struct->ui_info->resolve_spc,
  3871. my_struct->ui_info->line_height / 2,
  3872. my_struct->ui_info->avg_char,
  3873. *(my_struct->my_fonts),
  3874. -1, False);
  3875. /*
  3876. * restore the async seg linked list
  3877. */
  3878. _DtCvNextSeg(asyncSegs) = nextSeg;
  3879. /*
  3880. * check to see if anything was copied
  3881. */
  3882. if (NULL == newSeg)
  3883. return -1;
  3884. /*
  3885. * now place this segment in the list.
  3886. */
  3887. _DtCvCellsOfTableSeg(table_seg) = (_DtCvSegment **)
  3888. _DtCvAddPtrToArray(
  3889. (void **) _DtCvCellsOfTableSeg(table_seg),
  3890. (void *) newSeg);
  3891. }
  3892. }
  3893. /*
  3894. * replace the character.
  3895. */
  3896. *next = c;
  3897. }
  3898. colJ++;
  3899. }
  3900. /*
  3901. * check the next row
  3902. */
  3903. rowIds++;
  3904. }
  3905. return 0;
  3906. }
  3907. /******************************************************************************
  3908. * Function: static int FindSnb(my_struct, id);
  3909. *
  3910. * Parameters:
  3911. *
  3912. * Returns: 0 if successful, -1 if errors
  3913. *
  3914. * Purpose:
  3915. *
  3916. ******************************************************************************/
  3917. static _DtCvSegment *
  3918. FindSnbEntry(
  3919. _DtCvSegment *snb,
  3920. char *target)
  3921. {
  3922. char *id;
  3923. _DtCvSegment *retEntry;
  3924. if (NULL != snb)
  3925. {
  3926. retEntry = _DtCvContainerListOfSeg(snb);
  3927. while (NULL != retEntry)
  3928. {
  3929. id = NULL;
  3930. if (_DtCvIsSegContainer(retEntry))
  3931. id = _DtCvContainerIdOfSeg(retEntry);
  3932. if (NULL != id && _DtCvStrCaseCmpLatin1(target, id) == 0)
  3933. return retEntry;
  3934. retEntry = _DtCvNextSeg(retEntry);
  3935. }
  3936. }
  3937. return NULL;
  3938. }
  3939. /* A little helper function, acts like strcpy
  3940. * but safe for overlapping regions.
  3941. */
  3942. static void *strmove(void *dest, const void *src) {
  3943. return memmove(dest, src, strlen(src) + 1);
  3944. }
  3945. /******************************************************************************
  3946. * Function: static int ProcessString(string, int idx);
  3947. *
  3948. * Parameters:
  3949. *
  3950. * Returns: 0 if successful, -1 if errors
  3951. *
  3952. * Purpose:
  3953. *
  3954. ******************************************************************************/
  3955. static int
  3956. ProcessString(
  3957. FormatStruct *my_struct,
  3958. _DtCvValue last_flag,
  3959. _DtCvValue nl_flag,
  3960. _DtCvValue mod_str,
  3961. _DtCvValue cpy_str,
  3962. _DtCvValue process_flag,
  3963. char *string,
  3964. int byte_len,
  3965. int *idx)
  3966. {
  3967. if (mod_str == True)
  3968. string[*idx] = '\0';
  3969. if (process_flag == True && MySaveString(&(my_struct->seg_list),
  3970. my_struct, string, my_struct->cur_link,
  3971. byte_len, nl_flag) != 0)
  3972. {
  3973. MyFree(string);
  3974. return -1;
  3975. }
  3976. my_struct->last_was_space = last_flag;
  3977. if (cpy_str == True)
  3978. {
  3979. strmove (string, &string[*idx+1]);
  3980. *idx = -1;
  3981. }
  3982. return 0;
  3983. }
  3984. /******************************************************************************
  3985. * Function: static void CompressLinkSeg(seg);
  3986. *
  3987. * Parameters:
  3988. *
  3989. * Returns: nothing
  3990. *
  3991. * Purpose: Check to see if there is a blank at the beginning of the
  3992. * segment and if it is needed.
  3993. *
  3994. ******************************************************************************/
  3995. static void
  3996. CompressLinkSeg(
  3997. _DtCvSegment *p_seg)
  3998. {
  3999. void *pChar;
  4000. int wcFlag;
  4001. /*
  4002. * check to see if the first segment is a string.
  4003. */
  4004. while (NULL != p_seg && _DtCvIsSegNoop(p_seg))
  4005. p_seg = _DtCvNextSeg(p_seg);
  4006. if (NULL == p_seg)
  4007. return;
  4008. if (_DtCvIsSegString(p_seg))
  4009. {
  4010. wcFlag = _DtCvIsSegWideChar(p_seg);
  4011. pChar = _DtCvStrPtr(_DtCvStringOfStringSeg(p_seg), wcFlag, 0);
  4012. /*
  4013. * is this the only segment in the link?
  4014. * Is it only one character in size?
  4015. */
  4016. if (NULL == _DtCvNextDisp(p_seg) && 1 <= _DtCvStrLen(pChar, wcFlag))
  4017. return;
  4018. /*
  4019. * is it a blank? (wide char and single char codes are equal
  4020. * for blanks - ISO standard)
  4021. */
  4022. if ((_DtCvIsSegWideChar(p_seg) && ' ' == *((wchar_t *) pChar)) ||
  4023. (_DtCvIsSegRegChar(p_seg) && ' ' == *((char *) pChar)))
  4024. {
  4025. /*
  4026. * compress out the blank
  4027. *
  4028. * is this a single byte string? If so, use strcpy to move
  4029. * the string.
  4030. */
  4031. if (_DtCvIsSegRegChar(p_seg))
  4032. strmove(((char *)pChar), &(((char *)pChar)[1]));
  4033. else
  4034. {
  4035. wchar_t *wcChar = (wchar_t *) pChar;
  4036. while (0 != wcChar[0])
  4037. {
  4038. wcChar[0] = wcChar[1];
  4039. wcChar++;
  4040. }
  4041. }
  4042. }
  4043. }
  4044. }
  4045. /******************************************************************************
  4046. * Function: static int ProcessNonBreakChar(string, int idx);
  4047. *
  4048. * Parameters:
  4049. *
  4050. * Returns: 0 if successful, -1 if errors
  4051. *
  4052. * Purpose:
  4053. *
  4054. ******************************************************************************/
  4055. static int
  4056. ProcessNonBreakChar(
  4057. FormatStruct *my_struct,
  4058. _DtCvValue process_flag,
  4059. char *break_str,
  4060. char *string,
  4061. int byte_len,
  4062. int *idx)
  4063. {
  4064. if (ProcessString(my_struct, False, False, True, False,
  4065. process_flag, string, byte_len, idx) != 0)
  4066. return -1;
  4067. my_struct->flags = _DtCvSetTypeToNonBreak(my_struct->flags);
  4068. if (ProcessString(my_struct, False, False, False, False,
  4069. process_flag, break_str, byte_len, idx) != 0)
  4070. return -1;
  4071. my_struct->flags = my_struct->flags & ~(_DtCvNON_BREAK);
  4072. strmove (string, &string[*idx+1]);
  4073. *idx = -1;
  4074. return 0;
  4075. }
  4076. /******************************************************************************
  4077. * Function: static int MoveString(string, int idx);
  4078. *
  4079. * Parameters:
  4080. *
  4081. * Returns: 0 if successful, -1 if errors
  4082. *
  4083. * Purpose:
  4084. *
  4085. ******************************************************************************/
  4086. static int
  4087. MoveString(
  4088. char **string,
  4089. int *max_len,
  4090. int *idx)
  4091. {
  4092. int i = *idx;
  4093. int myLen = *max_len;
  4094. char *src = *string;
  4095. i--;
  4096. if (i == -1)
  4097. {
  4098. if (strlen(src) == myLen)
  4099. {
  4100. src = (char *) realloc (src, myLen + 2);
  4101. if (src == NULL)
  4102. return -1;
  4103. myLen++;
  4104. *string = src;
  4105. *max_len = myLen;
  4106. }
  4107. for (i = myLen; i > 0; i--)
  4108. src[i] = src[i-1];
  4109. }
  4110. *idx = i;
  4111. return 0;
  4112. }
  4113. /******************************************************************************
  4114. * Function: int SetUp (_DtHelpVolumeHdl volume,
  4115. * CESDLVolume **sdl_vol,
  4116. * FormatStruct *frmt_struct,
  4117. * _DtCvSegment *toss,
  4118. * _DtCvSegment *cur_frmt,
  4119. * _DtCvValue lang
  4120. *
  4121. * Parameters:
  4122. * volume Specifies the volume handle. If non-NULL,
  4123. * create and return the sdl volume pointer
  4124. * in 'sdl_vol'.
  4125. * sdl_vol If not NULL, returns the sdl volume pointer.
  4126. * frmt_struct Specifies the formatting structure to use.
  4127. * toss Specifies the toss to use. If NULL and
  4128. * sdl_vol asked for and flag == True, the
  4129. * sdl_vol->toss will be used.
  4130. * lang Specifies if the language/charset should
  4131. * be set using information from the volume.
  4132. * flag Specifies if to get/use the sdl_vol->toss
  4133. * if toss is NULL.
  4134. *
  4135. * Returns: 0 if no failures, -1 if errors.
  4136. *
  4137. * Purpose: Set up the formatting structure to use.
  4138. *
  4139. *****************************************************************************/
  4140. static int
  4141. SetUp (
  4142. _DtHelpVolumeHdl volume,
  4143. CESDLVolume **sdl_vol,
  4144. FormatStruct *frmt_struct,
  4145. _DtCvSegment *toss,
  4146. const _FrmtUiInfo *ui_info,
  4147. int fd,
  4148. _DtCvValue lang,
  4149. _DtCvValue flag)
  4150. {
  4151. *frmt_struct = DefFormatStruct;
  4152. frmt_struct->my_links = _DtLinkDbCreate();
  4153. if (NULL == frmt_struct->my_links)
  4154. return -1;
  4155. if (volume != NULL && sdl_vol != NULL)
  4156. {
  4157. *sdl_vol = _DtHelpCeGetSdlVolumePtr(volume);
  4158. if (*sdl_vol == NULL)
  4159. {
  4160. _DtLinkDbDestroy(frmt_struct->my_links);
  4161. return -1;
  4162. }
  4163. }
  4164. /*
  4165. * malloc and initialize the starting font information
  4166. */
  4167. frmt_struct->my_fonts = AllocateFontInfo(frmt_struct);
  4168. if (NULL == frmt_struct->my_fonts)
  4169. {
  4170. _DtLinkDbDestroy(frmt_struct->my_links);
  4171. return -1;
  4172. }
  4173. if (volume != NULL)
  4174. {
  4175. frmt_struct->vol_name = _DtHelpCeGetVolumeName(volume);
  4176. if (toss == NULL && flag == True)
  4177. toss = _DtHelpCeGetSdlVolToss(volume, fd);
  4178. if (lang == True)
  4179. {
  4180. _DtHelpFontHintsLang(*(frmt_struct->my_fonts)) =
  4181. _DtHelpCeGetSdlVolLanguage(volume);
  4182. _DtHelpFontHintsCharSet(*(frmt_struct->my_fonts)) =
  4183. (char *) _DtHelpCeGetSdlVolCharSet(volume);
  4184. }
  4185. }
  4186. /*
  4187. * determine mb_len should be based on lang/charset.
  4188. */
  4189. frmt_struct->mb_len = MB_CUR_MAX;
  4190. frmt_struct->toss = toss;
  4191. frmt_struct->ui_info = ui_info;
  4192. return 0;
  4193. }
  4194. /******************************************************************************
  4195. * Function: void AddToAsyncList (_DtCvSegment *seg_list)
  4196. *
  4197. * Parameters:
  4198. *
  4199. * Returns Nothing
  4200. *
  4201. * Purpose: Add a segment block to the async list.
  4202. *
  4203. *****************************************************************************/
  4204. static void
  4205. AddToAsyncList (
  4206. FormatStruct *my_struct,
  4207. _DtCvSegment *block_seg)
  4208. {
  4209. if (my_struct->async_blks != NULL)
  4210. {
  4211. _DtCvSegment *pSeg = my_struct->async_blks;
  4212. while (_DtCvNextSeg(pSeg) != NULL)
  4213. pSeg = _DtCvNextSeg(pSeg);
  4214. _DtCvNextSeg(pSeg) = block_seg;
  4215. }
  4216. else
  4217. my_struct->async_blks = block_seg;
  4218. }
  4219. /******************************************************************************
  4220. * Function: int CheckOptionList (int attr_value_type, const char *attr,
  4221. * _DtCvValue check_flag,
  4222. * SdlOption cur_num,
  4223. * SdlOption *num);
  4224. *
  4225. * Parameters:
  4226. *
  4227. * Returns: 0 if successful, -1 if errors
  4228. *
  4229. * Purpose: If found, returns the enum value.
  4230. *
  4231. ******************************************************************************/
  4232. static int
  4233. CheckOptionList(
  4234. int attr_value_type,
  4235. const char *attr,
  4236. _DtCvValue check,
  4237. SdlOption cur_num,
  4238. SdlOption *num)
  4239. {
  4240. int i = 0;
  4241. int lowerChar;
  4242. int result = -1;
  4243. const OptionList *option;
  4244. _DtCvValue found = False;
  4245. _DtCvValue cmpFnd = False;
  4246. while (SDLOptionsList[i].attr_value != -1 &&
  4247. SDLOptionsList[i].attr_value != attr_value_type)
  4248. i++;
  4249. if (SDLOptionsList[i].attr_value != -1)
  4250. {
  4251. option = SDLOptionsList[i].options;
  4252. lowerChar = _DtHelpCeToLower(*attr);
  4253. while (option != NULL && option->string != NULL &&
  4254. (check == True || cmpFnd == False))
  4255. {
  4256. /*
  4257. * check to see if the current option is in the list
  4258. * of valid options for this attribute.
  4259. */
  4260. if (check && cur_num == option->option_value)
  4261. {
  4262. /*
  4263. * okay, it's been found, don't check anymore.
  4264. */
  4265. found = True;
  4266. check = False;
  4267. }
  4268. /*
  4269. * otherwise, find out if this value is a valid option
  4270. * for the attribute.
  4271. */
  4272. else if (cmpFnd == False &&
  4273. lowerChar == _DtHelpCeToLower(*(option->string)) &&
  4274. _DtCvStrCaseCmpLatin1(option->string, attr) == 0)
  4275. {
  4276. cmpFnd = True;
  4277. *num = option->option_value;
  4278. }
  4279. option++;
  4280. }
  4281. }
  4282. /*
  4283. * if found is true, means check was originally set to true and
  4284. * we found the current value in the option list for this attribute.
  4285. */
  4286. if (found == True)
  4287. *num = cur_num;
  4288. /*
  4289. * if we found that the current value was valid or that the string
  4290. * was a valid option in the list for the attribute, return no error.
  4291. */
  4292. if (found == True || cmpFnd == True)
  4293. result = 0;
  4294. return result;
  4295. }
  4296. /******************************************************************************
  4297. * Function: int CheckFontList (int attr_value_type, char *attr,
  4298. * enum CEFontSpec *num);
  4299. *
  4300. * Parameters:
  4301. *
  4302. * Returns: 0 if successful, -1 if errors
  4303. *
  4304. * Purpose: If found, returns the enum value.
  4305. *
  4306. ******************************************************************************/
  4307. static int
  4308. CheckFontList(
  4309. int attr_value_type,
  4310. char *attr,
  4311. _DtHelpFontValue *num)
  4312. {
  4313. int i = 0;
  4314. const FontSpecOption *option;
  4315. while (SDLFontList[i].attr_value != -1 &&
  4316. SDLFontList[i].attr_value != attr_value_type)
  4317. i++;
  4318. if (SDLFontList[i].attr_value != -1)
  4319. {
  4320. option = SDLFontList[i].options;
  4321. while (option != NULL && option->string != NULL)
  4322. {
  4323. if (_DtCvStrCaseCmpLatin1(option->string, attr) == 0)
  4324. {
  4325. *num = option->option_value;
  4326. return 0;
  4327. }
  4328. option++;
  4329. }
  4330. }
  4331. return -1;
  4332. }
  4333. /******************************************************************************
  4334. * Function: int LookAhead (FormatStruct my_struct, int token_value,
  4335. * int remove_flag);
  4336. *
  4337. * Parameters:
  4338. * my_struct Specifies the parsing structure.
  4339. * token_value Specifies the token to match
  4340. * remove_flag Specifies whether to clear the look ahead
  4341. * value. If True, will set the look ahead
  4342. * parsed value to invalid iff token_value
  4343. * equals the parsed look ahead value.
  4344. *
  4345. * Returns: 0 if token_value matched parsed value,
  4346. * 1 if parsed value is invalid.
  4347. * -1 if parsed value is valid but token_value did not match.
  4348. *
  4349. * Purpose:
  4350. *
  4351. ******************************************************************************/
  4352. static int
  4353. TestLookAhead(
  4354. FormatStruct *my_struct,
  4355. enum SdlElement token_value,
  4356. _DtCvValue end_flag,
  4357. int remove_flag)
  4358. {
  4359. if (my_struct->parsed == SdlElementNone)
  4360. return 1;
  4361. if (my_struct->parsed == token_value && my_struct->end_flag == end_flag)
  4362. {
  4363. if (remove_flag == True)
  4364. {
  4365. my_struct->parsed = SdlElementNone;
  4366. if (my_struct->remember != NULL)
  4367. {
  4368. free (my_struct->remember);
  4369. my_struct->remember = NULL;
  4370. }
  4371. }
  4372. return 0;
  4373. }
  4374. return -1;
  4375. }
  4376. /******************************************************************************
  4377. * Function: int MatchSDLElement (FormatStruct my_struct, sdl_string,
  4378. * int sdl_element, sig_chars)
  4379. *
  4380. * Parameters:
  4381. *
  4382. * Returns: 0 if successful, -1 if errors
  4383. *
  4384. * Purpose: Looks for the specific element.
  4385. *
  4386. ******************************************************************************/
  4387. static int
  4388. MatchSDLElement(
  4389. FormatStruct *my_struct,
  4390. const char *sdl_string,
  4391. enum SdlElement sdl_element,
  4392. int sig_chars,
  4393. _DtCvValue end_flag)
  4394. {
  4395. int i;
  4396. i = TestLookAhead(my_struct, sdl_element, end_flag, True);
  4397. if ( i != 1)
  4398. return i;
  4399. return (_DtHelpCeMatchSdlElement(my_struct->my_file,sdl_string,sig_chars));
  4400. }
  4401. /******************************************************************************
  4402. * Function: void SetAttributeFlag (
  4403. *
  4404. ******************************************************************************/
  4405. static void
  4406. SetAttributeFlag(
  4407. ElementInfoPtr cur_info,
  4408. unsigned long attr_define)
  4409. {
  4410. unsigned long flag = attr_define & ~(VALUE_MASK);
  4411. switch (attr_define & VALUE_MASK)
  4412. {
  4413. case ENUM_VALUE:
  4414. cur_info->enum_values |= flag;
  4415. break;
  4416. case STRING1_VALUE:
  4417. cur_info->str1_values |= flag;
  4418. break;
  4419. case STRING2_VALUE:
  4420. cur_info->str2_values |= flag;
  4421. break;
  4422. case NUMBER_VALUE:
  4423. cur_info->num_values |= flag;
  4424. break;
  4425. }
  4426. }
  4427. /******************************************************************************
  4428. * Function: void InitAttributes(SDLAttrStruct *as,
  4429. * SDLElementAttrList *attr_list)
  4430. *
  4431. * Parameters:
  4432. *
  4433. * Returns: Attribute Processed if successful, -1 if errors
  4434. *
  4435. * Purpose: Looks for the virtual page beginning.
  4436. *
  4437. ******************************************************************************/
  4438. static void
  4439. InitAttributes(
  4440. _DtCvSegment *p_seg,
  4441. _DtHelpFontHints *font_specs,
  4442. ElementInfo *element_info,
  4443. const SDLElementAttrList *attr_list)
  4444. {
  4445. char **strPtr1;
  4446. char *varOffset1 = NULL;
  4447. SDLNumber *numPtr1;
  4448. SdlOption *enumPtr1;
  4449. SdlOption defNum = _DtCvOPTION_BAD;
  4450. const SDLAttribute *pAttr;
  4451. while (attr_list->sdl_attr_define != -1)
  4452. {
  4453. if (attr_list->def_string != NULL ||
  4454. attr_list->sdl_value == SdlAttrValueImpliedDef)
  4455. {
  4456. pAttr = SDLAttributeList;
  4457. while (pAttr->data_type != SdlAttrDataTypeInvalid &&
  4458. !(ATTRS_EQUAL(pAttr->data_type,
  4459. pAttr->sdl_attr_define, attr_list->sdl_attr_define)))
  4460. pAttr++;
  4461. if (pAttr->struct_type != SdlIgnore &&
  4462. pAttr->data_type != SdlAttrDataTypeInvalid &&
  4463. SDLIsAttrSet(*element_info, pAttr->sdl_attr_define) == False)
  4464. {
  4465. /*
  4466. * determine which structure the information goes in
  4467. */
  4468. if (pAttr->struct_type == SdlFontSpecific)
  4469. varOffset1 = ((char *) font_specs);
  4470. else if (pAttr->struct_type == SdlContainerSpecific)
  4471. varOffset1 = ((char *)_SdlContainerPtrOfSeg(p_seg));
  4472. else if (pAttr->struct_type == SdlElementSpecific)
  4473. varOffset1 = ((char *) element_info);
  4474. else if (pAttr->struct_type == SdlTableSpecific)
  4475. varOffset1 = ((char *) element_info->w.table_info);
  4476. varOffset1 = varOffset1 + pAttr->field_ptr;
  4477. if (pAttr->data_type == SdlAttrDataTypeNumber)
  4478. {
  4479. numPtr1 = (SDLNumber *) varOffset1;
  4480. *numPtr1 = ((SDLNumber)atoi(attr_list->def_string));
  4481. }
  4482. else if (pAttr->data_type == SdlAttrDataTypeEnum)
  4483. {
  4484. enumPtr1 = (SdlOption *) varOffset1;
  4485. (void) CheckOptionList (attr_list->sdl_attr_define,
  4486. attr_list->def_string,
  4487. ((attr_list->sdl_attr_define & SDL_ATTR_CLASS) ? True : False),
  4488. ElInfoClan(element_info),
  4489. &defNum);
  4490. if ((attr_list->sdl_attr_define & SDL_ATTR_CLASS & ~(VALUE_MASK))
  4491. && ElInfoClan(element_info) != defNum)
  4492. SetAttributeFlag(element_info,
  4493. attr_list->sdl_attr_define);
  4494. *enumPtr1 = defNum;
  4495. }
  4496. else if (SDLIsString1(pAttr->sdl_attr_define)
  4497. ||
  4498. SDLIsString2(pAttr->sdl_attr_define))
  4499. {
  4500. strPtr1 = (char **) varOffset1;
  4501. *strPtr1 = (char *) attr_list->def_string;
  4502. }
  4503. }
  4504. }
  4505. attr_list++;
  4506. }
  4507. }
  4508. #ifdef DEBUG
  4509. static char *
  4510. ElToName(enum SdlElement el)
  4511. {
  4512. switch (el)
  4513. {
  4514. case SdlElementNone: return ("None");
  4515. case SdlElementComment: return ("Comment");
  4516. case SdlElementSdlDoc: return ("SdlDoc");
  4517. case SdlElementVStruct: return ("VStruct");
  4518. case SdlElementVirpage: return ("Virpage");
  4519. case SdlElementHead: return ("Head");
  4520. case SdlElementSubHead: return ("SubHead");
  4521. case SdlElementSnb: return ("Snb");
  4522. case SdlElementBlock: return ("Block");
  4523. case SdlElementForm: return ("Form");
  4524. case SdlElementPara: return ("Para");
  4525. case SdlElementCPara: return ("CPara");
  4526. case SdlElementFdata: return ("Fdata");
  4527. case SdlElementFstyle: return ("Fstyle");
  4528. case SdlElementFrowvec: return ("Frowvec");
  4529. case SdlElementKey: return ("Key");
  4530. case SdlElementCdata: return ("Cdata");
  4531. case SdlElementGraphic: return ("Graphic");
  4532. case SdlElementText: return ("Text");
  4533. case SdlElementAudio: return ("Audio");
  4534. case SdlElementVideo: return ("Video");
  4535. case SdlElementAnimate: return ("Animate");
  4536. case SdlElementCrossDoc: return ("CrossDoc");
  4537. case SdlElementManPage: return ("ManPage");
  4538. case SdlElementTextFile: return ("TextFile");
  4539. case SdlElementSysCmd: return ("SysCmd");
  4540. case SdlElementCallback: return ("Callback");
  4541. case SdlElementScript: return ("Script");
  4542. case SdlElementAnchor: return ("Anchor");
  4543. case SdlElementLink: return ("Link");
  4544. case SdlElementSwitch: return ("Switch");
  4545. case SdlElementSnRef: return ("SnRef");
  4546. case SdlElementRefItem: return ("RefItem");
  4547. case SdlElementAltText: return ("AltText");
  4548. case SdlElementSphrase: return ("Sphrase");
  4549. case SdlElementRev: return ("Rev");
  4550. case SdlElementSpc: return ("Spc");
  4551. case SdlElementIf: return ("If");
  4552. case SdlElementCond: return ("Cond");
  4553. case SdlElementThen: return ("Then");
  4554. case SdlElementElse: return ("Else");
  4555. case SdlElementDocument: return ("Document");
  4556. case SdlElementSgml: return ("Sgml");
  4557. case SdlElementDocType: return ("DocType");
  4558. case SdlElementLoids: return ("Loids");
  4559. case SdlElementToss: return ("Toss");
  4560. case SdlElementLoPhrases: return ("LoPhrases");
  4561. case SdlElementPhrase: return ("Phrase");
  4562. case SdlElementIndex: return ("Index");
  4563. case SdlElementEntry: return ("Entry");
  4564. case SdlElementRelDocs: return ("RelDocs");
  4565. case SdlElementRelFile: return ("RelFile");
  4566. case SdlElementNotes: return ("Notes");
  4567. case SdlElementKeyStyle: return ("KeyStyle");
  4568. case SdlElementHeadStyle: return ("HeadStyle");
  4569. case SdlElementFormStyle: return ("FormStyle");
  4570. case SdlElementFrmtStyle: return ("FrmtStyle");
  4571. case SdlElementGrphStyle: return ("GrphStyle");
  4572. case SdlElementId: return ("Id");
  4573. case SdlElementBlockAsync: return ("BlockAsync");
  4574. case SdlElementTitle: return ("Title");
  4575. case SdlPcDataFollows: return ("Follows");
  4576. }
  4577. return ("Unknown");
  4578. }
  4579. #endif /* DEBUG */
  4580. /******************************************************************************
  4581. * Function: int ProcessSDLAttribute(FormatStruct my_struct,
  4582. * SDLAttrStruct *cur_attr,
  4583. * SDLElementAttrList *attr_list,
  4584. * char *attr_name,
  4585. *
  4586. * Parameters:
  4587. *
  4588. * Returns: 0 if successful, -1 if errors
  4589. *
  4590. * Purpose: Looks for the virtual page beginning.
  4591. *
  4592. ******************************************************************************/
  4593. static int
  4594. ProcessSDLAttribute(
  4595. FormatStruct *my_struct,
  4596. _DtCvSegment *p_seg,
  4597. _DtHelpFontHints *font_specs,
  4598. ElementInfo *element_info,
  4599. const SDLElementAttrList *attr_list,
  4600. char *attr_name)
  4601. {
  4602. int result;
  4603. char *attrValue;
  4604. char **strPtr;
  4605. char numBuf[DTD_NAMELEN+1];
  4606. char *varOffset1 = NULL;
  4607. SDLNumber *numPtr1;
  4608. SdlOption *enumPtr1;
  4609. SdlOption attrNum;
  4610. _DtHelpFontValue fontNum = 0;
  4611. _DtHelpFontValue *fontPtr1;
  4612. const SDLAttribute *pAttr = SDLAttributeList;
  4613. /*
  4614. * find the attribute in the list of SDL attributes
  4615. * assumes that 'attr_name' has been lower cased, since all the
  4616. * attribute names in SDLAttributeList are already lower case.
  4617. */
  4618. while (pAttr->data_type != SdlAttrDataTypeInvalid &&
  4619. (*(pAttr->name) != *attr_name || strcmp(pAttr->name, attr_name)))
  4620. pAttr++;
  4621. if (pAttr->data_type != SdlAttrDataTypeInvalid)
  4622. {
  4623. /*
  4624. * Check to see if this element contains an attribute with
  4625. * the found value.
  4626. */
  4627. while (attr_list->sdl_attr_define != -1 &&
  4628. !ATTRS_EQUAL(pAttr->data_type, pAttr->sdl_attr_define,
  4629. attr_list->sdl_attr_define))
  4630. attr_list++;
  4631. if (attr_list->sdl_attr_define == -1)
  4632. return -1;
  4633. }
  4634. /*
  4635. * check it against the ones that are allowed for this element
  4636. */
  4637. if (pAttr->data_type != SdlAttrDataTypeInvalid)
  4638. {
  4639. switch (pAttr->data_type)
  4640. {
  4641. case SdlAttrDataTypeId:
  4642. result = _DtHelpCeGetSdlId(my_struct->my_file, &attrValue);
  4643. break;
  4644. case SdlAttrDataTypeNumber:
  4645. result = _DtHelpCeGetSdlNumber(my_struct->my_file, numBuf);
  4646. break;
  4647. case SdlAttrDataTypeCdata:
  4648. result = _DtHelpCeGetSdlAttributeCdata(my_struct->my_file,
  4649. False, &attrValue);
  4650. break;
  4651. case SdlAttrDataTypeFont:
  4652. result = _DtHelpCeGetSdlAttributeCdata(my_struct->my_file,
  4653. False, &attrValue);
  4654. if (result != -1)
  4655. result = CheckFontList (attr_list->sdl_attr_define,
  4656. attrValue, &fontNum);
  4657. break;
  4658. case SdlAttrDataTypeEnum:
  4659. result = _DtHelpCeGetSdlAttributeCdata(my_struct->my_file,
  4660. False, &attrValue);
  4661. if (result != -1)
  4662. result = CheckOptionList (attr_list->sdl_attr_define,
  4663. attrValue, False,
  4664. (SdlOption) _DtCvOPTION_BAD,
  4665. &attrNum);
  4666. break;
  4667. default:
  4668. printf ("hit unknown in processing attribute\n");
  4669. result = -1;
  4670. break;
  4671. }
  4672. if (result == 0)
  4673. {
  4674. if (pAttr->struct_type != SdlIgnore)
  4675. {
  4676. /*
  4677. * determine which structure the information goes in
  4678. */
  4679. if (pAttr->struct_type == SdlFontSpecific)
  4680. varOffset1 = ((char *) font_specs);
  4681. else if (pAttr->struct_type == SdlContainerSpecific)
  4682. varOffset1 = ((char *)_SdlContainerPtrOfSeg(p_seg));
  4683. else if (pAttr->struct_type == SdlElementSpecific)
  4684. varOffset1 = ((char *) element_info);
  4685. else if (pAttr->struct_type == SdlTableSpecific)
  4686. varOffset1 = ((char *) element_info->w.table_info);
  4687. varOffset1 = varOffset1 + pAttr->field_ptr;
  4688. if (pAttr->data_type == SdlAttrDataTypeNumber)
  4689. {
  4690. numPtr1 = (SDLNumber *) varOffset1;
  4691. *numPtr1 = ((SDLNumber) atoi(numBuf));
  4692. }
  4693. else if (pAttr->data_type == SdlAttrDataTypeEnum)
  4694. {
  4695. enumPtr1 = (SdlOption *) varOffset1;
  4696. *enumPtr1 = attrNum;
  4697. free(attrValue);
  4698. }
  4699. else if (pAttr->data_type == SdlAttrDataTypeFont)
  4700. {
  4701. fontPtr1 = (_DtHelpFontValue *) varOffset1;
  4702. *fontPtr1 = fontNum;
  4703. free(attrValue);
  4704. }
  4705. else
  4706. {
  4707. strPtr = (char **) varOffset1;
  4708. *strPtr = attrValue;
  4709. }
  4710. }
  4711. else if (SdlAttrDataTypeNumber != pAttr->data_type)
  4712. free(attrValue);
  4713. SetAttributeFlag(element_info, pAttr->sdl_attr_define);
  4714. }
  4715. return result;
  4716. }
  4717. return -1;
  4718. }
  4719. /******************************************************************************
  4720. * Function: int VerifyAttrList (
  4721. * SDLElementAttrList *attr_list)
  4722. *
  4723. * Parameters:
  4724. *
  4725. * Returns: Attribute Processed if successful, -1 if errors
  4726. *
  4727. * Purpose: Looks for the virtual page beginning.
  4728. *
  4729. ******************************************************************************/
  4730. static int
  4731. VerifyAttrList(
  4732. ElementInfoPtr el_info,
  4733. const SDLElementAttrList *attr_list)
  4734. {
  4735. long value = 0;
  4736. while (attr_list->sdl_attr_define != -1)
  4737. {
  4738. if (attr_list->sdl_value == SdlAttrValueRequired)
  4739. {
  4740. switch (attr_list->sdl_attr_define & VALUE_MASK)
  4741. {
  4742. case ENUM_VALUE:
  4743. /*
  4744. * mask off the minor number
  4745. */
  4746. value = el_info->enum_values & ~(MINOR_MASK);
  4747. break;
  4748. case STRING1_VALUE:
  4749. value = el_info->str1_values;
  4750. break;
  4751. case STRING2_VALUE:
  4752. value = el_info->str2_values;
  4753. break;
  4754. case NUMBER_VALUE:
  4755. value = el_info->num_values;
  4756. break;
  4757. }
  4758. if (!(attr_list->sdl_attr_define & value))
  4759. return -1;
  4760. }
  4761. attr_list++;
  4762. }
  4763. return 0;
  4764. }
  4765. /******************************************************************************
  4766. * Function: void MergeTossInfo (
  4767. * _DtCvSegment *cur_element,
  4768. * FormatStruct my_struct);
  4769. *
  4770. * Parameters:
  4771. *
  4772. * Returns: nothing
  4773. *
  4774. * Purpose: Looks for the virtual page beginning.
  4775. *
  4776. ******************************************************************************/
  4777. static void
  4778. MergeTossInfo(
  4779. FormatStruct *my_struct,
  4780. _DtCvSegment *cur_contain,
  4781. _DtHelpFontHints *font_specs)
  4782. {
  4783. _DtCvSegment *tossSeg;
  4784. if (my_struct->toss == NULL)
  4785. return;
  4786. tossSeg = _DtHelpCeMatchSemanticStyle (my_struct->toss,
  4787. ElClan(my_struct),
  4788. ElLevel(my_struct),
  4789. ElSsi(my_struct));
  4790. _DtHelpCeMergeSdlAttribInfo(tossSeg, cur_contain, font_specs,
  4791. &(my_struct->el_info),
  4792. &(my_struct->el_info.str1_values),
  4793. &(my_struct->el_info.str2_values));
  4794. return;
  4795. }
  4796. /*------------------------- Element Processing ------------------------------*/
  4797. /******************************************************************************
  4798. * Function: int ParseElementStart (
  4799. * FormatStruct my_struct,
  4800. * int element, _DtCvValue process_flag);
  4801. *
  4802. * Parameters:
  4803. *
  4804. * Returns: 0 if successful, -1 if errors
  4805. *
  4806. * Purpose: Looks for the virtual page beginning.
  4807. *
  4808. ******************************************************************************/
  4809. static int
  4810. ParseElementStart(
  4811. FormatStruct *my_struct,
  4812. SDLElementInfo element,
  4813. _DtCvValue process_flag)
  4814. {
  4815. _DtCvSegment *segPtr;
  4816. _DtCvSegment *newSeg;
  4817. FrmtPrivateInfo *priv;
  4818. if (MatchSDLElement (my_struct, element.element_str, element.sdl_element,
  4819. element.str_sig_chars, False) != 0)
  4820. return -1;
  4821. /*
  4822. * remember what we are currently parsing
  4823. */
  4824. ElType(my_struct) = element.sdl_element;
  4825. /*
  4826. * does this element possibly pull in different fonts?
  4827. * if so, allocate a new font structure.
  4828. */
  4829. if (True == process_flag && element.new_fonts)
  4830. {
  4831. my_struct->my_fonts = AllocateFontInfo(my_struct);
  4832. if (NULL == my_struct->my_fonts)
  4833. return -1;
  4834. }
  4835. /*
  4836. * if Cdata or skipping information don't do anything else
  4837. */
  4838. if (element.sdl_to_gen == SdlToNone || process_flag == False)
  4839. return 0;
  4840. /*
  4841. * allocate a segment for this element
  4842. */
  4843. if (_DtHelpCeAllocSegment(my_struct->malloc_size,
  4844. &(my_struct->alloc_size),
  4845. &(my_struct->block_list), &segPtr) != 0)
  4846. return -1;
  4847. /*
  4848. * add this segment to the list when done
  4849. */
  4850. my_struct->add_seg = segPtr;
  4851. /*
  4852. * Set the flags and initialize variables depending on the
  4853. * type of general segment this element becomes.
  4854. */
  4855. switch (element.sdl_to_gen)
  4856. {
  4857. case SdlToContainer:
  4858. /*
  4859. * set the container flag and initialize its formatting
  4860. * information to the default.
  4861. */
  4862. segPtr->type = _DtCvSetTypeToContainer(segPtr->type);
  4863. _DtCvContainerOfSeg(segPtr) = DefFrmtSpecs;
  4864. _DtCvContainerLeadingOfSeg(segPtr) =
  4865. my_struct->ui_info->leading;
  4866. /*
  4867. * if this is a formatting type container, do some more work.
  4868. */
  4869. if (element.formatting)
  4870. {
  4871. const _DtCvContainer *active = my_struct->active_frmt;
  4872. if (NULL == active) active = &DefFrmtSpecs;
  4873. /*
  4874. * The margin information - it gets zero'ed
  4875. */
  4876. _DtCvContainerLMarginOfSeg(segPtr) = 0;
  4877. _DtCvContainerRMarginOfSeg(segPtr) = 0;
  4878. _DtCvContainerFMarginOfSeg(segPtr) = 0;
  4879. _DtCvContainerTMarginOfSeg(segPtr) = 0;
  4880. _DtCvContainerBMarginOfSeg(segPtr) = 0;
  4881. /*
  4882. * inherit some of the formatting directives
  4883. */
  4884. _DtCvContainerVJustifyOfSeg(segPtr) =
  4885. ContainerPtrToVJustify(active);
  4886. _DtCvContainerJustifyOfSeg(segPtr) =
  4887. ContainerPtrToJustify(active);
  4888. /*
  4889. * break the connection with the previous data.
  4890. */
  4891. my_struct->prev_data = NULL;
  4892. _DtCvContainerListOfSeg(segPtr) = NULL;
  4893. /*
  4894. * check to see if these are controllers.
  4895. */
  4896. if (element.sdl_element == SdlElementHead ||
  4897. SdlElementSubHead == element.sdl_element)
  4898. segPtr->type = _DtCvSetTypeToController(segPtr->type);
  4899. /*
  4900. * make this the currently active formatting information
  4901. */
  4902. my_struct->active_frmt = &(_DtCvContainerOfSeg(segPtr));
  4903. }
  4904. break;
  4905. case SdlToMarker:
  4906. /*
  4907. * set the type; the attribute processing will set the id.
  4908. */
  4909. segPtr->type = _DtCvSetTypeToMarker(segPtr->type);
  4910. break;
  4911. case SdlToSnb:
  4912. /*
  4913. * set the type; the attribute processing will set the id.
  4914. * graphics only exist in a snb. You have to keep the
  4915. * id around until the graphic get resolved. So a graphic
  4916. * is a container with a region.
  4917. */
  4918. segPtr->type = _DtCvSetTypeToContainer(segPtr->type);
  4919. /*
  4920. * remember the refitem type.
  4921. */
  4922. priv = FrmtPrivInfoPtr(segPtr);
  4923. priv->sdl_el_type = ElType(my_struct);
  4924. break;
  4925. case SdlToSpc:
  4926. /*
  4927. * set the type; the attribute processing will set the id.
  4928. */
  4929. segPtr->type = _DtCvSetTypeToRegion(segPtr->type);
  4930. break;
  4931. }
  4932. if (my_struct->cur_link != -1)
  4933. {
  4934. segPtr->type = _DtCvSetTypeToHyperText(segPtr->type);
  4935. segPtr->link_idx = my_struct->cur_link;
  4936. }
  4937. switch (element.sdl_element)
  4938. {
  4939. case SdlElementSnb:
  4940. my_struct->resolve_font = _SdlFontModeNone;
  4941. my_struct->snb = segPtr;
  4942. my_struct->prev_data = NULL;
  4943. break;
  4944. case SdlElementAltText:
  4945. segPtr->type = _DtCvSetTypeToNonBreak(segPtr->type);
  4946. break;
  4947. case SdlElementForm:
  4948. /*
  4949. * allocate a table for all the information
  4950. */
  4951. if (_DtHelpCeAllocSegment(my_struct->malloc_size,
  4952. &(my_struct->alloc_size),
  4953. &(my_struct->block_list), &newSeg) != 0)
  4954. return -1;
  4955. newSeg->type = _DtCvSetTypeToTable(newSeg->type);
  4956. _DtCvJustifyCharsOfTableSeg(newSeg) = NULL;
  4957. /*
  4958. * set the my_struct pointer to this table so that
  4959. * as the fstyle and frowec elements are parsed, the
  4960. * data goes directly into this table.
  4961. */
  4962. ElTable(my_struct) = newSeg;
  4963. break;
  4964. }
  4965. return 0;
  4966. } /* End ParseElementStart */
  4967. /******************************************************************************
  4968. * Function: int ParseElementAttr (
  4969. * FormatStruct my_struct,
  4970. * SDLElementAttrList *attribs)
  4971. *
  4972. * Parameters:
  4973. *
  4974. * Returns: 0 if successful, -1 if errors
  4975. *
  4976. * Purpose: Looks for the virtual page attributes.
  4977. *
  4978. ******************************************************************************/
  4979. static int
  4980. ParseElementAttr(
  4981. FormatStruct *my_struct,
  4982. enum SdlElement cur_element,
  4983. const SDLElementAttrList *attribs,
  4984. _DtCvValue flag,
  4985. _DtCvValue process_flag)
  4986. {
  4987. int result = 0;
  4988. char attribName[MAX_ATTRIBUTE_LENGTH + 2];
  4989. _DtCvSegment *mySeg;
  4990. if (attribs == NULL || process_flag == False)
  4991. {
  4992. /*
  4993. * No attributes - is there cdata in here?
  4994. */
  4995. if (flag || attribs != NULL)
  4996. result = _DtHelpCeSkipCdata (my_struct->my_file,
  4997. (cur_element == SdlElementDocType ? True : False));
  4998. /*
  4999. * get the element's end.
  5000. */
  5001. if (result != -1)
  5002. result = _DtHelpCeGetSdlAttribute(my_struct->my_file,
  5003. MAX_ATTRIBUTE_LENGTH,
  5004. attribName);
  5005. /*
  5006. * _DtHelpCeGetSdlAttribute should return 1, meaning it found
  5007. * the >
  5008. */
  5009. if (result != 1)
  5010. return -1;
  5011. return 0;
  5012. }
  5013. /*
  5014. * clean and initialize the attributes for this element.
  5015. */
  5016. my_struct->el_info.enum_values = 0;
  5017. my_struct->el_info.num_values = 0;
  5018. my_struct->el_info.str1_values = 0;
  5019. my_struct->el_info.str2_values = 0;
  5020. mySeg = my_struct->add_seg;
  5021. InitAttributes(mySeg, my_struct->my_fonts, &(my_struct->el_info), attribs);
  5022. /*
  5023. * clear the colJ and colW
  5024. */
  5025. if (SdlElementForm == ElType(my_struct))
  5026. {
  5027. ElTableColJStr(my_struct) = NULL;
  5028. ElTableColWStr(my_struct) = NULL;
  5029. }
  5030. /*
  5031. * force the default of subheading orientation to heads as below the head.
  5032. */
  5033. if (ElType(my_struct) == SdlElementSubHead)
  5034. _DtCvContainerVOrientOfSeg(mySeg) = _DtCvJUSTIFY_BOTTOM;
  5035. do {
  5036. result = _DtHelpCeGetSdlAttribute(my_struct->my_file,
  5037. MAX_ATTRIBUTE_LENGTH,
  5038. attribName);
  5039. if (result == 0)
  5040. result = ProcessSDLAttribute(my_struct, mySeg,
  5041. my_struct->my_fonts,
  5042. &(my_struct->el_info),
  5043. attribs,
  5044. attribName);
  5045. } while (result == 0);
  5046. if (result != -1)
  5047. result = VerifyAttrList(&(my_struct->el_info), attribs);
  5048. if (result != -1)
  5049. {
  5050. if (cur_element == SdlElementVirpage
  5051. ||
  5052. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CLASS)
  5053. ||
  5054. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_SSI)
  5055. ||
  5056. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LEVEL))
  5057. MergeTossInfo(my_struct, mySeg, my_struct->my_fonts);
  5058. if (SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_LANGUAGE)
  5059. || SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_CHARSET))
  5060. my_struct->mb_len = MB_CUR_MAX;
  5061. /*
  5062. * Do some specific work for containers.
  5063. */
  5064. if (NULL != mySeg && _DtCvIsSegContainer(mySeg))
  5065. {
  5066. /*
  5067. * transfer any id or rid that got specified
  5068. */
  5069. if (SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_ID) ||
  5070. SDLIsStrAttrSet(my_struct->el_info, SDL_ATTR_RID))
  5071. {
  5072. _DtCvContainerIdOfSeg(mySeg) = ElId(my_struct);
  5073. ClearAttrFlag(my_struct->el_info, SDL_ATTR_ID);
  5074. ClearAttrFlag(my_struct->el_info, SDL_ATTR_RID);
  5075. }
  5076. /*
  5077. * set the margins to absolute values
  5078. */
  5079. if (my_struct->ui_info->avg_char > 0)
  5080. {
  5081. _DtCvContainerLMarginOfSeg(mySeg) =
  5082. _DtCvContainerLMarginOfSeg(mySeg) *
  5083. my_struct->ui_info->avg_char;
  5084. _DtCvContainerRMarginOfSeg(mySeg) =
  5085. _DtCvContainerRMarginOfSeg(mySeg) *
  5086. my_struct->ui_info->avg_char;
  5087. _DtCvContainerFMarginOfSeg(mySeg) =
  5088. _DtCvContainerFMarginOfSeg(mySeg) *
  5089. my_struct->ui_info->avg_char;
  5090. }
  5091. /*
  5092. * set the container spacing to absolute values
  5093. */
  5094. if (my_struct->ui_info->line_height / 2 > 0)
  5095. {
  5096. /*
  5097. * TODO .... take maximum! of spacing.
  5098. */
  5099. TMarginOfSeg(mySeg) = TMarginOfSeg(mySeg) *
  5100. (my_struct->ui_info->line_height / 2);
  5101. BMarginOfSeg(mySeg) = BMarginOfSeg(mySeg) *
  5102. (my_struct->ui_info->line_height / 2);
  5103. }
  5104. /*
  5105. * set the border width information
  5106. */
  5107. if (_DtCvBORDER_NONE != _DtCvContainerBorderOfSeg(mySeg))
  5108. _DtCvContainerLineWidthOfSeg(mySeg) =
  5109. my_struct->ui_info->line_width;
  5110. }
  5111. }
  5112. if (result == 1)
  5113. result = 0;
  5114. return result;
  5115. } /* End ParseElementAttr */
  5116. /******************************************************************************
  5117. * Function: int ParseElementEnd (
  5118. * FormatStruct my_struct,
  5119. * int el_type);
  5120. *
  5121. * Parameters:
  5122. *
  5123. * Returns: 0 if successful, -1 if errors
  5124. *
  5125. * Purpose: Looks for the virtual page beginning.
  5126. *
  5127. ******************************************************************************/
  5128. static int
  5129. ParseElementEnd(
  5130. FormatStruct *my_struct,
  5131. _DtCvSegment *if_prev,
  5132. SDLElementInfo element,
  5133. _DtCvValue process_flag,
  5134. _DtCvValue end_flag)
  5135. {
  5136. char *id;
  5137. _DtCvSegment *newSeg;
  5138. _DtCvSegment *segList;
  5139. if (MatchSDLElement (my_struct, element.element_end_str,
  5140. element.sdl_element, element.end_sig_chars, True) != 0 ||
  5141. (end_flag == False &&
  5142. _DtHelpCeFindSkipSdlElementEnd(my_struct->my_file) != 0))
  5143. return -1;
  5144. if (process_flag == True)
  5145. {
  5146. _DtCvSegment *pElement = my_struct->add_seg;
  5147. /*
  5148. * if we aren't resolving the fonts for this element,
  5149. * we need to save the toss information for later
  5150. * when the element gets used in a table or snref.
  5151. */
  5152. if (_SdlFontModeResolve != my_struct->resolve_font &&
  5153. (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CLASS)
  5154. ||
  5155. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_SSI)
  5156. ||
  5157. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LEVEL)))
  5158. {
  5159. SdlMatchData *match;
  5160. /*
  5161. * was a segment allocated for this element?
  5162. * if not, we'll have to put our own special segment
  5163. * around the segment list so the correct font inheritance
  5164. * occurs. Later, this special segment will have to be
  5165. * stripped out when the async blocks or snref item
  5166. * is resolved.
  5167. */
  5168. if (NULL == pElement)
  5169. {
  5170. if (_DtHelpCeAllocSegment(1, NULL, NULL, &pElement) != 0)
  5171. return -1;
  5172. pElement->type = _DtCvSetTypeToContainer(pElement->type);
  5173. pElement->type = SetSdlWrapper(pElement->type);
  5174. _DtCvContainerListOfSeg(pElement) = my_struct->seg_list;
  5175. my_struct->seg_list = pElement;
  5176. }
  5177. /*
  5178. * has match data already been allocated for this element?
  5179. */
  5180. match = SegMatchDataPtr(pElement);
  5181. if (NULL == match)
  5182. {
  5183. match = (SdlMatchData *) malloc(sizeof(SdlMatchData));
  5184. if (NULL == match)
  5185. return -1;
  5186. }
  5187. /*
  5188. * save the clan, level and ssi of this element.
  5189. */
  5190. *match = my_struct->el_info.match;
  5191. SegMatchData(pElement) = (void *) match;
  5192. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SSI);
  5193. }
  5194. /*
  5195. * attach the current segment list to the container's list
  5196. */
  5197. if (NULL != pElement && _DtCvIsSegContainer(pElement))
  5198. _DtCvContainerListOfSeg(pElement) = my_struct->seg_list;
  5199. /*
  5200. * check to see if the element has any data.
  5201. * If not, can it (the element) be eleminated and free up memory?
  5202. */
  5203. if (NULL != pElement && my_struct->seg_list == NULL
  5204. && element.elim_flag == True
  5205. && ElType(my_struct) != SdlElementKey
  5206. && TMarginOfSeg(pElement) == 0 && BMarginOfSeg(pElement) == 0)
  5207. {
  5208. _DtHelpFreeSegments(my_struct->add_seg, _DtCvFALSE,
  5209. my_struct->ui_info->destroy_region,
  5210. my_struct->ui_info->client_data);
  5211. if (ElType(my_struct) == SdlElementLink)
  5212. _DtLinkDbRemoveLink(my_struct->my_links,
  5213. my_struct->cur_link);
  5214. my_struct->add_seg = NULL;
  5215. }
  5216. else
  5217. {
  5218. switch(ElType(my_struct))
  5219. {
  5220. case SdlElementSnb:
  5221. my_struct->add_seg = NULL;
  5222. break;
  5223. case SdlElementBlock:
  5224. if (ElTiming(my_struct) == SdlTimingAsync)
  5225. {
  5226. if (NULL != my_struct->add_seg)
  5227. AddToAsyncList(my_struct, my_struct->add_seg);
  5228. my_struct->add_seg = NULL;
  5229. }
  5230. break;
  5231. case SdlElementHead:
  5232. case SdlElementSubHead:
  5233. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_ABBREV)
  5234. && ElAbbrev(my_struct) != NULL
  5235. && strlen(ElAbbrev(my_struct)))
  5236. {
  5237. AbbrevOfSeg(my_struct->add_seg) =
  5238. (void *) ElAbbrev(my_struct);
  5239. ClearAttrFlag(my_struct->el_info, SDL_ATTR_ABBREV);
  5240. }
  5241. break;
  5242. case SdlElementFdata:
  5243. ElTableList(my_struct) = ConvertToList(my_struct->seg_list);
  5244. break;
  5245. case SdlElementLink:
  5246. CompressLinkSeg(my_struct->seg_list);
  5247. case SdlElementKey:
  5248. case SdlElementSphrase:
  5249. /*
  5250. * move the content of the element up.
  5251. */
  5252. my_struct->add_seg = my_struct->seg_list;
  5253. /*
  5254. * free the no longer needed segments.
  5255. */
  5256. if (NULL != pElement)
  5257. {
  5258. _DtCvContainerListOfSeg(pElement) = NULL;
  5259. _DtHelpFreeSegments(pElement, _DtCvFALSE,
  5260. my_struct->ui_info->destroy_region,
  5261. my_struct->ui_info->client_data);
  5262. }
  5263. break;
  5264. case SdlElementForm:
  5265. /*
  5266. * get the segment list.
  5267. */
  5268. newSeg = ElTable(my_struct);
  5269. /*
  5270. * include any async blocks into the table list.
  5271. */
  5272. if (ResolveAsyncBlock(my_struct, newSeg) != 0)
  5273. return -1;
  5274. /*
  5275. * compress the table if possible down to just
  5276. * a container.
  5277. */
  5278. newSeg = CompressTable(my_struct, newSeg);
  5279. /*
  5280. * add the table segment to the form's container list
  5281. * taking into account any heads for the form.
  5282. */
  5283. _DtCvNextSeg(newSeg) = _DtCvContainerListOfSeg(pElement);
  5284. _DtCvContainerListOfSeg(pElement) = newSeg;
  5285. break;
  5286. case SdlElementIf:
  5287. if (ResolveIf (my_struct, if_prev))
  5288. return -1;
  5289. break;
  5290. case SdlElementSnRef:
  5291. /*
  5292. * get the id of snref
  5293. */
  5294. id = NULL;
  5295. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_ID))
  5296. id = _DtCvContainerIdOfSeg(pElement);
  5297. /*
  5298. * Resolve the snref to one of its items
  5299. */
  5300. newSeg = ResolveSnref(my_struct, pElement, id);
  5301. /*
  5302. * if the snref got resolved, process
  5303. * otherwise, let it pass through. We'll try to
  5304. * resolve it later.
  5305. */
  5306. if (newSeg != pElement)
  5307. {
  5308. /*
  5309. * remember the segment list that we want
  5310. * to free. This includes the snref.
  5311. */
  5312. segList = pElement;
  5313. /*
  5314. * if this <snref> had an id with it, then
  5315. * expand the <snref> to a marker segment
  5316. * (with the id) and a resolved refitem.
  5317. *
  5318. * Otherwise, eliminate the container.
  5319. */
  5320. if (NULL != id)
  5321. {
  5322. /*
  5323. * remember the segment list of the container.
  5324. * Since we are re-using the snref segment,
  5325. * we want to eliminate just the refitems of
  5326. * the snref and not the actual snref.
  5327. */
  5328. segList = _DtCvContainerListOfSeg(pElement);
  5329. /*
  5330. * Move the refitem to be a sibling of the
  5331. * container.
  5332. */
  5333. _DtCvNextSeg(pElement) = newSeg;
  5334. /*
  5335. * transfer the container id to a marker id
  5336. * and change the container into a marker.
  5337. */
  5338. _DtCvIdOfMarkerSeg(pElement) =
  5339. _DtCvContainerIdOfSeg(pElement);
  5340. pElement->type =
  5341. _DtCvSetTypeToMarker(pElement->type);
  5342. newSeg = pElement;
  5343. }
  5344. /*
  5345. * free the no longer needed segments.
  5346. */
  5347. _DtHelpFreeSegments(segList, _DtCvFALSE,
  5348. my_struct->ui_info->destroy_region,
  5349. my_struct->ui_info->client_data);
  5350. }
  5351. my_struct->add_seg = newSeg;
  5352. break;
  5353. }
  5354. }
  5355. /*
  5356. * free the attributes for this element
  5357. */
  5358. FreeAttributes(ElType(my_struct),
  5359. &(my_struct->el_info), my_struct->my_fonts);
  5360. /*
  5361. * if this element can pull in new fonts, then a new font
  5362. * structure was allocated for this element. Since we are
  5363. * leaving the element, place the font structure in the
  5364. * free list for possible reuse.
  5365. */
  5366. if (element.new_fonts && FreeFontInfo(my_struct) == -1)
  5367. return -1;
  5368. }
  5369. else
  5370. my_struct->add_seg = my_struct->seg_list;
  5371. if (element.formatting == True)
  5372. my_struct->prev_data = NULL;
  5373. return 0;
  5374. } /* End ParseElementEnd */
  5375. /******************************************************************************
  5376. *
  5377. * SDL Element Content Functions
  5378. *
  5379. *****************************************************************************/
  5380. /******************************************************************************
  5381. * Function: int FindAndFix (
  5382. * _DtCvSegment *toss,
  5383. * _DtCvSegment *snb,
  5384. * _DtCvSegment *seg_list)
  5385. *
  5386. * Parameters:
  5387. *
  5388. * Returns: 0 if successful, -1 if errors
  5389. *
  5390. * Purpose:
  5391. *
  5392. ******************************************************************************/
  5393. static int
  5394. FindAndFix(
  5395. FormatStruct *my_struct)
  5396. {
  5397. int curLink = my_struct->cur_link;
  5398. _DtCvSegment *newSeg;
  5399. _DtCvSegment *prevData = my_struct->prev_data;
  5400. _DtCvSegment *lastSeg = my_struct->last_seg;
  5401. _DtCvSegment *tmpSeg;
  5402. _DtHelpFontHints *oldFonts = my_struct->my_fonts;
  5403. /*
  5404. * If the head has an snref in it, get the snb and resolve them
  5405. */
  5406. if (0 < my_struct->snref_cnt)
  5407. {
  5408. UnresSnref *snref = my_struct->un_snrefs;
  5409. while (my_struct->snref_cnt)
  5410. {
  5411. /*
  5412. * reset the structure to what it was at the time
  5413. * this snref was encountered.
  5414. */
  5415. my_struct->prev_data = NULL;
  5416. my_struct->last_seg = NULL;
  5417. my_struct->my_fonts = &(snref->fonts);
  5418. my_struct->cur_link = snref->cur_link;
  5419. /*
  5420. * resolve it.
  5421. */
  5422. newSeg = ResolveSnref(my_struct, snref->seg, NULL);
  5423. /*
  5424. * free the snref items
  5425. */
  5426. _DtHelpFreeSegments(_DtCvContainerListOfSeg(snref->seg), _DtCvFALSE,
  5427. my_struct->ui_info->destroy_region,
  5428. my_struct->ui_info->client_data);
  5429. /*
  5430. * find the end of the new segment's and have it point to
  5431. * the next segments that the old segment points to.
  5432. */
  5433. if (NULL != newSeg)
  5434. {
  5435. tmpSeg = newSeg;
  5436. while (NULL != _DtCvNextSeg(tmpSeg))
  5437. tmpSeg = _DtCvNextSeg(tmpSeg);
  5438. _DtCvNextSeg(tmpSeg) = _DtCvNextSeg(snref->seg);
  5439. _DtCvNextDisp(tmpSeg) = _DtCvNextDisp(snref->seg);
  5440. }
  5441. /*
  5442. * does the snref have an id?
  5443. */
  5444. if (NULL != snref->id)
  5445. {
  5446. /*
  5447. * re-use the old snref, turning it into a marker
  5448. */
  5449. _DtCvIdOfMarkerSeg(snref->seg) = snref->id;
  5450. snref->seg->type = _DtCvSetTypeToMarker(snref->seg->type);
  5451. /*
  5452. * set the next pointers on the old segment to
  5453. * the new segment.
  5454. */
  5455. if (NULL != newSeg)
  5456. {
  5457. _DtCvNextSeg(snref->seg) = newSeg;
  5458. _DtCvNextDisp(snref->seg) = newSeg;
  5459. }
  5460. }
  5461. /*
  5462. * else move the resolved segment on top of the old snref.
  5463. */
  5464. else if (NULL != newSeg)
  5465. {
  5466. /*
  5467. * free the private information. No longer needed.
  5468. */
  5469. free(snref->seg->client_use);
  5470. /*
  5471. * now trounce the snref segment info.
  5472. */
  5473. *(snref->seg) = *newSeg;
  5474. /*
  5475. * free the duplicate new segment.
  5476. */
  5477. if (_DtCvIsSegContainer(newSeg))
  5478. _DtCvContainerListOfSeg(newSeg) = NULL;
  5479. free(newSeg);
  5480. }
  5481. /*
  5482. * else there was no resolution, leave this segment as a NOOP.
  5483. */
  5484. /*
  5485. * go to the next unresolved snref
  5486. */
  5487. snref++;
  5488. my_struct->snref_cnt--;
  5489. }
  5490. free(my_struct->un_snrefs);
  5491. my_struct->un_snrefs = NULL;
  5492. }
  5493. my_struct->cur_link = curLink;
  5494. my_struct->prev_data = prevData;
  5495. my_struct->last_seg = lastSeg;
  5496. my_struct->my_fonts = oldFonts;
  5497. return 0;
  5498. }
  5499. /******************************************************************************
  5500. * Function: char *GetInterpCmd (SdlOption interp_type);
  5501. *
  5502. * Parameters:
  5503. *
  5504. * Returns: 0 if successful, -1 if errors
  5505. *
  5506. * Purpose: Return the command associated with the interpreter type.
  5507. *
  5508. ******************************************************************************/
  5509. static char *
  5510. GetInterpCmd(SdlOption interp_type)
  5511. {
  5512. const _CEInterpData *interp = InterpData;
  5513. while (interp->type != _DtCvOPTION_BAD)
  5514. {
  5515. if (interp->type == interp_type)
  5516. return interp->cmd;
  5517. interp++;
  5518. }
  5519. return NULL;
  5520. }
  5521. /******************************************************************************
  5522. * Function: int CheckForSnb (
  5523. * FormatStruct my_struct,
  5524. * int element_types,
  5525. * int exceptions);
  5526. *
  5527. * Parameters:
  5528. *
  5529. * Returns: 0 if successful, -1 if errors
  5530. *
  5531. * Purpose: Looks for the virtual page attributes.
  5532. *
  5533. ******************************************************************************/
  5534. static int
  5535. CheckForSnb(
  5536. FormatStruct *my_struct,
  5537. SDLMask *element_types,
  5538. enum SdlElement sig_element,
  5539. SDLMask *exceptions,
  5540. SDLMask *process_mask)
  5541. {
  5542. int result = 0;
  5543. /*
  5544. * If the head has an snref in it, get the snb and resolve them
  5545. */
  5546. if (my_struct->snref_used == True)
  5547. {
  5548. _DtCvSegment *oldSegList = my_struct->seg_list;
  5549. _DtCvSegment *oldAddSeg = my_struct->add_seg;
  5550. _DtCvSegment *oldPrevSeg = my_struct->prev_data;
  5551. _DtCvSegment *oldLastSeg = my_struct->last_seg;
  5552. my_struct->seg_list = NULL;
  5553. my_struct->add_seg = NULL;
  5554. my_struct->prev_data = NULL;
  5555. my_struct->last_seg = NULL;
  5556. result = ProcessSDLMarkup(my_struct, SdlElementSnb, SdlElementNone,
  5557. exceptions, process_mask);
  5558. my_struct->seg_list = oldSegList;
  5559. my_struct->add_seg = oldAddSeg;
  5560. my_struct->prev_data = oldPrevSeg;
  5561. my_struct->last_seg = oldLastSeg;
  5562. /*
  5563. * if no problems getting the snb, go through the items and
  5564. * resolve the snrefs.
  5565. */
  5566. if (result != -1)
  5567. result = FindAndFix(my_struct);
  5568. }
  5569. return result;
  5570. } /* End CheckForSnb */
  5571. /******************************************************************************
  5572. * Function: int SetSaveSnref (
  5573. * FormatStruct my_struct,
  5574. * int element_types,
  5575. * int exceptions);
  5576. *
  5577. * Parameters:
  5578. *
  5579. * Returns: 0 if successful, -1 if errors
  5580. *
  5581. * Purpose: Looks for the virtual page attributes.
  5582. *
  5583. ******************************************************************************/
  5584. static int
  5585. SetSaveSnref(
  5586. FormatStruct *my_struct,
  5587. SDLMask *element_types,
  5588. enum SdlElement sig_element,
  5589. SDLMask *exceptions,
  5590. SDLMask *process_mask)
  5591. {
  5592. my_struct->save_snref = _DtCvTRUE;
  5593. return 0;
  5594. } /* End SetSaveSnref */
  5595. /******************************************************************************
  5596. * Function: int ClearAndCheckSnref (
  5597. * FormatStruct my_struct,
  5598. * int element_types,
  5599. * int exceptions);
  5600. *
  5601. * Parameters:
  5602. *
  5603. * Returns: 0 if successful, -1 if errors
  5604. *
  5605. * Purpose: Looks for the virtual page attributes.
  5606. *
  5607. ******************************************************************************/
  5608. static int
  5609. ClearAndCheckSnref(
  5610. FormatStruct *my_struct,
  5611. SDLMask *element_types,
  5612. enum SdlElement sig_element,
  5613. SDLMask *exceptions,
  5614. SDLMask *process_mask)
  5615. {
  5616. int result = 0;
  5617. /*
  5618. * reset the flag for saving snref elements
  5619. */
  5620. my_struct->save_snref = _DtCvFALSE;
  5621. /*
  5622. * was any snrefs found? If so, resolve them now.
  5623. */
  5624. if (my_struct->snref_used == True)
  5625. result = FindAndFix(my_struct);
  5626. return result;
  5627. } /* End ClearAndCheckSnref */
  5628. /******************************************************************************
  5629. * Function: int CheckType (
  5630. * FormatStruct my_struct,
  5631. * int element_types,
  5632. * int exceptions);
  5633. *
  5634. * Parameters:
  5635. *
  5636. * Returns: 0 if successful, -1 if errors
  5637. *
  5638. * Purpose: Looks for the virtual page attributes.
  5639. *
  5640. ******************************************************************************/
  5641. static int
  5642. CheckType(
  5643. FormatStruct *my_struct,
  5644. SDLMask *element_types,
  5645. enum SdlElement sig_element,
  5646. SDLMask *exceptions,
  5647. SDLMask *process_mask)
  5648. {
  5649. SdlOption newOpt;
  5650. /*
  5651. * cannot honor newlines in super or sub scripts.
  5652. */
  5653. newOpt = ElFrmtType(my_struct);
  5654. if (SdlTypeLiteral == newOpt)
  5655. newOpt = SdlTypeUnlinedLiteral;
  5656. else if (SdlTypeLined == newOpt)
  5657. newOpt = SdlTypeDynamic;
  5658. ElFrmtType(my_struct) = newOpt;
  5659. if (SdlTypeDynamic != newOpt)
  5660. my_struct->flags = _DtCvSetTypeToNonBreak(my_struct->flags);
  5661. if (SdlClassSub == ElClan(my_struct))
  5662. my_struct->flags = _DtCvSetTypeToSubScript(my_struct->flags);
  5663. else if (SdlClassSuper == ElClan(my_struct))
  5664. my_struct->flags = _DtCvSetTypeToSuperScript(my_struct->flags);
  5665. /*
  5666. * strip hypertext links
  5667. */
  5668. my_struct->cur_link = -1;
  5669. return 0;
  5670. } /* End CheckType */
  5671. /******************************************************************************
  5672. * Function: int SetType (
  5673. * FormatStruct my_struct,
  5674. * int element_types,
  5675. * int exceptions);
  5676. *
  5677. * Parameters:
  5678. *
  5679. * Returns: 0 if successful, -1 if errors
  5680. *
  5681. * Purpose: Looks for the virtual page attributes.
  5682. *
  5683. ******************************************************************************/
  5684. static int
  5685. SetType(
  5686. FormatStruct *my_struct,
  5687. SDLMask *element_types,
  5688. enum SdlElement sig_element,
  5689. SDLMask *exceptions,
  5690. SDLMask *process_mask)
  5691. {
  5692. if (ElType(my_struct) == SdlElementSphrase)
  5693. {
  5694. ContainerPtrToType(my_struct->active_frmt) =
  5695. (_DtCvFrmtOption) SdlTypeLiteral;
  5696. ElFrmtType(my_struct) = SdlTypeLiteral;
  5697. my_struct->flags = 0;
  5698. }
  5699. else
  5700. ElFrmtType(my_struct) = SdlTypeCdata;
  5701. if (SdlElementScript == ElType(my_struct))
  5702. {
  5703. /*
  5704. * remember the interpretor value
  5705. */
  5706. FrmtPrivateInfo *priv = FrmtPrivInfoPtr(my_struct->add_seg);
  5707. priv->interp = ElInterp(my_struct);
  5708. }
  5709. return 0;
  5710. } /* End SetType */
  5711. /******************************************************************************
  5712. * Function: int ElseInfo (
  5713. * FormatStruct my_struct,
  5714. * int element_types,
  5715. * int exceptions);
  5716. *
  5717. * Parameters:
  5718. *
  5719. * Returns: 0 if successful, -1 if errors
  5720. *
  5721. * Purpose: Looks for the virtual page attributes.
  5722. *
  5723. ******************************************************************************/
  5724. static int
  5725. IfInfo(
  5726. FormatStruct *my_struct,
  5727. SDLMask *element_types,
  5728. enum SdlElement sig_element,
  5729. SDLMask *exceptions,
  5730. SDLMask *process_mask)
  5731. {
  5732. if (ElType(my_struct) == SdlElementIf)
  5733. {
  5734. my_struct->then_prev = NULL;
  5735. my_struct->else_prev = NULL;
  5736. }
  5737. else if (ElType(my_struct) == SdlElementThen)
  5738. my_struct->then_prev = my_struct->prev_data;
  5739. else /* if (ElType(my_struct) == SdlElementElse) */
  5740. my_struct->else_prev = my_struct->prev_data;
  5741. return 0;
  5742. } /* End IfInfo */
  5743. /******************************************************************************
  5744. * Function: int MarkFound (
  5745. * FormatStruct my_struct,
  5746. * int element_types,
  5747. * int exceptions);
  5748. *
  5749. * Parameters:
  5750. *
  5751. * Returns: 0 if successful, -1 if errors
  5752. *
  5753. * Purpose: Looks for the virtual page attributes.
  5754. *
  5755. ******************************************************************************/
  5756. static int
  5757. MarkFound(
  5758. FormatStruct *my_struct,
  5759. SDLMask *element_types,
  5760. enum SdlElement sig_element,
  5761. SDLMask *exceptions,
  5762. SDLMask *process_mask)
  5763. {
  5764. my_struct->snref_used = True;
  5765. /*
  5766. * is there a newline hanging around that needs turning into a space?
  5767. */
  5768. if (SDLSearchMask(process_mask, SdlElementCdata)
  5769. && my_struct->last_was_space == False && my_struct->last_was_nl == True)
  5770. {
  5771. _DtCvSegment *pSeg = my_struct->prev_data;
  5772. /*
  5773. * tack the space onto the end of previous string if possible.
  5774. */
  5775. if (pSeg != NULL && _DtCvIsSegString(pSeg) &&
  5776. _DtCvIsSegRegChar(pSeg) && !(_DtCvIsSegNewLine(pSeg)))
  5777. {
  5778. char *strPtr;
  5779. int len = _DtCvStrLen(_DtCvStringOfStringSeg(pSeg), 0);
  5780. _DtCvStringOfStringSeg(pSeg) = (char *) realloc(
  5781. _DtCvStringOfStringSeg(pSeg), len+2);
  5782. if (_DtCvStringOfStringSeg(pSeg) == NULL)
  5783. return -1;
  5784. strPtr = (char *) _DtCvStrPtr(_DtCvStringOfStringSeg(pSeg),
  5785. 0, len);
  5786. *strPtr++ = ' ';
  5787. *strPtr = '\0';
  5788. }
  5789. else if (MySaveString(&(my_struct->seg_list), my_struct, " ",
  5790. my_struct->cur_link, 1, False ) != 0)
  5791. return -1;
  5792. my_struct->last_was_space = True;
  5793. my_struct->last_was_nl = False;
  5794. }
  5795. return 0;
  5796. } /* End MarkFound */
  5797. /******************************************************************************
  5798. * Function: int SaveItemInfo (
  5799. * FormatStruct my_struct,
  5800. * int element_types,
  5801. * int exceptions);
  5802. *
  5803. * Parameters:
  5804. *
  5805. * Returns: 0 if successful, -1 if errors
  5806. *
  5807. * Purpose: Looks for the virtual page attributes.
  5808. *
  5809. ******************************************************************************/
  5810. static int
  5811. SaveItemInfo(
  5812. FormatStruct *my_struct,
  5813. SDLMask *element_types,
  5814. enum SdlElement sig_element,
  5815. SDLMask *exceptions,
  5816. SDLMask *process_mask)
  5817. {
  5818. _DtCvSegment *refItem = my_struct->add_seg;
  5819. SdlMatchData *info;
  5820. if (SDLSearchMask(process_mask, SdlElementRefItem) == False)
  5821. return 0;
  5822. info = (SdlMatchData *) malloc (sizeof(SdlMatchData));
  5823. if (NULL == info)
  5824. return -1;
  5825. /*
  5826. * save the clan, ssi & level of this refitem
  5827. */
  5828. *info = my_struct->el_info.match;
  5829. SegMatchData(refItem) = (void *) info;
  5830. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SSI);
  5831. return 0;
  5832. } /* End SaveItemInfo */
  5833. /******************************************************************************
  5834. * Function: int AllocateBlock (
  5835. * FormatStruct my_struct,
  5836. * int element_types,
  5837. * int exceptions);
  5838. * Parameters:
  5839. *
  5840. * Returns: 0 if successful, -1 if errors
  5841. *
  5842. * Purpose:
  5843. *
  5844. ******************************************************************************/
  5845. static int
  5846. AllocateBlock(
  5847. FormatStruct *my_struct,
  5848. SDLMask *element_types,
  5849. enum SdlElement sig_element,
  5850. SDLMask *exceptions,
  5851. SDLMask *process_mask)
  5852. {
  5853. /*
  5854. * allocate a block of information all at once for later segments.
  5855. * This, hopefully, will save processing time when later freed.
  5856. *
  5857. * Simply change the malloc_size in the formatting struct.
  5858. */
  5859. if (my_struct->add_seg != NULL)
  5860. {
  5861. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_COUNT))
  5862. my_struct->malloc_size = ElCount(my_struct);
  5863. else
  5864. {
  5865. my_struct->malloc_size = 500;
  5866. if (ElType(my_struct) == SdlElementToss)
  5867. my_struct->malloc_size = 160;
  5868. }
  5869. }
  5870. return 0;
  5871. } /* End AllocateBlock */
  5872. /******************************************************************************
  5873. * Function: int CleanUpBlock (
  5874. * FormatStruct my_struct,
  5875. * int element_types,
  5876. * int exceptions);
  5877. * Parameters:
  5878. *
  5879. * Returns: 0 if successful, -1 if errors
  5880. *
  5881. * Purpose:
  5882. *
  5883. ******************************************************************************/
  5884. static int
  5885. CleanUpBlock(
  5886. FormatStruct *my_struct,
  5887. SDLMask *element_types,
  5888. enum SdlElement sig_element,
  5889. SDLMask *exceptions,
  5890. SDLMask *process_mask)
  5891. {
  5892. /*
  5893. * Go back to piece meal allocation.
  5894. */
  5895. my_struct->malloc_size = 1;
  5896. return 0;
  5897. } /* End CleanUpBlock */
  5898. /******************************************************************************
  5899. * Function: int RegisterLink (
  5900. * FormatStruct my_struct,
  5901. * int element_types,
  5902. * int exceptions);
  5903. *
  5904. * Parameters:
  5905. *
  5906. * Returns: 0 if successful, -1 if errors
  5907. *
  5908. * Purpose: Looks for the virtual page attributes.
  5909. *
  5910. ******************************************************************************/
  5911. static int
  5912. RegisterLink(
  5913. FormatStruct *my_struct,
  5914. SDLMask *element_types,
  5915. enum SdlElement sig_element,
  5916. SDLMask *exceptions,
  5917. SDLMask *process_mask)
  5918. {
  5919. int winType = _DtCvWindowHint_CurrentWindow;
  5920. SDLId rid = _DtCvContainerIdOfSeg(my_struct->add_seg);
  5921. if (SDLSearchMask(process_mask, SdlElementLink) == False)
  5922. return 0;
  5923. switch (ElWindow(my_struct))
  5924. {
  5925. case SdlWindowNew: winType = _DtCvWindowHint_NewWindow;
  5926. break;
  5927. case SdlWindowPopup: winType = _DtCvWindowHint_PopupWindow;
  5928. break;
  5929. }
  5930. my_struct->cur_link = _DtLinkDbAddLink(my_struct->my_links, NULL, rid,
  5931. _DtCvLinkType_SameVolume, winType, NULL);
  5932. if (rid == NULL || my_struct->cur_link < 0)
  5933. return -1;
  5934. /*
  5935. * indicate that at least a blank should be saved for the link
  5936. */
  5937. my_struct->save_blank = True;
  5938. return 0;
  5939. } /* End RegisterLink */
  5940. /******************************************************************************
  5941. * Function: int ResolveIf (FormatStruct my_struct)
  5942. *
  5943. * Parameters:
  5944. *
  5945. * Returns: 0 if successful, -1 if errors
  5946. *
  5947. * Purpose: Looks for the virtual page attributes.
  5948. *
  5949. ******************************************************************************/
  5950. static int
  5951. ResolveIf(
  5952. FormatStruct *my_struct,
  5953. _DtCvSegment *prev_data)
  5954. {
  5955. _DtCvSegment *ifSeg = my_struct->add_seg;
  5956. _DtCvSegment *condSeg = _DtCvContainerListOfSeg(ifSeg);
  5957. _DtCvSegment *condDataSeg = _DtCvContainerListOfSeg(condSeg);
  5958. _DtCvSegment *thenSeg = _DtCvNextSeg(condSeg);
  5959. _DtCvSegment *elseSeg = _DtCvNextSeg(thenSeg);
  5960. _DtCvSegment *resolveSeg = NULL;
  5961. _DtCvSegment *nextDisp = NULL;
  5962. _DtCvSegment *el = NULL;
  5963. char *ifData = NULL;
  5964. char *interpStr;
  5965. interpStr = GetInterpCmd(ElInterp(my_struct));
  5966. if (NULL == interpStr)
  5967. return -1;
  5968. if (_DtCvRunInterp(my_struct->ui_info->exec_filter,
  5969. my_struct->ui_info->client_data,
  5970. interpStr,
  5971. _DtCvStringOfStringSeg(condDataSeg), &ifData) == 0)
  5972. {
  5973. /*
  5974. * Get the pointer to the next displayable item in the 'then'
  5975. * list. This usually will point into the 'then' list,
  5976. * but may point into the 'else' list.
  5977. */
  5978. if (my_struct->then_prev != NULL)
  5979. nextDisp = my_struct->then_prev->next_disp;
  5980. /*
  5981. * use the 'then' data
  5982. */
  5983. if (atoi (ifData) != 0)
  5984. {
  5985. el = thenSeg;
  5986. /*
  5987. * check to make sure that the next_disp is NOT into the
  5988. * 'else' list (because it's about to become a dangling
  5989. * next_disp if it is!).
  5990. */
  5991. if (elseSeg != NULL)
  5992. {
  5993. /*
  5994. * if the next displayable segment is in the 'else'
  5995. * list, null out the next displayable segement since
  5996. * there isn't anything in the 'then' list.
  5997. */
  5998. if (my_struct->then_prev == my_struct->else_prev)
  5999. nextDisp = NULL;
  6000. else
  6001. /*
  6002. * terminate the displayable segment list
  6003. * before the 'else' list.
  6004. */
  6005. my_struct->else_prev->next_disp = NULL;
  6006. }
  6007. }
  6008. else if (elseSeg != NULL)
  6009. {
  6010. /*
  6011. * use the 'else' data.
  6012. */
  6013. el = elseSeg;
  6014. /*
  6015. * Get the next displayable item in the 'else' list.
  6016. */
  6017. if (my_struct->else_prev != NULL)
  6018. nextDisp = my_struct->else_prev->next_disp;
  6019. }
  6020. if (el != NULL)
  6021. {
  6022. resolveSeg = _DtCvContainerListOfSeg(el);
  6023. _DtCvContainerListOfSeg(el) = NULL;
  6024. }
  6025. free(ifData);
  6026. }
  6027. /*
  6028. * set the true next displayable pointer.
  6029. */
  6030. if (prev_data != NULL)
  6031. prev_data->next_disp = nextDisp;
  6032. /*
  6033. * set the previous displayable segment to the last displayable
  6034. * segment in the 'if' clause; in case more displayable segments
  6035. * follow.
  6036. */
  6037. my_struct->prev_data = nextDisp;
  6038. /*
  6039. * free the no longer needed if construct
  6040. */
  6041. _DtHelpFreeSegments(my_struct->add_seg, _DtCvFALSE,
  6042. my_struct->ui_info->destroy_region,
  6043. my_struct->ui_info->client_data);
  6044. /*
  6045. * set the add segment to the result of the if
  6046. */
  6047. my_struct->add_seg = resolveSeg;
  6048. return 0;
  6049. } /* End ResolveIf */
  6050. /******************************************************************************
  6051. * Function: int ZeroOrOne (
  6052. * FormatStruct my_struct,
  6053. * int element_types,
  6054. * int exceptions);
  6055. *
  6056. * Parameters:
  6057. *
  6058. * Returns: 0 if successful, -1 if errors
  6059. *
  6060. * Purpose: Looks for the virtual page attributes.
  6061. *
  6062. ******************************************************************************/
  6063. static int
  6064. ZeroOrOne(
  6065. FormatStruct *my_struct,
  6066. SDLMask *element_types,
  6067. enum SdlElement sig_element,
  6068. SDLMask *exceptions,
  6069. SDLMask *process_mask)
  6070. {
  6071. int result = 0;
  6072. if (my_struct->parsed == SdlElementNone)
  6073. result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList,
  6074. SDLSearchMask(element_types, SdlElementCdata),
  6075. &(my_struct->parsed), &(my_struct->remember),
  6076. &(my_struct->end_flag));
  6077. if (result == 0 && my_struct->end_flag == False &&
  6078. SDLSearchMask(element_types, my_struct->parsed) == True)
  6079. {
  6080. /*
  6081. * check to make sure this is *not* Cdata or if it is that the
  6082. * PcDataFollows flag is *not* set.
  6083. */
  6084. if (my_struct->parsed != SdlElementCdata ||
  6085. SDLSearchMask(element_types, SdlPcDataFollows) == False)
  6086. result = ParseSDL(my_struct, my_struct->parsed, sig_element,
  6087. exceptions, process_mask);
  6088. }
  6089. else if (result == 1) /* eof on compressed entry/file */
  6090. result = 0;
  6091. return result;
  6092. } /* End ZeroOrOne */
  6093. /******************************************************************************
  6094. * Function: int ZeroToN (
  6095. * FormatStruct my_struct,
  6096. * int element_types,
  6097. * int exceptions);
  6098. *
  6099. * Parameters:
  6100. *
  6101. * Returns: 0 if successful, -1 if errors
  6102. *
  6103. * Purpose: Looks for the virtual page attributes.
  6104. *
  6105. ******************************************************************************/
  6106. static int
  6107. ZeroToN(
  6108. FormatStruct *my_struct,
  6109. SDLMask *element_types,
  6110. enum SdlElement sig_element,
  6111. SDLMask *exceptions,
  6112. SDLMask *process_mask)
  6113. {
  6114. _DtCvValue done = False;
  6115. int result = 0;
  6116. while (result == 0 && !done)
  6117. {
  6118. if (my_struct->parsed == SdlElementNone)
  6119. result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList,
  6120. SDLSearchMask(element_types, SdlElementCdata),
  6121. &(my_struct->parsed), &(my_struct->remember),
  6122. &(my_struct->end_flag));
  6123. if (result == 0 && my_struct->end_flag == False &&
  6124. SDLSearchMask(element_types, my_struct->parsed) == True)
  6125. {
  6126. /*
  6127. * check to make sure this is *not* Cdata or if it is that the
  6128. * PcDataFollows flag is *not* set.
  6129. */
  6130. if (my_struct->parsed != SdlElementCdata ||
  6131. SDLSearchMask(element_types, SdlPcDataFollows) == False)
  6132. result = ParseSDL(my_struct, my_struct->parsed,
  6133. sig_element, exceptions, process_mask);
  6134. else
  6135. done = True;
  6136. }
  6137. else
  6138. {
  6139. if (result == 1) /* eof on compressed entry/file */
  6140. result = 0;
  6141. done = True;
  6142. }
  6143. }
  6144. return result;
  6145. } /* End ZeroToN */
  6146. /******************************************************************************
  6147. * Function: int OneToN (
  6148. * FormatStruct my_struct,
  6149. * int element_types,
  6150. * int exceptions);
  6151. *
  6152. * Parameters:
  6153. *
  6154. * Returns: 0 if successful, -1 if errors
  6155. *
  6156. * Purpose: Looks for the virtual page attributes.
  6157. *
  6158. ******************************************************************************/
  6159. static int
  6160. OneToN(
  6161. FormatStruct *my_struct,
  6162. SDLMask *element_types,
  6163. enum SdlElement sig_element,
  6164. SDLMask *exceptions,
  6165. SDLMask *process_mask)
  6166. {
  6167. int found = False;
  6168. int result = 0;
  6169. int done = False;
  6170. while (result == 0 && !done)
  6171. {
  6172. if (my_struct->parsed == SdlElementNone)
  6173. result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList,
  6174. SDLSearchMask(element_types, SdlElementCdata),
  6175. &(my_struct->parsed), &(my_struct->remember),
  6176. &(my_struct->end_flag));
  6177. if (result == 0 && my_struct->end_flag == False &&
  6178. SDLSearchMask(element_types, my_struct->parsed) == True)
  6179. {
  6180. found = True;
  6181. result = ParseSDL(my_struct, my_struct->parsed, sig_element,
  6182. exceptions, process_mask);
  6183. }
  6184. else
  6185. done = True;
  6186. }
  6187. if (!found)
  6188. result = -1;
  6189. return result;
  6190. } /* End OneToN */
  6191. /******************************************************************************
  6192. * Function: int OnlyOne (
  6193. * FormatStruct my_struct,
  6194. * int element_types,
  6195. * int exceptions);
  6196. *
  6197. * Parameters:
  6198. *
  6199. * Returns: 0 if successful, -1 if errors
  6200. *
  6201. * Purpose: Looks for the virtual page attributes.
  6202. *
  6203. ******************************************************************************/
  6204. static int
  6205. OnlyOne(
  6206. FormatStruct *my_struct,
  6207. SDLMask *element_types,
  6208. enum SdlElement sig_element,
  6209. SDLMask *exceptions,
  6210. SDLMask *process_mask)
  6211. {
  6212. _DtCvValue found = False;
  6213. int result = 0;
  6214. if (my_struct->parsed == SdlElementNone)
  6215. result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList,
  6216. SDLSearchMask(element_types, SdlElementCdata),
  6217. &(my_struct->parsed), &(my_struct->remember),
  6218. &(my_struct->end_flag));
  6219. if (result == 0 && my_struct->end_flag == False &&
  6220. SDLSearchMask(element_types, my_struct->parsed) == True)
  6221. {
  6222. found = True;
  6223. result = ParseSDL(my_struct, my_struct->parsed, sig_element,
  6224. exceptions, process_mask);
  6225. }
  6226. if (!found)
  6227. result = -1;
  6228. return result;
  6229. } /* End OnlyOne */
  6230. /******************************************************************************
  6231. * Function: int OnlyOneEach (
  6232. * FormatStruct my_struct,
  6233. * int element_types,
  6234. * int exceptions);
  6235. *
  6236. * Parameters:
  6237. *
  6238. * Returns: 0 if successful, -1 if errors
  6239. *
  6240. * Purpose: Looks for the virtual page attributes.
  6241. *
  6242. ******************************************************************************/
  6243. static int
  6244. OnlyOneEach(
  6245. FormatStruct *my_struct,
  6246. SDLMask *element_types,
  6247. enum SdlElement sig_element,
  6248. SDLMask *exceptions,
  6249. SDLMask *process_mask)
  6250. {
  6251. int result = 0;
  6252. enum SdlElement myEl;
  6253. SDLMask myMask[SDL_MASK_LEN];
  6254. SaveRestoreMask(myMask, element_types);
  6255. while (result == 0 && SDLCheckMask(myMask))
  6256. {
  6257. if (my_struct->parsed == SdlElementNone)
  6258. result = _DtHelpCeReturnSdlElement(my_struct->my_file, SdlElementList,
  6259. SDLSearchMask(myMask, SdlElementCdata),
  6260. &(my_struct->parsed), &(my_struct->remember),
  6261. &(my_struct->end_flag));
  6262. if (result == 0 && my_struct->end_flag == False &&
  6263. SDLSearchMask(element_types, my_struct->parsed) == True)
  6264. {
  6265. myEl = my_struct->parsed;
  6266. result = ParseSDL(my_struct, my_struct->parsed, sig_element,
  6267. exceptions, process_mask);
  6268. SDLStripFromMask(myMask, myEl);
  6269. }
  6270. else
  6271. result = -1;
  6272. }
  6273. if (SDLCheckMask(myMask))
  6274. result = -1;
  6275. return result;
  6276. } /* End OnlyOneEach */
  6277. /******************************************************************************
  6278. * Function: int Cdata (FormatStruct my_struct,
  6279. * int cur_element, exceptions);
  6280. *
  6281. * Parameters:
  6282. *
  6283. * Returns: 0 if successful, -1 if errors
  6284. *
  6285. * Purpose: Looks for the virtual page attributes.
  6286. *
  6287. ******************************************************************************/
  6288. static int
  6289. Cdata(
  6290. FormatStruct *my_struct,
  6291. SDLMask *cur_element,
  6292. enum SdlElement sig_element,
  6293. SDLMask *exceptions,
  6294. SDLMask *process_mask)
  6295. {
  6296. int i;
  6297. int reason;
  6298. int myLen = 0;
  6299. int curLen = my_struct->mb_len;
  6300. int multiLen = my_struct->mb_len;
  6301. int saveLen = my_struct->mb_len;
  6302. char nonBreakChar;
  6303. char *string = NULL;
  6304. char spaceStr[] = " ";
  6305. char dashStr[] = "-";
  6306. SdlOption type = ElFrmtType(my_struct);
  6307. _DtCvSegment *pSeg = NULL;
  6308. _DtCvValue nlToSpace = True;
  6309. _DtCvValue processFlag = SDLSearchMask(process_mask, SdlElementCdata);
  6310. if (my_struct->ui_info->nl_to_space == 0)
  6311. nlToSpace = False;
  6312. if (type == SdlTypeCdata)
  6313. {
  6314. /*
  6315. * the element requires straight cdata for processing - i.e.
  6316. * the data is going to be passed off to an interperter.
  6317. * Therefore it doesn't want it broken up into different
  6318. * byte length segments.
  6319. *
  6320. * Therefore, force the string save to put all the data into
  6321. * one string.
  6322. */
  6323. saveLen = 1;
  6324. }
  6325. if (my_struct->remember != NULL)
  6326. {
  6327. i = 0;
  6328. string = my_struct->remember;
  6329. myLen = strlen(string);
  6330. while (string[i] != '\0' && i < myLen)
  6331. {
  6332. if (multiLen != 1)
  6333. curLen = mblen (&string[i], multiLen);
  6334. if (curLen == 1)
  6335. {
  6336. if (my_struct->last_was_nl == True)
  6337. {
  6338. if (MoveString(&string, &myLen, &i) == -1)
  6339. return -1;
  6340. string[i++] = ' ';
  6341. my_struct->last_was_space = True;
  6342. }
  6343. my_struct->last_was_nl = False;
  6344. my_struct->last_was_mb = False;
  6345. if (string[i] == '\t')
  6346. string[i] = ' ';
  6347. if (string[i] == '&')
  6348. {
  6349. strmove (&string[i], &string[i+1]);
  6350. if (string[i] == '\0')
  6351. {
  6352. string[i] = BufFileGet(my_struct->my_file);
  6353. if (string[i] == BUFFILEEOF)
  6354. return -1;
  6355. string[i+1] = '\0';
  6356. }
  6357. /*
  6358. * is this an SGML numeric character reference
  6359. * entity? if so, it should have the format
  6360. * '&#d[d[d]][;]' where 'ddd' represent characters
  6361. * of '0' to '9'. The semi-colon is required iff
  6362. * the next character is a numeric character of '0'
  6363. * to '9'. Otherwise it is optional.
  6364. */
  6365. if (string[i] == '#')
  6366. {
  6367. int j;
  6368. int value;
  6369. #define ESC_STRING_LEN 4
  6370. i++;
  6371. /*
  6372. * Is there enough to room to process three digits
  6373. * and a possible semi-colon?
  6374. */
  6375. if (myLen - i < ESC_STRING_LEN)
  6376. {
  6377. /*
  6378. * lengthen the string so that it can contain
  6379. * the information
  6380. */
  6381. myLen += ESC_STRING_LEN;
  6382. string = (char *) realloc(string,
  6383. sizeof(char) * (myLen + 1));
  6384. if (string == NULL)
  6385. return -1;
  6386. }
  6387. /*
  6388. * now make sure that the entire numeric entity
  6389. * exists in the string.
  6390. */
  6391. j = i;
  6392. while ('0' <= string[i] && string[i] <= '9')
  6393. i++;
  6394. /*
  6395. * run into the end of string before running
  6396. * into a delimiter? Fill out the escaped
  6397. * numeric character.
  6398. */
  6399. if (string[i] == '\0')
  6400. {
  6401. do
  6402. {
  6403. string[i] = BufFileGet(my_struct->my_file);
  6404. if (string[i] == BUFFILEEOF)
  6405. return -1;
  6406. i++;
  6407. } while (i < myLen && '0' <= string[i-1]
  6408. && string[i-1] <= '9');
  6409. /*
  6410. * end the string and back up to the last
  6411. * character
  6412. */
  6413. string[i] = '\0';
  6414. i--;
  6415. }
  6416. /*
  6417. * the fourth character is a numeric, error
  6418. */
  6419. if ('0' <= string[i] && string[i] <= '9')
  6420. return -1;
  6421. if (string[i] == ';')
  6422. i++;
  6423. value = atoi(&string[j]);
  6424. if (value > 255)
  6425. return -1;
  6426. /*
  6427. * smash over the pound sign with the 'real' value
  6428. * and copy the rest of the string to after it.
  6429. */
  6430. string[j-1] = (char) value;
  6431. strmove (&string[j], &string[i]);
  6432. i = j;
  6433. }
  6434. if (string[i] == '\n')
  6435. {
  6436. if (ProcessString(my_struct, True, True, True,
  6437. True,
  6438. processFlag, string, saveLen, &i) != 0)
  6439. return -1;
  6440. }
  6441. else if (string[i] == ' ')
  6442. {
  6443. if (ProcessNonBreakChar(my_struct, processFlag,
  6444. spaceStr, string, saveLen, &i) != 0)
  6445. return -1;
  6446. }
  6447. else if (string[i] == '-')
  6448. {
  6449. if (ProcessNonBreakChar(my_struct, processFlag,
  6450. dashStr, string, saveLen, &i) != 0)
  6451. return -1;
  6452. }
  6453. else
  6454. my_struct->last_was_space = False;
  6455. i++;
  6456. }
  6457. else if (string[i] == '\n')
  6458. {
  6459. /*
  6460. * want to keep the newlines
  6461. */
  6462. if (type == SdlTypeCdata)
  6463. i++;
  6464. else if (type == SdlTypeDynamic ||
  6465. type == SdlTypeUnlinedLiteral)
  6466. {
  6467. if (my_struct->last_was_space == False)
  6468. my_struct->last_was_nl = True;
  6469. strmove (&string[i], &string[i+1]);
  6470. }
  6471. else
  6472. {
  6473. string[i] = '\0';
  6474. if (processFlag == True &&
  6475. MySaveString(&(my_struct->seg_list),
  6476. my_struct, string, my_struct->cur_link,
  6477. saveLen, True) != 0)
  6478. {
  6479. MyFree(string);
  6480. return -1;
  6481. }
  6482. strmove (string, &string[i+1]);
  6483. i = 0;
  6484. }
  6485. }
  6486. else if (string[i] == ' ')
  6487. {
  6488. if (False == my_struct->save_blank &&
  6489. type != SdlTypeLiteral && type != SdlTypeUnlinedLiteral
  6490. && my_struct->last_was_space == True)
  6491. strmove (&string[i], &string[i+1]);
  6492. else
  6493. i++;
  6494. my_struct->last_was_space = True;
  6495. }
  6496. else
  6497. {
  6498. my_struct->last_was_space = False;
  6499. i++;
  6500. }
  6501. }
  6502. else if (curLen > 0)
  6503. {
  6504. if (my_struct->last_was_nl == True)
  6505. {
  6506. if (nlToSpace == True || my_struct->last_was_mb == False)
  6507. {
  6508. if (MoveString(&string, &myLen, &i) == -1)
  6509. return -1;
  6510. string[i++] = ' ';
  6511. }
  6512. else /* the last was a multibyte character, tighten up */
  6513. {
  6514. i--;
  6515. strmove (&string[i], &string[i+1]);
  6516. }
  6517. }
  6518. my_struct->last_was_space = False;
  6519. my_struct->last_was_nl = False;
  6520. my_struct->last_was_mb = True;
  6521. i += curLen;
  6522. }
  6523. else if (curLen == 0)
  6524. return -1;
  6525. else /* if (curLen < 0) */
  6526. {
  6527. /*
  6528. * must finish up the character
  6529. */
  6530. int len = 0;
  6531. myLen = strlen(string);
  6532. string = (char *) realloc(string, myLen + multiLen + 1);
  6533. if (string == NULL) return -1;
  6534. while (curLen < 0 && len < multiLen) {
  6535. string[myLen] = BufFileGet(my_struct->my_file);
  6536. if (string[myLen] == BUFFILEEOF) return -1;
  6537. string[myLen + 1] = '\0';
  6538. curLen = mblen(&string[i], multiLen);
  6539. ++len;
  6540. ++myLen;
  6541. }
  6542. if (curLen < 0)
  6543. return -1;
  6544. }
  6545. }
  6546. if (processFlag == False)
  6547. {
  6548. free(string);
  6549. string = NULL;
  6550. myLen = 0;
  6551. }
  6552. my_struct->remember = NULL;
  6553. }
  6554. do {
  6555. my_struct->parsed = SdlElementNone;
  6556. reason = _DtHelpCeGetSdlCdata(my_struct->my_file, type, multiLen,
  6557. nlToSpace,
  6558. &my_struct->last_was_space,
  6559. &my_struct->last_was_nl,
  6560. &my_struct->last_was_mb,
  6561. &nonBreakChar,
  6562. (processFlag == True ? &string : ((char**)NULL)),
  6563. &myLen);
  6564. if (reason < 0)
  6565. return -1;
  6566. if (string != NULL && *string != '\0')
  6567. {
  6568. /*
  6569. * save the string.
  6570. */
  6571. if (MySaveString(&(my_struct->seg_list), my_struct,
  6572. string, my_struct->cur_link, saveLen,
  6573. (1 == reason ? True : False)) != 0)
  6574. {
  6575. MyFree(string);
  6576. return -1;
  6577. }
  6578. /*
  6579. * indicate that a string was saved for the current link
  6580. */
  6581. my_struct->save_blank = False;
  6582. /*
  6583. * null the temp buffer.
  6584. */
  6585. string[0] = '\0';
  6586. /*
  6587. * reset flags if we stopped because of a newline.
  6588. */
  6589. if (1 == reason && (SdlTypeLiteral == type || SdlTypeLined == type))
  6590. {
  6591. my_struct->last_was_space = True;
  6592. my_struct->last_was_nl = False;
  6593. }
  6594. }
  6595. else if (reason == 1) /* stopped because of newline */
  6596. {
  6597. pSeg = my_struct->prev_data;
  6598. if (pSeg == NULL || _DtCvIsSegNewLine(pSeg))
  6599. {
  6600. if (_DtHelpCeAllocSegment(my_struct->malloc_size,
  6601. &(my_struct->alloc_size),
  6602. &(my_struct->block_list), &pSeg) != 0)
  6603. return -1;
  6604. pSeg->type = _DtCvSetTypeToNoop(pSeg->type);
  6605. if (my_struct->prev_data != NULL)
  6606. my_struct->prev_data->next_disp = pSeg;
  6607. my_struct->prev_data = pSeg;
  6608. _DtHelpCeAddSegToList(pSeg, &(my_struct->seg_list),
  6609. &(my_struct->last_seg));
  6610. }
  6611. pSeg->type = _DtCvSetTypeToNewLine(pSeg->type);
  6612. my_struct->last_was_space = True;
  6613. my_struct->last_was_nl = False;
  6614. }
  6615. /*
  6616. * did we stop because of a non-breaking character?
  6617. */
  6618. if (2 == reason && True == processFlag)
  6619. {
  6620. /*
  6621. * copy the non breaking character into a buffer.
  6622. */
  6623. if (1 > myLen)
  6624. {
  6625. string = (char *) malloc (sizeof(char) * 32);
  6626. myLen = 32;
  6627. }
  6628. string[0] = nonBreakChar;
  6629. string[1] = '\0';
  6630. /*
  6631. * save the string.
  6632. */
  6633. my_struct->flags = _DtCvSetTypeToNonBreak(my_struct->flags);
  6634. if (MySaveString(&(my_struct->seg_list), my_struct,
  6635. string, my_struct->cur_link, saveLen, False) != 0)
  6636. {
  6637. MyFree(string);
  6638. return -1;
  6639. }
  6640. my_struct->flags = my_struct->flags & ~(_DtCvNON_BREAK);
  6641. /*
  6642. * indicate that the non-breaking character is considered
  6643. * non-white space.
  6644. */
  6645. my_struct->last_was_space = False;
  6646. /*
  6647. * indicate that a string was saved for the current link
  6648. */
  6649. my_struct->save_blank = False;
  6650. /*
  6651. * null the temp buffer.
  6652. */
  6653. string[0] = '\0';
  6654. }
  6655. } while (reason > 0);
  6656. MyFree(string);
  6657. return 0;
  6658. } /* End Cdata */
  6659. /******************************************************************************
  6660. * Function: int ProcessEnterAttr (
  6661. * FormatStruct my_struct,
  6662. * int cur_element, exceptions);
  6663. *
  6664. * Parameters:
  6665. *
  6666. * Returns: 0 if successful, -1 if errors
  6667. *
  6668. * Purpose:
  6669. *
  6670. ******************************************************************************/
  6671. static int
  6672. ProcessEnterAttr(
  6673. FormatStruct *my_struct,
  6674. SDLMask *cur_element,
  6675. enum SdlElement sig_element,
  6676. SDLMask *exceptions,
  6677. SDLMask *process_mask)
  6678. {
  6679. /*
  6680. * save the enter string as part of this element's segment list
  6681. */
  6682. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_ENTER) &&
  6683. ((int)strlen(ElEnter(my_struct))) > 0 &&
  6684. MySaveString(&(my_struct->seg_list), my_struct, ElEnter(my_struct),
  6685. my_struct->cur_link, my_struct->mb_len, False) != 0)
  6686. return -1;
  6687. return 0;
  6688. } /* End ProcessEnterAttr */
  6689. /******************************************************************************
  6690. * Function: int ProcessExitAttr (
  6691. * FormatStruct my_struct,
  6692. * int cur_element, exceptions);
  6693. *
  6694. * Parameters:
  6695. *
  6696. * Returns: 0 if successful, -1 if errors
  6697. *
  6698. * Purpose:
  6699. *
  6700. ******************************************************************************/
  6701. static int
  6702. ProcessExitAttr(
  6703. FormatStruct *my_struct,
  6704. SDLMask *cur_element,
  6705. enum SdlElement sig_element,
  6706. SDLMask *exceptions,
  6707. SDLMask *process_mask)
  6708. {
  6709. /*
  6710. * save the exit string as part of this element's segment list
  6711. */
  6712. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_EXIT) &&
  6713. ((int)strlen(ElExit(my_struct))) > 0 &&
  6714. MySaveString(&(my_struct->seg_list), my_struct, ElExit(my_struct),
  6715. my_struct->cur_link, my_struct->mb_len, False) != 0)
  6716. return -1;
  6717. return 0;
  6718. } /* End ProcessExitAttr */
  6719. /******************************************************************************
  6720. * Function: int FakeEnd (FormatStruct my_struct,
  6721. * int cur_element, exceptions);
  6722. *
  6723. * Parameters:
  6724. *
  6725. * Returns: 0 if successful, -1 if errors
  6726. *
  6727. * Purpose: Looks for the virtual page attributes.
  6728. *
  6729. ******************************************************************************/
  6730. static int
  6731. FakeEnd(
  6732. FormatStruct *my_struct,
  6733. SDLMask *cur_element,
  6734. enum SdlElement sig_element,
  6735. SDLMask *exceptions,
  6736. SDLMask *process_mask)
  6737. {
  6738. my_struct->end_flag = True;
  6739. my_struct->faked_end = True;
  6740. MaskToValue(cur_element, my_struct->parsed);
  6741. return 0;
  6742. } /* End FakeEnd */
  6743. /******************************************************************************
  6744. * Function: int AddRowToTable (FormatStruct my_struct,
  6745. * int cur_element, exceptions);
  6746. *
  6747. * Parameters:
  6748. *
  6749. * Returns: 0 if successful, -1 if errors
  6750. *
  6751. * Purpose: Looks for the virtual page attributes.
  6752. *
  6753. ******************************************************************************/
  6754. static int
  6755. AddRowToTable(
  6756. FormatStruct *my_struct,
  6757. SDLMask *cur_element,
  6758. enum SdlElement sig_element,
  6759. SDLMask *exceptions,
  6760. SDLMask *process_mask)
  6761. {
  6762. if (SDLSearchMask(process_mask, SdlElementFrowvec) != False)
  6763. {
  6764. ElTableCellIds(my_struct) = (char **) _DtCvAddPtrToArray(
  6765. (void **) ElTableCellIds(my_struct),
  6766. ElTableCellId(my_struct));
  6767. if (NULL == ElTableCellIds(my_struct))
  6768. return -1;
  6769. ClearAttrFlag(my_struct->el_info, SDL_ATTR_CELLS);
  6770. }
  6771. return 0;
  6772. } /* End AddRowToTable */
  6773. /******************************************************************************
  6774. * Function: int SaveLangCharSet (
  6775. * FormatStruct my_struct,
  6776. * int cur_element, exceptions);
  6777. *
  6778. * Parameters:
  6779. *
  6780. * Returns: 0 if successful, -1 if errors
  6781. *
  6782. * Purpose: Looks for the virtual page attributes.
  6783. *
  6784. ******************************************************************************/
  6785. static int
  6786. SaveLangCharSet(
  6787. FormatStruct *my_struct,
  6788. SDLMask *cur_element,
  6789. enum SdlElement sig_element,
  6790. SDLMask *exceptions,
  6791. SDLMask *process_mask)
  6792. {
  6793. char **info;
  6794. if (SDLSearchMask(process_mask, SdlElementText) == False ||
  6795. !(SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LANGUAGE) ||
  6796. SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CHARSET)))
  6797. return 0;
  6798. info = (char **) calloc (2, sizeof(char *));
  6799. if (NULL == info)
  6800. return -1;
  6801. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_LANGUAGE))
  6802. info[0] = ElLanguage(my_struct);
  6803. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_CHARSET))
  6804. info[1] = ElCharSet(my_struct);
  6805. ClearAttrFlag(my_struct->el_info, SDL_ATTR_LANGUAGE);
  6806. ClearAttrFlag(my_struct->el_info, SDL_ATTR_CHARSET);
  6807. _SdlSegLangChar(my_struct->add_seg) = (void *) info;
  6808. return 0;
  6809. } /* End SaveLangCharSet */
  6810. /******************************************************************************
  6811. * Function: int CopyDocInfo (FormatStruct my_struct,
  6812. * int cur_element, exceptions);
  6813. *
  6814. * Parameters:
  6815. *
  6816. * Returns: 0 if successful, -1 if errors
  6817. *
  6818. * Purpose: Looks for the virtual page attributes.
  6819. *
  6820. ******************************************************************************/
  6821. static int
  6822. CopyDocInfo(
  6823. FormatStruct *my_struct,
  6824. SDLMask *cur_element,
  6825. enum SdlElement sig_element,
  6826. SDLMask *exceptions,
  6827. SDLMask *process_mask)
  6828. {
  6829. SDLDocInfo *docInfo;
  6830. if (SDLSearchMask(process_mask, SdlElementSdlDoc) == False)
  6831. return 0;
  6832. docInfo = (SDLDocInfo *) malloc (sizeof(SDLDocInfo));
  6833. if (NULL == docInfo)
  6834. return -1;
  6835. *(docInfo) = ElDocInfo(my_struct);
  6836. _SdlDocInfoPtrLanguage(docInfo) = strdup(ElLanguage(my_struct));
  6837. _SdlDocInfoPtrCharSet(docInfo) = strdup(ElCharSet(my_struct));
  6838. ClearAttrFlag(my_struct->el_info, SDL_ATTR_DOCID);
  6839. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SDLDTD);
  6840. ClearAttrFlag(my_struct->el_info, SDL_ATTR_TIMESTAMP);
  6841. ClearAttrFlag(my_struct->el_info, SDL_ATTR_FRST_PG);
  6842. ClearAttrFlag(my_struct->el_info, SDL_ATTR_VERSION);
  6843. FrmtPrivInfoPtr(my_struct->add_seg)->doc_info = (void *) docInfo;
  6844. return 0;
  6845. } /* End CopyDocInfo */
  6846. /******************************************************************************
  6847. * Function: int CopyAnchorId (FormatStruct my_struct,
  6848. * int cur_element, exceptions);
  6849. *
  6850. * Parameters:
  6851. *
  6852. * Returns: 0 if successful, -1 if errors
  6853. *
  6854. * Purpose: Looks for the virtual page attributes.
  6855. *
  6856. ******************************************************************************/
  6857. static int
  6858. CopyAnchorId(
  6859. FormatStruct *my_struct,
  6860. SDLMask *cur_element,
  6861. enum SdlElement sig_element,
  6862. SDLMask *exceptions,
  6863. SDLMask *process_mask)
  6864. {
  6865. _DtCvSegment *mySeg = my_struct->add_seg;
  6866. /*
  6867. * if we're not suppose to process this, skip.
  6868. */
  6869. if (SDLSearchMask(process_mask, SdlElementAnchor) == False)
  6870. return 0;
  6871. /*
  6872. * copy the id.
  6873. */
  6874. _DtCvIdOfMarkerSeg(mySeg) = ElId(my_struct);
  6875. /*
  6876. * clear the flag so that it don't get freed.
  6877. */
  6878. ClearAttrFlag(my_struct->el_info, SDL_ATTR_ID);
  6879. return 0;
  6880. } /* End CopyDocInfo */
  6881. /******************************************************************************
  6882. * Function: int LoadGraphic (
  6883. * FormatStruct my_struct,
  6884. * int cur_element, exceptions);
  6885. *
  6886. * Parameters:
  6887. *
  6888. * Returns: 0 if successful, -1 if errors
  6889. *
  6890. * Purpose: Looks for the virtual page attributes.
  6891. *
  6892. ******************************************************************************/
  6893. static int
  6894. LoadGraphic(
  6895. FormatStruct *my_struct,
  6896. SDLMask *cur_element,
  6897. enum SdlElement sig_element,
  6898. SDLMask *exceptions,
  6899. SDLMask *process_mask)
  6900. {
  6901. int result = 0;
  6902. if (SDLSearchMask(process_mask, SdlElementGraphic) != False)
  6903. {
  6904. /*
  6905. * get my container segment.
  6906. */
  6907. _DtCvSegment *mySeg = my_struct->add_seg;
  6908. _DtCvSegment *cvRegion; /* Canvas Engine Region */
  6909. result = -1;
  6910. /*
  6911. * allocate a Canvas Engine region.
  6912. */
  6913. if (_DtHelpCeAllocSegment(1, NULL, NULL, &cvRegion) == 0)
  6914. {
  6915. /*
  6916. * got memory for a region, now fill out the information.
  6917. *
  6918. * even if the load fails, we should just throw away
  6919. * the graphic and continue.
  6920. */
  6921. result = 0;
  6922. if (NULL != my_struct->ui_info->load_graphic &&
  6923. (*(my_struct->ui_info->load_graphic))(
  6924. my_struct->ui_info->client_data,
  6925. my_struct->vol_name,
  6926. my_struct->id_string,
  6927. ElSnbXid(my_struct),
  6928. ElSnbFormat(my_struct),
  6929. ElSnbMethod(my_struct),
  6930. &(_DtCvWidthOfRegionSeg(cvRegion)),
  6931. &(_DtCvHeightOfRegionSeg(cvRegion)),
  6932. &(_DtCvInfoOfRegionSeg(cvRegion))) == 0)
  6933. {
  6934. /*
  6935. * set the type on the region! And its ascent!
  6936. */
  6937. cvRegion->type = _DtCvSetTypeToRegion(cvRegion->type);
  6938. _DtCvAscentOfRegionSeg(cvRegion) = -1;
  6939. /*
  6940. * set the seg list for the wrapper container.
  6941. */
  6942. _DtCvContainerListOfSeg(mySeg) = cvRegion;
  6943. /*
  6944. * indicate the link has been fixed up
  6945. */
  6946. my_struct->save_blank = True;
  6947. }
  6948. else
  6949. {
  6950. /*
  6951. * problems loading the graphic. Clean up!
  6952. */
  6953. MyFree(cvRegion);
  6954. }
  6955. }
  6956. }
  6957. return result;
  6958. } /* End LoadGraphic */
  6959. /******************************************************************************
  6960. * Function: int ColInfoToTableInfo (
  6961. * FormatStruct my_struct,
  6962. * int cur_element, exceptions);
  6963. *
  6964. * Parameters:
  6965. *
  6966. * Returns: 0 if successful, -1 if errors
  6967. *
  6968. * Purpose: Looks for the virtual page attributes.
  6969. *
  6970. ******************************************************************************/
  6971. static int
  6972. ColInfoToTableInfo(
  6973. FormatStruct *my_struct,
  6974. SDLMask *cur_element,
  6975. enum SdlElement sig_element,
  6976. SDLMask *exceptions,
  6977. SDLMask *process_mask)
  6978. {
  6979. if (SDLSearchMask(process_mask, SdlElementForm) != False)
  6980. {
  6981. int i;
  6982. int mySize = ElTableColNum(my_struct);
  6983. const char *next;
  6984. const char *start = NULL;
  6985. const char *last = NULL;
  6986. char **colWidths = NULL;
  6987. _DtCvFrmtOption *colJust;
  6988. colWidths = (char **) malloc (sizeof(char *) * mySize);
  6989. colJust = (_DtCvFrmtOption *) malloc (sizeof(_DtCvFrmtOption)*mySize);
  6990. if (NULL == colWidths || NULL == colJust)
  6991. {
  6992. MyFree(colWidths);
  6993. MyFree(colJust);
  6994. return -1;
  6995. }
  6996. /*
  6997. * now process the column width specification.
  6998. */
  6999. next = ElTableColWStr(my_struct);
  7000. if (NULL == next || '\0' == *next)
  7001. next = "1";
  7002. for (i = 0; i < mySize; i++)
  7003. {
  7004. /* skip the leading spaces */
  7005. while (' ' == *next) next++;
  7006. /* if the string really moved */
  7007. if (last != next)
  7008. start = next;
  7009. /* go to the end of this specification */
  7010. while (' ' != *next && '\0' != *next) next++;
  7011. /* duplicate the specification */
  7012. colWidths[i] = strdup(start);
  7013. if (NULL == colWidths[i])
  7014. return -1;
  7015. /* mark the end of the string */
  7016. last = next;
  7017. }
  7018. /*
  7019. * now process the column justify specification.
  7020. */
  7021. next = ElTableColJStr(my_struct);
  7022. if (NULL == next || '\0' == *next)
  7023. next = NullOption;
  7024. for (i = 0; i < mySize; i++)
  7025. {
  7026. /* skip the leading spaces */
  7027. while (' ' == *next) next++;
  7028. /* if the string really moved */
  7029. if (last != next)
  7030. start = next;
  7031. /* go to the end of this specification */
  7032. while (' ' != *next && '\0' != *next) next++;
  7033. /* determine the justification */
  7034. switch (*start)
  7035. {
  7036. case 'r':
  7037. case 'R': colJust[i] = _DtCvJUSTIFY_RIGHT;
  7038. break;
  7039. case 'c':
  7040. case 'C': colJust[i] = _DtCvJUSTIFY_CENTER;
  7041. break;
  7042. case 'd':
  7043. case 'D': colJust[i] = _DtCvJUSTIFY_NUM;
  7044. break;
  7045. case 'l':
  7046. case 'L': colJust[i] = _DtCvJUSTIFY_LEFT;
  7047. break;
  7048. default : colJust[i] = _DtCvJUSTIFY_LEFT;
  7049. if (NullOption == start)
  7050. colJust[i] = _DtCvINHERIT;
  7051. break;
  7052. }
  7053. /* mark the end of the string */
  7054. last = next;
  7055. }
  7056. ElTableColWidths(my_struct) = colWidths;
  7057. ElTableColJust(my_struct) = colJust;
  7058. }
  7059. return 0;
  7060. } /* End ColInfoToTableInfo */
  7061. /******************************************************************************
  7062. * Function: int CopyIdInfo (FormatStruct my_struct,
  7063. * int cur_element, exceptions);
  7064. *
  7065. * Parameters:
  7066. *
  7067. * Returns: 0 if successful, -1 if errors
  7068. *
  7069. * Purpose: Looks for the virtual page attributes.
  7070. *
  7071. ******************************************************************************/
  7072. static int
  7073. CopyIdInfo(
  7074. FormatStruct *my_struct,
  7075. SDLMask *cur_element,
  7076. enum SdlElement sig_element,
  7077. SDLMask *exceptions,
  7078. SDLMask *process_mask)
  7079. {
  7080. SDLIdInfo *idInfo;
  7081. if (SDLSearchMask(process_mask, SdlElementId) == False)
  7082. return 0;
  7083. idInfo = (SDLIdInfo *) malloc (sizeof(SDLIdInfo));
  7084. if (NULL == idInfo)
  7085. return -1;
  7086. *(idInfo) = ElIdInfo(my_struct);
  7087. _SdlIdInfoPtrType(idInfo) = ElFrmtType(my_struct);
  7088. _SdlIdInfoPtrOffset(idInfo) = ElOffset(my_struct);
  7089. _SdlIdInfoPtrRlevel(idInfo) = ElLevel(my_struct);
  7090. _SdlIdInfoPtrRssi(idInfo) = ElSsi(my_struct);
  7091. ClearAttrFlag(my_struct->el_info, SDL_ATTR_RID);
  7092. ClearAttrFlag(my_struct->el_info, SDL_ATTR_RSSI);
  7093. FrmtPrivInfoPtr(my_struct->add_seg)->id_info = (void *) idInfo;
  7094. return 0;
  7095. } /* End CopyIdInfo */
  7096. /******************************************************************************
  7097. * Function: int RegisterSnbLink (FormatStruct my_struct,
  7098. * int cur_element, exceptions);
  7099. *
  7100. * Parameters:
  7101. *
  7102. * Returns: 0 if successful, -1 if errors
  7103. *
  7104. * Purpose: Looks for the virtual page attributes.
  7105. *
  7106. ******************************************************************************/
  7107. static int
  7108. RegisterSnbLink(
  7109. FormatStruct *my_struct,
  7110. SDLMask *cur_element,
  7111. enum SdlElement sig_element,
  7112. SDLMask *exceptions,
  7113. SDLMask *process_mask)
  7114. {
  7115. int linkType;
  7116. int len = 0;
  7117. char buffer[64] = "";
  7118. char *fileSpec = NULL;
  7119. if (SDLSearchMask(process_mask, ElType(my_struct)) == False)
  7120. return 0;
  7121. fileSpec = ElSnbXid(my_struct);
  7122. switch (ElType(my_struct))
  7123. {
  7124. case SdlElementCrossDoc:
  7125. linkType = _DtCvLinkType_CrossLink;
  7126. break;
  7127. case SdlElementManPage:
  7128. linkType = _DtCvLinkType_ManPage;
  7129. break;
  7130. case SdlElementTextFile:
  7131. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_OFFSET))
  7132. {
  7133. sprintf(buffer, " %d", ElOffset(my_struct));
  7134. len += strlen(buffer);
  7135. }
  7136. if (SDLIsAttrSet(my_struct->el_info, SDL_ATTR_FORMAT))
  7137. len += strlen(ElSnbFormat(my_struct));
  7138. /*
  7139. * create a new file spec for the link
  7140. */
  7141. if (0 < len)
  7142. {
  7143. len += strlen(ElSnbXid(my_struct) + 1);
  7144. fileSpec = malloc(sizeof(char) * len);
  7145. if (NULL == fileSpec)
  7146. return -1;
  7147. strcpy(fileSpec, ElSnbXid(my_struct));
  7148. strcat(fileSpec, buffer);
  7149. strcat(fileSpec, ElSnbFormat(my_struct));
  7150. }
  7151. linkType = _DtCvLinkType_TextFile;
  7152. break;
  7153. case SdlElementSysCmd:
  7154. linkType = _DtCvLinkType_Execute;
  7155. break;
  7156. case SdlElementCallback:
  7157. linkType = _DtCvLinkType_AppDefine;
  7158. break;
  7159. default: return -1;
  7160. }
  7161. if (0 > _DtLinkDbAddLink(my_struct->my_links,
  7162. _DtCvContainerIdOfSeg(my_struct->add_seg),
  7163. fileSpec,
  7164. linkType,
  7165. _DtCvWindowHint_Original,
  7166. NULL))
  7167. return -1;
  7168. if (fileSpec != ElSnbXid(my_struct))
  7169. free(fileSpec);
  7170. return 0;
  7171. } /* End RegisterSnbLink */
  7172. /******************************************************************************
  7173. * Function: int RegisterSwitch (FormatStruct my_struct,
  7174. * int cur_element, exceptions);
  7175. *
  7176. * Parameters:
  7177. *
  7178. * Returns: 0 if successful, -1 if errors
  7179. *
  7180. * Purpose: Looks for the virtual page attributes.
  7181. *
  7182. ******************************************************************************/
  7183. static int
  7184. RegisterSwitch(
  7185. FormatStruct *my_struct,
  7186. SDLMask *cur_element,
  7187. enum SdlElement sig_element,
  7188. SDLMask *exceptions,
  7189. SDLMask *process_mask)
  7190. {
  7191. int result = -1;
  7192. char *interpStr;
  7193. if (SDLSearchMask(process_mask, ElType(my_struct)) == False)
  7194. return 0;
  7195. interpStr = GetInterpCmd(ElInterp(my_struct));
  7196. if (NULL != interpStr)
  7197. interpStr = strdup(interpStr);
  7198. if (NULL != interpStr)
  7199. {
  7200. if (0 == _DtLinkDbAddSwitch(my_struct->my_links,
  7201. _DtCvContainerIdOfSeg(my_struct->add_seg),
  7202. interpStr,
  7203. _DtCvStringOfStringSeg(my_struct->add_seg),
  7204. ElSwitchBranches(my_struct)))
  7205. result = 0;
  7206. free(my_struct->add_seg);
  7207. my_struct->add_seg = NULL;
  7208. }
  7209. return result;
  7210. } /* End RegisterSwitch */
  7211. /******************************************************************************
  7212. * Function: int ResolveSpcInfo (FormatStruct my_struct,
  7213. * int cur_element, exceptions);
  7214. *
  7215. * Parameters:
  7216. *
  7217. * Returns: 0 if successful, -1 if errors
  7218. *
  7219. * Purpose: Looks for the virtual page attributes.
  7220. *
  7221. ******************************************************************************/
  7222. static int
  7223. ResolveSpcInfo(
  7224. FormatStruct *my_struct,
  7225. SDLMask *cur_element,
  7226. enum SdlElement sig_element,
  7227. SDLMask *exceptions,
  7228. SDLMask *process_mask)
  7229. {
  7230. _DtCvSegment *mySeg = my_struct->add_seg;
  7231. if (SDLSearchMask(process_mask, ElType(my_struct)) != False)
  7232. {
  7233. /*
  7234. * set the non break character flag so that the layout routines
  7235. * will only wrap this to the next line if there is a space
  7236. * before it.
  7237. *
  7238. * Also set the inline flag so that the layout routines don't
  7239. * think that the region is a figure.
  7240. */
  7241. mySeg->type = _DtCvSetTypeToNonBreak(mySeg->type);
  7242. mySeg->type = _DtCvSetTypeToInLine(mySeg->type);
  7243. /*
  7244. * now establish the proper display linking.
  7245. */
  7246. if (my_struct->prev_data != NULL)
  7247. my_struct->prev_data->next_disp = mySeg;
  7248. my_struct->prev_data = mySeg;
  7249. my_struct->save_blank = False;
  7250. /*
  7251. * resolve the font hints.
  7252. */
  7253. if (_SdlFontModeResolve == my_struct->resolve_font)
  7254. (*(my_struct->ui_info->resolve_spc))(
  7255. my_struct->ui_info->client_data,
  7256. ElLanguage(my_struct),
  7257. ElCharSet(my_struct),
  7258. *(my_struct->my_fonts),
  7259. ElSpcName(my_struct),
  7260. &(_DtCvInfoOfRegionSeg(my_struct->add_seg)),
  7261. &(_DtCvWidthOfRegionSeg(my_struct->add_seg)),
  7262. &(_DtCvHeightOfRegionSeg(my_struct->add_seg)),
  7263. &(_DtCvAscentOfRegionSeg(my_struct->add_seg)));
  7264. else
  7265. {
  7266. _DtHelpDARegion *pReg;
  7267. _DtHelpDASpcInfo *spcInfo;
  7268. /*
  7269. * malloc a structure to hold the spc
  7270. */
  7271. pReg = (_DtHelpDARegion *) malloc (sizeof(_DtHelpDARegion));
  7272. if (NULL == pReg)
  7273. return -1;
  7274. /*
  7275. * malloc the structure to hold the information needed to
  7276. * create the spc later.
  7277. */
  7278. spcInfo = (_DtHelpDASpcInfo *) calloc (1, sizeof(_DtHelpDASpcInfo));
  7279. if (NULL == spcInfo)
  7280. {
  7281. free(pReg);
  7282. return -1;
  7283. }
  7284. /*
  7285. * remember the spc's name and fonts
  7286. */
  7287. spcInfo->name = ElSpcName(my_struct);
  7288. if (_SdlFontModeSave == my_struct->resolve_font)
  7289. {
  7290. spcInfo->spc_fonts = *(my_struct->my_fonts);
  7291. _DtHelpFontHintsLang(spcInfo->spc_fonts) =
  7292. ElLanguage(my_struct);
  7293. _DtHelpFontHintsCharSet(spcInfo->spc_fonts) =
  7294. ElCharSet(my_struct);
  7295. if (-1 == _DtHelpDupFontHints(&(spcInfo->spc_fonts)))
  7296. return -1;
  7297. }
  7298. /*
  7299. * remember the spc's name
  7300. */
  7301. pReg->inited = False;
  7302. pReg->type = _DtHelpDASpc;
  7303. pReg->handle = (_DtCvPointer) spcInfo;
  7304. _DtCvInfoOfRegionSeg(mySeg) = (_DtCvPointer) pReg;
  7305. ClearAttrFlag(my_struct->el_info, SDL_ATTR_NAME);
  7306. }
  7307. }
  7308. return 0;
  7309. } /* End ResolveSpcInfo */
  7310. /******************************************************************************
  7311. * Function: int CopyTossInfo (FormatStruct my_struct,
  7312. * int cur_element, exceptions);
  7313. *
  7314. * Parameters:
  7315. *
  7316. * Returns: 0 if successful, -1 if errors
  7317. *
  7318. * Purpose: Looks for the virtual page attributes.
  7319. *
  7320. ******************************************************************************/
  7321. static int
  7322. CopyTossInfo(
  7323. FormatStruct *my_struct,
  7324. SDLMask *cur_element,
  7325. enum SdlElement sig_element,
  7326. SDLMask *exceptions,
  7327. SDLMask *process_mask)
  7328. {
  7329. SDLTossInfo *tossInfo;
  7330. if (SDLSearchMask(process_mask, ElType(my_struct)) == False)
  7331. return 0;
  7332. tossInfo = (SDLTossInfo *) malloc (sizeof(SDLTossInfo));
  7333. if (NULL == tossInfo)
  7334. return -1;
  7335. /*
  7336. * save the flags
  7337. */
  7338. _SdlTossInfoPtrFlag1(tossInfo) = ElFlag1(my_struct);
  7339. _SdlTossInfoPtrFlag2(tossInfo) = ElFlag2(my_struct);
  7340. _SdlTossInfoPtrFlag3(tossInfo) = ElFlag3(my_struct);
  7341. _SdlTossInfoPtrFlag4(tossInfo) = ElFlag4(my_struct);
  7342. /*
  7343. * save the match data - level, ssi and class/clan.
  7344. */
  7345. _SdlTossInfoPtrRlevel(tossInfo) = ElLevel(my_struct);
  7346. _SdlTossInfoPtrSsi(tossInfo) = ElSsi(my_struct);
  7347. _SdlTossInfoPtrClan(tossInfo) = ElClan(my_struct);
  7348. /*
  7349. * save the table information (colj, colw) or the keystyle
  7350. * enter/exit data.
  7351. */
  7352. _SdlTossInfoPtrStr1(tossInfo) = ElString1(my_struct);
  7353. _SdlTossInfoPtrStr2(tossInfo) = ElString2(my_struct);
  7354. /*
  7355. * save the element type.
  7356. */
  7357. _SdlTossInfoPtrType(tossInfo) = ElType(my_struct);
  7358. /*
  7359. * save the fonts - even if this toss style doesn't specify fonts.
  7360. */
  7361. _SdlTossInfoPtrFontSpecs(tossInfo) = *(my_struct->my_fonts);
  7362. /*
  7363. * now clear string attributes
  7364. */
  7365. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SSI);
  7366. /*
  7367. * table specs.
  7368. */
  7369. ClearAttrFlag(my_struct->el_info, SDL_ATTR_COLW);
  7370. ClearAttrFlag(my_struct->el_info, SDL_ATTR_COLJ);
  7371. /*
  7372. * key style specs.
  7373. */
  7374. ClearAttrFlag(my_struct->el_info, SDL_ATTR_ENTER);
  7375. ClearAttrFlag(my_struct->el_info, SDL_ATTR_EXIT);
  7376. /*
  7377. * font specs
  7378. */
  7379. ClearAttrFlag(my_struct->el_info, SDL_ATTR_COLOR);
  7380. ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFD);
  7381. ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFDI);
  7382. ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFDB);
  7383. ClearAttrFlag(my_struct->el_info, SDL_ATTR_XLFDIB);
  7384. ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAM);
  7385. ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAMI);
  7386. ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAMB);
  7387. ClearAttrFlag(my_struct->el_info, SDL_ATTR_TYPENAMIB);
  7388. /*
  7389. * set the internal pointer
  7390. */
  7391. _SdlSegTossInfo(my_struct->add_seg) = (void *) tossInfo;
  7392. /*
  7393. * now re-initialize the font specifications back to the original
  7394. * values
  7395. */
  7396. *(my_struct->my_fonts) = DefFontInfo;
  7397. return 0;
  7398. } /* End CopyTossInfo */
  7399. /******************************************************************************
  7400. * Function: int CopyEntryInfo (FormatStruct my_struct,
  7401. * int cur_element, exceptions);
  7402. *
  7403. * Parameters:
  7404. *
  7405. * Returns: 0 if successful, -1 if errors
  7406. *
  7407. * Purpose: Looks for the virtual page attributes.
  7408. *
  7409. ******************************************************************************/
  7410. static int
  7411. CopyEntryInfo(
  7412. FormatStruct *my_struct,
  7413. SDLMask *cur_element,
  7414. enum SdlElement sig_element,
  7415. SDLMask *exceptions,
  7416. SDLMask *process_mask)
  7417. {
  7418. SDLEntryInfo *entryInfo;
  7419. if (SDLSearchMask(process_mask, ElType(my_struct)) == False)
  7420. return 0;
  7421. entryInfo = (SDLEntryInfo *) malloc (sizeof(SDLEntryInfo));
  7422. if (NULL == entryInfo)
  7423. return -1;
  7424. /*
  7425. * save the strings.
  7426. */
  7427. *entryInfo = ElEntryInfo(my_struct);
  7428. /*
  7429. * now clear the attributes
  7430. */
  7431. ClearAttrFlag(my_struct->el_info, SDL_ATTR_MAIN);
  7432. ClearAttrFlag(my_struct->el_info, SDL_ATTR_LOCS);
  7433. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SYNS);
  7434. ClearAttrFlag(my_struct->el_info, SDL_ATTR_SORT);
  7435. /*
  7436. * set the internal pointer
  7437. */
  7438. _SdlSegEntryInfo(my_struct->add_seg) = (void *) entryInfo;
  7439. return 0;
  7440. } /* End CopyEntryInfo */
  7441. /******************************************************************************
  7442. * Function: int InitLast (FormatStruct my_struct,
  7443. * int cur_element, exceptions);
  7444. *
  7445. * Parameters:
  7446. *
  7447. * Returns: 0 if successful, -1 if errors
  7448. *
  7449. * Purpose: Looks for the virtual page attributes.
  7450. *
  7451. ******************************************************************************/
  7452. static int
  7453. InitLast(
  7454. FormatStruct *my_struct,
  7455. SDLMask *cur_element,
  7456. enum SdlElement sig_element,
  7457. SDLMask *exceptions,
  7458. SDLMask *process_mask)
  7459. {
  7460. /*
  7461. * set the parsing flags
  7462. */
  7463. my_struct->last_was_space = True;
  7464. my_struct->last_was_mb = False;
  7465. my_struct->last_was_nl = False;
  7466. /*
  7467. * set the container type correctly.
  7468. */
  7469. if (NULL != my_struct->add_seg &&
  7470. (SdlTypeLiteral == ElFrmtType(my_struct) ||
  7471. SdlTypeLined == ElFrmtType(my_struct)))
  7472. _DtCvContainerTypeOfSeg(my_struct->add_seg) = _DtCvLITERAL;
  7473. return 0;
  7474. } /* End InitLast */
  7475. /******************************************************************************
  7476. * Function: int SetTransit (FormatStruct my_struct,
  7477. * int cur_element, exceptions);
  7478. *
  7479. * Parameters:
  7480. *
  7481. * Returns: 0 if successful, -1 if errors
  7482. *
  7483. * Purpose: Looks for the virtual page attributes.
  7484. *
  7485. ******************************************************************************/
  7486. static int
  7487. SetTransit(
  7488. FormatStruct *my_struct,
  7489. SDLMask *cur_element,
  7490. enum SdlElement sig_element,
  7491. SDLMask *exceptions,
  7492. SDLMask *process_mask)
  7493. {
  7494. if (ElTiming(my_struct) == SdlTimingAsync)
  7495. my_struct->resolve_font = _SdlFontModeNone;
  7496. return 0;
  7497. } /* End SetTransit */
  7498. /******************************************************************************
  7499. *
  7500. * Main Parsing Functions
  7501. *
  7502. *****************************************************************************/
  7503. /******************************************************************************
  7504. * Function: int ParseSDL (FormatStruct my_struct,
  7505. * int cur_element, int cur_execpt);
  7506. *
  7507. * Parameters:
  7508. *
  7509. * Returns: 0 if successful, -1 if errors
  7510. *
  7511. * Purpose: Parses a set of rules.
  7512. *
  7513. ******************************************************************************/
  7514. static int
  7515. ParseSDL(
  7516. FormatStruct *my_struct,
  7517. enum SdlElement cur_element,
  7518. enum SdlElement sig_element,
  7519. SDLMask *cur_except,
  7520. SDLMask *process_mask)
  7521. {
  7522. int i = 0;
  7523. int result = 0;
  7524. int oldLink = my_struct->cur_link;
  7525. enum SdlElement oldElType = ElType(my_struct);
  7526. _DtCvSegment *oldCurSeg = my_struct->last_seg;
  7527. _DtCvSegment *oldSeglist = my_struct->seg_list;
  7528. _DtCvSegment *oldAddSeg = my_struct->add_seg;
  7529. _DtCvSegment *ifPrevData = my_struct->prev_data;
  7530. _SdlFontMode saveFontMode = my_struct->resolve_font;
  7531. ElementInfo saveElInfo = my_struct->el_info;
  7532. _DtHelpFontHints *oldFontInfo = my_struct->my_fonts;
  7533. const SDLContent *content;
  7534. _DtCvContainer *activeFrmt = my_struct->active_frmt;
  7535. SDLMask oldMask[SDL_MASK_LEN];
  7536. SDLMask oldExcept[SDL_MASK_LEN];
  7537. _DtCvValue oldBlank = my_struct->save_blank;
  7538. _DtCvValue processFlag =
  7539. SDLSearchMask(process_mask, SdlElementCdata);
  7540. /*
  7541. * While this element is allowed normally in the content of
  7542. * the parent element, it it currently allowed?
  7543. */
  7544. if (SDLSearchMask(cur_except, cur_element) == True)
  7545. return -1;
  7546. /*
  7547. * special processing for CDATA elements
  7548. */
  7549. if (cur_element != SdlElementCdata)
  7550. {
  7551. my_struct->seg_list = NULL;
  7552. my_struct->last_seg = NULL;
  7553. my_struct->add_seg = NULL;
  7554. }
  7555. /*
  7556. * look in the master list for this element
  7557. */
  7558. while (i < MaxSDLElements && SdlElementList[i].sdl_element != cur_element)
  7559. i++;
  7560. /*
  7561. * Didn't find this element in the master list.
  7562. */
  7563. if (i >= MaxSDLElements)
  7564. return -1;
  7565. /*
  7566. * merge this element's exceptions with parent's list.
  7567. * save the old process mask.
  7568. */
  7569. SaveRestoreMask(oldExcept, cur_except);
  7570. MergeMasks(cur_except, SdlElementList[i].exceptions);
  7571. SaveRestoreMask(oldMask, process_mask);
  7572. /*
  7573. * the content for this element is...
  7574. */
  7575. content = SdlElementList[i].content;
  7576. /*
  7577. * check to see if we want to process this element
  7578. * If sig_element is set, parse the element and its content.
  7579. */
  7580. if (sig_element != SdlElementNone)
  7581. {
  7582. processFlag = False;
  7583. if (sig_element == cur_element)
  7584. {
  7585. processFlag = True;
  7586. sig_element = SdlElementNone;
  7587. SaveRestoreMask(process_mask, AllMaskSet);
  7588. }
  7589. }
  7590. /*
  7591. * If not CDATA, then have to get the element start string, attributes
  7592. * and ending markup tag.
  7593. */
  7594. if (cur_element != SdlElementCdata)
  7595. {
  7596. if (ParseElementStart(my_struct,SdlElementList[i],processFlag) != 0
  7597. ||
  7598. ParseElementAttr(my_struct,
  7599. cur_element,
  7600. SdlElementList[i].attrib_list,
  7601. SdlElementList[i].cdata_flag,
  7602. processFlag) != 0)
  7603. result = -1;
  7604. }
  7605. /*
  7606. * now parse the element's content
  7607. */
  7608. my_struct->faked_end = False;
  7609. ElType(my_struct) = cur_element;
  7610. while (result == 0 && content != NULL &&
  7611. SDLSearchMask(content->mask, SdlElementNone) == False)
  7612. {
  7613. result = (*(content->model))(my_struct, content->mask,
  7614. sig_element, cur_except, process_mask);
  7615. content++;
  7616. }
  7617. /*
  7618. * If not CDATA, get the element end markup and adjust some pointers
  7619. */
  7620. SaveRestoreMask(process_mask, oldMask);
  7621. SaveRestoreMask(cur_except , oldExcept);
  7622. if (cur_element != SdlElementCdata)
  7623. {
  7624. if (result == 0 && SdlElementList[i].element_end_str != NULL)
  7625. result = ParseElementEnd(my_struct, ifPrevData,
  7626. SdlElementList[i],
  7627. processFlag,
  7628. my_struct->faked_end);
  7629. else
  7630. {
  7631. /*
  7632. * free the attributes for this element.
  7633. */
  7634. FreeAttributes(ElType(my_struct),
  7635. &(my_struct->el_info), my_struct->my_fonts);
  7636. if (SdlElementList[i].new_fonts && FreeFontInfo(my_struct) == -1)
  7637. result = -1;
  7638. }
  7639. my_struct->last_seg = oldCurSeg;
  7640. my_struct->seg_list = oldSeglist;
  7641. if (result == 0 && my_struct->add_seg != NULL)
  7642. _DtHelpCeAddSegToList(my_struct->add_seg, &(my_struct->seg_list),
  7643. &(my_struct->last_seg));
  7644. my_struct->add_seg = oldAddSeg;
  7645. my_struct->cur_link = oldLink;
  7646. if (SdlElementLink == cur_element)
  7647. my_struct->save_blank = oldBlank;
  7648. my_struct->el_info = saveElInfo;
  7649. my_struct->my_fonts = oldFontInfo;
  7650. }
  7651. my_struct->active_frmt = activeFrmt;
  7652. my_struct->resolve_font = saveFontMode;
  7653. ElType(my_struct) = oldElType;
  7654. return result;
  7655. } /* End ParseSDL */
  7656. /******************************************************************************
  7657. * Function: int ProcessSDLMarkup (FormatStruct my_struct,
  7658. * int cur_element, int cur_execpt);
  7659. *
  7660. * Parameters:
  7661. *
  7662. * Returns: 0 if successful, -1 if errors
  7663. *
  7664. * Purpose: Parses a set of rules, looks through the result and changes
  7665. * bad options into good.
  7666. *
  7667. ******************************************************************************/
  7668. static int
  7669. ProcessSDLMarkup(
  7670. FormatStruct *my_struct,
  7671. enum SdlElement cur_element,
  7672. enum SdlElement sig_element,
  7673. SDLMask *cur_except,
  7674. SDLMask *process_mask)
  7675. {
  7676. int result = ParseSDL (my_struct, cur_element, sig_element, cur_except,
  7677. process_mask);
  7678. if (-1 != result)
  7679. PropagateJustification(my_struct->seg_list, _DtCvJUSTIFY_LEFT);
  7680. return result;
  7681. }
  7682. /******************************************************************************
  7683. * Function: int ProcessContent (
  7684. * FormatStruct *my_struct,
  7685. * const SDLContent *content,
  7686. * SDLMask *exceptions,
  7687. * SDLMask *process_mask);
  7688. *
  7689. * Parameters:
  7690. * my_struct Specifies specific informationg for this parse.
  7691. * content Specifies the content model to parse.
  7692. * exceptions Specifies the current elements excepted
  7693. * from being in the current content.
  7694. * process_mask Specifies which elements to save in memory.
  7695. *
  7696. * Returns: 0 if successful, -1 if errors
  7697. *
  7698. * Purpose:
  7699. ******************************************************************************/
  7700. static int
  7701. ProcessContent(
  7702. FormatStruct *my_struct,
  7703. const SDLContent *content,
  7704. enum SdlElement sig_element,
  7705. SDLMask *exceptions,
  7706. SDLMask *process_mask)
  7707. {
  7708. int result = 0;
  7709. while (result == 0 && content != NULL &&
  7710. SDLSearchMask(content->mask, SdlElementNone) == False)
  7711. {
  7712. result = (*(content->model))(my_struct, content->mask,
  7713. sig_element, exceptions, process_mask);
  7714. content++;
  7715. }
  7716. if (-1 != result)
  7717. PropagateJustification(my_struct->seg_list, _DtCvJUSTIFY_LEFT);
  7718. return result;
  7719. }
  7720. /******************************************************************************
  7721. * Function: int SearchForController (_DtCvSegment p_seg,
  7722. *
  7723. * Parameters:
  7724. *
  7725. * Returns: 0 if successful, -1 if errors
  7726. *
  7727. * Purpose: Parses a set of rules.
  7728. *
  7729. ******************************************************************************/
  7730. static _DtCvSegment *
  7731. SearchForController(
  7732. _DtCvSegment *p_seg)
  7733. {
  7734. while (NULL != p_seg &&
  7735. !(_DtCvIsSegContainer(p_seg) && _DtCvIsSegController(p_seg)))
  7736. p_seg = _DtCvNextSeg(p_seg);
  7737. return p_seg;
  7738. } /* End SearchForController */
  7739. /******************************************************************************
  7740. * Function: int FormatSDLTitle (
  7741. *
  7742. * Parameters:
  7743. *
  7744. * Returns: 0 if successful, -1 if errors
  7745. *
  7746. * Purpose: Parses a set of rules.
  7747. *
  7748. ******************************************************************************/
  7749. static int
  7750. FormatSDLTitle(
  7751. char *filename,
  7752. int offset,
  7753. int fd,
  7754. FormatStruct *my_struct)
  7755. {
  7756. int result = 0;
  7757. SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits;
  7758. /*
  7759. SDLMask processMask[SDL_MASK_LEN] = SDLInitMaskEleven( \
  7760. SdlElementTitle , SdlElementHead , \
  7761. SdlElementKey , SdlElementSphrase, \
  7762. SdlElementRev , SdlElementIf , \
  7763. SdlElementSpc , SdlElementAnchor , \
  7764. SdlElementLink , SdlElementSnRef , \
  7765. SdlElementCdata);
  7766. */
  7767. SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone);
  7768. /*
  7769. * set the volume name for the graphics.
  7770. */
  7771. my_struct->vol_name = filename;
  7772. /*
  7773. * can we seek to the correct place?
  7774. */
  7775. result = _DtHelpCeFileOpenAndSeek(filename, offset, fd,
  7776. &(my_struct->my_file), NULL);
  7777. if (result != -1)
  7778. {
  7779. result = ProcessSDLMarkup (my_struct, SdlElementTitle, SdlElementNone,
  7780. startExcept, processMask);
  7781. _DtHelpCeBufFileClose (my_struct->my_file, (fd == -1 ? True : False));
  7782. }
  7783. return result;
  7784. } /* End FormatSDLTitle */
  7785. /******************************************************************************
  7786. * Function: void SetGhostLink (
  7787. *
  7788. * Parameters:
  7789. *
  7790. * Returns:
  7791. *
  7792. * Purpose:
  7793. *
  7794. ******************************************************************************/
  7795. static int
  7796. SetGhostLink(
  7797. _DtCvLinkDb link_data,
  7798. _DtCvSegment *segments,
  7799. int link_idx)
  7800. {
  7801. while (segments != NULL)
  7802. {
  7803. if (!(_DtCvIsSegContainer(segments)))
  7804. {
  7805. if (_DtCvIsSegHyperText(segments))
  7806. {
  7807. _DtLinkDbRemoveLink(link_data, segments->link_idx);
  7808. segments->type = ClearSegLinks(segments);
  7809. }
  7810. segments->type = _DtCvSetTypeToGhostLink(segments->type);
  7811. segments->link_idx = link_idx;
  7812. }
  7813. else /* if (_DtCvIsSegContainer(segments)) */
  7814. SetGhostLink (link_data, _DtCvContainerListOfSeg(segments),
  7815. link_idx);
  7816. segments = _DtCvNextSeg(segments);
  7817. }
  7818. } /* End SetGhostLink */
  7819. /******************************************************************************
  7820. * Function: void CreateAsciiString ()
  7821. *
  7822. * Parameters:
  7823. *
  7824. * Returns:
  7825. *
  7826. * Purpose:
  7827. *
  7828. ******************************************************************************/
  7829. static void
  7830. CreateAsciiString(
  7831. _DtCvSegment *p_seg,
  7832. _DtCvSegment *snb,
  7833. _DtCvValue *nl_flag,
  7834. char **ret_string)
  7835. {
  7836. int newLen;
  7837. int len;
  7838. while (p_seg != NULL)
  7839. {
  7840. len = 1;
  7841. if (_DtCvIsSegString(p_seg))
  7842. {
  7843. if (*nl_flag == True)
  7844. {
  7845. if (*ret_string != NULL &&
  7846. (*ret_string)[strlen(*ret_string)-1] != ' ')
  7847. len++;
  7848. else
  7849. *nl_flag = False;
  7850. }
  7851. newLen = _DtCvStrLen(_DtCvStringOfStringSeg(p_seg),
  7852. _DtCvIsSegWideChar(p_seg));
  7853. if (_DtCvIsSegWideChar(p_seg))
  7854. newLen = newLen * MB_CUR_MAX;
  7855. len += newLen;
  7856. if (*ret_string == NULL)
  7857. {
  7858. *ret_string = (char *) malloc (len);
  7859. **ret_string = '\0';
  7860. }
  7861. else
  7862. {
  7863. len += strlen(*ret_string);
  7864. *ret_string = (char *) realloc (*ret_string, len);
  7865. }
  7866. if (*nl_flag == True)
  7867. strcat(*ret_string, " ");
  7868. /*
  7869. * back up to the insertion point.
  7870. */
  7871. len -= newLen;
  7872. len--;
  7873. /*
  7874. * wide char or single byte?
  7875. */
  7876. if (_DtCvIsSegWideChar(p_seg))
  7877. wcstombs(&((*ret_string)[len]),
  7878. (wchar_t *) _DtCvStringOfStringSeg(p_seg),
  7879. newLen + 1);
  7880. else
  7881. strcpy (&((*ret_string)[len]), _DtCvStringOfStringSeg(p_seg));
  7882. *nl_flag = False;
  7883. if (p_seg->next_disp == NULL)
  7884. *nl_flag = True;
  7885. }
  7886. else if (_DtCvIsSegContainer(p_seg) && !(_DtCvIsSegController(p_seg)))
  7887. CreateAsciiString(_DtCvContainerListOfSeg(p_seg),
  7888. snb, nl_flag, ret_string);
  7889. p_seg = _DtCvNextSeg(p_seg);
  7890. }
  7891. }
  7892. /******************************************************************************
  7893. * Function: void CreateAsciiAbbrev ()
  7894. *
  7895. * Parameters:
  7896. *
  7897. * Returns:
  7898. *
  7899. * Purpose:
  7900. *
  7901. ******************************************************************************/
  7902. static void
  7903. CreateAsciiAbbrev(
  7904. _DtCvSegment *p_el,
  7905. char **ret_abbrev)
  7906. {
  7907. *ret_abbrev = NULL;
  7908. if (NULL != AbbrevOfSeg(p_el) && strlen ((char *) AbbrevOfSeg(p_el)))
  7909. *ret_abbrev = strdup((char *) AbbrevOfSeg(p_el));
  7910. }
  7911. /******************************************************************************
  7912. * Function: void CleanUpToc ()
  7913. *
  7914. * Parameters:
  7915. * my_struct Specifies current formatting information.
  7916. * p_seg Specifies the current segment list to modify.
  7917. * level Specifes the parent element's level.
  7918. * lnk_indx Specifies the link index to use for the
  7919. * ghost link.
  7920. *
  7921. * Returns: nothing
  7922. *
  7923. * Purpose: Modifies the formatting information for conform to what
  7924. * it should be for a TOC and sets the ghost link.
  7925. *
  7926. ******************************************************************************/
  7927. static void
  7928. CleanUpToc(
  7929. FormatStruct *my_struct,
  7930. _DtCvSegment *p_seg,
  7931. int level,
  7932. _DtCvValue target)
  7933. {
  7934. level--;
  7935. if (level < 0)
  7936. level = 0;
  7937. while (p_seg != NULL)
  7938. {
  7939. if (_DtCvIsSegNewLine(p_seg))
  7940. p_seg->type = p_seg->type & ~(_DtCvNEW_LINE);
  7941. if (_DtCvIsSegContainer(p_seg))
  7942. {
  7943. _DtCvContainerPercentOfSeg(p_seg) = DefPercent;
  7944. _DtCvContainerOrientOfSeg(p_seg) = _DtCvJUSTIFY_LEFT_MARGIN;
  7945. _DtCvContainerFlowOfSeg(p_seg) = _DtCvWRAP_NONE;
  7946. _DtCvContainerTypeOfSeg(p_seg) = _DtCvLITERAL;
  7947. _DtCvContainerVJustifyOfSeg(p_seg) = _DtCvJUSTIFY_TOP;
  7948. _DtCvContainerJustifyOfSeg(p_seg) = _DtCvJUSTIFY_LEFT;
  7949. _DtCvContainerFMarginOfSeg(p_seg) = 0;
  7950. _DtCvContainerLMarginOfSeg(p_seg) =
  7951. level * 2 * my_struct->ui_info->avg_char;
  7952. _DtCvContainerRMarginOfSeg(p_seg) = 0;
  7953. _DtCvContainerTMarginOfSeg(p_seg) = 0;
  7954. _DtCvContainerBMarginOfSeg(p_seg) = 0;
  7955. CleanUpToc(my_struct, _DtCvContainerListOfSeg(p_seg),
  7956. level, target);
  7957. }
  7958. else if (_DtCvIsSegString(p_seg))
  7959. {
  7960. _DtHelpFontHints *font_specs = (_DtHelpFontHints *)_DtCvFontOfStringSeg(p_seg);
  7961. _DtHelpFontPtrPtSize(font_specs) = 10;
  7962. _DtHelpFontPtrWeight(font_specs) = _DtHelpFontWeightMedium;
  7963. if (target == True)
  7964. _DtHelpFontPtrWeight(font_specs) = _DtHelpFontWeightBold;
  7965. (my_struct->ui_info->load_font)(my_struct->ui_info->client_data,
  7966. _DtHelpFontHintsLang(*font_specs),
  7967. _DtHelpFontHintsCharSet(*font_specs),
  7968. *font_specs,
  7969. &(_DtCvFontOfStringSeg(p_seg)));
  7970. free(font_specs);
  7971. }
  7972. else if (_DtCvIsSegRegion(p_seg))
  7973. {
  7974. int result;
  7975. _DtHelpDARegion *pReg = (_DtHelpDARegion *) _DtCvInfoOfRegionSeg(p_seg);
  7976. if (_DtHelpDASpc == pReg->type)
  7977. {
  7978. _DtHelpDASpcInfo *pSpc = (_DtHelpDASpcInfo *) pReg->handle;
  7979. _DtHelpFontHintsPtSize(pSpc->spc_fonts) = 10;
  7980. _DtHelpFontHintsWeight(pSpc->spc_fonts) =
  7981. _DtHelpFontWeightMedium;
  7982. if (True == target)
  7983. _DtHelpFontHintsWeight(pSpc->spc_fonts) =
  7984. _DtHelpFontWeightBold;
  7985. result = (*(my_struct->ui_info->resolve_spc))(
  7986. my_struct->ui_info->client_data,
  7987. _DtHelpFontHintsLang(pSpc->spc_fonts),
  7988. _DtHelpFontHintsCharSet(pSpc->spc_fonts),
  7989. pSpc->spc_fonts,
  7990. pSpc->name,
  7991. &(_DtCvInfoOfRegionSeg(p_seg)),
  7992. &(_DtCvWidthOfRegionSeg(p_seg)),
  7993. &(_DtCvHeightOfRegionSeg(p_seg)),
  7994. &(_DtCvAscentOfRegionSeg(p_seg)));
  7995. if (0 != result)
  7996. p_seg->type = _DtCvSetTypeToNoop(p_seg->type);
  7997. free(pSpc->name);
  7998. _DtHelpFreeFontHints(&(pSpc->spc_fonts));
  7999. free(pSpc);
  8000. free(pReg);
  8001. }
  8002. }
  8003. p_seg = _DtCvNextSeg(p_seg);
  8004. }
  8005. }
  8006. /******************************************************************************
  8007. * Function: int AddEntryToToc ()
  8008. *
  8009. * Parameters:
  8010. *
  8011. * Returns:
  8012. *
  8013. * Purpose:
  8014. *
  8015. ******************************************************************************/
  8016. static int
  8017. AddEntryToToc(
  8018. FormatStruct *my_struct,
  8019. _DtHelpVolumeHdl volume,
  8020. int fd,
  8021. int level,
  8022. char *lang,
  8023. const char *char_set,
  8024. _DtCvSegment *toss,
  8025. _DtCvSegment *info_seg,
  8026. _DtCvValue target,
  8027. _DtCvSegment **ret_snb,
  8028. _DtCvSegment **seg_list,
  8029. _DtCvSegment **prev_list)
  8030. {
  8031. int result = 0;
  8032. _DtCvLinkDb saveLinks;
  8033. SDLIdInfo *info;
  8034. /*
  8035. * initialize the structure
  8036. * save some information that's going to be destroyed in the setup.
  8037. */
  8038. saveLinks = my_struct->my_links;
  8039. if (SetUp(NULL,NULL,my_struct,toss,my_struct->ui_info,fd,False,False) != 0)
  8040. return -1;
  8041. /*
  8042. * Initialize the standard/default to use
  8043. */
  8044. _DtHelpFontHintsLang(*(my_struct->my_fonts)) = lang;
  8045. _DtHelpFontHintsCharSet(*(my_struct->my_fonts)) = (char *) char_set;
  8046. /*
  8047. * free the new link database and restore the old one.
  8048. * set font mode to save and the id for graphics.
  8049. */
  8050. _DtLinkDbDestroy(my_struct->my_links);
  8051. my_struct->my_links = saveLinks;
  8052. my_struct->resolve_font = _SdlFontModeSave;
  8053. info = FrmtPrivInfoPtr(info_seg)->id_info;
  8054. result = FormatSDLTitle(_DtHelpCeGetVolumeName(volume),
  8055. _SdlIdInfoPtrOffset(info), fd, my_struct);
  8056. /*
  8057. * if no errors, continue
  8058. */
  8059. if (result != -1)
  8060. {
  8061. _DtCvSegment *headEl = NULL;
  8062. /*
  8063. * find the actual head element
  8064. */
  8065. if (my_struct->seg_list != NULL)
  8066. headEl = SearchForController(
  8067. _DtCvContainerListOfSeg(my_struct->seg_list));
  8068. /*
  8069. * If there isn't a head element, use the id.
  8070. */
  8071. if (headEl == NULL)
  8072. {
  8073. _DtCvSegment *addSeg = NULL;
  8074. if (MySaveString(&(addSeg), my_struct,
  8075. _DtCvContainerIdOfSeg(info_seg),
  8076. -1, my_struct->mb_len, False) != 0)
  8077. {
  8078. /*
  8079. * free the segments
  8080. */
  8081. _DtHelpFreeSegments(my_struct->seg_list, _DtCvTRUE,
  8082. my_struct->ui_info->destroy_region,
  8083. my_struct->ui_info->client_data);
  8084. my_struct->seg_list = NULL;
  8085. DestroyFontInfo(my_struct);
  8086. return -1;
  8087. }
  8088. /*
  8089. * if there is a virpage, attach the segment to it.
  8090. * I.e. just reuse the container.
  8091. */
  8092. if (NULL != my_struct->seg_list)
  8093. {
  8094. /*
  8095. * free the container original list
  8096. */
  8097. _DtHelpFreeSegments(
  8098. _DtCvContainerListOfSeg(my_struct->seg_list),
  8099. _DtCvTRUE,
  8100. my_struct->ui_info->destroy_region,
  8101. my_struct->ui_info->client_data);
  8102. }
  8103. else
  8104. {
  8105. /*
  8106. * create a container for the segment.
  8107. */
  8108. if (_DtHelpCeAllocSegment(my_struct->malloc_size,
  8109. &(my_struct->alloc_size),
  8110. &(my_struct->block_list),
  8111. &(my_struct->seg_list)) != 0)
  8112. {
  8113. _DtHelpFreeSegments(addSeg, _DtCvTRUE,
  8114. my_struct->ui_info->destroy_region,
  8115. my_struct->ui_info->client_data);
  8116. DestroyFontInfo(my_struct);
  8117. return -1;
  8118. }
  8119. /*
  8120. * set the container flag and initialize its formatting
  8121. * information to the default.
  8122. */
  8123. my_struct->seg_list->type =
  8124. _DtCvSetTypeToContainer(my_struct->seg_list->type);
  8125. _DtCvContainerOfSeg(my_struct->seg_list) = DefFrmtSpecs;
  8126. _DtCvContainerLeadingOfSeg(my_struct->seg_list) =
  8127. my_struct->ui_info->leading;
  8128. }
  8129. _DtCvContainerListOfSeg(my_struct->seg_list) = addSeg;
  8130. headEl = my_struct->seg_list;
  8131. }
  8132. /*
  8133. * there was a empty head, use the abbreviation or the id.
  8134. */
  8135. else if (_DtCvContainerListOfSeg(headEl) == NULL)
  8136. {
  8137. char *myPtr = (char *) AbbrevOfSeg(headEl);
  8138. if (NULL == myPtr)
  8139. myPtr = _DtCvContainerIdOfSeg(info_seg);
  8140. if (MySaveString(&(_DtCvContainerListOfSeg(headEl)), my_struct,
  8141. myPtr, -1, my_struct->mb_len, False) != 0)
  8142. {
  8143. /*
  8144. * free the segments
  8145. */
  8146. _DtHelpFreeSegments(my_struct->seg_list, _DtCvTRUE,
  8147. my_struct->ui_info->destroy_region,
  8148. my_struct->ui_info->client_data);
  8149. my_struct->seg_list = NULL;
  8150. DestroyFontInfo(my_struct);
  8151. return -1;
  8152. }
  8153. }
  8154. /*
  8155. * Make sure we only use the first head.
  8156. * first make sure that the segment list is not the head already.
  8157. */
  8158. if (headEl != my_struct->seg_list)
  8159. {
  8160. _DtCvSegment *prevSeg;
  8161. /*
  8162. * destroy the segments after this one.
  8163. */
  8164. _DtHelpFreeSegments(_DtCvNextSeg(headEl), _DtCvTRUE,
  8165. my_struct->ui_info->destroy_region,
  8166. my_struct->ui_info->client_data);
  8167. /*
  8168. * break the link to the freed segments
  8169. */
  8170. _DtCvNextSeg(headEl) = NULL;
  8171. /*
  8172. * destroy the segments before this one.
  8173. */
  8174. prevSeg = _DtCvContainerListOfSeg(my_struct->seg_list);
  8175. if (prevSeg != headEl)
  8176. {
  8177. /*
  8178. * search for the previous segment before the head.
  8179. */
  8180. while (_DtCvNextSeg(prevSeg) != headEl)
  8181. prevSeg = _DtCvNextSeg(prevSeg);
  8182. /*
  8183. * break the link to the head element
  8184. */
  8185. _DtCvNextSeg(prevSeg) = NULL;
  8186. }
  8187. else
  8188. _DtCvContainerListOfSeg(my_struct->seg_list) = NULL;
  8189. /*
  8190. * free the segments before the head and virpage container.
  8191. */
  8192. _DtHelpFreeSegments(my_struct->seg_list, _DtCvTRUE,
  8193. my_struct->ui_info->destroy_region,
  8194. my_struct->ui_info->client_data);
  8195. my_struct->seg_list = headEl;
  8196. }
  8197. if (headEl != NULL)
  8198. {
  8199. int linkIndex = _DtLinkDbAddLink(my_struct->my_links, NULL,
  8200. _DtCvContainerIdOfSeg(info_seg),
  8201. _DtCvLinkType_SameVolume,
  8202. _DtCvWindowHint_CurrentWindow, NULL);
  8203. CleanUpToc(my_struct, headEl, level, target);
  8204. SetGhostLink(my_struct->my_links, headEl, linkIndex);
  8205. }
  8206. }
  8207. if (result != -1)
  8208. {
  8209. /*
  8210. * now tack this segment onto the end of the list
  8211. */
  8212. if ((*seg_list) == NULL)
  8213. (*seg_list) = my_struct->seg_list;
  8214. else
  8215. _DtCvNextSeg((*prev_list)) = my_struct->seg_list;
  8216. *prev_list = my_struct->seg_list;
  8217. while ((*prev_list) != NULL && _DtCvNextSeg((*prev_list)) != NULL)
  8218. *prev_list = _DtCvNextSeg((*prev_list));
  8219. }
  8220. /*
  8221. * if the snb for this topic was read, free it now.
  8222. */
  8223. if (my_struct->snb != NULL)
  8224. {
  8225. _DtHelpFreeSegments(my_struct->snb, _DtCvTRUE,
  8226. my_struct->ui_info->destroy_region,
  8227. my_struct->ui_info->client_data);
  8228. my_struct->snb = NULL;
  8229. }
  8230. /*
  8231. * free the font structures allocated
  8232. */
  8233. DestroyFontInfo(my_struct);
  8234. return result;
  8235. }
  8236. /******************************************************************************
  8237. * Function: int ExpandToc ()
  8238. *
  8239. * Parameters:
  8240. *
  8241. * Returns:
  8242. *
  8243. * Purpose:
  8244. *
  8245. ******************************************************************************/
  8246. static int
  8247. ExpandToc(
  8248. FormatStruct *my_struct,
  8249. _DtHelpVolumeHdl volume,
  8250. int fd,
  8251. char *lang,
  8252. const char *char_set,
  8253. _DtCvSegment *toss,
  8254. int level,
  8255. char **path_list,
  8256. _DtCvSegment **id_seg,
  8257. _DtCvSegment **ret_snb,
  8258. _DtCvSegment **seg_list,
  8259. _DtCvSegment **prev_list)
  8260. {
  8261. int result = 0;
  8262. int segLev;
  8263. int tst = 1;
  8264. _DtCvSegment *pEl;
  8265. _DtCvValue done = False;
  8266. _DtCvValue found = False;
  8267. /*
  8268. * skip anything that isn't a virpage and of the correct level.
  8269. */
  8270. while ((*id_seg) != NULL && _SdlSegToSdlIdInfoType(*id_seg) != SdlIdVirpage
  8271. && _SdlSegToSdlIdInfoLevel(*id_seg) != level)
  8272. *id_seg = _DtCvNextSeg((*id_seg));
  8273. /*
  8274. * process any virpage that has the correct level
  8275. */
  8276. while ((*id_seg) != NULL && done == False && result == 0)
  8277. {
  8278. pEl = (*id_seg);
  8279. segLev = _SdlSegToSdlIdInfoLevel(pEl);
  8280. if (_SdlSegToSdlIdInfoType(pEl) == SdlIdVirpage)
  8281. {
  8282. if (segLev == level)
  8283. {
  8284. /*
  8285. * If the virpage in the path list has not been found,
  8286. * test the next virpage. Otherwise skip.
  8287. */
  8288. if (found == False && *path_list != NULL &&
  8289. _DtCvContainerIdOfSeg(pEl) != NULL)
  8290. tst = _DtCvStrCaseCmpLatin1(*path_list,
  8291. _DtCvContainerIdOfSeg(pEl));
  8292. /*
  8293. * the only time tst == 0 is when the next item in the
  8294. * path_list matches this element. Check to see if the
  8295. * next item in the path_list is null. If so, that
  8296. * means this is the location the user has desired.
  8297. */
  8298. result = AddEntryToToc(my_struct, volume, fd,
  8299. segLev, lang, char_set, toss, pEl,
  8300. (tst == 0 && path_list[1] == NULL ? True : False),
  8301. ret_snb, seg_list, prev_list);
  8302. /*
  8303. * increment the segment pointer to the next item
  8304. */
  8305. *id_seg = _DtCvNextSeg((*id_seg));
  8306. /*
  8307. * The only time tst is zero is if the current virpage
  8308. * matches the next item in the list. Expand it's children.
  8309. * and set tst to non-zero so that AddEntryToToc does not
  8310. * special case the siblings following this one.
  8311. */
  8312. if (tst == 0)
  8313. {
  8314. result = ExpandToc(my_struct, volume, fd, lang,
  8315. char_set, toss,
  8316. segLev + 1,
  8317. &path_list[1],
  8318. id_seg, ret_snb, seg_list, prev_list);
  8319. found = True;
  8320. tst = 1;
  8321. }
  8322. }
  8323. else if (segLev < level)
  8324. done = True;
  8325. else
  8326. *id_seg = _DtCvNextSeg((*id_seg));
  8327. }
  8328. else
  8329. *id_seg = _DtCvNextSeg((*id_seg));
  8330. }
  8331. return result;
  8332. } /* ExpandToc */
  8333. /******************************************************************************
  8334. * Function: void CreateTitleChunks ()
  8335. *
  8336. * Parameters:
  8337. *
  8338. * Returns:
  8339. *
  8340. * Purpose:
  8341. *
  8342. ******************************************************************************/
  8343. static int
  8344. CreateTitleChunks(
  8345. _DtCvSegment *toss,
  8346. _DtCvSegment *p_seg,
  8347. _DtCvSegment *snb,
  8348. SDLMask *stop_mask,
  8349. const char *lang,
  8350. const char *char_set,
  8351. _DtCvValue (*resolve_spc)(),
  8352. _DtCvPointer client_data,
  8353. int *ret_cnt,
  8354. void ***ret_chunks)
  8355. {
  8356. long type;
  8357. int cnt;
  8358. int result = 0;
  8359. const char *myLang;
  8360. const char *mySet;
  8361. void *ptr;
  8362. _DtHelpDARegion *daRegion;
  8363. while (result != -1 && p_seg != NULL)
  8364. {
  8365. myLang = lang;
  8366. mySet = char_set;
  8367. cnt = *ret_cnt;
  8368. if (_DtCvIsSegString(p_seg))
  8369. {
  8370. if (*ret_cnt == 0)
  8371. *ret_cnt = 1;
  8372. else
  8373. cnt--;
  8374. *ret_cnt = *ret_cnt + 3;
  8375. if (*ret_chunks == NULL)
  8376. *ret_chunks = (void **) malloc (sizeof(void *) * (*ret_cnt));
  8377. else
  8378. *ret_chunks = (void **) realloc (*ret_chunks,
  8379. sizeof(void *) * (*ret_cnt));
  8380. if (*ret_chunks == NULL)
  8381. return -1;
  8382. type = DT_HELP_CE_FONT_PTR | DT_HELP_CE_STRING;
  8383. ptr = _DtCvFontOfStringSeg(p_seg);
  8384. if (p_seg->next_disp == NULL || _DtCvIsSegNewLine(p_seg))
  8385. type |= DT_HELP_CE_NEWLINE;
  8386. (*ret_chunks)[cnt++] = (void *) type;
  8387. (*ret_chunks)[cnt++] = (void *) ptr;
  8388. if (_DtCvIsSegWideChar(p_seg))
  8389. {
  8390. int len = _DtCvStrLen(_DtCvStringOfStringSeg(p_seg), 1)
  8391. * MB_CUR_MAX + 1;
  8392. ptr = malloc (sizeof(char *) * len);
  8393. if (NULL != ptr)
  8394. wcstombs((char *) ptr,
  8395. (wchar_t *) _DtCvStringOfStringSeg(p_seg), len);
  8396. }
  8397. else
  8398. ptr = strdup(_DtCvStringOfStringSeg(p_seg));
  8399. (*ret_chunks)[cnt++] = (void *) ptr;
  8400. if ((*ret_chunks)[cnt-1] == NULL)
  8401. return -1;
  8402. (*ret_chunks)[cnt++] = (void *) DT_HELP_CE_END;
  8403. }
  8404. else if (_DtCvIsSegRegion(p_seg))
  8405. {
  8406. daRegion = (_DtHelpDARegion *) _DtCvInfoOfRegionSeg(p_seg);
  8407. if (_DtHelpDASpc == daRegion->type)
  8408. {
  8409. if (False == daRegion->inited)
  8410. {
  8411. _DtHelpDASpcInfo *pSpc =
  8412. (_DtHelpDASpcInfo *) daRegion->handle;
  8413. /*
  8414. * allocate the spc!
  8415. */
  8416. result = (*(resolve_spc))(
  8417. client_data,
  8418. _DtHelpFontHintsLang(pSpc->spc_fonts),
  8419. _DtHelpFontHintsCharSet(pSpc->spc_fonts),
  8420. pSpc->spc_fonts,
  8421. pSpc->name,
  8422. &(_DtCvInfoOfRegionSeg(p_seg)),
  8423. &(_DtCvWidthOfRegionSeg(p_seg)),
  8424. &(_DtCvHeightOfRegionSeg(p_seg)),
  8425. &(_DtCvAscentOfRegionSeg(p_seg)));
  8426. free(pSpc->name);
  8427. _DtHelpFreeFontHints(&(pSpc->spc_fonts));
  8428. free(pSpc);
  8429. free(daRegion);
  8430. if (0 != result)
  8431. return -1;
  8432. daRegion = (_DtHelpDARegion *) _DtCvInfoOfRegionSeg(p_seg);
  8433. }
  8434. if (*ret_cnt == 0)
  8435. *ret_cnt = 1;
  8436. else
  8437. cnt--;
  8438. *ret_cnt = *ret_cnt + 2;
  8439. if (*ret_chunks == NULL)
  8440. *ret_chunks = (void **) malloc (sizeof(void *) * *ret_cnt);
  8441. else
  8442. *ret_chunks = (void **) realloc (*ret_chunks,
  8443. sizeof(void *) * *ret_cnt);
  8444. if (*ret_chunks == NULL)
  8445. return -1;
  8446. type = DT_HELP_CE_SPC;
  8447. if (p_seg->next_disp == NULL || _DtCvIsSegNewLine(p_seg))
  8448. type |= DT_HELP_CE_NEWLINE;
  8449. (*ret_chunks)[cnt++] = (void *) type;
  8450. (*ret_chunks)[cnt++] = (void *) daRegion->handle;
  8451. (*ret_chunks)[cnt++] = (void *) DT_HELP_CE_END;
  8452. }
  8453. result = 0;
  8454. }
  8455. else if (_DtCvIsSegContainer(p_seg) && !(_DtCvIsSegController(p_seg)))
  8456. result = CreateTitleChunks(toss,
  8457. _DtCvContainerListOfSeg(p_seg), snb,
  8458. stop_mask,
  8459. myLang, mySet,
  8460. resolve_spc,
  8461. client_data,
  8462. ret_cnt, ret_chunks);
  8463. p_seg = _DtCvNextSeg(p_seg);
  8464. }
  8465. return result;
  8466. }
  8467. /******************************************************************************
  8468. * Function: int ProcessSegmentsToChunks ()
  8469. *
  8470. * Parameters:
  8471. *
  8472. * Returns: 0 if created a chunk, -1 if errors
  8473. *
  8474. * Purpose:
  8475. *
  8476. ******************************************************************************/
  8477. static int
  8478. ProcessSegmentsToChunks(
  8479. _DtCvSegment *toss,
  8480. _DtCvSegment *head_el,
  8481. _DtCvSegment *snb_el,
  8482. SDLMask *stop_mask,
  8483. const char *lang,
  8484. const char *char_set,
  8485. _DtCvValue (*resolve_spc)(),
  8486. _DtCvPointer client_data,
  8487. void ***ret_chunks)
  8488. {
  8489. int cnt = 0;
  8490. int result = 0;
  8491. result = CreateTitleChunks(toss, _DtCvContainerListOfSeg(head_el),
  8492. snb_el, stop_mask, lang, char_set,
  8493. resolve_spc, client_data,
  8494. &cnt, ret_chunks);
  8495. if ((result != 0 || cnt == 0) && NULL != AbbrevOfSeg(head_el)
  8496. && strlen ((char *) AbbrevOfSeg(head_el)))
  8497. {
  8498. *ret_chunks = (void **) malloc (sizeof(void *) * 4);
  8499. if (*ret_chunks == NULL)
  8500. return -1;
  8501. (*ret_chunks)[0] = (void *) DT_HELP_CE_CHARSET;
  8502. (*ret_chunks)[1] = (void *) strdup(char_set);
  8503. (*ret_chunks)[2] = (void *) strdup(AbbrevOfSeg(head_el));
  8504. (*ret_chunks)[3] = (void *) DT_HELP_CE_END;
  8505. }
  8506. return result;
  8507. }
  8508. /******************************************************************************
  8509. * Function: _DtCvSegment *GetSdlDocSnb (
  8510. * _DtHelpVolumeHdl volume)
  8511. * Parameters:
  8512. * volume Specifies the volume.
  8513. *
  8514. * Returns: 0 if successful, -1 if errors
  8515. *
  8516. * Purpose: If the title has been parsed and it used snrefs,
  8517. * this function will return the snb specified in the
  8518. * sdldoc element.
  8519. ******************************************************************************/
  8520. static _DtCvSegment *
  8521. GetSdlDocSnb(
  8522. _DtHelpVolumeHdl volume)
  8523. {
  8524. _DtCvSegment *retEl = NULL;
  8525. CESDLVolume *sdlVol;
  8526. sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
  8527. if (sdlVol != NULL && sdlVol->snb != NULL)
  8528. retEl = (sdlVol->snb);
  8529. return retEl;
  8530. }
  8531. /******************************************************************************
  8532. * Function: int GetDocumentTitle (
  8533. * _DtHelpVolumeHdl volume,
  8534. * _DtCvValue flag,
  8535. * _DtCvSegment **ret_seg)
  8536. * Parameters:
  8537. * volume Specifies the volume.
  8538. * flag Specifies if the toss is needed.
  8539. * ret_seg Returns sdlVol->title.
  8540. *
  8541. * Returns: 0 if successful, -1 if errors, -2 if there is no title.
  8542. *
  8543. * Purpose: This will fill in the 'title' and 'snb' elements of
  8544. * the CESDLVolume structure and return 'title' in 'ret_seg'.
  8545. ******************************************************************************/
  8546. static int
  8547. GetDocumentTitle(
  8548. _DtHelpVolumeHdl volume,
  8549. _FrmtUiInfo *ui_info,
  8550. _SdlFontMode mode,
  8551. _DtCvValue flag,
  8552. _DtCvSegment **ret_seg)
  8553. {
  8554. int result = -1;
  8555. short procFlag = True;
  8556. CESDLVolume *sdlVol;
  8557. FormatStruct frmtStruct;
  8558. _DtCvSegment *toss = NULL;
  8559. SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits;
  8560. SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits;
  8561. SDLMask startExcept[SDL_MASK_LEN] =
  8562. SDLInitMask(SdlElementNone);
  8563. sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
  8564. if (sdlVol == NULL)
  8565. return -1;
  8566. if (sdlVol->title_processed == False)
  8567. {
  8568. if (flag == True)
  8569. toss = _DtHelpCeGetSdlVolToss(volume, -1);
  8570. if (SetUp(volume,NULL,&frmtStruct,toss,ui_info,-1,True,False) !=0 )
  8571. return -1;
  8572. /*
  8573. * now set up correct font mode.
  8574. */
  8575. frmtStruct.resolve_font = mode;
  8576. /*
  8577. * now get the title.
  8578. */
  8579. if (_DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, -1,
  8580. &(frmtStruct.my_file), NULL) != -1)
  8581. {
  8582. if (ProcessContent(&frmtStruct, SDLDocumentContent,
  8583. SdlElementNone, startExcept, skipMask) != -1
  8584. && ProcessSDLMarkup(&frmtStruct, SdlElementVStruct,
  8585. SdlElementNone, startExcept, skipMask) != -1
  8586. && ProcessContent(&frmtStruct, HeadAndSnb,
  8587. SdlElementNone, startExcept, processMask) != -1)
  8588. {
  8589. sdlVol->title = frmtStruct.seg_list;
  8590. sdlVol->snb = frmtStruct.snb;
  8591. sdlVol->client_data = ui_info->client_data;
  8592. sdlVol->destroy_region = ui_info->destroy_region;
  8593. result = 0;
  8594. /*
  8595. * if the volume doesn't have a head, set the
  8596. * appropriate flags.
  8597. */
  8598. if (NULL == sdlVol->title)
  8599. {
  8600. procFlag = -1; /* processed with no errors */
  8601. result = -2; /* but no title */
  8602. }
  8603. }
  8604. else /* free the segments */
  8605. _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE,
  8606. ui_info->destroy_region,
  8607. ui_info->client_data);
  8608. _DtHelpCeBufFileClose (frmtStruct.my_file, True);
  8609. }
  8610. /*
  8611. * free the font structures allocated
  8612. */
  8613. DestroyFontInfo(&frmtStruct);
  8614. /*
  8615. * destroy the link database
  8616. */
  8617. _DtLinkDbDestroy(frmtStruct.my_links);
  8618. sdlVol->title_processed = procFlag;
  8619. }
  8620. /*
  8621. * if we have a title, good
  8622. */
  8623. else if (sdlVol->title != NULL)
  8624. result = 0;
  8625. /*
  8626. * we haven't processed a title. Is is because the volume
  8627. * doesn't have one or because of problems accessing the volume?
  8628. */
  8629. else if (-1 == sdlVol->title_processed)
  8630. result = -2; /* volume doesn't have a title */
  8631. *ret_seg = sdlVol->title;
  8632. return result;
  8633. }
  8634. /******************************************************************************
  8635. *
  8636. * Semi-Private Functions
  8637. *
  8638. *****************************************************************************/
  8639. /******************************************************************************
  8640. * Function: SDLAttribute *_DtHelpCeGetSdlAttributeList(void)
  8641. *
  8642. * Parameters:
  8643. *
  8644. * Returns: ptr or NULL;
  8645. *
  8646. * Purpose:
  8647. ******************************************************************************/
  8648. const SDLAttribute *
  8649. _DtHelpCeGetSdlAttributeList(void)
  8650. {
  8651. const SDLAttribute *ptr = SDLAttributeList;
  8652. return ptr;
  8653. }
  8654. /******************************************************************************
  8655. *
  8656. * Semi-Public Functions
  8657. *
  8658. *****************************************************************************/
  8659. /******************************************************************************
  8660. * Function: int _DtHelpCeFrmtSDLPathAndChildren (
  8661. * _DtHelpVolumeHdl volume, char *filename,
  8662. * int offset, char *id_string,
  8663. * _DtCvTopicPtr *ret_handle)
  8664. *
  8665. * Parameters:
  8666. * volume Specifies the Help Volume the information
  8667. * is associated with.
  8668. * filename Specifies the file containing the Help Topic
  8669. * desired.
  8670. * offset Specifies the offset into 'filename' to
  8671. * the Help Topic desired.
  8672. * id_string Specifies the location id to look for or NULL.
  8673. * ret_handle Returns a handle to the topic information
  8674. * including the number of paragraphs and the
  8675. * id match segment.
  8676. *
  8677. * Returns: 0 if successful, -1 if errors, 1 if the path is empty.
  8678. *
  8679. ******************************************************************************/
  8680. int
  8681. _DtHelpCeFrmtSdlPathAndChildren(
  8682. _DtHelpVolumeHdl volume,
  8683. _FrmtUiInfo *ui_info,
  8684. int fd,
  8685. char *target_id,
  8686. _DtCvTopicPtr *ret_handle)
  8687. {
  8688. char *lang;
  8689. const char *charSet;
  8690. char **topicMap;
  8691. int result = 0;
  8692. int pathCnt;
  8693. FormatStruct frmtStruct;
  8694. _DtCvTopicInfo *topicHandle;
  8695. _DtCvSegment *mySegList = NULL;
  8696. _DtCvSegment *myPrevSeg = NULL;
  8697. _DtCvSegment *loids;
  8698. _DtCvSegment *snb = NULL;
  8699. SDLIdInfo *info;
  8700. *ret_handle = NULL;
  8701. /*
  8702. * look for the heading for each virpage
  8703. */
  8704. frmtStruct = DefFormatStruct;
  8705. frmtStruct.ui_info = ui_info;
  8706. frmtStruct.my_links = _DtLinkDbCreate();
  8707. frmtStruct.vol_name = _DtHelpCeGetVolumeName(volume);
  8708. frmtStruct.id_string = target_id;
  8709. /*
  8710. * get the path from the target to the top.
  8711. */
  8712. pathCnt = _DtHelpCeGetSdlIdPath(volume, target_id, &topicMap);
  8713. if (pathCnt == -1)
  8714. return -1;
  8715. /*
  8716. * get the beginning of the path
  8717. */
  8718. loids = _DtHelpCeMapSdlIdToSegment(volume, *topicMap, fd);
  8719. if (loids == NULL)
  8720. {
  8721. _DtCvFreeArray((void **) topicMap);
  8722. return -1;
  8723. }
  8724. /*
  8725. * format the top topic entry.
  8726. */
  8727. info = FrmtPrivInfoPtr(loids)->id_info;
  8728. if (_SdlIdInfoPtrRlevel(info) > 0)
  8729. {
  8730. /*
  8731. * Put the top topic in the table of contents.
  8732. */
  8733. lang = _DtHelpCeGetSdlVolLanguage(volume);
  8734. charSet = _DtHelpCeGetSdlVolCharSet(volume);
  8735. result = AddEntryToToc(&frmtStruct, volume, fd,
  8736. _SdlIdInfoPtrRlevel(info), lang, charSet,
  8737. _DtHelpCeGetSdlVolToss(volume, fd),
  8738. loids, (topicMap[1] == NULL ? True : False),
  8739. &snb, &mySegList, &myPrevSeg);
  8740. /*
  8741. * format the children.
  8742. */
  8743. if (result != -1 && _DtCvNextSeg(loids) != NULL)
  8744. {
  8745. loids = _DtCvNextSeg(loids);
  8746. result = ExpandToc(&frmtStruct, volume, fd, lang, charSet,
  8747. _DtHelpCeGetSdlVolToss(volume, fd),
  8748. _SdlIdInfoPtrRlevel(info) + 1,
  8749. &topicMap[1],
  8750. &loids, &snb, &mySegList, &myPrevSeg);
  8751. }
  8752. }
  8753. if (result != -1)
  8754. {
  8755. topicHandle = (_DtCvTopicInfo *) malloc (sizeof(_DtCvTopicInfo));
  8756. if (topicHandle != NULL)
  8757. {
  8758. topicHandle->id_str = NULL;
  8759. topicHandle->mark_list = NULL;
  8760. topicHandle->link_data = frmtStruct.my_links;
  8761. topicHandle->seg_list = (void *) mySegList;
  8762. /*
  8763. * let the top level know that there isn't a path
  8764. */
  8765. if (NULL == mySegList)
  8766. result = 1;
  8767. *ret_handle = (void *) topicHandle;
  8768. }
  8769. else
  8770. result = -1;
  8771. }
  8772. _DtCvFreeArray((void **) topicMap);
  8773. return result;
  8774. } /* End _DtHelpCeFrmtSDLPathAndChildren */
  8775. /******************************************************************************
  8776. * Function: int _DtHelpCeFrmtSdlVolumeInfo (char *filename,
  8777. * _DtCvTopicPtr *ret_handle)
  8778. *
  8779. * Parameters:
  8780. * filename Specifies the file containing the Help Topic
  8781. * desired.
  8782. * ret_handle Returns a handle to the topic information
  8783. * including the number of paragraphs and the
  8784. * id match segment.
  8785. *
  8786. * Returns: 0 if successful, -1 if errors
  8787. *
  8788. * Purpose: _DtHelpCeFrmtSdlVolumeInfo processes the SDL volume looking
  8789. * for the generated items.
  8790. *
  8791. ******************************************************************************/
  8792. int
  8793. _DtHelpCeFrmtSdlVolumeInfo(
  8794. char *filename,
  8795. _DtHelpVolumeHdl volume,
  8796. time_t *ret_time)
  8797. {
  8798. int result = 0;
  8799. char *numPtr;
  8800. CESDLVolume *sdlVol;
  8801. FormatStruct frmtStruct;
  8802. SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits;
  8803. SDLMask startExcept[SDL_MASK_LEN] =
  8804. SDLInitMask(SdlElementNone);
  8805. if (SetUp(volume,&sdlVol,&frmtStruct,NULL,&DefUiInfo,-1,True,False) != 0)
  8806. return -1;
  8807. /*
  8808. * now set up correct font mode.
  8809. */
  8810. frmtStruct.resolve_font = _SdlFontModeNone;
  8811. if (result == 0)
  8812. {
  8813. result = _DtHelpCeFileOpenAndSeek(filename, 0, -1,
  8814. &(frmtStruct.my_file), ret_time);
  8815. if (result != -1)
  8816. {
  8817. result = ProcessContent(&frmtStruct, SDLDocumentContent,
  8818. SdlElementNone, startExcept, processMask);
  8819. _DtHelpCeBufFileClose (frmtStruct.my_file, True);
  8820. if (frmtStruct.remember != NULL)
  8821. free(frmtStruct.remember);
  8822. }
  8823. if (result != -1)
  8824. {
  8825. /*
  8826. * attach the information to this volume.
  8827. */
  8828. sdlVol->sdl_info = (SDLDocInfo *)
  8829. FrmtPrivInfoPtr(frmtStruct.seg_list)->doc_info;
  8830. /*
  8831. * check the major and minor numbers.
  8832. */
  8833. numPtr = _SdlDocInfoPtrSdlDtd(sdlVol->sdl_info);
  8834. while (*numPtr < '0' || *numPtr > '9')
  8835. numPtr++;
  8836. if (atoi(numPtr) != SDL_DTD_VERSION)
  8837. result = -1;
  8838. else
  8839. {
  8840. while (*numPtr != '.' && *numPtr != '\0')
  8841. numPtr++;
  8842. if (*numPtr == '.')
  8843. numPtr++;
  8844. sdlVol->minor_no = atoi(numPtr);
  8845. }
  8846. /*
  8847. * free the container
  8848. */
  8849. FrmtPrivInfoPtr(frmtStruct.seg_list)->doc_info = NULL;
  8850. _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE, NULL, NULL);
  8851. }
  8852. }
  8853. _DtLinkDbDestroy(frmtStruct.my_links);
  8854. /*
  8855. * free the font structures allocated
  8856. */
  8857. DestroyFontInfo(&frmtStruct);
  8858. return result;
  8859. }
  8860. /******************************************************************************
  8861. * Function: int _DtHelpCeFrmtSDLTitleToAscii (
  8862. * char *filename,
  8863. * int offset,
  8864. * char **ret_title, char **ret_abbrev)
  8865. *
  8866. * Parameters:
  8867. *
  8868. * Returns: 0 if successful, -1 if errors
  8869. *
  8870. * Purpose:
  8871. ******************************************************************************/
  8872. int
  8873. _DtHelpCeFrmtSDLTitleToAscii(
  8874. _DtHelpVolumeHdl volume,
  8875. int offset,
  8876. char **ret_title,
  8877. char **ret_abbrev)
  8878. {
  8879. int result = 0;
  8880. FormatStruct frmtStruct;
  8881. if (SetUp(volume,NULL,&frmtStruct,NULL,&DefUiInfo,-1,True,False) != 0)
  8882. return -1;
  8883. *ret_title = NULL;
  8884. if (ret_abbrev != NULL)
  8885. *ret_abbrev = NULL;
  8886. /*
  8887. * now set up correct font mode.
  8888. */
  8889. frmtStruct.resolve_font = _SdlFontModeNone;
  8890. /*
  8891. * get the title.
  8892. */
  8893. result = FormatSDLTitle(frmtStruct.vol_name, offset, -1, &frmtStruct);
  8894. if (result != -1 && frmtStruct.seg_list != NULL)
  8895. {
  8896. _DtCvSegment *pHeadSeg;
  8897. _DtCvValue nlFlag = False;
  8898. pHeadSeg = _DtCvContainerListOfSeg(frmtStruct.seg_list);
  8899. if (pHeadSeg != NULL)
  8900. {
  8901. CreateAsciiString(_DtCvContainerListOfSeg(pHeadSeg),
  8902. frmtStruct.snb, &nlFlag, ret_title);
  8903. CreateAsciiAbbrev(pHeadSeg, ret_abbrev);
  8904. }
  8905. else
  8906. result = -1;
  8907. }
  8908. else
  8909. result = -1;
  8910. if (frmtStruct.seg_list != NULL)
  8911. _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE, NULL, NULL);
  8912. /*
  8913. * free the font structures allocated
  8914. */
  8915. DestroyFontInfo(&frmtStruct);
  8916. return result;
  8917. } /* End _DtHelpCeFrmtSDLTitleToAscii */
  8918. /******************************************************************************
  8919. * Function: char *_DtHelpCeFrmtSdlVolumeAbstractToAscii(
  8920. * _DtHelpVolumeHdl volume)
  8921. *
  8922. * Parameters:
  8923. * volume Specifies the Help Volume the information
  8924. * is associated with.
  8925. *
  8926. * Returns: 0 if successful, -1 if errors
  8927. *
  8928. * Purpose: _DtHelpCeFrmtSdlVolumeAbstractToAscii formats Help Files
  8929. * with formatting information into a CEVirtualPage
  8930. *
  8931. ******************************************************************************/
  8932. char *
  8933. _DtHelpCeFrmtSdlVolumeAbstractToAscii(
  8934. _DtHelpVolumeHdl volume)
  8935. {
  8936. int offset;
  8937. char *abstr = NULL;
  8938. _DtCvSegment *pSeg;
  8939. _DtCvSegment *pSnb;
  8940. _DtCvValue nlFlag = False;
  8941. _DtHelpCeLockInfo lockInfo;
  8942. if (_DtHelpCeLockVolume(volume, &lockInfo) != 0)
  8943. return NULL;
  8944. if (_DtHelpCeFindSdlId(volume,"_abstract",lockInfo.fd,NULL,&offset) == True)
  8945. {
  8946. int result = 0;
  8947. SDLMask startExcept[SDL_MASK_LEN] = SDLInitMask(SdlElementNone);
  8948. SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits;
  8949. FormatStruct frmtStruct;
  8950. CESDLVolume *sdlVol;
  8951. if (SetUp(volume, &sdlVol, &frmtStruct, NULL, &DefUiInfo,
  8952. lockInfo.fd, True, False) != 0)
  8953. return NULL;
  8954. /*
  8955. * now set up correct font mode.
  8956. */
  8957. frmtStruct.resolve_font = _SdlFontModeNone;
  8958. /*
  8959. * open the volume and seek to the virpage
  8960. */
  8961. result = _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume),
  8962. offset, lockInfo.fd,
  8963. &(frmtStruct.my_file), NULL);
  8964. if (result != -1)
  8965. {
  8966. result = ProcessSDLMarkup (&frmtStruct, SdlElementVirpage,
  8967. SdlElementNone, startExcept, processMask);
  8968. _DtHelpCeBufFileClose (frmtStruct.my_file,
  8969. (lockInfo.fd == -1 ? True : False));
  8970. }
  8971. if (result != -1)
  8972. {
  8973. pSeg = frmtStruct.seg_list;
  8974. pSnb = frmtStruct.snb;
  8975. CreateAsciiString(pSeg, pSnb, &nlFlag, &abstr);
  8976. _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE, NULL, NULL);
  8977. _DtHelpFreeSegments(frmtStruct.snb, _DtCvFALSE, NULL, NULL);
  8978. }
  8979. /*
  8980. * free the font structures allocated
  8981. */
  8982. DestroyFontInfo(&frmtStruct);
  8983. }
  8984. _DtHelpCeUnlockVolume(lockInfo);
  8985. return abstr;
  8986. } /* End _DtHelpCeFrmtSdlVolumeAbstractToAscii */
  8987. /******************************************************************************
  8988. * Function: int _DtHelpCeFrmtSDLVolTitleToAscii (
  8989. * char *filename,
  8990. * int offset,
  8991. * char **ret_title, char **ret_abbrev)
  8992. *
  8993. * Parameters:
  8994. *
  8995. * Returns: 0 if successful, -1 if errors
  8996. *
  8997. * Purpose:
  8998. ******************************************************************************/
  8999. int
  9000. _DtHelpCeFrmtSDLVolTitleToAscii(
  9001. _DtHelpVolumeHdl volume,
  9002. _FrmtUiInfo *ui_info,
  9003. char **ret_title)
  9004. {
  9005. char *abbrev = NULL;
  9006. int result = 0;
  9007. _DtCvSegment *pHeadSeg;
  9008. _DtHelpCeLockInfo lockInfo;
  9009. *ret_title = NULL;
  9010. /*
  9011. * get the head element
  9012. */
  9013. if (_DtHelpCeLockVolume(volume, &lockInfo) != 0)
  9014. return -1;
  9015. result = GetDocumentTitle(volume,ui_info, _SdlFontModeNone, False, &pHeadSeg);
  9016. _DtHelpCeUnlockVolume(lockInfo);
  9017. if (result == 0)
  9018. {
  9019. /*
  9020. * get the abbreviation of the head
  9021. */
  9022. result = -2;
  9023. if (pHeadSeg != NULL)
  9024. {
  9025. CreateAsciiAbbrev(pHeadSeg, &abbrev);
  9026. if (abbrev != NULL && *abbrev != '\0')
  9027. {
  9028. *ret_title = abbrev;
  9029. result = 0;
  9030. }
  9031. }
  9032. /*
  9033. * if there wasn't an abbreviation, use the head itself, stripping
  9034. * all special items and graphics.
  9035. */
  9036. if (0 != result && pHeadSeg != NULL &&
  9037. NULL != _DtCvContainerListOfSeg(pHeadSeg))
  9038. {
  9039. _DtCvValue nlFlag = False;
  9040. CreateAsciiString(_DtCvContainerListOfSeg(pHeadSeg),
  9041. GetSdlDocSnb(volume),
  9042. &nlFlag, ret_title);
  9043. if (abbrev != NULL)
  9044. free(abbrev);
  9045. result = 0;
  9046. }
  9047. }
  9048. /*
  9049. * if there isn't an abbreviation on the document, and there isn't
  9050. * a head, then try for the title page. After that, try the
  9051. * hometopic's title.
  9052. */
  9053. if (-2 == result)
  9054. {
  9055. result = 0;
  9056. if (_DtHelpGetTopicTitle(volume, "_title", ret_title) != 0)
  9057. result = _DtHelpGetTopicTitle(volume, "_hometopic", ret_title);
  9058. }
  9059. return result;
  9060. } /* End _DtHelpCeFrmtSDLVolTitleToAscii */
  9061. /******************************************************************************
  9062. * Function: int _DtHelpCeGetSdlTopicTitleChunks (
  9063. *
  9064. * Parameters:
  9065. *
  9066. * Returns: 0 if successful, -1 if errors
  9067. *
  9068. * Purpose:
  9069. ******************************************************************************/
  9070. int
  9071. _DtHelpCeGetSdlTitleChunks(
  9072. _DtHelpVolumeHdl volume,
  9073. char *loc_id,
  9074. _FrmtUiInfo *ui_info,
  9075. void ***ret_chunks)
  9076. {
  9077. int result = 0;
  9078. int offset;
  9079. FormatStruct frmtStruct;
  9080. CESDLVolume *sdlVol;
  9081. SDLMask stopMask[SDL_MASK_LEN] =
  9082. SDLInitMask(SdlElementSubHead);
  9083. *ret_chunks = NULL;
  9084. if (_DtHelpCeFindSdlId(volume, loc_id, -1, NULL, &offset) != True)
  9085. return -1;
  9086. if (SetUp(volume, &sdlVol, &frmtStruct, NULL, ui_info, -1, True, True) != 0)
  9087. return -1;
  9088. result = FormatSDLTitle(frmtStruct.vol_name, offset, -1, &frmtStruct);
  9089. if (result != -1 && frmtStruct.seg_list != NULL)
  9090. {
  9091. _DtCvSegment *headEl;
  9092. _DtCvSegment *pSnbEl = NULL;
  9093. result = -1;
  9094. headEl = _DtCvContainerListOfSeg(frmtStruct.seg_list);
  9095. /*
  9096. * A virpage contains a zero or more heads as it's first
  9097. * content. Therefore, if the the first item is not a
  9098. * container and a controller (heads get the controller flag
  9099. * put on them), then this virpage does not have a title.
  9100. */
  9101. if (NULL != headEl && _DtCvIsSegContainer(headEl) &&
  9102. _DtCvIsSegController(headEl))
  9103. {
  9104. result = ProcessSegmentsToChunks(frmtStruct.toss,
  9105. headEl,
  9106. pSnbEl, stopMask,
  9107. _DtHelpCeGetSdlVolLanguage(volume),
  9108. _DtHelpCeGetSdlVolCharSet(volume),
  9109. ui_info->resolve_spc,
  9110. ui_info->client_data,
  9111. ret_chunks);
  9112. }
  9113. }
  9114. else
  9115. result = -1;
  9116. if (frmtStruct.seg_list != NULL)
  9117. _DtHelpFreeSegments(frmtStruct.seg_list, _DtCvFALSE,
  9118. ui_info->destroy_region,
  9119. ui_info->client_data);
  9120. if (frmtStruct.snb != NULL)
  9121. _DtHelpFreeSegments(frmtStruct.snb, _DtCvFALSE,
  9122. ui_info->destroy_region,
  9123. ui_info->client_data);
  9124. /*
  9125. * free the font structures allocated
  9126. */
  9127. DestroyFontInfo(&frmtStruct);
  9128. /*
  9129. * destroy the link database
  9130. */
  9131. _DtLinkDbDestroy(frmtStruct.my_links);
  9132. return result;
  9133. } /* End _DtHelpCeGetSdlTitleChunks */
  9134. /******************************************************************************
  9135. * Function: int _DtHelpCeGetSdlVolTitleChunks (
  9136. *
  9137. * Parameters:
  9138. *
  9139. * Returns: 0 if successful, -1 if errors
  9140. *
  9141. * Purpose:
  9142. ******************************************************************************/
  9143. int
  9144. _DtHelpCeGetSdlVolTitleChunks(
  9145. _DtHelpVolumeHdl volume_handle,
  9146. _FrmtUiInfo *ui_info,
  9147. void ***ret_chunks)
  9148. {
  9149. int result = -2;
  9150. _DtCvSegment *pHeadSeg;
  9151. CESDLVolume *sdlVol;
  9152. SDLMask stopMask[SDL_MASK_LEN] =
  9153. SDLInitMask(SdlElementSubHead);
  9154. /*
  9155. * get the sdl volume pointer.
  9156. */
  9157. sdlVol = _DtHelpCeGetSdlVolumePtr(volume_handle);
  9158. if (sdlVol == NULL)
  9159. return -1;
  9160. /*
  9161. * find the document attributes
  9162. */
  9163. if (NULL == sdlVol->sdl_info)
  9164. return -1;
  9165. /*
  9166. * get the head element
  9167. */
  9168. if (GetDocumentTitle(volume_handle, ui_info,
  9169. _SdlFontModeResolve, True, &pHeadSeg) == -1)
  9170. return -1;
  9171. /*
  9172. * process it
  9173. */
  9174. if (pHeadSeg != NULL)
  9175. result = ProcessSegmentsToChunks(
  9176. _DtHelpCeGetSdlVolToss(volume_handle, -1),
  9177. pHeadSeg,
  9178. GetSdlDocSnb(volume_handle), stopMask,
  9179. _DtHelpCeGetSdlVolLanguage(volume_handle),
  9180. _DtHelpCeGetSdlVolCharSet(volume_handle),
  9181. ui_info->resolve_spc,
  9182. ui_info->client_data,
  9183. ret_chunks);
  9184. if (result != 0)
  9185. {
  9186. result = _DtHelpCeGetSdlTitleChunks(volume_handle, "_title",
  9187. ui_info, ret_chunks);
  9188. if (result != 0)
  9189. result = _DtHelpCeGetSdlTitleChunks(volume_handle, "_hometopic",
  9190. ui_info, ret_chunks);
  9191. }
  9192. return result;
  9193. } /* End _DtHelpCeGetSdlVolTitleChunks */
  9194. /******************************************************************************
  9195. * Function: int _DtHelpCeGetSdlVolToss (
  9196. * _DtHelpVolumeHdl volume,
  9197. * Parameters:
  9198. * volume Specifies the volume to read/parse.
  9199. *
  9200. * Returns: 0 if successful, -1 if errors
  9201. *
  9202. * Purpose: Get the toss from a volume.
  9203. ******************************************************************************/
  9204. _DtCvSegment *
  9205. _DtHelpCeGetSdlVolToss(
  9206. _DtHelpVolumeHdl volume,
  9207. int fd)
  9208. {
  9209. CESDLVolume *sdlVol;
  9210. FormatStruct frmtStruct;
  9211. SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits;
  9212. SDLMask startExcept[SDL_MASK_LEN] =
  9213. SDLInitMask(SdlElementNone);
  9214. /*
  9215. * get the sdl volume pointer.
  9216. */
  9217. sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
  9218. if (sdlVol == NULL)
  9219. return NULL;
  9220. if (sdlVol->toss == NULL
  9221. && SetUp(volume,NULL,&frmtStruct,NULL,&DefUiInfo,fd,True,False) == 0
  9222. && _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, fd,
  9223. &(frmtStruct.my_file), NULL) != -1)
  9224. {
  9225. if (ProcessContent(&frmtStruct, SDLDocumentContent,
  9226. SdlElementNone, startExcept, skipMask) != -1
  9227. && ProcessSDLMarkup(&frmtStruct, SdlElementVStruct,
  9228. SdlElementToss, startExcept, skipMask) != -1)
  9229. sdlVol->toss = frmtStruct.seg_list;
  9230. _DtHelpCeBufFileClose (frmtStruct.my_file, (fd == -1 ? True : False));
  9231. /*
  9232. * free the font structures allocated
  9233. */
  9234. DestroyFontInfo(&frmtStruct);
  9235. /*
  9236. * destroy the link database
  9237. */
  9238. _DtLinkDbDestroy(frmtStruct.my_links);
  9239. }
  9240. if (sdlVol->toss != NULL)
  9241. return (_DtCvContainerListOfSeg(sdlVol->toss));
  9242. return NULL;
  9243. } /* End _DtHelpCeGetSdlVolToss */
  9244. /******************************************************************************
  9245. * Function: int _DtHelpCeGetSdlVolIndex (
  9246. * _DtHelpVolumeHdl volume,
  9247. * Parameters:
  9248. * volume Specifies the volume to read/parse.
  9249. *
  9250. * Returns: 0 if successful, -1 if errors
  9251. *
  9252. * Purpose: Get the index from a volume.
  9253. ******************************************************************************/
  9254. int
  9255. _DtHelpCeGetSdlVolIndex(
  9256. _DtHelpVolumeHdl volume)
  9257. {
  9258. int result = -1;
  9259. CESDLVolume *sdlVol;
  9260. FormatStruct frmtStruct;
  9261. SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits;
  9262. SDLMask startExcept[SDL_MASK_LEN] =
  9263. SDLInitMask(SdlElementNone);
  9264. sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
  9265. if (sdlVol == NULL)
  9266. return -1;
  9267. if (sdlVol->index != NULL)
  9268. return 0;
  9269. if (SetUp(volume, NULL, &frmtStruct, NULL, &DefUiInfo, -1, True, True) != 0)
  9270. return -1;
  9271. /*
  9272. * now set up correct font mode.
  9273. */
  9274. frmtStruct.resolve_font = _SdlFontModeNone;
  9275. if (_DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, -1,
  9276. &(frmtStruct.my_file), NULL) != -1)
  9277. {
  9278. if (ProcessContent(&frmtStruct, SDLDocumentContent,
  9279. SdlElementNone, startExcept, skipMask) != -1
  9280. && ProcessSDLMarkup(&frmtStruct, SdlElementVStruct,
  9281. SdlElementIndex, startExcept, skipMask) != -1)
  9282. {
  9283. sdlVol->index = frmtStruct.seg_list;
  9284. result = 0;
  9285. }
  9286. _DtHelpCeBufFileClose (frmtStruct.my_file, True);
  9287. }
  9288. /*
  9289. * destroy the link database
  9290. */
  9291. _DtLinkDbDestroy(frmtStruct.my_links);
  9292. /*
  9293. * free the font structures allocated
  9294. */
  9295. DestroyFontInfo(&frmtStruct);
  9296. return result;
  9297. } /* End _DtHelpCeGetSdlVolIndex */
  9298. /******************************************************************************
  9299. * Function: int _DtHelpCeGetSdlVolIds (
  9300. * _DtHelpVolumeHdl volume,
  9301. * _DtCvSegment **ret_ids
  9302. * Parameters:
  9303. * volume Specifies the volume to read/parse.
  9304. *
  9305. * Returns: 0 if successful, -1 if errors
  9306. *
  9307. * Purpose: Get the loids from a volume.
  9308. ******************************************************************************/
  9309. int
  9310. _DtHelpCeGetSdlVolIds(
  9311. _DtHelpVolumeHdl volume,
  9312. int fd,
  9313. _DtCvSegment **ret_ids)
  9314. {
  9315. int result = 0;
  9316. CESDLVolume *sdlVol;
  9317. FormatStruct frmtStruct;
  9318. SDLMask skipMask [SDL_MASK_LEN] = SDLClearAllBits;
  9319. SDLMask startExcept[SDL_MASK_LEN] =
  9320. SDLInitMask(SdlElementNone);
  9321. *ret_ids = NULL;
  9322. sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
  9323. if (sdlVol == NULL)
  9324. return -1;
  9325. if (sdlVol->loids == NULL)
  9326. {
  9327. result = -1;
  9328. if (SetUp(NULL,NULL,&frmtStruct,NULL,&DefUiInfo,-1,False,False) != -1
  9329. && _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume), 0, fd,
  9330. &(frmtStruct.my_file), NULL) != -1)
  9331. {
  9332. if (ProcessContent(&frmtStruct, SDLDocumentContent,
  9333. SdlElementNone, startExcept, skipMask) != -1)
  9334. {
  9335. if (ProcessSDLMarkup(&frmtStruct, SdlElementVStruct,
  9336. SdlElementLoids, startExcept, skipMask) != -1)
  9337. {
  9338. sdlVol->loids = frmtStruct.seg_list;
  9339. result = 0;
  9340. }
  9341. }
  9342. /*
  9343. * free the font structures allocated
  9344. */
  9345. DestroyFontInfo(&frmtStruct);
  9346. /*
  9347. * destroy the link database
  9348. */
  9349. _DtLinkDbDestroy(frmtStruct.my_links);
  9350. _DtHelpCeBufFileClose(frmtStruct.my_file,(fd == -1 ? True : False));
  9351. }
  9352. }
  9353. if (sdlVol->loids != NULL)
  9354. *ret_ids = _DtCvContainerListOfSeg(sdlVol->loids);
  9355. return result;
  9356. } /* End _DtHelpCeGetSdlVolIds */
  9357. /******************************************************************************
  9358. * Function: int _DtHelpCeParseSdlTopic (_DtHelpVolumeHdl volume,
  9359. * int offset, char *id_string,
  9360. * _DtCvTopicPtr *ret_handle)
  9361. *
  9362. * Parameters:
  9363. * volume Specifies the Help Volume the information
  9364. * is associated with.
  9365. * offset Specifies the offset into 'filename' to
  9366. * the Help Topic desired.
  9367. * id_string Specifies the location id to look for or NULL.
  9368. * ret_handle Returns a handle to the topic information
  9369. * including the number of paragraphs and the
  9370. * id match segment.
  9371. *
  9372. * Returns: 0 if successful, -1 if errors
  9373. *
  9374. * Purpose: _DtHelpCeParseSdlTopic formats Help Files with formatting
  9375. * information into a CEVirtualPage
  9376. *
  9377. ******************************************************************************/
  9378. int
  9379. _DtHelpCeParseSdlTopic(
  9380. _DtHelpVolumeHdl volume,
  9381. _FrmtUiInfo *ui_info,
  9382. int fd,
  9383. int offset,
  9384. char *id_string,
  9385. int rich_text,
  9386. _DtCvTopicPtr *ret_handle)
  9387. {
  9388. int result = 0;
  9389. SDLMask startExcept[SDL_MASK_LEN] =
  9390. SDLInitMask(SdlElementNone);
  9391. SDLMask processMask[SDL_MASK_LEN] = SDLSetAllBits;
  9392. FormatStruct frmtStruct;
  9393. _DtCvTopicInfo *topicHandle;
  9394. CESDLVolume *sdlVol;
  9395. *ret_handle = NULL;
  9396. if (SetUp(volume,&sdlVol,&frmtStruct,NULL,ui_info,fd,True,rich_text) != 0)
  9397. return -1;
  9398. /*
  9399. * remember the id for graphics
  9400. */
  9401. frmtStruct.id_string = id_string;
  9402. result = _DtHelpCeFileOpenAndSeek(_DtHelpCeGetVolumeName(volume),
  9403. offset, fd,
  9404. &(frmtStruct.my_file), NULL);
  9405. if (result != -1)
  9406. {
  9407. result = ProcessSDLMarkup (&frmtStruct, SdlElementVirpage,
  9408. SdlElementNone, startExcept, processMask);
  9409. _DtHelpCeBufFileClose (frmtStruct.my_file, (fd == -1 ? True : False));
  9410. }
  9411. /*
  9412. * free the async blocks
  9413. */
  9414. _DtHelpFreeSegments(frmtStruct.async_blks, _DtCvFALSE,
  9415. ui_info->destroy_region,
  9416. ui_info->client_data);
  9417. /*
  9418. * free the system notation blocks
  9419. */
  9420. _DtHelpFreeSegments(frmtStruct.snb, _DtCvFALSE,
  9421. ui_info->destroy_region,
  9422. ui_info->client_data);
  9423. if (result != -1)
  9424. {
  9425. topicHandle = (_DtCvTopicInfo *) malloc (sizeof(_DtCvTopicInfo));
  9426. if (topicHandle != NULL)
  9427. {
  9428. topicHandle->mark_list = NULL;
  9429. topicHandle->id_str = NULL;
  9430. if (id_string != NULL)
  9431. topicHandle->id_str = strdup(id_string);
  9432. topicHandle->link_data = frmtStruct.my_links;
  9433. topicHandle->seg_list = frmtStruct.seg_list;
  9434. *ret_handle = (void *) topicHandle;
  9435. }
  9436. else
  9437. result = -1;
  9438. }
  9439. /*
  9440. * free the allocated font structures
  9441. */
  9442. DestroyFontInfo(&frmtStruct);
  9443. return result;
  9444. } /* End _DtHelpCeParseSdlTopic */