1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /*
- * (c) Copyright 1989, 1990, 1991, 1992, 1993, 1994 OPEN SOFTWARE FOUNDATION, INC.
- * ALL RIGHTS RESERVED
- */
- /*
- * Motif Release 1.2.4
- */
- /*
- * (c) Copyright 1987, 1988, 1989, 1990, 1993, 1994 Hewlett-Packard Company
- * (c) Copyright 1993, 1994 International Business Machines Corp.
- * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
- * (c) Copyright 1993, 1994 Novell, Inc.
- */
- /*
- * (c) Copyright 1987, 1988 DIGITAL EQUIPMENT CORPORATION */
- /*
- * (c) Copyright 1988 MASSACHUSETTS INSTITUTE OF TECHNOLOGY */
- /*
- * Included Files:
- */
- #include "WmGlobal.h"
- #include "WmResNames.h"
- #include <Dt/UserMsg.h>
- #include <Dt/Connect.h>
- #include <Tt/tt_c.h>
- #include "WmParse.h"
- #include "WmParseP.h"
- #include "WmPanelP.h"
- #include "WmResource.h"
- #include <codelibs/shellutils.h> /* shellscan */
- #include <Xm/VirtKeysP.h>
- #include <Xm/XmPrivate.h> /* _XmVirtKeysLoadFileBindings,
- * _XmVirtKeysLoadFallbackBindings */
- #include <X11/cursorfont.h>
- #include <X11/keysym.h>
- #include <X11/Xatom.h>
- #include <ctype.h>
- #include <locale.h>
- #include <stdlib.h>
- #include <Xm/XmP.h> /* for XmeGetHomeDirName */
- #include <signal.h>
- /* maximum string lengths */
- #define MAX_KEYSYM_STRLEN 100
- #define MAX_EVENTTYPE_STRLEN 20
- #define MAX_MODIFIER_STRLEN 20
- #define MAX_CONTEXT_STRLEN 20
- #define MAX_GROUP_STRLEN 20
- #define min(a,b) ((a)>(b) ? (b) : (a))
- #define MAXLINE (MAXWMPATH+1)
- #define MBBSIZ 4096
- #define PARSE_MENU_ITEMS(pSD, mSpec) ParseMenuItems(pSD)
- /*
- * include extern functions
- */
- #include "WmResParse.h"
- #include "WmWrkspace.h"
- #include "WmError.h"
- #include "WmFunction.h"
- #include "WmImage.h"
- #include "WmXSMP.h"
- # include <errno.h>
- # ifdef X_NOT_STDC_ENV
- extern int errno;
- # endif
- # define HOME_DT_WMRC "/.dt/dtwmrc"
- # define LANG_DT_WMRC "/dtwmrc"
- # define SYS_DT_WMRC CDE_CONFIGURATION_TOP "/sys.dtwmrc"
- /*
- * Global Variables And Tables:
- */
- static char cfileName[MAXWMPATH+1];
- #ifndef NO_MESSAGE_CATALOG
- char * pWarningStringFile;
- char * pWarningStringLine;
- #else
- char pWarningStringFile[] = "%s: %s on line %d of configuration file %s\n";
- char pWarningStringLine[] = "%s: %s on line %d of specification string\n";
- #endif
- #define cfileP (wmGD.pWmPB->pFile)
- #define parseP (wmGD.pWmPB->pchNext)
- #define line (wmGD.pWmPB->pchLine)
- #define linec (wmGD.pWmPB->lineNumber)
- typedef struct {
- char *name;
- unsigned int mask;
- } MaskTableEntry;
- static MaskTableEntry modifierStrings[] = {
- {"none", None},
- {"ctrl", ControlMask},
- {"shift", ShiftMask},
- {"alt", Mod1Mask},
- {"meta", Mod1Mask},
- {"lock", LockMask},
- {"mod1", Mod1Mask},
- {"mod2", Mod2Mask},
- {"mod3", Mod3Mask},
- {"mod4", Mod4Mask},
- {"mod5", Mod5Mask},
- {NULL, 0},
- };
- #define ALT_INDEX 3
- #define META_INDEX 4
- typedef struct {
- char *event;
- unsigned int eventType;
- Boolean (*parseProc)();
- unsigned int closure;
- Boolean fClick;
- } EventTableEntry;
- static String GetNetworkFileName (char *pchFile);
- FILE *FopenConfigFile (void);
- void SaveMenuAccelerators (WmScreenData *pSD, MenuSpec *newMenuSpec);
- static void ParseMenuSet (WmScreenData *pSD, unsigned char *lineP);
- MenuItem *ParseMwmMenuStr (WmScreenData *pSD, unsigned char *menuStr);
- static MenuItem *ParseMenuItems (WmScreenData *pSD);
- static Boolean ParseWmLabel (WmScreenData *pSD, MenuItem *menuItem,
- unsigned char *string);
- static void ParseWmMnemonic (unsigned char **linePP, MenuItem *menuItem);
- static Boolean ParseWmAccelerator (unsigned char **linePP, MenuItem *menuItem);
- int ParseWmFunction (unsigned char **linePP, unsigned int res_spec,
- WmFunction *pWmFunction);
- static Boolean ParseWmFuncNoArg (unsigned char **linePP, WmFunction wmFunction,
- String *pArgs);
- void FreeMenuItem (MenuItem *menuItem);
- static Boolean ParseWmFuncGrpArg (unsigned char **linePP,
- WmFunction wmFunction, GroupArg *pGroup);
- static Boolean ParseWmFuncNbrArg (unsigned char **linePP,
- WmFunction wmFunction,
- unsigned long *pNumber);
- void ParseButtonStr (WmScreenData *pSD, unsigned char *buttonStr);
- static void ParseButtonSet (WmScreenData *pSD, unsigned char *lineP);
- static Boolean ParseContext (unsigned char **linePP, Context *context,
- Context *subContext);
- void
- ParseKeyStr (WmScreenData *pSD, unsigned char *keyStr);
- static void ParseKeySet (WmScreenData *pSD, unsigned char *lineP);
- Boolean ParseBtnEvent (unsigned char **linePP,
- unsigned int *eventType,
- unsigned int *button,
- unsigned int *state,
- Boolean *fClick);
- Boolean ParseKeyEvent (unsigned char **linePP, unsigned int *eventType,
- KeyCode *keyCode, unsigned int *state);
- static Boolean ParseEvent (unsigned char **linePP, EventTableEntry *table,
- unsigned int *eventType, unsigned int *detail,
- unsigned int *state, Boolean *fClick);
- static Boolean ParseModifiers(unsigned char **linePP, unsigned int *state);
- static Boolean LookupModifier (unsigned char *name, unsigned int *valueP);
- static Boolean ParseEventType (unsigned char **linePP, EventTableEntry *table,
- unsigned int *eventType, Cardinal *ix);
- static Boolean ParseImmed (unsigned char **linePP, unsigned int closure,
- unsigned int *detail);
- static Boolean ParseKeySym (unsigned char **linePP, unsigned int closure,
- unsigned int *detail);
- static unsigned int StrToNum(unsigned char *str);
- static unsigned int StrToHex(unsigned char *str);
- static unsigned int StrToOct(unsigned char *str);
- void ScanAlphanumeric (unsigned char **linePP);
- void ScanWhitespace(unsigned char **linePP);
- void ToLower (char *string);
- void
- PWarning (char *message);
- static void ProcessAccelText (unsigned char *startP, unsigned char *endP,
- unsigned char *destP);
- void ProcessCommandLine (int argc, char *argv[]);
- static void ParseScreensArgument (int argc, char *argv[], int *pArgnum,
- unsigned char *lineP);
- void ProcessMotifBindings (void);
- static void ParseIncludeSet (WmScreenData *pSD, unsigned char *lineP);
- static void ConfigStackInit (char *pchFileName);
- static FILE *ConfigStackPush (unsigned char *pchFileName);
- static void ConfigStackPop (void);
- Boolean ParseWmFuncActionArg (unsigned char **linePP,
- WmFunction wmFunction, String *pArgs);
- static void PreprocessConfigFile (void);
- static EventTableEntry buttonEvents[] = {
- {"btn1down", ButtonPress, ParseImmed, SELECT_BUTTON, FALSE},
- {"btn1up", ButtonRelease, ParseImmed, SELECT_BUTTON, FALSE},
- {"btn1click", ButtonRelease, ParseImmed, SELECT_BUTTON, TRUE},
- {"btn1click2", ButtonPress, ParseImmed, SELECT_BUTTON, TRUE},
- {"btn2down", ButtonPress, ParseImmed, DMANIP_BUTTON, FALSE},
- {"btn2up", ButtonRelease, ParseImmed, DMANIP_BUTTON, FALSE},
- {"btn2click", ButtonRelease, ParseImmed, DMANIP_BUTTON, TRUE},
- {"btn2click2", ButtonPress, ParseImmed, DMANIP_BUTTON, TRUE},
- {"btn3down", ButtonPress, ParseImmed, BMENU_BUTTON, FALSE},
- {"btn3up", ButtonRelease, ParseImmed, BMENU_BUTTON, FALSE},
- {"btn3click", ButtonRelease, ParseImmed, BMENU_BUTTON, TRUE},
- {"btn3click2", ButtonPress, ParseImmed, BMENU_BUTTON, TRUE},
- {"btn4down", ButtonPress, ParseImmed, Button4, FALSE},
- {"btn4up", ButtonRelease, ParseImmed, Button4, FALSE},
- {"btn4click", ButtonRelease, ParseImmed, Button4, TRUE},
- {"btn4click2", ButtonPress, ParseImmed, Button4, TRUE},
- {"btn5down", ButtonPress, ParseImmed, Button5, FALSE},
- {"btn5up", ButtonRelease, ParseImmed, Button5, FALSE},
- {"btn5click", ButtonRelease, ParseImmed, Button5, TRUE},
- {"btn5click2", ButtonPress, ParseImmed, Button5, TRUE},
- { NULL, 0, (Boolean(*)())NULL, 0, FALSE}
- };
- static EventTableEntry keyEvents[] = {
- {"key", KeyPress, ParseKeySym, 0, FALSE},
- { NULL, 0, (Boolean(*)())NULL, 0, FALSE}
- };
- typedef struct _ConfigFileStackEntry {
- char *fileName;
- char *tempName;
- char *cppName;
- char *wmgdConfigFile;
- long offset;
- DtWmpParseBuf *pWmPB;
- struct _ConfigFileStackEntry *pIncluder;
-
- } ConfigFileStackEntry;
- static ConfigFileStackEntry *pConfigStack = NULL;
- static ConfigFileStackEntry *pConfigStackTop = NULL;
- unsigned int buttonModifierMasks[] = {
- 0,
- SELECT_BUTTON_MASK,
- DMANIP_BUTTON_MASK,
- BMENU_BUTTON_MASK,
- Button4Mask,
- Button5Mask
- };
- /*
- * FUNCTION PARSER TABLE (function names must be in alphabetic order)
- */
- typedef struct {
- char * funcName;
- Context greyedContext;
- unsigned int resource;
- long mgtMask;
- WmFunction wmFunction;
- Boolean (*parseProc)();
- } FunctionTableEntry;
- /*
- * NOTE: New functions MUST be added in ALPHABETICAL order. A binary search
- * is used to find the correct function name.
- */
- FunctionTableEntry functionTable[] = {
- {"f.action", 0,
- CRS_ANY,
- 0,
- F_Action,
- ParseWmFuncActionArg},
- {"f.beep", 0,
- CRS_ANY,
- 0,
- F_Beep,
- ParseWmFuncNoArg},
- {"f.circle_down", F_SUBCONTEXT_IB_IICON|F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- 0,
- F_Circle_Down,
- ParseWmFuncGrpArg},
- {"f.circle_up", F_SUBCONTEXT_IB_IICON|F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- 0,
- F_Circle_Up,
- ParseWmFuncGrpArg},
- {"f.create_workspace", 0,
- CRS_ANY,
- 0,
- F_CreateWorkspace,
- ParseWmFuncNoArg},
- {"f.delete_workspace", 0,
- CRS_ANY,
- 0,
- F_DeleteWorkspace,
- ParseWmFuncNoArg},
- {"f.exec", 0,
- CRS_ANY,
- 0,
- F_Exec,
- ParseWmFuncStrArg},
- {"f.focus_color", F_SUBCONTEXT_IB_IICON|F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- 0,
- F_Focus_Color,
- ParseWmFuncNoArg},
- {"f.focus_key", F_SUBCONTEXT_IB_IICON|F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- 0,
- F_Focus_Key,
- ParseWmFuncNoArg},
- {"f.goto_workspace", 0,
- CRS_ANY,
- 0,
- F_Goto_Workspace,
- ParseWmFuncStrArg},
- {"f.help", 0,
- CRS_ANY,
- 0,
- F_Help,
- ParseWmFuncStrArg}, /* [helpvolume && helptopic] */
- {"f.help_mode", 0,
- CRS_ANY,
- 0,
- F_Help_Mode,
- ParseWmFuncNoArg}, /* for now */
- {"f.kill", F_CONTEXT_ROOT,
- CRS_ANY,
- MWM_FUNC_CLOSE,
- F_Kill,
- ParseWmFuncNoArg},
- {"f.lower", F_SUBCONTEXT_IB_IICON|F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- 0,
- F_Lower,
- ParseWmFuncMaybeStrArg},
- {"f.marquee_selection",
- F_CONTEXT_WINDOW|F_CONTEXT_ICON|F_SUBCONTEXT_IB_IICON,
- CRS_ANY,
- 0,
- F_Marquee_Selection,
- ParseWmFuncNoArg},
- {"f.maximize", F_CONTEXT_ROOT|F_CONTEXT_MAXIMIZE|
- F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- MWM_FUNC_MAXIMIZE,
- F_Maximize,
- ParseWmFuncNoArg},
- {"f.menu", 0,
- CRS_ANY,
- 0,
- F_Menu,
- ParseWmFuncStrArg},
- {"f.minimize", F_CONTEXT_ICON|F_CONTEXT_ROOT|F_SUBCONTEXT_IB_IICON,
- CRS_ANY,
- MWM_FUNC_MINIMIZE,
- F_Minimize,
- ParseWmFuncNoArg},
- {"f.move", F_CONTEXT_ROOT,
- CRS_ANY,
- MWM_FUNC_MOVE,
- F_Move,
- ParseWmFuncNoArg},
- {"f.next_cmap", 0,
- CRS_ANY,
- 0,
- F_Next_Cmap,
- ParseWmFuncNoArg},
- {"f.next_key", 0,
- CRS_ANY,
- 0,
- F_Next_Key,
- ParseWmFuncGrpArg},
- {"f.next_workspace", 0,
- CRS_ANY,
- 0,
- F_Next_Workspace,
- ParseWmFuncNoArg},
- {"f.nop", F_CONTEXT_ROOT|F_CONTEXT_ICON|F_CONTEXT_WINDOW|
- F_SUBCONTEXT_IB_WICON | F_SUBCONTEXT_IB_IICON,
- CRS_ANY,
- 0,
- F_Nop,
- ParseWmFuncNoArg},
- {"f.normalize", F_CONTEXT_ROOT|F_CONTEXT_NORMAL|F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- 0,
- F_Normalize,
- ParseWmFuncNoArg},
- {"f.normalize_and_raise",
- F_CONTEXT_ROOT|F_CONTEXT_NORMAL,
- CRS_ANY,
- 0,
- F_Normalize_And_Raise,
- ParseWmFuncMaybeStrArg},
- {"f.occupy_all", F_CONTEXT_ICONBOX|F_CONTEXT_ROOT,
- CRS_ANY,
- DtWM_FUNC_OCCUPY_WS,
- F_AddToAllWorkspaces,
- ParseWmFuncNoArg},
- {"f.pack_icons", 0,
- CRS_ANY,
- 0,
- F_Pack_Icons,
- ParseWmFuncNoArg},
- {"f.pass_keys", 0,
- CRS_ANY,
- 0,
- F_Pass_Key,
- ParseWmFuncNoArg},
- {"f.post_wmenu", 0,
- CRS_BUTTON|CRS_KEY,
- 0,
- F_Post_SMenu,
- ParseWmFuncNoArg},
- {"f.prev_cmap", 0,
- CRS_ANY,
- 0,
- F_Prev_Cmap,
- ParseWmFuncNoArg},
- {"f.prev_key", 0,
- CRS_ANY,
- 0,
- F_Prev_Key,
- ParseWmFuncGrpArg},
- {"f.prev_workspace", 0,
- CRS_ANY,
- 0,
- F_Prev_Workspace,
- ParseWmFuncNoArg},
- {"f.quit_mwm", F_CONTEXT_ICON|F_CONTEXT_WINDOW,
- CRS_ANY,
- 0,
- F_Quit_Mwm,
- ParseWmFuncNoArg},
- {"f.raise", F_SUBCONTEXT_IB_IICON|F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- 0,
- F_Raise,
- ParseWmFuncMaybeStrArg},
- {"f.raise_lower", F_CONTEXT_ROOT |
- F_SUBCONTEXT_IB_IICON|F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- 0,
- F_Raise_Lower,
- ParseWmFuncNoArg},
- {"f.refresh", 0,
- CRS_ANY,
- 0,
- F_Refresh,
- ParseWmFuncNoArg},
- {"f.refresh_win", F_CONTEXT_ICON|F_CONTEXT_ROOT,
- CRS_ANY,
- 0,
- F_Refresh_Win,
- ParseWmFuncNoArg},
- {"f.remove", F_CONTEXT_ROOT,
- CRS_ANY,
- DtWM_FUNC_OCCUPY_WS,
- F_Remove,
- ParseWmFuncNoArg},
- {"f.rename", F_CONTEXT_ROOT|F_CONTEXT_ICONBOX|F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- DtWM_FUNC_OCCUPY_WS,
- F_Rename,
- ParseWmFuncNoArg},
- {"f.resize", F_CONTEXT_ICON|F_CONTEXT_ROOT|
- F_SUBCONTEXT_IB_IICON|F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- MWM_FUNC_RESIZE,
- F_Resize,
- ParseWmFuncNoArg},
- {"f.restart", F_CONTEXT_ICON|F_CONTEXT_WINDOW,
- CRS_ANY,
- 0,
- F_Restart,
- ParseWmFuncStrArg},
- {"f.restore", F_CONTEXT_ROOT|F_CONTEXT_NORMAL|F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- 0,
- F_Restore,
- ParseWmFuncNoArg},
- {"f.restore_and_raise",
- F_CONTEXT_ROOT|F_CONTEXT_NORMAL,
- CRS_ANY,
- 0,
- F_Restore_And_Raise,
- ParseWmFuncNoArg},
- {"f.screen", 0,
- CRS_ANY,
- 0,
- F_Screen,
- ParseWmFuncStrArg},
- {"f.send_msg", F_CONTEXT_ROOT,
- CRS_ANY,
- 0,
- F_Send_Msg,
- ParseWmFuncNbrArg},
- {"f.separator", 0,
- CRS_MENU,
- 0,
- F_Separator,
- ParseWmFuncNoArg},
- {"f.set_behavior", 0,
- CRS_ANY,
- 0,
- F_Set_Behavior,
- ParseWmFuncNoArg},
- {"f.set_context", 0,
- CRS_ANY,
- 0,
- F_Set_Context,
- ParseWmFuncNbrArg},
- {"f.title", 0,
- CRS_MENU,
- 0,
- F_Title,
- ParseWmFuncNoArg},
- {"f.toggle_frontpanel", 0,
- CRS_ANY,
- 0,
- F_Toggle_Front_Panel,
- ParseWmFuncNoArg},
- {"f.version", 0,
- CRS_ANY,
- 0,
- F_Version,
- ParseWmFuncNoArg},
- #ifdef OLD
- {"f.workspace_presence",F_CONTEXT_ICON|F_CONTEXT_ROOT|F_CONTEXT_ICONBOX|
- F_SUBCONTEXT_IB_IICON|F_SUBCONTEXT_IB_WICON,
- #endif /* OLD */
- {"f.workspace_presence", F_CONTEXT_ROOT|F_CONTEXT_ICONBOX|
- F_SUBCONTEXT_IB_WICON,
- CRS_ANY,
- DtWM_FUNC_OCCUPY_WS,
- F_Workspace_Presence,
- ParseWmFuncNoArg},
- #if defined(DEBUG)
- {"f.zz_debug", 0,
- CRS_ANY,
- 0,
- F_ZZ_Debug,
- ParseWmFuncStrArg},
- #endif /* DEBUG */
- };
- /*
- * NOTE: New functions MUST be added in ALPHABETICAL order. A binary search
- * is used to find the correct function name.
- */
- #define WMFUNCTIONTABLESIZE (sizeof(functionTable)/sizeof(functionTable[0]))
- /*
- * Be sure to update these define, whenever adding/deleting a function.
- */
- int F_ACTION_INDEX;
- int F_EXEC_INDEX;
- int F_NOP_INDEX;
- /******************************<->*************************************
- *
- * void GetFunctionTableValues (int *execIndex, int *nopIndex,
- * int *actionIndex)
- *
- * Description:
- * -----------
- * This routine dynamically computes the size of the functionTable[],
- * and the indices for key functions, such as f.exec, f.action, and
- * f.nop
- *
- * Inputs:
- * ------
- * We are setting the values of F_EXEC_INDEX, F_ACTION_INDEX,
- * and F_NOP_INDEX on a global level. The addresses
- * for same are passed in.
- *
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- * This routine calls smaller routines for efficiency sake.
- *
- ******************************<->***********************************/
- void
- GetFunctionTableValues (int *execIndex, int *nopIndex,
- int *actionIndex)
- {
- GetExecIndex (WMFUNCTIONTABLESIZE, execIndex);
- GetActionIndex (WMFUNCTIONTABLESIZE, actionIndex);
- GetNopIndex (WMFUNCTIONTABLESIZE, nopIndex);
- } /* END OF FUNCTION GetFunctionTableValues */
- /******************************<->*************************************
- *
- *
- * Description:
- * -----------
- *
- * Inputs:
- * ------
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- *
- ******************************<->***********************************/
- void
- GetExecIndex (int tableSize, int *execIndex)
- {
- int i;
- for (i = 0; i < (tableSize); i++)
- {
- if (!(strcmp ("f.exec", functionTable[i].funcName)))
- {
- *execIndex = i;
- return;
- }
- else
- {
- *execIndex = 0;
- }
- }
- } /* END OF FUNCTION GetExecIndex */
- /******************************<->*************************************
- *
- *
- * Description:
- * -----------
- *
- * Inputs:
- * ------
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- *
- ******************************<->***********************************/
- void
- GetActionIndex (int tableSize, int *actionIndex)
- {
- int i;
- for (i = 0; i < (tableSize); i++)
- {
- if (!(strcmp ("f.action", functionTable[i].funcName)))
- {
- *actionIndex = i;
- return;
- }
- else
- {
- *actionIndex = 0;
- }
- }
- } /* END OF FUNCTION GetActionIndex */
- /******************************<->*************************************
- *
- *
- * Description:
- * -----------
- *
- * Inputs:
- * ------
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- *
- ******************************<->***********************************/
- void
- GetNopIndex (int tableSize, int *nopIndex)
- {
- int i;
- for (i = 0; i < (tableSize); i++)
- {
- if (!(strcmp ("f.nop", functionTable[i].funcName)))
- {
- *nopIndex = i;
- return;
- }
- else
- {
- *nopIndex = 0;
- }
- }
- } /* END OF FUNCTION GetNopIndex */
- /*************************************<->*************************************
- *
- * void
- * WmDtGetHelpArgs ()
- *
- *
- * Description:
- * -----------
- * Get Help Args
- *
- * Inputs:
- * ------
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- void
- WmDtGetHelpArgs(char *args,
- unsigned char* volume,
- unsigned char* topic,
- int *argsCount)
- {
- unsigned char *string;
- unsigned char *lineP;
- cfileP = NULL;
- linec = 0;
- parseP = (unsigned char*) args;
- if(GetNextLine () != NULL)
- {
- *argsCount = 0;
- lineP = line;
- if ((string = GetSmartSMString (&lineP)) != NULL)
- {
- *argsCount = *argsCount + 1;
- strcpy ((char*)topic, (char*)string);
- }
- if ((string = GetSmartSMString (&lineP)) != NULL)
- {
- *argsCount = *argsCount + 1;
- strcpy ((char*)volume, (char *)string);
- }
- }
- } /* END OF FUNCTION WmDtGetHelpArgs */
- /******************************<->*************************************
- *
- * void
- * ParseDtSessionHints (pSD, property)
- *
- *
- * Description:
- * -----------
- * This function parses a DtSessionHints string and returns a list of
- * DtSessionItems array. The string should have the syntax:
- *
- *
- *
- * Inputs:
- * ------
- * line = (global) line buffer
- * pSD->rootWindow = default root window of display
- *
- *
- * Outputs:
- * -------
- * Return =
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- void
- ParseDtSessionHints (WmScreenData *pSD, unsigned char *property)
- {
- cfileP = NULL;
- linec = 0;
- parseP = property;
- ParseSessionItems (pSD);
- } /* END OF FUNCTION ParseDtSessionHints */
- /*************************************<->*************************************
- *
- * FindDtSessionMatch(commandArgc, commandArgv, pCD, pSD, pWorkSpaceList,
- * clientMachine)
- *
- * Description:
- * -----------
- * Try to find a match for this client in the session hints.
- * Set up client-session data.
- *
- *
- * Inputs:
- * ------
- * commandArgc - argument count
- * commandArgv - WM_COMMAND argument vector
- * pCD - pointer to client data
- * pSD - pointer to screen data
- * pWorkspaceList - pointer to a list of workspaces (to be returned)
- * clientMachine - string for -host option in session hints
- *
- * Outputs:
- * -------
- * *pCD - client data (may be modified)
- * FindDtSessionMatch - returns True if a match for this client
- * was found in the session hints.
- * *pWorkspaceList - list of workspaces this client should be put
- * into. (needs to be freed)
- *
- *
- * Comments:
- * --------
- * Various pieces of client state (in pCD) are reset when a match
- * is found.
- *
- * The caller must free *pWorkspaceList when done.
- *
- *************************************<->***********************************/
- Boolean FindDtSessionMatch(int commandArgc, char **commandArgv,
- ClientData *pCD, WmScreenData *pSD,
- char **pWorkSpaceList, char *clientMachine)
- {
- int count;
- int relCount;
- int argNum;
- SessionGeom *sessionGeom;
- for (count = 0; count < pSD->totalSessionItems; count++)
- {
- if (!pSD->pDtSessionItems[count].processed &&
- pSD->pDtSessionItems[count].commandArgc == commandArgc)
- {
- if ((clientMachine) &&
- (pSD->pDtSessionItems[count].clientMachine) &&
- (strcmp(clientMachine,
- pSD->pDtSessionItems[count].clientMachine)))
- {
- /*
- * This item has clientMachine string but the
- * clientMachine does not match.
- */
- continue;
- }
- for (argNum = 0; argNum < commandArgc ; argNum++)
- {
- if(strcmp(commandArgv[argNum],
- pSD->pDtSessionItems[count].commandArgv[argNum]))
- {
- /*
- * One mismatch and we quit looking at this item.
- * Decrement argNum so a mismatch on the last item
- * will not look like a match below when comparing
- * argNum == commandArgc
- */
- argNum--;
- break;
- }
- }
- if (argNum == commandArgc)
- {
- /*
- * Made it through all strings so this is a match
- */
-
- pSD->pDtSessionItems[count].processed = True;
- pSD->remainingSessionItems --;
- pCD->clientFlags |= SM_LAUNCHED;
-
- /*
- * Free strings malloc'd for commandArgv for this item
- */
-
- for (relCount = 0; relCount < commandArgc; relCount++)
- {
- XtFree(pSD->pDtSessionItems[count].commandArgv[relCount]);
- }
- XtFree((char *)pSD->pDtSessionItems[count].commandArgv);
- if(pSD->pDtSessionItems[count].clientState)
- {
- pCD->clientState =
- pSD->pDtSessionItems[count].clientState;
- pCD->clientFlags |= SM_CLIENT_STATE;
- }
-
- if(pSD->pDtSessionItems[count].sessionGeom)
- {
- sessionGeom = pSD->pDtSessionItems[count].sessionGeom;
- if (sessionGeom->flags & XValue)
- {
- pCD->clientX = sessionGeom->clientX;
- pCD->clientFlags |= SM_X;
- }
- if (sessionGeom->flags & YValue)
- {
- pCD->clientY = sessionGeom->clientY;
- pCD->clientFlags |= SM_Y;
- }
- if (sessionGeom->flags & WidthValue)
- {
- pCD->clientWidth = sessionGeom->clientWidth;
- pCD->clientFlags |= SM_WIDTH;
- }
- if (sessionGeom->flags & HeightValue)
- {
- pCD->clientHeight = sessionGeom->clientHeight;
- pCD->clientFlags |= SM_HEIGHT;
- }
- /*
- * Free SessionGeom malloc'd space for this item
- */
-
- XtFree((char *)pSD->pDtSessionItems[count].sessionGeom);
- }
- if(pSD->pDtSessionItems[count].clientMachine)
- {
- /*
- * Free clientMachine malloc'd space for this item
- */
-
- XtFree((char *)
- pSD->pDtSessionItems[count].clientMachine);
- pSD->pDtSessionItems[count].clientMachine = NULL;
- }
-
-
- if(pSD->pDtSessionItems[count].workspaces)
- {
- /*
- * The caller is responsible for freeing this
- * data.
- */
- *pWorkSpaceList = pSD->pDtSessionItems[count].workspaces;
- }
- if(pSD->remainingSessionItems == 0)
- {
- /*
- * Free the whole pSD->pDtSessionHints structure
- */
- XtFree((char *)pSD->pDtSessionItems);
- }
-
- return (True);
- }
- } /* not processed and argc's are the same */
- } /* for */
-
- return (False);
-
- } /* END OF FUNCTION FindDtSessionMatch */
- /*************************************<->*************************************
- *
- * void
- * ParseSessionItems (pSD)
- *
- *
- * Description:
- * -----------
- * Parse session items
- *
- * Inputs:
- * ------
- * pSD = pointer to screen data
- * cfileP = (global) file pointer to NULL
- * line = (global) line buffer
- * linec = (global) line count
- * parseP = (global) parse string pointer if cfileP == NULL
- * pSD->rootWindow = default root window of display
- *
- * Outputs:
- * -------
- * linec = (global) line count incremented
- * parseP = (global) parse string pointer if cfileP == NULL
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- void
- ParseSessionItems (WmScreenData *pSD)
- {
- unsigned char *string;
- unsigned char *lineP;
- int count;
-
- /*
- * Parse property string
- */
-
- if(GetNextLine () != NULL)
- {
- pSD->totalSessionItems = atoi((char *)line);
- pSD->remainingSessionItems = pSD->totalSessionItems;
- }
-
- if((pSD->totalSessionItems < 1) ||
- !GetSessionHintsInfo(pSD, pSD->totalSessionItems))
- {
- /*
- * No items or couldn't allocate space
- */
- return;
- }
-
- count = 0;
- while ((count < pSD->totalSessionItems) && (GetNextLine () != NULL))
- {
- lineP = line;
- while ((string = GetSmartSMString (&lineP)) != NULL)
- {
- if (!strcmp((char *)string, "-geometry"))
- {
- /*
- * Parse geometry if it is present
- */
- string = GetSmartSMString(&lineP);
- ParseSessionGeometry (pSD, count, string);
- }
-
- else if (!strcmp((char *)string, "-state"))
- {
- /*
- * Parse the state if it is present
- */
- string = GetSmartSMString(&lineP);
- ParseSessionClientState (pSD, count, string);
- }
- else if (!strcmp((char *)string, "-workspaces"))
- {
- /*
- * Parse the workspaces string if it is present
- */
- string = GetSmartSMString(&lineP);
- ParseSessionWorkspaces (pSD, count, string);
- }
- else if (!strcmp((char *)string, "-cmd"))
- {
- /*
- * Parse the command string if it is present
- */
- string = GetSmartSMString(&lineP);
- ParseSessionCommand (pSD, count, &string);
- }
-
- else if (!strcmp((char *)string, "-host"))
- {
- /*
- * Parse the host string if it is present
- */
- string = GetSmartSMString(&lineP);
- ParseSessionHost (pSD, count, string);
- }
-
- } /* while GetSmartSMString */
-
- count++;
- } /* while GetNextLine */
-
- } /* END OF FUNCTION ParseSessionItems */
- /*************************************<->*************************************
- *
- * ParseSessionClientState (pSD, count, string);
- *
- * Description:
- * -----------
- * Inputs:
- * ------
- * Outputs:
- * -------
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void ParseSessionClientState (WmScreenData *pSD, int count,
- unsigned char *string)
- {
- if(!strcmp((char *)string, "NormalState"))
- {
- pSD->pDtSessionItems[count].clientState = NORMAL_STATE;
- }
- else if(!strcmp((char *)string, "IconicState"))
- {
- pSD->pDtSessionItems[count].clientState = MINIMIZED_STATE;
- }
-
- } /* END OF FUNCTION ParseSessionClientState */
- /*************************************<->*************************************
- *
- * ParseSessionGeometry (pSD, count, string)
- *
- * Description:
- * -----------
- * Inputs:
- * ------
- * Outputs:
- * -------
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void ParseSessionGeometry (WmScreenData *pSD, int count,
- unsigned char *string)
- {
- SessionGeom *pTmpSessionGeom;
- int mask /* = 0 */;
- int X, Y, width, height;
- X = Y = width = height = 0;
-
- /*
- * XParseGeometry
- */
- mask = XParseGeometry((char *)string, &X, &Y, (unsigned int *)&width,
- (unsigned int *)&height);
- if (mask)
- {
- /*
- * Allocate space for the geometry structure
- */
- if ((pTmpSessionGeom =
- (SessionGeom *)XtMalloc (sizeof (SessionGeom))) == NULL)
- {
- Warning (((char *)GETMESSAGE(60, 1, "Insufficient memory for session geometry item")));
- return;
- }
- pTmpSessionGeom->flags = mask;
- pTmpSessionGeom->clientX = X;
- pTmpSessionGeom->clientY = Y;
- pTmpSessionGeom->clientWidth = width;
- pTmpSessionGeom->clientHeight = height;
- pSD->pDtSessionItems[count].sessionGeom = pTmpSessionGeom;
- }
-
- } /* END OF FUNCTION ParseSessionGeometry */
- /*************************************<->*************************************
- *
- * void
- * ParseSessionWorkspaces (pSD, count, string)
- *
- * Description:
- * -----------
- * Inputs:
- * ------
- * Outputs:
- * -------
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void ParseSessionWorkspaces (WmScreenData *pSD, int count,
- unsigned char *string)
- {
- /*
- * Allocate space for the workspaces string
- */
- if ((pSD->pDtSessionItems[count].workspaces =
- (String)XtMalloc ((unsigned int) (strlen((char *)string) + 1))) == NULL)
- {
- Warning (((char *)GETMESSAGE(60, 2, "Insufficient memory for workspaces list in session item")));
- return;
- }
- strcpy(pSD->pDtSessionItems[count].workspaces, (char *)string);
-
- } /* END OF FUNCTION ParseSessionWorkspaces */
- /*************************************<->*************************************
- *
- * void
- * ParseSessionCommand (pSD, count, string)
- *
- * Description:
- * -----------
- * Inputs:
- * ------
- * Outputs:
- * -------
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void ParseSessionCommand (WmScreenData *pSD, int count,
- unsigned char **commandString)
- {
- #define ARG_AMT 100
- int xindex;
- unsigned char **argv;
- int argc = 0;
- int iSizeArgv;
-
- unsigned char *string;
-
- argv = (unsigned char **) XtMalloc (ARG_AMT * sizeof(char *));
- iSizeArgv = ARG_AMT;
-
- while ((string = GetSmartSMString (commandString)) != NULL)
- {
- /*
- * Get pointers to strings in command line and count them
- */
- argv[argc] = string;
- argc ++;
- if (argc >= iSizeArgv)
- {
- iSizeArgv += ARG_AMT;
- argv = (unsigned char **)
- XtRealloc ((char *)argv, (iSizeArgv * sizeof(char *)));
- }
- }
- if ((pSD->pDtSessionItems[count].commandArgv =
- (char **)XtMalloc ((argc) * sizeof(char * ))) == NULL)
- {
- /*
- * Allocate space for saved argv
- */
-
- Warning (((char *)GETMESSAGE(60, 3, "Insufficient memory for commandArgv array")));
- }
- else
- {
- pSD->pDtSessionItems[count].commandArgc = argc;
- for (xindex = 0; xindex < argc ; xindex++)
- {
- if ((pSD->pDtSessionItems[count].commandArgv[xindex] =
- (String) XtMalloc
- ((unsigned int) (strlen((char *)argv[xindex]) + 1))) == NULL)
- {
- /*
- * Allocate space for the next command segment.
- */
- Warning (((char *)GETMESSAGE(60, 4, "Insufficient memory for commandArgv item")));
- }
- else
- {
- strcpy(pSD->pDtSessionItems[count].commandArgv[xindex],
- (char *)argv[xindex]);
- }
- }
- }
- XtFree ((char *) argv);
-
- } /* END OF FUNCTION ParseSessionCommand */
- /*************************************<->*************************************
- *
- * void
- * ParseSessionHost (pSD, count, string)
- *
- * Description:
- * -----------
- * Inputs:
- * ------
- * Outputs:
- * -------
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void ParseSessionHost (WmScreenData *pSD, int count,
- unsigned char *string)
- {
- /*
- * Allocate space for the workspaces string
- */
- if ((pSD->pDtSessionItems[count].clientMachine =
- (String)XtMalloc ((unsigned int) (strlen((char *)string) + 1))) ==
- NULL)
- {
- Warning (((char *)GETMESSAGE(60, 38,
- "Insufficient memory for host name in session item")));
- return;
- }
- strcpy(pSD->pDtSessionItems[count].clientMachine, (char *)string);
-
- } /* END OF FUNCTION ParseSessionHost */
- /*************************************<->*************************************
- *
- * GetSessionHintsInfo (pSD, numItems)
- *
- * Description:
- * -----------
- * Inputs:
- * ------
- * Outputs:
- * -------
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- Boolean GetSessionHintsInfo (WmScreenData *pSD, long numItems)
- {
-
- if ((pSD->pDtSessionItems =
- (DtSessionItem *)XtMalloc (numItems * sizeof (DtSessionItem)))
- == NULL)
- {
- Warning (((char *)GETMESSAGE(60, 5, "Insufficient memory for Dt Session Hints")));
- return(False);
- }
-
- memset ((char *)pSD->pDtSessionItems, 0,
- numItems * sizeof (DtSessionItem));
- return(True);
-
-
- } /* END OF FUNCTION GetSessionHintsInfo */
- /*************************************<->*************************************
- *
- * PeekAhead (currentChar, currentLev)
- *
- *
- * Description:
- * -----------
- * Returns a new level value if this is a new nesting level of quoted string
- * Otherwise it returns a zero
- *
- *
- * Inputs:
- * ------
- * currentChar = current position in the string
- * currentLev = current level of nesting
- *
- *
- * Outputs:
- * -------
- * Returns either a new level of nesting or zero if the character is copied in
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- unsigned int PeekAhead(unsigned char *currentChar,
- unsigned int currentLev)
- {
- Boolean done = False;
- unsigned int tmpLev = 1;
- unsigned int chlen;
- while (((chlen = mblen ((char *)currentChar, MB_CUR_MAX)) > 0) &&
- (chlen == 1) && ((*currentChar == '"') || (*currentChar == '\\'))
- && (done == False))
- {
- currentChar++;
- if(((chlen = mblen ((char *)currentChar, MB_CUR_MAX)) > 0) && (chlen == 1) &&
- ((*currentChar == '"') || (*currentChar == '\\')))
- {
- tmpLev++;
- if(*currentChar == '"')
- {
- done = True;
- }
- else
- {
- currentChar++;
- }
- }
- }
- /*
- * Figure out if this is truly a new level of nesting - else ignore it
- * This section probably could do some error checking and return -1
- * If so, change type of routine from unsigned int to int
- */
- if(done == True)
- {
- return(tmpLev);
- }
- else
- {
- return(0);
- }
- } /* END OF FUNCTION PeekAhead */
- /*************************************<->*************************************
- *
- * SyncModifierStrings (fileName)
- *
- * Description:
- * -----------
- * This function updates modifierStrings table so that Mwm uses the correct
- * modifier to keysym mapping. Specifically, fix up the Alt and Meta bindings.
- *
- * Inputs:
- * ------
- * fileName
- *
- * Outputs:
- * -------
- * fileName
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void SyncModifierStrings(void)
- {
- XModifierKeymap *map;
- int i, j, k = 0;
- map = XGetModifierMapping (DISPLAY);
- for (i = 0; i < 8; i++)
- {
- for (j = 0; j < map->max_keypermod; j++)
- {
- if (map->modifiermap[k])
- {
- KeySym ks = XKeycodeToKeysym(DISPLAY, map->modifiermap[k], 0);
- char *nm = XKeysymToString(ks);
- /* Compare, ignoring the trailing '_L' or '_R' in keysym */
- if (nm && !strncmp("Alt", nm, 3))
- {
- modifierStrings[ALT_INDEX].mask = (1<<i);
- }
- else if (nm && !strncmp("Meta", nm, 4))
- {
- modifierStrings[META_INDEX].mask = (1<<i);
- }
- }
- k++;
- }
- }
- XFreeModifiermap(map);
- }
- /*************************************<->*************************************
- *
- * ProcessWmFile ()
- *
- *
- * Description:
- * -----------
- * This function reads the mwm resource description file and processes the
- * resources that are described.
- *
- *
- * Inputs:
- * ------
- * wmGD.bitmapDirectory = bitmapDirectory resource value
- * pSD->buttonBindings = buttonBindings resource value
- * wmGD.configFile = configuration file resource value
- * pSD->keyBindings = keyBindings resource value
- * wmGD.rootWindow = default root window of display
- * HOME = environment variable for home directory
- * functionTable = window manager function parse table
- *
- *
- * Outputs:
- * -------
- * wmGD.buttonSpecs = list of button binding specifications
- * wmGD.keySpecs = list of key binding specification
- * wmGD.menuSpecs = list of menu specifications
- * *wmGD.acceleratorMenuSpecs = initialized array of (MenuSpec *)
- * wmGD.acceleratorMenuCount = 0
- *
- *
- * Comments:
- * --------
- * If there are more than MAXLINE characters on a line the excess characters
- * are truncated.
- *
- *************************************<->***********************************/
- #define MENU_SPEC "menu"
- #define BUTTON_SPEC "buttons"
- #define KEY_SPEC "keys"
- #define FRONT_PANEL_SPEC DTWM_FP_PANEL_OLD
- #define DROP_EFFECTS_SPEC DTWM_FP_DROP_EFFECTS
- #define PANEL_SPEC DTWM_FP_PANEL
- #define BOX_SPEC DTWM_FP_BOX
- #define CONTROL_SPEC DTWM_FP_CONTROL
- #define INCLUDE_SPEC DTWM_FP_INCLUDE
- #define ANIMATION_SPEC DTWM_FP_ANIMATION
- #define SWITCH_SPEC DTWM_FP_SWITCH
- void ProcessWmFile (WmScreenData *pSD, Boolean bNested)
- {
- unsigned char *lineP;
- unsigned char *string;
- unsigned int n;
- MenuSpec *menuSpec;
- if (!bNested)
- {
- /*
- * Initialize global data values that are set based on data in
- * the mwm resource description file.
- */
- pSD->buttonSpecs = NULL;
- pSD->keySpecs = NULL;
- pSD->menuSpecs = NULL;
- /**** hhhhhhhhhhhh ******/
- GetFunctionTableValues (&F_EXEC_INDEX, &F_NOP_INDEX, &F_ACTION_INDEX);
- /*
- * Find and parse the default system menu string, if it exists.
- */
- cfileP = NULL;
- linec = 0;
- if (((parseP = (unsigned char *) builtinSystemMenu) != NULL) &&
- (GetNextLine () != NULL))
- {
- lineP = line;
- ParseMenuSet (pSD, lineP);
- }
- linec = 0;
- if (((parseP = (unsigned char *) builtinRootMenu) != NULL) &&
- (GetNextLine () != NULL))
- {
- lineP = line;
- ParseMenuSet (pSD, lineP);
- }
- if (wmGD.useFrontPanel && !wmGD.dtSD &&
- (XDefaultScreen (wmGD.display) == pSD->screen))
- {
- wmGD.dtSD = pSD; /* only one per display */
- }
- /*
- * Find and associate a stream with the window manager resource
- * description file.
- */
- if ((cfileP = FopenConfigFile ()) == NULL)
- {
- if (!wmGD.useStandardBehavior)
- Warning (((char *)GETMESSAGE(60, 6, "Cannot open configuration file")));
- return;
- }
- } /* end if (!bNested) */
- /*
- * Parse the information in the configuration file.
- * If there are more than MAXLINE characters on a line the excess are
- * truncated.
- */
- linec = 0;
- while ((GetNextLine () != NULL)) /* not EOF nor read error */
- {
- lineP = line;
- if ((*line == '!') || (string = GetString (&lineP)) == NULL)
- /* empty or comment line */
- {
- continue;
- }
- ToLower ((char *)string);
- if (!strcmp ((char *)string, MENU_SPEC))
- {
- ParseMenuSet (pSD, lineP);
- }
- else if (!strcmp ((char *) string, BUTTON_SPEC))
- {
- ParseButtonSet (pSD, lineP);
- }
- else if (!strcmp ((char *) string, KEY_SPEC))
- {
- ParseKeySet (pSD, lineP);
- }
- else if (!strcmp ((char *)string, INCLUDE_SPEC))
- {
- ParseIncludeSet (pSD, lineP);
- }
- }
- fclose (cfileP);
- /*
- * Create and initialize the pSD->acceleratorMenuSpecs array.
- * This assumes we create pointers to MenuSpecs within ProcessWmFile().
- * Set pSD->acceleratorMenuCount to 0.
- */
- /* count the number of menu specifications */
- n = 0;
- menuSpec = pSD->menuSpecs;
- while (menuSpec)
- {
- n++;
- menuSpec = menuSpec->nextMenuSpec;
- }
- /* allocate the array and initialize to zeros */
- pSD->acceleratorMenuSpecs = NULL;
- if (n)
- {
- pSD->acceleratorMenuSpecs =
- (MenuSpec **) XtCalloc (n, sizeof (MenuSpec *));
- if (pSD->acceleratorMenuSpecs == NULL)
- {
- Warning (((char *)GETMESSAGE(60, 7, "Insufficient memory for menu accelerators")));
- }
- }
- pSD->acceleratorMenuCount = 0;
- } /* END OF FUNCTION ProcessWmFile */
- /**** This function stolen from Xt/Intrinsic.c ****/
- /* The implementation of this routine is operating system dependent */
- static char *ExtractLocaleName(String lang)
- {
- return lang;
- }
- #define RC_CONFIG_SUBDIR "/config/"
- #define RC_DEFAULT_CONFIG_SUBDIR "/config/C"
- /*************************************<->*************************************
- *
- * FopenConfigFile ()
- *
- *
- * Description:
- * -----------
- * This function searches for, opens, and associates a stream with the mwm
- * resource description file,
- *
- *
- * Inputs:
- * ------
- * wmGD.configFile = configuration file resource value.
- * HOME = environment variable for home directory
- *
- *
- * Outputs:
- * -------
- * Return = If successful, a pointer to the FILE structure associated with
- * the configuration file. Otherwise, NULL.
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- FILE *FopenConfigFile (void)
- {
- char *LANG, *LANGp;
- FILE *fileP;
- char *homeDir = XmeGetHomeDirName();
- Boolean stackPushed;
- /*
- * Get the LANG environment variable
- * make copy since another call to getenv will blast the value.
- */
- LANGp = setlocale(LC_CTYPE, NULL);
- /*
- * setlocale not guaranteed to return $LANG -- extract
- * something usable.
- */
- LANGp = ExtractLocaleName (LANGp);
- if ((LANGp == NULL) || (strlen(LANGp) == 0))
- {
- LANG = NULL;
- }
- else
- {
- if ((LANG = (char *) XtMalloc(strlen(LANGp) +1)) == NULL)
- {
- PWarning (((char *)GETMESSAGE(60, 41, "Insufficient memory to get LANG environment variable.")));
- return(NULL);
- }
- strcpy(LANG, LANGp);
- }
- /*
- * To get a name for the file first look at the value of the configFile
- * resource. Interpret "~/.." as relative to the user's home directory.
- * Use the LANG variable if set and .mwmrc is in $HOME/$LANG/.mwmrc
- */
- if (pConfigStackTop && pConfigStackTop->tempName)
- {
- fileP = fopen (pConfigStackTop->tempName, "r");
- return (fileP);
- }
- stackPushed = (pConfigStackTop && (pConfigStackTop != pConfigStack));
- fileP = NULL;
- cfileName[0] = '\0';
- if ((wmGD.configFile != NULL) && (wmGD.configFile[0] != '\0'))
- /* pointer to nonNULL string */
- {
- if ((wmGD.configFile[0] == '~') && (wmGD.configFile[1] == '/'))
- /* handle "~/..." */
- {
- strcpy (cfileName, homeDir);
- if (LANG != NULL)
- {
- strncat(cfileName, "/", MAXWMPATH-strlen(cfileName));
- strncat(cfileName, LANG, MAXWMPATH-strlen(cfileName));
- }
- strncat(cfileName, &(wmGD.configFile[1]), MAXWMPATH-strlen(cfileName));
- if ((fileP = fopen (cfileName, "r")) != NULL)
- {
- if (LANG != NULL) {
- XtFree(LANG);
- LANG = NULL;
- }
- }
- else
- {
- /*
- * Just try $HOME/.mwmrc
- */
- strcpy (cfileName, homeDir);
- strncat(cfileName, &(wmGD.configFile[1]),
- MAXWMPATH-strlen(cfileName));
- if ((fileP = fopen (cfileName, "r")) != NULL)
- {
- if (LANG != NULL) {
- XtFree(LANG);
- LANG = NULL;
- }
- }
- }
-
- }
- else
- /* relative to current directory or absolute */
- {
- char *pch;
- pch = (char *) GetNetworkFileName (wmGD.configFile);
- if ((fileP = fopen (pch, "r")) != NULL)
- {
- strncpy (cfileName, pch, MAXWMPATH);
- }
- XtFree (pch);
-
- if ((fileP == NULL) && !stackPushed)
- {
- if ((fileP = fopen (wmGD.configFile, "r")) != NULL)
- {
- if (LANG != NULL) {
- XtFree(LANG);
- LANG = NULL;
- }
- return(fileP);
- }
- }
- else if ((fileP == NULL) && stackPushed)
- {
- strcpy (cfileName, wmGD.configFile);
- }
- }
- }
- if ((fileP == NULL) && !stackPushed)
- {
- /*
- * The configFile resource didn't do it for us.
- * First try HOME_MWMRC, then try SYS_MWMRC .
- */
- #define HOME_MWMRC "/.mwmrc"
- #define SLASH_MWMRC "/system.mwmrc"
- strcpy (cfileName, homeDir);
- if (MwmBehavior)
- {
- /*
- *
- * Looking for $HOME/$LANG/.mwmrc
- * --or--if $LANG is NULL
- * Looking for $HOME/.mwmrc
- *
- */
- if (LANG != NULL)
- {
- strncat(cfileName, "/", MAXWMPATH-strlen(cfileName));
- strncat(cfileName, LANG, MAXWMPATH-strlen(cfileName));
- }
- strncat(cfileName, HOME_MWMRC, MAXWMPATH - strlen(cfileName));
- }
- else
- {
- /*
- *
- * Looking for $HOME/.dt/$LANG/dtwmrc
- *
- * --or--if $LANG is NULL--
- *
- * Looking for $HOME/.dt/dtwmrc
- *
- */
- strncat(cfileName, "/.dt/", MAXWMPATH-strlen(cfileName));
- if (LANG != NULL)
- {
- strncat(cfileName, LANG, MAXWMPATH-strlen(cfileName));
- }
- strncat(cfileName, LANG_DT_WMRC, MAXWMPATH - strlen(cfileName));
- }
- if ((fileP = fopen (cfileName, "r")) != NULL)
- {
- if (LANG != NULL) {
- XtFree(LANG);
- LANG = NULL;
- }
- }
- else
- {
- /*
- * Just try $HOME/.mwmrc
- */
- strcpy (cfileName, homeDir);
- if (MwmBehavior)
- {
- /*
- * Just try $HOME/.mwmrc
- */
- strncat(cfileName, HOME_MWMRC, MAXWMPATH - strlen(cfileName));
- }
- else
- {
- /*
- * Just try $HOME/.dt/dtwmrc
- */
- strncat(cfileName, HOME_DT_WMRC, MAXWMPATH - strlen(cfileName));
- }
- if ((fileP = fopen (cfileName, "r")) != NULL)
- {
- if (LANG != NULL) {
- XtFree(LANG);
- LANG = NULL;
- }
- }
- }
- }
- #define DTLIBDIR CDE_INSTALLATION_TOP
- #define DTADMINDIR CDE_CONFIGURATION_TOP
- #define SLASH_DT_WMRC "/sys.dtwmrc"
- if ((fileP == NULL) && !stackPushed)
- {
- /*
- * No home-based config file. Try the admin directory.
- */
- strcpy(cfileName, DTADMINDIR);
- strncat(cfileName, RC_CONFIG_SUBDIR, MAXWMPATH-strlen(cfileName));
- strncat(cfileName, LANG, MAXWMPATH-strlen(cfileName));
- strncat(cfileName, SLASH_DT_WMRC, MAXWMPATH - strlen(cfileName));
- if (((fileP = fopen (cfileName, "r")) == NULL) && LANG && *LANG)
- {
- /* Try it with no LANG */
- strcpy(cfileName, DTADMINDIR);
- strncat(cfileName, RC_CONFIG_SUBDIR, MAXWMPATH-strlen(cfileName));
- strncat(cfileName, SLASH_DT_WMRC, MAXWMPATH - strlen(cfileName));
- }
- if ((fileP = fopen (cfileName, "r")) != NULL)
- {
- XtFree(LANG);
- LANG = NULL;
- }
- }
- if ((fileP == NULL) && !stackPushed)
- {
- #ifndef LIBDIR
- #define LIBDIR "/usr/lib/X11"
- #endif
- if (LANG != NULL)
- {
- if (MwmBehavior)
- {
- strcpy(cfileName, LIBDIR);
- strncat(cfileName, "/", MAXWMPATH-strlen(cfileName));
- strncat(cfileName, LANG, MAXWMPATH-strlen(cfileName));
- strncat(cfileName, SLASH_MWMRC, MAXWMPATH - strlen(cfileName));
- }
- else
- {
- strcpy(cfileName, DTLIBDIR);
- strncat(cfileName, RC_CONFIG_SUBDIR, MAXWMPATH-strlen(cfileName));
- strncat(cfileName, LANG, MAXWMPATH-strlen(cfileName));
- strncat(cfileName, SLASH_DT_WMRC, MAXWMPATH - strlen(cfileName));
- }
- if ((fileP = fopen (cfileName, "r")) != NULL)
- {
- XtFree(LANG);
- LANG = NULL;
- }
- }
- if ((fileP == NULL) && !stackPushed)
- {
- if (MwmBehavior)
- {
- strcpy(cfileName, LIBDIR);
- strncat(cfileName, SLASH_MWMRC, MAXWMPATH - strlen(cfileName));
- fileP = fopen (cfileName, "r");
- }
- else
- {
- strcpy(cfileName, DTLIBDIR);
- strncat(cfileName, RC_DEFAULT_CONFIG_SUBDIR,
- MAXWMPATH - strlen(cfileName));
- strncat(cfileName, SLASH_DT_WMRC, MAXWMPATH - strlen(cfileName));
- fileP = fopen (cfileName, "r");
- }
- }
- }
- if (!fileP)
- {
- char *pch;
- /*
- * handle "<host>:<path>" form of file name
- */
- pch = (char *) GetNetworkFileName (cfileName);
- if ((fileP = fopen (cfileName, "r")) != NULL)
- {
- strncpy (cfileName, pch, MAXWMPATH);
- XtFree (pch);
- }
- /*
- * Either not "<host>:<path>" form or there was a
- * problem up above. This is the last attempt to
- * open something.
- */
- if (!fileP)
- {
- fileP = fopen (cfileName, "r");
- }
- }
- if (!pConfigStack)
- {
- ConfigStackInit (cfileName);
- }
- if (wmGD.cppCommand && *wmGD.cppCommand)
- {
- /*
- * Run the file through the C-preprocessor
- */
- PreprocessConfigFile ();
- if (pConfigStackTop && pConfigStackTop->cppName)
- {
- if(fileP) {
- fclose(fileP);
- }
- /* open the result */
- fileP = fopen (pConfigStackTop->cppName, "r");
- }
- }
- if (LANG != NULL)
- {
- XtFree(LANG);
- LANG = NULL;
- }
- return (fileP);
- } /* END OF FUNCTION FopenConfigFile */
- /*************************************<->*************************************
- *
- * SaveMenuAccelerators (pSD, newMenuSpec)
- *
- *
- * Description:
- * -----------
- * This function saves the MenuSpec pointer in pSD->acceleratorMenuSpecs.
- *
- *
- * Inputs:
- * ------
- * newMenuSpec = pointer to MenuSpec to be saved.
- * pSD->acceleratorMenuSpecs =
- * pSD->acceleratorMenuCount =
- *
- *
- * Outputs:
- * -------
- * pSD->acceleratorMenuSpecs = possibly updated
- * pSD->acceleratorMenuCount = possibly updated
- *
- *
- * Comments:
- * --------
- * We assume only MenuSpecs created within ProcessWmFile() are to be saved.
- * Otherwise, we may cause override the limits of pSD->acceleratorMenuSpecs.
- *
- *************************************<->***********************************/
- void SaveMenuAccelerators (WmScreenData *pSD, MenuSpec *newMenuSpec)
- {
- MenuSpec **pMenuSpec;
- pMenuSpec = pSD->acceleratorMenuSpecs;
- if (pMenuSpec == NULL)
- return;
- while ((*pMenuSpec != NULL) && (*pMenuSpec != newMenuSpec))
- {
- pMenuSpec++;
- }
- if (*pMenuSpec == NULL)
- {
- *pMenuSpec = newMenuSpec;
- pSD->acceleratorMenuCount++;
- }
- } /* END OF FUNCTION SaveMenuAccelerators */
- /*************************************<->*************************************
- *
- * ParseMenuSet (pSD, lineP)
- *
- *
- * Description:
- * -----------
- * Menu pane specification found. Parse the following syntax:
- *
- * v
- * Menu menu_pane_name
- * {
- * label [mnemonic] [accelerator] function
- * label [mnemonic] [accelerator] function
- * ...
- * label [mnemonic] [accelerator] function
- * }
- *
- *
- * Inputs:
- * ------
- * cfileP = (global) file pointer to fopened configuration file or NULL
- * lineP = pointer to menu name in line buffer
- * line = (global) line buffer
- * linec = (global) line count
- * parseP = (global) parse string pointer if cfileP == NULL
- * pSD->rootWindow = default root window of display
- * wmGD.bitmapDirectory = bitmapDirectory resource value
- * HOME = environment variable for home directory
- *
- *
- * Outputs:
- * -------
- * linec = (global) line count incremented
- * parseP = (global) parse string pointer if cfileP == NULL
- * pSD->menuSpecs = list of menu specifications
- *
- *
- * Comments:
- * --------
- * Skips unnamed menu specifications.
- * This means custom menu specifications can be distinguished by NULL name.
- *
- *************************************<->***********************************/
- static void ParseMenuSet (WmScreenData *pSD, unsigned char *lineP)
- {
- unsigned char *string;
- MenuSpec *menuSpec;
-
- /*
- * If menu name is NULL then skip this pane specification.
- */
- if ((string = GetString (&lineP)) == NULL)
- {
- return;
- }
- /*
- * Allocate space for the menu specification structure.
- */
- if ((menuSpec = (MenuSpec *)XtMalloc (sizeof (MenuSpec))) == NULL)
- {
- PWarning (((char *)GETMESSAGE(60, 9, "Insufficient memory for menu")));
- return;
- }
- menuSpec->currentContext = 0;
- menuSpec->menuWidget = NULL;
- menuSpec->whichButton = SELECT_BUTTON; /* Button1 selection default */
- menuSpec->menuItems = NULL;
- menuSpec->accelContext = 0;
- menuSpec->accelKeySpecs = NULL;
- menuSpec->nextMenuSpec = NULL;
- /*
- * Allocate and fill space for the menu name.
- */
- if ((menuSpec->name =
- (String)XtMalloc ((unsigned int) (strlen ((char *)string) + 1)))
- == NULL)
- {
- PWarning (((char *)GETMESSAGE(60, 10, "Insufficient memory for menu")));
- XtFree ((char *)menuSpec);
- return;
- }
- strcpy (menuSpec->name, (char *)string);
- /*
- * Add the empty structure to the head of the menu specification list.
- */
- menuSpec->nextMenuSpec = pSD->menuSpecs;
- pSD->menuSpecs = menuSpec;
- /*
- * Require leading '{' on the next line.
- */
- while ((GetNextLine () != NULL)) /* not EOF nor read error */
- {
- lineP = line;
- ScanWhitespace(&lineP);
- if ((lineP == NULL) || (*line == '!') || (*lineP == '\0') || (*lineP == '#'))
- /* ignore empty or comment line */
- {
- continue;
- }
- if (*lineP == '{')
- /* found '{' */
- {
- break;
- }
- /* not a '{' */
- PWarning (((char *)GETMESSAGE(60, 11, "Expected '{' after menu name")));
- return;
- }
- /*
- * Found leading "{" or EOF.
- * Parse menu item specifications until "}" or EOF found.
- */
- menuSpec->menuItems = PARSE_MENU_ITEMS (pSD, menuSpec);
- } /* END OF FUNCTION ParseMenuSet */
- /*************************************<->*************************************
- *
- * MenuItem *
- * ParseMwmMenuStr (pSD, menuStr)
- *
- *
- * Description:
- * -----------
- * This function parses a WMW_MENU string and returns a list of
- * MenuItems structures. The string should have the syntax:
- *
- * label [mnemonic] [accelerator] function
- * label [mnemonic] [accelerator] function
- * ...
- * label [mnemonic] [accelerator] function
- *
- *
- * Inputs:
- * ------
- * line = (global) line buffer
- * pSD->rootWindow = default root window of display
- * wmGD.bitmapDirectory = bitmapDirectory resource value
- * HOME = environment variable for home directory
- * functionTable = window manager function parse table
- *
- *
- * Outputs:
- * -------
- * Return = list of MenuItem structures or NULL
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- MenuItem *ParseMwmMenuStr (WmScreenData *pSD, unsigned char *menuStr)
- {
- cfileP = NULL;
- linec = 0;
- parseP = menuStr;
- return (PARSE_MENU_ITEMS (pSD, NULL));
- } /* END OF FUNCTION ParseMwmMenuStr */
- /*************************************<->*************************************
- *
- * static MenuItem *
- * ParseMenuItems (pSD, menuSpec)
- *
- *
- * Description:
- * -----------
- * Parse menu item specifications:
- *
- * label [mnemonic] [accelerator] function
- * label [mnemonic] [accelerator] function
- * ...
- * label [mnemonic] [accelerator] function
- * [}]
- *
- *
- * Inputs:
- * ------
- * pSD = pointer to screen data
- * cfileP = (global) file pointer to fopened configuration file or NULL
- * line = (global) line buffer
- * linec = (global) line count
- * parseP = (global) parse string pointer if cfileP == NULL
- * pSD->rootWindow = default root window of display
- * wmGD.bitmapDirectory = bitmapDirectory resource value
- * HOME = environment variable for home directory
- *
- *
- * Outputs:
- * -------
- * linec = (global) line count incremented
- * parseP = (global) parse string pointer if cfileP == NULL
- * Return = list of MenuItem structures or NULL
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static MenuItem *ParseMenuItems (WmScreenData *pSD)
- {
- unsigned char *string;
- unsigned char *lineP;
- MenuItem *firstMenuItem;
- MenuItem *lastMenuItem;
- MenuItem *menuItem;
- int ix;
-
- /*
- * Parse "label [mnemonic] [accelerator] function" or
- * "<client command>[.<client command>]*"
- * lines until "}" or EOF found.
- */
- firstMenuItem = lastMenuItem = NULL;
- while ((GetNextLine () != NULL))
- {
- lineP = line;
- if ((*line == '!') || (*line == '#') || (string = GetString (&lineP)) == NULL)
- /* ignore empty or comment lines */
- {
- continue;
- }
- if (*string == '}') /* finished with menu set. */
- {
- break;
- }
- /*
- * Allocate space for the menu item structure.
- */
- if ((menuItem = (MenuItem *)XtMalloc (sizeof (MenuItem))) == NULL)
- {
- PWarning (((char *)GETMESSAGE(60, 12, "Insufficient memory for menu item")));
- continue;
- }
- menuItem->nextMenuItem = NULL;
- menuItem->wmFunction = (WmFunction)NULL;
- menuItem->wmFuncArgs = NULL;
- {
- /*
- * Parse the menu item label.
- */
- if (!ParseWmLabel (pSD, menuItem, string))
- {
- XtFree ((char *)menuItem);
- continue;
- }
- }
- /*
- * Parse any menu function mnemonic.
- */
- ParseWmMnemonic (&lineP, menuItem);
- /*
- * Parse any menu function accelerator.
- */
- if (!ParseWmAccelerator (&lineP, menuItem))
- {
- XtFree ((char *)menuItem);
- continue;
- }
- /*
- * Parse the menu function name if this is not a client
- * command. If it is a client command, then the wmFunction
- * field should already be set, as well as the ix variable,
- * but we do want to search for a menu item name that occupies
- * the same place as the function does for normal menu items.
- */
- ix = ParseWmFunction (&lineP, CRS_MENU, &menuItem->wmFunction);
- /*
- * Determine context sensitivity and applicability mask.
- */
- menuItem->greyedContext = functionTable[ix].greyedContext;
- menuItem->mgtMask = functionTable[ix].mgtMask;
- if ((menuItem->wmFunction == F_Toggle_Front_Panel) &&
- ((wmGD.useFrontPanel == False) ||
- (wmGD.dtSD != pSD)))
- {
- /*
- * disallow this function if there's no front
- * panel on this screen.
- */
- menuItem->greyedContext |= (F_CONTEXT_ALL |
- F_SUBCONTEXT_IB_WICON |
- F_SUBCONTEXT_IB_IICON);
- }
- /*
- * Apply the function argument parser.
- */
- if (!(*(functionTable [ix].parseProc))
- (&lineP, menuItem->wmFunction, &menuItem->wmFuncArgs))
- {
- FreeMenuItem (menuItem);
- continue; /* skip this menu item */
- }
- /*
- * Add this item to the menu specification.
- */
- if (lastMenuItem != NULL) /* not first */
- {
- lastMenuItem->nextMenuItem = menuItem;
- }
- else
- {
- firstMenuItem = menuItem;
- }
- lastMenuItem = menuItem;
- }
- return (firstMenuItem);
- } /* END OF FUNCTION ParseMenuItems */
- /*************************************<->*************************************
- *
- * ParseWmLabel (pSD, menuItem, string)
- *
- *
- * Description:
- * -----------
- * Parse a menu label string.
- *
- *
- * Inputs:
- * ------
- * pSD = pointer to screen data
- * menuItem = pointer to MenuItem structure
- * string = label string
- *
- *
- * Outputs:
- * -------
- * menuItem->label
- * menuItem->labelType
- * menuItem->labelBitmapCache
- * Return = boolean, FALSE iff insufficient memory
- *
- *
- * Comments:
- * --------
- * We have two label types: XmSTRING and XmPIXMAP
- * We allocate and fill the label field with string and set the type to
- * XmSTRING. If string = "@<bitmap_file>", and <bitmap_file> contains a
- * with which to build a label image we save the bitmap in the MenuItem
- * structure and set the type to XmPIXMAP.
- *
- *************************************<->***********************************/
- static Boolean ParseWmLabel (WmScreenData *pSD, MenuItem *menuItem,
- unsigned char *string)
- {
- /*
- * Allocate the label field and copy string.
- */
- if ((menuItem->label = (String)
- XtMalloc ((unsigned int)(strlen ((char *)string) + 1))) == NULL)
- {
- PWarning (((char *)GETMESSAGE(60, 13, "Insufficient memory for menu item")));
- return (FALSE);
- }
- strcpy (menuItem->label, (char *)string);
- menuItem->labelType = XmSTRING;
- if (*string == '@')
- /*
- * Here: string = "@<bitmap file>"
- * Try to find the label bitmap in the bitmap cache or read the label
- * bitmap file.
- */
- {
- string++; /* skip "@" */
- if ((menuItem->labelBitmapIndex = GetBitmapIndex (pSD,
- (char *)string, True)) >= 0)
- {
- menuItem->labelType = XmPIXMAP;
- }
- }
- return (TRUE);
- } /* END OF FUNCTION ParseWmLabel */
- /*************************************<->*************************************
- *
- * ParseWmMnemonic (linePP, menuItem)
- *
- *
- * Description:
- * -----------
- * Parse an optional menu function mnemonic.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * menuItem = pointer to MenuItem structure
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * menuItem->mnemonic = valid mnemonic character or NULL.
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static void ParseWmMnemonic (unsigned char **linePP, MenuItem *menuItem)
- {
- unsigned char *lineP = *linePP;
- unsigned char *mnemonic;
- /*
- * Skip leading white space.
- */
- ScanWhitespace (&lineP);
- menuItem->mnemonic = (KeySym)NULL;
- if (*lineP == '_')
- /*
- * We have a mnemonic specification.
- * Get the next string (we only use the first character).
- * If no string exists, the labelType is not XmSTRING, or does not contain
- * the first character, then skip the string and return.
- * Otherwise, accept the first character as a mnemonic.
- */
- {
- KeySym ks;
- lineP++;
- mnemonic = GetString(&lineP);
- if (menuItem->labelType == XmSTRING &&
- mnemonic != NULL &&
- (ks = XStringToKeysym((char *)mnemonic)) != NoSymbol &&
- strchr(menuItem->label, (char)(ks & 0xff)) != NULL)
- {
- menuItem->mnemonic = ks;
- }
- else
- {
- PWarning (((char *)GETMESSAGE(60, 14, "Invalid mnemonic specification")));
- }
- }
- *linePP = lineP; /* consume any string */
- } /* END OF FUNCTION ParseWmMnemonic */
- /*************************************<->*************************************
- *
- * ParseWmAccelerator (linePP, menuItem)
- *
- *
- * Description:
- * -----------
- * Parse an optional menu function accelerator.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * menuItem = pointer to MenuItem structure
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * menuItem->accelText = pointer to an accelerator string or NULL.
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static Boolean ParseWmAccelerator (unsigned char **linePP, MenuItem *menuItem)
- {
- unsigned char *lineP;
- String string;
- unsigned int eventType;
- unsigned int state;
- KeyCode keycode;
- Boolean status;
- menuItem->accelState = 0;
- menuItem->accelKeyCode = 0;
- menuItem->accelText = NULL;
- status = TRUE;
- /*
- * If linePP contains NULL, then abort.
- */
- if (*linePP == (unsigned char *) NULL) return(FALSE);
- /*
- * Skip leading white space.
- */
- ScanWhitespace (linePP);
- lineP = *linePP;
- /*
- * If the second character is not ".", and an accelerator specification
- * exists, then process and save the specification string.
- */
- if ((*lineP != '\0') && /* something follows */
- (*lineP != '!') && /* skip if we have the ! WmFunction */
- (*lineP != 'f') &&
- (*(lineP+1) != '.')) /* skip if we have f.xxx WmFunction */
- {
- if (ParseKeyEvent(&lineP, &eventType, &keycode, &state))
- {
- if ((string = (String) XtMalloc
- ((unsigned int) (lineP - *linePP + 1))) == NULL)
- {
- PWarning (((char *)GETMESSAGE(60, 15, "Insufficient memory for accelerator specification")));
- status = FALSE;
- }
- else
- /*
- * Save the accelerator state and keycode.
- * Process and save the accelerator text.
- */
- {
- ProcessAccelText (*linePP, lineP, (unsigned char *) string);
- menuItem->accelState = state;
- menuItem->accelKeyCode = keycode;
- menuItem->accelText = string;
- }
- }
- else
- {
- PWarning (((char *)GETMESSAGE(60, 16, "Invalid accelerator specification")));
- status = FALSE;
- }
- *linePP = lineP; /* consume the specification */
- }
- return (status);
- } /* END OF FUNCTION ParseWmAccelerator */
- /*************************************<->*************************************
- *
- * int
- * ParseWmFunction (linePP, res_spec, pWmFunction)
- *
- *
- * Description:
- * -----------
- * Parse a button, key, or menu function name and return its function table
- * index.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * res_spec = resource specification type (key, button, or menu).
- * pWmFunction = pointer to window manager function destination.
- * functionTable = window manager function parse table
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * pWmFunction = pointer to parsed window manager function.
- * Return = function table index of parsed function.
- *
- *
- * Comments:
- * --------
- * Uses F_Nop if the function name or resource type is invalid.
- *
- *************************************<->***********************************/
- int ParseWmFunction (unsigned char **linePP, unsigned int res_spec,
- WmFunction *pWmFunction)
- {
- unsigned char *lineP = *linePP;
- unsigned char *string;
- int low, mid, high, cmp;
- /*
- * Skip leading white space.
- */
- ScanWhitespace (&lineP);
- /*
- * Have function string (may be NULL or a comment).
- * Handle the special case of '!'
- */
- if (*lineP == '!')
- {
- *linePP = ++lineP;
- *pWmFunction = F_Exec;
- return (F_EXEC_INDEX);
- }
- /*
- * Identify the function corresponding to the specified name.
- * Try binary search of the window manager function parse table.
- * Assume f.nop if the function and resource type cannot be matched.
- * This handles NULL and comment strings, bad function names, and functions
- * in inappropriate resource sets.
- */
- string = GetString (&lineP);
- *linePP = lineP;
- if (string != NULL)
- {
- ToLower ((char *)string);
- low = 0;
- high = WMFUNCTIONTABLESIZE - 1;
- while (low <= high)
- {
- mid = (low + high)/2;
- cmp = strcmp (functionTable[mid].funcName, (char *)string);
- if (!cmp)
- /*
- * Function name match
- * Require proper resource type for the function.
- */
- {
- if (res_spec & functionTable[mid].resource)
- {
- *pWmFunction = functionTable[mid].wmFunction;
- return (mid);
- }
- /* invalid resource: use F_Nop */
- break;
- }
- /*
- * Function name mismatch
- */
- if (cmp > 0)
- {
- high = mid - 1;
- }
- else
- {
- low = mid + 1;
- }
- }
- }
- /*
- * Not found: assume f.nop
- */
- *pWmFunction = F_Nop;
- return (F_NOP_INDEX);
- } /* END OF FUNCTION ParseWmFunction */
- /*************************************<->*************************************
- *
- * ParseWmFuncMaybeStrArg (linePP, wmFunction, pArgs)
- *
- *
- * Description:
- * -----------
- * Parses a window manager function with a null or string argument.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * wmFunction = function (not used).
- * pArgs = pointer to argument destination.
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * pArgs = pointer to parsed argument string.
- * Return = FALSE iff insufficient memory
- *
- *
- * Comments:
- * --------
- * Only used to parse arguments for F_Lower, F_Raise, and F_Raise_Lower.
- * If it is used for any other function, be sure to change FreeMenuItem ()
- * accordingly.
- *
- *************************************<->***********************************/
- Boolean ParseWmFuncMaybeStrArg (unsigned char **linePP,
- WmFunction wmFunction, String *pArgs)
- {
- unsigned char *string = *linePP;
- unsigned int len;
- ScanWhitespace (&string);
- /*
- if (*lineP == '-')
- {
- *linePP = ++lineP;
- return (ParseWmFuncStrArg (linePP, wmFunction, pArgs));
- }
- */
- #if 0
- else if (*lineP == '"' && *(lineP+1) == '-')
- {
- /* kill off '-' */
- strcpy ((char *) (lineP+1), (char *) (lineP+2));
- return (ParseWmFuncStrArg (linePP, wmFunction, pArgs));
- }
- #endif
- if ((len = strlen ((char *)string)) != 0)
- {
- if ((*pArgs = (String)XtMalloc (len + 1)) == NULL)
- {
- PWarning (((char *)GETMESSAGE(60, 17, "Insufficient memory")));
- return (FALSE);
- }
- strcpy (*pArgs, (char *)string);
- return (TRUE);
- }
- else
- /* Do ParseWmFuncNoArg () */
- {
- *pArgs = NULL;
- return (TRUE);
- }
- } /* END OF FUNCTION ParseWmFuncMaybeStrArg */
- /*************************************<->*************************************
- *
- * ParseWmFuncNoArg (linePP, wmFunction, pArgs)
- *
- *
- * Description:
- * -----------
- * Parses a window manager function null argument.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * wmFunction = function (not used).
- * pArgs = pointer to argument destination.
- *
- *
- * Outputs:
- * -------
- * linePP = unchanged
- * pArgs = NULL
- * Return = TRUE
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static Boolean ParseWmFuncNoArg (unsigned char **linePP, WmFunction wmFunction,
- String *pArgs)
- {
- *pArgs = NULL;
- return (TRUE);
- } /* END OF FUNCTION ParseWmFuncNoArg */
- /*************************************<->*************************************
- *
- * ParseWmFuncStrArg (linePP, wmFunction, pArgs)
- *
- *
- * Description:
- * -----------
- * Parses a window manager function string argument.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * wmFunction = function for which the argument string is intended.
- * pArgs = pointer to argument string destination.
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * pArgs = pointer to parsed argument string.
- * Return = FALSE iff insufficient memory
- *
- *
- * Comments:
- * --------
- * Insures that an argument for F_Exec() ends in '&' .
- * Only used to parse arguments for F_Exec, F_Menu, F_Lower, F_Raise,
- * F_Raise_Lower, and F_Screen. If it is used for any other function, be
- * sure to change FreeMenuItem () accordingly.
- *
- *************************************<->***********************************/
- Boolean ParseWmFuncStrArg (unsigned char **linePP,
- WmFunction wmFunction, String *pArgs)
- {
- unsigned char *string;
- unsigned int len;
- char *p;
- wchar_t last;
- char delim;
- wchar_t wdelim;
- int lastlen;
- if ((string = GetString (linePP)) != NULL)
- /* nonNULL string argument */
- {
- len = strlen ((char *)string);
- if ((*pArgs = (String)XtMalloc (len + 2)) == NULL)
- {
- PWarning (((char *)GETMESSAGE(60, 17, "Insufficient memory")));
- return (FALSE);
- }
- strcpy (*pArgs, (char *)string);
- /*
- * Insure that an argument for F_Exec ends in '&' .
- */
- if (wmFunction == F_Exec)
- {
- lastlen = 0;
- p = *pArgs;
- while (*p &&
- ((len = mblen(p, MB_CUR_MAX)) > 0))
- {
- mbtowc(&last, p, MB_CUR_MAX);
- lastlen = len;
- p += len;
- }
- delim = '&';
- mbtowc(&wdelim, &delim, MB_CUR_MAX);
- if (lastlen == 1 && last != wdelim)
- {
- *p++ = '&';
- *p = '\0';
- }
- }
- }
- else
- /* NULL string argument */
- {
- *pArgs = NULL;
- }
- return (TRUE);
- } /* END OF FUNCTION ParseWmFuncStrArg */
- /*************************************<->*************************************
- *
- * FreeMenuItem (menuItem)
- *
- *
- * Description:
- * -----------
- * This procedure destroys a MenuItem structure.
- *
- *
- * Inputs:
- * ------
- * menuItem = to be destroyed.
- *
- *
- * Outputs:
- * -------
- * None.
- *
- *
- * Comments:
- * --------
- * Assumes that ParseWmFuncStrArg () has parsed a menu item's function
- * argument only for F_Exec, F_Menu, F_Lower, F_Raise, F_Raise_Lower, and
- * F_Screen. If it is used for other functions, be sure to include them here!
- *
- *************************************<->***********************************/
- void FreeMenuItem (MenuItem *menuItem)
- {
- if (menuItem->label != NULL)
- {
- XtFree ((char *)menuItem->label);
- }
- if (menuItem->accelText != NULL)
- {
- XtFree ((char *)menuItem->accelText);
- }
- /*
- * If menuItem->wmFuncArgs is nonNULL, we assume that it is a string that
- * was malloc'ed in ParseWmFuncStrArg () and we free it now.
- */
- if ((menuItem->wmFuncArgs != NULL) &&
- ((menuItem->wmFunction == F_Exec) ||
- (menuItem->wmFunction == F_Menu) ||
- (menuItem->wmFunction == F_Lower) ||
- (menuItem->wmFunction == F_Raise) ||
- (menuItem->wmFunction == F_Raise_Lower) ||
- (menuItem->wmFunction == F_Screen)))
- {
- XtFree ((char *)menuItem->wmFuncArgs);
- }
- XtFree ((char *)menuItem);
- } /* END OF FUNCTION FreeMenuItem */
- /*************************************<->*************************************
- *
- * ParseWmFuncGrpArg (linePP, wmFunction, pGroup)
- *
- *
- * Description:
- * -----------
- * Parses a window manager function group argument.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * wmFunction = function for which the group argument is intended.
- * pGroup = pointer to group argument destination.
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * pGroup = pointer to parsed group argument.
- * Return = FALSE iff invalid group argument.
- *
- *
- * Comments:
- * --------
- * The only valid nonNULL arguments are "icon", "window", and "transient".
- *
- *************************************<->***********************************/
- static Boolean ParseWmFuncGrpArg (unsigned char **linePP,
- WmFunction wmFunction, GroupArg *pGroup)
- {
- unsigned char *lineP = *linePP;
- unsigned char *startP;
- unsigned char grpStr[MAX_GROUP_STRLEN+1];
- int len;
- /*
- * Parse groups while each is followed by "|".
- */
- *pGroup = 0;
- while (1)
- {
- /*
- * Skip whitespace and find next group string.
- */
- ScanWhitespace (&lineP);
- startP = lineP;
- ScanAlphanumeric (&lineP);
- if (startP == lineP)
- /* Group missing => use default or complain */
- {
- if (*pGroup)
- {
- PWarning (((char *)GETMESSAGE(60, 18, "Missing group specification")));
- return (FALSE);
- }
- else
- {
- *pGroup = F_GROUP_DEFAULT;
- break;
- }
- }
- /*
- * Found a group string; compare it with valid groups.
- */
- len = min (lineP - startP, MAX_GROUP_STRLEN);
- (void) strncpy ((char *)grpStr, (char *)startP, len);
- grpStr[len] = '\0';
- ToLower ((char *)grpStr);
- if (!strcmp ("icon", (char *)grpStr))
- {
- *pGroup |= F_GROUP_ICON;
- }
- else if (!strcmp ("window", (char *)grpStr))
- {
- *pGroup |= F_GROUP_WINDOW;
- }
- else if (!strcmp ("transient", (char *)grpStr))
- {
- *pGroup |= F_GROUP_TRANSIENT;
- }
- else
- /* Unknown group name */
- {
- PWarning (((char *)GETMESSAGE(60, 19, "Invalid group specification")));
- return (FALSE);
- }
- /*
- * Continue processing until the line is exhausted.
- * Skip any '|' .
- */
- ScanWhitespace (&lineP);
- if (lineP == NULL || *lineP == '\0')
- {
- break;
- }
- else if (*lineP == '|')
- {
- lineP++;
- }
- }
- *linePP = lineP;
- return (TRUE);
- } /* END OF FUNCTION ParseWmFuncGrpArg */
- /*************************************<->*************************************
- *
- * ParseWmFuncNbrArg (linePP, wmFunction, pNumber)
- *
- *
- * Description:
- * -----------
- * Parses a window manager function number argument.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * wmFunction = function
- * pNumber = pointer to number argument destination.
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * pNumber = pointer to parsed number argument.
- * Return = FALSE iff invalid number argument.
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static Boolean ParseWmFuncNbrArg (unsigned char **linePP,
- WmFunction wmFunction,
- unsigned long *pNumber)
- {
- int val;
- val = StrToNum (GetString (linePP));
- if (val == -1)
- {
- PWarning (((char *)GETMESSAGE(60, 20, "Invalid number specification")));
- *pNumber = 0;
- return (FALSE);
- }
- *pNumber = val;
- return (TRUE);
- } /* END OF FUNCTION ParseWmFuncNbrArg */
- /*************************************<->*************************************
- *
- * ParseButtonStr ()
- *
- *
- * Description:
- * -----------
- * This function parses a button set specification string:
- *
- * bindings_name
- * {
- * button context function
- * button context function
- * ...
- * button context function
- * }
- *
- *
- *
- * Inputs:
- * ------
- * pSD->buttonBindings = buttonBindings resource value
- * functionTable = window manager function parse table
- *
- *
- * Outputs:
- * -------
- * pSD->buttonSpecs = list of button binding specifications.
- *
- *
- * Comments:
- * --------
- * The button set specification name must match pSD->buttonBindings.
- *
- *************************************<->***********************************/
- void ParseButtonStr (WmScreenData *pSD, unsigned char *buttonStr)
- {
- unsigned char *lineP;
- cfileP = NULL;
- linec = 0;
- if (((parseP = buttonStr) != NULL) && (GetNextLine () != NULL))
- {
- lineP = line;
- ParseButtonSet (pSD, lineP);
- }
- } /* END OF FUNCTION ParseButtonStr */
- /*************************************<->*************************************
- *
- * ParseButtonSet (pSD, lineP)
- *
- *
- * Description:
- * -----------
- * Button set specification found. Parse the following syntax:
- *
- * v
- * Buttons bindings_name
- * {
- * button context function
- * button context function
- * ...
- * button context function
- * }
- *
- *
- * Inputs:
- * ------
- * cfileP = (global) file pointer to fopened configuration file or NULL
- * line = (global) line buffer
- * lineP = pointer to current character in line buffer
- * pSD->buttonBindings = buttonBindings resource value
- *
- *
- * Outputs:
- * -------
- * lineP = pointer to current character in line buffer
- * pSD->buttonSpecs = list of button binding specifications.
- *
- *
- * Comments:
- * --------
- * Skips unnamed button binding set and sets with names that don't match
- * the buttonBindings resource.
- * Skips bad button binding specifications.
- *
- *************************************<->***********************************/
- static void ParseButtonSet (WmScreenData *pSD, unsigned char *lineP)
- {
- unsigned char *string;
- ButtonSpec *buttonSpec;
- ButtonSpec *lastButtonSpec;
- int ix;
-
- /*
- * Parse the button set bindings from the configuration file.
- * If either the button set name or buttonBindings resource is NULL or
- * they don't match, then skip this button specification.
- */
- if (((string = GetString (&lineP)) == NULL) ||
- (pSD->buttonBindings == NULL) ||
- strcmp ((char *)string, pSD->buttonBindings))
- {
- return;
- }
- /*
- * Require leading '{' on the next line.
- */
- while ((GetNextLine () != NULL)) /* not EOF nor read error */
- {
- lineP = line;
- ScanWhitespace(&lineP);
- if ((lineP == NULL) || (*line == '!') || (*lineP == '\0') || (*lineP == '#'))
- /* ignore empty or comment line */
- {
- continue;
- }
- if (*lineP == '{')
- /* found '{' */
- {
- break;
- }
- /* not a '{' */
- PWarning (((char *)GETMESSAGE(60, 21, "Expected '{' after button set name")));
- return;
- }
- /*
- * Found leading "{" or EOF.
- * Prepare to accumulate button bindings by finding the end of
- * the button specification list.
- * lastButtonSpec will be NULL only if no prior bindings exist.
- */
- lastButtonSpec = pSD->buttonSpecs;
- if (lastButtonSpec != NULL)
- {
- while (lastButtonSpec->nextButtonSpec != NULL)
- {
- lastButtonSpec = (lastButtonSpec->nextButtonSpec);
- }
- }
- /*
- * Parse "button context function" until "}" or EOF found.
- * Skips bad button binding specifications.
- */
- while ((GetNextLine () != NULL)) /* not EOF nor read error */
- {
- lineP = line;
- ScanWhitespace(&lineP);
- if ((lineP == NULL) || (*line == '!') || (*lineP == '\0') || (*lineP == '#'))
- /* ignore empty or comment lines */
- {
- continue;
- }
- if (*lineP == '}') /* finished with button set */
- {
- break;
- }
- /*
- * Allocate space for the button binding specification.
- */
- if ((buttonSpec = (ButtonSpec *)XtMalloc (sizeof (ButtonSpec))) == NULL)
- {
- PWarning (((char *)GETMESSAGE(60, 22, "Insufficient memory for button specification")));
- continue;
- }
- buttonSpec->wmFunction = (WmFunction)NULL;
- buttonSpec->wmFuncArgs = NULL;
- buttonSpec->nextButtonSpec = NULL;
- /*
- * Parse the button specification "button".
- */
- lineP = line;
- if (!ParseBtnEvent(&lineP,
- &buttonSpec->eventType,
- &buttonSpec->button,
- &buttonSpec->state,
- &buttonSpec->click))
- {
- PWarning (((char *)GETMESSAGE(60, 23, "Invalid button specification")));
- XtFree ((char *)buttonSpec);
- continue; /* skip this button specification */
- }
- /*
- * Parse the button context.
- */
- if (!ParseContext(&lineP, &buttonSpec->context,
- &buttonSpec->subContext))
- {
- PWarning (((char *)GETMESSAGE(60, 24, "Invalid button context")));
- XtFree ((char *)buttonSpec);
- continue; /* skip this button specification */
- }
- /*
- * Parse the button function and any arguments.
- */
- ix = ParseWmFunction (&lineP, CRS_BUTTON, &buttonSpec->wmFunction);
- /*
- * remove any subContexts that don't apply to this function
- */
- if ((functionTable[ix].greyedContext & F_SUBCONTEXT_IB_IICON) &&
- (buttonSpec->subContext & F_SUBCONTEXT_IB_IICON))
- {
- buttonSpec->subContext &= ~F_SUBCONTEXT_IB_IICON;
- }
- if ((functionTable[ix].greyedContext & F_SUBCONTEXT_IB_WICON) &&
- (buttonSpec->subContext & F_SUBCONTEXT_IB_WICON))
- {
- buttonSpec->subContext &= ~F_SUBCONTEXT_IB_WICON;
- }
- /*
- * Map Button3 menus to BMenu virtual button
- */
- if (buttonSpec->button == Button3 &&
- (buttonSpec->wmFunction == F_Menu ||
- buttonSpec->wmFunction == F_Post_SMenu)) {
- buttonSpec->button = wmGD.bMenuButton;
- }
- /*
- * Apply the function argument parser.
- */
- if (!(*(functionTable [ix].parseProc))
- (&lineP, buttonSpec->wmFunction, &buttonSpec->wmFuncArgs))
- {
- XtFree ((char *)buttonSpec);
- continue; /* skip this button specification */
- }
- /*
- * Add the button specification to the button specification list.
- */
- if (lastButtonSpec != NULL)
- /* a prior specification exists */
- {
- lastButtonSpec->nextButtonSpec = buttonSpec;
- }
- else
- {
- pSD->buttonSpecs = buttonSpec;
- }
- lastButtonSpec = buttonSpec;
- }
- } /* END OF FUNCTION ParseButtonSet */
- /*************************************<->*************************************
- *
- * ParseContext (linePP, context, subContext)
- *
- *
- * Description:
- * -----------
- * Parses a general context string.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * context = context field value
- * subContext = subContext field value
- * Return = (Boolean) true iff valid context string
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static Boolean ParseContext (unsigned char **linePP, Context *context,
- Context *subContext)
- {
- unsigned char *lineP = *linePP;
- unsigned char *startP;
- unsigned char ctxStr[MAX_CONTEXT_STRLEN+1];
- int len;
- /*
- * Parse contexts while each is followed by "|".
- */
- *context = 0;
- *subContext = 0;
- while (1) {
- /*
- * Skip whitespace and find next context string.
- */
- ScanWhitespace (&lineP);
- startP = lineP;
- ScanAlphanumeric (&lineP);
- if (startP == lineP)
- /* ERROR: Context missing */
- {
- return (FALSE);
- }
- /*
- * Found nonNULL string; compare it with valid contexts.
- */
- len = min(lineP - startP, MAX_CONTEXT_STRLEN);
- (void) strncpy ((char *)ctxStr, (char *)startP, len);
- ctxStr[len] = '\0';
- ToLower ((char *)ctxStr);
- if (!strcmp ("root", (char *)ctxStr))
- {
- *context |= F_CONTEXT_ROOT;
- *subContext |= F_SUBCONTEXT_R_ALL;
- }
- else if (!strcmp ("icon", (char *)ctxStr))
- {
- *context |= (F_CONTEXT_ICON |
- F_CONTEXT_ICONBOX |
- F_SUBCONTEXT_IB_IICON |
- F_SUBCONTEXT_IB_WICON );
- *subContext |= (F_SUBCONTEXT_I_ALL |
- F_SUBCONTEXT_IB_IICON |
- F_SUBCONTEXT_IB_WICON );
- }
- else if (!strcmp ("window", (char *)ctxStr))
- {
- *context |= F_CONTEXT_WINDOW;
- *subContext |= F_SUBCONTEXT_W_ALL;
- }
- else if (!strcmp ("frame", (char *)ctxStr))
- {
- *context |= F_CONTEXT_WINDOW;
- *subContext |= F_SUBCONTEXT_W_FRAME;
- }
- else if (!strcmp ("title", (char *)ctxStr))
- {
- *context |= F_CONTEXT_WINDOW;
- *subContext |= F_SUBCONTEXT_W_TITLE;
- }
- else if (!strcmp ("border", (char *)ctxStr))
- {
- *context |= F_CONTEXT_WINDOW;
- *subContext |= F_SUBCONTEXT_W_BORDER;
- }
- else if (!strcmp ("app", (char *)ctxStr))
- {
- *context |= F_CONTEXT_WINDOW;
- *subContext |= F_SUBCONTEXT_W_APP;
- }
- else if (!strcmp ("ifkey", (char *)ctxStr))
- {
- *context |= F_CONTEXT_IFKEY;
- }
- else
- /* Unknown context name */
- {
- return (FALSE);
- }
- /* continue only if followed by '|' */
- ScanWhitespace (&lineP);
- if (*lineP != '|')
- {
- break;
- }
- lineP++;
- }
- *linePP = lineP;
- return (TRUE);
- } /* END OF FUNCTION ParseContext */
- /*************************************<->*************************************
- *
- * ParseKeyStr ()
- *
- *
- * Description:
- * -----------
- * This function parses a key set specification string:
- *
- * bindings_name
- * {
- * key context function
- * key context function
- * ...
- * key context function
- * }
- *
- *
- * Inputs:
- * ------
- * pSD->keyBindings = keyBindings resource value
- * functionTable = window manager function parse table
- *
- *
- * Outputs:
- * -------
- * pSD->keySpecs = list of key binding specification
- *
- *
- * Comments:
- * --------
- * The key set specification name must match pSD->keyBindings.
- *
- *************************************<->***********************************/
- void
- ParseKeyStr (WmScreenData *pSD, unsigned char *keyStr)
- {
- unsigned char *lineP;
- cfileP = NULL;
- linec = 0;
- if (((parseP = keyStr) != NULL) && (GetNextLine () != NULL))
- {
- lineP = line;
- ParseKeySet (pSD, lineP);
- }
- } /* END OF FUNCTION ParseKeyStr */
- /*************************************<->*************************************
- *
- * ParseKeySet (pSD, lineP)
- *
- *
- * Description:
- * -----------
- * Key set specification found. Parse the following syntax:
- *
- * v
- * Keys bindings_name
- * {
- * key context function
- * key context function
- * ...
- * key context function
- * }
- *
- *
- * Inputs:
- * ------
- * cfileP = (global) file pointer to fopened configuration file or NULL
- * line = (global) line buffer
- * lineP = pointer to current character in line buffer
- * pSD->keyBindings = keyBindings resource value
- *
- *
- * Outputs:
- * -------
- * lineP = pointer to current character in line buffer
- * pSD->keySpecs = list of key binding specifications.
- *
- *
- * Comments:
- * --------
- * Skips unnamed key binding set and sets with names that don't match the
- * keyBindings resource.
- * Skips bad key binding specifications.
- *
- *************************************<->***********************************/
- static void ParseKeySet (WmScreenData *pSD, unsigned char *lineP)
- {
- unsigned char *string;
- KeySpec *keySpec;
- KeySpec *lastKeySpec;
- unsigned int eventType;
- int ix;
- Boolean bBadKey;
-
- /*
- * Parse the key set bindings from the configuration file.
- * If either the key set name or keyBindings resource is NULL or they
- * don't match then skip this key specification.
- */
- if (((string = GetString (&lineP)) == NULL) ||
- (pSD->keyBindings == NULL) ||
- strcmp ((char *)string, pSD->keyBindings))
- {
- return;
- }
- /*
- * Require leading '{' on next line.
- */
- while ((GetNextLine () != NULL)) /* not EOF nor read error */
- {
- lineP = line;
- ScanWhitespace(&lineP);
- if ((lineP == NULL) || (*line == '!') || (*lineP == '\0') || (*lineP == '#'))
- /* ignore empty or comment line */
- {
- continue;
- }
- if (*lineP == '{')
- /* found '{' */
- {
- break;
- }
- /* not a '{' */
- PWarning (((char *)GETMESSAGE(60, 25, "Expected '{' after key set name")));
- return;
- }
- /*
- * Found leading "{" or EOF.
- * Prepare to accumulate key bindings by finding the end of
- * the key specification list.
- * lastKeySpec will be NULL only if no prior bindings exist.
- */
- lastKeySpec = pSD->keySpecs;
- if (lastKeySpec != NULL)
- {
- while (lastKeySpec->nextKeySpec != NULL)
- {
- lastKeySpec = (lastKeySpec->nextKeySpec);
- }
- }
- /*
- * Parse "key context function" until "}" or EOF found.
- * Skip bad key bindings.
- */
- while ((GetNextLine () != NULL)) /* not EOF nor read error */
- {
- lineP = line;
- ScanWhitespace (&lineP);
- if ((lineP == NULL) || (*line == '!') || (*lineP == '\0') || (*lineP == '#'))
- /* ignore empty or comment lines */
- {
- continue;
- }
- if (*lineP == '}') /* finished with key set */
- {
- break;
- }
- /*
- * Allocate space for the key specification.
- */
- if ((keySpec = (KeySpec *)XtMalloc (sizeof (KeySpec))) == NULL)
- {
- PWarning (((char *)GETMESSAGE(60, 26, "Insufficient memory for key specification")));
- continue;
- }
- keySpec->wmFunction = (WmFunction)NULL;
- keySpec->wmFuncArgs = NULL;
- keySpec->nextKeySpec = NULL;
- /*
- * Parse the key specification.
- */
- bBadKey = False;
- if (!ParseKeyEvent(&lineP,
- &eventType,
- &keySpec->keycode,
- &keySpec->state))
- {
- bBadKey = True;
- }
- /*
- * Parse the key context.
- * Here lineP points to the candidate context string.
- */
- if (!ParseContext(&lineP, &keySpec->context,
- &keySpec->subContext))
- {
- if (bBadKey)
- PWarning (((char *)GETMESSAGE(60, 27, "Invalid key specification")));
- PWarning (((char *)GETMESSAGE(60, 28, "Invalid key context")));
- XtFree ((char *)keySpec);
- continue; /* skip this key specification */
- }
- if (bBadKey)
- {
- /*
- * Don't print an error message if this is a "hardware
- * available" binding.
- */
- if (!(keySpec->context & F_CONTEXT_IFKEY))
- PWarning (((char *)GETMESSAGE(60, 27, "Invalid key specification")));
- XtFree ((char *)keySpec);
- continue; /* skip this key specification */
- }
- /*
- * This flag is only used for parsing, clear it so the
- * rest of the program doesn't see it.
- */
- keySpec->context &= ~F_CONTEXT_IFKEY;
- /*
- * Parse the key function and any arguments.
- */
- ix = ParseWmFunction (&lineP, CRS_KEY, &keySpec->wmFunction);
-
- /*
- * remove any subContexts that don't apply to this function
- */
- if ((functionTable[ix].greyedContext & F_SUBCONTEXT_IB_IICON) &&
- (keySpec->subContext & F_SUBCONTEXT_IB_IICON))
- {
- keySpec->subContext &= ~F_SUBCONTEXT_IB_IICON;
- }
- if ((functionTable[ix].greyedContext & F_SUBCONTEXT_IB_WICON) &&
- (keySpec->subContext & F_SUBCONTEXT_IB_WICON))
- {
- keySpec->subContext &= ~F_SUBCONTEXT_IB_WICON;
- }
- /*
- * Apply the function argument parser.
- */
- if (!(*(functionTable [ix].parseProc))
- (&lineP, keySpec->wmFunction, &keySpec->wmFuncArgs))
- {
- XtFree ((char *)keySpec);
- continue; /* skip this key specification */
- }
- /*
- * Add the key specification to the key specification list.
- */
- if (lastKeySpec != NULL)
- /* a prior specification exists */
- {
- lastKeySpec->nextKeySpec = keySpec;
- }
- else
- {
- pSD->keySpecs = keySpec;
- }
- lastKeySpec = keySpec;
- }
- } /* END OF FUNCTION ParseKeySet */
- /*************************************<->*************************************
- *
- * ParseBtnEvent (linePP, eventType, button, state, fClick)
- *
- *
- * Description:
- * -----------
- * Parse a button event specification.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer
- * buttonEvents = (global) button event parse table
- * modifierStrings = (global) modifier string/mask table
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * eventType = type of event
- * button = parsed button number
- * state = composite modifier mask
- * fClick = is click?
- *
- * Return = (Boolean) true iff valid button event specification
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- Boolean ParseBtnEvent (unsigned char **linePP,
- unsigned int *eventType,
- unsigned int *button,
- unsigned int *state,
- Boolean *fClick)
- {
- if (!ParseEvent (linePP, buttonEvents, eventType, button, state, fClick))
- {
- return (FALSE);
- }
- /*
- * The following is a fix for an X11 deficiency in regards to
- * modifiers in grabs.
- */
- if (*eventType == ButtonRelease)
- {
- /* the button that is going up will always be in the modifiers... */
- *state |= buttonModifierMasks[*button];
- }
- return (TRUE);
- } /* END OF FUNCTION ParseBtnEvent */
- /*************************************<->*************************************
- *
- * ParseKeyEvent (linePP, eventType, keyCode, state)
- *
- *
- * Description:
- * -----------
- * Parse a key event specification.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer
- * keyEvents = (global) key event parse table
- * modifierStrings = (global) modifier string/mask table
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * eventType = type of event
- * keyCode = parsed KeyCode
- * state = composite modifier mask
- *
- * Return = (Boolean) true iff valid key event specification
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- Boolean ParseKeyEvent (unsigned char **linePP, unsigned int *eventType,
- KeyCode *keyCode, unsigned int *state)
- {
- Boolean fClick;
- unsigned int keySym = 0;
- if (!ParseEvent (linePP, keyEvents, eventType, &keySym, state, &fClick))
- {
- return (FALSE);
- }
- /*
- * Here keySym is a KeySym. Convert it to a KeyCode.
- * KeyCode will be set to 0 if keySym is not defined for any KeyCode
- * (e.g. 0x001).
- */
- *keyCode = XKeysymToKeycode(DISPLAY, (KeySym) keySym);
- if (*keyCode == 0)
- {
- if (keySym == XK_F9)
- {
- keySym = XK_KP_F1;
- }
- else if (keySym == XK_F10)
- {
- keySym = XK_KP_F2;
- }
- else if (keySym == XK_F11)
- {
- keySym = XK_KP_F3;
- }
- else if (keySym == XK_F12)
- {
- keySym = XK_KP_F4;
- }
- *keyCode = XKeysymToKeycode(DISPLAY, (KeySym) keySym);
- }
- return (*keyCode != 0);
- } /* END OF FUNCTION ParseKeyEvent */
- /*************************************<->*************************************
- *
- * ParseEvent (linePP, table, eventType, detail, state, fClick)
- *
- *
- * Description:
- * -----------
- * Parse an event specification.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * table = event parse table
- * modifierStrings = (global) modifier string/mask table
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * eventType = type of event
- * detail = dependent upon parse table detail procedure and closure
- * state = composite modifier mask
- * fClick = click flag
- *
- * Return = (Boolean) true iff valid event specification
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static Boolean ParseEvent (unsigned char **linePP, EventTableEntry *table,
- unsigned int *eventType, unsigned int *detail,
- unsigned int *state, Boolean *fClick)
- {
- unsigned char *lineP = *linePP;
- Cardinal ix;
- Boolean status;
-
- /* Parse the modifiers */
- if (!ParseModifiers (&lineP, state) || *lineP != '<')
- {
- return (FALSE);
- }
- lineP++; /* skip '<' */
- /* Parse the event type */
- if (!ParseEventType (&lineP, table, eventType, &ix) || *lineP != '>')
- {
- return (FALSE);
- }
- lineP++; /* skip '>' */
- /*
- * Compute detail and fClick.
- * Status will be False for a invalid KeySym name.
- */
- status = (*(table[ix].parseProc))(&lineP, table[ix].closure, detail);
- *fClick = table[ix].fClick;
- if (status)
- {
- *linePP = lineP;
- }
- return (status);
- } /* END OF FUNCTION ParseEvent */
- /*************************************<->*************************************
- *
- * ParseModifiers(linePP, state)
- *
- *
- * Description:
- * -----------
- * Parses a modifier specification.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * modifierStrings = (global) modifier string/mask table
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * state = composite modifier mask
- * Return = (Boolean) true iff valid modifier name
- *
- *
- * Comments:
- * --------
- * If successful, will be followed by NULL or '<'.
- *
- *************************************<->***********************************/
- static Boolean ParseModifiers(unsigned char **linePP, unsigned int *state)
- {
- unsigned char *lineP = *linePP;
- unsigned char *startP;
- unsigned char modStr[MAX_MODIFIER_STRLEN+1];
- Boolean fNot;
- unsigned int maskBit;
- int len;
- *state = 0;
-
- /*
- * Parse modifiers until the event specifier is encountered.
- */
- ScanWhitespace (&lineP);
- while ((*lineP != '\0') && (*lineP != '<'))
- {
- if (*lineP == '~')
- {
- fNot = TRUE;
- lineP++;
- }
- else
- {
- fNot = FALSE;
- }
- startP = lineP;
- ScanAlphanumeric (&lineP);
- if (startP == lineP)
- /* ERROR: Modifier or '<' missing */
- {
- return (FALSE);
- }
- len = min(lineP - startP, MAX_MODIFIER_STRLEN);
- (void) strncpy ((char *)modStr, (char *)startP, len);
- modStr[len] = '\0';
- if (!LookupModifier (modStr, &maskBit))
- /* Unknown modifier name */
- {
- return (FALSE);
- }
- if (fNot)
- {
- *state &= ~maskBit;
- }
- else
- {
- *state |= maskBit;
- }
- ScanWhitespace(&lineP);
- }
- *linePP = lineP;
- return (TRUE); /* must have '<' or NULL following */
- } /* END OF FUNCTION ParseModifiers */
- /*************************************<->*************************************
- *
- * LookupModifier (name, valueP)
- *
- *
- * Description:
- * -----------
- * Return the modifier mask for the provided modifier name.
- *
- *
- * Inputs:
- * ------
- * name = modifier string
- * modifierStrings = modifier string/mask table
- *
- *
- * Outputs:
- * -------
- * valueP = modifier mask
- * Return = (Boolean) true iff valid modifier name
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static Boolean LookupModifier (unsigned char *name, unsigned int *valueP)
- {
- int i;
- if (name != NULL)
- {
- ToLower ((char *)name);
- for (i=0; modifierStrings[i].name != NULL; i++)
- {
- if (!strcmp (modifierStrings[i].name, (char *)name))
- {
- *valueP = modifierStrings[i].mask;
- return (TRUE);
- }
- }
- }
- return (FALSE);
- } /* END OF FUNCTION LookupModifier */
- /*************************************<->*************************************
- *
- * ParseEventType(linePP, table, eventType, ix)
- *
- *
- * Description:
- * -----------
- * Parses the event type string.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * table = event parse table
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * eventType = type of event
- * ix = table index for matched event
- *
- * Return = (Boolean) true iff valid event
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static Boolean ParseEventType (unsigned char **linePP, EventTableEntry *table,
- unsigned int *eventType, Cardinal *ix)
- {
- unsigned char *lineP = *linePP;
- unsigned char *startP = *linePP;
- unsigned char eventTypeStr[MAX_EVENTTYPE_STRLEN+1];
- int len;
- /* Parse out the event string */
- ScanAlphanumeric (&lineP);
- /*
- * Attempt to match the parsed event against our supported event set.
- */
- if (startP != lineP)
- {
- len = min (lineP - startP, MAX_EVENTTYPE_STRLEN);
- (void) strncpy ((char *)eventTypeStr, (char *)startP, len);
- eventTypeStr[len] = '\0';
- ToLower ((char *)eventTypeStr);
- for (len = 0; table[len].event != NULL; len++)
- if (!strcmp (table[len].event, (char *)eventTypeStr))
- {
- *ix = len;
- *eventType = table[*ix].eventType;
- *linePP = lineP;
- return (TRUE);
- }
- }
- /* Unknown event specified */
- return (FALSE);
- } /* END OF FUNCTION ParseEventType */
- /*************************************<->*************************************
- *
- * ParseImmed (linePP, closure, detail)
- *
- *
- * Description:
- * -----------
- * Button event detail procedure.
- *
- *
- * Inputs:
- * ------
- * linePP = not used
- * closure = table entry
- *
- *
- * Outputs:
- * -------
- * detail = pointer to closure
- *
- * Return = TRUE
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static Boolean ParseImmed (unsigned char **linePP, unsigned int closure,
- unsigned int *detail)
- {
- *detail = closure;
- return (TRUE);
- } /* END OF FUNCTION ParseImmed */
- /*************************************<->*************************************
- *
- * ParseKeySym (linePP, closure, detail)
- *
- *
- * Description:
- * -----------
- * Key event detail procedure. Parses a KeySym string.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer
- *
- * closure = not used.
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer
- * detail = pointer to parsed KeySym
- *
- * Return = (Boolean) true iff valid KeySym string
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static Boolean ParseKeySym (unsigned char **linePP, unsigned int closure,
- unsigned int *detail)
- {
- unsigned char *lineP = *linePP;
- unsigned char *startP;
- char keySymName[MAX_KEYSYM_STRLEN+1];
- int len;
- int chlen;
- ScanWhitespace (&lineP);
- startP = lineP;
- while (*lineP &&
- ((chlen = mblen ((char *)lineP, MB_CUR_MAX)) > 0) &&
- ((chlen > 1) ||
- (!isspace (*lineP) && *lineP != ',' && *lineP != ':')))
- {
- /* Skip next character */
- lineP += chlen;
- }
- len = min (lineP - startP, MAX_KEYSYM_STRLEN);
- (void) strncpy (keySymName, (char *)startP, len);
- keySymName[len] = '\0';
- if ((*detail = XStringToKeysym(keySymName)) == NoSymbol &&
- (mblen (keySymName, MB_CUR_MAX) == 1))
- {
- if (!isdigit (keySymName[0]) ||
- ((*detail = StrToNum ((unsigned char *)&keySymName[0])) == -1))
- {
- *detail = NoSymbol;
- return (FALSE);
- }
- }
- *linePP = lineP;
- return (TRUE);
- } /* END OF FUNCTION ParseKeySym */
- /*************************************<->*************************************
- *
- * StrToNum(str)
- *
- *
- * Description:
- * -----------
- * Converts a string to an unsigned hexadecimal, decimal, or octal integer.
- *
- *
- * Inputs:
- * ------
- * str = character string
- *
- *
- * Outputs:
- * -------
- * Return = unsigned integer
- *
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static unsigned int StrToNum(unsigned char *str)
- {
- unsigned char c;
- unsigned int val = 0;
- if (*str == '0')
- {
- str++;
- if (*str == 'x' || *str == 'X')
- {
- return (StrToHex(++str));
- }
- return (StrToOct(str));
- }
- while ((c = *str) != '\0')
- {
- if ('0' <= c && c <= '9')
- {
- val = val*10+c-'0';
- }
- else
- {
- return (-1);
- }
- str++;
- }
- return (val);
- } /* END OF FUNCTION StrToNum */
- /*************************************<->*************************************
- *
- *
- *
- * Description:
- * -----------
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static unsigned int StrToHex(unsigned char *str)
- {
- unsigned char c;
- unsigned int val = 0;
- while ((c = *str) != '\0')
- {
- if ('0' <= c && c <= '9')
- {
- val = val*16+c-'0';
- }
- else if ('a' <= c && c <= 'f')
- {
- val = val*16+c-'a'+10;
- }
- else if ('A' <= c && c <= 'F')
- {
- val = val*16+c-'A'+10;
- }
- else
- {
- return (-1);
- }
- str++;
- }
- return (val);
- } /* END OF FUNCTION StrToHex */
- /*************************************<->*************************************
- *
- *
- *
- * Description:
- * -----------
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static unsigned int StrToOct(unsigned char *str)
- {
- unsigned char c;
- unsigned int val = 0;
- while ((c = *str) != '\0')
- {
- if ('0' <= c && c <= '7')
- {
- val = val*8+c-'0';
- }
- else
- {
- return (-1);
- }
- str++;
- }
- return (val);
- } /* END OF FUNCTION StrToOct */
- /*************************************<->*************************************
- *
- * ScanAlphanumeric (linePP)
- *
- *
- * Description:
- * -----------
- * Scan string until a non-alphanumeric character is encountered.
- *
- *
- * Inputs:
- * ------
- * linePP = nonNULL pointer to current line buffer pointer
- *
- *
- * Outputs:
- * -------
- * linePP = nonNULL pointer to revised line buffer pointer
- *
- *
- * Comments:
- * --------
- * Assumes linePP is nonNULL
- *
- *************************************<->***********************************/
- void ScanAlphanumeric (unsigned char **linePP)
- {
- int chlen;
- while (*linePP &&
- ((chlen = mblen ((char *) *linePP, MB_CUR_MAX)) > 0) &&
- ((chlen > 1) || isalnum (**linePP)))
- {
- (*linePP) += chlen;
- }
- } /* END OF FUNCTION ScanAlphanumeric */
- /*************************************<->*************************************
- *
- * PWarning (message)
- *
- *
- * Description:
- * -----------
- * This function lists a resource description parse message to stderr.
- *
- *
- * Inputs:
- * ------
- * message = pointer to a message string
- * cfileP = (global) file pointer to fopened configuration file or NULL
- * linec = (global) line counter
- *
- *************************************<->***********************************/
- void
- PWarning (char *message)
- {
- char pch[MAXWMPATH+1];
- String sMessage;
- char *pchFile;
- sMessage = XtNewString ((String) message);
- if (cfileP != NULL)
- {
- if (pConfigStackTop->fileName)
- {
- pchFile = pConfigStackTop->fileName;
- }
- else
- {
- pchFile = wmGD.configFile;
- }
- sprintf (pch, pWarningStringFile,
- GETMESSAGE(20,1,"Workspace Manager"),
- sMessage, linec, pchFile);
- }
- else
- {
- sprintf (pch, pWarningStringLine,
- GETMESSAGE(20,1,"Workspace Manager"),
- sMessage, linec);
- }
- _DtSimpleError (wmGD.mwmName, DtIgnore, NULL, pch, NULL);
- XtFree (sMessage);
- } /* END OF FUNCTION PWarning */
- /*
- * Key substitution table entry
- */
- typedef struct _keySubs
- {
- unsigned char * pchFrom;
- int lenFrom;
- unsigned char * pchTo;
- } KeySub;
- /*************************************<->*************************************
- *
- * InitKeySubs (ppKeySubs, pNumKeySubs)
- *
- *
- * Description:
- * -----------
- * Initialize key label substitutions used in acclerator text
- *
- *
- * Inputs:
- * ------
- * ppKeySubs = ptr to key substitution table ptr
- * pNumKeySubs = ptr to number of key substitutions
- *
- *
- * Outputs:
- * -------
- * *ppKeySubs = ptr to key substitution table
- * *pNumKeySubs = number of substitutions found
- *
- * Comments:
- * --------
- * *ppKeySubs is allocated with XtMalloc in a complicated way.
- * If this ever needs to be freed, a function to free it needs to
- * be written.
- *
- *************************************<->***********************************/
- static void InitKeySubs (
- KeySub **ppKeySubs,
- int *pNumKeySubs)
- {
- int numKS;
- KeySub *pKS;
- KeySub *pKSret;
- unsigned char *pch0;
- unsigned char *pch1;
- int len;
- int chlen;
- pch0 = (unsigned char *)GETMESSAGE(60, 40, "");
- if ((pch0 == NULL) || (*pch0 == '\0'))
- {
- *ppKeySubs = NULL;
- *pNumKeySubs = 0;
- return;
- }
- pKSret = NULL;
- numKS = 0;
- while (*pch0 != '\0')
- {
- ScanWhitespace (&pch0);
- if (*pch0 == '\0') break;
- /*
- * allocate space for next key sub
- */
- if (pKSret == NULL)
- {
- pKSret = (KeySub *) XtMalloc (1*sizeof(KeySub));
- }
- else
- {
- pKSret = (KeySub *) XtRealloc ((char *)pKSret,
- (numKS+1)*sizeof(KeySub));
- }
- pKS = &pKSret[numKS];
- /* get "from" string */
- pch1 = pch0;
- while (*pch1 && ((chlen = mblen ((char *)pch1, MB_CUR_MAX)) > 0))
- {
- if ((chlen == 1) && (*pch1 == ' '))
- {
- break;
- }
- pch1 += chlen;
- }
- pKS->lenFrom = pch1 - pch0;
- if (pKS->lenFrom < 1)
- {
- /*
- * no "from" string
- */
- break;
- }
- pKS->pchFrom = (unsigned char *) XtMalloc (1+pKS->lenFrom);
- memcpy (pKS->pchFrom, pch0, pKS->lenFrom);
- pKS->pchFrom[pKS->lenFrom] = '\0';
- /* get "to" string */
- ScanWhitespace (&pch1);
- pch0 = pch1;
- while (*pch1 && ((chlen = mblen ((char *)pch1, MB_CUR_MAX)) > 0))
- {
- if ((chlen == 1) && (*pch1 == ' '))
- {
- break;
- }
- pch1 += chlen;
- }
- len = pch1 - pch0;
- if (len < 1)
- {
- /*
- * Invalid format, "from" string with no "to" string.
- */
- break;
- }
- pKS->pchTo = (unsigned char *) XtMalloc (1+len);
- memcpy (pKS->pchTo, pch0, len);
- pKS->pchTo[len] = '\0';
- /* advance cursor */
- pch0 = pch1;
- /* got one, bump the counter */
- numKS++;
- }
- *ppKeySubs = pKSret;
- *pNumKeySubs = numKS;
- }
- /*************************************<->*************************************
- *
- * ProcessAccelText (startP, endP, destP)
- *
- *
- * Description:
- * -----------
- * Process accelerator text and copy into string.
- *
- *
- * Inputs:
- * ------
- * startP = pointer to start of valid accelerator specification
- * endP = pointer past end of accelerator specification
- * destP = pointer to destination buffer
- *
- *
- * Outputs:
- * -------
- * Destination buffer has processed accelerator text.
- *
- * Comments:
- * --------
- * None.
- *
- *************************************<->***********************************/
- static void ProcessAccelText (unsigned char *startP, unsigned char *endP,
- unsigned char *destP)
- {
- int chlen;
- static Boolean bAccelInit = False;
- static KeySub *pKeySub;
- static int numKeySubs;
- unsigned char * pchFirst;
- unsigned char * pchSub;
- int lenSub;
- int i;
- if (!bAccelInit)
- {
- InitKeySubs (&pKeySub, &numKeySubs);
- bAccelInit = True;
- }
- /*
- * Copy modifiers
- */
- ScanWhitespace (&startP);
- while (*startP != '<')
- {
- if (*startP == '~')
- {
- *destP++ = *startP++;
- }
- pchFirst = startP;
- while (*startP &&
- (((chlen = mblen ((char *)startP, MB_CUR_MAX)) > 1)
- || isalnum (*startP)))
- {
- while (chlen--)
- {
- startP++;
- }
- }
- /* find substitution */
- pchSub = NULL;
- lenSub = 0;
- for (i=0; i<numKeySubs; i++)
- {
- if ((pKeySub[i].lenFrom == startP-pchFirst) &&
- (!strncasecmp ((char *)pKeySub[i].pchFrom, (char *)pchFirst,
- pKeySub[i].lenFrom)))
- {
- pchSub = pKeySub[i].pchTo;
- lenSub = strlen((char *)pchSub);
- break;
- }
- }
- if ((pchSub != NULL) && (lenSub > 0))
- {
- memcpy (destP, pchSub, lenSub);
- destP += lenSub;
- }
- else
- {
- memcpy (destP, pchFirst, startP-pchFirst);
- destP += startP-pchFirst;
- }
- *destP++ = '+';
- ScanWhitespace (&startP);
- }
- /*
- * Skip the key event type.
- */
- startP++; /* skip '<' */
- while (*startP != '>')
- {
- startP += mblen ((char *)startP, MB_CUR_MAX);
- }
- startP++; /* skip '>' */
- /*
- * Copy the KeySym string.
- */
- ScanWhitespace (&startP);
- while (startP != endP)
- {
- *destP++ = *startP++;
- }
- *destP = '\0';
- } /* END OF FUNCTION ProcessAccelText */
- /*************************************<->*************************************
- *
- * ProcessCommandLine (argc, argv)
- *
- *
- * Description:
- * -----------
- * This function looks for and processes mwm options in the command line
- *
- * Inputs:
- * ------
- * argc = argument count.
- * argv = argument vector.
- *
- *
- * Outputs:
- * -------
- * Changes global data to based on command line options recognized
- *
- *
- *************************************<->***********************************/
- #define SCREENS_OPT "-screens"
- #define MULTI_SCREEN_OPT "-multiscreen"
- void ProcessCommandLine (int argc, char *argv[])
- {
- unsigned char *string;
- int argnum;
- unsigned char *lineP;
- for (argnum = 1; argnum < argc; argnum++)
- {
- lineP = (unsigned char *) argv[argnum];
- if ((string = GetString (&lineP)) == NULL)
- /* empty or comment line */
- {
- continue;
- }
- if (!strcmp((char *)string, MULTI_SCREEN_OPT))
- {
- wmGD.multiScreen = True;
- wmGD.numScreens = ScreenCount (DISPLAY);
- }
- else if (!strcmp((char *)string, SCREENS_OPT))
- {
- argnum++; /* skip to next arg */
- ParseScreensArgument (argc, argv, &argnum, lineP);
- }
- }
- } /* END OF FUNCTION ProcessCommandLine */
- /*************************************<->*************************************
- *
- * ParseScreensArgument (argc, argv, pArgnum, lineP)
- *
- *
- * Description:
- * -----------
- * This function processes the ``-screens'' command line argument
- *
- * Inputs:
- * ------
- * argc = argument count.
- * argv = argument vector.
- * pArgnum = pointer to argument number where processing left off
- * lineP = pointer into argv[*pArgnum] where processing left off
- *
- *
- * Outputs:
- * -------
- * Changes global data to based on command line options recognized
- * + wmGD.screenNames
- * + wmGD.numScreens
- * Assumes default screenNames are already in place
- *
- *************************************<->***********************************/
- static void ParseScreensArgument (int argc, char *argv[], int *pArgnum,
- unsigned char *lineP)
- {
- unsigned char *string;
- int sNum = 0;
- int lastLen;
- int nameCount = 0;
- for (; (*pArgnum < argc) && (sNum < ScreenCount(DISPLAY));
- (*pArgnum)++, sNum++)
- {
- lineP = (unsigned char *)argv[*pArgnum];
- if (*argv[*pArgnum] == '"')
- {
- /*
- * if Quote, use GetString to strip it
- */
- if ((string = GetString (&lineP)) == NULL)
- /* empty or comment line */
- {
- continue;
- }
- }
- else
- {
- string = (unsigned char *)argv[*pArgnum];
- if (*string == '-')
- {
- /* another option, end of screens names */
- break;
- }
- }
-
- if (!(wmGD.screenNames[sNum] = (unsigned char *)
- XtRealloc ((char*)wmGD.screenNames[sNum],
- 1 + strlen((char *)string))))
- {
- Warning (((char *)GETMESSAGE(60, 31, "Insufficient memory for screen names")));
- ExitWM(WM_ERROR_EXIT_VALUE);
- }
- else
- {
- strcpy((char *)wmGD.screenNames[sNum], (char *)string);
- nameCount++;
- }
- }
- (*pArgnum)--;
- /*
- * remaining screens (if any) get first name specified
- */
- if (nameCount > 0)
- {
- lastLen = 1 + strlen((char *)wmGD.screenNames[0]);
- for (; sNum < ScreenCount(DISPLAY); sNum++)
- {
- if (!(wmGD.screenNames[sNum] = (unsigned char *)
- XtRealloc ((char*)wmGD.screenNames[sNum], lastLen)))
- {
- Warning (((char *)GETMESSAGE(60, 32, "Insufficient memory for screen names")));
- ExitWM(WM_ERROR_EXIT_VALUE);
- }
- else
- {
- strcpy((char *)wmGD.screenNames[sNum],
- (char *)wmGD.screenNames[0]);
- }
- }
- }
- } /* END OF FUNCTION ParseScreensArgument */
- /*************************************<->*************************************
- *
- * ProcessMotifBindings ()
- *
- *
- * Description:
- * -----------
- * This function is used retrieve the motif input bindings
- * and put them into a property on the root window.
- *
- *
- *************************************<->***********************************/
- void ProcessMotifBindings (void)
- {
- char fileName[MAXWMPATH+1];
- char *bindings = NULL;
- char *homeDir = XmeGetHomeDirName();
- /*
- * Look in the user's home directory for .motifbind
- */
- strcpy (fileName, homeDir);
- strncat(fileName, "/", MAXWMPATH-strlen(fileName));
- strncat(fileName, MOTIF_BINDINGS_FILE, MAXWMPATH-strlen(fileName));
- XDeleteProperty (DISPLAY, RootWindow (DISPLAY, 0),
- XInternAtom (DISPLAY, "_MOTIF_BINDINGS", False));
- XDeleteProperty (DISPLAY, RootWindow (DISPLAY, 0),
- XInternAtom (DISPLAY, "_MOTIF_DEFAULT_BINDINGS", False));
- if (_XmVirtKeysLoadFileBindings (fileName, &bindings) == True) {
- XChangeProperty (DISPLAY, RootWindow(DISPLAY, 0),
- XInternAtom (DISPLAY, "_MOTIF_BINDINGS", False),
- XA_STRING, 8, PropModeReplace,
- (unsigned char *)bindings, strlen(bindings));
- }
- else {
- _XmVirtKeysLoadFallbackBindings (DISPLAY, &bindings);
- }
- XtFree (bindings);
- } /* END OF FUNCTION ProcessMotifBindings */
- /*************************************<->*************************************
- *
- * void
- * ParseWmFunctionArg (linePP, ix, wmFunc, ppArg, sClientName)
- *
- *
- * Description:
- * -----------
- * Parse the function arguments for a window manager function.
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to line buffer pointer (contains string arg).
- * ix = window manager function index (returned by ParseWmFunction)
- * pWmFunction = pointer to window manager function destination.
- * ppArg = ptr to argument pointer.
- * sClientName = string name of client
- *
- *
- * Outputs:
- * -------
- * *ppArg = arg to pass to window manager function when invoking.
- * Return = true on succes, false on some kind of parse error
- *
- *
- * Comments:
- * --------
- * functionTable (window manager function table) is indexed with ix
- * to get parsing info.
- *
- * This function may malloc memory for the returned arg.
- *
- * The sClientName is needed for starting some hpterm-based push_recall
- * clients. It needs to be passed into the action so the hpterm gets
- * named appropriately.
- *
- *************************************<->***********************************/
- Boolean
- ParseWmFunctionArg (
- unsigned char **linePP,
- int ix,
- WmFunction wmFunc,
- void **ppArg,
- String sClientName,
- String sTitle)
- {
- unsigned char *lineP = *linePP;
- Boolean bValidArg = True;
- unsigned char *str = NULL;
- /*
- * If this is (possibly) a string argument, put it
- * in quotes so that it will be parsed properly.
- */
- if ((functionTable[ix].parseProc == ParseWmFuncStrArg) ||
- (functionTable[ix].parseProc == ParseWmFuncMaybeStrArg))
- {
- if (lineP && *lineP != '"')
- {
- /*
- * not in quotes, repackage it, escaping the appropriate
- * characters.
- */
- str = _DtWmParseMakeQuotedString (lineP);
- if (str)
- {
- lineP = str;
- }
- }
- }
- /*
- * Apply the function argument parser.
- */
- if ((functionTable[ix].wmFunction != wmFunc) ||
- !(*(functionTable [ix].parseProc)) (&lineP, wmFunc, ppArg))
- {
- bValidArg = False;
- }
- /*
- * Add the exec parms if this is an f.action
- */
- if ((wmFunc == F_Action) && ppArg && *ppArg)
- {
- WmActionArg *pAP = (WmActionArg *) *ppArg;
- int totLen = 0;
- /*
- * allocate more than enough string space to copy
- * strings and intervening spaces.
- */
- if (sClientName && *sClientName)
- {
- /* length of: "name=" + sClientName + NULL */
- totLen += 5 + strlen(sClientName) + 1;
- }
- if (sTitle && *sTitle)
- {
- /* length of: "," + "title=" + sTitle + NULL */
- totLen += 1 + 6 + strlen(sTitle) + 1;
- }
- if (totLen > 0)
- {
- pAP->szExecParms = (String) XtMalloc (totLen);
- /* start with empty string */
- pAP->szExecParms[0] = '\0';
- if (sClientName && *sClientName)
- {
- strcat (pAP->szExecParms, "name=");
- strcat (pAP->szExecParms, sClientName);
- }
- if (sTitle && *sTitle)
- {
- if (pAP->szExecParms[0] != '\0')
- {
- strcat (pAP->szExecParms, ",");
- }
- strcat (pAP->szExecParms, "title=");
- strcat (pAP->szExecParms, sTitle);
- }
- }
- }
- if (str)
- {
- XtFree ((char *) str);
- }
- return (bValidArg);
- } /* END OF FUNCTION ParseWmFunctionArg */
- /*************************************<->*************************************
- *
- * SystemCmd (pchCmd)
- *
- *
- * Description:
- * -----------
- * This function fiddles with our signal handling and calls the
- * system() function to invoke a unix command.
- *
- *
- * Inputs:
- * ------
- * pchCmd = string with the command we want to exec.
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- * The system() command is touchy about the SIGCLD behavior. Restore
- * the default SIGCLD handler during the time we run system().
- *
- *************************************<->***********************************/
- void
- SystemCmd (char *pchCmd)
- {
- struct sigaction sa;
- struct sigaction osa;
- (void) sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = SIG_DFL;
- (void) sigaction (SIGCHLD, &sa, &osa);
- system (pchCmd);
- (void) sigaction (SIGCHLD, &osa, (struct sigaction *) 0);
- }
- /*************************************<->*************************************
- *
- * DeleteTempConfigFileIfAny ()
- *
- *
- * Description:
- * -----------
- * This function deletes the temporary config file used to process
- * old dtwmrc syntax.
- *
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void
- DeleteTempConfigFileIfAny (void)
- {
- char pchCmd[MAXWMPATH+1];
- if (pConfigStackTop->tempName)
- {
- strcpy (pchCmd, "/bin/rm ");
- strcat (pchCmd, pConfigStackTop->tempName);
- SystemCmd (pchCmd);
- XtFree ((char *) pConfigStackTop->tempName);
- pConfigStackTop->tempName = NULL;
- }
- if (pConfigStackTop->cppName)
- {
- strcpy (pchCmd, "/bin/rm ");
- strcat (pchCmd, pConfigStackTop->cppName);
- SystemCmd (pchCmd);
- XtFree ((char *) pConfigStackTop->cppName);
- pConfigStackTop->cppName = NULL;
- }
- }
- /*************************************<->*************************************
- *
- * ParseIncludeSet (pSD, lineP)
- *
- *
- * Description:
- * -----------
- *
- *
- * Inputs:
- * ------
- * cfileP = (global) file pointer to fopened configuration file or NULL
- * lineP = pointer to line buffer
- * line = (global) line buffer
- * linec = (global) line count
- * parseP = (global) parse string pointer if cfileP == NULL
- * pSD->rootWindow = default root window of display
- *
- * Outputs:
- * -------
- * linec = (global) line count incremented
- * parseP = (global) parse string pointer if cfileP == NULL
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static void ParseIncludeSet (WmScreenData *pSD, unsigned char *lineP)
- {
- unsigned char *string;
- unsigned char *pchName;
- /*
- * Require leading '{' on the next line.
- */
- while ((GetNextLine () != NULL)) /* not EOF nor read error */
- {
- lineP = line;
- ScanWhitespace(&lineP);
- if ((lineP == NULL) || (*line == '!') || (*lineP == '\0') || (*lineP == '#'))
- /* ignore empty or comment line */
- {
- continue;
- }
- if (*lineP == '{')
- /* found '{' */
- {
- break;
- }
- /* not a '{' */
- PWarning (((char *)GETMESSAGE(60, 37, "Expected '{'")));
- return;
- }
- /*
- * Found leading "{" or EOF.
- * Parse include files until "}" or EOF found.
- */
- while ((GetNextLine () != NULL))
- {
- lineP = line;
- if ((*line == '!') || (string = GetString (&lineP)) == NULL)
- /* ignore empty or comment lines */
- {
- continue;
- }
- if (*string == '}') /* finished with set. */
- {
- break;
- }
- pchName = _DtWmParseFilenameExpand (string);
- if (pchName && ConfigStackPush (pchName))
- {
- ProcessWmFile (pSD, True /* nested */);
- ConfigStackPop ();
- XtFree ((char *) pchName);
- }
- }
- }
- /*************************************<->*************************************
- *
- * ConfigStackInit (pchFileName)
- *
- *
- * Description:
- * -----------
- * Initializes the config file processing stack
- *
- * Inputs:
- * ------
- * pchFileName = name of new file to start parsing
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static void ConfigStackInit (char *pchFileName)
- {
- pConfigStack = XtNew (ConfigFileStackEntry);
- if (pConfigStack)
- {
- pConfigStackTop = pConfigStack;
- pConfigStackTop->fileName = XtNewString (pchFileName);
- pConfigStackTop->tempName = NULL;
- pConfigStackTop->cppName = NULL;
- pConfigStackTop->offset = 0;
- pConfigStackTop->pWmPB = wmGD.pWmPB;
- pConfigStackTop->wmgdConfigFile = wmGD.configFile;
- pConfigStackTop->pIncluder = NULL;
- }
- else
- {
- sprintf ((char *)wmGD.tmpBuffer,
- (char *)GETMESSAGE(60,36,"Insufficient memory to process included file: %s"),
- pchFileName);
- Warning ((char *)wmGD.tmpBuffer);
- }
- }
- /*************************************<->*************************************
- *
- * ConfigStackPush (pchFileName)
- *
- *
- * Description:
- * -----------
- * Open an included config file
- *
- * Inputs:
- * ------
- * pchFileName = name of new file to start parsing
- * wmGD.pWmPB = global parse buffer (pickle this)
- *
- * Outputs:
- * -------
- * wmGD.pWmPB = global parse buffer (new one for new file)
- * return = FILE * to open file or NULL
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static FILE *
- ConfigStackPush (unsigned char *pchFileName)
- {
- ConfigFileStackEntry *pEntry;
- FILE *pNewFile = NULL;
- pEntry = XtNew (ConfigFileStackEntry);
- if (pEntry)
- {
- /* save off state of current config file */
- pConfigStackTop->offset = ftell (cfileP);
- pConfigStackTop->pWmPB = wmGD.pWmPB;
- fclose (cfileP);
- /* set up state of new config file */
- pEntry->fileName = XtNewString ((char *)pchFileName);
- pEntry->tempName = NULL;
- pEntry->cppName = NULL;
- pEntry->wmgdConfigFile = (String) pEntry->fileName;
- /* set globals for new config file */
- wmGD.pWmPB = _DtWmParseNewBuf ();
- wmGD.configFile = pEntry->wmgdConfigFile;
- /* put new entry onto stack */
- pEntry->pIncluder = pConfigStackTop;
- pConfigStackTop = pEntry;
- /* open the file */
- pNewFile = cfileP = FopenConfigFile();
- if (!pNewFile)
- {
- /* file open failed! back out */
- ConfigStackPop ();
- }
- }
- else
- {
- sprintf ((char *)wmGD.tmpBuffer,
- (char *)GETMESSAGE(60,36,"Insufficient memory to process included file: %s"),
- pchFileName);
- Warning ((char *)wmGD.tmpBuffer);
- }
- return (pNewFile);
- }
- /*************************************<->*************************************
- *
- * ConfigStackPop ()
- *
- *
- * Description:
- * -----------
- *
- *
- * Inputs:
- * ------
- * pchFileName = name of new file to start parsing
- * wmGD.pWmPB = global parse buffer (pickle this)
- *
- * Outputs:
- * -------
- * wmGD.pWmPB = global parse buffer (new one for new file)
- *
- *
- * Comments:
- * --------
- * assumes cfileP is closed already
- *
- *************************************<->***********************************/
- static void ConfigStackPop (void)
- {
- ConfigFileStackEntry *pPrev;
- char pchCmd[MAXWMPATH+1];
- if (pConfigStackTop != pConfigStack)
- {
- pPrev = pConfigStackTop->pIncluder;
- _DtWmParseDestroyBuf (wmGD.pWmPB);
- if (pConfigStackTop->tempName)
- {
- XtFree (pConfigStackTop->tempName);
- }
- if (pConfigStackTop->cppName)
- {
- strcpy (pchCmd, "/bin/rm ");
- strcat (pchCmd, pConfigStackTop->cppName);
- SystemCmd (pchCmd);
- XtFree ((char *) pConfigStackTop->cppName);
- pConfigStackTop->cppName = NULL;
- }
- if (pConfigStackTop->fileName)
- {
- XtFree (pConfigStackTop->fileName);
- }
- wmGD.pWmPB = pPrev->pWmPB;
- wmGD.configFile = pPrev->wmgdConfigFile;
- if (pPrev->tempName)
- {
- cfileP = fopen (pPrev->tempName, "r");
- }
- else if (pPrev->cppName)
- {
- cfileP = fopen (pPrev->cppName, "r");
- }
- else
- {
- cfileP = fopen (pPrev->fileName, "r");
- }
- if (cfileP)
- {
- fseek (cfileP, pPrev->offset, 0);
- }
- else
- {
- char msg[MAXWMPATH+1];
- sprintf(msg, ((char *)GETMESSAGE(60, 39,
- "Could not reopen configuration file %s")),
- pPrev->fileName);
- Warning (msg);
- }
- XtFree ((char *)pConfigStackTop);
- pConfigStackTop = pPrev;
- }
- }
- /*************************************<->*************************************
- *
- * ParseWmFuncActionArg (linePP, wmFunction, pArgs)
- *
- *
- * Description:
- * -----------
- * Parses a window manager f.action argument
- *
- *
- * Inputs:
- * ------
- * linePP = pointer to current line buffer pointer.
- * wmFunction = function for which the argument string is intended.
- * pArgs = pointer to argument destination.
- *
- *
- * Outputs:
- * -------
- * linePP = pointer to revised line buffer pointer.
- * pArgs = pointer to parsed argument.
- * Return = FALSE iff insufficient memory
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- Boolean ParseWmFuncActionArg (unsigned char **linePP,
- WmFunction wmFunction, String *pArgs)
- {
- #define WM_ACTION_ARG_INCREMENT 5
- #define WM_ACTION_ARG_PAD 256
- unsigned char *string;
- char *pch;
- WmActionArg *pAP;
- int iArgSz;
- pAP = XtNew (WmActionArg);
- if (pAP && (string = GetString (linePP)) != NULL)
- {
- /* Got action name */
- pAP->actionName = XtNewString ((char *) string);
- /* Get action arguments, if any */
- if ((pAP->aap = (DtActionArg *)
- XtMalloc (WM_ACTION_ARG_INCREMENT * sizeof (DtActionArg))))
- {
- iArgSz = WM_ACTION_ARG_INCREMENT;
- pAP->numArgs = 0;
- while ((string = GetString (linePP)) != NULL)
- {
- if ((pAP->aap[pAP->numArgs].u.file.name = (char *)
- XtMalloc(1 + strlen((char *)string))))
- {
- pAP->aap[pAP->numArgs].argClass = DtACTION_FILE;
- /* format the action argument */
- pch = pAP->aap[pAP->numArgs].u.file.name;
- /*
- * Expand environment variable
- */
- if (string[0] == '$')
- {
- string = (unsigned char *) getenv ((char *)&string[1]);
- if (!string)
- {
- break;
- }
- else
- {
- /*
- * Make sure there's room for the new
- * string.
- */
- pch = (char *)
- XtRealloc (pch, (1+strlen((char *)string)));
- pAP->aap[pAP->numArgs].u.file.name = pch;
- }
- }
- /* !!! No host name processing is done!!! */
- strcpy (pch, (char *)string);
- pAP->numArgs++;
- if (pAP->numArgs == iArgSz)
- {
- /* need to increase our array space */
- iArgSz += WM_ACTION_ARG_INCREMENT;
- pAP->aap = (DtActionArg *)
- XtRealloc((char *)pAP->aap,
- (iArgSz * sizeof (DtActionArg)));
- if (!pAP->aap)
- {
- break; /* out of memory */
- }
- }
- }
- else
- {
- break; /* out of memory */
- }
- }
- }
- pAP->szExecParms = NULL;
- *pArgs = (String) pAP;
- }
- else
- /* NULL string argument */
- {
- *pArgs = NULL;
- }
- return (TRUE);
- } /* END OF FUNCTION ParseWmFuncActionArg */
- /*************************************<->*************************************
- *
- * PreprocessConfigFile (pSD)
- *
- *
- * Description:
- * -----------
- * This function runs the configuration file through the C
- * preprocessor
- *
- *
- * Inputs:
- * ------
- * pSD = ptr to screen data
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static void
- PreprocessConfigFile (void)
- {
- #define CPP_NAME_SIZE ((L_tmpnam)+1)
- char pchCmd[MAXWMPATH+1];
- if (wmGD.cppCommand && *wmGD.cppCommand)
- {
- /*
- * Generate a temp file name.
- */
- pConfigStackTop->cppName = XtMalloc (CPP_NAME_SIZE * sizeof(char));
- if (pConfigStackTop->cppName)
- {
- (void) tmpnam (pConfigStackTop->cppName);
- /*
- * Build up the command line.
- */
- strcpy (pchCmd, wmGD.cppCommand);
- strcat (pchCmd, " ");
- strcat (pchCmd, pConfigStackTop->fileName);
- strcat (pchCmd, " ");
- strcat (pchCmd, pConfigStackTop->cppName);
- /*
- * Run the config file through the converter program
- * and send the output to a temp file.
- */
- SystemCmd (pchCmd);
- }
- }
- }
- /*************************************<->*************************************
- *
- * GetNetworkFileName (char *pchFile)
- *
- *
- * Description:
- * -----------
- * This function returns a local representation for a network
- * file.
- *
- *
- * Inputs:
- * ------
- * pchFile - pointer to file name of form [<host>:]<path>
- *
- * Return:
- * -------
- * String - ptr to allocated string of local file name. If input
- * is not a network file, the a copy of pchFile is returned.
- *
- *
- * Comments:
- * --------
- * returned file name should be freed with XtFree().
- *
- *************************************<->***********************************/
- static String
- GetNetworkFileName (char *pchFile)
- {
- char *pch;
- char *host_part;
- char *file_part;
- char *netfile;
- char *sName = NULL;
- char *pchName = NULL;
- int count;
- char **pchTok;
- String sReturn = NULL;
- char *homeDir;
- int len;
- pch = strchr (pchFile, ':');
- if (pch)
- {
- /*
- * Expand special chars and find matching file.
- */
- pchTok = (char **)shellscan (pchFile, &count, 0);
- if ((count == 1) || (count == 2))
- {
- /* one match found */
- host_part = pchTok[0];
- }
- else if (count > 2)
- {
- /* several matches found, pick one */
- host_part = pchTok[1];
- }
- else
- {
- host_part = NULL;
- }
- if (host_part != NULL)
- {
- pch = strchr (host_part, ':');
- if (pch)
- {
- /*
- * copy the string so we don't munge data
- * inside shellscan
- */
- host_part = sName = XtNewString ((String) host_part);
- pch = strchr (sName, ':');
- /*
- * separate the host and file parts of the
- * file name
- */
- *pch = '\0';
- file_part = pch+1;
- }
- else
- {
- /*
- * The colon went away. Hmm...
- */
- file_part = host_part;
- host_part = NULL;
- }
- if ((mblen(file_part, MB_CUR_MAX) == 1) &&
- (mblen(file_part+1, MB_CUR_MAX) == 1) &&
- (*file_part == '~') &&
- (*(file_part+1) == '/'))
- {
- /*
- * Replace '~' with $HOME
- */
- homeDir = XmeGetHomeDirName();
- len = strlen (host_part) + 1 +
- strlen (homeDir) + strlen (file_part) + 1;
- pch = (char *) XtMalloc (len);
- strcpy (pch, sName);
- host_part = pch;
- pch += strlen (pch) + 1;
- strcpy (pch, homeDir);
- strcat (pch, file_part+1);
- file_part = pch;
- XtFree (sName);
- sName = host_part;
- }
- }
- else
- {
- /*
- * shellscan had a problem with the file name.
- * just operate on the name as-is.
- * temporarily replace ':' with a NULL
- */
- host_part = sName = XtNewString ((String) pchFile);
- pch = strchr (sName, ':');
- *pch = '\0';
- host_part = pchFile;
- file_part = pch+1;
- }
- /* convert to canonical host/file name */
- netfile = (char *)
- tt_host_file_netfile (host_part, file_part);
- if (tt_pointer_error (netfile) == TT_OK)
- {
- /* convert to local file name equivalent */
- pchName = tt_netfile_file (netfile);
- if (tt_pointer_error (pchName) == TT_OK)
- {
- sReturn = XtNewString ((String) pchName);
- tt_free ((char *)pchName);
- }
- tt_free (netfile);
- }
- if (sName)
- {
- XtFree ((char *)sName);
- }
- }
- if (sReturn == NULL)
- {
- if ((mblen(pchFile, MB_CUR_MAX) == 1) &&
- (mblen(pchFile+1, MB_CUR_MAX) == 1) &&
- (*pchFile == '~') &&
- (*(pchFile+1) == '/'))
- {
- /*
- * Replace '~' with $HOME
- */
- homeDir = XmeGetHomeDirName();
- len = strlen (homeDir) + strlen (pchFile) + 1;
- sReturn = (char *) XtMalloc (len);
- strcpy (sReturn, homeDir);
- strcat (sReturn, pchFile+1);
- }
- else
- {
- sReturn = XtNewString ((String) pchFile);
- }
- }
- return (sReturn);
- }
- /**************************** eof ***************************/
|