GLib.gtkdoc.xml 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231
  1. <?xml version="1.0"?><book><chapter><title>GLib</title><refentry><refnamediv><refname>&lt;GArray&gt;</refname></refnamediv><refsect1><title>Description</title><para>Contains the public fields of a GArray.</para></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibAsciiType&gt;</refname></refnamediv><refsect1><title>Members</title><refsect2><title>alnum</title><remark>alias <code>G_ASCII_ALNUM</code></remark><para>Undocumented</para></refsect2><refsect2><title>alpha</title><remark>alias <code>G_ASCII_ALPHA</code></remark><para>Undocumented</para></refsect2><refsect2><title>cntrl</title><remark>alias <code>G_ASCII_CNTRL</code></remark><para>Undocumented</para></refsect2><refsect2><title>digit</title><remark>alias <code>G_ASCII_DIGIT</code></remark><para>Undocumented</para></refsect2><refsect2><title>graph</title><remark>alias <code>G_ASCII_GRAPH</code></remark><para>Undocumented</para></refsect2><refsect2><title>lower</title><remark>alias <code>G_ASCII_LOWER</code></remark><para>Undocumented</para></refsect2><refsect2><title>print</title><remark>alias <code>G_ASCII_PRINT</code></remark><para>Undocumented</para></refsect2><refsect2><title>punct</title><remark>alias <code>G_ASCII_PUNCT</code></remark><para>Undocumented</para></refsect2><refsect2><title>space</title><remark>alias <code>G_ASCII_SPACE</code></remark><para>Undocumented</para></refsect2><refsect2><title>upper</title><remark>alias <code>G_ASCII_UPPER</code></remark><para>Undocumented</para></refsect2><refsect2><title>xdigit</title><remark>alias <code>G_ASCII_XDIGIT</code></remark><para>Undocumented</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibBookmarkFileError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by bookmark file parsing.</para></refsect1><refsect1><title>Members</title><refsect2><title>invalid-uri</title><remark>alias <code>G_BOOKMARK_FILE_ERROR_INVALID_URI</code></remark><para>URI was ill-formed</para></refsect2><refsect2><title>invalid-value</title><remark>alias <code>G_BOOKMARK_FILE_ERROR_INVALID_VALUE</code></remark><para>a requested field was not found</para></refsect2><refsect2><title>app-not-registered</title><remark>alias <code>G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED</code></remark><para>a requested application did
  2. not register a bookmark</para></refsect2><refsect2><title>uri-not-found</title><remark>alias <code>G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND</code></remark><para>a requested URI was not found</para></refsect2><refsect2><title>read</title><remark>alias <code>G_BOOKMARK_FILE_ERROR_READ</code></remark><para>document was ill formed</para></refsect2><refsect2><title>unknown-encoding</title><remark>alias <code>G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING</code></remark><para>the text being parsed was
  3. in an unknown encoding</para></refsect2><refsect2><title>write</title><remark>alias <code>G_BOOKMARK_FILE_ERROR_WRITE</code></remark><para>an error occurred while writing</para></refsect2><refsect2><title>file-not-found</title><remark>alias <code>G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND</code></remark><para>requested file was not found</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GByteArray&gt;</refname></refnamediv><refsect1><title>Description</title><para>Contains the public fields of a GByteArray.</para></refsect1><refsect1><title>Functions</title><refsect2><title>byte-array:free</title><informalexample><programlisting>(define-values (%return) (byte-array:free array free-segment))
  4. </programlisting></informalexample><para>Frees the memory allocated by the <type>GByteArray</type>. If <parameter>free_segment</parameter> is
  5. <constant>TRUE</constant> it frees the actual byte data. If the reference count of
  6. <parameter>array</parameter> is greater than one, the <type>GByteArray</type> wrapper is preserved but
  7. the size of <parameter>array</parameter> will be set to zero.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>array</para></td><td class="parameter_description"><para>a <type>GByteArray</type></para><para>Passed as <code>array</code></para></td></tr><tr><td class="parameter_name"><para>free_segment</para></td><td class="parameter_description"><para>if <constant>TRUE</constant> the actual byte data is freed as well</para><para>Passed as <code>free-segment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>byte-array:free-to-bytes</title><informalexample><programlisting>(define-values (%return) (byte-array:free-to-bytes array))
  8. </programlisting></informalexample><para>Transfers the data from the <type>GByteArray</type> into a new immutable <type>GBytes</type>.
  9. </para>
  10. <para>The <type>GByteArray</type> is freed unless the reference count of <parameter>array</parameter> is greater
  11. than one, the <type>GByteArray</type> wrapper is preserved but the size of <parameter>array</parameter>
  12. will be set to zero.
  13. </para>
  14. <para>This is identical to using <function>g_bytes_new_take()</function> and <function>g_byte_array_free()</function>
  15. together.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>array</para></td><td class="parameter_description"><para>a <type>GByteArray</type></para><para>Passed as <code>array</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>byte-array:new</title><informalexample><programlisting>(define-values (%return) (byte-array:new))
  16. </programlisting></informalexample><para>Creates a new <type>GByteArray</type> with a reference count of 1.</para></refsect2><refsect2><title>byte-array:new-take</title><informalexample><programlisting>(define-values (%return) (byte-array:new-take data))
  17. </programlisting></informalexample><para>Create byte array containing the data. The data will be owned by the array
  18. and will be freed with <function>g_free()</function>, i.e. it could be allocated using <function>g_strdup()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>byte data for the array</para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>data</parameter></para><para>Inferred from <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>byte-array:steal</title><informalexample><programlisting>(define-values (%return len) (byte-array:steal array len))
  19. </programlisting></informalexample><para>Frees the data in the array and resets the size to zero, while
  20. the underlying array is preserved for use elsewhere and returned
  21. to the caller.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>array</para></td><td class="parameter_description"><para>a <type>GByteArray</type>.</para><para>Passed as <code>array</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>pointer to retrieve the number of
  22. elements of the original array</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>byte-array:unref</title><informalexample><programlisting>(define-values () (byte-array:unref array))
  23. </programlisting></informalexample><para>Atomically decrements the reference count of <parameter>array</parameter> by one. If the
  24. reference count drops to 0, all memory allocated by the array is
  25. released. This function is thread-safe and may be called from any
  26. thread.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>array</para></td><td class="parameter_description"><para>A <type>GByteArray</type></para><para>Passed as <code>array</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GBytes&gt;</refname></refnamediv><refsect1><title>Description</title><para>A simple refcounted data type representing an immutable sequence of zero or
  27. more bytes from an unspecified origin.
  28. </para>
  29. <para>The purpose of a <type>GBytes</type> is to keep the memory region that it holds
  30. alive for as long as anyone holds a reference to the bytes. When
  31. the last reference count is dropped, the memory is released. Multiple
  32. unrelated callers can use byte data in the <type>GBytes</type> without coordinating
  33. their activities, resting assured that the byte data will not change or
  34. move while they hold a reference.
  35. </para>
  36. <para>A <type>GBytes</type> can come from many different origins that may have
  37. different procedures for freeing the memory region. Examples are
  38. memory from <function>g_malloc()</function>, from memory slices, from a <type>GMappedFile</type> or
  39. memory from other allocators.
  40. </para>
  41. <para><type>GBytes</type> work well as keys in <type>GHashTable</type>. Use <function>g_bytes_equal()</function> and
  42. <function>g_bytes_hash()</function> as parameters to <function>g_hash_table_new()</function> or <function>g_hash_table_new_full()</function>.
  43. <type>GBytes</type> can also be used as keys in a <type>GTree</type> by passing the <function>g_bytes_compare()</function>
  44. function to <function>g_tree_new()</function>.
  45. </para>
  46. <para>The data pointed to by this bytes must not be modified. For a mutable
  47. array of bytes see <type>GByteArray</type>. Use <function>g_bytes_unref_to_array()</function> to create a
  48. mutable array for a <type>GBytes</type> sequence. To create an immutable <type>GBytes</type> from
  49. a mutable <type>GByteArray</type>, use the <function>g_byte_array_free_to_bytes()</function> function.</para></refsect1><refsect1><title>Functions</title><refsect2><title>compare</title><informalexample><programlisting>(define-values (%return) (bytes:compare self bytes2))
  50. </programlisting></informalexample><para>Compares the two <type>GBytes</type> values.
  51. </para>
  52. <para>This function can be used to sort GBytes instances in lexicographical order.
  53. </para>
  54. <para>If <parameter>bytes1</parameter> and <parameter>bytes2</parameter> have different length but the shorter one is a
  55. prefix of the longer one then the shorter one is considered to be less than
  56. the longer one. Otherwise the first byte where both differ is used for
  57. comparison. If <parameter>bytes1</parameter> has a smaller value at that position it is
  58. considered less, otherwise greater than <parameter>bytes2</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bytes1</para></td><td class="parameter_description"><para>a pointer to a <type>GBytes</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>bytes2</para></td><td class="parameter_description"><para>a pointer to a <type>GBytes</type> to compare with <parameter>bytes1</parameter></para><para>Passed as <code>bytes2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>equal?</title><informalexample><programlisting>(define-values (%return) (bytes:equal? self bytes2))
  59. </programlisting></informalexample><para>Compares the two <type>GBytes</type> values being pointed to and returns
  60. <constant>TRUE</constant> if they are equal.
  61. </para>
  62. <para>This function can be passed to <function>g_hash_table_new()</function> as the <parameter>key_equal_func</parameter>
  63. parameter, when using non-<constant>NULL</constant> <type>GBytes</type> pointers as keys in a <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bytes1</para></td><td class="parameter_description"><para>a pointer to a <type>GBytes</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>bytes2</para></td><td class="parameter_description"><para>a pointer to a <type>GBytes</type> to compare with <parameter>bytes1</parameter></para><para>Passed as <code>bytes2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-data</title><informalexample><programlisting>(define-values (%return size) (bytes:get-data self))
  64. </programlisting></informalexample><para>Get the byte data in the <type>GBytes</type>. This data should not be modified.
  65. </para>
  66. <para>This function will always return the same pointer for a given <type>GBytes</type>.
  67. </para>
  68. <para><constant>NULL</constant> may be returned if <parameter>size</parameter> is 0. This is not guaranteed, as the <type>GBytes</type>
  69. may represent an empty string with <parameter>data</parameter> non-<constant>NULL</constant> and <parameter>size</parameter> as 0. <constant>NULL</constant> will
  70. not be returned if <parameter>size</parameter> is non-zero.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bytes</para></td><td class="parameter_description"><para>a <type>GBytes</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>size</para></td><td class="parameter_description"><para>location to return size of byte data</para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-region</title><informalexample><programlisting>(define-values
  71. (%return)
  72. (bytes:get-region self element-size offset n-elements))
  73. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bytes</para></td><td class="parameter_description"><para></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>element_size</para></td><td class="parameter_description"><para></para><para>Passed as <code>element-size</code></para></td></tr><tr><td class="parameter_name"><para>offset</para></td><td class="parameter_description"><para></para><para>Passed as <code>offset</code></para></td></tr><tr><td class="parameter_name"><para>n_elements</para></td><td class="parameter_description"><para></para><para>Passed as <code>n-elements</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-size</title><informalexample><programlisting>(define-values (%return) (bytes:get-size self))
  74. </programlisting></informalexample><para>Get the size of the byte data in the <type>GBytes</type>.
  75. </para>
  76. <para>This function will always return the same value for a given <type>GBytes</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bytes</para></td><td class="parameter_description"><para>a <type>GBytes</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash</title><informalexample><programlisting>(define-values (%return) (bytes:hash self))
  77. </programlisting></informalexample><para>Creates an integer hash code for the byte data in the <type>GBytes</type>.
  78. </para>
  79. <para>This function can be passed to <function>g_hash_table_new()</function> as the <parameter>key_hash_func</parameter>
  80. parameter, when using non-<constant>NULL</constant> <type>GBytes</type> pointers as keys in a <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bytes</para></td><td class="parameter_description"><para>a pointer to a <type>GBytes</type> key</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>new-from-bytes</title><informalexample><programlisting>(define-values (%return) (bytes:new-from-bytes self offset length))
  81. </programlisting></informalexample><para>Creates a <type>GBytes</type> which is a subsection of another <type>GBytes</type>. The <parameter>offset</parameter> +
  82. <parameter>length</parameter> may not be longer than the size of <parameter>bytes</parameter>.
  83. </para>
  84. <para>A reference to <parameter>bytes</parameter> will be held by the newly created <type>GBytes</type> until
  85. the byte data is no longer needed.
  86. </para>
  87. <para>Since 2.56, if <parameter>offset</parameter> is 0 and <parameter>length</parameter> matches the size of <parameter>bytes</parameter>, then
  88. <parameter>bytes</parameter> will be returned with the reference count incremented by 1. If <parameter>bytes</parameter>
  89. is a slice of another <type>GBytes</type>, then the resulting <type>GBytes</type> will reference
  90. the same <type>GBytes</type> instead of <parameter>bytes</parameter>. This allows consumers to simplify the
  91. usage of <type>GBytes</type> when asynchronously writing to streams.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bytes</para></td><td class="parameter_description"><para>a <type>GBytes</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>offset</para></td><td class="parameter_description"><para>offset which subsection starts at</para><para>Passed as <code>offset</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>length of subsection</para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (bytes:ref self))
  92. </programlisting></informalexample><para>Increase the reference count on <parameter>bytes</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bytes</para></td><td class="parameter_description"><para>a <type>GBytes</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (bytes:unref self))
  93. </programlisting></informalexample><para>Releases a reference on <parameter>bytes</parameter>. This may result in the bytes being
  94. freed. If <parameter>bytes</parameter> is <constant>NULL</constant>, it will return immediately.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bytes</para></td><td class="parameter_description"><para>a <type>GBytes</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref-to-array</title><informalexample><programlisting>(define-values (%return) (bytes:unref-to-array self))
  95. </programlisting></informalexample><para>Unreferences the bytes, and returns a new mutable <type>GByteArray</type> containing
  96. the same byte data.
  97. </para>
  98. <para>As an optimization, the byte data is transferred to the array without copying
  99. if this was the last reference to bytes and bytes was created with
  100. <function>g_bytes_new()</function>, <function>g_bytes_new_take()</function> or <function>g_byte_array_free_to_bytes()</function>. In all
  101. other cases the data is copied.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bytes</para></td><td class="parameter_description"><para>a <type>GBytes</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref-to-data</title><informalexample><programlisting>(define-values (%return size) (bytes:unref-to-data self))
  102. </programlisting></informalexample><para>Unreferences the bytes, and returns a pointer the same byte data
  103. contents.
  104. </para>
  105. <para>As an optimization, the byte data is returned without copying if this was
  106. the last reference to bytes and bytes was created with <function>g_bytes_new()</function>,
  107. <function>g_bytes_new_take()</function> or <function>g_byte_array_free_to_bytes()</function>. In all other cases the
  108. data is copied.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bytes</para></td><td class="parameter_description"><para>a <type>GBytes</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>size</para></td><td class="parameter_description"><para>location to place the length of the returned data</para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>bytes:new-take</title><informalexample><programlisting>(define-values (%return) (bytes:new-take data))
  109. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para></para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>size</para></td><td class="parameter_description"><para></para><para>Inferred from <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>bytes:new</title><informalexample><programlisting>(define-values (%return) (bytes:new data))
  110. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para></para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>size</para></td><td class="parameter_description"><para></para><para>Inferred from <code>data</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GChecksum&gt;</refname></refnamediv><refsect1><title>Description</title><para>An opaque structure representing a checksumming operation.
  111. </para>
  112. <para>To create a new GChecksum, use <function>g_checksum_new()</function>. To free
  113. a GChecksum, use <function>g_checksum_free()</function>.</para></refsect1><refsect1><title>Functions</title><refsect2><title>copy</title><informalexample><programlisting>(define-values (%return) (checksum:copy self))
  114. </programlisting></informalexample><para>Copies a <type>GChecksum</type>. If <parameter>checksum</parameter> has been closed, by calling
  115. <function>g_checksum_get_string()</function> or <function>g_checksum_get_digest()</function>, the copied
  116. checksum will be closed as well.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>checksum</para></td><td class="parameter_description"><para>the <type>GChecksum</type> to copy</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>free</title><informalexample><programlisting>(define-values () (checksum:free self))
  117. </programlisting></informalexample><para>Frees the memory allocated for <parameter>checksum</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>checksum</para></td><td class="parameter_description"><para>a <type>GChecksum</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-string</title><informalexample><programlisting>(define-values (%return) (checksum:get-string self))
  118. </programlisting></informalexample><para>Gets the digest as a hexadecimal string.
  119. </para>
  120. <para>Once this function has been called the <type>GChecksum</type> can no longer be
  121. updated with <function>g_checksum_update()</function>.
  122. </para>
  123. <para>The hexadecimal characters will be lower case.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>checksum</para></td><td class="parameter_description"><para>a <type>GChecksum</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>reset</title><informalexample><programlisting>(define-values () (checksum:reset self))
  124. </programlisting></informalexample><para>Resets the state of the <parameter>checksum</parameter> back to its initial state.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>checksum</para></td><td class="parameter_description"><para>the <type>GChecksum</type> to reset</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>update</title><informalexample><programlisting>(define-values () (checksum:update self data))
  125. </programlisting></informalexample><para>Feeds <parameter>data</parameter> into an existing <type>GChecksum</type>. The checksum must still be
  126. open, that is <function>g_checksum_get_string()</function> or <function>g_checksum_get_digest()</function> must
  127. not have been called on <parameter>checksum</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>checksum</para></td><td class="parameter_description"><para>a <type>GChecksum</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>buffer used to compute the checksum</para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>size of the buffer, or -1 if it is a null-terminated string.</para><para>Inferred from <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>checksum:new</title><informalexample><programlisting>(define-values (%return) (checksum:new checksum-type))
  128. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>checksum_type</para></td><td class="parameter_description"><para></para><para>Passed as <code>checksum-type</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>checksum:type-get-length</title><informalexample><programlisting>(define-values (%return) (checksum:type-get-length checksum-type))
  129. </programlisting></informalexample><para>Gets the length in bytes of digests of type <parameter>checksum_type</parameter></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>checksum_type</para></td><td class="parameter_description"><para>a <type>GChecksumType</type></para><para>Passed as <code>checksum-type</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibChecksumType&gt;</refname></refnamediv><refsect1><title>Description</title><para>The hashing algorithm to be used by <type>GChecksum</type> when performing the
  130. digest of some data.
  131. </para>
  132. <para>Note that the <type>GChecksumType</type> enumeration may be extended at a later
  133. date to include new hashing algorithm types.</para></refsect1><refsect1><title>Members</title><refsect2><title>md5</title><remark>alias <code>G_CHECKSUM_MD5</code></remark><para>Use the MD5 hashing algorithm</para></refsect2><refsect2><title>sha1</title><remark>alias <code>G_CHECKSUM_SHA1</code></remark><para>Use the SHA-1 hashing algorithm</para></refsect2><refsect2><title>sha256</title><remark>alias <code>G_CHECKSUM_SHA256</code></remark><para>Use the SHA-256 hashing algorithm</para></refsect2><refsect2><title>sha512</title><remark>alias <code>G_CHECKSUM_SHA512</code></remark><para>Use the SHA-512 hashing algorithm (Since: 2.36)</para></refsect2><refsect2><title>sha384</title><remark>alias <code>G_CHECKSUM_SHA384</code></remark><para>Use the SHA-384 hashing algorithm (Since: 2.51)</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibConvertError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by character set conversion routines.</para></refsect1><refsect1><title>Members</title><refsect2><title>no-conversion</title><remark>alias <code>G_CONVERT_ERROR_NO_CONVERSION</code></remark><para>Conversion between the requested character
  134. sets is not supported.</para></refsect2><refsect2><title>illegal-sequence</title><remark>alias <code>G_CONVERT_ERROR_ILLEGAL_SEQUENCE</code></remark><para>Invalid byte sequence in conversion input;
  135. or the character sequence could not be represented in the target
  136. character set.</para></refsect2><refsect2><title>failed</title><remark>alias <code>G_CONVERT_ERROR_FAILED</code></remark><para>Conversion failed for some reason.</para></refsect2><refsect2><title>partial-input</title><remark>alias <code>G_CONVERT_ERROR_PARTIAL_INPUT</code></remark><para>Partial character sequence at end of input.</para></refsect2><refsect2><title>bad-uri</title><remark>alias <code>G_CONVERT_ERROR_BAD_URI</code></remark><para>URI is invalid.</para></refsect2><refsect2><title>not-absolute-path</title><remark>alias <code>G_CONVERT_ERROR_NOT_ABSOLUTE_PATH</code></remark><para>Pathname is not an absolute path.</para></refsect2><refsect2><title>no-memory</title><remark>alias <code>G_CONVERT_ERROR_NO_MEMORY</code></remark><para>No memory available. Since: 2.40</para></refsect2><refsect2><title>embedded-nul</title><remark>alias <code>G_CONVERT_ERROR_EMBEDDED_NUL</code></remark><para>An embedded NUL character is present in
  137. conversion output where a NUL-terminated string is expected.
  138. Since: 2.56</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GDate&gt;</refname></refnamediv><refsect1><title>Description</title><para>Represents a day between January 1, Year 1 and a few thousand years in
  139. the future. None of its members should be accessed directly.
  140. </para>
  141. <para>If the <type>GDate</type>-struct is obtained from <function>g_date_new()</function>, it will be safe
  142. to mutate but invalid and thus not safe for calendrical computations.
  143. </para>
  144. <para>If it's declared on the stack, it will contain garbage so must be
  145. initialized with <function>g_date_clear()</function>. <function>g_date_clear()</function> makes the date invalid
  146. but safe. An invalid date doesn't represent a day, it's &quot;empty.&quot; A date
  147. becomes valid after you set it to a Julian day or you set a day, month,
  148. and year.</para></refsect1><refsect1><title>Functions</title><refsect2><title>add-days</title><informalexample><programlisting>(define-values () (date:add-days self n-days))
  149. </programlisting></informalexample><para>Increments a date some number of days.
  150. To move forward by weeks, add weeks*7 days.
  151. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to increment</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>n_days</para></td><td class="parameter_description"><para>number of days to move the date forward</para><para>Passed as <code>n-days</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-months</title><informalexample><programlisting>(define-values () (date:add-months self n-months))
  152. </programlisting></informalexample><para>Increments a date by some number of months.
  153. If the day of the month is greater than 28,
  154. this routine may change the day of the month
  155. (because the destination month may not have
  156. the current day in it). The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to increment</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>n_months</para></td><td class="parameter_description"><para>number of months to move forward</para><para>Passed as <code>n-months</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-years</title><informalexample><programlisting>(define-values () (date:add-years self n-years))
  157. </programlisting></informalexample><para>Increments a date by some number of years.
  158. If the date is February 29, and the destination
  159. year is not a leap year, the date will be changed
  160. to February 28. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to increment</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>n_years</para></td><td class="parameter_description"><para>number of years to move forward</para><para>Passed as <code>n-years</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>clamp</title><informalexample><programlisting>(define-values () (date:clamp self min-date max-date))
  161. </programlisting></informalexample><para>If <parameter>date</parameter> is prior to <parameter>min_date</parameter>, sets <parameter>date</parameter> equal to <parameter>min_date</parameter>.
  162. If <parameter>date</parameter> falls after <parameter>max_date</parameter>, sets <parameter>date</parameter> equal to <parameter>max_date</parameter>.
  163. Otherwise, <parameter>date</parameter> is unchanged.
  164. Either of <parameter>min_date</parameter> and <parameter>max_date</parameter> may be <constant>NULL</constant>.
  165. All non-<constant>NULL</constant> dates must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to clamp</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>min_date</para></td><td class="parameter_description"><para>minimum accepted value for <parameter>date</parameter></para><para>Passed as <code>min-date</code></para></td></tr><tr><td class="parameter_name"><para>max_date</para></td><td class="parameter_description"><para>maximum accepted value for <parameter>date</parameter></para><para>Passed as <code>max-date</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>clear</title><informalexample><programlisting>(define-values () (date:clear self n-dates))
  166. </programlisting></informalexample><para>Initializes one or more <type>GDate</type> structs to a safe but invalid
  167. state. The cleared dates will not represent an existing date, but will
  168. not contain garbage. Useful to init a date declared on the stack.
  169. Validity can be tested with <function>g_date_valid()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>pointer to one or more dates to clear</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>n_dates</para></td><td class="parameter_description"><para>number of dates to clear</para><para>Passed as <code>n-dates</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>compare</title><informalexample><programlisting>(define-values (%return) (date:compare self rhs))
  170. </programlisting></informalexample><para><function>qsort()</function>-style comparison function for dates.
  171. Both dates must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>lhs</para></td><td class="parameter_description"><para>first date to compare</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>rhs</para></td><td class="parameter_description"><para>second date to compare</para><para>Passed as <code>rhs</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>copy</title><informalexample><programlisting>(define-values (%return) (date:copy self))
  172. </programlisting></informalexample><para>Copies a GDate to a newly-allocated GDate. If the input was invalid
  173. (as determined by <function>g_date_valid()</function>), the invalid state will be copied
  174. as is into the new object.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to copy</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>days-between</title><informalexample><programlisting>(define-values (%return) (date:days-between self date2))
  175. </programlisting></informalexample><para>Computes the number of days between two dates.
  176. If <parameter>date2</parameter> is prior to <parameter>date1</parameter>, the returned value is negative.
  177. Both dates must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date1</para></td><td class="parameter_description"><para>the first date</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>date2</para></td><td class="parameter_description"><para>the second date</para><para>Passed as <code>date2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>free</title><informalexample><programlisting>(define-values () (date:free self))
  178. </programlisting></informalexample><para>Frees a <type>GDate</type> returned from <function>g_date_new()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to free</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-day</title><informalexample><programlisting>(define-values (%return) (date:get-day self))
  179. </programlisting></informalexample><para>Returns the day of the month. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to extract the day of the month from</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-day-of-year</title><informalexample><programlisting>(define-values (%return) (date:get-day-of-year self))
  180. </programlisting></informalexample><para>Returns the day of the year, where Jan 1 is the first day of the
  181. year. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to extract day of year from</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-iso8601-week-of-year</title><informalexample><programlisting>(define-values (%return) (date:get-iso8601-week-of-year self))
  182. </programlisting></informalexample><para>Returns the week of the year, where weeks are interpreted according
  183. to ISO 8601.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a valid <type>GDate</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-julian</title><informalexample><programlisting>(define-values (%return) (date:get-julian self))
  184. </programlisting></informalexample><para>Returns the Julian day or &quot;serial number&quot; of the <type>GDate</type>. The
  185. Julian day is simply the number of days since January 1, Year 1; i.e.,
  186. January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
  187. etc. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to extract the Julian day from</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-monday-week-of-year</title><informalexample><programlisting>(define-values (%return) (date:get-monday-week-of-year self))
  188. </programlisting></informalexample><para>Returns the week of the year, where weeks are understood to start on
  189. Monday. If the date is before the first Monday of the year, return 0.
  190. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-month</title><informalexample><programlisting>(define-values (%return) (date:get-month self))
  191. </programlisting></informalexample><para>Returns the month of the year. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to get the month from</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-sunday-week-of-year</title><informalexample><programlisting>(define-values (%return) (date:get-sunday-week-of-year self))
  192. </programlisting></informalexample><para>Returns the week of the year during which this date falls, if
  193. weeks are understood to begin on Sunday. The date must be valid.
  194. Can return 0 if the day is before the first Sunday of the year.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-weekday</title><informalexample><programlisting>(define-values (%return) (date:get-weekday self))
  195. </programlisting></informalexample><para>Returns the day of the week for a <type>GDate</type>. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-year</title><informalexample><programlisting>(define-values (%return) (date:get-year self))
  196. </programlisting></informalexample><para>Returns the year of a <type>GDate</type>. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-first-of-month?</title><informalexample><programlisting>(define-values (%return) (date:is-first-of-month? self))
  197. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the date is on the first of a month.
  198. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to check</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-last-of-month?</title><informalexample><programlisting>(define-values (%return) (date:is-last-of-month? self))
  199. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the date is the last day of the month.
  200. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to check</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>order</title><informalexample><programlisting>(define-values () (date:order self date2))
  201. </programlisting></informalexample><para>Checks if <parameter>date1</parameter> is less than or equal to <parameter>date2</parameter>,
  202. and swap the values if this is not the case.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date1</para></td><td class="parameter_description"><para>the first date</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>date2</para></td><td class="parameter_description"><para>the second date</para><para>Passed as <code>date2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-day</title><informalexample><programlisting>(define-values () (date:set-day self day))
  203. </programlisting></informalexample><para>Sets the day of the month for a <type>GDate</type>. If the resulting
  204. day-month-year triplet is invalid, the date will be invalid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>day</para></td><td class="parameter_description"><para>day to set</para><para>Passed as <code>day</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-dmy</title><informalexample><programlisting>(define-values () (date:set-dmy self day month y))
  205. </programlisting></informalexample><para>Sets the value of a <type>GDate</type> from a day, month, and year.
  206. The day-month-year triplet must be valid; if you aren't
  207. sure it is, call <function>g_date_valid_dmy()</function> to check before you
  208. set it.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>day</para></td><td class="parameter_description"><para>day</para><para>Passed as <code>day</code></para></td></tr><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para>month</para><para>Passed as <code>month</code></para></td></tr><tr><td class="parameter_name"><para>y</para></td><td class="parameter_description"><para>year</para><para>Passed as <code>y</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-julian</title><informalexample><programlisting>(define-values () (date:set-julian self julian-date))
  209. </programlisting></informalexample><para>Sets the value of a <type>GDate</type> from a Julian day number.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>julian_date</para></td><td class="parameter_description"><para>Julian day number (days since January 1, Year 1)</para><para>Passed as <code>julian-date</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-month</title><informalexample><programlisting>(define-values () (date:set-month self month))
  210. </programlisting></informalexample><para>Sets the month of the year for a <type>GDate</type>. If the resulting
  211. day-month-year triplet is invalid, the date will be invalid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para>month to set</para><para>Passed as <code>month</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-parse</title><informalexample><programlisting>(define-values () (date:set-parse self str))
  212. </programlisting></informalexample><para>Parses a user-inputted string <parameter>str</parameter>, and try to figure out what date it
  213. represents, taking the [current locale][setlocale] into account. If the
  214. string is successfully parsed, the date will be valid after the call.
  215. Otherwise, it will be invalid. You should check using <function>g_date_valid()</function>
  216. to see whether the parsing succeeded.
  217. </para>
  218. <para>This function is not appropriate for file formats and the like; it
  219. isn't very precise, and its exact behavior varies with the locale.
  220. It's intended to be a heuristic routine that guesses what the user
  221. means by a given string (and it does work pretty well in that
  222. capacity).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to fill in</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>string to parse</para><para>Passed as <code>str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-time</title><informalexample><programlisting>(define-values () (date:set-time self time-))
  223. </programlisting></informalexample><para>Sets the value of a date from a <type>GTime</type> value.
  224. The time to date conversion is done using the user's current timezone.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type>.</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>time_</para></td><td class="parameter_description"><para><type>GTime</type> value to set.</para><para>Passed as <code>time-</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-time-t</title><informalexample><programlisting>(define-values () (date:set-time-t self timet))
  225. </programlisting></informalexample><para>Sets the value of a date to the date corresponding to a time
  226. specified as a time_t. The time to date conversion is done using
  227. the user's current timezone.
  228. </para>
  229. <para>To set the value of a date to the current day, you could write:
  230. <informalexample><programlisting>
  231. time_t now = time (NULL);
  232. if (now == (time_t) -1)
  233. // handle the error
  234. g_date_set_time_t (date, now);
  235. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>timet</para></td><td class="parameter_description"><para>time_t value to set</para><para>Passed as <code>timet</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-year</title><informalexample><programlisting>(define-values () (date:set-year self year))
  236. </programlisting></informalexample><para>Sets the year for a <type>GDate</type>. If the resulting day-month-year
  237. triplet is invalid, the date will be invalid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>year to set</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>subtract-days</title><informalexample><programlisting>(define-values () (date:subtract-days self n-days))
  238. </programlisting></informalexample><para>Moves a date some number of days into the past.
  239. To move by weeks, just move by weeks*7 days.
  240. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to decrement</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>n_days</para></td><td class="parameter_description"><para>number of days to move</para><para>Passed as <code>n-days</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>subtract-months</title><informalexample><programlisting>(define-values () (date:subtract-months self n-months))
  241. </programlisting></informalexample><para>Moves a date some number of months into the past.
  242. If the current day of the month doesn't exist in
  243. the destination month, the day of the month
  244. may change. The date must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to decrement</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>n_months</para></td><td class="parameter_description"><para>number of months to move</para><para>Passed as <code>n-months</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>subtract-years</title><informalexample><programlisting>(define-values () (date:subtract-years self n-years))
  245. </programlisting></informalexample><para>Moves a date some number of years into the past.
  246. If the current day doesn't exist in the destination
  247. year (i.e. it's February 29 and you move to a non-leap-year)
  248. then the day is changed to February 29. The date
  249. must be valid.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to decrement</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>n_years</para></td><td class="parameter_description"><para>number of years to move</para><para>Passed as <code>n-years</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>to-struct-tm</title><informalexample><programlisting>(define-values () (date:to-struct-tm self tm))
  250. </programlisting></informalexample><para>Fills in the date-related bits of a struct tm using the <parameter>date</parameter> value.
  251. Initializes the non-date parts with something safe but meaningless.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to set the struct tm from</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>tm</para></td><td class="parameter_description"><para>struct tm to fill</para><para>Passed as <code>tm</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>valid?</title><informalexample><programlisting>(define-values (%return) (date:valid? self))
  252. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the <type>GDate</type> represents an existing day. The date must not
  253. contain garbage; it should have been initialized with <function>g_date_clear()</function>
  254. if it wasn't allocated by one of the <function>g_date_new()</function> variants.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>a <type>GDate</type> to check</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:new-julian</title><informalexample><programlisting>(define-values (%return) (date:new-julian julian-day))
  255. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>julian_day</para></td><td class="parameter_description"><para></para><para>Passed as <code>julian-day</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:new-dmy</title><informalexample><programlisting>(define-values (%return) (date:new-dmy day month year))
  256. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>day</para></td><td class="parameter_description"><para></para><para>Passed as <code>day</code></para></td></tr><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para></para><para>Passed as <code>month</code></para></td></tr><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para></para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:new</title><informalexample><programlisting>(define-values (%return) (date:new))
  257. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>date:get-days-in-month</title><informalexample><programlisting>(define-values (%return) (date:get-days-in-month month year))
  258. </programlisting></informalexample><para>Returns the number of days in a month, taking leap
  259. years into account.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para>month</para><para>Passed as <code>month</code></para></td></tr><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>year</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:get-monday-weeks-in-year</title><informalexample><programlisting>(define-values (%return) (date:get-monday-weeks-in-year year))
  260. </programlisting></informalexample><para>Returns the number of weeks in the year, where weeks
  261. are taken to start on Monday. Will be 52 or 53. The
  262. date must be valid. (Years always have 52 7-day periods,
  263. plus 1 or 2 extra days depending on whether it's a leap
  264. year. This function is basically telling you how many
  265. Mondays are in the year, i.e. there are 53 Mondays if
  266. one of the extra days happens to be a Monday.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>a year</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:get-sunday-weeks-in-year</title><informalexample><programlisting>(define-values (%return) (date:get-sunday-weeks-in-year year))
  267. </programlisting></informalexample><para>Returns the number of weeks in the year, where weeks
  268. are taken to start on Sunday. Will be 52 or 53. The
  269. date must be valid. (Years always have 52 7-day periods,
  270. plus 1 or 2 extra days depending on whether it's a leap
  271. year. This function is basically telling you how many
  272. Sundays are in the year, i.e. there are 53 Sundays if
  273. one of the extra days happens to be a Sunday.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>year to count weeks in</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:is-leap-year?</title><informalexample><programlisting>(define-values (%return) (date:is-leap-year? year))
  274. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the year is a leap year.
  275. </para>
  276. <para>For the purposes of this function, leap year is every year
  277. divisible by 4 unless that year is divisible by 100. If it
  278. is divisible by 100 it would be a leap year only if that year
  279. is also divisible by 400.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>year to check</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:strftime</title><informalexample><programlisting>(define-values (%return) (date:strftime s slen format date))
  280. </programlisting></informalexample><para>Generates a printed representation of the date, in a
  281. [locale][setlocale]-specific way.
  282. Works just like the platform's C library <function>strftime()</function> function,
  283. but only accepts date-related formats; time-related formats
  284. give undefined results. Date must be valid. Unlike <function>strftime()</function>
  285. (which uses the locale encoding), works on a UTF-8 format
  286. string and stores a UTF-8 result.
  287. </para>
  288. <para>This function does not provide any conversion specifiers in
  289. addition to those implemented by the platform's C library.
  290. For example, don't expect that using <function>g_date_strftime()</function> would
  291. make the \%F provided by the C99 <function>strftime()</function> work on Windows
  292. where the C library only complies to C89.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>s</para></td><td class="parameter_description"><para>destination buffer</para><para>Passed as <code>s</code></para></td></tr><tr><td class="parameter_name"><para>slen</para></td><td class="parameter_description"><para>buffer size</para><para>Passed as <code>slen</code></para></td></tr><tr><td class="parameter_name"><para>format</para></td><td class="parameter_description"><para>format string</para><para>Passed as <code>format</code></para></td></tr><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>valid <type>GDate</type></para><para>Passed as <code>date</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:valid-day?</title><informalexample><programlisting>(define-values (%return) (date:valid-day? day))
  293. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the day of the month is valid (a day is valid if it's
  294. between 1 and 31 inclusive).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>day</para></td><td class="parameter_description"><para>day to check</para><para>Passed as <code>day</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:valid-dmy?</title><informalexample><programlisting>(define-values (%return) (date:valid-dmy? day month year))
  295. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the day-month-year triplet forms a valid, existing day
  296. in the range of days <type>GDate</type> understands (Year 1 or later, no more than
  297. a few thousand years in the future).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>day</para></td><td class="parameter_description"><para>day</para><para>Passed as <code>day</code></para></td></tr><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para>month</para><para>Passed as <code>month</code></para></td></tr><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>year</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:valid-julian?</title><informalexample><programlisting>(define-values (%return) (date:valid-julian? julian-date))
  298. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the Julian day is valid. Anything greater than zero
  299. is basically a valid Julian, though there is a 32-bit limit.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>julian_date</para></td><td class="parameter_description"><para>Julian day to check</para><para>Passed as <code>julian-date</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:valid-month?</title><informalexample><programlisting>(define-values (%return) (date:valid-month? month))
  300. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the month value is valid. The 12 <type>GDateMonth</type>
  301. enumeration values are the only valid months.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para>month</para><para>Passed as <code>month</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:valid-weekday?</title><informalexample><programlisting>(define-values (%return) (date:valid-weekday? weekday))
  302. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the weekday is valid. The seven <type>GDateWeekday</type> enumeration
  303. values are the only valid weekdays.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>weekday</para></td><td class="parameter_description"><para>weekday</para><para>Passed as <code>weekday</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date:valid-year?</title><informalexample><programlisting>(define-values (%return) (date:valid-year? year))
  304. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the year is valid. Any year greater than 0 is valid,
  305. though there is a 16-bit limit to what <type>GDate</type> will understand.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>year</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibDateDMY&gt;</refname></refnamediv><refsect1><title>Description</title><para>This enumeration isn't used in the API, but may be useful if you need
  306. to mark a number as a day, month, or year.</para></refsect1><refsect1><title>Members</title><refsect2><title>day</title><remark>alias <code>G_DATE_DAY</code></remark><para>a day</para></refsect2><refsect2><title>month</title><remark>alias <code>G_DATE_MONTH</code></remark><para>a month</para></refsect2><refsect2><title>year</title><remark>alias <code>G_DATE_YEAR</code></remark><para>a year</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibDateMonth&gt;</refname></refnamediv><refsect1><title>Description</title><para>Enumeration representing a month; values are <type>G_DATE_JANUARY</type>,
  307. <type>G_DATE_FEBRUARY</type>, etc. <type>G_DATE_BAD_MONTH</type> is the invalid value.</para></refsect1><refsect1><title>Members</title><refsect2><title>bad-month</title><remark>alias <code>G_DATE_BAD_MONTH</code></remark><para>invalid value</para></refsect2><refsect2><title>january</title><remark>alias <code>G_DATE_JANUARY</code></remark><para>January</para></refsect2><refsect2><title>february</title><remark>alias <code>G_DATE_FEBRUARY</code></remark><para>February</para></refsect2><refsect2><title>march</title><remark>alias <code>G_DATE_MARCH</code></remark><para>March</para></refsect2><refsect2><title>april</title><remark>alias <code>G_DATE_APRIL</code></remark><para>April</para></refsect2><refsect2><title>may</title><remark>alias <code>G_DATE_MAY</code></remark><para>May</para></refsect2><refsect2><title>june</title><remark>alias <code>G_DATE_JUNE</code></remark><para>June</para></refsect2><refsect2><title>july</title><remark>alias <code>G_DATE_JULY</code></remark><para>July</para></refsect2><refsect2><title>august</title><remark>alias <code>G_DATE_AUGUST</code></remark><para>August</para></refsect2><refsect2><title>september</title><remark>alias <code>G_DATE_SEPTEMBER</code></remark><para>September</para></refsect2><refsect2><title>october</title><remark>alias <code>G_DATE_OCTOBER</code></remark><para>October</para></refsect2><refsect2><title>november</title><remark>alias <code>G_DATE_NOVEMBER</code></remark><para>November</para></refsect2><refsect2><title>december</title><remark>alias <code>G_DATE_DECEMBER</code></remark><para>December</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GDateTime&gt;</refname></refnamediv><refsect1><title>Description</title><para>An opaque structure that represents a date and time, including a time zone.</para></refsect1><refsect1><title>Functions</title><refsect2><title>add</title><informalexample><programlisting>(define-values (%return) (date-time:add self timespan))
  308. </programlisting></informalexample><para>Creates a copy of <parameter>datetime</parameter> and adds the specified timespan to the copy.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>timespan</para></td><td class="parameter_description"><para>a <type>GTimeSpan</type></para><para>Passed as <code>timespan</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-days</title><informalexample><programlisting>(define-values (%return) (date-time:add-days self days))
  309. </programlisting></informalexample><para>Creates a copy of <parameter>datetime</parameter> and adds the specified number of days to the
  310. copy. Add negative values to subtract days.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>days</para></td><td class="parameter_description"><para>the number of days</para><para>Passed as <code>days</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-full</title><informalexample><programlisting>(define-values
  311. (%return)
  312. (date-time:add-full self years months days hours minutes seconds))
  313. </programlisting></informalexample><para>Creates a new <type>GDateTime</type> adding the specified values to the current date and
  314. time in <parameter>datetime</parameter>. Add negative values to subtract.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>years</para></td><td class="parameter_description"><para>the number of years to add</para><para>Passed as <code>years</code></para></td></tr><tr><td class="parameter_name"><para>months</para></td><td class="parameter_description"><para>the number of months to add</para><para>Passed as <code>months</code></para></td></tr><tr><td class="parameter_name"><para>days</para></td><td class="parameter_description"><para>the number of days to add</para><para>Passed as <code>days</code></para></td></tr><tr><td class="parameter_name"><para>hours</para></td><td class="parameter_description"><para>the number of hours to add</para><para>Passed as <code>hours</code></para></td></tr><tr><td class="parameter_name"><para>minutes</para></td><td class="parameter_description"><para>the number of minutes to add</para><para>Passed as <code>minutes</code></para></td></tr><tr><td class="parameter_name"><para>seconds</para></td><td class="parameter_description"><para>the number of seconds to add</para><para>Passed as <code>seconds</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-hours</title><informalexample><programlisting>(define-values (%return) (date-time:add-hours self hours))
  315. </programlisting></informalexample><para>Creates a copy of <parameter>datetime</parameter> and adds the specified number of hours.
  316. Add negative values to subtract hours.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>hours</para></td><td class="parameter_description"><para>the number of hours to add</para><para>Passed as <code>hours</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-minutes</title><informalexample><programlisting>(define-values (%return) (date-time:add-minutes self minutes))
  317. </programlisting></informalexample><para>Creates a copy of <parameter>datetime</parameter> adding the specified number of minutes.
  318. Add negative values to subtract minutes.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>minutes</para></td><td class="parameter_description"><para>the number of minutes to add</para><para>Passed as <code>minutes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-months</title><informalexample><programlisting>(define-values (%return) (date-time:add-months self months))
  319. </programlisting></informalexample><para>Creates a copy of <parameter>datetime</parameter> and adds the specified number of months to the
  320. copy. Add negative values to subtract months.
  321. </para>
  322. <para>The day of the month of the resulting <type>GDateTime</type> is clamped to the number
  323. of days in the updated calendar month. For example, if adding 1 month to
  324. 31st January 2018, the result would be 28th February 2018. In 2020 (a leap
  325. year), the result would be 29th February.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>months</para></td><td class="parameter_description"><para>the number of months</para><para>Passed as <code>months</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-seconds</title><informalexample><programlisting>(define-values (%return) (date-time:add-seconds self seconds))
  326. </programlisting></informalexample><para>Creates a copy of <parameter>datetime</parameter> and adds the specified number of seconds.
  327. Add negative values to subtract seconds.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>seconds</para></td><td class="parameter_description"><para>the number of seconds to add</para><para>Passed as <code>seconds</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-weeks</title><informalexample><programlisting>(define-values (%return) (date-time:add-weeks self weeks))
  328. </programlisting></informalexample><para>Creates a copy of <parameter>datetime</parameter> and adds the specified number of weeks to the
  329. copy. Add negative values to subtract weeks.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>weeks</para></td><td class="parameter_description"><para>the number of weeks</para><para>Passed as <code>weeks</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-years</title><informalexample><programlisting>(define-values (%return) (date-time:add-years self years))
  330. </programlisting></informalexample><para>Creates a copy of <parameter>datetime</parameter> and adds the specified number of years to the
  331. copy. Add negative values to subtract years.
  332. </para>
  333. <para>As with <function>g_date_time_add_months()</function>, if the resulting date would be 29th
  334. February on a non-leap year, the day will be clamped to 28th February.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>years</para></td><td class="parameter_description"><para>the number of years</para><para>Passed as <code>years</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>difference</title><informalexample><programlisting>(define-values (%return) (date-time:difference self begin))
  335. </programlisting></informalexample><para>Calculates the difference in time between <parameter>end</parameter> and <parameter>begin</parameter>. The
  336. <type>GTimeSpan</type> that is returned is effectively <parameter>end</parameter> - <parameter>begin</parameter> (ie:
  337. positive if the first parameter is larger).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>end</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>begin</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>begin</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>format</title><informalexample><programlisting>(define-values (%return) (date-time:format self format))
  338. </programlisting></informalexample><para>Creates a newly allocated string representing the requested <parameter>format</parameter>.
  339. </para>
  340. <para>The format strings understood by this function are a subset of the
  341. <function>strftime()</function> format language as specified by C99. The \%D, \%U and \%W
  342. conversions are not supported, nor is the 'E' modifier. The GNU
  343. extensions \%k, \%l, \%s and \%P are supported, however, as are the
  344. '0', '_' and '-' modifiers. The Python extension \%f is also supported.
  345. </para>
  346. <para>In contrast to <function>strftime()</function>, this function always produces a UTF-8
  347. string, regardless of the current locale. Note that the rendering of
  348. many formats is locale-dependent and may not match the <function>strftime()</function>
  349. output exactly.
  350. </para>
  351. <para>The following format specifiers are supported:
  352. </para>
  353. <para>- \%a: the abbreviated weekday name according to the current locale
  354. - \%A: the full weekday name according to the current locale
  355. - \%b: the abbreviated month name according to the current locale
  356. - \%B: the full month name according to the current locale
  357. - \%c: the preferred date and time representation for the current locale
  358. - \%C: the century number (year/100) as a 2-digit integer (00-99)
  359. - \%d: the day of the month as a decimal number (range 01 to 31)
  360. - \%e: the day of the month as a decimal number (range 1 to 31)
  361. - \%F: equivalent to <code>%Y-%m-%d</code> (the ISO 8601 date format)
  362. - \%g: the last two digits of the ISO 8601 week-based year as a
  363. decimal number (00-99). This works well with \%V and \%u.
  364. - \%G: the ISO 8601 week-based year as a decimal number. This works
  365. well with \%V and \%u.
  366. - \%h: equivalent to \%b
  367. - \%H: the hour as a decimal number using a 24-hour clock (range 00 to 23)
  368. - \%I: the hour as a decimal number using a 12-hour clock (range 01 to 12)
  369. - \%j: the day of the year as a decimal number (range 001 to 366)
  370. - \%k: the hour (24-hour clock) as a decimal number (range 0 to 23);
  371. single digits are preceded by a blank
  372. - \%l: the hour (12-hour clock) as a decimal number (range 1 to 12);
  373. single digits are preceded by a blank
  374. - \%m: the month as a decimal number (range 01 to 12)
  375. - \%M: the minute as a decimal number (range 00 to 59)
  376. - \%f: the microsecond as a decimal number (range 000000 to 999999)
  377. - \%p: either &quot;AM&quot; or &quot;PM&quot; according to the given time value, or the
  378. corresponding strings for the current locale. Noon is treated as
  379. &quot;PM&quot; and midnight as &quot;AM&quot;. Use of this format specifier is discouraged, as
  380. many locales have no concept of AM/PM formatting. Use \%c or \%X instead.
  381. - \%P: like \%p but lowercase: &quot;am&quot; or &quot;pm&quot; or a corresponding string for
  382. the current locale. Use of this format specifier is discouraged, as
  383. many locales have no concept of AM/PM formatting. Use \%c or \%X instead.
  384. - \%r: the time in a.m. or p.m. notation. Use of this format specifier is
  385. discouraged, as many locales have no concept of AM/PM formatting. Use \%c
  386. or \%X instead.
  387. - \%R: the time in 24-hour notation (\%H:\%M)
  388. - \%s: the number of seconds since the Epoch, that is, since 1970-01-01
  389. 00:00:00 UTC
  390. - \%S: the second as a decimal number (range 00 to 60)
  391. - \%t: a tab character
  392. - \%T: the time in 24-hour notation with seconds (\%H:\%M:\%S)
  393. - \%u: the ISO 8601 standard day of the week as a decimal, range 1 to 7,
  394. Monday being 1. This works well with \%G and \%V.
  395. - \%V: the ISO 8601 standard week number of the current year as a decimal
  396. number, range 01 to 53, where week 1 is the first week that has at
  397. least 4 days in the new year. See <function>g_date_time_get_week_of_year()</function>.
  398. This works well with \%G and \%u.
  399. - \%w: the day of the week as a decimal, range 0 to 6, Sunday being 0.
  400. This is not the ISO 8601 standard format -- use \%u instead.
  401. - \%x: the preferred date representation for the current locale without
  402. the time
  403. - \%X: the preferred time representation for the current locale without
  404. the date
  405. - \%y: the year as a decimal number without the century
  406. - \%Y: the year as a decimal number including the century
  407. - \%z: the time zone as an offset from UTC (+hhmm)
  408. - \%:z: the time zone as an offset from UTC (+hh:mm).
  409. This is a gnulib <function>strftime()</function> extension. Since: 2.38
  410. - \%::z: the time zone as an offset from UTC (+hh:mm:ss). This is a
  411. gnulib <function>strftime()</function> extension. Since: 2.38
  412. - \%:::z: the time zone as an offset from UTC, with : to necessary
  413. precision (e.g., -04, +05:30). This is a gnulib <function>strftime()</function> extension. Since: 2.38
  414. - \%Z: the time zone or name or abbreviation
  415. - \%\%: a literal \% character
  416. </para>
  417. <para>Some conversion specifications can be modified by preceding the
  418. conversion specifier by one or more modifier characters. The
  419. following modifiers are supported for many of the numeric
  420. conversions:
  421. </para>
  422. <para>- O: Use alternative numeric symbols, if the current locale supports those.
  423. - _: Pad a numeric result with spaces. This overrides the default padding
  424. for the specifier.
  425. - -: Do not pad a numeric result. This overrides the default padding
  426. for the specifier.
  427. - 0: Pad a numeric result with zeros. This overrides the default padding
  428. for the specifier.
  429. </para>
  430. <para>Additionally, when O is used with B, b, or h, it produces the alternative
  431. form of a month name. The alternative form should be used when the month
  432. name is used without a day number (e.g., standalone). It is required in
  433. some languages (Baltic, Slavic, Greek, and more) due to their grammatical
  434. rules. For other languages there is no difference. \%OB is a GNU and BSD
  435. <function>strftime()</function> extension expected to be added to the future POSIX specification,
  436. \%Ob and \%Oh are GNU <function>strftime()</function> extensions. Since: 2.56</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>A <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>format</para></td><td class="parameter_description"><para>a valid UTF-8 string, containing the format for the
  437. <type>GDateTime</type></para><para>Passed as <code>format</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>format-iso8601</title><informalexample><programlisting>(define-values (%return) (date-time:format-iso8601 self))
  438. </programlisting></informalexample><para>Format <parameter>datetime</parameter> in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601),
  439. including the date, time and time zone, and return that as a UTF-8 encoded
  440. string.
  441. </para>
  442. <para>Since GLib 2.66, this will output to sub-second precision if needed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>A <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-day-of-month</title><informalexample><programlisting>(define-values (%return) (date-time:get-day-of-month self))
  443. </programlisting></informalexample><para>Retrieves the day of the month represented by <parameter>datetime</parameter> in the gregorian
  444. calendar.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-day-of-week</title><informalexample><programlisting>(define-values (%return) (date-time:get-day-of-week self))
  445. </programlisting></informalexample><para>Retrieves the ISO 8601 day of the week on which <parameter>datetime</parameter> falls (1 is
  446. Monday, 2 is Tuesday... 7 is Sunday).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-day-of-year</title><informalexample><programlisting>(define-values (%return) (date-time:get-day-of-year self))
  447. </programlisting></informalexample><para>Retrieves the day of the year represented by <parameter>datetime</parameter> in the Gregorian
  448. calendar.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-hour</title><informalexample><programlisting>(define-values (%return) (date-time:get-hour self))
  449. </programlisting></informalexample><para>Retrieves the hour of the day represented by <parameter>datetime</parameter></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-microsecond</title><informalexample><programlisting>(define-values (%return) (date-time:get-microsecond self))
  450. </programlisting></informalexample><para>Retrieves the microsecond of the date represented by <parameter>datetime</parameter></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-minute</title><informalexample><programlisting>(define-values (%return) (date-time:get-minute self))
  451. </programlisting></informalexample><para>Retrieves the minute of the hour represented by <parameter>datetime</parameter></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-month</title><informalexample><programlisting>(define-values (%return) (date-time:get-month self))
  452. </programlisting></informalexample><para>Retrieves the month of the year represented by <parameter>datetime</parameter> in the Gregorian
  453. calendar.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-second</title><informalexample><programlisting>(define-values (%return) (date-time:get-second self))
  454. </programlisting></informalexample><para>Retrieves the second of the minute represented by <parameter>datetime</parameter></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-seconds</title><informalexample><programlisting>(define-values (%return) (date-time:get-seconds self))
  455. </programlisting></informalexample><para>Retrieves the number of seconds since the start of the last minute,
  456. including the fractional part.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-timezone</title><informalexample><programlisting>(define-values (%return) (date-time:get-timezone self))
  457. </programlisting></informalexample><para>Get the time zone for this <parameter>datetime</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-timezone-abbreviation</title><informalexample><programlisting>(define-values (%return) (date-time:get-timezone-abbreviation self))
  458. </programlisting></informalexample><para>Determines the time zone abbreviation to be used at the time and in
  459. the time zone of <parameter>datetime</parameter>.
  460. </para>
  461. <para>For example, in Toronto this is currently &quot;EST&quot; during the winter
  462. months and &quot;EDT&quot; during the summer months when daylight savings
  463. time is in effect.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-utc-offset</title><informalexample><programlisting>(define-values (%return) (date-time:get-utc-offset self))
  464. </programlisting></informalexample><para>Determines the offset to UTC in effect at the time and in the time
  465. zone of <parameter>datetime</parameter>.
  466. </para>
  467. <para>The offset is the number of microseconds that you add to UTC time to
  468. arrive at local time for the time zone (ie: negative numbers for time
  469. zones west of GMT, positive numbers for east).
  470. </para>
  471. <para>If <parameter>datetime</parameter> represents UTC time, then the offset is always zero.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-week-numbering-year</title><informalexample><programlisting>(define-values (%return) (date-time:get-week-numbering-year self))
  472. </programlisting></informalexample><para>Returns the ISO 8601 week-numbering year in which the week containing
  473. <parameter>datetime</parameter> falls.
  474. </para>
  475. <para>This function, taken together with <function>g_date_time_get_week_of_year()</function> and
  476. <function>g_date_time_get_day_of_week()</function> can be used to determine the full ISO
  477. week date on which <parameter>datetime</parameter> falls.
  478. </para>
  479. <para>This is usually equal to the normal Gregorian year (as returned by
  480. <function>g_date_time_get_year()</function>), except as detailed below:
  481. </para>
  482. <para>For Thursday, the week-numbering year is always equal to the usual
  483. calendar year. For other days, the number is such that every day
  484. within a complete week (Monday to Sunday) is contained within the
  485. same week-numbering year.
  486. </para>
  487. <para>For Monday, Tuesday and Wednesday occurring near the end of the year,
  488. this may mean that the week-numbering year is one greater than the
  489. calendar year (so that these days have the same week-numbering year
  490. as the Thursday occurring early in the next year).
  491. </para>
  492. <para>For Friday, Saturday and Sunday occurring near the start of the year,
  493. this may mean that the week-numbering year is one less than the
  494. calendar year (so that these days have the same week-numbering year
  495. as the Thursday occurring late in the previous year).
  496. </para>
  497. <para>An equivalent description is that the week-numbering year is equal to
  498. the calendar year containing the majority of the days in the current
  499. week (Monday to Sunday).
  500. </para>
  501. <para>Note that January 1 0001 in the proleptic Gregorian calendar is a
  502. Monday, so this function never returns 0.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-week-of-year</title><informalexample><programlisting>(define-values (%return) (date-time:get-week-of-year self))
  503. </programlisting></informalexample><para>Returns the ISO 8601 week number for the week containing <parameter>datetime</parameter>.
  504. The ISO 8601 week number is the same for every day of the week (from
  505. Moday through Sunday). That can produce some unusual results
  506. (described below).
  507. </para>
  508. <para>The first week of the year is week 1. This is the week that contains
  509. the first Thursday of the year. Equivalently, this is the first week
  510. that has more than 4 of its days falling within the calendar year.
  511. </para>
  512. <para>The value 0 is never returned by this function. Days contained
  513. within a year but occurring before the first ISO 8601 week of that
  514. year are considered as being contained in the last week of the
  515. previous year. Similarly, the final days of a calendar year may be
  516. considered as being part of the first ISO 8601 week of the next year
  517. if 4 or more days of that week are contained within the new year.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-year</title><informalexample><programlisting>(define-values (%return) (date-time:get-year self))
  518. </programlisting></informalexample><para>Retrieves the year represented by <parameter>datetime</parameter> in the Gregorian calendar.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>A <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-ymd</title><informalexample><programlisting>(define-values (year month day) (date-time:get-ymd self))
  519. </programlisting></informalexample><para>Retrieves the Gregorian day, month, and year of a given <type>GDateTime</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type>.</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>the return location for the gregorian year, or <constant>NULL</constant>.</para><para>Passed as <code>year</code></para></td></tr><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para>the return location for the month of the year, or <constant>NULL</constant>.</para><para>Passed as <code>month</code></para></td></tr><tr><td class="parameter_name"><para>day</para></td><td class="parameter_description"><para>the return location for the day of the month, or <constant>NULL</constant>.</para><para>Passed as <code>day</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-daylight-savings?</title><informalexample><programlisting>(define-values (%return) (date-time:is-daylight-savings? self))
  520. </programlisting></informalexample><para>Determines if daylight savings time is in effect at the time and in
  521. the time zone of <parameter>datetime</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (date-time:ref self))
  522. </programlisting></informalexample><para>Atomically increments the reference count of <parameter>datetime</parameter> by one.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>to-local</title><informalexample><programlisting>(define-values (%return) (date-time:to-local self))
  523. </programlisting></informalexample><para>Creates a new <type>GDateTime</type> corresponding to the same instant in time as
  524. <parameter>datetime</parameter>, but in the local time zone.
  525. </para>
  526. <para>This call is equivalent to calling <function>g_date_time_to_timezone()</function> with the
  527. time zone returned by <function>g_time_zone_new_local()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>to-timezone</title><informalexample><programlisting>(define-values (%return) (date-time:to-timezone self tz))
  528. </programlisting></informalexample><para>Create a new <type>GDateTime</type> corresponding to the same instant in time as
  529. <parameter>datetime</parameter>, but in the time zone <parameter>tz</parameter>.
  530. </para>
  531. <para>This call can fail in the case that the time goes out of bounds. For
  532. example, converting 0001-01-01 00:00:00 UTC to a time zone west of
  533. Greenwich will fail (due to the year 0 being out of range).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>tz</para></td><td class="parameter_description"><para>the new <type>GTimeZone</type></para><para>Passed as <code>tz</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>to-unix</title><informalexample><programlisting>(define-values (%return) (date-time:to-unix self))
  534. </programlisting></informalexample><para>Gives the Unix time corresponding to <parameter>datetime</parameter>, rounding down to the
  535. nearest second.
  536. </para>
  537. <para>Unix time is the number of seconds that have elapsed since 1970-01-01
  538. 00:00:00 UTC, regardless of the time zone associated with <parameter>datetime</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>to-utc</title><informalexample><programlisting>(define-values (%return) (date-time:to-utc self))
  539. </programlisting></informalexample><para>Creates a new <type>GDateTime</type> corresponding to the same instant in time as
  540. <parameter>datetime</parameter>, but in UTC.
  541. </para>
  542. <para>This call is equivalent to calling <function>g_date_time_to_timezone()</function> with the
  543. time zone returned by <function>g_time_zone_new_utc()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (date-time:unref self))
  544. </programlisting></informalexample><para>Atomically decrements the reference count of <parameter>datetime</parameter> by one.
  545. </para>
  546. <para>When the reference count reaches zero, the resources allocated by
  547. <parameter>datetime</parameter> are freed</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time:new-utc</title><informalexample><programlisting>(define-values
  548. (%return)
  549. (date-time:new-utc year month day hour minute seconds))
  550. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para></para><para>Passed as <code>year</code></para></td></tr><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para></para><para>Passed as <code>month</code></para></td></tr><tr><td class="parameter_name"><para>day</para></td><td class="parameter_description"><para></para><para>Passed as <code>day</code></para></td></tr><tr><td class="parameter_name"><para>hour</para></td><td class="parameter_description"><para></para><para>Passed as <code>hour</code></para></td></tr><tr><td class="parameter_name"><para>minute</para></td><td class="parameter_description"><para></para><para>Passed as <code>minute</code></para></td></tr><tr><td class="parameter_name"><para>seconds</para></td><td class="parameter_description"><para></para><para>Passed as <code>seconds</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time:new-now-utc</title><informalexample><programlisting>(define-values (%return) (date-time:new-now-utc))
  551. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>date-time:new-now-local</title><informalexample><programlisting>(define-values (%return) (date-time:new-now-local))
  552. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>date-time:new-now</title><informalexample><programlisting>(define-values (%return) (date-time:new-now tz))
  553. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tz</para></td><td class="parameter_description"><para></para><para>Passed as <code>tz</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time:new-local</title><informalexample><programlisting>(define-values
  554. (%return)
  555. (date-time:new-local year month day hour minute seconds))
  556. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para></para><para>Passed as <code>year</code></para></td></tr><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para></para><para>Passed as <code>month</code></para></td></tr><tr><td class="parameter_name"><para>day</para></td><td class="parameter_description"><para></para><para>Passed as <code>day</code></para></td></tr><tr><td class="parameter_name"><para>hour</para></td><td class="parameter_description"><para></para><para>Passed as <code>hour</code></para></td></tr><tr><td class="parameter_name"><para>minute</para></td><td class="parameter_description"><para></para><para>Passed as <code>minute</code></para></td></tr><tr><td class="parameter_name"><para>seconds</para></td><td class="parameter_description"><para></para><para>Passed as <code>seconds</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time:new-from-unix-utc</title><informalexample><programlisting>(define-values (%return) (date-time:new-from-unix-utc t))
  557. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>t</para></td><td class="parameter_description"><para></para><para>Passed as <code>t</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time:new-from-unix-local</title><informalexample><programlisting>(define-values (%return) (date-time:new-from-unix-local t))
  558. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>t</para></td><td class="parameter_description"><para></para><para>Passed as <code>t</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time:new-from-iso8601</title><informalexample><programlisting>(define-values (%return) (date-time:new-from-iso8601 text default-tz))
  559. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>text</para></td><td class="parameter_description"><para></para><para>Passed as <code>text</code></para></td></tr><tr><td class="parameter_name"><para>default_tz</para></td><td class="parameter_description"><para></para><para>Passed as <code>default-tz</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time:new</title><informalexample><programlisting>(define-values
  560. (%return)
  561. (date-time:new tz year month day hour minute seconds))
  562. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tz</para></td><td class="parameter_description"><para></para><para>Passed as <code>tz</code></para></td></tr><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para></para><para>Passed as <code>year</code></para></td></tr><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para></para><para>Passed as <code>month</code></para></td></tr><tr><td class="parameter_name"><para>day</para></td><td class="parameter_description"><para></para><para>Passed as <code>day</code></para></td></tr><tr><td class="parameter_name"><para>hour</para></td><td class="parameter_description"><para></para><para>Passed as <code>hour</code></para></td></tr><tr><td class="parameter_name"><para>minute</para></td><td class="parameter_description"><para></para><para>Passed as <code>minute</code></para></td></tr><tr><td class="parameter_name"><para>seconds</para></td><td class="parameter_description"><para></para><para>Passed as <code>seconds</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time:compare</title><informalexample><programlisting>(define-values (%return) (date-time:compare dt1 dt2))
  563. </programlisting></informalexample><para>A comparison function for <type>GDateTimes</type> that is suitable
  564. as a <type>GCompareFunc</type>. Both <type>GDateTimes</type> must be non-<constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dt1</para></td><td class="parameter_description"><para>first <type>GDateTime</type> to compare</para><para>Passed as <code>dt1</code></para></td></tr><tr><td class="parameter_name"><para>dt2</para></td><td class="parameter_description"><para>second <type>GDateTime</type> to compare</para><para>Passed as <code>dt2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time:equal?</title><informalexample><programlisting>(define-values (%return) (date-time:equal? dt1 dt2))
  565. </programlisting></informalexample><para>Checks to see if <parameter>dt1</parameter> and <parameter>dt2</parameter> are equal.
  566. </para>
  567. <para>Equal here means that they represent the same moment after converting
  568. them to the same time zone.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dt1</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>dt1</code></para></td></tr><tr><td class="parameter_name"><para>dt2</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>dt2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time:hash</title><informalexample><programlisting>(define-values (%return) (date-time:hash datetime))
  569. </programlisting></informalexample><para>Hashes <parameter>datetime</parameter> into a <type>guint</type>, suitable for use within <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>datetime</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibDateWeekday&gt;</refname></refnamediv><refsect1><title>Description</title><para>Enumeration representing a day of the week; <type>G_DATE_MONDAY</type>,
  570. <type>G_DATE_TUESDAY</type>, etc. <type>G_DATE_BAD_WEEKDAY</type> is an invalid weekday.</para></refsect1><refsect1><title>Members</title><refsect2><title>bad-weekday</title><remark>alias <code>G_DATE_BAD_WEEKDAY</code></remark><para>invalid value</para></refsect2><refsect2><title>monday</title><remark>alias <code>G_DATE_MONDAY</code></remark><para>Monday</para></refsect2><refsect2><title>tuesday</title><remark>alias <code>G_DATE_TUESDAY</code></remark><para>Tuesday</para></refsect2><refsect2><title>wednesday</title><remark>alias <code>G_DATE_WEDNESDAY</code></remark><para>Wednesday</para></refsect2><refsect2><title>thursday</title><remark>alias <code>G_DATE_THURSDAY</code></remark><para>Thursday</para></refsect2><refsect2><title>friday</title><remark>alias <code>G_DATE_FRIDAY</code></remark><para>Friday</para></refsect2><refsect2><title>saturday</title><remark>alias <code>G_DATE_SATURDAY</code></remark><para>Saturday</para></refsect2><refsect2><title>sunday</title><remark>alias <code>G_DATE_SUNDAY</code></remark><para>Sunday</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GError&gt;</refname></refnamediv><refsect1><title>Description</title><para>The <code>GError</code> structure contains information about
  571. an error that has occurred.</para></refsect1><refsect1><title>Functions</title><refsect2><title>copy</title><informalexample><programlisting>(define-values (%return) (error:copy self))
  572. </programlisting></informalexample><para>Makes a copy of <parameter>error</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>error</para></td><td class="parameter_description"><para>a <type>GError</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>free</title><informalexample><programlisting>(define-values () (error:free self))
  573. </programlisting></informalexample><para>Frees a <type>GError</type> and associated resources.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>error</para></td><td class="parameter_description"><para>a <type>GError</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>matches?</title><informalexample><programlisting>(define-values (%return) (error:matches? self domain code))
  574. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if <parameter>error</parameter> matches <parameter>domain</parameter> and <parameter>code</parameter>, <constant>FALSE</constant>
  575. otherwise. In particular, when <parameter>error</parameter> is <constant>NULL</constant>, <constant>FALSE</constant> will
  576. be returned.
  577. </para>
  578. <para>If <parameter>domain</parameter> contains a <code>FAILED</code> (or otherwise generic) error code,
  579. you should generally not check for it explicitly, but should
  580. instead treat any not-explicitly-recognized error code as being
  581. equivalent to the <code>FAILED</code> code. This way, if the domain is
  582. extended in the future to provide a more specific error code for
  583. a certain case, your code will still work.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>error</para></td><td class="parameter_description"><para>a <type>GError</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para>an error domain</para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>code</para></td><td class="parameter_description"><para>an error code</para><para>Passed as <code>code</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>error:new-literal</title><informalexample><programlisting>(define-values (%return) (error:new-literal domain code message))
  584. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>code</para></td><td class="parameter_description"><para></para><para>Passed as <code>code</code></para></td></tr><tr><td class="parameter_name"><para>message</para></td><td class="parameter_description"><para></para><para>Passed as <code>message</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibErrorType&gt;</refname></refnamediv><refsect1><title>Description</title><para>The possible errors, used in the <parameter>v_error</parameter> field
  585. of <type>GTokenValue</type>, when the token is a <constant>G_TOKEN_ERROR</constant>.</para></refsect1><refsect1><title>Members</title><refsect2><title>unknown</title><remark>alias <code>G_ERR_UNKNOWN</code></remark><para>unknown error</para></refsect2><refsect2><title>unexp-eof</title><remark>alias <code>G_ERR_UNEXP_EOF</code></remark><para>unexpected end of file</para></refsect2><refsect2><title>unexp-eof-in-string</title><remark>alias <code>G_ERR_UNEXP_EOF_IN_STRING</code></remark><para>unterminated string constant</para></refsect2><refsect2><title>unexp-eof-in-comment</title><remark>alias <code>G_ERR_UNEXP_EOF_IN_COMMENT</code></remark><para>unterminated comment</para></refsect2><refsect2><title>non-digit-in-const</title><remark>alias <code>G_ERR_NON_DIGIT_IN_CONST</code></remark><para>non-digit character in a number</para></refsect2><refsect2><title>digit-radix</title><remark>alias <code>G_ERR_DIGIT_RADIX</code></remark><para>digit beyond radix in a number</para></refsect2><refsect2><title>float-radix</title><remark>alias <code>G_ERR_FLOAT_RADIX</code></remark><para>non-decimal floating point number</para></refsect2><refsect2><title>float-malformed</title><remark>alias <code>G_ERR_FLOAT_MALFORMED</code></remark><para>malformed floating point number</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibFileError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Values corresponding to <parameter>errno</parameter> codes returned from file operations
  586. on UNIX. Unlike <parameter>errno</parameter> codes, GFileError values are available on
  587. all systems, even Windows. The exact meaning of each code depends
  588. on what sort of file operation you were performing; the UNIX
  589. documentation gives more details. The following error code descriptions
  590. come from the GNU C Library manual, and are under the copyright
  591. of that manual.
  592. </para>
  593. <para>It's not very portable to make detailed assumptions about exactly
  594. which errors will be returned from a given operation. Some errors
  595. don't occur on some systems, etc., sometimes there are subtle
  596. differences in when a system will report a given error, etc.</para></refsect1><refsect1><title>Members</title><refsect2><title>exist</title><remark>alias <code>G_FILE_ERROR_EXIST</code></remark><para>Operation not permitted; only the owner of
  597. the file (or other resource) or processes with special privileges
  598. can perform the operation.</para></refsect2><refsect2><title>isdir</title><remark>alias <code>G_FILE_ERROR_ISDIR</code></remark><para>File is a directory; you cannot open a directory
  599. for writing, or create or remove hard links to it.</para></refsect2><refsect2><title>acces</title><remark>alias <code>G_FILE_ERROR_ACCES</code></remark><para>Permission denied; the file permissions do not
  600. allow the attempted operation.</para></refsect2><refsect2><title>nametoolong</title><remark>alias <code>G_FILE_ERROR_NAMETOOLONG</code></remark><para>Filename too long.</para></refsect2><refsect2><title>noent</title><remark>alias <code>G_FILE_ERROR_NOENT</code></remark><para>No such file or directory. This is a &quot;file
  601. doesn't exist&quot; error for ordinary files that are referenced in
  602. contexts where they are expected to already exist.</para></refsect2><refsect2><title>notdir</title><remark>alias <code>G_FILE_ERROR_NOTDIR</code></remark><para>A file that isn't a directory was specified when
  603. a directory is required.</para></refsect2><refsect2><title>nxio</title><remark>alias <code>G_FILE_ERROR_NXIO</code></remark><para>No such device or address. The system tried to
  604. use the device represented by a file you specified, and it
  605. couldn't find the device. This can mean that the device file was
  606. installed incorrectly, or that the physical device is missing or
  607. not correctly attached to the computer.</para></refsect2><refsect2><title>nodev</title><remark>alias <code>G_FILE_ERROR_NODEV</code></remark><para>The underlying file system of the specified file
  608. does not support memory mapping.</para></refsect2><refsect2><title>rofs</title><remark>alias <code>G_FILE_ERROR_ROFS</code></remark><para>The directory containing the new link can't be
  609. modified because it's on a read-only file system.</para></refsect2><refsect2><title>txtbsy</title><remark>alias <code>G_FILE_ERROR_TXTBSY</code></remark><para>Text file busy.</para></refsect2><refsect2><title>fault</title><remark>alias <code>G_FILE_ERROR_FAULT</code></remark><para>You passed in a pointer to bad memory.
  610. (GLib won't reliably return this, don't pass in pointers to bad
  611. memory.)</para></refsect2><refsect2><title>loop</title><remark>alias <code>G_FILE_ERROR_LOOP</code></remark><para>Too many levels of symbolic links were encountered
  612. in looking up a file name. This often indicates a cycle of symbolic
  613. links.</para></refsect2><refsect2><title>nospc</title><remark>alias <code>G_FILE_ERROR_NOSPC</code></remark><para>No space left on device; write operation on a
  614. file failed because the disk is full.</para></refsect2><refsect2><title>nomem</title><remark>alias <code>G_FILE_ERROR_NOMEM</code></remark><para>No memory available. The system cannot allocate
  615. more virtual memory because its capacity is full.</para></refsect2><refsect2><title>mfile</title><remark>alias <code>G_FILE_ERROR_MFILE</code></remark><para>The current process has too many files open and
  616. can't open any more. Duplicate descriptors do count toward this
  617. limit.</para></refsect2><refsect2><title>nfile</title><remark>alias <code>G_FILE_ERROR_NFILE</code></remark><para>There are too many distinct file openings in the
  618. entire system.</para></refsect2><refsect2><title>badf</title><remark>alias <code>G_FILE_ERROR_BADF</code></remark><para>Bad file descriptor; for example, I/O on a
  619. descriptor that has been closed or reading from a descriptor open
  620. only for writing (or vice versa).</para></refsect2><refsect2><title>inval</title><remark>alias <code>G_FILE_ERROR_INVAL</code></remark><para>Invalid argument. This is used to indicate
  621. various kinds of problems with passing the wrong argument to a
  622. library function.</para></refsect2><refsect2><title>pipe</title><remark>alias <code>G_FILE_ERROR_PIPE</code></remark><para>Broken pipe; there is no process reading from the
  623. other end of a pipe. Every library function that returns this
  624. error code also generates a 'SIGPIPE' signal; this signal
  625. terminates the program if not handled or blocked. Thus, your
  626. program will never actually see this code unless it has handled
  627. or blocked 'SIGPIPE'.</para></refsect2><refsect2><title>again</title><remark>alias <code>G_FILE_ERROR_AGAIN</code></remark><para>Resource temporarily unavailable; the call might
  628. work if you try again later.</para></refsect2><refsect2><title>intr</title><remark>alias <code>G_FILE_ERROR_INTR</code></remark><para>Interrupted function call; an asynchronous signal
  629. occurred and prevented completion of the call. When this
  630. happens, you should try the call again.</para></refsect2><refsect2><title>io</title><remark>alias <code>G_FILE_ERROR_IO</code></remark><para>Input/output error; usually used for physical read
  631. or write errors. i.e. the disk or other physical device hardware
  632. is returning errors.</para></refsect2><refsect2><title>perm</title><remark>alias <code>G_FILE_ERROR_PERM</code></remark><para>Operation not permitted; only the owner of the
  633. file (or other resource) or processes with special privileges can
  634. perform the operation.</para></refsect2><refsect2><title>nosys</title><remark>alias <code>G_FILE_ERROR_NOSYS</code></remark><para>Function not implemented; this indicates that
  635. the system is missing some functionality.</para></refsect2><refsect2><title>failed</title><remark>alias <code>G_FILE_ERROR_FAILED</code></remark><para>Does not correspond to a UNIX error code; this
  636. is the standard &quot;failed for unspecified reason&quot; error code present
  637. in all <type>GError</type> error code enumerations. Returned if no specific
  638. code applies.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibFileSetContentsFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags to pass to <function>g_file_set_contents_full()</function> to affect its safety and
  639. performance.</para></refsect1><refsect1><title>Members</title><refsect2><title>none</title><remark>alias <code>G_FILE_SET_CONTENTS_NONE</code></remark><para>No guarantees about file consistency or durability.
  640. The most dangerous setting, which is slightly faster than other settings.</para></refsect2><refsect2><title>consistent</title><remark>alias <code>G_FILE_SET_CONTENTS_CONSISTENT</code></remark><para>Guarantee file consistency: after a crash,
  641. either the old version of the file or the new version of the file will be
  642. available, but not a mixture. On Unix systems this equates to an <code>fsync()</code>
  643. on the file and use of an atomic <code>rename()</code> of the new version of the file
  644. over the old.</para></refsect2><refsect2><title>durable</title><remark>alias <code>G_FILE_SET_CONTENTS_DURABLE</code></remark><para>Guarantee file durability: after a crash, the
  645. new version of the file will be available. On Unix systems this equates to
  646. an <code>fsync()</code> on the file (if <constant>G_FILE_SET_CONTENTS_CONSISTENT</constant> is unset), or
  647. the effects of <constant>G_FILE_SET_CONTENTS_CONSISTENT</constant> plus an <code>fsync()</code> on the
  648. directory containing the file after calling <code>rename()</code>.</para></refsect2><refsect2><title>only-existing</title><remark>alias <code>G_FILE_SET_CONTENTS_ONLY_EXISTING</code></remark><para>Only apply consistency and durability
  649. guarantees if the file already exists. This may speed up file operations
  650. if the file doesn’t currently exist, but may result in a corrupted version
  651. of the new file if the system crashes while writing it.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibFileTest&gt;</refname></refnamediv><refsect1><title>Description</title><para>A test to perform on a file using <function>g_file_test()</function>.</para></refsect1><refsect1><title>Members</title><refsect2><title>is-regular</title><remark>alias <code>G_FILE_TEST_IS_REGULAR</code></remark><para><constant>TRUE</constant> if the file is a regular file
  652. (not a directory). Note that this test will also return <constant>TRUE</constant>
  653. if the tested file is a symlink to a regular file.</para></refsect2><refsect2><title>is-symlink</title><remark>alias <code>G_FILE_TEST_IS_SYMLINK</code></remark><para><constant>TRUE</constant> if the file is a symlink.</para></refsect2><refsect2><title>is-dir</title><remark>alias <code>G_FILE_TEST_IS_DIR</code></remark><para><constant>TRUE</constant> if the file is a directory.</para></refsect2><refsect2><title>is-executable</title><remark>alias <code>G_FILE_TEST_IS_EXECUTABLE</code></remark><para><constant>TRUE</constant> if the file is executable.</para></refsect2><refsect2><title>exists</title><remark>alias <code>G_FILE_TEST_EXISTS</code></remark><para><constant>TRUE</constant> if the file exists. It may or may not
  654. be a regular file.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibFormatSizeFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags to modify the format of the string returned by <function>g_format_size_full()</function>.</para></refsect1><refsect1><title>Members</title><refsect2><title>default</title><remark>alias <code>G_FORMAT_SIZE_DEFAULT</code></remark><para>behave the same as <function>g_format_size()</function></para></refsect2><refsect2><title>long-format</title><remark>alias <code>G_FORMAT_SIZE_LONG_FORMAT</code></remark><para>include the exact number of bytes as part
  655. of the returned string. For example, &quot;45.6 kB (45,612 bytes)&quot;.</para></refsect2><refsect2><title>iec-units</title><remark>alias <code>G_FORMAT_SIZE_IEC_UNITS</code></remark><para>use IEC (base 1024) units with &quot;KiB&quot;-style
  656. suffixes. IEC units should only be used for reporting things with
  657. a strong &quot;power of 2&quot; basis, like RAM sizes or RAID stripe sizes.
  658. Network and storage sizes should be reported in the normal SI units.</para></refsect2><refsect2><title>bits</title><remark>alias <code>G_FORMAT_SIZE_BITS</code></remark><para>set the size as a quantity in bits, rather than
  659. bytes, and return units in bits. For example, ‘Mb’ rather than ‘MB’.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GHashTable&gt;</refname></refnamediv><refsect1><title>Description</title><para>The <type>GHashTable</type> struct is an opaque data structure to represent a
  660. [Hash Table][glib-Hash-Tables]. It should only be accessed via the
  661. following functions.</para></refsect1><refsect1><title>Functions</title><refsect2><title>hash-table:add?</title><informalexample><programlisting>(define-values (%return) (hash-table:add? hash-table key))
  662. </programlisting></informalexample><para>This is a convenience function for using a <type>GHashTable</type> as a set. It
  663. is equivalent to calling <function>g_hash_table_replace()</function> with <parameter>key</parameter> as both the
  664. key and the value.
  665. </para>
  666. <para>In particular, this means that if <parameter>key</parameter> already exists in the hash table, then
  667. the old copy of <parameter>key</parameter> in the hash table is freed and <parameter>key</parameter> replaces it in the
  668. table.
  669. </para>
  670. <para>When a hash table only ever contains keys that have themselves as the
  671. corresponding value it is able to be stored more efficiently. See
  672. the discussion in the section description.
  673. </para>
  674. <para>Starting from GLib 2.40, this function returns a boolean value to
  675. indicate whether the newly added value was already in the hash table
  676. or not.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key to insert</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:contains?</title><informalexample><programlisting>(define-values (%return) (hash-table:contains? hash-table key))
  677. </programlisting></informalexample><para>Checks if <parameter>key</parameter> is in <parameter>hash_table</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key to check</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:destroy</title><informalexample><programlisting>(define-values () (hash-table:destroy hash-table))
  678. </programlisting></informalexample><para>Destroys all keys and values in the <type>GHashTable</type> and decrements its
  679. reference count by 1. If keys and/or values are dynamically allocated,
  680. you should either free them first or create the <type>GHashTable</type> with destroy
  681. notifiers using <function>g_hash_table_new_full()</function>. In the latter case the destroy
  682. functions you supplied will be called on all keys and values during the
  683. destruction phase.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:insert?</title><informalexample><programlisting>(define-values (%return) (hash-table:insert? hash-table key value))
  684. </programlisting></informalexample><para>Inserts a new key and value into a <type>GHashTable</type>.
  685. </para>
  686. <para>If the key already exists in the <type>GHashTable</type> its current
  687. value is replaced with the new value. If you supplied a
  688. <parameter>value_destroy_func</parameter> when creating the <type>GHashTable</type>, the old
  689. value is freed using that function. If you supplied a
  690. <parameter>key_destroy_func</parameter> when creating the <type>GHashTable</type>, the passed
  691. key is freed using that function.
  692. </para>
  693. <para>Starting from GLib 2.40, this function returns a boolean value to
  694. indicate whether the newly added value was already in the hash table
  695. or not.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key to insert</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>the value to associate with the key</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:lookup</title><informalexample><programlisting>(define-values (%return) (hash-table:lookup hash-table key))
  696. </programlisting></informalexample><para>Looks up a key in a <type>GHashTable</type>. Note that this function cannot
  697. distinguish between a key that is not present and one which is present
  698. and has the value <constant>NULL</constant>. If you need this distinction, use
  699. <function>g_hash_table_lookup_extended()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to look up</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:lookup-extended</title><informalexample><programlisting>(define-values
  700. (%return orig-key value)
  701. (hash-table:lookup-extended hash-table lookup-key))
  702. </programlisting></informalexample><para>Looks up a key in the <type>GHashTable</type>, returning the original key and the
  703. associated value and a <type>gboolean</type> which is <constant>TRUE</constant> if the key was found. This
  704. is useful if you need to free the memory allocated for the original key,
  705. for example before calling <function>g_hash_table_remove()</function>.
  706. </para>
  707. <para>You can actually pass <constant>NULL</constant> for <parameter>lookup_key</parameter> to test
  708. whether the <constant>NULL</constant> key exists, provided the hash and equal functions
  709. of <parameter>hash_table</parameter> are <constant>NULL</constant>-safe.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>lookup_key</para></td><td class="parameter_description"><para>the key to look up</para><para>Passed as <code>lookup-key</code></para></td></tr><tr><td class="parameter_name"><para>orig_key</para></td><td class="parameter_description"><para>return location for the original key</para><para>Passed as <code>orig-key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>return location for the value associated
  710. with the key</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:remove?</title><informalexample><programlisting>(define-values (%return) (hash-table:remove? hash-table key))
  711. </programlisting></informalexample><para>Removes a key and its associated value from a <type>GHashTable</type>.
  712. </para>
  713. <para>If the <type>GHashTable</type> was created using <function>g_hash_table_new_full()</function>, the
  714. key and value are freed using the supplied destroy functions, otherwise
  715. you have to make sure that any dynamically allocated values are freed
  716. yourself.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to remove</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:remove-all</title><informalexample><programlisting>(define-values () (hash-table:remove-all hash-table))
  717. </programlisting></informalexample><para>Removes all keys and their associated values from a <type>GHashTable</type>.
  718. </para>
  719. <para>If the <type>GHashTable</type> was created using <function>g_hash_table_new_full()</function>,
  720. the keys and values are freed using the supplied destroy functions,
  721. otherwise you have to make sure that any dynamically allocated
  722. values are freed yourself.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:replace?</title><informalexample><programlisting>(define-values (%return) (hash-table:replace? hash-table key value))
  723. </programlisting></informalexample><para>Inserts a new key and value into a <type>GHashTable</type> similar to
  724. <function>g_hash_table_insert()</function>. The difference is that if the key
  725. already exists in the <type>GHashTable</type>, it gets replaced by the
  726. new key. If you supplied a <parameter>value_destroy_func</parameter> when creating
  727. the <type>GHashTable</type>, the old value is freed using that function.
  728. If you supplied a <parameter>key_destroy_func</parameter> when creating the
  729. <type>GHashTable</type>, the old key is freed using that function.
  730. </para>
  731. <para>Starting from GLib 2.40, this function returns a boolean value to
  732. indicate whether the newly added value was already in the hash table
  733. or not.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key to insert</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>the value to associate with the key</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:size</title><informalexample><programlisting>(define-values (%return) (hash-table:size hash-table))
  734. </programlisting></informalexample><para>Returns the number of elements contained in the <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:steal?</title><informalexample><programlisting>(define-values (%return) (hash-table:steal? hash-table key))
  735. </programlisting></informalexample><para>Removes a key and its associated value from a <type>GHashTable</type> without
  736. calling the key and value destroy functions.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to remove</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:steal-all</title><informalexample><programlisting>(define-values () (hash-table:steal-all hash-table))
  737. </programlisting></informalexample><para>Removes all keys and their associated values from a <type>GHashTable</type>
  738. without calling the key and value destroy functions.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:steal-extended</title><informalexample><programlisting>(define-values
  739. (%return stolen-key stolen-value)
  740. (hash-table:steal-extended hash-table lookup-key))
  741. </programlisting></informalexample><para>Looks up a key in the <type>GHashTable</type>, stealing the original key and the
  742. associated value and returning <constant>TRUE</constant> if the key was found. If the key was
  743. not found, <constant>FALSE</constant> is returned.
  744. </para>
  745. <para>If found, the stolen key and value are removed from the hash table without
  746. calling the key and value destroy functions, and ownership is transferred to
  747. the caller of this method; as with <function>g_hash_table_steal()</function>.
  748. </para>
  749. <para>You can pass <constant>NULL</constant> for <parameter>lookup_key</parameter>, provided the hash and equal functions
  750. of <parameter>hash_table</parameter> are <constant>NULL</constant>-safe.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>lookup_key</para></td><td class="parameter_description"><para>the key to look up</para><para>Passed as <code>lookup-key</code></para></td></tr><tr><td class="parameter_name"><para>stolen_key</para></td><td class="parameter_description"><para>return location for the
  751. original key</para><para>Passed as <code>stolen-key</code></para></td></tr><tr><td class="parameter_name"><para>stolen_value</para></td><td class="parameter_description"><para>return location
  752. for the value associated with the key</para><para>Passed as <code>stolen-value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table:unref</title><informalexample><programlisting>(define-values () (hash-table:unref hash-table))
  753. </programlisting></informalexample><para>Atomically decrements the reference count of <parameter>hash_table</parameter> by one.
  754. If the reference count drops to 0, all keys and values will be
  755. destroyed, and all memory allocated by the hash table is released.
  756. This function is MT-safe and may be called from any thread.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a valid <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibHookFlagMask&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags used internally in the <type>GHook</type> implementation.</para></refsect1><refsect1><title>Members</title><refsect2><title>active</title><remark>alias <code>G_HOOK_FLAG_ACTIVE</code></remark><para>set if the hook has not been destroyed</para></refsect2><refsect2><title>in-call</title><remark>alias <code>G_HOOK_FLAG_IN_CALL</code></remark><para>set if the hook is currently being run</para></refsect2><refsect2><title>mask</title><remark>alias <code>G_HOOK_FLAG_MASK</code></remark><para>A mask covering all bits reserved for
  757. hook flags; see <constant>G_HOOK_FLAG_USER_SHIFT</constant></para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GIOChannel&gt;</refname></refnamediv><refsect1><title>Description</title><para>A data structure representing an IO Channel. The fields should be
  758. considered private and should only be accessed with the following
  759. functions.</para></refsect1><refsect1><title>Functions</title><refsect2><title>close</title><informalexample><programlisting>(define-values () (iochannel:close self))
  760. </programlisting></informalexample><para>Close an IO channel. Any pending data to be written will be
  761. flushed, ignoring errors. The channel will not be freed until the
  762. last reference is dropped using <function>g_io_channel_unref()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>A <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>flush</title><informalexample><programlisting>(define-values (%return) (iochannel:flush self))
  763. </programlisting></informalexample><para>Flushes the write buffer for the GIOChannel.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-buffer-condition</title><informalexample><programlisting>(define-values (%return) (iochannel:get-buffer-condition self))
  764. </programlisting></informalexample><para>This function returns a <type>GIOCondition</type> depending on whether there
  765. is data to be read/space to write data in the internal buffers in
  766. the <type>GIOChannel</type>. Only the flags <constant>G_IO_IN</constant> and <constant>G_IO_OUT</constant> may be set.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>A <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-buffer-size</title><informalexample><programlisting>(define-values (%return) (iochannel:get-buffer-size self))
  767. </programlisting></informalexample><para>Gets the buffer size.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-buffered?</title><informalexample><programlisting>(define-values (%return) (iochannel:get-buffered? self))
  768. </programlisting></informalexample><para>Returns whether <parameter>channel</parameter> is buffered.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-close-on-unref?</title><informalexample><programlisting>(define-values (%return) (iochannel:get-close-on-unref? self))
  769. </programlisting></informalexample><para>Returns whether the file/socket/whatever associated with <parameter>channel</parameter>
  770. will be closed when <parameter>channel</parameter> receives its final unref and is
  771. destroyed. The default value of this is <constant>TRUE</constant> for channels created
  772. by g_io_channel_new_file (), and <constant>FALSE</constant> for all other channels.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type>.</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-encoding</title><informalexample><programlisting>(define-values (%return) (iochannel:get-encoding self))
  773. </programlisting></informalexample><para>Gets the encoding for the input/output of the channel.
  774. The internal encoding is always UTF-8. The encoding <constant>NULL</constant>
  775. makes the channel safe for binary data.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-flags</title><informalexample><programlisting>(define-values (%return) (iochannel:get-flags self))
  776. </programlisting></informalexample><para>Gets the current flags for a <type>GIOChannel</type>, including read-only
  777. flags such as <constant>G_IO_FLAG_IS_READABLE</constant>.
  778. </para>
  779. <para>The values of the flags <constant>G_IO_FLAG_IS_READABLE</constant> and <constant>G_IO_FLAG_IS_WRITABLE</constant>
  780. are cached for internal use by the channel when it is created.
  781. If they should change at some later point (e.g. partial shutdown
  782. of a socket with the UNIX <function>shutdown()</function> function), the user
  783. should immediately call <function>g_io_channel_get_flags()</function> to update
  784. the internal values of these flags.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-line-term</title><informalexample><programlisting>(define-values (%return) (iochannel:get-line-term self length))
  785. </programlisting></informalexample><para>This returns the string that <type>GIOChannel</type> uses to determine
  786. where in the file a line break occurs. A value of <constant>NULL</constant>
  787. indicates autodetection.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>a location to return the length of the line terminator</para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>init</title><informalexample><programlisting>(define-values () (iochannel:init self))
  788. </programlisting></informalexample><para>Initializes a <type>GIOChannel</type> struct.
  789. </para>
  790. <para>This is called by each of the above functions when creating a
  791. <type>GIOChannel</type>, and so is not often needed by the application
  792. programmer (unless you are creating a new type of <type>GIOChannel</type>).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>read</title><informalexample><programlisting>(define-values (%return) (iochannel:read self buf count bytes-read))
  793. </programlisting></informalexample><para>Reads data from a <type>GIOChannel</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>buf</para></td><td class="parameter_description"><para>a buffer to read the data into (which should be at least
  794. count bytes long)</para><para>Passed as <code>buf</code></para></td></tr><tr><td class="parameter_name"><para>count</para></td><td class="parameter_description"><para>the number of bytes to read from the <type>GIOChannel</type></para><para>Passed as <code>count</code></para></td></tr><tr><td class="parameter_name"><para>bytes_read</para></td><td class="parameter_description"><para>returns the number of bytes actually read</para><para>Passed as <code>bytes-read</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>read-chars!</title><informalexample><programlisting>(define-values (%return buf bytes-read) (iochannel:read-chars! self buf))
  795. </programlisting></informalexample><para>Replacement for <function>g_io_channel_read()</function> with the new API.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>buf</para></td><td class="parameter_description"><para>
  796. <para>a buffer to read data into</para></para><para>Passed as <code>buf</code></para></td></tr><tr><td class="parameter_name"><para>count</para></td><td class="parameter_description"><para>the size of the buffer. Note that the buffer may not be
  797. completely filled even if there is data in the buffer if the
  798. remaining data is not a complete character.</para><para>Inferred from <code>buf</code></para></td></tr><tr><td class="parameter_name"><para>bytes_read</para></td><td class="parameter_description"><para>The number of bytes read. This may be
  799. zero even on success if count &lt; 6 and the channel's encoding
  800. is non-<constant>NULL</constant>. This indicates that the next UTF-8 character is
  801. too wide for the buffer.</para><para>Passed as <code>bytes-read</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>read-line</title><informalexample><programlisting>(define-values
  802. (%return str-return length terminator-pos)
  803. (iochannel:read-line self))
  804. </programlisting></informalexample><para>Reads a line, including the terminating character(s),
  805. from a <type>GIOChannel</type> into a newly-allocated string.
  806. <parameter>str_return</parameter> will contain allocated memory if the return
  807. is <constant>G_IO_STATUS_NORMAL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>str_return</para></td><td class="parameter_description"><para>The line read from the <type>GIOChannel</type>, including the
  808. line terminator. This data should be freed with <function>g_free()</function>
  809. when no longer needed. This is a nul-terminated string.
  810. If a <parameter>length</parameter> of zero is returned, this will be <constant>NULL</constant> instead.</para><para>Passed as <code>str-return</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>location to store length of the read data, or <constant>NULL</constant></para><para>Passed as <code>length</code></para></td></tr><tr><td class="parameter_name"><para>terminator_pos</para></td><td class="parameter_description"><para>location to store position of line terminator, or <constant>NULL</constant></para><para>Passed as <code>terminator-pos</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>read-line-string</title><informalexample><programlisting>(define-values
  811. (%return)
  812. (iochannel:read-line-string self buffer terminator-pos))
  813. </programlisting></informalexample><para>Reads a line from a <type>GIOChannel</type>, using a <type>GString</type> as a buffer.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>buffer</para></td><td class="parameter_description"><para>a <type>GString</type> into which the line will be written.
  814. If <parameter>buffer</parameter> already contains data, the old data will
  815. be overwritten.</para><para>Passed as <code>buffer</code></para></td></tr><tr><td class="parameter_name"><para>terminator_pos</para></td><td class="parameter_description"><para>location to store position of line terminator, or <constant>NULL</constant></para><para>Passed as <code>terminator-pos</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>read-to-end</title><informalexample><programlisting>(define-values (%return str-return length) (iochannel:read-to-end self))
  816. </programlisting></informalexample><para>Reads all the remaining data from the file.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>str_return</para></td><td class="parameter_description"><para>Location to
  817. store a pointer to a string holding the remaining data in the
  818. <type>GIOChannel</type>. This data should be freed with <function>g_free()</function> when no
  819. longer needed. This data is terminated by an extra nul
  820. character, but there may be other nuls in the intervening data.</para><para>Passed as <code>str-return</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>location to store length of the data</para><para>Inferred from <code>str-return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>read-unichar</title><informalexample><programlisting>(define-values (%return thechar) (iochannel:read-unichar self))
  821. </programlisting></informalexample><para>Reads a Unicode character from <parameter>channel</parameter>.
  822. This function cannot be called on a channel with <constant>NULL</constant> encoding.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>thechar</para></td><td class="parameter_description"><para>a location to return a character</para><para>Passed as <code>thechar</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (iochannel:ref self))
  823. </programlisting></informalexample><para>Increments the reference count of a <type>GIOChannel</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>seek</title><informalexample><programlisting>(define-values (%return) (iochannel:seek self offset type))
  824. </programlisting></informalexample><para>Sets the current position in the <type>GIOChannel</type>, similar to the standard
  825. library function <function>fseek()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>offset</para></td><td class="parameter_description"><para>an offset, in bytes, which is added to the position specified
  826. by <parameter>type</parameter></para><para>Passed as <code>offset</code></para></td></tr><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>the position in the file, which can be <constant>G_SEEK_CUR</constant> (the current
  827. position), <constant>G_SEEK_SET</constant> (the start of the file), or <constant>G_SEEK_END</constant>
  828. (the end of the file)</para><para>Passed as <code>type</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>seek-position</title><informalexample><programlisting>(define-values (%return) (iochannel:seek-position self offset type))
  829. </programlisting></informalexample><para>Replacement for <function>g_io_channel_seek()</function> with the new API.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>offset</para></td><td class="parameter_description"><para>The offset in bytes from the position specified by <parameter>type</parameter></para><para>Passed as <code>offset</code></para></td></tr><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GSeekType</type>. The type <constant>G_SEEK_CUR</constant> is only allowed in those
  830. cases where a call to g_io_channel_set_encoding ()
  831. is allowed. See the documentation for
  832. g_io_channel_set_encoding () for details.</para><para>Passed as <code>type</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-buffer-size</title><informalexample><programlisting>(define-values () (iochannel:set-buffer-size self size))
  833. </programlisting></informalexample><para>Sets the buffer size.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>size</para></td><td class="parameter_description"><para>the size of the buffer, or 0 to let GLib pick a good size</para><para>Passed as <code>size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-buffered</title><informalexample><programlisting>(define-values () (iochannel:set-buffered self buffered))
  834. </programlisting></informalexample><para>The buffering state can only be set if the channel's encoding
  835. is <constant>NULL</constant>. For any other encoding, the channel must be buffered.
  836. </para>
  837. <para>A buffered channel can only be set unbuffered if the channel's
  838. internal buffers have been flushed. Newly created channels or
  839. channels which have returned <constant>G_IO_STATUS_EOF</constant>
  840. not require such a flush. For write-only channels, a call to
  841. g_io_channel_flush () is sufficient. For all other channels,
  842. the buffers may be flushed by a call to g_io_channel_seek_position ().
  843. This includes the possibility of seeking with seek type <constant>G_SEEK_CUR</constant>
  844. and an offset of zero. Note that this means that socket-based
  845. channels cannot be set unbuffered once they have had data
  846. read from them.
  847. </para>
  848. <para>On unbuffered channels, it is safe to mix read and write
  849. calls from the new and old APIs, if this is necessary for
  850. maintaining old code.
  851. </para>
  852. <para>The default state of the channel is buffered.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>buffered</para></td><td class="parameter_description"><para>whether to set the channel buffered or unbuffered</para><para>Passed as <code>buffered</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-close-on-unref</title><informalexample><programlisting>(define-values () (iochannel:set-close-on-unref self do-close))
  853. </programlisting></informalexample><para>Whether to close the channel on the final unref of the <type>GIOChannel</type>
  854. data structure. The default value of this is <constant>TRUE</constant> for channels
  855. created by g_io_channel_new_file (), and <constant>FALSE</constant> for all other channels.
  856. </para>
  857. <para>Setting this flag to <constant>TRUE</constant> for a channel you have already closed
  858. can cause problems when the final reference to the <type>GIOChannel</type> is dropped.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>do_close</para></td><td class="parameter_description"><para>Whether to close the channel on the final unref of
  859. the GIOChannel data structure.</para><para>Passed as <code>do-close</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-encoding</title><informalexample><programlisting>(define-values (%return) (iochannel:set-encoding self encoding))
  860. </programlisting></informalexample><para>Sets the encoding for the input/output of the channel.
  861. The internal encoding is always UTF-8. The default encoding
  862. for the external file is UTF-8.
  863. </para>
  864. <para>The encoding <constant>NULL</constant> is safe to use with binary data.
  865. </para>
  866. <para>The encoding can only be set if one of the following conditions
  867. is true:
  868. </para>
  869. <para>- The channel was just created, and has not been written to or read from yet.
  870. </para>
  871. <para>- The channel is write-only.
  872. </para>
  873. <para>- The channel is a file, and the file pointer was just repositioned
  874. by a call to <function>g_io_channel_seek_position()</function>. (This flushes all the
  875. internal buffers.)
  876. </para>
  877. <para>- The current encoding is <constant>NULL</constant> or UTF-8.
  878. </para>
  879. <para>- One of the (new API) read functions has just returned <constant>G_IO_STATUS_EOF</constant>
  880. (or, in the case of <function>g_io_channel_read_to_end()</function>, <constant>G_IO_STATUS_NORMAL</constant>).
  881. </para>
  882. <para>- One of the functions <function>g_io_channel_read_chars()</function> or
  883. <function>g_io_channel_read_unichar()</function> has returned <constant>G_IO_STATUS_AGAIN</constant> or
  884. <constant>G_IO_STATUS_ERROR</constant>. This may be useful in the case of
  885. <constant>G_CONVERT_ERROR_ILLEGAL_SEQUENCE</constant>.
  886. Returning one of these statuses from <function>g_io_channel_read_line()</function>,
  887. <function>g_io_channel_read_line_string()</function>, or <function>g_io_channel_read_to_end()</function>
  888. does not guarantee that the encoding can be changed.
  889. </para>
  890. <para>Channels which do not meet one of the above conditions cannot call
  891. <function>g_io_channel_seek_position()</function> with an offset of <constant>G_SEEK_CUR</constant>, and, if
  892. they are &quot;seekable&quot;, cannot call <function>g_io_channel_write_chars()</function> after
  893. calling one of the API &quot;read&quot; functions.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>encoding</para></td><td class="parameter_description"><para>the encoding type</para><para>Passed as <code>encoding</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-flags</title><informalexample><programlisting>(define-values (%return) (iochannel:set-flags self flags))
  894. </programlisting></informalexample><para>Sets the (writeable) flags in <parameter>channel</parameter> to (<parameter>flags</parameter> &amp; <constant>G_IO_FLAG_SET_MASK</constant>).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>the flags to set on the IO channel</para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-line-term</title><informalexample><programlisting>(define-values () (iochannel:set-line-term self line-term length))
  895. </programlisting></informalexample><para>This sets the string that <type>GIOChannel</type> uses to determine
  896. where in the file a line break occurs.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>line_term</para></td><td class="parameter_description"><para>The line termination string. Use <constant>NULL</constant> for
  897. autodetect. Autodetection breaks on &quot;\n&quot;, &quot;\r\n&quot;, &quot;\r&quot;, &quot;\0&quot;,
  898. and the Unicode paragraph separator. Autodetection should not be
  899. used for anything other than file-based channels.</para><para>Passed as <code>line-term</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>The length of the termination string. If -1 is passed, the
  900. string is assumed to be nul-terminated. This option allows
  901. termination strings with embedded nuls.</para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>shutdown</title><informalexample><programlisting>(define-values (%return) (iochannel:shutdown self flush))
  902. </programlisting></informalexample><para>Close an IO channel. Any pending data to be written will be
  903. flushed if <parameter>flush</parameter> is <constant>TRUE</constant>. The channel will not be freed until the
  904. last reference is dropped using <function>g_io_channel_unref()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>flush</para></td><td class="parameter_description"><para>if <constant>TRUE</constant>, flush pending</para><para>Passed as <code>flush</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unix-get-fd</title><informalexample><programlisting>(define-values (%return) (iochannel:unix-get-fd self))
  905. </programlisting></informalexample><para>Returns the file descriptor of the <type>GIOChannel</type>.
  906. </para>
  907. <para>On Windows this function returns the file descriptor or socket of
  908. the <type>GIOChannel</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type>, created with <function>g_io_channel_unix_new()</function>.</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (iochannel:unref self))
  909. </programlisting></informalexample><para>Decrements the reference count of a <type>GIOChannel</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>write</title><informalexample><programlisting>(define-values (%return) (iochannel:write self buf count bytes-written))
  910. </programlisting></informalexample><para>Writes data to a <type>GIOChannel</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>buf</para></td><td class="parameter_description"><para>the buffer containing the data to write</para><para>Passed as <code>buf</code></para></td></tr><tr><td class="parameter_name"><para>count</para></td><td class="parameter_description"><para>the number of bytes to write</para><para>Passed as <code>count</code></para></td></tr><tr><td class="parameter_name"><para>bytes_written</para></td><td class="parameter_description"><para>the number of bytes actually written</para><para>Passed as <code>bytes-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>write-chars</title><informalexample><programlisting>(define-values (%return bytes-written) (iochannel:write-chars self buf count))
  911. </programlisting></informalexample><para>Replacement for <function>g_io_channel_write()</function> with the new API.
  912. </para>
  913. <para>On seekable channels with encodings other than <constant>NULL</constant> or UTF-8, generic
  914. mixing of reading and writing is not allowed. A call to g_io_channel_write_chars ()
  915. may only be made on a channel from which data has been read in the
  916. cases described in the documentation for g_io_channel_set_encoding ().</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>buf</para></td><td class="parameter_description"><para>a buffer to write data from</para><para>Passed as <code>buf</code></para></td></tr><tr><td class="parameter_name"><para>count</para></td><td class="parameter_description"><para>the size of the buffer. If -1, the buffer
  917. is taken to be a nul-terminated string.</para><para>Passed as <code>count</code></para></td></tr><tr><td class="parameter_name"><para>bytes_written</para></td><td class="parameter_description"><para>The number of bytes written. This can be nonzero
  918. even if the return value is not <constant>G_IO_STATUS_NORMAL</constant>.
  919. If the return value is <constant>G_IO_STATUS_NORMAL</constant> and the
  920. channel is blocking, this will always be equal
  921. to <parameter>count</parameter> if <parameter>count</parameter> &gt;= 0.</para><para>Passed as <code>bytes-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>write-unichar</title><informalexample><programlisting>(define-values (%return) (iochannel:write-unichar self thechar))
  922. </programlisting></informalexample><para>Writes a Unicode character to <parameter>channel</parameter>.
  923. This function cannot be called on a channel with <constant>NULL</constant> encoding.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>thechar</para></td><td class="parameter_description"><para>a character</para><para>Passed as <code>thechar</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>iochannel:unix-new</title><informalexample><programlisting>(define-values (%return) (iochannel:unix-new fd))
  924. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>fd</para></td><td class="parameter_description"><para></para><para>Passed as <code>fd</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>iochannel:new-file</title><informalexample><programlisting>(define-values (%return) (iochannel:new-file filename mode))
  925. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para></para><para>Passed as <code>filename</code></para></td></tr><tr><td class="parameter_name"><para>mode</para></td><td class="parameter_description"><para></para><para>Passed as <code>mode</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>iochannel:error-from-errno</title><informalexample><programlisting>(define-values (%return) (iochannel:error-from-errno en))
  926. </programlisting></informalexample><para>Converts an <code>errno</code> error number to a <type>GIOChannelError</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>en</para></td><td class="parameter_description"><para>an <code>errno</code> error number, e.g. <code>EINVAL</code></para><para>Passed as <code>en</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>iochannel:error-quark</title><informalexample><programlisting>(define-values (%return) (iochannel:error-quark))
  927. </programlisting></informalexample><para>Undocumented</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibIOChannelError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by <type>GIOChannel</type> operations.</para></refsect1><refsect1><title>Members</title><refsect2><title>fbig</title><remark>alias <code>G_IO_CHANNEL_ERROR_FBIG</code></remark><para>File too large.</para></refsect2><refsect2><title>inval</title><remark>alias <code>G_IO_CHANNEL_ERROR_INVAL</code></remark><para>Invalid argument.</para></refsect2><refsect2><title>io</title><remark>alias <code>G_IO_CHANNEL_ERROR_IO</code></remark><para>IO error.</para></refsect2><refsect2><title>isdir</title><remark>alias <code>G_IO_CHANNEL_ERROR_ISDIR</code></remark><para>File is a directory.</para></refsect2><refsect2><title>nospc</title><remark>alias <code>G_IO_CHANNEL_ERROR_NOSPC</code></remark><para>No space left on device.</para></refsect2><refsect2><title>nxio</title><remark>alias <code>G_IO_CHANNEL_ERROR_NXIO</code></remark><para>No such device or address.</para></refsect2><refsect2><title>overflow</title><remark>alias <code>G_IO_CHANNEL_ERROR_OVERFLOW</code></remark><para>Value too large for defined datatype.</para></refsect2><refsect2><title>pipe</title><remark>alias <code>G_IO_CHANNEL_ERROR_PIPE</code></remark><para>Broken pipe.</para></refsect2><refsect2><title>failed</title><remark>alias <code>G_IO_CHANNEL_ERROR_FAILED</code></remark><para>Some other error.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GIOCondition&gt;</refname></refnamediv><refsect1><title>Description</title><para>A bitwise combination representing a condition to watch for on an
  928. event source.</para></refsect1><refsect1><title>Members</title><refsect2><title>in</title><remark>alias <code>G_IO_IN</code></remark><para>There is data to read.</para></refsect2><refsect2><title>out</title><remark>alias <code>G_IO_OUT</code></remark><para>Data can be written (without blocking).</para></refsect2><refsect2><title>pri</title><remark>alias <code>G_IO_PRI</code></remark><para>There is urgent data to read.</para></refsect2><refsect2><title>err</title><remark>alias <code>G_IO_ERR</code></remark><para>Error condition.</para></refsect2><refsect2><title>hup</title><remark>alias <code>G_IO_HUP</code></remark><para>Hung up (the connection has been broken, usually for
  929. pipes and sockets).</para></refsect2><refsect2><title>nval</title><remark>alias <code>G_IO_NVAL</code></remark><para>Invalid request. The file descriptor is not open.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibIOError&gt;</refname></refnamediv><refsect1><title>Description</title><para><type>GIOError</type> is only used by the deprecated functions
  930. <function>g_io_channel_read()</function>, <function>g_io_channel_write()</function>, and <function>g_io_channel_seek()</function>.</para></refsect1><refsect1><title>Members</title><refsect2><title>none</title><remark>alias <code>G_IO_ERROR_NONE</code></remark><para>no error</para></refsect2><refsect2><title>again</title><remark>alias <code>G_IO_ERROR_AGAIN</code></remark><para>an EAGAIN error occurred</para></refsect2><refsect2><title>inval</title><remark>alias <code>G_IO_ERROR_INVAL</code></remark><para>an EINVAL error occurred</para></refsect2><refsect2><title>unknown</title><remark>alias <code>G_IO_ERROR_UNKNOWN</code></remark><para>another error occurred</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibIOFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Specifies properties of a <type>GIOChannel</type>. Some of the flags can only be
  931. read with <function>g_io_channel_get_flags()</function>, but not changed with
  932. <function>g_io_channel_set_flags()</function>.</para></refsect1><refsect1><title>Members</title><refsect2><title>append</title><remark>alias <code>G_IO_FLAG_APPEND</code></remark><para>turns on append mode, corresponds to <constant>O_APPEND</constant>
  933. (see the documentation of the UNIX <function>open()</function> syscall)</para></refsect2><refsect2><title>nonblock</title><remark>alias <code>G_IO_FLAG_NONBLOCK</code></remark><para>turns on nonblocking mode, corresponds to
  934. <constant>O_NONBLOCK</constant>/<constant>O_NDELAY</constant> (see the documentation of the UNIX <function>open()</function>
  935. syscall)</para></refsect2><refsect2><title>is-readable</title><remark>alias <code>G_IO_FLAG_IS_READABLE</code></remark><para>indicates that the io channel is readable.
  936. This flag cannot be changed.</para></refsect2><refsect2><title>is-writable</title><remark>alias <code>G_IO_FLAG_IS_WRITABLE</code></remark><para>indicates that the io channel is writable.
  937. This flag cannot be changed.</para></refsect2><refsect2><title>is-writeable</title><remark>alias <code>G_IO_FLAG_IS_WRITEABLE</code></remark><para>a misspelled version of <parameter>G_IO_FLAG_IS_WRITABLE</parameter>
  938. that existed before the spelling was fixed in GLib 2.30. It is kept
  939. here for compatibility reasons. Deprecated since 2.30</para></refsect2><refsect2><title>is-seekable</title><remark>alias <code>G_IO_FLAG_IS_SEEKABLE</code></remark><para>indicates that the io channel is seekable,
  940. i.e. that <function>g_io_channel_seek_position()</function> can be used on it.
  941. This flag cannot be changed.</para></refsect2><refsect2><title>mask</title><remark>alias <code>G_IO_FLAG_MASK</code></remark><para>the mask that specifies all the valid flags.</para></refsect2><refsect2><title>get-mask</title><remark>alias <code>G_IO_FLAG_GET_MASK</code></remark><para>the mask of the flags that are returned from
  942. <function>g_io_channel_get_flags()</function></para></refsect2><refsect2><title>set-mask</title><remark>alias <code>G_IO_FLAG_SET_MASK</code></remark><para>the mask of the flags that the user can modify
  943. with <function>g_io_channel_set_flags()</function></para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibIOStatus&gt;</refname></refnamediv><refsect1><title>Description</title><para>Statuses returned by most of the <type>GIOFuncs</type> functions.</para></refsect1><refsect1><title>Members</title><refsect2><title>error</title><remark>alias <code>G_IO_STATUS_ERROR</code></remark><para>An error occurred.</para></refsect2><refsect2><title>normal</title><remark>alias <code>G_IO_STATUS_NORMAL</code></remark><para>Success.</para></refsect2><refsect2><title>eof</title><remark>alias <code>G_IO_STATUS_EOF</code></remark><para>End of file.</para></refsect2><refsect2><title>again</title><remark>alias <code>G_IO_STATUS_AGAIN</code></remark><para>Resource temporarily unavailable.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GKeyFile&gt;</refname></refnamediv><refsect1><title>Description</title><para>The GKeyFile struct contains only private data
  944. and should not be accessed directly.</para></refsect1><refsect1><title>Functions</title><refsect2><title>get-boolean?</title><informalexample><programlisting>(define-values (%return) (key-file:get-boolean? self group-name key))
  945. </programlisting></informalexample><para>Returns the value associated with <parameter>key</parameter> under <parameter>group_name</parameter> as a
  946. boolean.
  947. </para>
  948. <para>If <parameter>key</parameter> cannot be found then <constant>FALSE</constant> is returned and <parameter>error</parameter> is set
  949. to <type>G_KEY_FILE_ERROR_KEY_NOT_FOUND</type>. Likewise, if the value
  950. associated with <parameter>key</parameter> cannot be interpreted as a boolean then <constant>FALSE</constant>
  951. is returned and <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_INVALID_VALUE</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-boolean-list</title><informalexample><programlisting>(define-values
  952. (%return length)
  953. (key-file:get-boolean-list self group-name key))
  954. </programlisting></informalexample><para>Returns the values associated with <parameter>key</parameter> under <parameter>group_name</parameter> as
  955. booleans.
  956. </para>
  957. <para>If <parameter>key</parameter> cannot be found then <constant>NULL</constant> is returned and <parameter>error</parameter> is set to
  958. <type>G_KEY_FILE_ERROR_KEY_NOT_FOUND</type>. Likewise, if the values associated
  959. with <parameter>key</parameter> cannot be interpreted as booleans then <constant>NULL</constant> is returned
  960. and <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_INVALID_VALUE</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the number of booleans returned</para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-comment</title><informalexample><programlisting>(define-values (%return) (key-file:get-comment self group-name key))
  961. </programlisting></informalexample><para>Retrieves a comment above <parameter>key</parameter> from <parameter>group_name</parameter>.
  962. If <parameter>key</parameter> is <constant>NULL</constant> then <parameter>comment</parameter> will be read from above
  963. <parameter>group_name</parameter>. If both <parameter>key</parameter> and <parameter>group_name</parameter> are <constant>NULL</constant>, then
  964. <parameter>comment</parameter> will be read from above the first group in the file.
  965. </para>
  966. <para>Note that the returned string does not include the '#' comment markers,
  967. but does include any whitespace after them (on each line). It includes
  968. the line breaks between lines, but does not include the final line break.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name, or <constant>NULL</constant></para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-double</title><informalexample><programlisting>(define-values (%return) (key-file:get-double self group-name key))
  969. </programlisting></informalexample><para>Returns the value associated with <parameter>key</parameter> under <parameter>group_name</parameter> as a
  970. double. If <parameter>group_name</parameter> is <constant>NULL</constant>, the start_group is used.
  971. </para>
  972. <para>If <parameter>key</parameter> cannot be found then 0.0 is returned and <parameter>error</parameter> is set to
  973. <type>G_KEY_FILE_ERROR_KEY_NOT_FOUND</type>. Likewise, if the value associated
  974. with <parameter>key</parameter> cannot be interpreted as a double then 0.0 is returned
  975. and <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_INVALID_VALUE</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-double-list</title><informalexample><programlisting>(define-values
  976. (%return length)
  977. (key-file:get-double-list self group-name key))
  978. </programlisting></informalexample><para>Returns the values associated with <parameter>key</parameter> under <parameter>group_name</parameter> as
  979. doubles.
  980. </para>
  981. <para>If <parameter>key</parameter> cannot be found then <constant>NULL</constant> is returned and <parameter>error</parameter> is set to
  982. <type>G_KEY_FILE_ERROR_KEY_NOT_FOUND</type>. Likewise, if the values associated
  983. with <parameter>key</parameter> cannot be interpreted as doubles then <constant>NULL</constant> is returned
  984. and <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_INVALID_VALUE</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the number of doubles returned</para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-groups</title><informalexample><programlisting>(define-values (%return length) (key-file:get-groups self))
  985. </programlisting></informalexample><para>Returns all groups in the key file loaded with <parameter>key_file</parameter>.
  986. The array of returned groups will be <constant>NULL</constant>-terminated, so
  987. <parameter>length</parameter> may optionally be <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>return location for the number of returned groups, or <constant>NULL</constant></para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-int64</title><informalexample><programlisting>(define-values (%return) (key-file:get-int64 self group-name key))
  988. </programlisting></informalexample><para>Returns the value associated with <parameter>key</parameter> under <parameter>group_name</parameter> as a signed
  989. 64-bit integer. This is similar to <function>g_key_file_get_integer()</function> but can return
  990. 64-bit results without truncation.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a non-<constant>NULL</constant> <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a non-<constant>NULL</constant> group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a non-<constant>NULL</constant> key</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-integer</title><informalexample><programlisting>(define-values (%return) (key-file:get-integer self group-name key))
  991. </programlisting></informalexample><para>Returns the value associated with <parameter>key</parameter> under <parameter>group_name</parameter> as an
  992. integer.
  993. </para>
  994. <para>If <parameter>key</parameter> cannot be found then 0 is returned and <parameter>error</parameter> is set to
  995. <type>G_KEY_FILE_ERROR_KEY_NOT_FOUND</type>. Likewise, if the value associated
  996. with <parameter>key</parameter> cannot be interpreted as an integer, or is out of range
  997. for a <type>gint</type>, then 0 is returned
  998. and <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_INVALID_VALUE</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-integer-list</title><informalexample><programlisting>(define-values
  999. (%return length)
  1000. (key-file:get-integer-list self group-name key))
  1001. </programlisting></informalexample><para>Returns the values associated with <parameter>key</parameter> under <parameter>group_name</parameter> as
  1002. integers.
  1003. </para>
  1004. <para>If <parameter>key</parameter> cannot be found then <constant>NULL</constant> is returned and <parameter>error</parameter> is set to
  1005. <type>G_KEY_FILE_ERROR_KEY_NOT_FOUND</type>. Likewise, if the values associated
  1006. with <parameter>key</parameter> cannot be interpreted as integers, or are out of range for
  1007. <type>gint</type>, then <constant>NULL</constant> is returned
  1008. and <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_INVALID_VALUE</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the number of integers returned</para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-keys</title><informalexample><programlisting>(define-values (%return length) (key-file:get-keys self group-name))
  1009. </programlisting></informalexample><para>Returns all keys for the group name <parameter>group_name</parameter>. The array of
  1010. returned keys will be <constant>NULL</constant>-terminated, so <parameter>length</parameter> may
  1011. optionally be <constant>NULL</constant>. In the event that the <parameter>group_name</parameter> cannot
  1012. be found, <constant>NULL</constant> is returned and <parameter>error</parameter> is set to
  1013. <type>G_KEY_FILE_ERROR_GROUP_NOT_FOUND</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>return location for the number of keys returned, or <constant>NULL</constant></para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-locale-for-key</title><informalexample><programlisting>(define-values
  1014. (%return)
  1015. (key-file:get-locale-for-key self group-name key locale))
  1016. </programlisting></informalexample><para>Returns the actual locale which the result of
  1017. <function>g_key_file_get_locale_string()</function> or <function>g_key_file_get_locale_string_list()</function>
  1018. came from.
  1019. </para>
  1020. <para>If calling <function>g_key_file_get_locale_string()</function> or
  1021. <function>g_key_file_get_locale_string_list()</function> with exactly the same <parameter>key_file</parameter>,
  1022. <parameter>group_name</parameter>, <parameter>key</parameter> and <parameter>locale</parameter>, the result of those functions will
  1023. have originally been tagged with the locale that is the result of
  1024. this function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>locale</para></td><td class="parameter_description"><para>a locale identifier or <constant>NULL</constant></para><para>Passed as <code>locale</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-locale-string</title><informalexample><programlisting>(define-values
  1025. (%return)
  1026. (key-file:get-locale-string self group-name key locale))
  1027. </programlisting></informalexample><para>Returns the value associated with <parameter>key</parameter> under <parameter>group_name</parameter>
  1028. translated in the given <parameter>locale</parameter> if available. If <parameter>locale</parameter> is
  1029. <constant>NULL</constant> then the current locale is assumed.
  1030. </para>
  1031. <para>If <parameter>locale</parameter> is to be non-<constant>NULL</constant>, or if the current locale will change over
  1032. the lifetime of the <type>GKeyFile</type>, it must be loaded with
  1033. <constant>G_KEY_FILE_KEEP_TRANSLATIONS</constant> in order to load strings for all locales.
  1034. </para>
  1035. <para>If <parameter>key</parameter> cannot be found then <constant>NULL</constant> is returned and <parameter>error</parameter> is set
  1036. to <type>G_KEY_FILE_ERROR_KEY_NOT_FOUND</type>. If the value associated
  1037. with <parameter>key</parameter> cannot be interpreted or no suitable translation can
  1038. be found then the untranslated value is returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>locale</para></td><td class="parameter_description"><para>a locale identifier or <constant>NULL</constant></para><para>Passed as <code>locale</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-locale-string-list</title><informalexample><programlisting>(define-values
  1039. (%return length)
  1040. (key-file:get-locale-string-list self group-name key locale))
  1041. </programlisting></informalexample><para>Returns the values associated with <parameter>key</parameter> under <parameter>group_name</parameter>
  1042. translated in the given <parameter>locale</parameter> if available. If <parameter>locale</parameter> is
  1043. <constant>NULL</constant> then the current locale is assumed.
  1044. </para>
  1045. <para>If <parameter>locale</parameter> is to be non-<constant>NULL</constant>, or if the current locale will change over
  1046. the lifetime of the <type>GKeyFile</type>, it must be loaded with
  1047. <constant>G_KEY_FILE_KEEP_TRANSLATIONS</constant> in order to load strings for all locales.
  1048. </para>
  1049. <para>If <parameter>key</parameter> cannot be found then <constant>NULL</constant> is returned and <parameter>error</parameter> is set
  1050. to <type>G_KEY_FILE_ERROR_KEY_NOT_FOUND</type>. If the values associated
  1051. with <parameter>key</parameter> cannot be interpreted or no suitable translations
  1052. can be found then the untranslated values are returned. The
  1053. returned array is <constant>NULL</constant>-terminated, so <parameter>length</parameter> may optionally
  1054. be <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>locale</para></td><td class="parameter_description"><para>a locale identifier or <constant>NULL</constant></para><para>Passed as <code>locale</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>return location for the number of returned strings or <constant>NULL</constant></para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-start-group</title><informalexample><programlisting>(define-values (%return) (key-file:get-start-group self))
  1055. </programlisting></informalexample><para>Returns the name of the start group of the file.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-string</title><informalexample><programlisting>(define-values (%return) (key-file:get-string self group-name key))
  1056. </programlisting></informalexample><para>Returns the string value associated with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1057. Unlike <function>g_key_file_get_value()</function>, this function handles escape sequences
  1058. like \s.
  1059. </para>
  1060. <para>In the event the key cannot be found, <constant>NULL</constant> is returned and
  1061. <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_KEY_NOT_FOUND</type>. In the
  1062. event that the <parameter>group_name</parameter> cannot be found, <constant>NULL</constant> is returned
  1063. and <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_GROUP_NOT_FOUND</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-string-list</title><informalexample><programlisting>(define-values
  1064. (%return length)
  1065. (key-file:get-string-list self group-name key))
  1066. </programlisting></informalexample><para>Returns the values associated with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1067. </para>
  1068. <para>In the event the key cannot be found, <constant>NULL</constant> is returned and
  1069. <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_KEY_NOT_FOUND</type>. In the
  1070. event that the <parameter>group_name</parameter> cannot be found, <constant>NULL</constant> is returned
  1071. and <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_GROUP_NOT_FOUND</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>return location for the number of returned strings, or <constant>NULL</constant></para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-uint64</title><informalexample><programlisting>(define-values (%return) (key-file:get-uint64 self group-name key))
  1072. </programlisting></informalexample><para>Returns the value associated with <parameter>key</parameter> under <parameter>group_name</parameter> as an unsigned
  1073. 64-bit integer. This is similar to <function>g_key_file_get_integer()</function> but can return
  1074. large positive results without truncation.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a non-<constant>NULL</constant> <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a non-<constant>NULL</constant> group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a non-<constant>NULL</constant> key</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-value</title><informalexample><programlisting>(define-values (%return) (key-file:get-value self group-name key))
  1075. </programlisting></informalexample><para>Returns the raw value associated with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1076. Use <function>g_key_file_get_string()</function> to retrieve an unescaped UTF-8 string.
  1077. </para>
  1078. <para>In the event the key cannot be found, <constant>NULL</constant> is returned and
  1079. <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_KEY_NOT_FOUND</type>. In the
  1080. event that the <parameter>group_name</parameter> cannot be found, <constant>NULL</constant> is returned
  1081. and <parameter>error</parameter> is set to <type>G_KEY_FILE_ERROR_GROUP_NOT_FOUND</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>has-group?</title><informalexample><programlisting>(define-values (%return) (key-file:has-group? self group-name))
  1082. </programlisting></informalexample><para>Looks whether the key file has the group <parameter>group_name</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>load-from-bytes?</title><informalexample><programlisting>(define-values (%return) (key-file:load-from-bytes? self bytes flags))
  1083. </programlisting></informalexample><para>Loads a key file from the data in <parameter>bytes</parameter> into an empty <type>GKeyFile</type> structure.
  1084. If the object cannot be created then <constant>error</constant> is set to a <type>GKeyFileError</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>an empty <type>GKeyFile</type> struct</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>bytes</para></td><td class="parameter_description"><para>a <type>GBytes</type></para><para>Passed as <code>bytes</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags from <type>GKeyFileFlags</type></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>load-from-data?</title><informalexample><programlisting>(define-values (%return) (key-file:load-from-data? self data length flags))
  1085. </programlisting></informalexample><para>Loads a key file from memory into an empty <type>GKeyFile</type> structure.
  1086. If the object cannot be created then <constant>error</constant> is set to a <type>GKeyFileError</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>an empty <type>GKeyFile</type> struct</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>key file loaded in memory</para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of <parameter>data</parameter> in bytes (or (gsize)-1 if data is nul-terminated)</para><para>Passed as <code>length</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags from <type>GKeyFileFlags</type></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>load-from-data-dirs</title><informalexample><programlisting>(define-values
  1087. (%return full-path)
  1088. (key-file:load-from-data-dirs self file flags))
  1089. </programlisting></informalexample><para>This function looks for a key file named <parameter>file</parameter> in the paths
  1090. returned from <function>g_get_user_data_dir()</function> and <function>g_get_system_data_dirs()</function>,
  1091. loads the file into <parameter>key_file</parameter> and returns the file's full path in
  1092. <parameter>full_path</parameter>. If the file could not be loaded then an <constant>error</constant> is
  1093. set to either a <type>GFileError</type> or <type>GKeyFileError</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>an empty <type>GKeyFile</type> struct</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para>a relative path to a filename to open and parse</para><para>Passed as <code>file</code></para></td></tr><tr><td class="parameter_name"><para>full_path</para></td><td class="parameter_description"><para>return location for a string containing the full path
  1094. of the file, or <constant>NULL</constant></para><para>Passed as <code>full-path</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags from <type>GKeyFileFlags</type></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>load-from-dirs</title><informalexample><programlisting>(define-values
  1095. (%return full-path)
  1096. (key-file:load-from-dirs self file search-dirs flags))
  1097. </programlisting></informalexample><para>This function looks for a key file named <parameter>file</parameter> in the paths
  1098. specified in <parameter>search_dirs</parameter>, loads the file into <parameter>key_file</parameter> and
  1099. returns the file's full path in <parameter>full_path</parameter>.
  1100. </para>
  1101. <para>If the file could not be found in any of the <parameter>search_dirs</parameter>,
  1102. <constant>G_KEY_FILE_ERROR_NOT_FOUND</constant> is returned. If
  1103. the file is found but the OS returns an error when opening or reading the
  1104. file, a <constant>G_FILE_ERROR</constant> is returned. If there is a problem parsing the file, a
  1105. <constant>G_KEY_FILE_ERROR</constant> is returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>an empty <type>GKeyFile</type> struct</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para>a relative path to a filename to open and parse</para><para>Passed as <code>file</code></para></td></tr><tr><td class="parameter_name"><para>search_dirs</para></td><td class="parameter_description"><para><constant>NULL</constant>-terminated array of directories to search</para><para>Passed as <code>search-dirs</code></para></td></tr><tr><td class="parameter_name"><para>full_path</para></td><td class="parameter_description"><para>return location for a string containing the full path
  1106. of the file, or <constant>NULL</constant></para><para>Passed as <code>full-path</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags from <type>GKeyFileFlags</type></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>load-from-file?</title><informalexample><programlisting>(define-values (%return) (key-file:load-from-file? self file flags))
  1107. </programlisting></informalexample><para>Loads a key file into an empty <type>GKeyFile</type> structure.
  1108. </para>
  1109. <para>If the OS returns an error when opening or reading the file, a
  1110. <constant>G_FILE_ERROR</constant> is returned. If there is a problem parsing the file, a
  1111. <constant>G_KEY_FILE_ERROR</constant> is returned.
  1112. </para>
  1113. <para>This function will never return a <constant>G_KEY_FILE_ERROR_NOT_FOUND</constant> error. If the
  1114. <parameter>file</parameter> is not found, <constant>G_FILE_ERROR_NOENT</constant> is returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>an empty <type>GKeyFile</type> struct</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para>the path of a filename to load, in the GLib filename encoding</para><para>Passed as <code>file</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags from <type>GKeyFileFlags</type></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>remove-comment?</title><informalexample><programlisting>(define-values (%return) (key-file:remove-comment? self group-name key))
  1115. </programlisting></informalexample><para>Removes a comment above <parameter>key</parameter> from <parameter>group_name</parameter>.
  1116. If <parameter>key</parameter> is <constant>NULL</constant> then <parameter>comment</parameter> will be removed above <parameter>group_name</parameter>.
  1117. If both <parameter>key</parameter> and <parameter>group_name</parameter> are <constant>NULL</constant>, then <parameter>comment</parameter> will
  1118. be removed above the first group in the file.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name, or <constant>NULL</constant></para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>remove-group?</title><informalexample><programlisting>(define-values (%return) (key-file:remove-group? self group-name))
  1119. </programlisting></informalexample><para>Removes the specified group, <parameter>group_name</parameter>,
  1120. from the key file.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>remove-key?</title><informalexample><programlisting>(define-values (%return) (key-file:remove-key? self group-name key))
  1121. </programlisting></informalexample><para>Removes <parameter>key</parameter> in <parameter>group_name</parameter> from the key file.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key name to remove</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>save-to-file?</title><informalexample><programlisting>(define-values (%return) (key-file:save-to-file? self filename))
  1122. </programlisting></informalexample><para>Writes the contents of <parameter>key_file</parameter> to <parameter>filename</parameter> using
  1123. <function>g_file_set_contents()</function>. If you need stricter guarantees about durability of
  1124. the written file than are provided by <function>g_file_set_contents()</function>, use
  1125. <function>g_file_set_contents_full()</function> with the return value of <function>g_key_file_to_data()</function>.
  1126. </para>
  1127. <para>This function can fail for any of the reasons that
  1128. <function>g_file_set_contents()</function> may fail.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>the name of the file to write to</para><para>Passed as <code>filename</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-boolean</title><informalexample><programlisting>(define-values () (key-file:set-boolean self group-name key value))
  1129. </programlisting></informalexample><para>Associates a new boolean value with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1130. If <parameter>key</parameter> cannot be found then it is created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para><constant>TRUE</constant> or <constant>FALSE</constant></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-boolean-list</title><informalexample><programlisting>(define-values () (key-file:set-boolean-list self group-name key list))
  1131. </programlisting></informalexample><para>Associates a list of boolean values with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1132. If <parameter>key</parameter> cannot be found then it is created.
  1133. If <parameter>group_name</parameter> is <constant>NULL</constant>, the start_group is used.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>list</para></td><td class="parameter_description"><para>an array of boolean values</para><para>Passed as <code>list</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>length of <parameter>list</parameter></para><para>Inferred from <code>list</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-comment?</title><informalexample><programlisting>(define-values (%return) (key-file:set-comment? self group-name key comment))
  1134. </programlisting></informalexample><para>Places a comment above <parameter>key</parameter> from <parameter>group_name</parameter>.
  1135. </para>
  1136. <para>If <parameter>key</parameter> is <constant>NULL</constant> then <parameter>comment</parameter> will be written above <parameter>group_name</parameter>.
  1137. If both <parameter>key</parameter> and <parameter>group_name</parameter> are <constant>NULL</constant>, then <parameter>comment</parameter> will be
  1138. written above the first group in the file.
  1139. </para>
  1140. <para>Note that this function prepends a '#' comment marker to
  1141. each line of <parameter>comment</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name, or <constant>NULL</constant></para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>comment</para></td><td class="parameter_description"><para>a comment</para><para>Passed as <code>comment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-double</title><informalexample><programlisting>(define-values () (key-file:set-double self group-name key value))
  1142. </programlisting></informalexample><para>Associates a new double value with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1143. If <parameter>key</parameter> cannot be found then it is created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a double value</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-double-list</title><informalexample><programlisting>(define-values () (key-file:set-double-list self group-name key list))
  1144. </programlisting></informalexample><para>Associates a list of double values with <parameter>key</parameter> under
  1145. <parameter>group_name</parameter>. If <parameter>key</parameter> cannot be found then it is created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>list</para></td><td class="parameter_description"><para>an array of double values</para><para>Passed as <code>list</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>number of double values in <parameter>list</parameter></para><para>Inferred from <code>list</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-int64</title><informalexample><programlisting>(define-values () (key-file:set-int64 self group-name key value))
  1146. </programlisting></informalexample><para>Associates a new integer value with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1147. If <parameter>key</parameter> cannot be found then it is created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an integer value</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-integer</title><informalexample><programlisting>(define-values () (key-file:set-integer self group-name key value))
  1148. </programlisting></informalexample><para>Associates a new integer value with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1149. If <parameter>key</parameter> cannot be found then it is created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an integer value</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-integer-list</title><informalexample><programlisting>(define-values () (key-file:set-integer-list self group-name key list))
  1150. </programlisting></informalexample><para>Associates a list of integer values with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1151. If <parameter>key</parameter> cannot be found then it is created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>list</para></td><td class="parameter_description"><para>an array of integer values</para><para>Passed as <code>list</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>number of integer values in <parameter>list</parameter></para><para>Inferred from <code>list</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-list-separator</title><informalexample><programlisting>(define-values () (key-file:set-list-separator self separator))
  1152. </programlisting></informalexample><para>Sets the character which is used to separate
  1153. values in lists. Typically ';' or ',' are used
  1154. as separators. The default list separator is ';'.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>separator</para></td><td class="parameter_description"><para>the separator</para><para>Passed as <code>separator</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-locale-string</title><informalexample><programlisting>(define-values
  1155. ()
  1156. (key-file:set-locale-string self group-name key locale string))
  1157. </programlisting></informalexample><para>Associates a string value for <parameter>key</parameter> and <parameter>locale</parameter> under <parameter>group_name</parameter>.
  1158. If the translation for <parameter>key</parameter> cannot be found then it is created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>locale</para></td><td class="parameter_description"><para>a locale identifier</para><para>Passed as <code>locale</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-locale-string-list</title><informalexample><programlisting>(define-values
  1159. ()
  1160. (key-file:set-locale-string-list self group-name key locale list))
  1161. </programlisting></informalexample><para>Associates a list of string values for <parameter>key</parameter> and <parameter>locale</parameter> under
  1162. <parameter>group_name</parameter>. If the translation for <parameter>key</parameter> cannot be found then
  1163. it is created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>locale</para></td><td class="parameter_description"><para>a locale identifier</para><para>Passed as <code>locale</code></para></td></tr><tr><td class="parameter_name"><para>list</para></td><td class="parameter_description"><para>a <constant>NULL</constant>-terminated array of locale string values</para><para>Passed as <code>list</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of <parameter>list</parameter></para><para>Inferred from <code>list</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-string</title><informalexample><programlisting>(define-values () (key-file:set-string self group-name key string))
  1164. </programlisting></informalexample><para>Associates a new string value with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1165. If <parameter>key</parameter> cannot be found then it is created.
  1166. If <parameter>group_name</parameter> cannot be found then it is created.
  1167. Unlike <function>g_key_file_set_value()</function>, this function handles characters
  1168. that need escaping, such as newlines.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-string-list</title><informalexample><programlisting>(define-values () (key-file:set-string-list self group-name key list))
  1169. </programlisting></informalexample><para>Associates a list of string values for <parameter>key</parameter> under <parameter>group_name</parameter>.
  1170. If <parameter>key</parameter> cannot be found then it is created.
  1171. If <parameter>group_name</parameter> cannot be found then it is created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>list</para></td><td class="parameter_description"><para>an array of string values</para><para>Passed as <code>list</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>number of string values in <parameter>list</parameter></para><para>Inferred from <code>list</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-uint64</title><informalexample><programlisting>(define-values () (key-file:set-uint64 self group-name key value))
  1172. </programlisting></informalexample><para>Associates a new integer value with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1173. If <parameter>key</parameter> cannot be found then it is created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an integer value</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-value</title><informalexample><programlisting>(define-values () (key-file:set-value self group-name key value))
  1174. </programlisting></informalexample><para>Associates a new value with <parameter>key</parameter> under <parameter>group_name</parameter>.
  1175. </para>
  1176. <para>If <parameter>key</parameter> cannot be found then it is created. If <parameter>group_name</parameter> cannot
  1177. be found then it is created. To set an UTF-8 string which may contain
  1178. characters that need escaping (such as newlines or spaces), use
  1179. <function>g_key_file_set_string()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>group_name</para></td><td class="parameter_description"><para>a group name</para><para>Passed as <code>group-name</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>to-data</title><informalexample><programlisting>(define-values (%return length) (key-file:to-data self))
  1180. </programlisting></informalexample><para>This function outputs <parameter>key_file</parameter> as a string.
  1181. </para>
  1182. <para>Note that this function never reports an error,
  1183. so it is safe to pass <constant>NULL</constant> as <parameter>error</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>return location for the length of the
  1184. returned string, or <constant>NULL</constant></para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (key-file:unref self))
  1185. </programlisting></informalexample><para>Decreases the reference count of <parameter>key_file</parameter> by 1. If the reference count
  1186. reaches zero, frees the key file and all its allocated memory.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_file</para></td><td class="parameter_description"><para>a <type>GKeyFile</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>key-file:new</title><informalexample><programlisting>(define-values (%return) (key-file:new))
  1187. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>key-file:error-quark</title><informalexample><programlisting>(define-values (%return) (key-file:error-quark))
  1188. </programlisting></informalexample><para>Undocumented</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibKeyFileError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by key file parsing.</para></refsect1><refsect1><title>Members</title><refsect2><title>unknown-encoding</title><remark>alias <code>G_KEY_FILE_ERROR_UNKNOWN_ENCODING</code></remark><para>the text being parsed was in
  1189. an unknown encoding</para></refsect2><refsect2><title>parse</title><remark>alias <code>G_KEY_FILE_ERROR_PARSE</code></remark><para>document was ill-formed</para></refsect2><refsect2><title>not-found</title><remark>alias <code>G_KEY_FILE_ERROR_NOT_FOUND</code></remark><para>the file was not found</para></refsect2><refsect2><title>key-not-found</title><remark>alias <code>G_KEY_FILE_ERROR_KEY_NOT_FOUND</code></remark><para>a requested key was not found</para></refsect2><refsect2><title>group-not-found</title><remark>alias <code>G_KEY_FILE_ERROR_GROUP_NOT_FOUND</code></remark><para>a requested group was not found</para></refsect2><refsect2><title>invalid-value</title><remark>alias <code>G_KEY_FILE_ERROR_INVALID_VALUE</code></remark><para>a value could not be parsed</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibKeyFileFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags which influence the parsing.</para></refsect1><refsect1><title>Members</title><refsect2><title>none</title><remark>alias <code>G_KEY_FILE_NONE</code></remark><para>No flags, default behaviour</para></refsect2><refsect2><title>keep-comments</title><remark>alias <code>G_KEY_FILE_KEEP_COMMENTS</code></remark><para>Use this flag if you plan to write the
  1190. (possibly modified) contents of the key file back to a file;
  1191. otherwise all comments will be lost when the key file is
  1192. written back.</para></refsect2><refsect2><title>keep-translations</title><remark>alias <code>G_KEY_FILE_KEEP_TRANSLATIONS</code></remark><para>Use this flag if you plan to write the
  1193. (possibly modified) contents of the key file back to a file;
  1194. otherwise only the translations for the current language will be
  1195. written back.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibLogLevelFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags specifying the level of log messages.
  1196. </para>
  1197. <para>It is possible to change how GLib treats messages of the various
  1198. levels using <function>g_log_set_handler()</function> and <function>g_log_set_fatal_mask()</function>.</para></refsect1><refsect1><title>Members</title><refsect2><title>flag-recursion</title><remark>alias <code>G_LOG_FLAG_RECURSION</code></remark><para>internal flag</para></refsect2><refsect2><title>flag-fatal</title><remark>alias <code>G_LOG_FLAG_FATAL</code></remark><para>internal flag</para></refsect2><refsect2><title>level-error</title><remark>alias <code>G_LOG_LEVEL_ERROR</code></remark><para>log level for errors, see <function>g_error()</function>.
  1199. This level is also used for messages produced by <function>g_assert()</function>.</para></refsect2><refsect2><title>level-critical</title><remark>alias <code>G_LOG_LEVEL_CRITICAL</code></remark><para>log level for critical warning messages, see
  1200. <function>g_critical()</function>.
  1201. This level is also used for messages produced by <function>g_return_if_fail()</function>
  1202. and <function>g_return_val_if_fail()</function>.</para></refsect2><refsect2><title>level-warning</title><remark>alias <code>G_LOG_LEVEL_WARNING</code></remark><para>log level for warnings, see <function>g_warning()</function></para></refsect2><refsect2><title>level-message</title><remark>alias <code>G_LOG_LEVEL_MESSAGE</code></remark><para>log level for messages, see <function>g_message()</function></para></refsect2><refsect2><title>level-info</title><remark>alias <code>G_LOG_LEVEL_INFO</code></remark><para>log level for informational messages, see <function>g_info()</function></para></refsect2><refsect2><title>level-debug</title><remark>alias <code>G_LOG_LEVEL_DEBUG</code></remark><para>log level for debug messages, see <function>g_debug()</function></para></refsect2><refsect2><title>level-mask</title><remark>alias <code>G_LOG_LEVEL_MASK</code></remark><para>a mask including all log levels</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibLogWriterOutput&gt;</refname></refnamediv><refsect1><title>Description</title><para>Return values from <type>GLogWriterFuncs</type> to indicate whether the given log entry
  1203. was successfully handled by the writer, or whether there was an error in
  1204. handling it (and hence a fallback writer should be used).
  1205. </para>
  1206. <para>If a <type>GLogWriterFunc</type> ignores a log entry, it should return
  1207. <constant>G_LOG_WRITER_HANDLED</constant>.</para></refsect1><refsect1><title>Members</title><refsect2><title>handled</title><remark>alias <code>G_LOG_WRITER_HANDLED</code></remark><para>Log writer has handled the log entry.</para></refsect2><refsect2><title>unhandled</title><remark>alias <code>G_LOG_WRITER_UNHANDLED</code></remark><para>Log writer could not handle the log entry.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GMainContext&gt;</refname></refnamediv><refsect1><title>Description</title><para>The <code>GMainContext</code> struct is an opaque data
  1208. type representing a set of sources to be handled in a main loop.</para></refsect1><refsect1><title>Functions</title><refsect2><title>acquire?</title><informalexample><programlisting>(define-values (%return) (main-context:acquire? self))
  1209. </programlisting></informalexample><para>Tries to become the owner of the specified context.
  1210. If some other thread is the owner of the context,
  1211. returns <constant>FALSE</constant> immediately. Ownership is properly
  1212. recursive: the owner can require ownership again
  1213. and will release ownership when <function>g_main_context_release()</function>
  1214. is called as many times as <function>g_main_context_acquire()</function>.
  1215. </para>
  1216. <para>You must be the owner of a context before you
  1217. can call <function>g_main_context_prepare()</function>, <function>g_main_context_query()</function>,
  1218. <function>g_main_context_check()</function>, <function>g_main_context_dispatch()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-poll</title><informalexample><programlisting>(define-values () (main-context:add-poll self fd priority))
  1219. </programlisting></informalexample><para>Adds a file descriptor to the set of file descriptors polled for
  1220. this context. This will very seldom be used directly. Instead
  1221. a typical event source will use <function>g_source_add_unix_fd()</function> instead.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type> (or <constant>NULL</constant> for the default context)</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>fd</para></td><td class="parameter_description"><para>a <type>GPollFD</type> structure holding information about a file
  1222. descriptor to watch.</para><para>Passed as <code>fd</code></para></td></tr><tr><td class="parameter_name"><para>priority</para></td><td class="parameter_description"><para>the priority for this file descriptor which should be
  1223. the same as the priority used for <function>g_source_attach()</function> to ensure that the
  1224. file descriptor is polled whenever the results may be needed.</para><para>Passed as <code>priority</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>check?</title><informalexample><programlisting>(define-values (%return) (main-context:check? self max-priority fds))
  1225. </programlisting></informalexample><para>Passes the results of polling back to the main loop.
  1226. </para>
  1227. <para>You must have successfully acquired the context with
  1228. <function>g_main_context_acquire()</function> before you may call this function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>max_priority</para></td><td class="parameter_description"><para>the maximum numerical priority of sources to check</para><para>Passed as <code>max-priority</code></para></td></tr><tr><td class="parameter_name"><para>fds</para></td><td class="parameter_description"><para>array of <type>GPollFD</type>'s that was passed to
  1229. the last call to <function>g_main_context_query()</function></para><para>Passed as <code>fds</code></para></td></tr><tr><td class="parameter_name"><para>n_fds</para></td><td class="parameter_description"><para>return value of <function>g_main_context_query()</function></para><para>Inferred from <code>fds</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dispatch</title><informalexample><programlisting>(define-values () (main-context:dispatch self))
  1230. </programlisting></informalexample><para>Dispatches all pending sources.
  1231. </para>
  1232. <para>You must have successfully acquired the context with
  1233. <function>g_main_context_acquire()</function> before you may call this function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>find-source-by-id</title><informalexample><programlisting>(define-values (%return) (main-context:find-source-by-id self source-id))
  1234. </programlisting></informalexample><para>Finds a <type>GSource</type> given a pair of context and ID.
  1235. </para>
  1236. <para>It is a programmer error to attempt to look up a non-existent source.
  1237. </para>
  1238. <para>More specifically: source IDs can be reissued after a source has been
  1239. destroyed and therefore it is never valid to use this function with a
  1240. source ID which may have already been removed. An example is when
  1241. scheduling an idle to run in another thread with <function>g_idle_add()</function>: the
  1242. idle may already have run and been removed by the time this function
  1243. is called on its (now invalid) source ID. This source ID may have
  1244. been reissued, leading to the operation being performed against the
  1245. wrong source.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type> (if <constant>NULL</constant>, the default context will be used)</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>source_id</para></td><td class="parameter_description"><para>the source ID, as returned by <function>g_source_get_id()</function>.</para><para>Passed as <code>source-id</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>find-source-by-user-data</title><informalexample><programlisting>(define-values
  1246. (%return)
  1247. (main-context:find-source-by-user-data self user-data))
  1248. </programlisting></informalexample><para>Finds a source with the given user data for the callback. If
  1249. multiple sources exist with the same user data, the first
  1250. one found will be returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>the user_data for the callback.</para><para>Passed as <code>user-data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>invoke-full</title><informalexample><programlisting>(define-values
  1251. ()
  1252. (main-context:invoke-full self priority function data notify))
  1253. </programlisting></informalexample><para>Invokes a function in such a way that <parameter>context</parameter> is owned during the
  1254. invocation of <parameter>function</parameter>.
  1255. </para>
  1256. <para>This function is the same as <function>g_main_context_invoke()</function> except that it
  1257. lets you specify the priority in case <parameter>function</parameter> ends up being
  1258. scheduled as an idle and also lets you give a <type>GDestroyNotify</type> for <parameter>data</parameter>.
  1259. </para>
  1260. <para><parameter>notify</parameter> should not assume that it is called from any particular
  1261. thread or with any particular context acquired.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type>, or <constant>NULL</constant></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>priority</para></td><td class="parameter_description"><para>the priority at which to run <parameter>function</parameter></para><para>Passed as <code>priority</code></para></td></tr><tr><td class="parameter_name"><para>function</para></td><td class="parameter_description"><para>function to call</para><para>Passed as <code>function</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>data to pass to <parameter>function</parameter></para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>notify</para></td><td class="parameter_description"><para>a function to call when <parameter>data</parameter> is no longer in use, or <constant>NULL</constant>.</para><para>Passed as <code>notify</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-owner?</title><informalexample><programlisting>(define-values (%return) (main-context:is-owner? self))
  1262. </programlisting></informalexample><para>Determines whether this thread holds the (recursive)
  1263. ownership of this <type>GMainContext</type>. This is useful to
  1264. know before waiting on another thread that may be
  1265. blocking to get ownership of <parameter>context</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>iteration?</title><informalexample><programlisting>(define-values (%return) (main-context:iteration? self may-block))
  1266. </programlisting></informalexample><para>Runs a single iteration for the given main loop. This involves
  1267. checking to see if any event sources are ready to be processed,
  1268. then if no events sources are ready and <parameter>may_block</parameter> is <constant>TRUE</constant>, waiting
  1269. for a source to become ready, then dispatching the highest priority
  1270. events sources that are ready. Otherwise, if <parameter>may_block</parameter> is <constant>FALSE</constant>
  1271. sources are not waited to become ready, only those highest priority
  1272. events sources will be dispatched (if any), that are ready at this
  1273. given moment without further waiting.
  1274. </para>
  1275. <para>Note that even when <parameter>may_block</parameter> is <constant>TRUE</constant>, it is still possible for
  1276. <function>g_main_context_iteration()</function> to return <constant>FALSE</constant>, since the wait may
  1277. be interrupted for other reasons than an event source becoming ready.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type> (if <constant>NULL</constant>, the default context will be used)</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>may_block</para></td><td class="parameter_description"><para>whether the call may block.</para><para>Passed as <code>may-block</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>pending?</title><informalexample><programlisting>(define-values (%return) (main-context:pending? self))
  1278. </programlisting></informalexample><para>Checks if any sources have pending events for the given context.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type> (if <constant>NULL</constant>, the default context will be used)</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>pop-thread-default</title><informalexample><programlisting>(define-values () (main-context:pop-thread-default self))
  1279. </programlisting></informalexample><para>Pops <parameter>context</parameter> off the thread-default context stack (verifying that
  1280. it was on the top of the stack).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type> object, or <constant>NULL</constant></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>prepare</title><informalexample><programlisting>(define-values (%return priority) (main-context:prepare self))
  1281. </programlisting></informalexample><para>Prepares to poll sources within a main loop. The resulting information
  1282. for polling is determined by calling g_main_context_query ().
  1283. </para>
  1284. <para>You must have successfully acquired the context with
  1285. <function>g_main_context_acquire()</function> before you may call this function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>priority</para></td><td class="parameter_description"><para>location to store priority of highest priority
  1286. source already ready.</para><para>Passed as <code>priority</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>push-thread-default</title><informalexample><programlisting>(define-values () (main-context:push-thread-default self))
  1287. </programlisting></informalexample><para>Acquires <parameter>context</parameter> and sets it as the thread-default context for the
  1288. current thread. This will cause certain asynchronous operations
  1289. (such as most [gio][gio]-based I/O) which are
  1290. started in this thread to run under <parameter>context</parameter> and deliver their
  1291. results to its main loop, rather than running under the global
  1292. default context in the main thread. Note that calling this function
  1293. changes the context returned by <function>g_main_context_get_thread_default()</function>,
  1294. not the one returned by <function>g_main_context_default()</function>, so it does not affect
  1295. the context used by functions like <function>g_idle_add()</function>.
  1296. </para>
  1297. <para>Normally you would call this function shortly after creating a new
  1298. thread, passing it a <type>GMainContext</type> which will be run by a
  1299. <type>GMainLoop</type> in that thread, to set a new default context for all
  1300. async operations in that thread. In this case you may not need to
  1301. ever call <function>g_main_context_pop_thread_default()</function>, assuming you want the
  1302. new <type>GMainContext</type> to be the default for the whole lifecycle of the
  1303. thread.
  1304. </para>
  1305. <para>If you don't have control over how the new thread was created (e.g.
  1306. in the new thread isn't newly created, or if the thread life
  1307. cycle is managed by a <type>GThreadPool</type>), it is always suggested to wrap
  1308. the logic that needs to use the new <type>GMainContext</type> inside a
  1309. <function>g_main_context_push_thread_default()</function> / <function>g_main_context_pop_thread_default()</function>
  1310. pair, otherwise threads that are re-used will end up never explicitly
  1311. releasing the <type>GMainContext</type> reference they hold.
  1312. </para>
  1313. <para>In some cases you may want to schedule a single operation in a
  1314. non-default context, or temporarily use a non-default context in
  1315. the main thread. In that case, you can wrap the call to the
  1316. asynchronous operation inside a
  1317. <function>g_main_context_push_thread_default()</function> /
  1318. <function>g_main_context_pop_thread_default()</function> pair, but it is up to you to
  1319. ensure that no other asynchronous operations accidentally get
  1320. started while the non-default context is active.
  1321. </para>
  1322. <para>Beware that libraries that predate this function may not correctly
  1323. handle being used from a thread with a thread-default context. Eg,
  1324. see <function>g_file_supports_thread_contexts()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type>, or <constant>NULL</constant> for the global default context</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>query!</title><informalexample><programlisting>(define-values
  1325. (%return timeout- fds)
  1326. (main-context:query! self max-priority fds))
  1327. </programlisting></informalexample><para>Determines information necessary to poll this main loop.
  1328. </para>
  1329. <para>You must have successfully acquired the context with
  1330. <function>g_main_context_acquire()</function> before you may call this function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>max_priority</para></td><td class="parameter_description"><para>maximum priority source to check</para><para>Passed as <code>max-priority</code></para></td></tr><tr><td class="parameter_name"><para>timeout_</para></td><td class="parameter_description"><para>location to store timeout to be used in polling</para><para>Passed as <code>timeout-</code></para></td></tr><tr><td class="parameter_name"><para>fds</para></td><td class="parameter_description"><para>location to
  1331. store <type>GPollFD</type> records that need to be polled.</para><para>Passed as <code>fds</code></para></td></tr><tr><td class="parameter_name"><para>n_fds</para></td><td class="parameter_description"><para>length of <parameter>fds</parameter>.</para><para>Inferred from <code>fds</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (main-context:ref self))
  1332. </programlisting></informalexample><para>Increases the reference count on a <type>GMainContext</type> object by one.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>release</title><informalexample><programlisting>(define-values () (main-context:release self))
  1333. </programlisting></informalexample><para>Releases ownership of a context previously acquired by this thread
  1334. with <function>g_main_context_acquire()</function>. If the context was acquired multiple
  1335. times, the ownership will be released only when <function>g_main_context_release()</function>
  1336. is called as many times as it was acquired.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>remove-poll</title><informalexample><programlisting>(define-values () (main-context:remove-poll self fd))
  1337. </programlisting></informalexample><para>Removes file descriptor from the set of file descriptors to be
  1338. polled for a particular context.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>fd</para></td><td class="parameter_description"><para>a <type>GPollFD</type> descriptor previously added with <function>g_main_context_add_poll()</function></para><para>Passed as <code>fd</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (main-context:unref self))
  1339. </programlisting></informalexample><para>Decreases the reference count on a <type>GMainContext</type> object by one. If
  1340. the result is zero, free the context and free all associated memory.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>wakeup</title><informalexample><programlisting>(define-values () (main-context:wakeup self))
  1341. </programlisting></informalexample><para>If <parameter>context</parameter> is currently blocking in <function>g_main_context_iteration()</function>
  1342. waiting for a source to become ready, cause it to stop blocking
  1343. and return. Otherwise, cause the next invocation of
  1344. <function>g_main_context_iteration()</function> to return without blocking.
  1345. </para>
  1346. <para>This API is useful for low-level control over <type>GMainContext</type>; for
  1347. example, integrating it with main loop implementations such as
  1348. <type>GMainLoop</type>.
  1349. </para>
  1350. <para>Another related use for this function is when implementing a main
  1351. loop with a termination condition, computed from multiple threads:
  1352. </para>
  1353. <para><informalexample><programlisting>
  1354. #define NUM_TASKS 10
  1355. static volatile gint tasks_remaining = NUM_TASKS;
  1356. ...
  1357. while (g_atomic_int_get (&amp;tasks_remaining) != 0)
  1358. g_main_context_iteration (NULL, TRUE);
  1359. </programlisting></informalexample></para>
  1360. <para>Then in a thread:
  1361. <informalexample><programlisting>
  1362. perform_work();
  1363. if (g_atomic_int_dec_and_test (&amp;tasks_remaining))
  1364. g_main_context_wakeup (NULL);
  1365. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>main-context:new</title><informalexample><programlisting>(define-values (%return) (main-context:new))
  1366. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>main-context:default</title><informalexample><programlisting>(define-values (%return) (main-context:default))
  1367. </programlisting></informalexample><para>Returns the global default main context. This is the main context
  1368. used for main loop functions when a main loop is not explicitly
  1369. specified, and corresponds to the &quot;main&quot; main loop. See also
  1370. <function>g_main_context_get_thread_default()</function>.</para></refsect2><refsect2><title>main-context:get-thread-default</title><informalexample><programlisting>(define-values (%return) (main-context:get-thread-default))
  1371. </programlisting></informalexample><para>Gets the thread-default <type>GMainContext</type> for this thread. Asynchronous
  1372. operations that want to be able to be run in contexts other than
  1373. the default one should call this method or
  1374. <function>g_main_context_ref_thread_default()</function> to get a <type>GMainContext</type> to add
  1375. their <type>GSources</type> to. (Note that even in single-threaded
  1376. programs applications may sometimes want to temporarily push a
  1377. non-default context, so it is not safe to assume that this will
  1378. always return <constant>NULL</constant> if you are running in the default thread.)
  1379. </para>
  1380. <para>If you need to hold a reference on the context, use
  1381. <function>g_main_context_ref_thread_default()</function> instead.</para></refsect2><refsect2><title>main-context:ref-thread-default</title><informalexample><programlisting>(define-values (%return) (main-context:ref-thread-default))
  1382. </programlisting></informalexample><para>Gets the thread-default <type>GMainContext</type> for this thread, as with
  1383. <function>g_main_context_get_thread_default()</function>, but also adds a reference to
  1384. it with <function>g_main_context_ref()</function>. In addition, unlike
  1385. <function>g_main_context_get_thread_default()</function>, if the thread-default context
  1386. is the global default context, this will return that <type>GMainContext</type>
  1387. (with a ref added to it) rather than returning <constant>NULL</constant>.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GMainLoop&gt;</refname></refnamediv><refsect1><title>Description</title><para>The <code>GMainLoop</code> struct is an opaque data type
  1388. representing the main event loop of a GLib or GTK+ application.</para></refsect1><refsect1><title>Functions</title><refsect2><title>get-context</title><informalexample><programlisting>(define-values (%return) (main-loop:get-context self))
  1389. </programlisting></informalexample><para>Returns the <type>GMainContext</type> of <parameter>loop</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>loop</para></td><td class="parameter_description"><para>a <type>GMainLoop</type>.</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-running?</title><informalexample><programlisting>(define-values (%return) (main-loop:is-running? self))
  1390. </programlisting></informalexample><para>Checks to see if the main loop is currently being run via <function>g_main_loop_run()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>loop</para></td><td class="parameter_description"><para>a <type>GMainLoop</type>.</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>quit</title><informalexample><programlisting>(define-values () (main-loop:quit self))
  1391. </programlisting></informalexample><para>Stops a <type>GMainLoop</type> from running. Any calls to <function>g_main_loop_run()</function>
  1392. for the loop will return.
  1393. </para>
  1394. <para>Note that sources that have already been dispatched when
  1395. <function>g_main_loop_quit()</function> is called will still be executed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>loop</para></td><td class="parameter_description"><para>a <type>GMainLoop</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (main-loop:ref self))
  1396. </programlisting></informalexample><para>Increases the reference count on a <type>GMainLoop</type> object by one.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>loop</para></td><td class="parameter_description"><para>a <type>GMainLoop</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>run</title><informalexample><programlisting>(define-values () (main-loop:run self))
  1397. </programlisting></informalexample><para>Runs a main loop until <function>g_main_loop_quit()</function> is called on the loop.
  1398. If this is called for the thread of the loop's <type>GMainContext</type>,
  1399. it will process events from the loop, otherwise it will
  1400. simply wait.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>loop</para></td><td class="parameter_description"><para>a <type>GMainLoop</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (main-loop:unref self))
  1401. </programlisting></informalexample><para>Decreases the reference count on a <type>GMainLoop</type> object by one. If
  1402. the result is zero, free the loop and free all associated memory.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>loop</para></td><td class="parameter_description"><para>a <type>GMainLoop</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>main-loop:new</title><informalexample><programlisting>(define-values (%return) (main-loop:new context is-running))
  1403. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para></para><para>Passed as <code>context</code></para></td></tr><tr><td class="parameter_name"><para>is_running</para></td><td class="parameter_description"><para></para><para>Passed as <code>is-running</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GMappedFile&gt;</refname></refnamediv><refsect1><title>Description</title><para>The <type>GMappedFile</type> represents a file mapping created with
  1404. <function>g_mapped_file_new()</function>. It has only private members and should
  1405. not be accessed directly.</para></refsect1><refsect1><title>Functions</title><refsect2><title>free</title><informalexample><programlisting>(define-values () (mapped-file:free self))
  1406. </programlisting></informalexample><para>This call existed before <type>GMappedFile</type> had refcounting and is currently
  1407. exactly the same as <function>g_mapped_file_unref()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para>a <type>GMappedFile</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-bytes</title><informalexample><programlisting>(define-values (%return) (mapped-file:get-bytes self))
  1408. </programlisting></informalexample><para>Creates a new <type>GBytes</type> which references the data mapped from <parameter>file</parameter>.
  1409. The mapped contents of the file must not be modified after creating this
  1410. bytes object, because a <type>GBytes</type> should be immutable.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para>a <type>GMappedFile</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-contents</title><informalexample><programlisting>(define-values (%return) (mapped-file:get-contents self))
  1411. </programlisting></informalexample><para>Returns the contents of a <type>GMappedFile</type>.
  1412. </para>
  1413. <para>Note that the contents may not be zero-terminated,
  1414. even if the <type>GMappedFile</type> is backed by a text file.
  1415. </para>
  1416. <para>If the file is empty then <constant>NULL</constant> is returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para>a <type>GMappedFile</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-length</title><informalexample><programlisting>(define-values (%return) (mapped-file:get-length self))
  1417. </programlisting></informalexample><para>Returns the length of the contents of a <type>GMappedFile</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para>a <type>GMappedFile</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (mapped-file:ref self))
  1418. </programlisting></informalexample><para>Increments the reference count of <parameter>file</parameter> by one. It is safe to call
  1419. this function from any thread.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para>a <type>GMappedFile</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (mapped-file:unref self))
  1420. </programlisting></informalexample><para>Decrements the reference count of <parameter>file</parameter> by one. If the reference count
  1421. drops to 0, unmaps the buffer of <parameter>file</parameter> and frees it.
  1422. </para>
  1423. <para>It is safe to call this function from any thread.
  1424. </para>
  1425. <para>Since 2.22</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para>a <type>GMappedFile</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>mapped-file:new-from-fd</title><informalexample><programlisting>(define-values (%return) (mapped-file:new-from-fd fd writable))
  1426. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>fd</para></td><td class="parameter_description"><para></para><para>Passed as <code>fd</code></para></td></tr><tr><td class="parameter_name"><para>writable</para></td><td class="parameter_description"><para></para><para>Passed as <code>writable</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>mapped-file:new</title><informalexample><programlisting>(define-values (%return) (mapped-file:new filename writable))
  1427. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para></para><para>Passed as <code>filename</code></para></td></tr><tr><td class="parameter_name"><para>writable</para></td><td class="parameter_description"><para></para><para>Passed as <code>writable</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibMarkupCollectType&gt;</refname></refnamediv><refsect1><title>Description</title><para>A mixed enumerated type and flags field. You must specify one type
  1428. (string, strdup, boolean, tristate). Additionally, you may optionally
  1429. bitwise OR the type with the flag <constant>G_MARKUP_COLLECT_OPTIONAL</constant>.
  1430. </para>
  1431. <para>It is likely that this enum will be extended in the future to
  1432. support other types.</para></refsect1><refsect1><title>Members</title><refsect2><title>invalid</title><remark>alias <code>G_MARKUP_COLLECT_INVALID</code></remark><para>used to terminate the list of attributes
  1433. to collect</para></refsect2><refsect2><title>string</title><remark>alias <code>G_MARKUP_COLLECT_STRING</code></remark><para>collect the string pointer directly from
  1434. the attribute_values[] array. Expects a parameter of type (const
  1435. char **). If <constant>G_MARKUP_COLLECT_OPTIONAL</constant> is specified and the
  1436. attribute isn't present then the pointer will be set to <constant>NULL</constant></para></refsect2><refsect2><title>strdup</title><remark>alias <code>G_MARKUP_COLLECT_STRDUP</code></remark><para>as with <constant>G_MARKUP_COLLECT_STRING</constant>, but
  1437. expects a parameter of type (char **) and <function>g_strdup()</function>s the
  1438. returned pointer. The pointer must be freed with <function>g_free()</function></para></refsect2><refsect2><title>boolean</title><remark>alias <code>G_MARKUP_COLLECT_BOOLEAN</code></remark><para>expects a parameter of type (gboolean *)
  1439. and parses the attribute value as a boolean. Sets <constant>FALSE</constant> if the
  1440. attribute isn't present. Valid boolean values consist of
  1441. (case-insensitive) &quot;false&quot;, &quot;f&quot;, &quot;no&quot;, &quot;n&quot;, &quot;0&quot; and &quot;true&quot;, &quot;t&quot;,
  1442. &quot;yes&quot;, &quot;y&quot;, &quot;1&quot;</para></refsect2><refsect2><title>tristate</title><remark>alias <code>G_MARKUP_COLLECT_TRISTATE</code></remark><para>as with <constant>G_MARKUP_COLLECT_BOOLEAN</constant>, but
  1443. in the case of a missing attribute a value is set that compares
  1444. equal to neither <constant>FALSE</constant> nor <constant>TRUE</constant> G_MARKUP_COLLECT_OPTIONAL is
  1445. implied</para></refsect2><refsect2><title>optional</title><remark>alias <code>G_MARKUP_COLLECT_OPTIONAL</code></remark><para>can be bitwise ORed with the other fields.
  1446. If present, allows the attribute not to appear. A default value
  1447. is set depending on what value type is used</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibMarkupError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by markup parsing.</para></refsect1><refsect1><title>Members</title><refsect2><title>bad-utf8</title><remark>alias <code>G_MARKUP_ERROR_BAD_UTF8</code></remark><para>text being parsed was not valid UTF-8</para></refsect2><refsect2><title>empty</title><remark>alias <code>G_MARKUP_ERROR_EMPTY</code></remark><para>document contained nothing, or only whitespace</para></refsect2><refsect2><title>parse</title><remark>alias <code>G_MARKUP_ERROR_PARSE</code></remark><para>document was ill-formed</para></refsect2><refsect2><title>unknown-element</title><remark>alias <code>G_MARKUP_ERROR_UNKNOWN_ELEMENT</code></remark><para>error should be set by <type>GMarkupParser</type>
  1448. functions; element wasn't known</para></refsect2><refsect2><title>unknown-attribute</title><remark>alias <code>G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE</code></remark><para>error should be set by <type>GMarkupParser</type>
  1449. functions; attribute wasn't known</para></refsect2><refsect2><title>invalid-content</title><remark>alias <code>G_MARKUP_ERROR_INVALID_CONTENT</code></remark><para>error should be set by <type>GMarkupParser</type>
  1450. functions; content was invalid</para></refsect2><refsect2><title>missing-attribute</title><remark>alias <code>G_MARKUP_ERROR_MISSING_ATTRIBUTE</code></remark><para>error should be set by <type>GMarkupParser</type>
  1451. functions; a required attribute was missing</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GMarkupParseContext&gt;</refname></refnamediv><refsect1><title>Description</title><para>A parse context is used to parse a stream of bytes that
  1452. you expect to contain marked-up text.
  1453. </para>
  1454. <para>See <function>g_markup_parse_context_new()</function>, <type>GMarkupParser</type>, and so
  1455. on for more details.</para></refsect1><refsect1><title>Functions</title><refsect2><title>end-parse?</title><informalexample><programlisting>(define-values (%return) (markup-parse-context:end-parse? self))
  1456. </programlisting></informalexample><para>Signals to the <type>GMarkupParseContext</type> that all data has been
  1457. fed into the parse context with <function>g_markup_parse_context_parse()</function>.
  1458. </para>
  1459. <para>This function reports an error if the document isn't complete,
  1460. for example if elements are still open.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMarkupParseContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>free</title><informalexample><programlisting>(define-values () (markup-parse-context:free self))
  1461. </programlisting></informalexample><para>Frees a <type>GMarkupParseContext</type>.
  1462. </para>
  1463. <para>This function can't be called from inside one of the
  1464. <type>GMarkupParser</type> functions or while a subparser is pushed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMarkupParseContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-element</title><informalexample><programlisting>(define-values (%return) (markup-parse-context:get-element self))
  1465. </programlisting></informalexample><para>Retrieves the name of the currently open element.
  1466. </para>
  1467. <para>If called from the start_element or end_element handlers this will
  1468. give the element_name as passed to those functions. For the parent
  1469. elements, see <function>g_markup_parse_context_get_element_stack()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMarkupParseContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-position</title><informalexample><programlisting>(define-values
  1470. (line-number char-number)
  1471. (markup-parse-context:get-position self))
  1472. </programlisting></informalexample><para>Retrieves the current line number and the number of the character on
  1473. that line. Intended for use in error messages; there are no strict
  1474. semantics for what constitutes the &quot;current&quot; line number other than
  1475. &quot;the best number we could come up with for error messages.&quot;</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMarkupParseContext</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>line_number</para></td><td class="parameter_description"><para>return location for a line number, or <constant>NULL</constant></para><para>Passed as <code>line-number</code></para></td></tr><tr><td class="parameter_name"><para>char_number</para></td><td class="parameter_description"><para>return location for a char-on-line number, or <constant>NULL</constant></para><para>Passed as <code>char-number</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-user-data</title><informalexample><programlisting>(define-values (%return) (markup-parse-context:get-user-data self))
  1476. </programlisting></informalexample><para>Returns the user_data associated with <parameter>context</parameter>.
  1477. </para>
  1478. <para>This will either be the user_data that was provided to
  1479. <function>g_markup_parse_context_new()</function> or to the most recent call
  1480. of <function>g_markup_parse_context_push()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMarkupParseContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>parse?</title><informalexample><programlisting>(define-values (%return) (markup-parse-context:parse? self text text-len))
  1481. </programlisting></informalexample><para>Feed some data to the <type>GMarkupParseContext</type>.
  1482. </para>
  1483. <para>The data need not be valid UTF-8; an error will be signaled if
  1484. it's invalid. The data need not be an entire document; you can
  1485. feed a document into the parser incrementally, via multiple calls
  1486. to this function. Typically, as you receive data from a network
  1487. connection or file, you feed each received chunk of data into this
  1488. function, aborting the process if an error occurs. Once an error
  1489. is reported, no further data may be fed to the <type>GMarkupParseContext</type>;
  1490. all errors are fatal.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMarkupParseContext</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>text</para></td><td class="parameter_description"><para>chunk of text to parse</para><para>Passed as <code>text</code></para></td></tr><tr><td class="parameter_name"><para>text_len</para></td><td class="parameter_description"><para>length of <parameter>text</parameter> in bytes</para><para>Passed as <code>text-len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>pop</title><informalexample><programlisting>(define-values (%return) (markup-parse-context:pop self))
  1491. </programlisting></informalexample><para>Completes the process of a temporary sub-parser redirection.
  1492. </para>
  1493. <para>This function exists to collect the user_data allocated by a
  1494. matching call to <function>g_markup_parse_context_push()</function>. It must be called
  1495. in the end_element handler corresponding to the start_element
  1496. handler during which <function>g_markup_parse_context_push()</function> was called.
  1497. You must not call this function from the error callback -- the
  1498. <parameter>user_data</parameter> is provided directly to the callback in that case.
  1499. </para>
  1500. <para>This function is not intended to be directly called by users
  1501. interested in invoking subparsers. Instead, it is intended to
  1502. be used by the subparsers themselves to implement a higher-level
  1503. interface.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMarkupParseContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (markup-parse-context:ref self))
  1504. </programlisting></informalexample><para>Increases the reference count of <parameter>context</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMarkupParseContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (markup-parse-context:unref self))
  1505. </programlisting></informalexample><para>Decreases the reference count of <parameter>context</parameter>. When its reference count
  1506. drops to 0, it is freed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMarkupParseContext</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibMarkupParseFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags that affect the behaviour of the parser.</para></refsect1><refsect1><title>Members</title><refsect2><title>do-not-use-this-unsupported-flag</title><remark>alias <code>G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG</code></remark><para>flag you should not use</para></refsect2><refsect2><title>treat-cdata-as-text</title><remark>alias <code>G_MARKUP_TREAT_CDATA_AS_TEXT</code></remark><para>When this flag is set, CDATA marked
  1507. sections are not passed literally to the <parameter>passthrough</parameter> function of
  1508. the parser. Instead, the content of the section (without the
  1509. <code>&lt;![CDATA[</code> and <code>]]&gt;</code>) is
  1510. passed to the <parameter>text</parameter> function. This flag was added in GLib 2.12</para></refsect2><refsect2><title>prefix-error-position</title><remark>alias <code>G_MARKUP_PREFIX_ERROR_POSITION</code></remark><para>Normally errors caught by GMarkup
  1511. itself have line/column information prefixed to them to let the
  1512. caller know the location of the error. When this flag is set the
  1513. location information is also prefixed to errors generated by the
  1514. <type>GMarkupParser</type> implementation functions</para></refsect2><refsect2><title>ignore-qualified</title><remark>alias <code>G_MARKUP_IGNORE_QUALIFIED</code></remark><para>Ignore (don't report) qualified
  1515. attributes and tags, along with their contents. A qualified
  1516. attribute or tag is one that contains ':' in its name (ie: is in
  1517. another namespace). Since: 2.40.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GMatchInfo&gt;</refname></refnamediv><refsect1><title>Description</title><para>A GMatchInfo is an opaque struct used to return information about
  1518. matches.</para></refsect1><refsect1><title>Functions</title><refsect2><title>expand-references</title><informalexample><programlisting>(define-values (%return) (match-info:expand-references self string-to-expand))
  1519. </programlisting></informalexample><para>Returns a new string containing the text in <parameter>string_to_expand</parameter> with
  1520. references and escape sequences expanded. References refer to the last
  1521. match done with <parameter>string</parameter> against <parameter>regex</parameter> and have the same syntax used by
  1522. <function>g_regex_replace()</function>.
  1523. </para>
  1524. <para>The <parameter>string_to_expand</parameter> must be UTF-8 encoded even if <type>G_REGEX_RAW</type> was
  1525. passed to <function>g_regex_new()</function>.
  1526. </para>
  1527. <para>The backreferences are extracted from the string passed to the match
  1528. function, so you cannot call this function after freeing the string.
  1529. </para>
  1530. <para><parameter>match_info</parameter> may be <constant>NULL</constant> in which case <parameter>string_to_expand</parameter> must not
  1531. contain references. For instance &quot;foo\n&quot; does not refer to an actual
  1532. pattern and '\n' merely will be replaced with \n character,
  1533. while to expand &quot;\0&quot; (whole match) one needs the result of a match.
  1534. Use <function>g_regex_check_replacement()</function> to find out whether <parameter>string_to_expand</parameter>
  1535. contains references.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>a <type>GMatchInfo</type> or <constant>NULL</constant></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>string_to_expand</para></td><td class="parameter_description"><para>the string to expand</para><para>Passed as <code>string-to-expand</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>fetch</title><informalexample><programlisting>(define-values (%return) (match-info:fetch self match-num))
  1536. </programlisting></informalexample><para>Retrieves the text matching the <parameter>match_num</parameter>'th capturing
  1537. parentheses. 0 is the full text of the match, 1 is the first paren
  1538. set, 2 the second, and so on.
  1539. </para>
  1540. <para>If <parameter>match_num</parameter> is a valid sub pattern but it didn't match anything
  1541. (e.g. sub pattern 1, matching &quot;b&quot; against &quot;(a)?b&quot;) then an empty
  1542. string is returned.
  1543. </para>
  1544. <para>If the match was obtained using the DFA algorithm, that is using
  1545. <function>g_regex_match_all()</function> or <function>g_regex_match_all_full()</function>, the retrieved
  1546. string is not that of a set of parentheses but that of a matched
  1547. substring. Substrings are matched in reverse order of length, so
  1548. 0 is the longest match.
  1549. </para>
  1550. <para>The string is fetched from the string passed to the match function,
  1551. so you cannot call this function after freeing the string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para><type>GMatchInfo</type> structure</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>match_num</para></td><td class="parameter_description"><para>number of the sub expression</para><para>Passed as <code>match-num</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>fetch-all</title><informalexample><programlisting>(define-values (%return) (match-info:fetch-all self))
  1552. </programlisting></informalexample><para>Bundles up pointers to each of the matching substrings from a match
  1553. and stores them in an array of gchar pointers. The first element in
  1554. the returned array is the match number 0, i.e. the entire matched
  1555. text.
  1556. </para>
  1557. <para>If a sub pattern didn't match anything (e.g. sub pattern 1, matching
  1558. &quot;b&quot; against &quot;(a)?b&quot;) then an empty string is inserted.
  1559. </para>
  1560. <para>If the last match was obtained using the DFA algorithm, that is using
  1561. <function>g_regex_match_all()</function> or <function>g_regex_match_all_full()</function>, the retrieved
  1562. strings are not that matched by sets of parentheses but that of the
  1563. matched substring. Substrings are matched in reverse order of length,
  1564. so the first one is the longest match.
  1565. </para>
  1566. <para>The strings are fetched from the string passed to the match function,
  1567. so you cannot call this function after freeing the string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>a <type>GMatchInfo</type> structure</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>fetch-named</title><informalexample><programlisting>(define-values (%return) (match-info:fetch-named self name))
  1568. </programlisting></informalexample><para>Retrieves the text matching the capturing parentheses named <parameter>name</parameter>.
  1569. </para>
  1570. <para>If <parameter>name</parameter> is a valid sub pattern name but it didn't match anything
  1571. (e.g. sub pattern &quot;X&quot;, matching &quot;b&quot; against &quot;(?P&lt;X&gt;a)?b&quot;)
  1572. then an empty string is returned.
  1573. </para>
  1574. <para>The string is fetched from the string passed to the match function,
  1575. so you cannot call this function after freeing the string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para><type>GMatchInfo</type> structure</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>name</para></td><td class="parameter_description"><para>name of the subexpression</para><para>Passed as <code>name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>fetch-named-pos</title><informalexample><programlisting>(define-values
  1576. (%return start-pos end-pos)
  1577. (match-info:fetch-named-pos self name))
  1578. </programlisting></informalexample><para>Retrieves the position in bytes of the capturing parentheses named <parameter>name</parameter>.
  1579. </para>
  1580. <para>If <parameter>name</parameter> is a valid sub pattern name but it didn't match anything
  1581. (e.g. sub pattern &quot;X&quot;, matching &quot;b&quot; against &quot;(?P&lt;X&gt;a)?b&quot;)
  1582. then <parameter>start_pos</parameter> and <parameter>end_pos</parameter> are set to -1 and <constant>TRUE</constant> is returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para><type>GMatchInfo</type> structure</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>name</para></td><td class="parameter_description"><para>name of the subexpression</para><para>Passed as <code>name</code></para></td></tr><tr><td class="parameter_name"><para>start_pos</para></td><td class="parameter_description"><para>pointer to location where to store
  1583. the start position, or <constant>NULL</constant></para><para>Passed as <code>start-pos</code></para></td></tr><tr><td class="parameter_name"><para>end_pos</para></td><td class="parameter_description"><para>pointer to location where to store
  1584. the end position, or <constant>NULL</constant></para><para>Passed as <code>end-pos</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>fetch-pos</title><informalexample><programlisting>(define-values
  1585. (%return start-pos end-pos)
  1586. (match-info:fetch-pos self match-num))
  1587. </programlisting></informalexample><para>Retrieves the position in bytes of the <parameter>match_num</parameter>'th capturing
  1588. parentheses. 0 is the full text of the match, 1 is the first
  1589. paren set, 2 the second, and so on.
  1590. </para>
  1591. <para>If <parameter>match_num</parameter> is a valid sub pattern but it didn't match anything
  1592. (e.g. sub pattern 1, matching &quot;b&quot; against &quot;(a)?b&quot;) then <parameter>start_pos</parameter>
  1593. and <parameter>end_pos</parameter> are set to -1 and <constant>TRUE</constant> is returned.
  1594. </para>
  1595. <para>If the match was obtained using the DFA algorithm, that is using
  1596. <function>g_regex_match_all()</function> or <function>g_regex_match_all_full()</function>, the retrieved
  1597. position is not that of a set of parentheses but that of a matched
  1598. substring. Substrings are matched in reverse order of length, so
  1599. 0 is the longest match.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para><type>GMatchInfo</type> structure</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>match_num</para></td><td class="parameter_description"><para>number of the sub expression</para><para>Passed as <code>match-num</code></para></td></tr><tr><td class="parameter_name"><para>start_pos</para></td><td class="parameter_description"><para>pointer to location where to store
  1600. the start position, or <constant>NULL</constant></para><para>Passed as <code>start-pos</code></para></td></tr><tr><td class="parameter_name"><para>end_pos</para></td><td class="parameter_description"><para>pointer to location where to store
  1601. the end position, or <constant>NULL</constant></para><para>Passed as <code>end-pos</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>free</title><informalexample><programlisting>(define-values () (match-info:free self))
  1602. </programlisting></informalexample><para>If <parameter>match_info</parameter> is not <constant>NULL</constant>, calls <function>g_match_info_unref()</function>; otherwise does
  1603. nothing.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>a <type>GMatchInfo</type>, or <constant>NULL</constant></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-match-count</title><informalexample><programlisting>(define-values (%return) (match-info:get-match-count self))
  1604. </programlisting></informalexample><para>Retrieves the number of matched substrings (including substring 0,
  1605. that is the whole matched text), so 1 is returned if the pattern
  1606. has no substrings in it and 0 is returned if the match failed.
  1607. </para>
  1608. <para>If the last match was obtained using the DFA algorithm, that is
  1609. using <function>g_regex_match_all()</function> or <function>g_regex_match_all_full()</function>, the retrieved
  1610. count is not that of the number of capturing parentheses but that of
  1611. the number of matched substrings.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>a <type>GMatchInfo</type> structure</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-regex</title><informalexample><programlisting>(define-values (%return) (match-info:get-regex self))
  1612. </programlisting></informalexample><para>Returns <type>GRegex</type> object used in <parameter>match_info</parameter>. It belongs to Glib
  1613. and must not be freed. Use <function>g_regex_ref()</function> if you need to keep it
  1614. after you free <parameter>match_info</parameter> object.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>a <type>GMatchInfo</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-string</title><informalexample><programlisting>(define-values (%return) (match-info:get-string self))
  1615. </programlisting></informalexample><para>Returns the string searched with <parameter>match_info</parameter>. This is the
  1616. string passed to <function>g_regex_match()</function> or <function>g_regex_replace()</function> so
  1617. you may not free it before calling this function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>a <type>GMatchInfo</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-partial-match?</title><informalexample><programlisting>(define-values (%return) (match-info:is-partial-match? self))
  1618. </programlisting></informalexample><para>Usually if the string passed to g_regex_match*() matches as far as
  1619. it goes, but is too short to match the entire pattern, <constant>FALSE</constant> is
  1620. returned. There are circumstances where it might be helpful to
  1621. distinguish this case from other cases in which there is no match.
  1622. </para>
  1623. <para>Consider, for example, an application where a human is required to
  1624. type in data for a field with specific formatting requirements. An
  1625. example might be a date in the form ddmmmyy, defined by the pattern
  1626. &quot;^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$&quot;.
  1627. If the application sees the user’s keystrokes one by one, and can
  1628. check that what has been typed so far is potentially valid, it is
  1629. able to raise an error as soon as a mistake is made.
  1630. </para>
  1631. <para>GRegex supports the concept of partial matching by means of the
  1632. <type>G_REGEX_MATCH_PARTIAL_SOFT</type> and <type>G_REGEX_MATCH_PARTIAL_HARD</type> flags.
  1633. When they are used, the return code for
  1634. <function>g_regex_match()</function> or <function>g_regex_match_full()</function> is, as usual, <constant>TRUE</constant>
  1635. for a complete match, <constant>FALSE</constant> otherwise. But, when these functions
  1636. return <constant>FALSE</constant>, you can check if the match was partial calling
  1637. <function>g_match_info_is_partial_match()</function>.
  1638. </para>
  1639. <para>The difference between <type>G_REGEX_MATCH_PARTIAL_SOFT</type> and
  1640. <type>G_REGEX_MATCH_PARTIAL_HARD</type> is that when a partial match is encountered
  1641. with <type>G_REGEX_MATCH_PARTIAL_SOFT</type>, matching continues to search for a
  1642. possible complete match, while with <type>G_REGEX_MATCH_PARTIAL_HARD</type> matching
  1643. stops at the partial match.
  1644. When both <type>G_REGEX_MATCH_PARTIAL_SOFT</type> and <type>G_REGEX_MATCH_PARTIAL_HARD</type>
  1645. are set, the latter takes precedence.
  1646. </para>
  1647. <para>There were formerly some restrictions on the pattern for partial matching.
  1648. The restrictions no longer apply.
  1649. </para>
  1650. <para>See pcrepartial(3) for more information on partial matching.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>a <type>GMatchInfo</type> structure</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>matches?</title><informalexample><programlisting>(define-values (%return) (match-info:matches? self))
  1651. </programlisting></informalexample><para>Returns whether the previous match operation succeeded.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>a <type>GMatchInfo</type> structure</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>next?</title><informalexample><programlisting>(define-values (%return) (match-info:next? self))
  1652. </programlisting></informalexample><para>Scans for the next match using the same parameters of the previous
  1653. call to <function>g_regex_match_full()</function> or <function>g_regex_match()</function> that returned
  1654. <parameter>match_info</parameter>.
  1655. </para>
  1656. <para>The match is done on the string passed to the match function, so you
  1657. cannot free it before calling this function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>a <type>GMatchInfo</type> structure</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (match-info:ref self))
  1658. </programlisting></informalexample><para>Increases reference count of <parameter>match_info</parameter> by 1.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>a <type>GMatchInfo</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (match-info:unref self))
  1659. </programlisting></informalexample><para>Decreases reference count of <parameter>match_info</parameter> by 1. When reference count drops
  1660. to zero, it frees all the memory associated with the match_info structure.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>a <type>GMatchInfo</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibNormalizeMode&gt;</refname></refnamediv><refsect1><title>Description</title><para>Defines how a Unicode string is transformed in a canonical
  1661. form, standardizing such issues as whether a character with
  1662. an accent is represented as a base character and combining
  1663. accent or as a single precomposed character. Unicode strings
  1664. should generally be normalized before comparing them.</para></refsect1><refsect1><title>Members</title><refsect2><title>default</title><remark>alias <code>G_NORMALIZE_DEFAULT</code></remark><para>standardize differences that do not affect the
  1665. text content, such as the above-mentioned accent representation</para></refsect2><refsect2><title>nfd</title><remark>alias <code>G_NORMALIZE_NFD</code></remark><para>another name for <constant>G_NORMALIZE_DEFAULT</constant></para></refsect2><refsect2><title>default-compose</title><remark>alias <code>G_NORMALIZE_DEFAULT_COMPOSE</code></remark><para>like <constant>G_NORMALIZE_DEFAULT</constant>, but with
  1666. composed forms rather than a maximally decomposed form</para></refsect2><refsect2><title>nfc</title><remark>alias <code>G_NORMALIZE_NFC</code></remark><para>another name for <constant>G_NORMALIZE_DEFAULT_COMPOSE</constant></para></refsect2><refsect2><title>all</title><remark>alias <code>G_NORMALIZE_ALL</code></remark><para>beyond <constant>G_NORMALIZE_DEFAULT</constant> also standardize the
  1667. &quot;compatibility&quot; characters in Unicode, such as SUPERSCRIPT THREE
  1668. to the standard forms (in this case DIGIT THREE). Formatting
  1669. information may be lost but for most text operations such
  1670. characters should be considered the same</para></refsect2><refsect2><title>nfkd</title><remark>alias <code>G_NORMALIZE_NFKD</code></remark><para>another name for <constant>G_NORMALIZE_ALL</constant></para></refsect2><refsect2><title>all-compose</title><remark>alias <code>G_NORMALIZE_ALL_COMPOSE</code></remark><para>like <constant>G_NORMALIZE_ALL</constant>, but with composed
  1671. forms rather than a maximally decomposed form</para></refsect2><refsect2><title>nfkc</title><remark>alias <code>G_NORMALIZE_NFKC</code></remark><para>another name for <constant>G_NORMALIZE_ALL_COMPOSE</constant></para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibNumberParserError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by functions converting a string to a number.</para></refsect1><refsect1><title>Members</title><refsect2><title>invalid</title><remark>alias <code>G_NUMBER_PARSER_ERROR_INVALID</code></remark><para>String was not a valid number.</para></refsect2><refsect2><title>out-of-bounds</title><remark>alias <code>G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS</code></remark><para>String was a number, but out of bounds.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibOnceStatus&gt;</refname></refnamediv><refsect1><title>Description</title><para>The possible statuses of a one-time initialization function
  1672. controlled by a <type>GOnce</type> struct.</para></refsect1><refsect1><title>Members</title><refsect2><title>notcalled</title><remark>alias <code>G_ONCE_STATUS_NOTCALLED</code></remark><para>the function has not been called yet.</para></refsect2><refsect2><title>progress</title><remark>alias <code>G_ONCE_STATUS_PROGRESS</code></remark><para>the function call is currently in progress.</para></refsect2><refsect2><title>ready</title><remark>alias <code>G_ONCE_STATUS_READY</code></remark><para>the function has been called.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibOptionArg&gt;</refname></refnamediv><refsect1><title>Description</title><para>The <type>GOptionArg</type> enum values determine which type of extra argument the
  1673. options expect to find. If an option expects an extra argument, it can
  1674. be specified in several ways; with a short option: <code>-x arg</code>, with a long
  1675. option: <code>--name arg</code> or combined in a single argument: <code>--name=arg</code>.</para></refsect1><refsect1><title>Members</title><refsect2><title>none</title><remark>alias <code>G_OPTION_ARG_NONE</code></remark><para>No extra argument. This is useful for simple flags.</para></refsect2><refsect2><title>string</title><remark>alias <code>G_OPTION_ARG_STRING</code></remark><para>The option takes a UTF-8 string argument.</para></refsect2><refsect2><title>int</title><remark>alias <code>G_OPTION_ARG_INT</code></remark><para>The option takes an integer argument.</para></refsect2><refsect2><title>callback</title><remark>alias <code>G_OPTION_ARG_CALLBACK</code></remark><para>The option provides a callback (of type
  1676. <type>GOptionArgFunc</type>) to parse the extra argument.</para></refsect2><refsect2><title>filename</title><remark>alias <code>G_OPTION_ARG_FILENAME</code></remark><para>The option takes a filename as argument, which will
  1677. be in the GLib filename encoding rather than UTF-8.</para></refsect2><refsect2><title>string-array</title><remark>alias <code>G_OPTION_ARG_STRING_ARRAY</code></remark><para>The option takes a string argument, multiple
  1678. uses of the option are collected into an array of strings.</para></refsect2><refsect2><title>filename-array</title><remark>alias <code>G_OPTION_ARG_FILENAME_ARRAY</code></remark><para>The option takes a filename as argument,
  1679. multiple uses of the option are collected into an array of strings.</para></refsect2><refsect2><title>double</title><remark>alias <code>G_OPTION_ARG_DOUBLE</code></remark><para>The option takes a double argument. The argument
  1680. can be formatted either for the user's locale or for the &quot;C&quot; locale.
  1681. Since 2.12</para></refsect2><refsect2><title>int64</title><remark>alias <code>G_OPTION_ARG_INT64</code></remark><para>The option takes a 64-bit integer. Like
  1682. <constant>G_OPTION_ARG_INT</constant> but for larger numbers. The number can be in
  1683. decimal base, or in hexadecimal (when prefixed with <code>0x</code>, for
  1684. example, <code>0xffffffff</code>). Since 2.12</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibOptionError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by option parsing.</para></refsect1><refsect1><title>Members</title><refsect2><title>unknown-option</title><remark>alias <code>G_OPTION_ERROR_UNKNOWN_OPTION</code></remark><para>An option was not known to the parser.
  1685. This error will only be reported, if the parser hasn't been instructed
  1686. to ignore unknown options, see <function>g_option_context_set_ignore_unknown_options()</function>.</para></refsect2><refsect2><title>bad-value</title><remark>alias <code>G_OPTION_ERROR_BAD_VALUE</code></remark><para>A value couldn't be parsed.</para></refsect2><refsect2><title>failed</title><remark>alias <code>G_OPTION_ERROR_FAILED</code></remark><para>A <type>GOptionArgFunc</type> callback failed.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibOptionFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags which modify individual options.</para></refsect1><refsect1><title>Members</title><refsect2><title>none</title><remark>alias <code>G_OPTION_FLAG_NONE</code></remark><para>No flags. Since: 2.42.</para></refsect2><refsect2><title>hidden</title><remark>alias <code>G_OPTION_FLAG_HIDDEN</code></remark><para>The option doesn't appear in <code>--help</code> output.</para></refsect2><refsect2><title>in-main</title><remark>alias <code>G_OPTION_FLAG_IN_MAIN</code></remark><para>The option appears in the main section of the
  1687. <code>--help</code> output, even if it is defined in a group.</para></refsect2><refsect2><title>reverse</title><remark>alias <code>G_OPTION_FLAG_REVERSE</code></remark><para>For options of the <constant>G_OPTION_ARG_NONE</constant> kind, this
  1688. flag indicates that the sense of the option is reversed.</para></refsect2><refsect2><title>no-arg</title><remark>alias <code>G_OPTION_FLAG_NO_ARG</code></remark><para>For options of the <constant>G_OPTION_ARG_CALLBACK</constant> kind,
  1689. this flag indicates that the callback does not take any argument
  1690. (like a <constant>G_OPTION_ARG_NONE</constant> option). Since 2.8</para></refsect2><refsect2><title>filename</title><remark>alias <code>G_OPTION_FLAG_FILENAME</code></remark><para>For options of the <constant>G_OPTION_ARG_CALLBACK</constant>
  1691. kind, this flag indicates that the argument should be passed to the
  1692. callback in the GLib filename encoding rather than UTF-8. Since 2.8</para></refsect2><refsect2><title>optional-arg</title><remark>alias <code>G_OPTION_FLAG_OPTIONAL_ARG</code></remark><para>For options of the <constant>G_OPTION_ARG_CALLBACK</constant>
  1693. kind, this flag indicates that the argument supply is optional.
  1694. If no argument is given then data of <constant>GOptionParseFunc</constant> will be
  1695. set to NULL. Since 2.8</para></refsect2><refsect2><title>noalias</title><remark>alias <code>G_OPTION_FLAG_NOALIAS</code></remark><para>This flag turns off the automatic conflict
  1696. resolution which prefixes long option names with <code>groupname-</code> if
  1697. there is a conflict. This option should only be used in situations
  1698. where aliasing is necessary to model some legacy commandline interface.
  1699. It is not safe to use this option, unless all option groups are under
  1700. your direct control. Since 2.8.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GOptionGroup&gt;</refname></refnamediv><refsect1><title>Description</title><para>A <code>GOptionGroup</code> struct defines the options in a single
  1701. group. The struct has only private fields and should not be directly accessed.
  1702. </para>
  1703. <para>All options in a group share the same translation function. Libraries which
  1704. need to parse commandline options are expected to provide a function for
  1705. getting a <code>GOptionGroup</code> holding their options, which
  1706. the application can then add to its <type>GOptionContext</type>.</para></refsect1><refsect1><title>Functions</title><refsect2><title>free</title><informalexample><programlisting>(define-values () (option-group:free self))
  1707. </programlisting></informalexample><para>Frees a <type>GOptionGroup</type>. Note that you must not free groups
  1708. which have been added to a <type>GOptionContext</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>group</para></td><td class="parameter_description"><para>a <type>GOptionGroup</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (option-group:ref self))
  1709. </programlisting></informalexample><para>Increments the reference count of <parameter>group</parameter> by one.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>group</para></td><td class="parameter_description"><para>a <type>GOptionGroup</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-translate-func</title><informalexample><programlisting>(define-values
  1710. ()
  1711. (option-group:set-translate-func self func data destroy-notify))
  1712. </programlisting></informalexample><para>Sets the function which is used to translate user-visible strings,
  1713. for <code>--help</code> output. Different groups can use different
  1714. <type>GTranslateFuncs</type>. If <parameter>func</parameter> is <constant>NULL</constant>, strings are not translated.
  1715. </para>
  1716. <para>If you are using <function>gettext()</function>, you only need to set the translation
  1717. domain, see <function>g_option_group_set_translation_domain()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>group</para></td><td class="parameter_description"><para>a <type>GOptionGroup</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para>the <type>GTranslateFunc</type>, or <constant>NULL</constant></para><para>Passed as <code>func</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>user data to pass to <parameter>func</parameter>, or <constant>NULL</constant></para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>destroy_notify</para></td><td class="parameter_description"><para>a function which gets called to free <parameter>data</parameter>, or <constant>NULL</constant></para><para>Passed as <code>destroy-notify</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-translation-domain</title><informalexample><programlisting>(define-values () (option-group:set-translation-domain self domain))
  1718. </programlisting></informalexample><para>A convenience function to use <function>gettext()</function> for translating
  1719. user-visible strings.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>group</para></td><td class="parameter_description"><para>a <type>GOptionGroup</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para>the domain to use</para><para>Passed as <code>domain</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (option-group:unref self))
  1720. </programlisting></informalexample><para>Decrements the reference count of <parameter>group</parameter> by one.
  1721. If the reference count drops to 0, the <parameter>group</parameter> will be freed.
  1722. and all memory allocated by the <parameter>group</parameter> is released.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>group</para></td><td class="parameter_description"><para>a <type>GOptionGroup</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>option-group:new</title><informalexample><programlisting>(define-values
  1723. (%return)
  1724. (option-group:new name description help-description user-data destroy))
  1725. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>name</para></td><td class="parameter_description"><para></para><para>Passed as <code>name</code></para></td></tr><tr><td class="parameter_name"><para>description</para></td><td class="parameter_description"><para></para><para>Passed as <code>description</code></para></td></tr><tr><td class="parameter_name"><para>help_description</para></td><td class="parameter_description"><para></para><para>Passed as <code>help-description</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para></para><para>Passed as <code>user-data</code></para></td></tr><tr><td class="parameter_name"><para>destroy</para></td><td class="parameter_description"><para></para><para>Passed as <code>destroy</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GPatternSpec&gt;</refname></refnamediv><refsect1><title>Description</title><para>A GPatternSpec struct is the 'compiled' form of a pattern. This
  1726. structure is opaque and its fields cannot be accessed directly.</para></refsect1><refsect1><title>Functions</title><refsect2><title>copy</title><informalexample><programlisting>(define-values (%return) (pattern-spec:copy self))
  1727. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pspec</para></td><td class="parameter_description"><para></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>equal?</title><informalexample><programlisting>(define-values (%return) (pattern-spec:equal? self pspec2))
  1728. </programlisting></informalexample><para>Compares two compiled pattern specs and returns whether they will
  1729. match the same set of strings.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pspec1</para></td><td class="parameter_description"><para>a <type>GPatternSpec</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>pspec2</para></td><td class="parameter_description"><para>another <type>GPatternSpec</type></para><para>Passed as <code>pspec2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>free</title><informalexample><programlisting>(define-values () (pattern-spec:free self))
  1730. </programlisting></informalexample><para>Frees the memory allocated for the <type>GPatternSpec</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pspec</para></td><td class="parameter_description"><para>a <type>GPatternSpec</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>match?</title><informalexample><programlisting>(define-values
  1731. (%return)
  1732. (pattern-spec:match? self string-length string string-reversed))
  1733. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pspec</para></td><td class="parameter_description"><para></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>string_length</para></td><td class="parameter_description"><para></para><para>Passed as <code>string-length</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para></para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>string_reversed</para></td><td class="parameter_description"><para></para><para>Passed as <code>string-reversed</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>match-string?</title><informalexample><programlisting>(define-values (%return) (pattern-spec:match-string? self string))
  1734. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pspec</para></td><td class="parameter_description"><para></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para></para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>pattern-spec:new</title><informalexample><programlisting>(define-values (%return) (pattern-spec:new pattern))
  1735. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pattern</para></td><td class="parameter_description"><para></para><para>Passed as <code>pattern</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GPollFD&gt;</refname></refnamediv><refsect1><title>Description</title><para>Represents a file descriptor, which events to poll for, and which events
  1736. occurred.</para></refsect1></refentry><refentry><refnamediv><refname>&lt;GPtrArray&gt;</refname></refnamediv><refsect1><title>Description</title><para>Contains the public fields of a pointer array.</para></refsect1></refentry><refentry><refnamediv><refname>&lt;GRegex&gt;</refname></refnamediv><refsect1><title>Description</title><para>The g_regex_*() functions implement regular
  1737. expression pattern matching using syntax and semantics similar to
  1738. Perl regular expression.
  1739. </para>
  1740. <para>Some functions accept a <parameter>start_position</parameter> argument, setting it differs
  1741. from just passing over a shortened string and setting <type>G_REGEX_MATCH_NOTBOL</type>
  1742. in the case of a pattern that begins with any kind of lookbehind assertion.
  1743. For example, consider the pattern &quot;\Biss\B&quot; which finds occurrences of &quot;iss&quot;
  1744. in the middle of words. (&quot;\B&quot; matches only if the current position in the
  1745. subject is not a word boundary.) When applied to the string &quot;Mississipi&quot;
  1746. from the fourth byte, namely &quot;issipi&quot;, it does not match, because &quot;\B&quot; is
  1747. always false at the start of the subject, which is deemed to be a word
  1748. boundary. However, if the entire string is passed , but with
  1749. <parameter>start_position</parameter> set to 4, it finds the second occurrence of &quot;iss&quot; because
  1750. it is able to look behind the starting point to discover that it is
  1751. preceded by a letter.
  1752. </para>
  1753. <para>Note that, unless you set the <type>G_REGEX_RAW</type> flag, all the strings passed
  1754. to these functions must be encoded in UTF-8. The lengths and the positions
  1755. inside the strings are in bytes and not in characters, so, for instance,
  1756. &quot;\xc3\xa0&quot; (i.e. &quot;à&quot;) is two bytes long but it is treated as a
  1757. single character. If you set <type>G_REGEX_RAW</type> the strings can be non-valid
  1758. UTF-8 strings and a byte is treated as a character, so &quot;\xc3\xa0&quot; is two
  1759. bytes and two characters long.
  1760. </para>
  1761. <para>When matching a pattern, &quot;\n&quot; matches only against a &quot;\n&quot; character in
  1762. the string, and &quot;\r&quot; matches only a &quot;\r&quot; character. To match any newline
  1763. sequence use &quot;\R&quot;. This particular group matches either the two-character
  1764. sequence CR + LF (&quot;\r\n&quot;), or one of the single characters LF (linefeed,
  1765. U+000A, &quot;\n&quot;), VT vertical tab, U+000B, &quot;\v&quot;), FF (formfeed, U+000C, &quot;\f&quot;),
  1766. CR (carriage return, U+000D, &quot;\r&quot;), NEL (next line, U+0085), LS (line
  1767. separator, U+2028), or PS (paragraph separator, U+2029).
  1768. </para>
  1769. <para>The behaviour of the dot, circumflex, and dollar metacharacters are
  1770. affected by newline characters, the default is to recognize any newline
  1771. character (the same characters recognized by &quot;\R&quot;). This can be changed
  1772. with <type>G_REGEX_NEWLINE_CR</type>, <type>G_REGEX_NEWLINE_LF</type> and <type>G_REGEX_NEWLINE_CRLF</type>
  1773. compile options, and with <type>G_REGEX_MATCH_NEWLINE_ANY</type>,
  1774. <type>G_REGEX_MATCH_NEWLINE_CR</type>, <type>G_REGEX_MATCH_NEWLINE_LF</type> and
  1775. <type>G_REGEX_MATCH_NEWLINE_CRLF</type> match options. These settings are also
  1776. relevant when compiling a pattern if <type>G_REGEX_EXTENDED</type> is set, and an
  1777. unescaped &quot;#&quot; outside a character class is encountered. This indicates
  1778. a comment that lasts until after the next newline.
  1779. </para>
  1780. <para>When setting the <constant>G_REGEX_JAVASCRIPT_COMPAT</constant> flag, pattern syntax and pattern
  1781. matching is changed to be compatible with the way that regular expressions
  1782. work in JavaScript. More precisely, a lonely ']' character in the pattern
  1783. is a syntax error; the '\x' escape only allows 0 to 2 hexadecimal digits, and
  1784. you must use the '\u' escape sequence with 4 hex digits to specify a unicode
  1785. codepoint instead of '\x' or 'x{....}'. If '\x' or '\u' are not followed by
  1786. the specified number of hex digits, they match 'x' and 'u' literally; also
  1787. '\U' always matches 'U' instead of being an error in the pattern. Finally,
  1788. pattern matching is modified so that back references to an unset subpattern
  1789. group produces a match with the empty string instead of an error. See
  1790. pcreapi(3) for more information.
  1791. </para>
  1792. <para>Creating and manipulating the same <type>GRegex</type> structure from different
  1793. threads is not a problem as <type>GRegex</type> does not modify its internal
  1794. state between creation and destruction, on the other hand <type>GMatchInfo</type>
  1795. is not threadsafe.
  1796. </para>
  1797. <para>The regular expressions low-level functionalities are obtained through
  1798. the excellent
  1799. [PCRE](http://www.pcre.org/)
  1800. library written by Philip Hazel.</para></refsect1><refsect1><title>Functions</title><refsect2><title>get-capture-count</title><informalexample><programlisting>(define-values (%return) (regex:get-capture-count self))
  1801. </programlisting></informalexample><para>Returns the number of capturing subpatterns in the pattern.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-compile-flags</title><informalexample><programlisting>(define-values (%return) (regex:get-compile-flags self))
  1802. </programlisting></informalexample><para>Returns the compile options that <parameter>regex</parameter> was created with.
  1803. </para>
  1804. <para>Depending on the version of PCRE that is used, this may or may not
  1805. include flags set by option expressions such as <code>(?i)</code> found at the
  1806. top-level within the compiled pattern.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-has-cr-or-lf?</title><informalexample><programlisting>(define-values (%return) (regex:get-has-cr-or-lf? self))
  1807. </programlisting></informalexample><para>Checks whether the pattern contains explicit CR or LF references.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type> structure</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-match-flags</title><informalexample><programlisting>(define-values (%return) (regex:get-match-flags self))
  1808. </programlisting></informalexample><para>Returns the match options that <parameter>regex</parameter> was created with.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-max-backref</title><informalexample><programlisting>(define-values (%return) (regex:get-max-backref self))
  1809. </programlisting></informalexample><para>Returns the number of the highest back reference
  1810. in the pattern, or 0 if the pattern does not contain
  1811. back references.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-max-lookbehind</title><informalexample><programlisting>(define-values (%return) (regex:get-max-lookbehind self))
  1812. </programlisting></informalexample><para>Gets the number of characters in the longest lookbehind assertion in the
  1813. pattern. This information is useful when doing multi-segment matching using
  1814. the partial matching facilities.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type> structure</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-pattern</title><informalexample><programlisting>(define-values (%return) (regex:get-pattern self))
  1815. </programlisting></informalexample><para>Gets the pattern string associated with <parameter>regex</parameter>, i.e. a copy of
  1816. the string passed to <function>g_regex_new()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type> structure</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-string-number</title><informalexample><programlisting>(define-values (%return) (regex:get-string-number self name))
  1817. </programlisting></informalexample><para>Retrieves the number of the subexpression named <parameter>name</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para><type>GRegex</type> structure</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>name</para></td><td class="parameter_description"><para>name of the subexpression</para><para>Passed as <code>name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>match</title><informalexample><programlisting>(define-values (%return match-info) (regex:match self string match-options))
  1818. </programlisting></informalexample><para>Scans for a match in <parameter>string</parameter> for the pattern in <parameter>regex</parameter>.
  1819. The <parameter>match_options</parameter> are combined with the match options specified
  1820. when the <parameter>regex</parameter> structure was created, letting you have more
  1821. flexibility in reusing <type>GRegex</type> structures.
  1822. </para>
  1823. <para>Unless <constant>G_REGEX_RAW</constant> is specified in the options, <parameter>string</parameter> must be valid UTF-8.
  1824. </para>
  1825. <para>A <type>GMatchInfo</type> structure, used to get information on the match,
  1826. is stored in <parameter>match_info</parameter> if not <constant>NULL</constant>. Note that if <parameter>match_info</parameter>
  1827. is not <constant>NULL</constant> then it is created even if the function returns <constant>FALSE</constant>,
  1828. i.e. you must free it regardless if regular expression actually matched.
  1829. </para>
  1830. <para>To retrieve all the non-overlapping matches of the pattern in
  1831. string you can use <function>g_match_info_next()</function>.
  1832. </para>
  1833. <para><informalexample><programlisting>
  1834. static void
  1835. print_uppercase_words (const gchar *string)
  1836. {
  1837. // Print all uppercase-only words.
  1838. GRegex *regex;
  1839. GMatchInfo *match_info;
  1840. regex = g_regex_new (&quot;[A-Z]+&quot;, 0, 0, NULL);
  1841. g_regex_match (regex, string, 0, &amp;match_info);
  1842. while (g_match_info_matches (match_info))
  1843. {
  1844. gchar *word = g_match_info_fetch (match_info, 0);
  1845. g_print (&quot;Found: %s\n&quot;, word);
  1846. g_free (word);
  1847. g_match_info_next (match_info, NULL);
  1848. }
  1849. g_match_info_free (match_info);
  1850. g_regex_unref (regex);
  1851. }
  1852. </programlisting></informalexample></para>
  1853. <para><parameter>string</parameter> is not copied and is used in <type>GMatchInfo</type> internally. If
  1854. you use any <type>GMatchInfo</type> method (except <function>g_match_info_free()</function>) after
  1855. freeing or modifying <parameter>string</parameter> then the behaviour is undefined.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type> structure from <function>g_regex_new()</function></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to scan for matches</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>match options</para><para>Passed as <code>match-options</code></para></td></tr><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>pointer to location where to store
  1856. the <type>GMatchInfo</type>, or <constant>NULL</constant> if you do not need it</para><para>Passed as <code>match-info</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>match-all</title><informalexample><programlisting>(define-values
  1857. (%return match-info)
  1858. (regex:match-all self string match-options))
  1859. </programlisting></informalexample><para>Using the standard algorithm for regular expression matching only
  1860. the longest match in the string is retrieved. This function uses
  1861. a different algorithm so it can retrieve all the possible matches.
  1862. For more documentation see <function>g_regex_match_all_full()</function>.
  1863. </para>
  1864. <para>A <type>GMatchInfo</type> structure, used to get information on the match, is
  1865. stored in <parameter>match_info</parameter> if not <constant>NULL</constant>. Note that if <parameter>match_info</parameter> is
  1866. not <constant>NULL</constant> then it is created even if the function returns <constant>FALSE</constant>,
  1867. i.e. you must free it regardless if regular expression actually
  1868. matched.
  1869. </para>
  1870. <para><parameter>string</parameter> is not copied and is used in <type>GMatchInfo</type> internally. If
  1871. you use any <type>GMatchInfo</type> method (except <function>g_match_info_free()</function>) after
  1872. freeing or modifying <parameter>string</parameter> then the behaviour is undefined.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type> structure from <function>g_regex_new()</function></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to scan for matches</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>match options</para><para>Passed as <code>match-options</code></para></td></tr><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>pointer to location where to store
  1873. the <type>GMatchInfo</type>, or <constant>NULL</constant> if you do not need it</para><para>Passed as <code>match-info</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>match-all-full</title><informalexample><programlisting>(define-values
  1874. (%return match-info)
  1875. (regex:match-all-full self string start-position match-options))
  1876. </programlisting></informalexample><para>Using the standard algorithm for regular expression matching only
  1877. the longest match in the <parameter>string</parameter> is retrieved, it is not possible
  1878. to obtain all the available matches. For instance matching
  1879. &quot;&lt;a&gt; &lt;b&gt; &lt;c&gt;&quot; against the pattern &quot;&lt;.*&gt;&quot;
  1880. you get &quot;&lt;a&gt; &lt;b&gt; &lt;c&gt;&quot;.
  1881. </para>
  1882. <para>This function uses a different algorithm (called DFA, i.e. deterministic
  1883. finite automaton), so it can retrieve all the possible matches, all
  1884. starting at the same point in the string. For instance matching
  1885. &quot;&lt;a&gt; &lt;b&gt; &lt;c&gt;&quot; against the pattern &quot;&lt;.*&gt;;&quot;
  1886. you would obtain three matches: &quot;&lt;a&gt; &lt;b&gt; &lt;c&gt;&quot;,
  1887. &quot;&lt;a&gt; &lt;b&gt;&quot; and &quot;&lt;a&gt;&quot;.
  1888. </para>
  1889. <para>The number of matched strings is retrieved using
  1890. <function>g_match_info_get_match_count()</function>. To obtain the matched strings and
  1891. their position you can use, respectively, <function>g_match_info_fetch()</function> and
  1892. <function>g_match_info_fetch_pos()</function>. Note that the strings are returned in
  1893. reverse order of length; that is, the longest matching string is
  1894. given first.
  1895. </para>
  1896. <para>Note that the DFA algorithm is slower than the standard one and it
  1897. is not able to capture substrings, so backreferences do not work.
  1898. </para>
  1899. <para>Setting <parameter>start_position</parameter> differs from just passing over a shortened
  1900. string and setting <type>G_REGEX_MATCH_NOTBOL</type> in the case of a pattern
  1901. that begins with any kind of lookbehind assertion, such as &quot;\b&quot;.
  1902. </para>
  1903. <para>Unless <constant>G_REGEX_RAW</constant> is specified in the options, <parameter>string</parameter> must be valid UTF-8.
  1904. </para>
  1905. <para>A <type>GMatchInfo</type> structure, used to get information on the match, is
  1906. stored in <parameter>match_info</parameter> if not <constant>NULL</constant>. Note that if <parameter>match_info</parameter> is
  1907. not <constant>NULL</constant> then it is created even if the function returns <constant>FALSE</constant>,
  1908. i.e. you must free it regardless if regular expression actually
  1909. matched.
  1910. </para>
  1911. <para><parameter>string</parameter> is not copied and is used in <type>GMatchInfo</type> internally. If
  1912. you use any <type>GMatchInfo</type> method (except <function>g_match_info_free()</function>) after
  1913. freeing or modifying <parameter>string</parameter> then the behaviour is undefined.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type> structure from <function>g_regex_new()</function></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to scan for matches</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>string_len</para></td><td class="parameter_description"><para>the length of <parameter>string</parameter>, in bytes, or -1 if <parameter>string</parameter> is nul-terminated</para><para>Inferred from <code>string</code></para></td></tr><tr><td class="parameter_name"><para>start_position</para></td><td class="parameter_description"><para>starting index of the string to match, in bytes</para><para>Passed as <code>start-position</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>match options</para><para>Passed as <code>match-options</code></para></td></tr><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>pointer to location where to store
  1914. the <type>GMatchInfo</type>, or <constant>NULL</constant> if you do not need it</para><para>Passed as <code>match-info</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>match-full</title><informalexample><programlisting>(define-values
  1915. (%return match-info)
  1916. (regex:match-full self string start-position match-options))
  1917. </programlisting></informalexample><para>Scans for a match in <parameter>string</parameter> for the pattern in <parameter>regex</parameter>.
  1918. The <parameter>match_options</parameter> are combined with the match options specified
  1919. when the <parameter>regex</parameter> structure was created, letting you have more
  1920. flexibility in reusing <type>GRegex</type> structures.
  1921. </para>
  1922. <para>Setting <parameter>start_position</parameter> differs from just passing over a shortened
  1923. string and setting <type>G_REGEX_MATCH_NOTBOL</type> in the case of a pattern
  1924. that begins with any kind of lookbehind assertion, such as &quot;\b&quot;.
  1925. </para>
  1926. <para>Unless <constant>G_REGEX_RAW</constant> is specified in the options, <parameter>string</parameter> must be valid UTF-8.
  1927. </para>
  1928. <para>A <type>GMatchInfo</type> structure, used to get information on the match, is
  1929. stored in <parameter>match_info</parameter> if not <constant>NULL</constant>. Note that if <parameter>match_info</parameter> is
  1930. not <constant>NULL</constant> then it is created even if the function returns <constant>FALSE</constant>,
  1931. i.e. you must free it regardless if regular expression actually
  1932. matched.
  1933. </para>
  1934. <para><parameter>string</parameter> is not copied and is used in <type>GMatchInfo</type> internally. If
  1935. you use any <type>GMatchInfo</type> method (except <function>g_match_info_free()</function>) after
  1936. freeing or modifying <parameter>string</parameter> then the behaviour is undefined.
  1937. </para>
  1938. <para>To retrieve all the non-overlapping matches of the pattern in
  1939. string you can use <function>g_match_info_next()</function>.
  1940. </para>
  1941. <para><informalexample><programlisting>
  1942. static void
  1943. print_uppercase_words (const gchar *string)
  1944. {
  1945. // Print all uppercase-only words.
  1946. GRegex *regex;
  1947. GMatchInfo *match_info;
  1948. GError *error = NULL;
  1949. regex = g_regex_new (&quot;[A-Z]+&quot;, 0, 0, NULL);
  1950. g_regex_match_full (regex, string, -1, 0, 0, &amp;match_info, &amp;error);
  1951. while (g_match_info_matches (match_info))
  1952. {
  1953. gchar *word = g_match_info_fetch (match_info, 0);
  1954. g_print (&quot;Found: %s\n&quot;, word);
  1955. g_free (word);
  1956. g_match_info_next (match_info, &amp;error);
  1957. }
  1958. g_match_info_free (match_info);
  1959. g_regex_unref (regex);
  1960. if (error != NULL)
  1961. {
  1962. g_printerr (&quot;Error while matching: %s\n&quot;, error-&gt;message);
  1963. g_error_free (error);
  1964. }
  1965. }
  1966. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type> structure from <function>g_regex_new()</function></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to scan for matches</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>string_len</para></td><td class="parameter_description"><para>the length of <parameter>string</parameter>, in bytes, or -1 if <parameter>string</parameter> is nul-terminated</para><para>Inferred from <code>string</code></para></td></tr><tr><td class="parameter_name"><para>start_position</para></td><td class="parameter_description"><para>starting index of the string to match, in bytes</para><para>Passed as <code>start-position</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>match options</para><para>Passed as <code>match-options</code></para></td></tr><tr><td class="parameter_name"><para>match_info</para></td><td class="parameter_description"><para>pointer to location where to store
  1967. the <type>GMatchInfo</type>, or <constant>NULL</constant> if you do not need it</para><para>Passed as <code>match-info</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (regex:ref self))
  1968. </programlisting></informalexample><para>Increases reference count of <parameter>regex</parameter> by 1.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>replace</title><informalexample><programlisting>(define-values
  1969. (%return)
  1970. (regex:replace self string start-position replacement match-options))
  1971. </programlisting></informalexample><para>Replaces all occurrences of the pattern in <parameter>regex</parameter> with the
  1972. replacement text. Backreferences of the form '\number' or
  1973. '\g&lt;number&gt;' in the replacement text are interpolated by the
  1974. number-th captured subexpression of the match, '\g&lt;name&gt;' refers
  1975. to the captured subexpression with the given name. '\0' refers
  1976. to the complete match, but '\0' followed by a number is the octal
  1977. representation of a character. To include a literal '\' in the
  1978. replacement, write '\\\\'.
  1979. </para>
  1980. <para>There are also escapes that changes the case of the following text:
  1981. </para>
  1982. <para>- \l: Convert to lower case the next character
  1983. - \u: Convert to upper case the next character
  1984. - \L: Convert to lower case till \E
  1985. - \U: Convert to upper case till \E
  1986. - \E: End case modification
  1987. </para>
  1988. <para>If you do not need to use backreferences use <function>g_regex_replace_literal()</function>.
  1989. </para>
  1990. <para>The <parameter>replacement</parameter> string must be UTF-8 encoded even if <type>G_REGEX_RAW</type> was
  1991. passed to <function>g_regex_new()</function>. If you want to use not UTF-8 encoded strings
  1992. you can use <function>g_regex_replace_literal()</function>.
  1993. </para>
  1994. <para>Setting <parameter>start_position</parameter> differs from just passing over a shortened
  1995. string and setting <type>G_REGEX_MATCH_NOTBOL</type> in the case of a pattern that
  1996. begins with any kind of lookbehind assertion, such as &quot;\b&quot;.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type> structure</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to perform matches against</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>string_len</para></td><td class="parameter_description"><para>the length of <parameter>string</parameter>, in bytes, or -1 if <parameter>string</parameter> is nul-terminated</para><para>Inferred from <code>string</code></para></td></tr><tr><td class="parameter_name"><para>start_position</para></td><td class="parameter_description"><para>starting index of the string to match, in bytes</para><para>Passed as <code>start-position</code></para></td></tr><tr><td class="parameter_name"><para>replacement</para></td><td class="parameter_description"><para>text to replace each match with</para><para>Passed as <code>replacement</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>options for the match</para><para>Passed as <code>match-options</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>replace-literal</title><informalexample><programlisting>(define-values
  1997. (%return)
  1998. (regex:replace-literal self string start-position replacement match-options))
  1999. </programlisting></informalexample><para>Replaces all occurrences of the pattern in <parameter>regex</parameter> with the
  2000. replacement text. <parameter>replacement</parameter> is replaced literally, to
  2001. include backreferences use <function>g_regex_replace()</function>.
  2002. </para>
  2003. <para>Setting <parameter>start_position</parameter> differs from just passing over a
  2004. shortened string and setting <type>G_REGEX_MATCH_NOTBOL</type> in the
  2005. case of a pattern that begins with any kind of lookbehind
  2006. assertion, such as &quot;\b&quot;.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type> structure</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to perform matches against</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>string_len</para></td><td class="parameter_description"><para>the length of <parameter>string</parameter>, in bytes, or -1 if <parameter>string</parameter> is nul-terminated</para><para>Inferred from <code>string</code></para></td></tr><tr><td class="parameter_name"><para>start_position</para></td><td class="parameter_description"><para>starting index of the string to match, in bytes</para><para>Passed as <code>start-position</code></para></td></tr><tr><td class="parameter_name"><para>replacement</para></td><td class="parameter_description"><para>text to replace each match with</para><para>Passed as <code>replacement</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>options for the match</para><para>Passed as <code>match-options</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>split</title><informalexample><programlisting>(define-values (%return) (regex:split self string match-options))
  2007. </programlisting></informalexample><para>Breaks the string on the pattern, and returns an array of the tokens.
  2008. If the pattern contains capturing parentheses, then the text for each
  2009. of the substrings will also be returned. If the pattern does not match
  2010. anywhere in the string, then the whole string is returned as the first
  2011. token.
  2012. </para>
  2013. <para>As a special case, the result of splitting the empty string &quot;&quot; is an
  2014. empty vector, not a vector containing a single string. The reason for
  2015. this special case is that being able to represent an empty vector is
  2016. typically more useful than consistent handling of empty elements. If
  2017. you do need to represent empty elements, you'll need to check for the
  2018. empty string before calling this function.
  2019. </para>
  2020. <para>A pattern that can match empty strings splits <parameter>string</parameter> into separate
  2021. characters wherever it matches the empty string between characters.
  2022. For example splitting &quot;ab c&quot; using as a separator &quot;\s*&quot;, you will get
  2023. &quot;a&quot;, &quot;b&quot; and &quot;c&quot;.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type> structure</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to split with the pattern</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>match time option flags</para><para>Passed as <code>match-options</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>split-full</title><informalexample><programlisting>(define-values
  2024. (%return)
  2025. (regex:split-full self string start-position match-options max-tokens))
  2026. </programlisting></informalexample><para>Breaks the string on the pattern, and returns an array of the tokens.
  2027. If the pattern contains capturing parentheses, then the text for each
  2028. of the substrings will also be returned. If the pattern does not match
  2029. anywhere in the string, then the whole string is returned as the first
  2030. token.
  2031. </para>
  2032. <para>As a special case, the result of splitting the empty string &quot;&quot; is an
  2033. empty vector, not a vector containing a single string. The reason for
  2034. this special case is that being able to represent an empty vector is
  2035. typically more useful than consistent handling of empty elements. If
  2036. you do need to represent empty elements, you'll need to check for the
  2037. empty string before calling this function.
  2038. </para>
  2039. <para>A pattern that can match empty strings splits <parameter>string</parameter> into separate
  2040. characters wherever it matches the empty string between characters.
  2041. For example splitting &quot;ab c&quot; using as a separator &quot;\s*&quot;, you will get
  2042. &quot;a&quot;, &quot;b&quot; and &quot;c&quot;.
  2043. </para>
  2044. <para>Setting <parameter>start_position</parameter> differs from just passing over a shortened
  2045. string and setting <type>G_REGEX_MATCH_NOTBOL</type> in the case of a pattern
  2046. that begins with any kind of lookbehind assertion, such as &quot;\b&quot;.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type> structure</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to split with the pattern</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>string_len</para></td><td class="parameter_description"><para>the length of <parameter>string</parameter>, in bytes, or -1 if <parameter>string</parameter> is nul-terminated</para><para>Inferred from <code>string</code></para></td></tr><tr><td class="parameter_name"><para>start_position</para></td><td class="parameter_description"><para>starting index of the string to match, in bytes</para><para>Passed as <code>start-position</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>match time option flags</para><para>Passed as <code>match-options</code></para></td></tr><tr><td class="parameter_name"><para>max_tokens</para></td><td class="parameter_description"><para>the maximum number of tokens to split <parameter>string</parameter> into.
  2047. If this is less than 1, the string is split completely</para><para>Passed as <code>max-tokens</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (regex:unref self))
  2048. </programlisting></informalexample><para>Decreases reference count of <parameter>regex</parameter> by 1. When reference count drops
  2049. to zero, it frees all the memory associated with the regex structure.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>regex</para></td><td class="parameter_description"><para>a <type>GRegex</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>regex:new</title><informalexample><programlisting>(define-values (%return) (regex:new pattern compile-options match-options))
  2050. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pattern</para></td><td class="parameter_description"><para></para><para>Passed as <code>pattern</code></para></td></tr><tr><td class="parameter_name"><para>compile_options</para></td><td class="parameter_description"><para></para><para>Passed as <code>compile-options</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para></para><para>Passed as <code>match-options</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>regex:check-replacement</title><informalexample><programlisting>(define-values (%return has-references) (regex:check-replacement replacement))
  2051. </programlisting></informalexample><para>Checks whether <parameter>replacement</parameter> is a valid replacement string
  2052. (see <function>g_regex_replace()</function>), i.e. that all escape sequences in
  2053. it are valid.
  2054. </para>
  2055. <para>If <parameter>has_references</parameter> is not <constant>NULL</constant> then <parameter>replacement</parameter> is checked
  2056. for pattern references. For instance, replacement text 'foo\n'
  2057. does not contain references and may be evaluated without information
  2058. about actual match, but '\0\1' (whole match followed by first
  2059. subpattern) requires valid <type>GMatchInfo</type> object.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>replacement</para></td><td class="parameter_description"><para>the replacement string</para><para>Passed as <code>replacement</code></para></td></tr><tr><td class="parameter_name"><para>has_references</para></td><td class="parameter_description"><para>location to store information about
  2060. references in <parameter>replacement</parameter> or <constant>NULL</constant></para><para>Passed as <code>has-references</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>regex:error-quark</title><informalexample><programlisting>(define-values (%return) (regex:error-quark))
  2061. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>regex:escape-nul</title><informalexample><programlisting>(define-values (%return) (regex:escape-nul string length))
  2062. </programlisting></informalexample><para>Escapes the nul characters in <parameter>string</parameter> to &quot;\x00&quot;. It can be used
  2063. to compile a regex with embedded nul characters.
  2064. </para>
  2065. <para>For completeness, <parameter>length</parameter> can be -1 for a nul-terminated string.
  2066. In this case the output string will be of course equal to <parameter>string</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to escape</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of <parameter>string</parameter></para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>regex:escape-string</title><informalexample><programlisting>(define-values (%return) (regex:escape-string string))
  2067. </programlisting></informalexample><para>Escapes the special characters used for regular expressions
  2068. in <parameter>string</parameter>, for instance &quot;a.b*c&quot; becomes &quot;a\.b\*c&quot;. This
  2069. function is useful to dynamically generate regular expressions.
  2070. </para>
  2071. <para><parameter>string</parameter> can contain nul characters that are replaced with &quot;\0&quot;,
  2072. in this case remember to specify the correct length of <parameter>string</parameter>
  2073. in <parameter>length</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to escape</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of <parameter>string</parameter>, in bytes, or -1 if <parameter>string</parameter> is nul-terminated</para><para>Inferred from <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>regex:match-simple?</title><informalexample><programlisting>(define-values
  2074. (%return)
  2075. (regex:match-simple? pattern string compile-options match-options))
  2076. </programlisting></informalexample><para>Scans for a match in <parameter>string</parameter> for <parameter>pattern</parameter>.
  2077. </para>
  2078. <para>This function is equivalent to <function>g_regex_match()</function> but it does not
  2079. require to compile the pattern with <function>g_regex_new()</function>, avoiding some
  2080. lines of code when you need just to do a match without extracting
  2081. substrings, capture counts, and so on.
  2082. </para>
  2083. <para>If this function is to be called on the same <parameter>pattern</parameter> more than
  2084. once, it's more efficient to compile the pattern once with
  2085. <function>g_regex_new()</function> and then use <function>g_regex_match()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pattern</para></td><td class="parameter_description"><para>the regular expression</para><para>Passed as <code>pattern</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to scan for matches</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>compile_options</para></td><td class="parameter_description"><para>compile options for the regular expression, or 0</para><para>Passed as <code>compile-options</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>match options, or 0</para><para>Passed as <code>match-options</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>regex:split-simple</title><informalexample><programlisting>(define-values
  2086. (%return)
  2087. (regex:split-simple pattern string compile-options match-options))
  2088. </programlisting></informalexample><para>Breaks the string on the pattern, and returns an array of
  2089. the tokens. If the pattern contains capturing parentheses,
  2090. then the text for each of the substrings will also be returned.
  2091. If the pattern does not match anywhere in the string, then the
  2092. whole string is returned as the first token.
  2093. </para>
  2094. <para>This function is equivalent to <function>g_regex_split()</function> but it does
  2095. not require to compile the pattern with <function>g_regex_new()</function>, avoiding
  2096. some lines of code when you need just to do a split without
  2097. extracting substrings, capture counts, and so on.
  2098. </para>
  2099. <para>If this function is to be called on the same <parameter>pattern</parameter> more than
  2100. once, it's more efficient to compile the pattern once with
  2101. <function>g_regex_new()</function> and then use <function>g_regex_split()</function>.
  2102. </para>
  2103. <para>As a special case, the result of splitting the empty string &quot;&quot;
  2104. is an empty vector, not a vector containing a single string.
  2105. The reason for this special case is that being able to represent
  2106. an empty vector is typically more useful than consistent handling
  2107. of empty elements. If you do need to represent empty elements,
  2108. you'll need to check for the empty string before calling this
  2109. function.
  2110. </para>
  2111. <para>A pattern that can match empty strings splits <parameter>string</parameter> into
  2112. separate characters wherever it matches the empty string between
  2113. characters. For example splitting &quot;ab c&quot; using as a separator
  2114. &quot;\s*&quot;, you will get &quot;a&quot;, &quot;b&quot; and &quot;c&quot;.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pattern</para></td><td class="parameter_description"><para>the regular expression</para><para>Passed as <code>pattern</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to scan for matches</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>compile_options</para></td><td class="parameter_description"><para>compile options for the regular expression, or 0</para><para>Passed as <code>compile-options</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>match options, or 0</para><para>Passed as <code>match-options</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibRegexCompileFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags specifying compile-time options.</para></refsect1><refsect1><title>Members</title><refsect2><title>caseless</title><remark>alias <code>G_REGEX_CASELESS</code></remark><para>Letters in the pattern match both upper- and
  2115. lowercase letters. This option can be changed within a pattern
  2116. by a &quot;(?i)&quot; option setting.</para></refsect2><refsect2><title>multiline</title><remark>alias <code>G_REGEX_MULTILINE</code></remark><para>By default, GRegex treats the strings as consisting
  2117. of a single line of characters (even if it actually contains
  2118. newlines). The &quot;start of line&quot; metacharacter (&quot;^&quot;) matches only
  2119. at the start of the string, while the &quot;end of line&quot; metacharacter
  2120. (&quot;$&quot;) matches only at the end of the string, or before a terminating
  2121. newline (unless <type>G_REGEX_DOLLAR_ENDONLY</type> is set). When
  2122. <type>G_REGEX_MULTILINE</type> is set, the &quot;start of line&quot; and &quot;end of line&quot;
  2123. constructs match immediately following or immediately before any
  2124. newline in the string, respectively, as well as at the very start
  2125. and end. This can be changed within a pattern by a &quot;(?m)&quot; option
  2126. setting.</para></refsect2><refsect2><title>dotall</title><remark>alias <code>G_REGEX_DOTALL</code></remark><para>A dot metacharacter (&quot;.&quot;) in the pattern matches all
  2127. characters, including newlines. Without it, newlines are excluded.
  2128. This option can be changed within a pattern by a (&quot;?s&quot;) option setting.</para></refsect2><refsect2><title>extended</title><remark>alias <code>G_REGEX_EXTENDED</code></remark><para>Whitespace data characters in the pattern are
  2129. totally ignored except when escaped or inside a character class.
  2130. Whitespace does not include the VT character (code 11). In addition,
  2131. characters between an unescaped &quot;#&quot; outside a character class and
  2132. the next newline character, inclusive, are also ignored. This can
  2133. be changed within a pattern by a &quot;(?x)&quot; option setting.</para></refsect2><refsect2><title>anchored</title><remark>alias <code>G_REGEX_ANCHORED</code></remark><para>The pattern is forced to be &quot;anchored&quot;, that is,
  2134. it is constrained to match only at the first matching point in the
  2135. string that is being searched. This effect can also be achieved by
  2136. appropriate constructs in the pattern itself such as the &quot;^&quot;
  2137. metacharacter.</para></refsect2><refsect2><title>dollar-endonly</title><remark>alias <code>G_REGEX_DOLLAR_ENDONLY</code></remark><para>A dollar metacharacter (&quot;$&quot;) in the pattern
  2138. matches only at the end of the string. Without this option, a
  2139. dollar also matches immediately before the final character if
  2140. it is a newline (but not before any other newlines). This option
  2141. is ignored if <type>G_REGEX_MULTILINE</type> is set.</para></refsect2><refsect2><title>ungreedy</title><remark>alias <code>G_REGEX_UNGREEDY</code></remark><para>Inverts the &quot;greediness&quot; of the quantifiers so that
  2142. they are not greedy by default, but become greedy if followed by &quot;?&quot;.
  2143. It can also be set by a &quot;(?U)&quot; option setting within the pattern.</para></refsect2><refsect2><title>raw</title><remark>alias <code>G_REGEX_RAW</code></remark><para>Usually strings must be valid UTF-8 strings, using this
  2144. flag they are considered as a raw sequence of bytes.</para></refsect2><refsect2><title>no-auto-capture</title><remark>alias <code>G_REGEX_NO_AUTO_CAPTURE</code></remark><para>Disables the use of numbered capturing
  2145. parentheses in the pattern. Any opening parenthesis that is not
  2146. followed by &quot;?&quot; behaves as if it were followed by &quot;?:&quot; but named
  2147. parentheses can still be used for capturing (and they acquire numbers
  2148. in the usual way).</para></refsect2><refsect2><title>optimize</title><remark>alias <code>G_REGEX_OPTIMIZE</code></remark><para>Optimize the regular expression. If the pattern will
  2149. be used many times, then it may be worth the effort to optimize it
  2150. to improve the speed of matches.</para></refsect2><refsect2><title>firstline</title><remark>alias <code>G_REGEX_FIRSTLINE</code></remark><para>Limits an unanchored pattern to match before (or at) the
  2151. first newline. Since: 2.34</para></refsect2><refsect2><title>dupnames</title><remark>alias <code>G_REGEX_DUPNAMES</code></remark><para>Names used to identify capturing subpatterns need not
  2152. be unique. This can be helpful for certain types of pattern when it
  2153. is known that only one instance of the named subpattern can ever be
  2154. matched.</para></refsect2><refsect2><title>newline-cr</title><remark>alias <code>G_REGEX_NEWLINE_CR</code></remark><para>Usually any newline character or character sequence is
  2155. recognized. If this option is set, the only recognized newline character
  2156. is '\r'.</para></refsect2><refsect2><title>newline-lf</title><remark>alias <code>G_REGEX_NEWLINE_LF</code></remark><para>Usually any newline character or character sequence is
  2157. recognized. If this option is set, the only recognized newline character
  2158. is '\n'.</para></refsect2><refsect2><title>newline-crlf</title><remark>alias <code>G_REGEX_NEWLINE_CRLF</code></remark><para>Usually any newline character or character sequence is
  2159. recognized. If this option is set, the only recognized newline character
  2160. sequence is '\r\n'.</para></refsect2><refsect2><title>newline-anycrlf</title><remark>alias <code>G_REGEX_NEWLINE_ANYCRLF</code></remark><para>Usually any newline character or character sequence
  2161. is recognized. If this option is set, the only recognized newline character
  2162. sequences are '\r', '\n', and '\r\n'. Since: 2.34</para></refsect2><refsect2><title>bsr-anycrlf</title><remark>alias <code>G_REGEX_BSR_ANYCRLF</code></remark><para>Usually any newline character or character sequence
  2163. is recognised. If this option is set, then &quot;\R&quot; only recognizes the newline
  2164. characters '\r', '\n' and '\r\n'. Since: 2.34</para></refsect2><refsect2><title>javascript-compat</title><remark>alias <code>G_REGEX_JAVASCRIPT_COMPAT</code></remark><para>Changes behaviour so that it is compatible with
  2165. JavaScript rather than PCRE. Since: 2.34</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibRegexError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by regular expressions functions.</para></refsect1><refsect1><title>Members</title><refsect2><title>compile</title><remark>alias <code>G_REGEX_ERROR_COMPILE</code></remark><para>Compilation of the regular expression failed.</para></refsect2><refsect2><title>optimize</title><remark>alias <code>G_REGEX_ERROR_OPTIMIZE</code></remark><para>Optimization of the regular expression failed.</para></refsect2><refsect2><title>replace</title><remark>alias <code>G_REGEX_ERROR_REPLACE</code></remark><para>Replacement failed due to an ill-formed replacement
  2166. string.</para></refsect2><refsect2><title>match</title><remark>alias <code>G_REGEX_ERROR_MATCH</code></remark><para>The match process failed.</para></refsect2><refsect2><title>internal</title><remark>alias <code>G_REGEX_ERROR_INTERNAL</code></remark><para>Internal error of the regular expression engine.
  2167. Since 2.16</para></refsect2><refsect2><title>stray-backslash</title><remark>alias <code>G_REGEX_ERROR_STRAY_BACKSLASH</code></remark><para>&quot;\\&quot; at end of pattern. Since 2.16</para></refsect2><refsect2><title>missing-control-char</title><remark>alias <code>G_REGEX_ERROR_MISSING_CONTROL_CHAR</code></remark><para>&quot;\\c&quot; at end of pattern. Since 2.16</para></refsect2><refsect2><title>unrecognized-escape</title><remark>alias <code>G_REGEX_ERROR_UNRECOGNIZED_ESCAPE</code></remark><para>Unrecognized character follows &quot;\\&quot;.
  2168. Since 2.16</para></refsect2><refsect2><title>quantifiers-out-of-order</title><remark>alias <code>G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER</code></remark><para>Numbers out of order in &quot;{}&quot;
  2169. quantifier. Since 2.16</para></refsect2><refsect2><title>quantifier-too-big</title><remark>alias <code>G_REGEX_ERROR_QUANTIFIER_TOO_BIG</code></remark><para>Number too big in &quot;{}&quot; quantifier.
  2170. Since 2.16</para></refsect2><refsect2><title>unterminated-character-class</title><remark>alias <code>G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS</code></remark><para>Missing terminating &quot;]&quot; for
  2171. character class. Since 2.16</para></refsect2><refsect2><title>invalid-escape-in-character-class</title><remark>alias <code>G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS</code></remark><para>Invalid escape sequence
  2172. in character class. Since 2.16</para></refsect2><refsect2><title>range-out-of-order</title><remark>alias <code>G_REGEX_ERROR_RANGE_OUT_OF_ORDER</code></remark><para>Range out of order in character class.
  2173. Since 2.16</para></refsect2><refsect2><title>nothing-to-repeat</title><remark>alias <code>G_REGEX_ERROR_NOTHING_TO_REPEAT</code></remark><para>Nothing to repeat. Since 2.16</para></refsect2><refsect2><title>unrecognized-character</title><remark>alias <code>G_REGEX_ERROR_UNRECOGNIZED_CHARACTER</code></remark><para>Unrecognized character after &quot;(?&quot;,
  2174. &quot;(?&lt;&quot; or &quot;(?P&quot;. Since 2.16</para></refsect2><refsect2><title>posix-named-class-outside-class</title><remark>alias <code>G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS</code></remark><para>POSIX named classes are
  2175. supported only within a class. Since 2.16</para></refsect2><refsect2><title>unmatched-parenthesis</title><remark>alias <code>G_REGEX_ERROR_UNMATCHED_PARENTHESIS</code></remark><para>Missing terminating &quot;)&quot; or &quot;)&quot;
  2176. without opening &quot;(&quot;. Since 2.16</para></refsect2><refsect2><title>inexistent-subpattern-reference</title><remark>alias <code>G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE</code></remark><para>Reference to non-existent
  2177. subpattern. Since 2.16</para></refsect2><refsect2><title>unterminated-comment</title><remark>alias <code>G_REGEX_ERROR_UNTERMINATED_COMMENT</code></remark><para>Missing terminating &quot;)&quot; after comment.
  2178. Since 2.16</para></refsect2><refsect2><title>expression-too-large</title><remark>alias <code>G_REGEX_ERROR_EXPRESSION_TOO_LARGE</code></remark><para>Regular expression too large.
  2179. Since 2.16</para></refsect2><refsect2><title>memory-error</title><remark>alias <code>G_REGEX_ERROR_MEMORY_ERROR</code></remark><para>Failed to get memory. Since 2.16</para></refsect2><refsect2><title>variable-length-lookbehind</title><remark>alias <code>G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND</code></remark><para>Lookbehind assertion is not
  2180. fixed length. Since 2.16</para></refsect2><refsect2><title>malformed-condition</title><remark>alias <code>G_REGEX_ERROR_MALFORMED_CONDITION</code></remark><para>Malformed number or name after &quot;(?(&quot;.
  2181. Since 2.16</para></refsect2><refsect2><title>too-many-conditional-branches</title><remark>alias <code>G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES</code></remark><para>Conditional group contains
  2182. more than two branches. Since 2.16</para></refsect2><refsect2><title>assertion-expected</title><remark>alias <code>G_REGEX_ERROR_ASSERTION_EXPECTED</code></remark><para>Assertion expected after &quot;(?(&quot;.
  2183. Since 2.16</para></refsect2><refsect2><title>unknown-posix-class-name</title><remark>alias <code>G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME</code></remark><para>Unknown POSIX class name.
  2184. Since 2.16</para></refsect2><refsect2><title>posix-collating-elements-not-supported</title><remark>alias <code>G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED</code></remark><para>POSIX collating
  2185. elements are not supported. Since 2.16</para></refsect2><refsect2><title>hex-code-too-large</title><remark>alias <code>G_REGEX_ERROR_HEX_CODE_TOO_LARGE</code></remark><para>Character value in &quot;\\x{...}&quot; sequence
  2186. is too large. Since 2.16</para></refsect2><refsect2><title>invalid-condition</title><remark>alias <code>G_REGEX_ERROR_INVALID_CONDITION</code></remark><para>Invalid condition &quot;(?(0)&quot;. Since 2.16</para></refsect2><refsect2><title>single-byte-match-in-lookbehind</title><remark>alias <code>G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND</code></remark><para>\\C not allowed in
  2187. lookbehind assertion. Since 2.16</para></refsect2><refsect2><title>infinite-loop</title><remark>alias <code>G_REGEX_ERROR_INFINITE_LOOP</code></remark><para>Recursive call could loop indefinitely.
  2188. Since 2.16</para></refsect2><refsect2><title>missing-subpattern-name-terminator</title><remark>alias <code>G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR</code></remark><para>Missing terminator
  2189. in subpattern name. Since 2.16</para></refsect2><refsect2><title>duplicate-subpattern-name</title><remark>alias <code>G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME</code></remark><para>Two named subpatterns have
  2190. the same name. Since 2.16</para></refsect2><refsect2><title>malformed-property</title><remark>alias <code>G_REGEX_ERROR_MALFORMED_PROPERTY</code></remark><para>Malformed &quot;\\P&quot; or &quot;\\p&quot; sequence.
  2191. Since 2.16</para></refsect2><refsect2><title>unknown-property</title><remark>alias <code>G_REGEX_ERROR_UNKNOWN_PROPERTY</code></remark><para>Unknown property name after &quot;\\P&quot; or
  2192. &quot;\\p&quot;. Since 2.16</para></refsect2><refsect2><title>subpattern-name-too-long</title><remark>alias <code>G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG</code></remark><para>Subpattern name is too long
  2193. (maximum 32 characters). Since 2.16</para></refsect2><refsect2><title>too-many-subpatterns</title><remark>alias <code>G_REGEX_ERROR_TOO_MANY_SUBPATTERNS</code></remark><para>Too many named subpatterns (maximum
  2194. 10,000). Since 2.16</para></refsect2><refsect2><title>invalid-octal-value</title><remark>alias <code>G_REGEX_ERROR_INVALID_OCTAL_VALUE</code></remark><para>Octal value is greater than &quot;\\377&quot;.
  2195. Since 2.16</para></refsect2><refsect2><title>too-many-branches-in-define</title><remark>alias <code>G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE</code></remark><para>&quot;DEFINE&quot; group contains more
  2196. than one branch. Since 2.16</para></refsect2><refsect2><title>define-repetion</title><remark>alias <code>G_REGEX_ERROR_DEFINE_REPETION</code></remark><para>Repeating a &quot;DEFINE&quot; group is not allowed.
  2197. This error is never raised. Since: 2.16 Deprecated: 2.34</para></refsect2><refsect2><title>inconsistent-newline-options</title><remark>alias <code>G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS</code></remark><para>Inconsistent newline options.
  2198. Since 2.16</para></refsect2><refsect2><title>missing-back-reference</title><remark>alias <code>G_REGEX_ERROR_MISSING_BACK_REFERENCE</code></remark><para>&quot;\\g&quot; is not followed by a braced,
  2199. angle-bracketed, or quoted name or number, or by a plain number. Since: 2.16</para></refsect2><refsect2><title>invalid-relative-reference</title><remark>alias <code>G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE</code></remark><para>relative reference must not be zero. Since: 2.34</para></refsect2><refsect2><title>backtracking-control-verb-argument-forbidden</title><remark>alias <code>G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN</code></remark><para>the backtracing
  2200. control verb used does not allow an argument. Since: 2.34</para></refsect2><refsect2><title>unknown-backtracking-control-verb</title><remark>alias <code>G_REGEX_ERROR_UNKNOWN_BACKTRACKING_CONTROL_VERB</code></remark><para>unknown backtracing
  2201. control verb. Since: 2.34</para></refsect2><refsect2><title>number-too-big</title><remark>alias <code>G_REGEX_ERROR_NUMBER_TOO_BIG</code></remark><para>number is too big in escape sequence. Since: 2.34</para></refsect2><refsect2><title>missing-subpattern-name</title><remark>alias <code>G_REGEX_ERROR_MISSING_SUBPATTERN_NAME</code></remark><para>Missing subpattern name. Since: 2.34</para></refsect2><refsect2><title>missing-digit</title><remark>alias <code>G_REGEX_ERROR_MISSING_DIGIT</code></remark><para>Missing digit. Since 2.34</para></refsect2><refsect2><title>invalid-data-character</title><remark>alias <code>G_REGEX_ERROR_INVALID_DATA_CHARACTER</code></remark><para>In JavaScript compatibility mode,
  2202. &quot;[&quot; is an invalid data character. Since: 2.34</para></refsect2><refsect2><title>extra-subpattern-name</title><remark>alias <code>G_REGEX_ERROR_EXTRA_SUBPATTERN_NAME</code></remark><para>different names for subpatterns of the
  2203. same number are not allowed. Since: 2.34</para></refsect2><refsect2><title>backtracking-control-verb-argument-required</title><remark>alias <code>G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED</code></remark><para>the backtracing control
  2204. verb requires an argument. Since: 2.34</para></refsect2><refsect2><title>invalid-control-char</title><remark>alias <code>G_REGEX_ERROR_INVALID_CONTROL_CHAR</code></remark><para>&quot;\\c&quot; must be followed by an ASCII
  2205. character. Since: 2.34</para></refsect2><refsect2><title>missing-name</title><remark>alias <code>G_REGEX_ERROR_MISSING_NAME</code></remark><para>&quot;\\k&quot; is not followed by a braced, angle-bracketed, or
  2206. quoted name. Since: 2.34</para></refsect2><refsect2><title>not-supported-in-class</title><remark>alias <code>G_REGEX_ERROR_NOT_SUPPORTED_IN_CLASS</code></remark><para>&quot;\\N&quot; is not supported in a class. Since: 2.34</para></refsect2><refsect2><title>too-many-forward-references</title><remark>alias <code>G_REGEX_ERROR_TOO_MANY_FORWARD_REFERENCES</code></remark><para>too many forward references. Since: 2.34</para></refsect2><refsect2><title>name-too-long</title><remark>alias <code>G_REGEX_ERROR_NAME_TOO_LONG</code></remark><para>the name is too long in &quot;(*MARK)&quot;, &quot;(*PRUNE)&quot;,
  2207. &quot;(*SKIP)&quot;, or &quot;(*THEN)&quot;. Since: 2.34</para></refsect2><refsect2><title>character-value-too-large</title><remark>alias <code>G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE</code></remark><para>the character value in the \\u sequence is
  2208. too large. Since: 2.34</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibRegexMatchFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags specifying match-time options.</para></refsect1><refsect1><title>Members</title><refsect2><title>anchored</title><remark>alias <code>G_REGEX_MATCH_ANCHORED</code></remark><para>The pattern is forced to be &quot;anchored&quot;, that is,
  2209. it is constrained to match only at the first matching point in the
  2210. string that is being searched. This effect can also be achieved by
  2211. appropriate constructs in the pattern itself such as the &quot;^&quot;
  2212. metacharacter.</para></refsect2><refsect2><title>notbol</title><remark>alias <code>G_REGEX_MATCH_NOTBOL</code></remark><para>Specifies that first character of the string is
  2213. not the beginning of a line, so the circumflex metacharacter should
  2214. not match before it. Setting this without <type>G_REGEX_MULTILINE</type> (at
  2215. compile time) causes circumflex never to match. This option affects
  2216. only the behaviour of the circumflex metacharacter, it does not
  2217. affect &quot;\A&quot;.</para></refsect2><refsect2><title>noteol</title><remark>alias <code>G_REGEX_MATCH_NOTEOL</code></remark><para>Specifies that the end of the subject string is
  2218. not the end of a line, so the dollar metacharacter should not match
  2219. it nor (except in multiline mode) a newline immediately before it.
  2220. Setting this without <type>G_REGEX_MULTILINE</type> (at compile time) causes
  2221. dollar never to match. This option affects only the behaviour of
  2222. the dollar metacharacter, it does not affect &quot;\Z&quot; or &quot;\z&quot;.</para></refsect2><refsect2><title>notempty</title><remark>alias <code>G_REGEX_MATCH_NOTEMPTY</code></remark><para>An empty string is not considered to be a valid
  2223. match if this option is set. If there are alternatives in the pattern,
  2224. they are tried. If all the alternatives match the empty string, the
  2225. entire match fails. For example, if the pattern &quot;a?b?&quot; is applied to
  2226. a string not beginning with &quot;a&quot; or &quot;b&quot;, it matches the empty string
  2227. at the start of the string. With this flag set, this match is not
  2228. valid, so GRegex searches further into the string for occurrences
  2229. of &quot;a&quot; or &quot;b&quot;.</para></refsect2><refsect2><title>partial</title><remark>alias <code>G_REGEX_MATCH_PARTIAL</code></remark><para>Turns on the partial matching feature, for more
  2230. documentation on partial matching see <function>g_match_info_is_partial_match()</function>.</para></refsect2><refsect2><title>newline-cr</title><remark>alias <code>G_REGEX_MATCH_NEWLINE_CR</code></remark><para>Overrides the newline definition set when
  2231. creating a new <type>GRegex</type>, setting the '\r' character as line terminator.</para></refsect2><refsect2><title>newline-lf</title><remark>alias <code>G_REGEX_MATCH_NEWLINE_LF</code></remark><para>Overrides the newline definition set when
  2232. creating a new <type>GRegex</type>, setting the '\n' character as line terminator.</para></refsect2><refsect2><title>newline-crlf</title><remark>alias <code>G_REGEX_MATCH_NEWLINE_CRLF</code></remark><para>Overrides the newline definition set when
  2233. creating a new <type>GRegex</type>, setting the '\r\n' characters sequence as line terminator.</para></refsect2><refsect2><title>newline-any</title><remark>alias <code>G_REGEX_MATCH_NEWLINE_ANY</code></remark><para>Overrides the newline definition set when
  2234. creating a new <type>GRegex</type>, any Unicode newline sequence
  2235. is recognised as a newline. These are '\r', '\n' and '\rn', and the
  2236. single characters U+000B LINE TABULATION, U+000C FORM FEED (FF),
  2237. U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and
  2238. U+2029 PARAGRAPH SEPARATOR.</para></refsect2><refsect2><title>newline-anycrlf</title><remark>alias <code>G_REGEX_MATCH_NEWLINE_ANYCRLF</code></remark><para>Overrides the newline definition set when
  2239. creating a new <type>GRegex</type>; any '\r', '\n', or '\r\n' character sequence
  2240. is recognized as a newline. Since: 2.34</para></refsect2><refsect2><title>bsr-anycrlf</title><remark>alias <code>G_REGEX_MATCH_BSR_ANYCRLF</code></remark><para>Overrides the newline definition for &quot;\R&quot; set when
  2241. creating a new <type>GRegex</type>; only '\r', '\n', or '\r\n' character sequences
  2242. are recognized as a newline by &quot;\R&quot;. Since: 2.34</para></refsect2><refsect2><title>bsr-any</title><remark>alias <code>G_REGEX_MATCH_BSR_ANY</code></remark><para>Overrides the newline definition for &quot;\R&quot; set when
  2243. creating a new <type>GRegex</type>; any Unicode newline character or character sequence
  2244. are recognized as a newline by &quot;\R&quot;. These are '\r', '\n' and '\rn', and the
  2245. single characters U+000B LINE TABULATION, U+000C FORM FEED (FF),
  2246. U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and
  2247. U+2029 PARAGRAPH SEPARATOR. Since: 2.34</para></refsect2><refsect2><title>partial-soft</title><remark>alias <code>G_REGEX_MATCH_PARTIAL_SOFT</code></remark><para>An alias for <type>G_REGEX_MATCH_PARTIAL</type>. Since: 2.34</para></refsect2><refsect2><title>partial-hard</title><remark>alias <code>G_REGEX_MATCH_PARTIAL_HARD</code></remark><para>Turns on the partial matching feature. In contrast to
  2248. to <type>G_REGEX_MATCH_PARTIAL_SOFT</type>, this stops matching as soon as a partial match
  2249. is found, without continuing to search for a possible complete match. See
  2250. <function>g_match_info_is_partial_match()</function> for more information. Since: 2.34</para></refsect2><refsect2><title>notempty-atstart</title><remark>alias <code>G_REGEX_MATCH_NOTEMPTY_ATSTART</code></remark><para>Like <type>G_REGEX_MATCH_NOTEMPTY</type>, but only applied to
  2251. the start of the matched string. For anchored
  2252. patterns this can only happen for pattern containing &quot;\K&quot;. Since: 2.34</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibSeekType&gt;</refname></refnamediv><refsect1><title>Description</title><para>An enumeration specifying the base position for a
  2253. <function>g_io_channel_seek_position()</function> operation.</para></refsect1><refsect1><title>Members</title><refsect2><title>cur</title><remark>alias <code>G_SEEK_CUR</code></remark><para>the current position in the file.</para></refsect2><refsect2><title>set</title><remark>alias <code>G_SEEK_SET</code></remark><para>the start of the file.</para></refsect2><refsect2><title>end</title><remark>alias <code>G_SEEK_END</code></remark><para>the end of the file.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibShellError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by shell functions.</para></refsect1><refsect1><title>Members</title><refsect2><title>bad-quoting</title><remark>alias <code>G_SHELL_ERROR_BAD_QUOTING</code></remark><para>Mismatched or otherwise mangled quoting.</para></refsect2><refsect2><title>empty-string</title><remark>alias <code>G_SHELL_ERROR_EMPTY_STRING</code></remark><para>String to be parsed was empty.</para></refsect2><refsect2><title>failed</title><remark>alias <code>G_SHELL_ERROR_FAILED</code></remark><para>Some other error.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibSliceConfig&gt;</refname></refnamediv><refsect1><title>Members</title><refsect2><title>always-malloc</title><remark>alias <code>G_SLICE_CONFIG_ALWAYS_MALLOC</code></remark><para>Undocumented</para></refsect2><refsect2><title>bypass-magazines</title><remark>alias <code>G_SLICE_CONFIG_BYPASS_MAGAZINES</code></remark><para>Undocumented</para></refsect2><refsect2><title>working-set-msecs</title><remark>alias <code>G_SLICE_CONFIG_WORKING_SET_MSECS</code></remark><para>Undocumented</para></refsect2><refsect2><title>color-increment</title><remark>alias <code>G_SLICE_CONFIG_COLOR_INCREMENT</code></remark><para>Undocumented</para></refsect2><refsect2><title>chunk-sizes</title><remark>alias <code>G_SLICE_CONFIG_CHUNK_SIZES</code></remark><para>Undocumented</para></refsect2><refsect2><title>contention-counter</title><remark>alias <code>G_SLICE_CONFIG_CONTENTION_COUNTER</code></remark><para>Undocumented</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GSource&gt;</refname></refnamediv><refsect1><title>Description</title><para>The <code>GSource</code> struct is an opaque data type
  2254. representing an event source.</para></refsect1><refsect1><title>Functions</title><refsect2><title>add-child-source</title><informalexample><programlisting>(define-values () (source:add-child-source self child-source))
  2255. </programlisting></informalexample><para>Adds <parameter>child_source</parameter> to <parameter>source</parameter> as a &quot;polled&quot; source; when <parameter>source</parameter> is
  2256. added to a <type>GMainContext</type>, <parameter>child_source</parameter> will be automatically added
  2257. with the same priority, when <parameter>child_source</parameter> is triggered, it will
  2258. cause <parameter>source</parameter> to dispatch (in addition to calling its own
  2259. callback), and when <parameter>source</parameter> is destroyed, it will destroy
  2260. <parameter>child_source</parameter> as well. (<parameter>source</parameter> will also still be dispatched if
  2261. its own prepare/check functions indicate that it is ready.)
  2262. </para>
  2263. <para>If you don't need <parameter>child_source</parameter> to do anything on its own when it
  2264. triggers, you can call <function>g_source_set_dummy_callback()</function> on it to set a
  2265. callback that does nothing (except return <constant>TRUE</constant> if appropriate).
  2266. </para>
  2267. <para><parameter>source</parameter> will hold a reference on <parameter>child_source</parameter> while <parameter>child_source</parameter>
  2268. is attached to it.
  2269. </para>
  2270. <para>This API is only intended to be used by implementations of <type>GSource</type>.
  2271. Do not call this API on a <type>GSource</type> that you did not create.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>child_source</para></td><td class="parameter_description"><para>a second <type>GSource</type> that <parameter>source</parameter> should &quot;poll&quot;</para><para>Passed as <code>child-source</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-poll</title><informalexample><programlisting>(define-values () (source:add-poll self fd))
  2272. </programlisting></informalexample><para>Adds a file descriptor to the set of file descriptors polled for
  2273. this source. This is usually combined with <function>g_source_new()</function> to add an
  2274. event source. The event source's check function will typically test
  2275. the <parameter>revents</parameter> field in the <type>GPollFD</type> struct and return <constant>TRUE</constant> if events need
  2276. to be processed.
  2277. </para>
  2278. <para>This API is only intended to be used by implementations of <type>GSource</type>.
  2279. Do not call this API on a <type>GSource</type> that you did not create.
  2280. </para>
  2281. <para>Using this API forces the linear scanning of event sources on each
  2282. main loop iteration. Newly-written event sources should try to use
  2283. <function>g_source_add_unix_fd()</function> instead of this API.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>fd</para></td><td class="parameter_description"><para>a <type>GPollFD</type> structure holding information about a file
  2284. descriptor to watch.</para><para>Passed as <code>fd</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>add-unix-fd</title><informalexample><programlisting>(define-values (%return) (source:add-unix-fd self fd events))
  2285. </programlisting></informalexample><para>Monitors <parameter>fd</parameter> for the IO events in <parameter>events</parameter>.
  2286. </para>
  2287. <para>The tag returned by this function can be used to remove or modify the
  2288. monitoring of the fd using <function>g_source_remove_unix_fd()</function> or
  2289. <function>g_source_modify_unix_fd()</function>.
  2290. </para>
  2291. <para>It is not necessary to remove the fd before destroying the source; it
  2292. will be cleaned up automatically.
  2293. </para>
  2294. <para>This API is only intended to be used by implementations of <type>GSource</type>.
  2295. Do not call this API on a <type>GSource</type> that you did not create.
  2296. </para>
  2297. <para>As the name suggests, this function is not available on Windows.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>fd</para></td><td class="parameter_description"><para>the fd to monitor</para><para>Passed as <code>fd</code></para></td></tr><tr><td class="parameter_name"><para>events</para></td><td class="parameter_description"><para>an event mask</para><para>Passed as <code>events</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>attach</title><informalexample><programlisting>(define-values (%return) (source:attach self context))
  2298. </programlisting></informalexample><para>Adds a <type>GSource</type> to a <parameter>context</parameter> so that it will be executed within
  2299. that context. Remove it by calling <function>g_source_destroy()</function>.
  2300. </para>
  2301. <para>This function is safe to call from any thread, regardless of which thread
  2302. the <parameter>context</parameter> is running in.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>a <type>GMainContext</type> (if <constant>NULL</constant>, the default context will be used)</para><para>Passed as <code>context</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>destroy</title><informalexample><programlisting>(define-values () (source:destroy self))
  2303. </programlisting></informalexample><para>Removes a source from its <type>GMainContext</type>, if any, and mark it as
  2304. destroyed. The source cannot be subsequently added to another
  2305. context. It is safe to call this on sources which have already been
  2306. removed from their context.
  2307. </para>
  2308. <para>This does not unref the #GSource: if you still hold a reference, use
  2309. <function>g_source_unref()</function> to drop it.
  2310. </para>
  2311. <para>This function is safe to call from any thread, regardless of which thread
  2312. the <type>GMainContext</type> is running in.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-can-recurse?</title><informalexample><programlisting>(define-values (%return) (source:get-can-recurse? self))
  2313. </programlisting></informalexample><para>Checks whether a source is allowed to be called recursively.
  2314. see <function>g_source_set_can_recurse()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-context</title><informalexample><programlisting>(define-values (%return) (source:get-context self))
  2315. </programlisting></informalexample><para>Gets the <type>GMainContext</type> with which the source is associated.
  2316. </para>
  2317. <para>You can call this on a source that has been destroyed, provided
  2318. that the <type>GMainContext</type> it was attached to still exists (in which
  2319. case it will return that <type>GMainContext</type>). In particular, you can
  2320. always call this function on the source returned from
  2321. <function>g_main_current_source()</function>. But calling this function on a source
  2322. whose <type>GMainContext</type> has been destroyed is an error.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-id</title><informalexample><programlisting>(define-values (%return) (source:get-id self))
  2323. </programlisting></informalexample><para>Returns the numeric ID for a particular source. The ID of a source
  2324. is a positive integer which is unique within a particular main loop
  2325. context. The reverse
  2326. mapping from ID to source is done by <function>g_main_context_find_source_by_id()</function>.
  2327. </para>
  2328. <para>You can only call this function while the source is associated to a
  2329. <type>GMainContext</type> instance; calling this function before <function>g_source_attach()</function>
  2330. or after <function>g_source_destroy()</function> yields undefined behavior. The ID returned
  2331. is unique within the <type>GMainContext</type> instance passed to <function>g_source_attach()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-name</title><informalexample><programlisting>(define-values (%return) (source:get-name self))
  2332. </programlisting></informalexample><para>Gets a name for the source, used in debugging and profiling. The
  2333. name may be <type>NULL</type> if it has never been set with <function>g_source_set_name()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-priority</title><informalexample><programlisting>(define-values (%return) (source:get-priority self))
  2334. </programlisting></informalexample><para>Gets the priority of a source.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-ready-time</title><informalexample><programlisting>(define-values (%return) (source:get-ready-time self))
  2335. </programlisting></informalexample><para>Gets the &quot;ready time&quot; of <parameter>source</parameter>, as set by
  2336. <function>g_source_set_ready_time()</function>.
  2337. </para>
  2338. <para>Any time before the current monotonic time (including 0) is an
  2339. indication that the source will fire immediately.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-time</title><informalexample><programlisting>(define-values (%return) (source:get-time self))
  2340. </programlisting></informalexample><para>Gets the time to be used when checking this source. The advantage of
  2341. calling this function over calling <function>g_get_monotonic_time()</function> directly is
  2342. that when checking multiple sources, GLib can cache a single value
  2343. instead of having to repeatedly get the system monotonic time.
  2344. </para>
  2345. <para>The time here is the system monotonic time, if available, or some
  2346. other reasonable alternative otherwise. See <function>g_get_monotonic_time()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-destroyed?</title><informalexample><programlisting>(define-values (%return) (source:is-destroyed? self))
  2347. </programlisting></informalexample><para>Returns whether <parameter>source</parameter> has been destroyed.
  2348. </para>
  2349. <para>This is important when you operate upon your objects
  2350. from within idle handlers, but may have freed the object
  2351. before the dispatch of your idle handler.
  2352. </para>
  2353. <para><informalexample><programlisting>
  2354. static gboolean
  2355. idle_callback (gpointer data)
  2356. {
  2357. SomeWidget *self = data;
  2358. GDK_THREADS_ENTER ();
  2359. // do stuff with self
  2360. self-&gt;idle_id = 0;
  2361. GDK_THREADS_LEAVE ();
  2362. return G_SOURCE_REMOVE;
  2363. }
  2364. static void
  2365. some_widget_do_stuff_later (SomeWidget *self)
  2366. {
  2367. self-&gt;idle_id = g_idle_add (idle_callback, self);
  2368. }
  2369. static void
  2370. some_widget_finalize (GObject *object)
  2371. {
  2372. SomeWidget *self = SOME_WIDGET (object);
  2373. if (self-&gt;idle_id)
  2374. g_source_remove (self-&gt;idle_id);
  2375. G_OBJECT_CLASS (parent_class)-&gt;finalize (object);
  2376. }
  2377. </programlisting></informalexample></para>
  2378. <para>This will fail in a multi-threaded application if the
  2379. widget is destroyed before the idle handler fires due
  2380. to the use after free in the callback. A solution, to
  2381. this particular problem, is to check to if the source
  2382. has already been destroy within the callback.
  2383. </para>
  2384. <para><informalexample><programlisting>
  2385. static gboolean
  2386. idle_callback (gpointer data)
  2387. {
  2388. SomeWidget *self = data;
  2389. GDK_THREADS_ENTER ();
  2390. if (!g_source_is_destroyed (g_main_current_source ()))
  2391. {
  2392. // do stuff with self
  2393. }
  2394. GDK_THREADS_LEAVE ();
  2395. return FALSE;
  2396. }
  2397. </programlisting></informalexample></para>
  2398. <para>Calls to this function from a thread other than the one acquired by the
  2399. <type>GMainContext</type> the <type>GSource</type> is attached to are typically redundant, as the
  2400. source could be destroyed immediately after this function returns. However,
  2401. once a source is destroyed it cannot be un-destroyed, so this function can be
  2402. used for opportunistic checks from any thread.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>modify-unix-fd</title><informalexample><programlisting>(define-values () (source:modify-unix-fd self tag new-events))
  2403. </programlisting></informalexample><para>Updates the event mask to watch for the fd identified by <parameter>tag</parameter>.
  2404. </para>
  2405. <para><parameter>tag</parameter> is the tag returned from <function>g_source_add_unix_fd()</function>.
  2406. </para>
  2407. <para>If you want to remove a fd, don't set its event mask to zero.
  2408. Instead, call <function>g_source_remove_unix_fd()</function>.
  2409. </para>
  2410. <para>This API is only intended to be used by implementations of <type>GSource</type>.
  2411. Do not call this API on a <type>GSource</type> that you did not create.
  2412. </para>
  2413. <para>As the name suggests, this function is not available on Windows.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>tag</para></td><td class="parameter_description"><para>the tag from <function>g_source_add_unix_fd()</function></para><para>Passed as <code>tag</code></para></td></tr><tr><td class="parameter_name"><para>new_events</para></td><td class="parameter_description"><para>the new event mask to watch</para><para>Passed as <code>new-events</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>query-unix-fd</title><informalexample><programlisting>(define-values (%return) (source:query-unix-fd self tag))
  2414. </programlisting></informalexample><para>Queries the events reported for the fd corresponding to <parameter>tag</parameter> on
  2415. <parameter>source</parameter> during the last poll.
  2416. </para>
  2417. <para>The return value of this function is only defined when the function
  2418. is called from the check or dispatch functions for <parameter>source</parameter>.
  2419. </para>
  2420. <para>This API is only intended to be used by implementations of <type>GSource</type>.
  2421. Do not call this API on a <type>GSource</type> that you did not create.
  2422. </para>
  2423. <para>As the name suggests, this function is not available on Windows.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>tag</para></td><td class="parameter_description"><para>the tag from <function>g_source_add_unix_fd()</function></para><para>Passed as <code>tag</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (source:ref self))
  2424. </programlisting></informalexample><para>Increases the reference count on a source by one.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>remove-child-source</title><informalexample><programlisting>(define-values () (source:remove-child-source self child-source))
  2425. </programlisting></informalexample><para>Detaches <parameter>child_source</parameter> from <parameter>source</parameter> and destroys it.
  2426. </para>
  2427. <para>This API is only intended to be used by implementations of <type>GSource</type>.
  2428. Do not call this API on a <type>GSource</type> that you did not create.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>child_source</para></td><td class="parameter_description"><para>a <type>GSource</type> previously passed to
  2429. <function>g_source_add_child_source()</function>.</para><para>Passed as <code>child-source</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>remove-poll</title><informalexample><programlisting>(define-values () (source:remove-poll self fd))
  2430. </programlisting></informalexample><para>Removes a file descriptor from the set of file descriptors polled for
  2431. this source.
  2432. </para>
  2433. <para>This API is only intended to be used by implementations of <type>GSource</type>.
  2434. Do not call this API on a <type>GSource</type> that you did not create.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>fd</para></td><td class="parameter_description"><para>a <type>GPollFD</type> structure previously passed to <function>g_source_add_poll()</function>.</para><para>Passed as <code>fd</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>remove-unix-fd</title><informalexample><programlisting>(define-values () (source:remove-unix-fd self tag))
  2435. </programlisting></informalexample><para>Reverses the effect of a previous call to <function>g_source_add_unix_fd()</function>.
  2436. </para>
  2437. <para>You only need to call this if you want to remove an fd from being
  2438. watched while keeping the same source around. In the normal case you
  2439. will just want to destroy the source.
  2440. </para>
  2441. <para>This API is only intended to be used by implementations of <type>GSource</type>.
  2442. Do not call this API on a <type>GSource</type> that you did not create.
  2443. </para>
  2444. <para>As the name suggests, this function is not available on Windows.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>tag</para></td><td class="parameter_description"><para>the tag from <function>g_source_add_unix_fd()</function></para><para>Passed as <code>tag</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-callback</title><informalexample><programlisting>(define-values () (source:set-callback self func data notify))
  2445. </programlisting></informalexample><para>Sets the callback function for a source. The callback for a source is
  2446. called from the source's dispatch function.
  2447. </para>
  2448. <para>The exact type of <parameter>func</parameter> depends on the type of source; ie. you
  2449. should not count on <parameter>func</parameter> being called with <parameter>data</parameter> as its first
  2450. parameter. Cast <parameter>func</parameter> with <function>G_SOURCE_FUNC()</function> to avoid warnings about
  2451. incompatible function types.
  2452. </para>
  2453. <para>See [memory management of sources][mainloop-memory-management] for details
  2454. on how to handle memory management of <parameter>data</parameter>.
  2455. </para>
  2456. <para>Typically, you won't use this function. Instead use functions specific
  2457. to the type of source you are using, such as <function>g_idle_add()</function> or <function>g_timeout_add()</function>.
  2458. </para>
  2459. <para>It is safe to call this function multiple times on a source which has already
  2460. been attached to a context. The changes will take effect for the next time
  2461. the source is dispatched after this call returns.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>the source</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para>a callback function</para><para>Passed as <code>func</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>the data to pass to callback function</para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>notify</para></td><td class="parameter_description"><para>a function to call when <parameter>data</parameter> is no longer in use, or <constant>NULL</constant>.</para><para>Passed as <code>notify</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-can-recurse</title><informalexample><programlisting>(define-values () (source:set-can-recurse self can-recurse))
  2462. </programlisting></informalexample><para>Sets whether a source can be called recursively. If <parameter>can_recurse</parameter> is
  2463. <constant>TRUE</constant>, then while the source is being dispatched then this source
  2464. will be processed normally. Otherwise, all processing of this
  2465. source is blocked until the dispatch function returns.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>can_recurse</para></td><td class="parameter_description"><para>whether recursion is allowed for this source</para><para>Passed as <code>can-recurse</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-name</title><informalexample><programlisting>(define-values () (source:set-name self name))
  2466. </programlisting></informalexample><para>Sets a name for the source, used in debugging and profiling.
  2467. The name defaults to <type>NULL</type>.
  2468. </para>
  2469. <para>The source name should describe in a human-readable way
  2470. what the source does. For example, &quot;X11 event queue&quot;
  2471. or &quot;GTK+ repaint idle handler&quot; or whatever it is.
  2472. </para>
  2473. <para>It is permitted to call this function multiple times, but is not
  2474. recommended due to the potential performance impact. For example,
  2475. one could change the name in the &quot;check&quot; function of a <type>GSourceFuncs</type>
  2476. to include details like the event type in the source name.
  2477. </para>
  2478. <para>Use caution if changing the name while another thread may be
  2479. accessing it with <function>g_source_get_name()</function>; that function does not copy
  2480. the value, and changing the value will free it while the other thread
  2481. may be attempting to use it.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>name</para></td><td class="parameter_description"><para>debug name for the source</para><para>Passed as <code>name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-priority</title><informalexample><programlisting>(define-values () (source:set-priority self priority))
  2482. </programlisting></informalexample><para>Sets the priority of a source. While the main loop is being run, a
  2483. source will be dispatched if it is ready to be dispatched and no
  2484. sources at a higher (numerically smaller) priority are ready to be
  2485. dispatched.
  2486. </para>
  2487. <para>A child source always has the same priority as its parent. It is not
  2488. permitted to change the priority of a source once it has been added
  2489. as a child of another source.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>priority</para></td><td class="parameter_description"><para>the new priority.</para><para>Passed as <code>priority</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-ready-time</title><informalexample><programlisting>(define-values () (source:set-ready-time self ready-time))
  2490. </programlisting></informalexample><para>Sets a <type>GSource</type> to be dispatched when the given monotonic time is
  2491. reached (or passed). If the monotonic time is in the past (as it
  2492. always will be if <parameter>ready_time</parameter> is 0) then the source will be
  2493. dispatched immediately.
  2494. </para>
  2495. <para>If <parameter>ready_time</parameter> is -1 then the source is never woken up on the basis
  2496. of the passage of time.
  2497. </para>
  2498. <para>Dispatching the source does not reset the ready time. You should do
  2499. so yourself, from the source dispatch function.
  2500. </para>
  2501. <para>Note that if you have a pair of sources where the ready time of one
  2502. suggests that it will be delivered first but the priority for the
  2503. other suggests that it would be delivered first, and the ready time
  2504. for both sources is reached during the same main context iteration,
  2505. then the order of dispatch is undefined.
  2506. </para>
  2507. <para>It is a no-op to call this function on a <type>GSource</type> which has already been
  2508. destroyed with <function>g_source_destroy()</function>.
  2509. </para>
  2510. <para>This API is only intended to be used by implementations of <type>GSource</type>.
  2511. Do not call this API on a <type>GSource</type> that you did not create.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>ready_time</para></td><td class="parameter_description"><para>the monotonic time at which the source will be ready,
  2512. 0 for &quot;immediately&quot;, -1 for &quot;never&quot;</para><para>Passed as <code>ready-time</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-static-name</title><informalexample><programlisting>(define-values () (source:set-static-name self name))
  2513. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>name</para></td><td class="parameter_description"><para></para><para>Passed as <code>name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (source:unref self))
  2514. </programlisting></informalexample><para>Decreases the reference count of a source by one. If the
  2515. resulting reference count is zero the source and associated
  2516. memory will be destroyed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a <type>GSource</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>source:remove?</title><informalexample><programlisting>(define-values (%return) (source:remove? tag))
  2517. </programlisting></informalexample><para>Removes the source with the given ID from the default main context. You must
  2518. use <function>g_source_destroy()</function> for sources added to a non-default main context.
  2519. </para>
  2520. <para>The ID of a <type>GSource</type> is given by <function>g_source_get_id()</function>, or will be
  2521. returned by the functions <function>g_source_attach()</function>, <function>g_idle_add()</function>,
  2522. <function>g_idle_add_full()</function>, <function>g_timeout_add()</function>, <function>g_timeout_add_full()</function>,
  2523. <function>g_child_watch_add()</function>, <function>g_child_watch_add_full()</function>, <function>g_io_add_watch()</function>, and
  2524. <function>g_io_add_watch_full()</function>.
  2525. </para>
  2526. <para>It is a programmer error to attempt to remove a non-existent source.
  2527. </para>
  2528. <para>More specifically: source IDs can be reissued after a source has been
  2529. destroyed and therefore it is never valid to use this function with a
  2530. source ID which may have already been removed. An example is when
  2531. scheduling an idle to run in another thread with <function>g_idle_add()</function>: the
  2532. idle may already have run and been removed by the time this function
  2533. is called on its (now invalid) source ID. This source ID may have
  2534. been reissued, leading to the operation being performed against the
  2535. wrong source.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tag</para></td><td class="parameter_description"><para>the ID of the source to remove.</para><para>Passed as <code>tag</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>source:remove-by-user-data?</title><informalexample><programlisting>(define-values (%return) (source:remove-by-user-data? user-data))
  2536. </programlisting></informalexample><para>Removes a source from the default main loop context given the user
  2537. data for the callback. If multiple sources exist with the same user
  2538. data, only one will be destroyed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>the user_data for the callback.</para><para>Passed as <code>user-data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>source:set-name-by-id</title><informalexample><programlisting>(define-values () (source:set-name-by-id tag name))
  2539. </programlisting></informalexample><para>Sets the name of a source using its ID.
  2540. </para>
  2541. <para>This is a convenience utility to set source names from the return
  2542. value of <function>g_idle_add()</function>, <function>g_timeout_add()</function>, etc.
  2543. </para>
  2544. <para>It is a programmer error to attempt to set the name of a non-existent
  2545. source.
  2546. </para>
  2547. <para>More specifically: source IDs can be reissued after a source has been
  2548. destroyed and therefore it is never valid to use this function with a
  2549. source ID which may have already been removed. An example is when
  2550. scheduling an idle to run in another thread with <function>g_idle_add()</function>: the
  2551. idle may already have run and been removed by the time this function
  2552. is called on its (now invalid) source ID. This source ID may have
  2553. been reissued, leading to the operation being performed against the
  2554. wrong source.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tag</para></td><td class="parameter_description"><para>a <type>GSource</type> ID</para><para>Passed as <code>tag</code></para></td></tr><tr><td class="parameter_name"><para>name</para></td><td class="parameter_description"><para>debug name for the source</para><para>Passed as <code>name</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibSpawnError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by spawning processes.</para></refsect1><refsect1><title>Members</title><refsect2><title>fork</title><remark>alias <code>G_SPAWN_ERROR_FORK</code></remark><para>Fork failed due to lack of memory.</para></refsect2><refsect2><title>read</title><remark>alias <code>G_SPAWN_ERROR_READ</code></remark><para>Read or select on pipes failed.</para></refsect2><refsect2><title>chdir</title><remark>alias <code>G_SPAWN_ERROR_CHDIR</code></remark><para>Changing to working directory failed.</para></refsect2><refsect2><title>acces</title><remark>alias <code>G_SPAWN_ERROR_ACCES</code></remark><para><function>execv()</function> returned <code>EACCES</code></para></refsect2><refsect2><title>perm</title><remark>alias <code>G_SPAWN_ERROR_PERM</code></remark><para><function>execv()</function> returned <code>EPERM</code></para></refsect2><refsect2><title>too-big</title><remark>alias <code>G_SPAWN_ERROR_TOO_BIG</code></remark><para><function>execv()</function> returned <code>E2BIG</code></para></refsect2><refsect2><title>2big</title><remark>alias <code>G_SPAWN_ERROR_2BIG</code></remark><para>deprecated alias for <constant>G_SPAWN_ERROR_TOO_BIG</constant> (deprecated since GLib 2.32)</para></refsect2><refsect2><title>noexec</title><remark>alias <code>G_SPAWN_ERROR_NOEXEC</code></remark><para><function>execv()</function> returned <code>ENOEXEC</code></para></refsect2><refsect2><title>nametoolong</title><remark>alias <code>G_SPAWN_ERROR_NAMETOOLONG</code></remark><para><function>execv()</function> returned <code>ENAMETOOLONG</code></para></refsect2><refsect2><title>noent</title><remark>alias <code>G_SPAWN_ERROR_NOENT</code></remark><para><function>execv()</function> returned <code>ENOENT</code></para></refsect2><refsect2><title>nomem</title><remark>alias <code>G_SPAWN_ERROR_NOMEM</code></remark><para><function>execv()</function> returned <code>ENOMEM</code></para></refsect2><refsect2><title>notdir</title><remark>alias <code>G_SPAWN_ERROR_NOTDIR</code></remark><para><function>execv()</function> returned <code>ENOTDIR</code></para></refsect2><refsect2><title>loop</title><remark>alias <code>G_SPAWN_ERROR_LOOP</code></remark><para><function>execv()</function> returned <code>ELOOP</code></para></refsect2><refsect2><title>txtbusy</title><remark>alias <code>G_SPAWN_ERROR_TXTBUSY</code></remark><para><function>execv()</function> returned <code>ETXTBUSY</code></para></refsect2><refsect2><title>io</title><remark>alias <code>G_SPAWN_ERROR_IO</code></remark><para><function>execv()</function> returned <code>EIO</code></para></refsect2><refsect2><title>nfile</title><remark>alias <code>G_SPAWN_ERROR_NFILE</code></remark><para><function>execv()</function> returned <code>ENFILE</code></para></refsect2><refsect2><title>mfile</title><remark>alias <code>G_SPAWN_ERROR_MFILE</code></remark><para><function>execv()</function> returned <code>EMFILE</code></para></refsect2><refsect2><title>inval</title><remark>alias <code>G_SPAWN_ERROR_INVAL</code></remark><para><function>execv()</function> returned <code>EINVAL</code></para></refsect2><refsect2><title>isdir</title><remark>alias <code>G_SPAWN_ERROR_ISDIR</code></remark><para><function>execv()</function> returned <code>EISDIR</code></para></refsect2><refsect2><title>libbad</title><remark>alias <code>G_SPAWN_ERROR_LIBBAD</code></remark><para><function>execv()</function> returned <code>ELIBBAD</code></para></refsect2><refsect2><title>failed</title><remark>alias <code>G_SPAWN_ERROR_FAILED</code></remark><para>Some other fatal failure,
  2555. <code>error-&gt;message</code> should explain.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibSpawnFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags passed to <function>g_spawn_sync()</function>, <function>g_spawn_async()</function> and <function>g_spawn_async_with_pipes()</function>.</para></refsect1><refsect1><title>Members</title><refsect2><title>default</title><remark>alias <code>G_SPAWN_DEFAULT</code></remark><para>no flags, default behaviour</para></refsect2><refsect2><title>leave-descriptors-open</title><remark>alias <code>G_SPAWN_LEAVE_DESCRIPTORS_OPEN</code></remark><para>the parent's open file descriptors will
  2556. be inherited by the child; otherwise all descriptors except stdin,
  2557. stdout and stderr will be closed before calling <function>exec()</function> in the child.</para></refsect2><refsect2><title>do-not-reap-child</title><remark>alias <code>G_SPAWN_DO_NOT_REAP_CHILD</code></remark><para>the child will not be automatically reaped;
  2558. you must use <function>g_child_watch_add()</function> yourself (or call <function>waitpid()</function> or handle
  2559. <code>SIGCHLD</code> yourself), or the child will become a zombie.</para></refsect2><refsect2><title>search-path</title><remark>alias <code>G_SPAWN_SEARCH_PATH</code></remark><para><code>argv[0]</code> need not be an absolute path, it will be
  2560. looked for in the user's <code>PATH</code>.</para></refsect2><refsect2><title>stdout-to-dev-null</title><remark>alias <code>G_SPAWN_STDOUT_TO_DEV_NULL</code></remark><para>the child's standard output will be discarded,
  2561. instead of going to the same location as the parent's standard output.</para></refsect2><refsect2><title>stderr-to-dev-null</title><remark>alias <code>G_SPAWN_STDERR_TO_DEV_NULL</code></remark><para>the child's standard error will be discarded.</para></refsect2><refsect2><title>child-inherits-stdin</title><remark>alias <code>G_SPAWN_CHILD_INHERITS_STDIN</code></remark><para>the child will inherit the parent's standard
  2562. input (by default, the child's standard input is attached to <code>/dev/null</code>).</para></refsect2><refsect2><title>file-and-argv-zero</title><remark>alias <code>G_SPAWN_FILE_AND_ARGV_ZERO</code></remark><para>the first element of <code>argv</code> is the file to
  2563. execute, while the remaining elements are the actual argument vector
  2564. to pass to the file. Normally <function>g_spawn_async_with_pipes()</function> uses <code>argv[0]</code>
  2565. as the file to execute, and passes all of <code>argv</code> to the child.</para></refsect2><refsect2><title>search-path-from-envp</title><remark>alias <code>G_SPAWN_SEARCH_PATH_FROM_ENVP</code></remark><para>if <code>argv[0]</code> is not an absolute path,
  2566. it will be looked for in the <code>PATH</code> from the passed child environment.
  2567. Since: 2.34</para></refsect2><refsect2><title>cloexec-pipes</title><remark>alias <code>G_SPAWN_CLOEXEC_PIPES</code></remark><para>create all pipes with the <code>O_CLOEXEC</code> flag set.
  2568. Since: 2.40</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GString&gt;</refname></refnamediv><refsect1><title>Description</title><para>The GString struct contains the public fields of a GString.</para></refsect1><refsect1><title>Functions</title><refsect2><title>append</title><informalexample><programlisting>(define-values (%return) (string:append self val))
  2569. </programlisting></informalexample><para>Adds a string onto the end of a <type>GString</type>, expanding
  2570. it if necessary.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the string to append onto the end of <parameter>string</parameter></para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>append-c</title><informalexample><programlisting>(define-values (%return) (string:append-c self c))
  2571. </programlisting></informalexample><para>Adds a byte onto the end of a <type>GString</type>, expanding
  2572. it if necessary.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>the byte to append onto the end of <parameter>string</parameter></para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>append-len</title><informalexample><programlisting>(define-values (%return) (string:append-len self val len))
  2573. </programlisting></informalexample><para>Appends <parameter>len</parameter> bytes of <parameter>val</parameter> to <parameter>string</parameter>.
  2574. </para>
  2575. <para>If <parameter>len</parameter> is positive, <parameter>val</parameter> may contain embedded nuls and need
  2576. not be nul-terminated. It is the caller's responsibility to
  2577. ensure that <parameter>val</parameter> has at least <parameter>len</parameter> addressable bytes.
  2578. </para>
  2579. <para>If <parameter>len</parameter> is negative, <parameter>val</parameter> must be nul-terminated and <parameter>len</parameter>
  2580. is considered to request the entire string length. This
  2581. makes <function>g_string_append_len()</function> equivalent to <function>g_string_append()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>bytes to append</para><para>Passed as <code>val</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>number of bytes of <parameter>val</parameter> to use, or -1 for all of <parameter>val</parameter></para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>append-unichar</title><informalexample><programlisting>(define-values (%return) (string:append-unichar self wc))
  2582. </programlisting></informalexample><para>Converts a Unicode character into UTF-8, and appends it
  2583. to the string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>wc</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>wc</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>append-uri-escaped</title><informalexample><programlisting>(define-values
  2584. (%return)
  2585. (string:append-uri-escaped self unescaped reserved-chars-allowed allow-utf8))
  2586. </programlisting></informalexample><para>Appends <parameter>unescaped</parameter> to <parameter>string</parameter>, escaping any characters that
  2587. are reserved in URIs using URI-style escape sequences.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>unescaped</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>unescaped</code></para></td></tr><tr><td class="parameter_name"><para>reserved_chars_allowed</para></td><td class="parameter_description"><para>a string of reserved characters allowed
  2588. to be used, or <constant>NULL</constant></para><para>Passed as <code>reserved-chars-allowed</code></para></td></tr><tr><td class="parameter_name"><para>allow_utf8</para></td><td class="parameter_description"><para>set <constant>TRUE</constant> if the escaped string may include UTF8 characters</para><para>Passed as <code>allow-utf8</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-down</title><informalexample><programlisting>(define-values (%return) (string:ascii-down self))
  2589. </programlisting></informalexample><para>Converts all uppercase ASCII letters to lowercase ASCII letters.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a GString</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-up</title><informalexample><programlisting>(define-values (%return) (string:ascii-up self))
  2590. </programlisting></informalexample><para>Converts all lowercase ASCII letters to uppercase ASCII letters.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a GString</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>assign</title><informalexample><programlisting>(define-values (%return) (string:assign self rval))
  2591. </programlisting></informalexample><para>Copies the bytes from a string into a <type>GString</type>,
  2592. destroying any previous contents. It is rather like
  2593. the standard <function>strcpy()</function> function, except that you do not
  2594. have to worry about having enough space to copy the string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the destination <type>GString</type>. Its current contents
  2595. are destroyed.</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>rval</para></td><td class="parameter_description"><para>the string to copy into <parameter>string</parameter></para><para>Passed as <code>rval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>down</title><informalexample><programlisting>(define-values (%return) (string:down self))
  2596. </programlisting></informalexample><para>Converts a <type>GString</type> to lowercase.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>equal?</title><informalexample><programlisting>(define-values (%return) (string:equal? self v2))
  2597. </programlisting></informalexample><para>Compares two strings for equality, returning <constant>TRUE</constant> if they are equal.
  2598. For use with <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>v</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>v2</para></td><td class="parameter_description"><para>another <type>GString</type></para><para>Passed as <code>v2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>erase</title><informalexample><programlisting>(define-values (%return) (string:erase self pos len))
  2599. </programlisting></informalexample><para>Removes <parameter>len</parameter> bytes from a <type>GString</type>, starting at position <parameter>pos</parameter>.
  2600. The rest of the <type>GString</type> is shifted down to fill the gap.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>pos</para></td><td class="parameter_description"><para>the position of the content to remove</para><para>Passed as <code>pos</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the number of bytes to remove, or -1 to remove all
  2601. following bytes</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>free</title><informalexample><programlisting>(define-values (%return) (string:free self free-segment))
  2602. </programlisting></informalexample><para>Frees the memory allocated for the <type>GString</type>.
  2603. If <parameter>free_segment</parameter> is <constant>TRUE</constant> it also frees the character data. If
  2604. it's <constant>FALSE</constant>, the caller gains ownership of the buffer and must
  2605. free it after use with <function>g_free()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>free_segment</para></td><td class="parameter_description"><para>if <constant>TRUE</constant>, the actual character data is freed as well</para><para>Passed as <code>free-segment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>free-to-bytes</title><informalexample><programlisting>(define-values (%return) (string:free-to-bytes self))
  2606. </programlisting></informalexample><para>Transfers ownership of the contents of <parameter>string</parameter> to a newly allocated
  2607. <type>GBytes</type>. The <type>GString</type> structure itself is deallocated, and it is
  2608. therefore invalid to use <parameter>string</parameter> after invoking this function.
  2609. </para>
  2610. <para>Note that while <type>GString</type> ensures that its buffer always has a
  2611. trailing nul character (not reflected in its &quot;len&quot;), the returned
  2612. <type>GBytes</type> does not include this extra nul; i.e. it has length exactly
  2613. equal to the &quot;len&quot; member.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash</title><informalexample><programlisting>(define-values (%return) (string:hash self))
  2614. </programlisting></informalexample><para>Creates a hash code for <parameter>str</parameter>; for use with <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a string to hash</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>insert</title><informalexample><programlisting>(define-values (%return) (string:insert self pos val))
  2615. </programlisting></informalexample><para>Inserts a copy of a string into a <type>GString</type>,
  2616. expanding it if necessary.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>pos</para></td><td class="parameter_description"><para>the position to insert the copy of the string</para><para>Passed as <code>pos</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the string to insert</para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>insert-c</title><informalexample><programlisting>(define-values (%return) (string:insert-c self pos c))
  2617. </programlisting></informalexample><para>Inserts a byte into a <type>GString</type>, expanding it if necessary.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>pos</para></td><td class="parameter_description"><para>the position to insert the byte</para><para>Passed as <code>pos</code></para></td></tr><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>the byte to insert</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>insert-len</title><informalexample><programlisting>(define-values (%return) (string:insert-len self pos val len))
  2618. </programlisting></informalexample><para>Inserts <parameter>len</parameter> bytes of <parameter>val</parameter> into <parameter>string</parameter> at <parameter>pos</parameter>.
  2619. </para>
  2620. <para>If <parameter>len</parameter> is positive, <parameter>val</parameter> may contain embedded nuls and need
  2621. not be nul-terminated. It is the caller's responsibility to
  2622. ensure that <parameter>val</parameter> has at least <parameter>len</parameter> addressable bytes.
  2623. </para>
  2624. <para>If <parameter>len</parameter> is negative, <parameter>val</parameter> must be nul-terminated and <parameter>len</parameter>
  2625. is considered to request the entire string length.
  2626. </para>
  2627. <para>If <parameter>pos</parameter> is -1, bytes are inserted at the end of the string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>pos</para></td><td class="parameter_description"><para>position in <parameter>string</parameter> where insertion should
  2628. happen, or -1 for at the end</para><para>Passed as <code>pos</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>bytes to insert</para><para>Passed as <code>val</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>number of bytes of <parameter>val</parameter> to insert, or -1 for all of <parameter>val</parameter></para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>insert-unichar</title><informalexample><programlisting>(define-values (%return) (string:insert-unichar self pos wc))
  2629. </programlisting></informalexample><para>Converts a Unicode character into UTF-8, and insert it
  2630. into the string at the given position.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>pos</para></td><td class="parameter_description"><para>the position at which to insert character, or -1
  2631. to append at the end of the string</para><para>Passed as <code>pos</code></para></td></tr><tr><td class="parameter_name"><para>wc</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>wc</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>overwrite</title><informalexample><programlisting>(define-values (%return) (string:overwrite self pos val))
  2632. </programlisting></informalexample><para>Overwrites part of a string, lengthening it if necessary.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>pos</para></td><td class="parameter_description"><para>the position at which to start overwriting</para><para>Passed as <code>pos</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the string that will overwrite the <parameter>string</parameter> starting at <parameter>pos</parameter></para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>overwrite-len</title><informalexample><programlisting>(define-values (%return) (string:overwrite-len self pos val len))
  2633. </programlisting></informalexample><para>Overwrites part of a string, lengthening it if necessary.
  2634. This function will work with embedded nuls.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>pos</para></td><td class="parameter_description"><para>the position at which to start overwriting</para><para>Passed as <code>pos</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the string that will overwrite the <parameter>string</parameter> starting at <parameter>pos</parameter></para><para>Passed as <code>val</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the number of bytes to write from <parameter>val</parameter></para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>prepend</title><informalexample><programlisting>(define-values (%return) (string:prepend self val))
  2635. </programlisting></informalexample><para>Adds a string on to the start of a <type>GString</type>,
  2636. expanding it if necessary.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the string to prepend on the start of <parameter>string</parameter></para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>prepend-c</title><informalexample><programlisting>(define-values (%return) (string:prepend-c self c))
  2637. </programlisting></informalexample><para>Adds a byte onto the start of a <type>GString</type>,
  2638. expanding it if necessary.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>the byte to prepend on the start of the <type>GString</type></para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>prepend-len</title><informalexample><programlisting>(define-values (%return) (string:prepend-len self val len))
  2639. </programlisting></informalexample><para>Prepends <parameter>len</parameter> bytes of <parameter>val</parameter> to <parameter>string</parameter>.
  2640. </para>
  2641. <para>If <parameter>len</parameter> is positive, <parameter>val</parameter> may contain embedded nuls and need
  2642. not be nul-terminated. It is the caller's responsibility to
  2643. ensure that <parameter>val</parameter> has at least <parameter>len</parameter> addressable bytes.
  2644. </para>
  2645. <para>If <parameter>len</parameter> is negative, <parameter>val</parameter> must be nul-terminated and <parameter>len</parameter>
  2646. is considered to request the entire string length. This
  2647. makes <function>g_string_prepend_len()</function> equivalent to <function>g_string_prepend()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>bytes to prepend</para><para>Passed as <code>val</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>number of bytes in <parameter>val</parameter> to prepend, or -1 for all of <parameter>val</parameter></para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>prepend-unichar</title><informalexample><programlisting>(define-values (%return) (string:prepend-unichar self wc))
  2648. </programlisting></informalexample><para>Converts a Unicode character into UTF-8, and prepends it
  2649. to the string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>wc</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>wc</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>replace</title><informalexample><programlisting>(define-values (%return) (string:replace self find replace limit))
  2650. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>find</para></td><td class="parameter_description"><para></para><para>Passed as <code>find</code></para></td></tr><tr><td class="parameter_name"><para>replace</para></td><td class="parameter_description"><para></para><para>Passed as <code>replace</code></para></td></tr><tr><td class="parameter_name"><para>limit</para></td><td class="parameter_description"><para></para><para>Passed as <code>limit</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-size</title><informalexample><programlisting>(define-values (%return) (string:set-size self len))
  2651. </programlisting></informalexample><para>Sets the length of a <type>GString</type>. If the length is less than
  2652. the current length, the string will be truncated. If the
  2653. length is greater than the current length, the contents
  2654. of the newly added area are undefined. (However, as
  2655. always, string-&gt;str[string-&gt;len] will be a nul byte.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the new length</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>truncate</title><informalexample><programlisting>(define-values (%return) (string:truncate self len))
  2656. </programlisting></informalexample><para>Cuts off the end of the GString, leaving the first <parameter>len</parameter> bytes.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the new size of <parameter>string</parameter></para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>up</title><informalexample><programlisting>(define-values (%return) (string:up self))
  2657. </programlisting></informalexample><para>Converts a <type>GString</type> to uppercase.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a <type>GString</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibTestFileType&gt;</refname></refnamediv><refsect1><title>Description</title><para>The type of file to return the filename for, when used with
  2658. <function>g_test_build_filename()</function>.
  2659. </para>
  2660. <para>These two options correspond rather directly to the 'dist' and
  2661. 'built' terminology that automake uses and are explicitly used to
  2662. distinguish between the 'srcdir' and 'builddir' being separate. All
  2663. files in your project should either be dist (in the
  2664. <code>EXTRA_DIST</code> or <code>dist_schema_DATA</code>
  2665. sense, in which case they will always be in the srcdir) or built (in
  2666. the <code>BUILT_SOURCES</code> sense, in which case they will
  2667. always be in the builddir).
  2668. </para>
  2669. <para>Note: as a general rule of automake, files that are generated only as
  2670. part of the build-from-git process (but then are distributed with the
  2671. tarball) always go in srcdir (even if doing a srcdir != builddir
  2672. build from git) and are considered as distributed files.</para></refsect1><refsect1><title>Members</title><refsect2><title>dist</title><remark>alias <code>G_TEST_DIST</code></remark><para>a file that was included in the distribution tarball</para></refsect2><refsect2><title>built</title><remark>alias <code>G_TEST_BUILT</code></remark><para>a file that was built on the compiling machine</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibTestLogType&gt;</refname></refnamediv><refsect1><title>Members</title><refsect2><title>none</title><remark>alias <code>G_TEST_LOG_NONE</code></remark><para>Undocumented</para></refsect2><refsect2><title>error</title><remark>alias <code>G_TEST_LOG_ERROR</code></remark><para>Undocumented</para></refsect2><refsect2><title>start-binary</title><remark>alias <code>G_TEST_LOG_START_BINARY</code></remark><para>Undocumented</para></refsect2><refsect2><title>list-case</title><remark>alias <code>G_TEST_LOG_LIST_CASE</code></remark><para>Undocumented</para></refsect2><refsect2><title>skip-case</title><remark>alias <code>G_TEST_LOG_SKIP_CASE</code></remark><para>Undocumented</para></refsect2><refsect2><title>start-case</title><remark>alias <code>G_TEST_LOG_START_CASE</code></remark><para>Undocumented</para></refsect2><refsect2><title>stop-case</title><remark>alias <code>G_TEST_LOG_STOP_CASE</code></remark><para>Undocumented</para></refsect2><refsect2><title>min-result</title><remark>alias <code>G_TEST_LOG_MIN_RESULT</code></remark><para>Undocumented</para></refsect2><refsect2><title>max-result</title><remark>alias <code>G_TEST_LOG_MAX_RESULT</code></remark><para>Undocumented</para></refsect2><refsect2><title>message</title><remark>alias <code>G_TEST_LOG_MESSAGE</code></remark><para>Undocumented</para></refsect2><refsect2><title>start-suite</title><remark>alias <code>G_TEST_LOG_START_SUITE</code></remark><para>Undocumented</para></refsect2><refsect2><title>stop-suite</title><remark>alias <code>G_TEST_LOG_STOP_SUITE</code></remark><para>Undocumented</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibTestResult&gt;</refname></refnamediv><refsect1><title>Members</title><refsect2><title>success</title><remark>alias <code>G_TEST_RUN_SUCCESS</code></remark><para>Undocumented</para></refsect2><refsect2><title>skipped</title><remark>alias <code>G_TEST_RUN_SKIPPED</code></remark><para>Undocumented</para></refsect2><refsect2><title>failure</title><remark>alias <code>G_TEST_RUN_FAILURE</code></remark><para>Undocumented</para></refsect2><refsect2><title>incomplete</title><remark>alias <code>G_TEST_RUN_INCOMPLETE</code></remark><para>Undocumented</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibTestSubprocessFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags to pass to <function>g_test_trap_subprocess()</function> to control input and output.
  2673. </para>
  2674. <para>Note that in contrast with <function>g_test_trap_fork()</function>, the default is to
  2675. not show stdout and stderr.</para></refsect1><refsect1><title>Members</title><refsect2><title>stdin</title><remark>alias <code>G_TEST_SUBPROCESS_INHERIT_STDIN</code></remark><para>If this flag is given, the child
  2676. process will inherit the parent's stdin. Otherwise, the child's
  2677. stdin is redirected to <code>/dev/null</code>.</para></refsect2><refsect2><title>stdout</title><remark>alias <code>G_TEST_SUBPROCESS_INHERIT_STDOUT</code></remark><para>If this flag is given, the child
  2678. process will inherit the parent's stdout. Otherwise, the child's
  2679. stdout will not be visible, but it will be captured to allow
  2680. later tests with <function>g_test_trap_assert_stdout()</function>.</para></refsect2><refsect2><title>stderr</title><remark>alias <code>G_TEST_SUBPROCESS_INHERIT_STDERR</code></remark><para>If this flag is given, the child
  2681. process will inherit the parent's stderr. Otherwise, the child's
  2682. stderr will not be visible, but it will be captured to allow
  2683. later tests with <function>g_test_trap_assert_stderr()</function>.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GThread&gt;</refname></refnamediv><refsect1><title>Description</title><para>The <type>GThread</type> struct represents a running thread. This struct
  2684. is returned by <function>g_thread_new()</function> or <function>g_thread_try_new()</function>. You can
  2685. obtain the <type>GThread</type> struct representing the current thread by
  2686. calling <function>g_thread_self()</function>.
  2687. </para>
  2688. <para>GThread is refcounted, see <function>g_thread_ref()</function> and <function>g_thread_unref()</function>.
  2689. The thread represented by it holds a reference while it is running,
  2690. and <function>g_thread_join()</function> consumes the reference that it is given, so
  2691. it is normally not necessary to manage GThread references
  2692. explicitly.
  2693. </para>
  2694. <para>The structure is opaque -- none of its fields may be directly
  2695. accessed.</para></refsect1><refsect1><title>Functions</title><refsect2><title>join</title><informalexample><programlisting>(define-values (%return) (thread:join self))
  2696. </programlisting></informalexample><para>Waits until <parameter>thread</parameter> finishes, i.e. the function <parameter>func</parameter>, as
  2697. given to <function>g_thread_new()</function>, returns or <function>g_thread_exit()</function> is called.
  2698. If <parameter>thread</parameter> has already terminated, then <function>g_thread_join()</function>
  2699. returns immediately.
  2700. </para>
  2701. <para>Any thread can wait for any other thread by calling <function>g_thread_join()</function>,
  2702. not just its 'creator'. Calling <function>g_thread_join()</function> from multiple threads
  2703. for the same <parameter>thread</parameter> leads to undefined behaviour.
  2704. </para>
  2705. <para>The value returned by <parameter>func</parameter> or given to <function>g_thread_exit()</function> is
  2706. returned by this function.
  2707. </para>
  2708. <para><function>g_thread_join()</function> consumes the reference to the passed-in <parameter>thread</parameter>.
  2709. This will usually cause the <type>GThread</type> struct and associated resources
  2710. to be freed. Use <function>g_thread_ref()</function> to obtain an extra reference if you
  2711. want to keep the GThread alive beyond the <function>g_thread_join()</function> call.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>thread</para></td><td class="parameter_description"><para>a <type>GThread</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (thread:ref self))
  2712. </programlisting></informalexample><para>Increase the reference count on <parameter>thread</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>thread</para></td><td class="parameter_description"><para>a <type>GThread</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (thread:unref self))
  2713. </programlisting></informalexample><para>Decrease the reference count on <parameter>thread</parameter>, possibly freeing all
  2714. resources associated with it.
  2715. </para>
  2716. <para>Note that each thread holds a reference to its <type>GThread</type> while
  2717. it is running, so it is safe to drop your own reference to it
  2718. if you don't need it anymore.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>thread</para></td><td class="parameter_description"><para>a <type>GThread</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>thread:try-new</title><informalexample><programlisting>(define-values (%return) (thread:try-new name func data))
  2719. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>name</para></td><td class="parameter_description"><para></para><para>Passed as <code>name</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para></para><para>Passed as <code>func</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para></para><para>Passed as <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>thread:new</title><informalexample><programlisting>(define-values (%return) (thread:new name func data))
  2720. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>name</para></td><td class="parameter_description"><para></para><para>Passed as <code>name</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para></para><para>Passed as <code>func</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para></para><para>Passed as <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>thread:error-quark</title><informalexample><programlisting>(define-values (%return) (thread:error-quark))
  2721. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>thread:exit</title><informalexample><programlisting>(define-values () (thread:exit retval))
  2722. </programlisting></informalexample><para>Terminates the current thread.
  2723. </para>
  2724. <para>If another thread is waiting for us using <function>g_thread_join()</function> then the
  2725. waiting thread will be woken up and get <parameter>retval</parameter> as the return value
  2726. of <function>g_thread_join()</function>.
  2727. </para>
  2728. <para>Calling <function>g_thread_exit()</function> with a parameter <parameter>retval</parameter> is equivalent to
  2729. returning <parameter>retval</parameter> from the function <parameter>func</parameter>, as given to <function>g_thread_new()</function>.
  2730. </para>
  2731. <para>You must only call <function>g_thread_exit()</function> from a thread that you created
  2732. yourself with <function>g_thread_new()</function> or related APIs. You must not call
  2733. this function from a thread created with another threading library
  2734. or or from within a <type>GThreadPool</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>retval</para></td><td class="parameter_description"><para>the return value of this thread</para><para>Passed as <code>retval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>thread:self</title><informalexample><programlisting>(define-values (%return) (thread:self))
  2735. </programlisting></informalexample><para>This function returns the <type>GThread</type> corresponding to the
  2736. current thread. Note that this function does not increase
  2737. the reference count of the returned struct.
  2738. </para>
  2739. <para>This function will return a <type>GThread</type> even for threads that
  2740. were not created by GLib (i.e. those created by other threading
  2741. APIs). This may be useful for thread identification purposes
  2742. (i.e. comparisons) but you must not use GLib functions (such
  2743. as <function>g_thread_join()</function>) on these threads.</para></refsect2><refsect2><title>thread:yield</title><informalexample><programlisting>(define-values () (thread:yield))
  2744. </programlisting></informalexample><para>Causes the calling thread to voluntarily relinquish the CPU, so
  2745. that other threads can run.
  2746. </para>
  2747. <para>This function is often used as a method to make busy wait less evil.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibThreadError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Possible errors of thread related functions.</para></refsect1><refsect1><title>Members</title><refsect2><title>thread-error-again</title><remark>alias <code>G_THREAD_ERROR_AGAIN</code></remark><para>a thread couldn't be created due to resource
  2748. shortage. Try again later.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibTimeType&gt;</refname></refnamediv><refsect1><title>Description</title><para>Disambiguates a given time in two ways.
  2749. </para>
  2750. <para>First, specifies if the given time is in universal or local time.
  2751. </para>
  2752. <para>Second, if the time is in local time, specifies if it is local
  2753. standard time or local daylight time. This is important for the case
  2754. where the same local time occurs twice (during daylight savings time
  2755. transitions, for example).</para></refsect1><refsect1><title>Members</title><refsect2><title>standard</title><remark>alias <code>G_TIME_TYPE_STANDARD</code></remark><para>the time is in local standard time</para></refsect2><refsect2><title>daylight</title><remark>alias <code>G_TIME_TYPE_DAYLIGHT</code></remark><para>the time is in local daylight time</para></refsect2><refsect2><title>universal</title><remark>alias <code>G_TIME_TYPE_UNIVERSAL</code></remark><para>the time is in UTC</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GTimeZone&gt;</refname></refnamediv><refsect1><title>Description</title><para><type>GTimeZone</type> is an opaque structure whose members cannot be accessed
  2756. directly.</para></refsect1><refsect1><title>Functions</title><refsect2><title>adjust-time</title><informalexample><programlisting>(define-values (%return) (time-zone:adjust-time self type time-))
  2757. </programlisting></informalexample><para>Finds an interval within <parameter>tz</parameter> that corresponds to the given <parameter>time_</parameter>,
  2758. possibly adjusting <parameter>time_</parameter> if required to fit into an interval.
  2759. The meaning of <parameter>time_</parameter> depends on <parameter>type</parameter>.
  2760. </para>
  2761. <para>This function is similar to <function>g_time_zone_find_interval()</function>, with the
  2762. difference that it always succeeds (by making the adjustments
  2763. described below).
  2764. </para>
  2765. <para>In any of the cases where <function>g_time_zone_find_interval()</function> succeeds then
  2766. this function returns the same value, without modifying <parameter>time_</parameter>.
  2767. </para>
  2768. <para>This function may, however, modify <parameter>time_</parameter> in order to deal with
  2769. non-existent times. If the non-existent local <parameter>time_</parameter> of 02:30 were
  2770. requested on March 14th 2010 in Toronto then this function would
  2771. adjust <parameter>time_</parameter> to be 03:00 and return the interval containing the
  2772. adjusted time.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tz</para></td><td class="parameter_description"><para>a <type>GTimeZone</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>the <type>GTimeType</type> of <parameter>time_</parameter></para><para>Passed as <code>type</code></para></td></tr><tr><td class="parameter_name"><para>time_</para></td><td class="parameter_description"><para>a pointer to a number of seconds since January 1, 1970</para><para>Passed as <code>time-</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>find-interval</title><informalexample><programlisting>(define-values (%return) (time-zone:find-interval self type time-))
  2773. </programlisting></informalexample><para>Finds an interval within <parameter>tz</parameter> that corresponds to the given <parameter>time_</parameter>.
  2774. The meaning of <parameter>time_</parameter> depends on <parameter>type</parameter>.
  2775. </para>
  2776. <para>If <parameter>type</parameter> is <constant>G_TIME_TYPE_UNIVERSAL</constant> then this function will always
  2777. succeed (since universal time is monotonic and continuous).
  2778. </para>
  2779. <para>Otherwise <parameter>time_</parameter> is treated as local time. The distinction between
  2780. <constant>G_TIME_TYPE_STANDARD</constant> and <constant>G_TIME_TYPE_DAYLIGHT</constant> is ignored except in
  2781. the case that the given <parameter>time_</parameter> is ambiguous. In Toronto, for example,
  2782. 01:30 on November 7th 2010 occurred twice (once inside of daylight
  2783. savings time and the next, an hour later, outside of daylight savings
  2784. time). In this case, the different value of <parameter>type</parameter> would result in a
  2785. different interval being returned.
  2786. </para>
  2787. <para>It is still possible for this function to fail. In Toronto, for
  2788. example, 02:00 on March 14th 2010 does not exist (due to the leap
  2789. forward to begin daylight savings time). -1 is returned in that
  2790. case.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tz</para></td><td class="parameter_description"><para>a <type>GTimeZone</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>the <type>GTimeType</type> of <parameter>time_</parameter></para><para>Passed as <code>type</code></para></td></tr><tr><td class="parameter_name"><para>time_</para></td><td class="parameter_description"><para>a number of seconds since January 1, 1970</para><para>Passed as <code>time-</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-abbreviation</title><informalexample><programlisting>(define-values (%return) (time-zone:get-abbreviation self interval))
  2791. </programlisting></informalexample><para>Determines the time zone abbreviation to be used during a particular
  2792. <parameter>interval</parameter> of time in the time zone <parameter>tz</parameter>.
  2793. </para>
  2794. <para>For example, in Toronto this is currently &quot;EST&quot; during the winter
  2795. months and &quot;EDT&quot; during the summer months when daylight savings time
  2796. is in effect.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tz</para></td><td class="parameter_description"><para>a <type>GTimeZone</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>interval</para></td><td class="parameter_description"><para>an interval within the timezone</para><para>Passed as <code>interval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-identifier</title><informalexample><programlisting>(define-values (%return) (time-zone:get-identifier self))
  2797. </programlisting></informalexample><para>Get the identifier of this <type>GTimeZone</type>, as passed to <function>g_time_zone_new()</function>.
  2798. If the identifier passed at construction time was not recognised, <code>UTC</code> will
  2799. be returned. If it was <constant>NULL</constant>, the identifier of the local timezone at
  2800. construction time will be returned.
  2801. </para>
  2802. <para>The identifier will be returned in the same format as provided at
  2803. construction time: if provided as a time offset, that will be returned by
  2804. this function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tz</para></td><td class="parameter_description"><para>a <type>GTimeZone</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-offset</title><informalexample><programlisting>(define-values (%return) (time-zone:get-offset self interval))
  2805. </programlisting></informalexample><para>Determines the offset to UTC in effect during a particular <parameter>interval</parameter>
  2806. of time in the time zone <parameter>tz</parameter>.
  2807. </para>
  2808. <para>The offset is the number of seconds that you add to UTC time to
  2809. arrive at local time for <parameter>tz</parameter> (ie: negative numbers for time zones
  2810. west of GMT, positive numbers for east).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tz</para></td><td class="parameter_description"><para>a <type>GTimeZone</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>interval</para></td><td class="parameter_description"><para>an interval within the timezone</para><para>Passed as <code>interval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-dst?</title><informalexample><programlisting>(define-values (%return) (time-zone:is-dst? self interval))
  2811. </programlisting></informalexample><para>Determines if daylight savings time is in effect during a particular
  2812. <parameter>interval</parameter> of time in the time zone <parameter>tz</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tz</para></td><td class="parameter_description"><para>a <type>GTimeZone</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>interval</para></td><td class="parameter_description"><para>an interval within the timezone</para><para>Passed as <code>interval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (time-zone:ref self))
  2813. </programlisting></informalexample><para>Increases the reference count on <parameter>tz</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tz</para></td><td class="parameter_description"><para>a <type>GTimeZone</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (time-zone:unref self))
  2814. </programlisting></informalexample><para>Decreases the reference count on <parameter>tz</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tz</para></td><td class="parameter_description"><para>a <type>GTimeZone</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>time-zone:new-utc</title><informalexample><programlisting>(define-values (%return) (time-zone:new-utc))
  2815. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>time-zone:new-offset</title><informalexample><programlisting>(define-values (%return) (time-zone:new-offset seconds))
  2816. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>seconds</para></td><td class="parameter_description"><para></para><para>Passed as <code>seconds</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>time-zone:new-local</title><informalexample><programlisting>(define-values (%return) (time-zone:new-local))
  2817. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>time-zone:new-identifier</title><informalexample><programlisting>(define-values (%return) (time-zone:new-identifier identifier))
  2818. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>identifier</para></td><td class="parameter_description"><para></para><para>Passed as <code>identifier</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>time-zone:new</title><informalexample><programlisting>(define-values (%return) (time-zone:new identifier))
  2819. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>identifier</para></td><td class="parameter_description"><para></para><para>Passed as <code>identifier</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibTokenType&gt;</refname></refnamediv><refsect1><title>Description</title><para>The possible types of token returned from each
  2820. <function>g_scanner_get_next_token()</function> call.</para></refsect1><refsect1><title>Members</title><refsect2><title>eof</title><remark>alias <code>G_TOKEN_EOF</code></remark><para>the end of the file</para></refsect2><refsect2><title>left-paren</title><remark>alias <code>G_TOKEN_LEFT_PAREN</code></remark><para>a '(' character</para></refsect2><refsect2><title>right-paren</title><remark>alias <code>G_TOKEN_RIGHT_PAREN</code></remark><para>a ')' character</para></refsect2><refsect2><title>left-curly</title><remark>alias <code>G_TOKEN_LEFT_CURLY</code></remark><para>a '{' character</para></refsect2><refsect2><title>right-curly</title><remark>alias <code>G_TOKEN_RIGHT_CURLY</code></remark><para>a '}' character</para></refsect2><refsect2><title>left-brace</title><remark>alias <code>G_TOKEN_LEFT_BRACE</code></remark><para>a '[' character</para></refsect2><refsect2><title>right-brace</title><remark>alias <code>G_TOKEN_RIGHT_BRACE</code></remark><para>a ']' character</para></refsect2><refsect2><title>equal-sign</title><remark>alias <code>G_TOKEN_EQUAL_SIGN</code></remark><para>a '=' character</para></refsect2><refsect2><title>comma</title><remark>alias <code>G_TOKEN_COMMA</code></remark><para>a ',' character</para></refsect2><refsect2><title>none</title><remark>alias <code>G_TOKEN_NONE</code></remark><para>not a token</para></refsect2><refsect2><title>error</title><remark>alias <code>G_TOKEN_ERROR</code></remark><para>an error occurred</para></refsect2><refsect2><title>char</title><remark>alias <code>G_TOKEN_CHAR</code></remark><para>a character</para></refsect2><refsect2><title>binary</title><remark>alias <code>G_TOKEN_BINARY</code></remark><para>a binary integer</para></refsect2><refsect2><title>octal</title><remark>alias <code>G_TOKEN_OCTAL</code></remark><para>an octal integer</para></refsect2><refsect2><title>int</title><remark>alias <code>G_TOKEN_INT</code></remark><para>an integer</para></refsect2><refsect2><title>hex</title><remark>alias <code>G_TOKEN_HEX</code></remark><para>a hex integer</para></refsect2><refsect2><title>float</title><remark>alias <code>G_TOKEN_FLOAT</code></remark><para>a floating point number</para></refsect2><refsect2><title>string</title><remark>alias <code>G_TOKEN_STRING</code></remark><para>a string</para></refsect2><refsect2><title>symbol</title><remark>alias <code>G_TOKEN_SYMBOL</code></remark><para>a symbol</para></refsect2><refsect2><title>identifier</title><remark>alias <code>G_TOKEN_IDENTIFIER</code></remark><para>an identifier</para></refsect2><refsect2><title>identifier-null</title><remark>alias <code>G_TOKEN_IDENTIFIER_NULL</code></remark><para>a null identifier</para></refsect2><refsect2><title>comment-single</title><remark>alias <code>G_TOKEN_COMMENT_SINGLE</code></remark><para>one line comment</para></refsect2><refsect2><title>comment-multi</title><remark>alias <code>G_TOKEN_COMMENT_MULTI</code></remark><para>multi line comment</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibTraverseFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Specifies which nodes are visited during several of the tree
  2821. functions, including <function>g_node_traverse()</function> and <function>g_node_find()</function>.</para></refsect1><refsect1><title>Members</title><refsect2><title>leaves</title><remark>alias <code>G_TRAVERSE_LEAVES</code></remark><para>only leaf nodes should be visited. This name has
  2822. been introduced in 2.6, for older version use
  2823. <constant>G_TRAVERSE_LEAFS</constant>.</para></refsect2><refsect2><title>non-leaves</title><remark>alias <code>G_TRAVERSE_NON_LEAVES</code></remark><para>only non-leaf nodes should be visited. This
  2824. name has been introduced in 2.6, for older
  2825. version use <constant>G_TRAVERSE_NON_LEAFS</constant>.</para></refsect2><refsect2><title>all</title><remark>alias <code>G_TRAVERSE_ALL</code></remark><para>all nodes should be visited.</para></refsect2><refsect2><title>mask</title><remark>alias <code>G_TRAVERSE_MASK</code></remark><para>a mask of all traverse flags.</para></refsect2><refsect2><title>leafs</title><remark>alias <code>G_TRAVERSE_LEAFS</code></remark><para>identical to <constant>G_TRAVERSE_LEAVES</constant>.</para></refsect2><refsect2><title>non-leafs</title><remark>alias <code>G_TRAVERSE_NON_LEAFS</code></remark><para>identical to <constant>G_TRAVERSE_NON_LEAVES</constant>.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibTraverseType&gt;</refname></refnamediv><refsect1><title>Description</title><para>Specifies the type of traversal performed by <function>g_tree_traverse()</function>,
  2826. <function>g_node_traverse()</function> and <function>g_node_find()</function>. The different orders are
  2827. illustrated here:
  2828. - In order: A, B, C, D, E, F, G, H, I
  2829. ![](Sorted_binary_tree_inorder.svg)
  2830. - Pre order: F, B, A, D, C, E, G, I, H
  2831. ![](Sorted_binary_tree_preorder.svg)
  2832. - Post order: A, C, E, D, B, H, I, G, F
  2833. ![](Sorted_binary_tree_postorder.svg)
  2834. - Level order: F, B, G, A, D, I, C, E, H
  2835. ![](Sorted_binary_tree_breadth-first_traversal.svg)</para></refsect1><refsect1><title>Members</title><refsect2><title>in-order</title><remark>alias <code>G_IN_ORDER</code></remark><para>vists a node's left child first, then the node itself,
  2836. then its right child. This is the one to use if you
  2837. want the output sorted according to the compare
  2838. function.</para></refsect2><refsect2><title>pre-order</title><remark>alias <code>G_PRE_ORDER</code></remark><para>visits a node, then its children.</para></refsect2><refsect2><title>post-order</title><remark>alias <code>G_POST_ORDER</code></remark><para>visits the node's children, then the node itself.</para></refsect2><refsect2><title>level-order</title><remark>alias <code>G_LEVEL_ORDER</code></remark><para>is not implemented for
  2839. [balanced binary trees][glib-Balanced-Binary-Trees].
  2840. For [n-ary trees][glib-N-ary-Trees], it
  2841. vists the root node first, then its children, then
  2842. its grandchildren, and so on. Note that this is less
  2843. efficient than the other orders.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GTree&gt;</refname></refnamediv><refsect1><title>Description</title><para>The GTree struct is an opaque data structure representing a
  2844. [balanced binary tree][glib-Balanced-Binary-Trees]. It should be
  2845. accessed only by using the following functions.</para></refsect1><refsect1><title>Functions</title><refsect2><title>destroy</title><informalexample><programlisting>(define-values () (tree:destroy self))
  2846. </programlisting></informalexample><para>Removes all keys and values from the <type>GTree</type> and decreases its
  2847. reference count by one. If keys and/or values are dynamically
  2848. allocated, you should either free them first or create the <type>GTree</type>
  2849. using <function>g_tree_new_full()</function>. In the latter case the destroy functions
  2850. you supplied will be called on all keys and values before destroying
  2851. the <type>GTree</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para>a <type>GTree</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>height</title><informalexample><programlisting>(define-values (%return) (tree:height self))
  2852. </programlisting></informalexample><para>Gets the height of a <type>GTree</type>.
  2853. </para>
  2854. <para>If the <type>GTree</type> contains no nodes, the height is 0.
  2855. If the <type>GTree</type> contains only one root node the height is 1.
  2856. If the root node has children the height is 2, etc.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para>a <type>GTree</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>insert</title><informalexample><programlisting>(define-values () (tree:insert self key value))
  2857. </programlisting></informalexample><para>Inserts a key/value pair into a <type>GTree</type>.
  2858. </para>
  2859. <para>If the given key already exists in the <type>GTree</type> its corresponding value
  2860. is set to the new value. If you supplied a <parameter>value_destroy_func</parameter> when
  2861. creating the <type>GTree</type>, the old value is freed using that function. If
  2862. you supplied a <parameter>key_destroy_func</parameter> when creating the <type>GTree</type>, the passed
  2863. key is freed using that function.
  2864. </para>
  2865. <para>The tree is automatically 'balanced' as new key/value pairs are added,
  2866. so that the distance from the root to every leaf is as small as possible.
  2867. The cost of maintaining a balanced tree while inserting new key/value
  2868. result in a O(n log(n)) operation where most of the other operations
  2869. are O(log(n)).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para>a <type>GTree</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to insert</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>the value corresponding to the key</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>lookup</title><informalexample><programlisting>(define-values (%return) (tree:lookup self key))
  2870. </programlisting></informalexample><para>Gets the value corresponding to the given key. Since a <type>GTree</type> is
  2871. automatically balanced as key/value pairs are added, key lookup
  2872. is O(log n) (where n is the number of key/value pairs in the tree).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para>a <type>GTree</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to look up</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>lookup-extended</title><informalexample><programlisting>(define-values
  2873. (%return orig-key value)
  2874. (tree:lookup-extended self lookup-key))
  2875. </programlisting></informalexample><para>Looks up a key in the <type>GTree</type>, returning the original key and the
  2876. associated value. This is useful if you need to free the memory
  2877. allocated for the original key, for example before calling
  2878. <function>g_tree_remove()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para>a <type>GTree</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>lookup_key</para></td><td class="parameter_description"><para>the key to look up</para><para>Passed as <code>lookup-key</code></para></td></tr><tr><td class="parameter_name"><para>orig_key</para></td><td class="parameter_description"><para>returns the original key</para><para>Passed as <code>orig-key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>returns the value associated with the key</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>nnodes</title><informalexample><programlisting>(define-values (%return) (tree:nnodes self))
  2879. </programlisting></informalexample><para>Gets the number of nodes in a <type>GTree</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para>a <type>GTree</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (tree:ref self))
  2880. </programlisting></informalexample><para>Increments the reference count of <parameter>tree</parameter> by one.
  2881. </para>
  2882. <para>It is safe to call this function from any thread.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para>a <type>GTree</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>remove?</title><informalexample><programlisting>(define-values (%return) (tree:remove? self key))
  2883. </programlisting></informalexample><para>Removes a key/value pair from a <type>GTree</type>.
  2884. </para>
  2885. <para>If the <type>GTree</type> was created using <function>g_tree_new_full()</function>, the key and value
  2886. are freed using the supplied destroy functions, otherwise you have to
  2887. make sure that any dynamically allocated values are freed yourself.
  2888. If the key does not exist in the <type>GTree</type>, the function does nothing.
  2889. </para>
  2890. <para>The cost of maintaining a balanced tree while removing a key/value
  2891. result in a O(n log(n)) operation where most of the other operations
  2892. are O(log(n)).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para>a <type>GTree</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to remove</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>remove-all</title><informalexample><programlisting>(define-values () (tree:remove-all self))
  2893. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>replace</title><informalexample><programlisting>(define-values () (tree:replace self key value))
  2894. </programlisting></informalexample><para>Inserts a new key and value into a <type>GTree</type> similar to <function>g_tree_insert()</function>.
  2895. The difference is that if the key already exists in the <type>GTree</type>, it gets
  2896. replaced by the new key. If you supplied a <parameter>value_destroy_func</parameter> when
  2897. creating the <type>GTree</type>, the old value is freed using that function. If you
  2898. supplied a <parameter>key_destroy_func</parameter> when creating the <type>GTree</type>, the old key is
  2899. freed using that function.
  2900. </para>
  2901. <para>The tree is automatically 'balanced' as new key/value pairs are added,
  2902. so that the distance from the root to every leaf is as small as possible.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para>a <type>GTree</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to insert</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>the value corresponding to the key</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>steal?</title><informalexample><programlisting>(define-values (%return) (tree:steal? self key))
  2903. </programlisting></informalexample><para>Removes a key and its associated value from a <type>GTree</type> without calling
  2904. the key and value destroy functions.
  2905. </para>
  2906. <para>If the key does not exist in the <type>GTree</type>, the function does nothing.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para>a <type>GTree</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to remove</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (tree:unref self))
  2907. </programlisting></informalexample><para>Decrements the reference count of <parameter>tree</parameter> by one.
  2908. If the reference count drops to 0, all keys and values will
  2909. be destroyed (if destroy functions were specified) and all
  2910. memory allocated by <parameter>tree</parameter> will be released.
  2911. </para>
  2912. <para>It is safe to call this function from any thread.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tree</para></td><td class="parameter_description"><para>a <type>GTree</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>tree:new-full</title><informalexample><programlisting>(define-values
  2913. (%return)
  2914. (tree:new-full
  2915. key-compare-func
  2916. key-compare-data
  2917. key-destroy-func
  2918. value-destroy-func))
  2919. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_compare_func</para></td><td class="parameter_description"><para></para><para>Passed as <code>key-compare-func</code></para></td></tr><tr><td class="parameter_name"><para>key_compare_data</para></td><td class="parameter_description"><para></para><para>Passed as <code>key-compare-data</code></para></td></tr><tr><td class="parameter_name"><para>key_destroy_func</para></td><td class="parameter_description"><para></para><para>Passed as <code>key-destroy-func</code></para></td></tr><tr><td class="parameter_name"><para>value_destroy_func</para></td><td class="parameter_description"><para></para><para>Passed as <code>value-destroy-func</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibUnicodeBreakType&gt;</refname></refnamediv><refsect1><title>Description</title><para>These are the possible line break classifications.
  2920. </para>
  2921. <para>Since new unicode versions may add new types here, applications should be ready
  2922. to handle unknown values. They may be regarded as <constant>G_UNICODE_BREAK_UNKNOWN</constant>.
  2923. </para>
  2924. <para>See [Unicode Line Breaking Algorithm](http://www.unicode.org/unicode/reports/tr14/).</para></refsect1><refsect1><title>Members</title><refsect2><title>mandatory</title><remark>alias <code>G_UNICODE_BREAK_MANDATORY</code></remark><para>Mandatory Break (BK)</para></refsect2><refsect2><title>carriage-return</title><remark>alias <code>G_UNICODE_BREAK_CARRIAGE_RETURN</code></remark><para>Carriage Return (CR)</para></refsect2><refsect2><title>line-feed</title><remark>alias <code>G_UNICODE_BREAK_LINE_FEED</code></remark><para>Line Feed (LF)</para></refsect2><refsect2><title>combining-mark</title><remark>alias <code>G_UNICODE_BREAK_COMBINING_MARK</code></remark><para>Attached Characters and Combining Marks (CM)</para></refsect2><refsect2><title>surrogate</title><remark>alias <code>G_UNICODE_BREAK_SURROGATE</code></remark><para>Surrogates (SG)</para></refsect2><refsect2><title>zero-width-space</title><remark>alias <code>G_UNICODE_BREAK_ZERO_WIDTH_SPACE</code></remark><para>Zero Width Space (ZW)</para></refsect2><refsect2><title>inseparable</title><remark>alias <code>G_UNICODE_BREAK_INSEPARABLE</code></remark><para>Inseparable (IN)</para></refsect2><refsect2><title>non-breaking-glue</title><remark>alias <code>G_UNICODE_BREAK_NON_BREAKING_GLUE</code></remark><para>Non-breaking (&quot;Glue&quot;) (GL)</para></refsect2><refsect2><title>contingent</title><remark>alias <code>G_UNICODE_BREAK_CONTINGENT</code></remark><para>Contingent Break Opportunity (CB)</para></refsect2><refsect2><title>space</title><remark>alias <code>G_UNICODE_BREAK_SPACE</code></remark><para>Space (SP)</para></refsect2><refsect2><title>after</title><remark>alias <code>G_UNICODE_BREAK_AFTER</code></remark><para>Break Opportunity After (BA)</para></refsect2><refsect2><title>before</title><remark>alias <code>G_UNICODE_BREAK_BEFORE</code></remark><para>Break Opportunity Before (BB)</para></refsect2><refsect2><title>before-and-after</title><remark>alias <code>G_UNICODE_BREAK_BEFORE_AND_AFTER</code></remark><para>Break Opportunity Before and After (B2)</para></refsect2><refsect2><title>hyphen</title><remark>alias <code>G_UNICODE_BREAK_HYPHEN</code></remark><para>Hyphen (HY)</para></refsect2><refsect2><title>non-starter</title><remark>alias <code>G_UNICODE_BREAK_NON_STARTER</code></remark><para>Nonstarter (NS)</para></refsect2><refsect2><title>open-punctuation</title><remark>alias <code>G_UNICODE_BREAK_OPEN_PUNCTUATION</code></remark><para>Opening Punctuation (OP)</para></refsect2><refsect2><title>close-punctuation</title><remark>alias <code>G_UNICODE_BREAK_CLOSE_PUNCTUATION</code></remark><para>Closing Punctuation (CL)</para></refsect2><refsect2><title>quotation</title><remark>alias <code>G_UNICODE_BREAK_QUOTATION</code></remark><para>Ambiguous Quotation (QU)</para></refsect2><refsect2><title>exclamation</title><remark>alias <code>G_UNICODE_BREAK_EXCLAMATION</code></remark><para>Exclamation/Interrogation (EX)</para></refsect2><refsect2><title>ideographic</title><remark>alias <code>G_UNICODE_BREAK_IDEOGRAPHIC</code></remark><para>Ideographic (ID)</para></refsect2><refsect2><title>numeric</title><remark>alias <code>G_UNICODE_BREAK_NUMERIC</code></remark><para>Numeric (NU)</para></refsect2><refsect2><title>infix-separator</title><remark>alias <code>G_UNICODE_BREAK_INFIX_SEPARATOR</code></remark><para>Infix Separator (Numeric) (IS)</para></refsect2><refsect2><title>symbol</title><remark>alias <code>G_UNICODE_BREAK_SYMBOL</code></remark><para>Symbols Allowing Break After (SY)</para></refsect2><refsect2><title>alphabetic</title><remark>alias <code>G_UNICODE_BREAK_ALPHABETIC</code></remark><para>Ordinary Alphabetic and Symbol Characters (AL)</para></refsect2><refsect2><title>prefix</title><remark>alias <code>G_UNICODE_BREAK_PREFIX</code></remark><para>Prefix (Numeric) (PR)</para></refsect2><refsect2><title>postfix</title><remark>alias <code>G_UNICODE_BREAK_POSTFIX</code></remark><para>Postfix (Numeric) (PO)</para></refsect2><refsect2><title>complex-context</title><remark>alias <code>G_UNICODE_BREAK_COMPLEX_CONTEXT</code></remark><para>Complex Content Dependent (South East Asian) (SA)</para></refsect2><refsect2><title>ambiguous</title><remark>alias <code>G_UNICODE_BREAK_AMBIGUOUS</code></remark><para>Ambiguous (Alphabetic or Ideographic) (AI)</para></refsect2><refsect2><title>unknown</title><remark>alias <code>G_UNICODE_BREAK_UNKNOWN</code></remark><para>Unknown (XX)</para></refsect2><refsect2><title>next-line</title><remark>alias <code>G_UNICODE_BREAK_NEXT_LINE</code></remark><para>Next Line (NL)</para></refsect2><refsect2><title>word-joiner</title><remark>alias <code>G_UNICODE_BREAK_WORD_JOINER</code></remark><para>Word Joiner (WJ)</para></refsect2><refsect2><title>hangul-l-jamo</title><remark>alias <code>G_UNICODE_BREAK_HANGUL_L_JAMO</code></remark><para>Hangul L Jamo (JL)</para></refsect2><refsect2><title>hangul-v-jamo</title><remark>alias <code>G_UNICODE_BREAK_HANGUL_V_JAMO</code></remark><para>Hangul V Jamo (JV)</para></refsect2><refsect2><title>hangul-t-jamo</title><remark>alias <code>G_UNICODE_BREAK_HANGUL_T_JAMO</code></remark><para>Hangul T Jamo (JT)</para></refsect2><refsect2><title>hangul-lv-syllable</title><remark>alias <code>G_UNICODE_BREAK_HANGUL_LV_SYLLABLE</code></remark><para>Hangul LV Syllable (H2)</para></refsect2><refsect2><title>hangul-lvt-syllable</title><remark>alias <code>G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE</code></remark><para>Hangul LVT Syllable (H3)</para></refsect2><refsect2><title>close-paranthesis</title><remark>alias <code>G_UNICODE_BREAK_CLOSE_PARANTHESIS</code></remark><para>Closing Parenthesis (CP). Since 2.28. Deprecated: 2.70: Use <constant>G_UNICODE_BREAK_CLOSE_PARENTHESIS</constant> instead.</para></refsect2><refsect2><title>close-parenthesis</title><remark>alias <code>G_UNICODE_BREAK_CLOSE_PARENTHESIS</code></remark><para>Closing Parenthesis (CP). Since 2.70</para></refsect2><refsect2><title>conditional-japanese-starter</title><remark>alias <code>G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER</code></remark><para>Conditional Japanese Starter (CJ). Since: 2.32</para></refsect2><refsect2><title>hebrew-letter</title><remark>alias <code>G_UNICODE_BREAK_HEBREW_LETTER</code></remark><para>Hebrew Letter (HL). Since: 2.32</para></refsect2><refsect2><title>regional-indicator</title><remark>alias <code>G_UNICODE_BREAK_REGIONAL_INDICATOR</code></remark><para>Regional Indicator (RI). Since: 2.36</para></refsect2><refsect2><title>emoji-base</title><remark>alias <code>G_UNICODE_BREAK_EMOJI_BASE</code></remark><para>Emoji Base (EB). Since: 2.50</para></refsect2><refsect2><title>emoji-modifier</title><remark>alias <code>G_UNICODE_BREAK_EMOJI_MODIFIER</code></remark><para>Emoji Modifier (EM). Since: 2.50</para></refsect2><refsect2><title>zero-width-joiner</title><remark>alias <code>G_UNICODE_BREAK_ZERO_WIDTH_JOINER</code></remark><para>Zero Width Joiner (ZWJ). Since: 2.50</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibUnicodeScript&gt;</refname></refnamediv><refsect1><title>Description</title><para>The <type>GUnicodeScript</type> enumeration identifies different writing
  2925. systems. The values correspond to the names as defined in the
  2926. Unicode standard. The enumeration has been added in GLib 2.14,
  2927. and is interchangeable with <type>PangoScript</type>.
  2928. </para>
  2929. <para>Note that new types may be added in the future. Applications
  2930. should be ready to handle unknown values.
  2931. See [Unicode Standard Annex #24: Script names](http://www.unicode.org/reports/tr24/).</para></refsect1><refsect1><title>Members</title><refsect2><title>invalid-code</title><remark>alias <code>G_UNICODE_SCRIPT_INVALID_CODE</code></remark><para>a value never returned from <function>g_unichar_get_script()</function></para></refsect2><refsect2><title>common</title><remark>alias <code>G_UNICODE_SCRIPT_COMMON</code></remark><para>a character used by multiple different scripts</para></refsect2><refsect2><title>inherited</title><remark>alias <code>G_UNICODE_SCRIPT_INHERITED</code></remark><para>a mark glyph that takes its script from the
  2932. base glyph to which it is attached</para></refsect2><refsect2><title>arabic</title><remark>alias <code>G_UNICODE_SCRIPT_ARABIC</code></remark><para>Arabic</para></refsect2><refsect2><title>armenian</title><remark>alias <code>G_UNICODE_SCRIPT_ARMENIAN</code></remark><para>Armenian</para></refsect2><refsect2><title>bengali</title><remark>alias <code>G_UNICODE_SCRIPT_BENGALI</code></remark><para>Bengali</para></refsect2><refsect2><title>bopomofo</title><remark>alias <code>G_UNICODE_SCRIPT_BOPOMOFO</code></remark><para>Bopomofo</para></refsect2><refsect2><title>cherokee</title><remark>alias <code>G_UNICODE_SCRIPT_CHEROKEE</code></remark><para>Cherokee</para></refsect2><refsect2><title>coptic</title><remark>alias <code>G_UNICODE_SCRIPT_COPTIC</code></remark><para>Coptic</para></refsect2><refsect2><title>cyrillic</title><remark>alias <code>G_UNICODE_SCRIPT_CYRILLIC</code></remark><para>Cyrillic</para></refsect2><refsect2><title>deseret</title><remark>alias <code>G_UNICODE_SCRIPT_DESERET</code></remark><para>Deseret</para></refsect2><refsect2><title>devanagari</title><remark>alias <code>G_UNICODE_SCRIPT_DEVANAGARI</code></remark><para>Devanagari</para></refsect2><refsect2><title>ethiopic</title><remark>alias <code>G_UNICODE_SCRIPT_ETHIOPIC</code></remark><para>Ethiopic</para></refsect2><refsect2><title>georgian</title><remark>alias <code>G_UNICODE_SCRIPT_GEORGIAN</code></remark><para>Georgian</para></refsect2><refsect2><title>gothic</title><remark>alias <code>G_UNICODE_SCRIPT_GOTHIC</code></remark><para>Gothic</para></refsect2><refsect2><title>greek</title><remark>alias <code>G_UNICODE_SCRIPT_GREEK</code></remark><para>Greek</para></refsect2><refsect2><title>gujarati</title><remark>alias <code>G_UNICODE_SCRIPT_GUJARATI</code></remark><para>Gujarati</para></refsect2><refsect2><title>gurmukhi</title><remark>alias <code>G_UNICODE_SCRIPT_GURMUKHI</code></remark><para>Gurmukhi</para></refsect2><refsect2><title>han</title><remark>alias <code>G_UNICODE_SCRIPT_HAN</code></remark><para>Han</para></refsect2><refsect2><title>hangul</title><remark>alias <code>G_UNICODE_SCRIPT_HANGUL</code></remark><para>Hangul</para></refsect2><refsect2><title>hebrew</title><remark>alias <code>G_UNICODE_SCRIPT_HEBREW</code></remark><para>Hebrew</para></refsect2><refsect2><title>hiragana</title><remark>alias <code>G_UNICODE_SCRIPT_HIRAGANA</code></remark><para>Hiragana</para></refsect2><refsect2><title>kannada</title><remark>alias <code>G_UNICODE_SCRIPT_KANNADA</code></remark><para>Kannada</para></refsect2><refsect2><title>katakana</title><remark>alias <code>G_UNICODE_SCRIPT_KATAKANA</code></remark><para>Katakana</para></refsect2><refsect2><title>khmer</title><remark>alias <code>G_UNICODE_SCRIPT_KHMER</code></remark><para>Khmer</para></refsect2><refsect2><title>lao</title><remark>alias <code>G_UNICODE_SCRIPT_LAO</code></remark><para>Lao</para></refsect2><refsect2><title>latin</title><remark>alias <code>G_UNICODE_SCRIPT_LATIN</code></remark><para>Latin</para></refsect2><refsect2><title>malayalam</title><remark>alias <code>G_UNICODE_SCRIPT_MALAYALAM</code></remark><para>Malayalam</para></refsect2><refsect2><title>mongolian</title><remark>alias <code>G_UNICODE_SCRIPT_MONGOLIAN</code></remark><para>Mongolian</para></refsect2><refsect2><title>myanmar</title><remark>alias <code>G_UNICODE_SCRIPT_MYANMAR</code></remark><para>Myanmar</para></refsect2><refsect2><title>ogham</title><remark>alias <code>G_UNICODE_SCRIPT_OGHAM</code></remark><para>Ogham</para></refsect2><refsect2><title>old-italic</title><remark>alias <code>G_UNICODE_SCRIPT_OLD_ITALIC</code></remark><para>Old Italic</para></refsect2><refsect2><title>oriya</title><remark>alias <code>G_UNICODE_SCRIPT_ORIYA</code></remark><para>Oriya</para></refsect2><refsect2><title>runic</title><remark>alias <code>G_UNICODE_SCRIPT_RUNIC</code></remark><para>Runic</para></refsect2><refsect2><title>sinhala</title><remark>alias <code>G_UNICODE_SCRIPT_SINHALA</code></remark><para>Sinhala</para></refsect2><refsect2><title>syriac</title><remark>alias <code>G_UNICODE_SCRIPT_SYRIAC</code></remark><para>Syriac</para></refsect2><refsect2><title>tamil</title><remark>alias <code>G_UNICODE_SCRIPT_TAMIL</code></remark><para>Tamil</para></refsect2><refsect2><title>telugu</title><remark>alias <code>G_UNICODE_SCRIPT_TELUGU</code></remark><para>Telugu</para></refsect2><refsect2><title>thaana</title><remark>alias <code>G_UNICODE_SCRIPT_THAANA</code></remark><para>Thaana</para></refsect2><refsect2><title>thai</title><remark>alias <code>G_UNICODE_SCRIPT_THAI</code></remark><para>Thai</para></refsect2><refsect2><title>tibetan</title><remark>alias <code>G_UNICODE_SCRIPT_TIBETAN</code></remark><para>Tibetan</para></refsect2><refsect2><title>canadian-aboriginal</title><remark>alias <code>G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL</code></remark><para>Canadian Aboriginal</para></refsect2><refsect2><title>yi</title><remark>alias <code>G_UNICODE_SCRIPT_YI</code></remark><para>Yi</para></refsect2><refsect2><title>tagalog</title><remark>alias <code>G_UNICODE_SCRIPT_TAGALOG</code></remark><para>Tagalog</para></refsect2><refsect2><title>hanunoo</title><remark>alias <code>G_UNICODE_SCRIPT_HANUNOO</code></remark><para>Hanunoo</para></refsect2><refsect2><title>buhid</title><remark>alias <code>G_UNICODE_SCRIPT_BUHID</code></remark><para>Buhid</para></refsect2><refsect2><title>tagbanwa</title><remark>alias <code>G_UNICODE_SCRIPT_TAGBANWA</code></remark><para>Tagbanwa</para></refsect2><refsect2><title>braille</title><remark>alias <code>G_UNICODE_SCRIPT_BRAILLE</code></remark><para>Braille</para></refsect2><refsect2><title>cypriot</title><remark>alias <code>G_UNICODE_SCRIPT_CYPRIOT</code></remark><para>Cypriot</para></refsect2><refsect2><title>limbu</title><remark>alias <code>G_UNICODE_SCRIPT_LIMBU</code></remark><para>Limbu</para></refsect2><refsect2><title>osmanya</title><remark>alias <code>G_UNICODE_SCRIPT_OSMANYA</code></remark><para>Osmanya</para></refsect2><refsect2><title>shavian</title><remark>alias <code>G_UNICODE_SCRIPT_SHAVIAN</code></remark><para>Shavian</para></refsect2><refsect2><title>linear-b</title><remark>alias <code>G_UNICODE_SCRIPT_LINEAR_B</code></remark><para>Linear B</para></refsect2><refsect2><title>tai-le</title><remark>alias <code>G_UNICODE_SCRIPT_TAI_LE</code></remark><para>Tai Le</para></refsect2><refsect2><title>ugaritic</title><remark>alias <code>G_UNICODE_SCRIPT_UGARITIC</code></remark><para>Ugaritic</para></refsect2><refsect2><title>new-tai-lue</title><remark>alias <code>G_UNICODE_SCRIPT_NEW_TAI_LUE</code></remark><para>New Tai Lue</para></refsect2><refsect2><title>buginese</title><remark>alias <code>G_UNICODE_SCRIPT_BUGINESE</code></remark><para>Buginese</para></refsect2><refsect2><title>glagolitic</title><remark>alias <code>G_UNICODE_SCRIPT_GLAGOLITIC</code></remark><para>Glagolitic</para></refsect2><refsect2><title>tifinagh</title><remark>alias <code>G_UNICODE_SCRIPT_TIFINAGH</code></remark><para>Tifinagh</para></refsect2><refsect2><title>syloti-nagri</title><remark>alias <code>G_UNICODE_SCRIPT_SYLOTI_NAGRI</code></remark><para>Syloti Nagri</para></refsect2><refsect2><title>old-persian</title><remark>alias <code>G_UNICODE_SCRIPT_OLD_PERSIAN</code></remark><para>Old Persian</para></refsect2><refsect2><title>kharoshthi</title><remark>alias <code>G_UNICODE_SCRIPT_KHAROSHTHI</code></remark><para>Kharoshthi</para></refsect2><refsect2><title>unknown</title><remark>alias <code>G_UNICODE_SCRIPT_UNKNOWN</code></remark><para>an unassigned code point</para></refsect2><refsect2><title>balinese</title><remark>alias <code>G_UNICODE_SCRIPT_BALINESE</code></remark><para>Balinese</para></refsect2><refsect2><title>cuneiform</title><remark>alias <code>G_UNICODE_SCRIPT_CUNEIFORM</code></remark><para>Cuneiform</para></refsect2><refsect2><title>phoenician</title><remark>alias <code>G_UNICODE_SCRIPT_PHOENICIAN</code></remark><para>Phoenician</para></refsect2><refsect2><title>phags-pa</title><remark>alias <code>G_UNICODE_SCRIPT_PHAGS_PA</code></remark><para>Phags-pa</para></refsect2><refsect2><title>nko</title><remark>alias <code>G_UNICODE_SCRIPT_NKO</code></remark><para>N'Ko</para></refsect2><refsect2><title>kayah-li</title><remark>alias <code>G_UNICODE_SCRIPT_KAYAH_LI</code></remark><para>Kayah Li. Since 2.16.3</para></refsect2><refsect2><title>lepcha</title><remark>alias <code>G_UNICODE_SCRIPT_LEPCHA</code></remark><para>Lepcha. Since 2.16.3</para></refsect2><refsect2><title>rejang</title><remark>alias <code>G_UNICODE_SCRIPT_REJANG</code></remark><para>Rejang. Since 2.16.3</para></refsect2><refsect2><title>sundanese</title><remark>alias <code>G_UNICODE_SCRIPT_SUNDANESE</code></remark><para>Sundanese. Since 2.16.3</para></refsect2><refsect2><title>saurashtra</title><remark>alias <code>G_UNICODE_SCRIPT_SAURASHTRA</code></remark><para>Saurashtra. Since 2.16.3</para></refsect2><refsect2><title>cham</title><remark>alias <code>G_UNICODE_SCRIPT_CHAM</code></remark><para>Cham. Since 2.16.3</para></refsect2><refsect2><title>ol-chiki</title><remark>alias <code>G_UNICODE_SCRIPT_OL_CHIKI</code></remark><para>Ol Chiki. Since 2.16.3</para></refsect2><refsect2><title>vai</title><remark>alias <code>G_UNICODE_SCRIPT_VAI</code></remark><para>Vai. Since 2.16.3</para></refsect2><refsect2><title>carian</title><remark>alias <code>G_UNICODE_SCRIPT_CARIAN</code></remark><para>Carian. Since 2.16.3</para></refsect2><refsect2><title>lycian</title><remark>alias <code>G_UNICODE_SCRIPT_LYCIAN</code></remark><para>Lycian. Since 2.16.3</para></refsect2><refsect2><title>lydian</title><remark>alias <code>G_UNICODE_SCRIPT_LYDIAN</code></remark><para>Lydian. Since 2.16.3</para></refsect2><refsect2><title>avestan</title><remark>alias <code>G_UNICODE_SCRIPT_AVESTAN</code></remark><para>Avestan. Since 2.26</para></refsect2><refsect2><title>bamum</title><remark>alias <code>G_UNICODE_SCRIPT_BAMUM</code></remark><para>Bamum. Since 2.26</para></refsect2><refsect2><title>egyptian-hieroglyphs</title><remark>alias <code>G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS</code></remark><para>Egyptian Hieroglpyhs. Since 2.26</para></refsect2><refsect2><title>imperial-aramaic</title><remark>alias <code>G_UNICODE_SCRIPT_IMPERIAL_ARAMAIC</code></remark><para>Imperial Aramaic. Since 2.26</para></refsect2><refsect2><title>inscriptional-pahlavi</title><remark>alias <code>G_UNICODE_SCRIPT_INSCRIPTIONAL_PAHLAVI</code></remark><para>Inscriptional Pahlavi. Since 2.26</para></refsect2><refsect2><title>inscriptional-parthian</title><remark>alias <code>G_UNICODE_SCRIPT_INSCRIPTIONAL_PARTHIAN</code></remark><para>Inscriptional Parthian. Since 2.26</para></refsect2><refsect2><title>javanese</title><remark>alias <code>G_UNICODE_SCRIPT_JAVANESE</code></remark><para>Javanese. Since 2.26</para></refsect2><refsect2><title>kaithi</title><remark>alias <code>G_UNICODE_SCRIPT_KAITHI</code></remark><para>Kaithi. Since 2.26</para></refsect2><refsect2><title>lisu</title><remark>alias <code>G_UNICODE_SCRIPT_LISU</code></remark><para>Lisu. Since 2.26</para></refsect2><refsect2><title>meetei-mayek</title><remark>alias <code>G_UNICODE_SCRIPT_MEETEI_MAYEK</code></remark><para>Meetei Mayek. Since 2.26</para></refsect2><refsect2><title>old-south-arabian</title><remark>alias <code>G_UNICODE_SCRIPT_OLD_SOUTH_ARABIAN</code></remark><para>Old South Arabian. Since 2.26</para></refsect2><refsect2><title>old-turkic</title><remark>alias <code>G_UNICODE_SCRIPT_OLD_TURKIC</code></remark><para>Old Turkic. Since 2.28</para></refsect2><refsect2><title>samaritan</title><remark>alias <code>G_UNICODE_SCRIPT_SAMARITAN</code></remark><para>Samaritan. Since 2.26</para></refsect2><refsect2><title>tai-tham</title><remark>alias <code>G_UNICODE_SCRIPT_TAI_THAM</code></remark><para>Tai Tham. Since 2.26</para></refsect2><refsect2><title>tai-viet</title><remark>alias <code>G_UNICODE_SCRIPT_TAI_VIET</code></remark><para>Tai Viet. Since 2.26</para></refsect2><refsect2><title>batak</title><remark>alias <code>G_UNICODE_SCRIPT_BATAK</code></remark><para>Batak. Since 2.28</para></refsect2><refsect2><title>brahmi</title><remark>alias <code>G_UNICODE_SCRIPT_BRAHMI</code></remark><para>Brahmi. Since 2.28</para></refsect2><refsect2><title>mandaic</title><remark>alias <code>G_UNICODE_SCRIPT_MANDAIC</code></remark><para>Mandaic. Since 2.28</para></refsect2><refsect2><title>chakma</title><remark>alias <code>G_UNICODE_SCRIPT_CHAKMA</code></remark><para>Chakma. Since: 2.32</para></refsect2><refsect2><title>meroitic-cursive</title><remark>alias <code>G_UNICODE_SCRIPT_MEROITIC_CURSIVE</code></remark><para>Meroitic Cursive. Since: 2.32</para></refsect2><refsect2><title>meroitic-hieroglyphs</title><remark>alias <code>G_UNICODE_SCRIPT_MEROITIC_HIEROGLYPHS</code></remark><para>Meroitic Hieroglyphs. Since: 2.32</para></refsect2><refsect2><title>miao</title><remark>alias <code>G_UNICODE_SCRIPT_MIAO</code></remark><para>Miao. Since: 2.32</para></refsect2><refsect2><title>sharada</title><remark>alias <code>G_UNICODE_SCRIPT_SHARADA</code></remark><para>Sharada. Since: 2.32</para></refsect2><refsect2><title>sora-sompeng</title><remark>alias <code>G_UNICODE_SCRIPT_SORA_SOMPENG</code></remark><para>Sora Sompeng. Since: 2.32</para></refsect2><refsect2><title>takri</title><remark>alias <code>G_UNICODE_SCRIPT_TAKRI</code></remark><para>Takri. Since: 2.32</para></refsect2><refsect2><title>bassa-vah</title><remark>alias <code>G_UNICODE_SCRIPT_BASSA_VAH</code></remark><para>Bassa. Since: 2.42</para></refsect2><refsect2><title>caucasian-albanian</title><remark>alias <code>G_UNICODE_SCRIPT_CAUCASIAN_ALBANIAN</code></remark><para>Caucasian Albanian. Since: 2.42</para></refsect2><refsect2><title>duployan</title><remark>alias <code>G_UNICODE_SCRIPT_DUPLOYAN</code></remark><para>Duployan. Since: 2.42</para></refsect2><refsect2><title>elbasan</title><remark>alias <code>G_UNICODE_SCRIPT_ELBASAN</code></remark><para>Elbasan. Since: 2.42</para></refsect2><refsect2><title>grantha</title><remark>alias <code>G_UNICODE_SCRIPT_GRANTHA</code></remark><para>Grantha. Since: 2.42</para></refsect2><refsect2><title>khojki</title><remark>alias <code>G_UNICODE_SCRIPT_KHOJKI</code></remark><para>Kjohki. Since: 2.42</para></refsect2><refsect2><title>khudawadi</title><remark>alias <code>G_UNICODE_SCRIPT_KHUDAWADI</code></remark><para>Khudawadi, Sindhi. Since: 2.42</para></refsect2><refsect2><title>linear-a</title><remark>alias <code>G_UNICODE_SCRIPT_LINEAR_A</code></remark><para>Linear A. Since: 2.42</para></refsect2><refsect2><title>mahajani</title><remark>alias <code>G_UNICODE_SCRIPT_MAHAJANI</code></remark><para>Mahajani. Since: 2.42</para></refsect2><refsect2><title>manichaean</title><remark>alias <code>G_UNICODE_SCRIPT_MANICHAEAN</code></remark><para>Manichaean. Since: 2.42</para></refsect2><refsect2><title>mende-kikakui</title><remark>alias <code>G_UNICODE_SCRIPT_MENDE_KIKAKUI</code></remark><para>Mende Kikakui. Since: 2.42</para></refsect2><refsect2><title>modi</title><remark>alias <code>G_UNICODE_SCRIPT_MODI</code></remark><para>Modi. Since: 2.42</para></refsect2><refsect2><title>mro</title><remark>alias <code>G_UNICODE_SCRIPT_MRO</code></remark><para>Mro. Since: 2.42</para></refsect2><refsect2><title>nabataean</title><remark>alias <code>G_UNICODE_SCRIPT_NABATAEAN</code></remark><para>Nabataean. Since: 2.42</para></refsect2><refsect2><title>old-north-arabian</title><remark>alias <code>G_UNICODE_SCRIPT_OLD_NORTH_ARABIAN</code></remark><para>Old North Arabian. Since: 2.42</para></refsect2><refsect2><title>old-permic</title><remark>alias <code>G_UNICODE_SCRIPT_OLD_PERMIC</code></remark><para>Old Permic. Since: 2.42</para></refsect2><refsect2><title>pahawh-hmong</title><remark>alias <code>G_UNICODE_SCRIPT_PAHAWH_HMONG</code></remark><para>Pahawh Hmong. Since: 2.42</para></refsect2><refsect2><title>palmyrene</title><remark>alias <code>G_UNICODE_SCRIPT_PALMYRENE</code></remark><para>Palmyrene. Since: 2.42</para></refsect2><refsect2><title>pau-cin-hau</title><remark>alias <code>G_UNICODE_SCRIPT_PAU_CIN_HAU</code></remark><para>Pau Cin Hau. Since: 2.42</para></refsect2><refsect2><title>psalter-pahlavi</title><remark>alias <code>G_UNICODE_SCRIPT_PSALTER_PAHLAVI</code></remark><para>Psalter Pahlavi. Since: 2.42</para></refsect2><refsect2><title>siddham</title><remark>alias <code>G_UNICODE_SCRIPT_SIDDHAM</code></remark><para>Siddham. Since: 2.42</para></refsect2><refsect2><title>tirhuta</title><remark>alias <code>G_UNICODE_SCRIPT_TIRHUTA</code></remark><para>Tirhuta. Since: 2.42</para></refsect2><refsect2><title>warang-citi</title><remark>alias <code>G_UNICODE_SCRIPT_WARANG_CITI</code></remark><para>Warang Citi. Since: 2.42</para></refsect2><refsect2><title>ahom</title><remark>alias <code>G_UNICODE_SCRIPT_AHOM</code></remark><para>Ahom. Since: 2.48</para></refsect2><refsect2><title>anatolian-hieroglyphs</title><remark>alias <code>G_UNICODE_SCRIPT_ANATOLIAN_HIEROGLYPHS</code></remark><para>Anatolian Hieroglyphs. Since: 2.48</para></refsect2><refsect2><title>hatran</title><remark>alias <code>G_UNICODE_SCRIPT_HATRAN</code></remark><para>Hatran. Since: 2.48</para></refsect2><refsect2><title>multani</title><remark>alias <code>G_UNICODE_SCRIPT_MULTANI</code></remark><para>Multani. Since: 2.48</para></refsect2><refsect2><title>old-hungarian</title><remark>alias <code>G_UNICODE_SCRIPT_OLD_HUNGARIAN</code></remark><para>Old Hungarian. Since: 2.48</para></refsect2><refsect2><title>signwriting</title><remark>alias <code>G_UNICODE_SCRIPT_SIGNWRITING</code></remark><para>Signwriting. Since: 2.48</para></refsect2><refsect2><title>adlam</title><remark>alias <code>G_UNICODE_SCRIPT_ADLAM</code></remark><para>Adlam. Since: 2.50</para></refsect2><refsect2><title>bhaiksuki</title><remark>alias <code>G_UNICODE_SCRIPT_BHAIKSUKI</code></remark><para>Bhaiksuki. Since: 2.50</para></refsect2><refsect2><title>marchen</title><remark>alias <code>G_UNICODE_SCRIPT_MARCHEN</code></remark><para>Marchen. Since: 2.50</para></refsect2><refsect2><title>newa</title><remark>alias <code>G_UNICODE_SCRIPT_NEWA</code></remark><para>Newa. Since: 2.50</para></refsect2><refsect2><title>osage</title><remark>alias <code>G_UNICODE_SCRIPT_OSAGE</code></remark><para>Osage. Since: 2.50</para></refsect2><refsect2><title>tangut</title><remark>alias <code>G_UNICODE_SCRIPT_TANGUT</code></remark><para>Tangut. Since: 2.50</para></refsect2><refsect2><title>masaram-gondi</title><remark>alias <code>G_UNICODE_SCRIPT_MASARAM_GONDI</code></remark><para>Masaram Gondi. Since: 2.54</para></refsect2><refsect2><title>nushu</title><remark>alias <code>G_UNICODE_SCRIPT_NUSHU</code></remark><para>Nushu. Since: 2.54</para></refsect2><refsect2><title>soyombo</title><remark>alias <code>G_UNICODE_SCRIPT_SOYOMBO</code></remark><para>Soyombo. Since: 2.54</para></refsect2><refsect2><title>zanabazar-square</title><remark>alias <code>G_UNICODE_SCRIPT_ZANABAZAR_SQUARE</code></remark><para>Zanabazar Square. Since: 2.54</para></refsect2><refsect2><title>dogra</title><remark>alias <code>G_UNICODE_SCRIPT_DOGRA</code></remark><para>Dogra. Since: 2.58</para></refsect2><refsect2><title>gunjala-gondi</title><remark>alias <code>G_UNICODE_SCRIPT_GUNJALA_GONDI</code></remark><para>Gunjala Gondi. Since: 2.58</para></refsect2><refsect2><title>hanifi-rohingya</title><remark>alias <code>G_UNICODE_SCRIPT_HANIFI_ROHINGYA</code></remark><para>Hanifi Rohingya. Since: 2.58</para></refsect2><refsect2><title>makasar</title><remark>alias <code>G_UNICODE_SCRIPT_MAKASAR</code></remark><para>Makasar. Since: 2.58</para></refsect2><refsect2><title>medefaidrin</title><remark>alias <code>G_UNICODE_SCRIPT_MEDEFAIDRIN</code></remark><para>Medefaidrin. Since: 2.58</para></refsect2><refsect2><title>old-sogdian</title><remark>alias <code>G_UNICODE_SCRIPT_OLD_SOGDIAN</code></remark><para>Old Sogdian. Since: 2.58</para></refsect2><refsect2><title>sogdian</title><remark>alias <code>G_UNICODE_SCRIPT_SOGDIAN</code></remark><para>Sogdian. Since: 2.58</para></refsect2><refsect2><title>elymaic</title><remark>alias <code>G_UNICODE_SCRIPT_ELYMAIC</code></remark><para>Elym. Since: 2.62</para></refsect2><refsect2><title>nandinagari</title><remark>alias <code>G_UNICODE_SCRIPT_NANDINAGARI</code></remark><para>Nand. Since: 2.62</para></refsect2><refsect2><title>nyiakeng-puachue-hmong</title><remark>alias <code>G_UNICODE_SCRIPT_NYIAKENG_PUACHUE_HMONG</code></remark><para>Rohg. Since: 2.62</para></refsect2><refsect2><title>wancho</title><remark>alias <code>G_UNICODE_SCRIPT_WANCHO</code></remark><para>Wcho. Since: 2.62</para></refsect2><refsect2><title>chorasmian</title><remark>alias <code>G_UNICODE_SCRIPT_CHORASMIAN</code></remark><para>Chorasmian. Since: 2.66</para></refsect2><refsect2><title>dives-akuru</title><remark>alias <code>G_UNICODE_SCRIPT_DIVES_AKURU</code></remark><para>Dives Akuru. Since: 2.66</para></refsect2><refsect2><title>khitan-small-script</title><remark>alias <code>G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT</code></remark><para>Khitan small script. Since: 2.66</para></refsect2><refsect2><title>yezidi</title><remark>alias <code>G_UNICODE_SCRIPT_YEZIDI</code></remark><para>Yezidi. Since: 2.66</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibUnicodeType&gt;</refname></refnamediv><refsect1><title>Description</title><para>These are the possible character classifications from the
  2933. Unicode specification.
  2934. See [Unicode Character Database](http://www.unicode.org/reports/tr44/<type>General_Category_Values</type>).</para></refsect1><refsect1><title>Members</title><refsect2><title>control</title><remark>alias <code>G_UNICODE_CONTROL</code></remark><para>General category &quot;Other, Control&quot; (Cc)</para></refsect2><refsect2><title>format</title><remark>alias <code>G_UNICODE_FORMAT</code></remark><para>General category &quot;Other, Format&quot; (Cf)</para></refsect2><refsect2><title>unassigned</title><remark>alias <code>G_UNICODE_UNASSIGNED</code></remark><para>General category &quot;Other, Not Assigned&quot; (Cn)</para></refsect2><refsect2><title>private-use</title><remark>alias <code>G_UNICODE_PRIVATE_USE</code></remark><para>General category &quot;Other, Private Use&quot; (Co)</para></refsect2><refsect2><title>surrogate</title><remark>alias <code>G_UNICODE_SURROGATE</code></remark><para>General category &quot;Other, Surrogate&quot; (Cs)</para></refsect2><refsect2><title>lowercase-letter</title><remark>alias <code>G_UNICODE_LOWERCASE_LETTER</code></remark><para>General category &quot;Letter, Lowercase&quot; (Ll)</para></refsect2><refsect2><title>modifier-letter</title><remark>alias <code>G_UNICODE_MODIFIER_LETTER</code></remark><para>General category &quot;Letter, Modifier&quot; (Lm)</para></refsect2><refsect2><title>other-letter</title><remark>alias <code>G_UNICODE_OTHER_LETTER</code></remark><para>General category &quot;Letter, Other&quot; (Lo)</para></refsect2><refsect2><title>titlecase-letter</title><remark>alias <code>G_UNICODE_TITLECASE_LETTER</code></remark><para>General category &quot;Letter, Titlecase&quot; (Lt)</para></refsect2><refsect2><title>uppercase-letter</title><remark>alias <code>G_UNICODE_UPPERCASE_LETTER</code></remark><para>General category &quot;Letter, Uppercase&quot; (Lu)</para></refsect2><refsect2><title>spacing-mark</title><remark>alias <code>G_UNICODE_SPACING_MARK</code></remark><para>General category &quot;Mark, Spacing&quot; (Mc)</para></refsect2><refsect2><title>enclosing-mark</title><remark>alias <code>G_UNICODE_ENCLOSING_MARK</code></remark><para>General category &quot;Mark, Enclosing&quot; (Me)</para></refsect2><refsect2><title>non-spacing-mark</title><remark>alias <code>G_UNICODE_NON_SPACING_MARK</code></remark><para>General category &quot;Mark, Nonspacing&quot; (Mn)</para></refsect2><refsect2><title>decimal-number</title><remark>alias <code>G_UNICODE_DECIMAL_NUMBER</code></remark><para>General category &quot;Number, Decimal Digit&quot; (Nd)</para></refsect2><refsect2><title>letter-number</title><remark>alias <code>G_UNICODE_LETTER_NUMBER</code></remark><para>General category &quot;Number, Letter&quot; (Nl)</para></refsect2><refsect2><title>other-number</title><remark>alias <code>G_UNICODE_OTHER_NUMBER</code></remark><para>General category &quot;Number, Other&quot; (No)</para></refsect2><refsect2><title>connect-punctuation</title><remark>alias <code>G_UNICODE_CONNECT_PUNCTUATION</code></remark><para>General category &quot;Punctuation, Connector&quot; (Pc)</para></refsect2><refsect2><title>dash-punctuation</title><remark>alias <code>G_UNICODE_DASH_PUNCTUATION</code></remark><para>General category &quot;Punctuation, Dash&quot; (Pd)</para></refsect2><refsect2><title>close-punctuation</title><remark>alias <code>G_UNICODE_CLOSE_PUNCTUATION</code></remark><para>General category &quot;Punctuation, Close&quot; (Pe)</para></refsect2><refsect2><title>final-punctuation</title><remark>alias <code>G_UNICODE_FINAL_PUNCTUATION</code></remark><para>General category &quot;Punctuation, Final quote&quot; (Pf)</para></refsect2><refsect2><title>initial-punctuation</title><remark>alias <code>G_UNICODE_INITIAL_PUNCTUATION</code></remark><para>General category &quot;Punctuation, Initial quote&quot; (Pi)</para></refsect2><refsect2><title>other-punctuation</title><remark>alias <code>G_UNICODE_OTHER_PUNCTUATION</code></remark><para>General category &quot;Punctuation, Other&quot; (Po)</para></refsect2><refsect2><title>open-punctuation</title><remark>alias <code>G_UNICODE_OPEN_PUNCTUATION</code></remark><para>General category &quot;Punctuation, Open&quot; (Ps)</para></refsect2><refsect2><title>currency-symbol</title><remark>alias <code>G_UNICODE_CURRENCY_SYMBOL</code></remark><para>General category &quot;Symbol, Currency&quot; (Sc)</para></refsect2><refsect2><title>modifier-symbol</title><remark>alias <code>G_UNICODE_MODIFIER_SYMBOL</code></remark><para>General category &quot;Symbol, Modifier&quot; (Sk)</para></refsect2><refsect2><title>math-symbol</title><remark>alias <code>G_UNICODE_MATH_SYMBOL</code></remark><para>General category &quot;Symbol, Math&quot; (Sm)</para></refsect2><refsect2><title>other-symbol</title><remark>alias <code>G_UNICODE_OTHER_SYMBOL</code></remark><para>General category &quot;Symbol, Other&quot; (So)</para></refsect2><refsect2><title>line-separator</title><remark>alias <code>G_UNICODE_LINE_SEPARATOR</code></remark><para>General category &quot;Separator, Line&quot; (Zl)</para></refsect2><refsect2><title>paragraph-separator</title><remark>alias <code>G_UNICODE_PARAGRAPH_SEPARATOR</code></remark><para>General category &quot;Separator, Paragraph&quot; (Zp)</para></refsect2><refsect2><title>space-separator</title><remark>alias <code>G_UNICODE_SPACE_SEPARATOR</code></remark><para>General category &quot;Separator, Space&quot; (Zs)</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GUri&gt;</refname></refnamediv><refsect1><title>Description</title><para>The <type>GUri</type> type and related functions can be used to parse URIs into
  2935. their components, and build valid URIs from individual components.
  2936. </para>
  2937. <para>Note that <type>GUri</type> scope is to help manipulate URIs in various applications,
  2938. following [RFC 3986](https://tools.ietf.org/html/rfc3986). In particular,
  2939. it doesn't intend to cover web browser needs, and doesn't implement the
  2940. [WHATWG URL](https://url.spec.whatwg.org/) standard. No APIs are provided to
  2941. help prevent
  2942. [homograph attacks](https://en.wikipedia.org/wiki/IDN_homograph_attack), so
  2943. <type>GUri</type> is not suitable for formatting URIs for display to the user for making
  2944. security-sensitive decisions.
  2945. </para>
  2946. <refsect2><title>Relative and absolute URIs <anchor id="relative-absolute-uris" /></title>
  2947. <para>As defined in [RFC 3986](https://tools.ietf.org/html/rfc3986#section-4), the
  2948. hierarchical nature of URIs means that they can either be ‘relative
  2949. references’ (sometimes referred to as ‘relative URIs’) or ‘URIs’ (for
  2950. clarity, ‘URIs’ are referred to in this documentation as
  2951. ‘absolute URIs’ — although
  2952. [in constrast to RFC 3986](https://tools.ietf.org/html/rfc3986#section-4.3),
  2953. fragment identifiers are always allowed).
  2954. </para>
  2955. <para>Relative references have one or more components of the URI missing. In
  2956. particular, they have no scheme. Any other component, such as hostname,
  2957. query, etc. may be missing, apart from a path, which has to be specified (but
  2958. may be empty). The path may be relative, starting with <code>./</code> rather than <code>/</code>.
  2959. </para>
  2960. <para>For example, a valid relative reference is <code>./path?query</code>,
  2961. <code>/?query#fragment</code> or <code>//example.com</code>.
  2962. </para>
  2963. <para>Absolute URIs have a scheme specified. Any other components of the URI which
  2964. are missing are specified as explicitly unset in the URI, rather than being
  2965. resolved relative to a base URI using <function>g_uri_parse_relative()</function>.
  2966. </para>
  2967. <para>For example, a valid absolute URI is <code>file:///home/bob</code> or
  2968. <code>https://search.com?query=string</code>.
  2969. </para>
  2970. <para>A <type>GUri</type> instance is always an absolute URI. A string may be an absolute URI
  2971. or a relative reference; see the documentation for individual functions as to
  2972. what forms they accept.
  2973. </para>
  2974. </refsect2><refsect2><title>Parsing URIs</title>
  2975. <para>The most minimalist APIs for parsing URIs are <function>g_uri_split()</function> and
  2976. <function>g_uri_split_with_user()</function>. These split a URI into its component
  2977. parts, and return the parts; the difference between the two is that
  2978. <function>g_uri_split()</function> treats the ‘userinfo’ component of the URI as a
  2979. single element, while <function>g_uri_split_with_user()</function> can (depending on the
  2980. <type>GUriFlags</type> you pass) treat it as containing a username, password,
  2981. and authentication parameters. Alternatively, <function>g_uri_split_network()</function>
  2982. can be used when you are only interested in the components that are
  2983. needed to initiate a network connection to the service (scheme,
  2984. host, and port).
  2985. </para>
  2986. <para><function>g_uri_parse()</function> is similar to <function>g_uri_split()</function>, but instead of returning
  2987. individual strings, it returns a <type>GUri</type> structure (and it requires
  2988. that the URI be an absolute URI).
  2989. </para>
  2990. <para><function>g_uri_resolve_relative()</function> and <function>g_uri_parse_relative()</function> allow you to
  2991. resolve a relative URI relative to a base URI.
  2992. <function>g_uri_resolve_relative()</function> takes two strings and returns a string,
  2993. and <function>g_uri_parse_relative()</function> takes a <type>GUri</type> and a string and returns a
  2994. <type>GUri</type>.
  2995. </para>
  2996. <para>All of the parsing functions take a <type>GUriFlags</type> argument describing
  2997. exactly how to parse the URI; see the documentation for that type
  2998. for more details on the specific flags that you can pass. If you
  2999. need to choose different flags based on the type of URI, you can
  3000. use <function>g_uri_peek_scheme()</function> on the URI string to check the scheme
  3001. first, and use that to decide what flags to parse it with.
  3002. </para>
  3003. <para>For example, you might want to use <constant>G_URI_PARAMS_WWW_FORM</constant> when parsing the
  3004. params for a web URI, so compare the result of <function>g_uri_peek_scheme()</function> against
  3005. <code>http</code> and <code>https</code>.
  3006. </para>
  3007. </refsect2><refsect2><title>Building URIs</title>
  3008. <para><function>g_uri_join()</function> and <function>g_uri_join_with_user()</function> can be used to construct
  3009. valid URI strings from a set of component strings. They are the
  3010. inverse of <function>g_uri_split()</function> and <function>g_uri_split_with_user()</function>.
  3011. </para>
  3012. <para>Similarly, <function>g_uri_build()</function> and <function>g_uri_build_with_user()</function> can be used to
  3013. construct a <type>GUri</type> from a set of component strings.
  3014. </para>
  3015. <para>As with the parsing functions, the building functions take a
  3016. <type>GUriFlags</type> argument. In particular, it is important to keep in mind
  3017. whether the URI components you are using are already <code>%</code>-encoded. If so,
  3018. you must pass the <constant>G_URI_FLAGS_ENCODED</constant> flag.
  3019. </para>
  3020. </refsect2><refsect2><title>`file://` URIs</title>
  3021. <para>Note that Windows and Unix both define special rules for parsing
  3022. <code>file://</code> URIs (involving non-UTF-8 character sets on Unix, and the
  3023. interpretation of path separators on Windows). <type>GUri</type> does not
  3024. implement these rules. Use <function>g_filename_from_uri()</function> and
  3025. <function>g_filename_to_uri()</function> if you want to properly convert between
  3026. <code>file://</code> URIs and local filenames.
  3027. </para>
  3028. </refsect2><refsect2><title>URI Equality</title>
  3029. <para>Note that there is no <code>g_uri_equal ()</code> function, because comparing
  3030. URIs usefully requires scheme-specific knowledge that <type>GUri</type> does
  3031. not have. For example, <code>http://example.com/</code> and
  3032. <code>http://EXAMPLE.COM:80</code> have exactly the same meaning according
  3033. to the HTTP specification, and <code>data:,foo</code> and
  3034. <code>data:;base64,Zm9v</code> resolve to the same thing according to the
  3035. <code>data:</code> URI specification.</para></refsect2></refsect1><refsect1><title>Functions</title><refsect2><title>get-auth-params</title><informalexample><programlisting>(define-values (%return) (uri:get-auth-params self))
  3036. </programlisting></informalexample><para>Gets <parameter>uri</parameter>'s authentication parameters, which may contain
  3037. <code>%</code>-encoding, depending on the flags with which <parameter>uri</parameter> was created.
  3038. (If <parameter>uri</parameter> was not created with <constant>G_URI_FLAGS_HAS_AUTH_PARAMS</constant> then this will
  3039. be <constant>NULL</constant>.)
  3040. </para>
  3041. <para>Depending on the URI scheme, <function>g_uri_parse_params()</function> may be useful for
  3042. further parsing this information.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-flags</title><informalexample><programlisting>(define-values (%return) (uri:get-flags self))
  3043. </programlisting></informalexample><para>Gets <parameter>uri</parameter>'s flags set upon construction.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-fragment</title><informalexample><programlisting>(define-values (%return) (uri:get-fragment self))
  3044. </programlisting></informalexample><para>Gets <parameter>uri</parameter>'s fragment, which may contain <code>%</code>-encoding, depending on
  3045. the flags with which <parameter>uri</parameter> was created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-host</title><informalexample><programlisting>(define-values (%return) (uri:get-host self))
  3046. </programlisting></informalexample><para>Gets <parameter>uri</parameter>'s host. This will never have <code>%</code>-encoded characters,
  3047. unless it is non-UTF-8 (which can only be the case if <parameter>uri</parameter> was
  3048. created with <constant>G_URI_FLAGS_NON_DNS</constant>).
  3049. </para>
  3050. <para>If <parameter>uri</parameter> contained an IPv6 address literal, this value will be just
  3051. that address, without the brackets around it that are necessary in
  3052. the string form of the URI. Note that in this case there may also
  3053. be a scope ID attached to the address. Eg, <code>fe80::1234%</code><code>em1</code> (or
  3054. <code>fe80::1234%</code><code>25em1</code> if the string is still encoded).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-password</title><informalexample><programlisting>(define-values (%return) (uri:get-password self))
  3055. </programlisting></informalexample><para>Gets <parameter>uri</parameter>'s password, which may contain <code>%</code>-encoding, depending on
  3056. the flags with which <parameter>uri</parameter> was created. (If <parameter>uri</parameter> was not created
  3057. with <constant>G_URI_FLAGS_HAS_PASSWORD</constant> then this will be <constant>NULL</constant>.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-path</title><informalexample><programlisting>(define-values (%return) (uri:get-path self))
  3058. </programlisting></informalexample><para>Gets <parameter>uri</parameter>'s path, which may contain <code>%</code>-encoding, depending on the
  3059. flags with which <parameter>uri</parameter> was created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-port</title><informalexample><programlisting>(define-values (%return) (uri:get-port self))
  3060. </programlisting></informalexample><para>Gets <parameter>uri</parameter>'s port.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-query</title><informalexample><programlisting>(define-values (%return) (uri:get-query self))
  3061. </programlisting></informalexample><para>Gets <parameter>uri</parameter>'s query, which may contain <code>%</code>-encoding, depending on the
  3062. flags with which <parameter>uri</parameter> was created.
  3063. </para>
  3064. <para>For queries consisting of a series of <code>name=value</code> parameters,
  3065. <type>GUriParamsIter</type> or <function>g_uri_parse_params()</function> may be useful.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-scheme</title><informalexample><programlisting>(define-values (%return) (uri:get-scheme self))
  3066. </programlisting></informalexample><para>Gets <parameter>uri</parameter>'s scheme. Note that this will always be all-lowercase,
  3067. regardless of the string or strings that <parameter>uri</parameter> was created from.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-user</title><informalexample><programlisting>(define-values (%return) (uri:get-user self))
  3068. </programlisting></informalexample><para>Gets the ‘username’ component of <parameter>uri</parameter>'s userinfo, which may contain
  3069. <code>%</code>-encoding, depending on the flags with which <parameter>uri</parameter> was created.
  3070. If <parameter>uri</parameter> was not created with <constant>G_URI_FLAGS_HAS_PASSWORD</constant> or
  3071. <constant>G_URI_FLAGS_HAS_AUTH_PARAMS</constant>, this is the same as <function>g_uri_get_userinfo()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-userinfo</title><informalexample><programlisting>(define-values (%return) (uri:get-userinfo self))
  3072. </programlisting></informalexample><para>Gets <parameter>uri</parameter>'s userinfo, which may contain <code>%</code>-encoding, depending on
  3073. the flags with which <parameter>uri</parameter> was created.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>parse-relative</title><informalexample><programlisting>(define-values (%return) (uri:parse-relative self uri-ref flags))
  3074. </programlisting></informalexample><para>Parses <parameter>uri_ref</parameter> according to <parameter>flags</parameter> and, if it is a
  3075. [relative URI][relative-absolute-uris], resolves it relative to <parameter>base_uri</parameter>.
  3076. If the result is not a valid absolute URI, it will be discarded, and an error
  3077. returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>base_uri</para></td><td class="parameter_description"><para>a base absolute URI</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>uri_ref</para></td><td class="parameter_description"><para>a string representing a relative or absolute URI</para><para>Passed as <code>uri-ref</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to parse <parameter>uri_ref</parameter></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>to-string</title><informalexample><programlisting>(define-values (%return) (uri:to-string self))
  3078. </programlisting></informalexample><para>Returns a string representing <parameter>uri</parameter>.
  3079. </para>
  3080. <para>This is not guaranteed to return a string which is identical to the
  3081. string that <parameter>uri</parameter> was parsed from. However, if the source URI was
  3082. syntactically correct (according to RFC 3986), and it was parsed
  3083. with <constant>G_URI_FLAGS_ENCODED</constant>, then <function>g_uri_to_string()</function> is guaranteed to return
  3084. a string which is at least semantically equivalent to the source
  3085. URI (according to RFC 3986).
  3086. </para>
  3087. <para>If <parameter>uri</parameter> might contain sensitive details, such as authentication parameters,
  3088. or private data in its query string, and the returned string is going to be
  3089. logged, then consider using <function>g_uri_to_string_partial()</function> to redact parts.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>to-string-partial</title><informalexample><programlisting>(define-values (%return) (uri:to-string-partial self flags))
  3090. </programlisting></informalexample><para>Returns a string representing <parameter>uri</parameter>, subject to the options in
  3091. <parameter>flags</parameter>. See <function>g_uri_to_string()</function> and <type>GUriHideFlags</type> for more details.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a <type>GUri</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing what parts of <parameter>uri</parameter> to hide</para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:build</title><informalexample><programlisting>(define-values
  3092. (%return)
  3093. (uri:build flags scheme userinfo host port path query fragment))
  3094. </programlisting></informalexample><para>Creates a new <type>GUri</type> from the given components according to <parameter>flags</parameter>.
  3095. </para>
  3096. <para>See also <function>g_uri_build_with_user()</function>, which allows specifying the
  3097. components of the &quot;userinfo&quot; separately.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to build the <type>GUri</type></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>the URI scheme</para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>userinfo</para></td><td class="parameter_description"><para>the userinfo component, or <constant>NULL</constant></para><para>Passed as <code>userinfo</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>the host component, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>the port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>the path component</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>the query component, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:build-with-user</title><informalexample><programlisting>(define-values
  3098. (%return)
  3099. (uri:build-with-user
  3100. flags
  3101. scheme
  3102. user
  3103. password
  3104. auth-params
  3105. host
  3106. port
  3107. path
  3108. query
  3109. fragment))
  3110. </programlisting></informalexample><para>Creates a new <type>GUri</type> from the given components according to <parameter>flags</parameter>
  3111. (<constant>G_URI_FLAGS_HAS_PASSWORD</constant> is added unconditionally). The <parameter>flags</parameter> must be
  3112. coherent with the passed values, in particular use <code>%</code>-encoded values with
  3113. <constant>G_URI_FLAGS_ENCODED</constant>.
  3114. </para>
  3115. <para>In contrast to <function>g_uri_build()</function>, this allows specifying the components
  3116. of the ‘userinfo’ field separately. Note that <parameter>user</parameter> must be non-<constant>NULL</constant>
  3117. if either <parameter>password</parameter> or <parameter>auth_params</parameter> is non-<constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to build the <type>GUri</type></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>the URI scheme</para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>user</para></td><td class="parameter_description"><para>the user component of the userinfo, or <constant>NULL</constant></para><para>Passed as <code>user</code></para></td></tr><tr><td class="parameter_name"><para>password</para></td><td class="parameter_description"><para>the password component of the userinfo, or <constant>NULL</constant></para><para>Passed as <code>password</code></para></td></tr><tr><td class="parameter_name"><para>auth_params</para></td><td class="parameter_description"><para>the auth params of the userinfo, or <constant>NULL</constant></para><para>Passed as <code>auth-params</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>the host component, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>the port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>the path component</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>the query component, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:error-quark</title><informalexample><programlisting>(define-values (%return) (uri:error-quark))
  3118. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>uri:escape-bytes</title><informalexample><programlisting>(define-values (%return) (uri:escape-bytes unescaped reserved-chars-allowed))
  3119. </programlisting></informalexample><para>Escapes arbitrary data for use in a URI.
  3120. </para>
  3121. <para>Normally all characters that are not ‘unreserved’ (i.e. ASCII
  3122. alphanumerical characters plus dash, dot, underscore and tilde) are
  3123. escaped. But if you specify characters in <parameter>reserved_chars_allowed</parameter>
  3124. they are not escaped. This is useful for the ‘reserved’ characters
  3125. in the URI specification, since those are allowed unescaped in some
  3126. portions of a URI.
  3127. </para>
  3128. <para>Though technically incorrect, this will also allow escaping nul
  3129. bytes as <code>%</code><code>00</code>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>unescaped</para></td><td class="parameter_description"><para>the unescaped input data.</para><para>Passed as <code>unescaped</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of <parameter>unescaped</parameter></para><para>Inferred from <code>unescaped</code></para></td></tr><tr><td class="parameter_name"><para>reserved_chars_allowed</para></td><td class="parameter_description"><para>a string of reserved
  3130. characters that are allowed to be used, or <constant>NULL</constant>.</para><para>Passed as <code>reserved-chars-allowed</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:escape-string</title><informalexample><programlisting>(define-values
  3131. (%return)
  3132. (uri:escape-string unescaped reserved-chars-allowed allow-utf8))
  3133. </programlisting></informalexample><para>Escapes a string for use in a URI.
  3134. </para>
  3135. <para>Normally all characters that are not &quot;unreserved&quot; (i.e. ASCII
  3136. alphanumerical characters plus dash, dot, underscore and tilde) are
  3137. escaped. But if you specify characters in <parameter>reserved_chars_allowed</parameter>
  3138. they are not escaped. This is useful for the &quot;reserved&quot; characters
  3139. in the URI specification, since those are allowed unescaped in some
  3140. portions of a URI.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>unescaped</para></td><td class="parameter_description"><para>the unescaped input string.</para><para>Passed as <code>unescaped</code></para></td></tr><tr><td class="parameter_name"><para>reserved_chars_allowed</para></td><td class="parameter_description"><para>a string of reserved
  3141. characters that are allowed to be used, or <constant>NULL</constant>.</para><para>Passed as <code>reserved-chars-allowed</code></para></td></tr><tr><td class="parameter_name"><para>allow_utf8</para></td><td class="parameter_description"><para><constant>TRUE</constant> if the result can include UTF-8 characters.</para><para>Passed as <code>allow-utf8</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:is-valid?</title><informalexample><programlisting>(define-values (%return) (uri:is-valid? uri-string flags))
  3142. </programlisting></informalexample><para>Parses <parameter>uri_string</parameter> according to <parameter>flags</parameter>, to determine whether it is a valid
  3143. [absolute URI][relative-absolute-uris], i.e. it does not need to be resolved
  3144. relative to another URI using <function>g_uri_parse_relative()</function>.
  3145. </para>
  3146. <para>If it’s not a valid URI, an error is returned explaining how it’s invalid.
  3147. </para>
  3148. <para>See <function>g_uri_split()</function>, and the definition of <type>GUriFlags</type>, for more
  3149. information on the effect of <parameter>flags</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_string</para></td><td class="parameter_description"><para>a string containing an absolute URI</para><para>Passed as <code>uri-string</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags for parsing <parameter>uri_string</parameter></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:join</title><informalexample><programlisting>(define-values
  3150. (%return)
  3151. (uri:join flags scheme userinfo host port path query fragment))
  3152. </programlisting></informalexample><para>Joins the given components together according to <parameter>flags</parameter> to create
  3153. an absolute URI string. <parameter>path</parameter> may not be <constant>NULL</constant> (though it may be the empty
  3154. string).
  3155. </para>
  3156. <para>When <parameter>host</parameter> is present, <parameter>path</parameter> must either be empty or begin with a slash (<code>/</code>)
  3157. character. When <parameter>host</parameter> is not present, <parameter>path</parameter> cannot begin with two slash
  3158. characters (<code>//</code>). See
  3159. [RFC 3986, section 3](https://tools.ietf.org/html/rfc3986#section-3).
  3160. </para>
  3161. <para>See also <function>g_uri_join_with_user()</function>, which allows specifying the
  3162. components of the ‘userinfo’ separately.
  3163. </para>
  3164. <para><constant>G_URI_FLAGS_HAS_PASSWORD</constant> and <constant>G_URI_FLAGS_HAS_AUTH_PARAMS</constant> are ignored if set
  3165. in <parameter>flags</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to build the URI string</para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>the URI scheme, or <constant>NULL</constant></para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>userinfo</para></td><td class="parameter_description"><para>the userinfo component, or <constant>NULL</constant></para><para>Passed as <code>userinfo</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>the host component, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>the port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>the path component</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>the query component, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:join-with-user</title><informalexample><programlisting>(define-values
  3166. (%return)
  3167. (uri:join-with-user
  3168. flags
  3169. scheme
  3170. user
  3171. password
  3172. auth-params
  3173. host
  3174. port
  3175. path
  3176. query
  3177. fragment))
  3178. </programlisting></informalexample><para>Joins the given components together according to <parameter>flags</parameter> to create
  3179. an absolute URI string. <parameter>path</parameter> may not be <constant>NULL</constant> (though it may be the empty
  3180. string).
  3181. </para>
  3182. <para>In contrast to <function>g_uri_join()</function>, this allows specifying the components
  3183. of the ‘userinfo’ separately. It otherwise behaves the same.
  3184. </para>
  3185. <para><constant>G_URI_FLAGS_HAS_PASSWORD</constant> and <constant>G_URI_FLAGS_HAS_AUTH_PARAMS</constant> are ignored if set
  3186. in <parameter>flags</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to build the URI string</para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>the URI scheme, or <constant>NULL</constant></para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>user</para></td><td class="parameter_description"><para>the user component of the userinfo, or <constant>NULL</constant></para><para>Passed as <code>user</code></para></td></tr><tr><td class="parameter_name"><para>password</para></td><td class="parameter_description"><para>the password component of the userinfo, or
  3187. <constant>NULL</constant></para><para>Passed as <code>password</code></para></td></tr><tr><td class="parameter_name"><para>auth_params</para></td><td class="parameter_description"><para>the auth params of the userinfo, or
  3188. <constant>NULL</constant></para><para>Passed as <code>auth-params</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>the host component, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>the port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>the path component</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>the query component, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:list-extract-uris</title><informalexample><programlisting>(define-values (%return) (uri:list-extract-uris uri-list))
  3189. </programlisting></informalexample><para>Splits an URI list conforming to the text/uri-list
  3190. mime type defined in RFC 2483 into individual URIs,
  3191. discarding any comments. The URIs are not validated.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_list</para></td><td class="parameter_description"><para>an URI list</para><para>Passed as <code>uri-list</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:parse</title><informalexample><programlisting>(define-values (%return) (uri:parse uri-string flags))
  3192. </programlisting></informalexample><para>Parses <parameter>uri_string</parameter> according to <parameter>flags</parameter>. If the result is not a
  3193. valid [absolute URI][relative-absolute-uris], it will be discarded, and an
  3194. error returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_string</para></td><td class="parameter_description"><para>a string representing an absolute URI</para><para>Passed as <code>uri-string</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to parse <parameter>uri_string</parameter></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:parse-params</title><informalexample><programlisting>(define-values (%return) (uri:parse-params params length separators flags))
  3195. </programlisting></informalexample><para>Many URI schemes include one or more attribute/value pairs as part of the URI
  3196. value. This method can be used to parse them into a hash table. When an
  3197. attribute has multiple occurrences, the last value is the final returned
  3198. value. If you need to handle repeated attributes differently, use
  3199. <type>GUriParamsIter</type>.
  3200. </para>
  3201. <para>The <parameter>params</parameter> string is assumed to still be <code>%</code>-encoded, but the returned
  3202. values will be fully decoded. (Thus it is possible that the returned values
  3203. may contain <code>=</code> or <parameter>separators</parameter>, if the value was encoded in the input.)
  3204. Invalid <code>%</code>-encoding is treated as with the <constant>G_URI_FLAGS_PARSE_RELAXED</constant>
  3205. rules for <function>g_uri_parse()</function>. (However, if <parameter>params</parameter> is the path or query string
  3206. from a <type>GUri</type> that was parsed without <constant>G_URI_FLAGS_PARSE_RELAXED</constant> and
  3207. <constant>G_URI_FLAGS_ENCODED</constant>, then you already know that it does not contain any
  3208. invalid encoding.)
  3209. </para>
  3210. <para><constant>G_URI_PARAMS_WWW_FORM</constant> is handled as documented for <function>g_uri_params_iter_init()</function>.
  3211. </para>
  3212. <para>If <constant>G_URI_PARAMS_CASE_INSENSITIVE</constant> is passed to <parameter>flags</parameter>, attributes will be
  3213. compared case-insensitively, so a params string <code>attr=123&amp;Attr=456</code> will only
  3214. return a single attribute–value pair, <code>Attr=456</code>. Case will be preserved in
  3215. the returned attributes.
  3216. </para>
  3217. <para>If <parameter>params</parameter> cannot be parsed (for example, it contains two <parameter>separators</parameter>
  3218. characters in a row), then <parameter>error</parameter> is set and <constant>NULL</constant> is returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>params</para></td><td class="parameter_description"><para>a <code>%</code>-encoded string containing <code>attribute=value</code>
  3219. parameters</para><para>Passed as <code>params</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of <parameter>params</parameter>, or <code>-1</code> if it is nul-terminated</para><para>Passed as <code>length</code></para></td></tr><tr><td class="parameter_name"><para>separators</para></td><td class="parameter_description"><para>the separator byte character set between parameters. (usually
  3220. <code>&amp;</code>, but sometimes <code>;</code> or both <code>&amp;;</code>). Note that this function works on
  3221. bytes not characters, so it can't be used to delimit UTF-8 strings for
  3222. anything but ASCII characters. You may pass an empty set, in which case
  3223. no splitting will occur.</para><para>Passed as <code>separators</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags to modify the way the parameters are handled.</para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:parse-scheme</title><informalexample><programlisting>(define-values (%return) (uri:parse-scheme uri))
  3224. </programlisting></informalexample><para>Gets the scheme portion of a URI string.
  3225. [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3) decodes the scheme
  3226. as:
  3227. <informalexample><programlisting>
  3228. URI = scheme &quot;:&quot; hier-part [ &quot;?&quot; query ] [ &quot;#&quot; fragment ]
  3229. </programlisting></informalexample></para>
  3230. <para>Common schemes include <code>file</code>, <code>https</code>, <code>svn+ssh</code>, etc.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a valid URI.</para><para>Passed as <code>uri</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:peek-scheme</title><informalexample><programlisting>(define-values (%return) (uri:peek-scheme uri))
  3231. </programlisting></informalexample><para>Gets the scheme portion of a URI string.
  3232. [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3) decodes the scheme
  3233. as:
  3234. <informalexample><programlisting>
  3235. URI = scheme &quot;:&quot; hier-part [ &quot;?&quot; query ] [ &quot;#&quot; fragment ]
  3236. </programlisting></informalexample></para>
  3237. <para>Common schemes include <code>file</code>, <code>https</code>, <code>svn+ssh</code>, etc.
  3238. </para>
  3239. <para>Unlike <function>g_uri_parse_scheme()</function>, the returned scheme is normalized to
  3240. all-lowercase and does not need to be freed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a valid URI.</para><para>Passed as <code>uri</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:resolve-relative</title><informalexample><programlisting>(define-values (%return) (uri:resolve-relative base-uri-string uri-ref flags))
  3241. </programlisting></informalexample><para>Parses <parameter>uri_ref</parameter> according to <parameter>flags</parameter> and, if it is a
  3242. [relative URI][relative-absolute-uris], resolves it relative to
  3243. <parameter>base_uri_string</parameter>. If the result is not a valid absolute URI, it will be
  3244. discarded, and an error returned.
  3245. </para>
  3246. <para>(If <parameter>base_uri_string</parameter> is <constant>NULL</constant>, this just returns <parameter>uri_ref</parameter>, or
  3247. <constant>NULL</constant> if <parameter>uri_ref</parameter> is invalid or not absolute.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>base_uri_string</para></td><td class="parameter_description"><para>a string representing a base URI</para><para>Passed as <code>base-uri-string</code></para></td></tr><tr><td class="parameter_name"><para>uri_ref</para></td><td class="parameter_description"><para>a string representing a relative or absolute URI</para><para>Passed as <code>uri-ref</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to parse <parameter>uri_ref</parameter></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:split</title><informalexample><programlisting>(define-values
  3248. (%return scheme userinfo host port path query fragment)
  3249. (uri:split uri-ref flags))
  3250. </programlisting></informalexample><para>Parses <parameter>uri_ref</parameter> (which can be an
  3251. [absolute or relative URI][relative-absolute-uris]) according to <parameter>flags</parameter>, and
  3252. returns the pieces. Any component that doesn't appear in <parameter>uri_ref</parameter> will be
  3253. returned as <constant>NULL</constant> (but note that all URIs always have a path component,
  3254. though it may be the empty string).
  3255. </para>
  3256. <para>If <parameter>flags</parameter> contains <constant>G_URI_FLAGS_ENCODED</constant>, then <code>%</code>-encoded characters in
  3257. <parameter>uri_ref</parameter> will remain encoded in the output strings. (If not,
  3258. then all such characters will be decoded.) Note that decoding will
  3259. only work if the URI components are ASCII or UTF-8, so you will
  3260. need to use <constant>G_URI_FLAGS_ENCODED</constant> if they are not.
  3261. </para>
  3262. <para>Note that the <constant>G_URI_FLAGS_HAS_PASSWORD</constant> and
  3263. <constant>G_URI_FLAGS_HAS_AUTH_PARAMS</constant> <parameter>flags</parameter> are ignored by <function>g_uri_split()</function>,
  3264. since it always returns only the full userinfo; use
  3265. <function>g_uri_split_with_user()</function> if you want it split up.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_ref</para></td><td class="parameter_description"><para>a string containing a relative or absolute URI</para><para>Passed as <code>uri-ref</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags for parsing <parameter>uri_ref</parameter></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>on return, contains
  3266. the scheme (converted to lowercase), or <constant>NULL</constant></para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>userinfo</para></td><td class="parameter_description"><para>on return, contains
  3267. the userinfo, or <constant>NULL</constant></para><para>Passed as <code>userinfo</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>on return, contains the
  3268. host, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>on return, contains the
  3269. port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>on return, contains the
  3270. path</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>on return, contains the
  3271. query, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>on return, contains
  3272. the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:split-network</title><informalexample><programlisting>(define-values
  3273. (%return scheme host port)
  3274. (uri:split-network uri-string flags))
  3275. </programlisting></informalexample><para>Parses <parameter>uri_string</parameter> (which must be an [absolute URI][relative-absolute-uris])
  3276. according to <parameter>flags</parameter>, and returns the pieces relevant to connecting to a host.
  3277. See the documentation for <function>g_uri_split()</function> for more details; this is
  3278. mostly a wrapper around that function with simpler arguments.
  3279. However, it will return an error if <parameter>uri_string</parameter> is a relative URI,
  3280. or does not contain a hostname component.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_string</para></td><td class="parameter_description"><para>a string containing an absolute URI</para><para>Passed as <code>uri-string</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags for parsing <parameter>uri_string</parameter></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>on return, contains
  3281. the scheme (converted to lowercase), or <constant>NULL</constant></para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>on return, contains the
  3282. host, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>on return, contains the
  3283. port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:split-with-user</title><informalexample><programlisting>(define-values
  3284. (%return scheme user password auth-params host port path query fragment)
  3285. (uri:split-with-user uri-ref flags))
  3286. </programlisting></informalexample><para>Parses <parameter>uri_ref</parameter> (which can be an
  3287. [absolute or relative URI][relative-absolute-uris]) according to <parameter>flags</parameter>, and
  3288. returns the pieces. Any component that doesn't appear in <parameter>uri_ref</parameter> will be
  3289. returned as <constant>NULL</constant> (but note that all URIs always have a path component,
  3290. though it may be the empty string).
  3291. </para>
  3292. <para>See <function>g_uri_split()</function>, and the definition of <type>GUriFlags</type>, for more
  3293. information on the effect of <parameter>flags</parameter>. Note that <parameter>password</parameter> will only
  3294. be parsed out if <parameter>flags</parameter> contains <constant>G_URI_FLAGS_HAS_PASSWORD</constant>, and
  3295. <parameter>auth_params</parameter> will only be parsed out if <parameter>flags</parameter> contains
  3296. <constant>G_URI_FLAGS_HAS_AUTH_PARAMS</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_ref</para></td><td class="parameter_description"><para>a string containing a relative or absolute URI</para><para>Passed as <code>uri-ref</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags for parsing <parameter>uri_ref</parameter></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>on return, contains
  3297. the scheme (converted to lowercase), or <constant>NULL</constant></para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>user</para></td><td class="parameter_description"><para>on return, contains
  3298. the user, or <constant>NULL</constant></para><para>Passed as <code>user</code></para></td></tr><tr><td class="parameter_name"><para>password</para></td><td class="parameter_description"><para>on return, contains
  3299. the password, or <constant>NULL</constant></para><para>Passed as <code>password</code></para></td></tr><tr><td class="parameter_name"><para>auth_params</para></td><td class="parameter_description"><para>on return, contains
  3300. the auth_params, or <constant>NULL</constant></para><para>Passed as <code>auth-params</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>on return, contains the
  3301. host, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>on return, contains the
  3302. port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>on return, contains the
  3303. path</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>on return, contains the
  3304. query, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>on return, contains
  3305. the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:unescape-bytes</title><informalexample><programlisting>(define-values
  3306. (%return)
  3307. (uri:unescape-bytes escaped-string length illegal-characters))
  3308. </programlisting></informalexample><para>Unescapes a segment of an escaped string as binary data.
  3309. </para>
  3310. <para>Note that in contrast to <function>g_uri_unescape_string()</function>, this does allow
  3311. nul bytes to appear in the output.
  3312. </para>
  3313. <para>If any of the characters in <parameter>illegal_characters</parameter> appears as an escaped
  3314. character in <parameter>escaped_string</parameter>, then that is an error and <constant>NULL</constant> will be
  3315. returned. This is useful if you want to avoid for instance having a slash
  3316. being expanded in an escaped path element, which might confuse pathname
  3317. handling.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>escaped_string</para></td><td class="parameter_description"><para>A URI-escaped string</para><para>Passed as <code>escaped-string</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length (in bytes) of <parameter>escaped_string</parameter> to escape, or <code>-1</code> if it
  3318. is nul-terminated.</para><para>Passed as <code>length</code></para></td></tr><tr><td class="parameter_name"><para>illegal_characters</para></td><td class="parameter_description"><para>a string of illegal characters
  3319. not to be allowed, or <constant>NULL</constant>.</para><para>Passed as <code>illegal-characters</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:unescape-segment</title><informalexample><programlisting>(define-values
  3320. (%return)
  3321. (uri:unescape-segment escaped-string escaped-string-end illegal-characters))
  3322. </programlisting></informalexample><para>Unescapes a segment of an escaped string.
  3323. </para>
  3324. <para>If any of the characters in <parameter>illegal_characters</parameter> or the NUL
  3325. character appears as an escaped character in <parameter>escaped_string</parameter>, then
  3326. that is an error and <constant>NULL</constant> will be returned. This is useful if you
  3327. want to avoid for instance having a slash being expanded in an
  3328. escaped path element, which might confuse pathname handling.
  3329. </para>
  3330. <para>Note: <code>NUL</code> byte is not accepted in the output, in contrast to
  3331. <function>g_uri_unescape_bytes()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>escaped_string</para></td><td class="parameter_description"><para>A string, may be <constant>NULL</constant></para><para>Passed as <code>escaped-string</code></para></td></tr><tr><td class="parameter_name"><para>escaped_string_end</para></td><td class="parameter_description"><para>Pointer to end of <parameter>escaped_string</parameter>,
  3332. may be <constant>NULL</constant></para><para>Passed as <code>escaped-string-end</code></para></td></tr><tr><td class="parameter_name"><para>illegal_characters</para></td><td class="parameter_description"><para>An optional string of illegal
  3333. characters not to be allowed, may be <constant>NULL</constant></para><para>Passed as <code>illegal-characters</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri:unescape-string</title><informalexample><programlisting>(define-values
  3334. (%return)
  3335. (uri:unescape-string escaped-string illegal-characters))
  3336. </programlisting></informalexample><para>Unescapes a whole escaped string.
  3337. </para>
  3338. <para>If any of the characters in <parameter>illegal_characters</parameter> or the NUL
  3339. character appears as an escaped character in <parameter>escaped_string</parameter>, then
  3340. that is an error and <constant>NULL</constant> will be returned. This is useful if you
  3341. want to avoid for instance having a slash being expanded in an
  3342. escaped path element, which might confuse pathname handling.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>escaped_string</para></td><td class="parameter_description"><para>an escaped string to be unescaped.</para><para>Passed as <code>escaped-string</code></para></td></tr><tr><td class="parameter_name"><para>illegal_characters</para></td><td class="parameter_description"><para>a string of illegal characters
  3343. not to be allowed, or <constant>NULL</constant>.</para><para>Passed as <code>illegal-characters</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibUriError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by <type>GUri</type> methods.</para></refsect1><refsect1><title>Members</title><refsect2><title>failed</title><remark>alias <code>G_URI_ERROR_FAILED</code></remark><para>Generic error if no more specific error is available.
  3344. See the error message for details.</para></refsect2><refsect2><title>bad-scheme</title><remark>alias <code>G_URI_ERROR_BAD_SCHEME</code></remark><para>The scheme of a URI could not be parsed.</para></refsect2><refsect2><title>bad-user</title><remark>alias <code>G_URI_ERROR_BAD_USER</code></remark><para>The user/userinfo of a URI could not be parsed.</para></refsect2><refsect2><title>bad-password</title><remark>alias <code>G_URI_ERROR_BAD_PASSWORD</code></remark><para>The password of a URI could not be parsed.</para></refsect2><refsect2><title>bad-auth-params</title><remark>alias <code>G_URI_ERROR_BAD_AUTH_PARAMS</code></remark><para>The authentication parameters of a URI could not be parsed.</para></refsect2><refsect2><title>bad-host</title><remark>alias <code>G_URI_ERROR_BAD_HOST</code></remark><para>The host of a URI could not be parsed.</para></refsect2><refsect2><title>bad-port</title><remark>alias <code>G_URI_ERROR_BAD_PORT</code></remark><para>The port of a URI could not be parsed.</para></refsect2><refsect2><title>bad-path</title><remark>alias <code>G_URI_ERROR_BAD_PATH</code></remark><para>The path of a URI could not be parsed.</para></refsect2><refsect2><title>bad-query</title><remark>alias <code>G_URI_ERROR_BAD_QUERY</code></remark><para>The query of a URI could not be parsed.</para></refsect2><refsect2><title>bad-fragment</title><remark>alias <code>G_URI_ERROR_BAD_FRAGMENT</code></remark><para>The fragment of a URI could not be parsed.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibUriFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags that describe a URI.
  3345. </para>
  3346. <para>When parsing a URI, if you need to choose different flags based on
  3347. the type of URI, you can use <function>g_uri_peek_scheme()</function> on the URI string
  3348. to check the scheme first, and use that to decide what flags to
  3349. parse it with.</para></refsect1><refsect1><title>Members</title><refsect2><title>none</title><remark>alias <code>G_URI_FLAGS_NONE</code></remark><para>No flags set.</para></refsect2><refsect2><title>parse-relaxed</title><remark>alias <code>G_URI_FLAGS_PARSE_RELAXED</code></remark><para>Parse the URI more relaxedly than the
  3350. [RFC 3986](https://tools.ietf.org/html/rfc3986) grammar specifies,
  3351. fixing up or ignoring common mistakes in URIs coming from external
  3352. sources. This is also needed for some obscure URI schemes where <code>;</code>
  3353. separates the host from the path. Don’t use this flag unless you need to.</para></refsect2><refsect2><title>has-password</title><remark>alias <code>G_URI_FLAGS_HAS_PASSWORD</code></remark><para>The userinfo field may contain a password,
  3354. which will be separated from the username by <code>:</code>.</para></refsect2><refsect2><title>has-auth-params</title><remark>alias <code>G_URI_FLAGS_HAS_AUTH_PARAMS</code></remark><para>The userinfo may contain additional
  3355. authentication-related parameters, which will be separated from
  3356. the username and/or password by <code>;</code>.</para></refsect2><refsect2><title>encoded</title><remark>alias <code>G_URI_FLAGS_ENCODED</code></remark><para>When parsing a URI, this indicates that <code>%</code>-encoded
  3357. characters in the userinfo, path, query, and fragment fields
  3358. should not be decoded. (And likewise the host field if
  3359. <constant>G_URI_FLAGS_NON_DNS</constant> is also set.) When building a URI, it indicates
  3360. that you have already <code>%</code>-encoded the components, and so <type>GUri</type>
  3361. should not do any encoding itself.</para></refsect2><refsect2><title>non-dns</title><remark>alias <code>G_URI_FLAGS_NON_DNS</code></remark><para>The host component should not be assumed to be a
  3362. DNS hostname or IP address (for example, for <code>smb</code> URIs with NetBIOS
  3363. hostnames).</para></refsect2><refsect2><title>encoded-query</title><remark>alias <code>G_URI_FLAGS_ENCODED_QUERY</code></remark><para>Same as <constant>G_URI_FLAGS_ENCODED</constant>, for the query
  3364. field only.</para></refsect2><refsect2><title>encoded-path</title><remark>alias <code>G_URI_FLAGS_ENCODED_PATH</code></remark><para>Same as <constant>G_URI_FLAGS_ENCODED</constant>, for the path only.</para></refsect2><refsect2><title>encoded-fragment</title><remark>alias <code>G_URI_FLAGS_ENCODED_FRAGMENT</code></remark><para>Same as <constant>G_URI_FLAGS_ENCODED</constant>, for the
  3365. fragment only.</para></refsect2><refsect2><title>scheme-normalize</title><remark>alias <code>G_URI_FLAGS_SCHEME_NORMALIZE</code></remark><para>A scheme-based normalization will be applied.
  3366. For example, when parsing an HTTP URI changing omitted path to <code>/</code> and
  3367. omitted port to <code>80</code>; and when building a URI, changing empty path to <code>/</code>
  3368. and default port <code>80</code>). This only supports a subset of known schemes. (Since: 2.68)</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibUriHideFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags describing what parts of the URI to hide in
  3369. <function>g_uri_to_string_partial()</function>. Note that <constant>G_URI_HIDE_PASSWORD</constant> and
  3370. <constant>G_URI_HIDE_AUTH_PARAMS</constant> will only work if the <type>GUri</type> was parsed with
  3371. the corresponding flags.</para></refsect1><refsect1><title>Members</title><refsect2><title>none</title><remark>alias <code>G_URI_HIDE_NONE</code></remark><para>No flags set.</para></refsect2><refsect2><title>userinfo</title><remark>alias <code>G_URI_HIDE_USERINFO</code></remark><para>Hide the userinfo.</para></refsect2><refsect2><title>password</title><remark>alias <code>G_URI_HIDE_PASSWORD</code></remark><para>Hide the password.</para></refsect2><refsect2><title>auth-params</title><remark>alias <code>G_URI_HIDE_AUTH_PARAMS</code></remark><para>Hide the auth_params.</para></refsect2><refsect2><title>query</title><remark>alias <code>G_URI_HIDE_QUERY</code></remark><para>Hide the query.</para></refsect2><refsect2><title>fragment</title><remark>alias <code>G_URI_HIDE_FRAGMENT</code></remark><para>Hide the fragment.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibUriParamsFlags&gt;</refname></refnamediv><refsect1><title>Description</title><para>Flags modifying the way parameters are handled by <function>g_uri_parse_params()</function> and
  3372. <type>GUriParamsIter</type>.</para></refsect1><refsect1><title>Members</title><refsect2><title>none</title><remark>alias <code>G_URI_PARAMS_NONE</code></remark><para>No flags set.</para></refsect2><refsect2><title>case-insensitive</title><remark>alias <code>G_URI_PARAMS_CASE_INSENSITIVE</code></remark><para>Parameter names are case insensitive.</para></refsect2><refsect2><title>www-form</title><remark>alias <code>G_URI_PARAMS_WWW_FORM</code></remark><para>Replace <code>+</code> with space character. Only useful for
  3373. URLs on the web, using the <code>https</code> or <code>http</code> schemas.</para></refsect2><refsect2><title>parse-relaxed</title><remark>alias <code>G_URI_PARAMS_PARSE_RELAXED</code></remark><para>See <constant>G_URI_FLAGS_PARSE_RELAXED</constant>.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibUserDirectory&gt;</refname></refnamediv><refsect1><title>Description</title><para>These are logical ids for special directories which are defined
  3374. depending on the platform used. You should use <function>g_get_user_special_dir()</function>
  3375. to retrieve the full path associated to the logical id.
  3376. </para>
  3377. <para>The <type>GUserDirectory</type> enumeration can be extended at later date. Not
  3378. every platform has a directory for every logical id in this
  3379. enumeration.</para></refsect1><refsect1><title>Members</title><refsect2><title>directory-desktop</title><remark>alias <code>G_USER_DIRECTORY_DESKTOP</code></remark><para>the user's Desktop directory</para></refsect2><refsect2><title>directory-documents</title><remark>alias <code>G_USER_DIRECTORY_DOCUMENTS</code></remark><para>the user's Documents directory</para></refsect2><refsect2><title>directory-download</title><remark>alias <code>G_USER_DIRECTORY_DOWNLOAD</code></remark><para>the user's Downloads directory</para></refsect2><refsect2><title>directory-music</title><remark>alias <code>G_USER_DIRECTORY_MUSIC</code></remark><para>the user's Music directory</para></refsect2><refsect2><title>directory-pictures</title><remark>alias <code>G_USER_DIRECTORY_PICTURES</code></remark><para>the user's Pictures directory</para></refsect2><refsect2><title>directory-public-share</title><remark>alias <code>G_USER_DIRECTORY_PUBLIC_SHARE</code></remark><para>the user's shared directory</para></refsect2><refsect2><title>directory-templates</title><remark>alias <code>G_USER_DIRECTORY_TEMPLATES</code></remark><para>the user's Templates directory</para></refsect2><refsect2><title>directory-videos</title><remark>alias <code>G_USER_DIRECTORY_VIDEOS</code></remark><para>the user's Movies directory</para></refsect2><refsect2><title>n-directories</title><remark>alias <code>G_USER_N_DIRECTORIES</code></remark><para>the number of enum values</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GVariant&gt;</refname></refnamediv><refsect1><title>Description</title><para><type>GVariant</type> is a variant datatype; it can contain one or more values
  3380. along with information about the type of the values.
  3381. </para>
  3382. <para>A <type>GVariant</type> may contain simple types, like an integer, or a boolean value;
  3383. or complex types, like an array of two strings, or a dictionary of key
  3384. value pairs. A <type>GVariant</type> is also immutable: once it's been created neither
  3385. its type nor its content can be modified further.
  3386. </para>
  3387. <para>GVariant is useful whenever data needs to be serialized, for example when
  3388. sending method parameters in DBus, or when saving settings using GSettings.
  3389. </para>
  3390. <para>When creating a new <type>GVariant</type>, you pass the data you want to store in it
  3391. along with a string representing the type of data you wish to pass to it.
  3392. </para>
  3393. <para>For instance, if you want to create a <type>GVariant</type> holding an integer value you
  3394. can use:
  3395. </para>
  3396. <para><informalexample><programlisting>
  3397. GVariant *v = g_variant_new (&quot;u&quot;, 40);
  3398. </programlisting></informalexample></para>
  3399. <para>The string &quot;u&quot; in the first argument tells <type>GVariant</type> that the data passed to
  3400. the constructor (40) is going to be an unsigned integer.
  3401. </para>
  3402. <para>More advanced examples of <type>GVariant</type> in use can be found in documentation for
  3403. [GVariant format strings][gvariant-format-strings-pointers].
  3404. </para>
  3405. <para>The range of possible values is determined by the type.
  3406. </para>
  3407. <para>The type system used by <type>GVariant</type> is <type>GVariantType</type>.
  3408. </para>
  3409. <para><type>GVariant</type> instances always have a type and a value (which are given
  3410. at construction time). The type and value of a <type>GVariant</type> instance
  3411. can never change other than by the <type>GVariant</type> itself being
  3412. destroyed. A <type>GVariant</type> cannot contain a pointer.
  3413. </para>
  3414. <para><type>GVariant</type> is reference counted using <function>g_variant_ref()</function> and
  3415. <function>g_variant_unref()</function>. <type>GVariant</type> also has floating reference counts --
  3416. see <function>g_variant_ref_sink()</function>.
  3417. </para>
  3418. <para><type>GVariant</type> is completely threadsafe. A <type>GVariant</type> instance can be
  3419. concurrently accessed in any way from any number of threads without
  3420. problems.
  3421. </para>
  3422. <para><type>GVariant</type> is heavily optimised for dealing with data in serialised
  3423. form. It works particularly well with data located in memory-mapped
  3424. files. It can perform nearly all deserialisation operations in a
  3425. small constant time, usually touching only a single memory page.
  3426. Serialised <type>GVariant</type> data can also be sent over the network.
  3427. </para>
  3428. <para><type>GVariant</type> is largely compatible with D-Bus. Almost all types of
  3429. <type>GVariant</type> instances can be sent over D-Bus. See <type>GVariantType</type> for
  3430. exceptions. (However, <type>GVariant</type>'s serialisation format is not the same
  3431. as the serialisation format of a D-Bus message body: use <type>GDBusMessage</type>,
  3432. in the gio library, for those.)
  3433. </para>
  3434. <para>For space-efficiency, the <type>GVariant</type> serialisation format does not
  3435. automatically include the variant's length, type or endianness,
  3436. which must either be implied from context (such as knowledge that a
  3437. particular file format always contains a little-endian
  3438. <constant>G_VARIANT_TYPE_VARIANT</constant> which occupies the whole length of the file)
  3439. or supplied out-of-band (for instance, a length, type and/or endianness
  3440. indicator could be placed at the beginning of a file, network message
  3441. or network stream).
  3442. </para>
  3443. <para>A <type>GVariant</type>'s size is limited mainly by any lower level operating
  3444. system constraints, such as the number of bits in <type>gsize</type>. For
  3445. example, it is reasonable to have a 2GB file mapped into memory
  3446. with <type>GMappedFile</type>, and call <function>g_variant_new_from_data()</function> on it.
  3447. </para>
  3448. <para>For convenience to C programmers, <type>GVariant</type> features powerful
  3449. varargs-based value construction and destruction. This feature is
  3450. designed to be embedded in other libraries.
  3451. </para>
  3452. <para>There is a Python-inspired text language for describing <type>GVariant</type>
  3453. values. <type>GVariant</type> includes a printer for this language and a parser
  3454. with type inferencing.
  3455. </para>
  3456. <refsect2><title>Memory Use</title>
  3457. <para><type>GVariant</type> tries to be quite efficient with respect to memory use.
  3458. This section gives a rough idea of how much memory is used by the
  3459. current implementation. The information here is subject to change
  3460. in the future.
  3461. </para>
  3462. <para>The memory allocated by <type>GVariant</type> can be grouped into 4 broad
  3463. purposes: memory for serialised data, memory for the type
  3464. information cache, buffer management memory and memory for the
  3465. <type>GVariant</type> structure itself.
  3466. </para>
  3467. </refsect2><refsect2><title>Serialised Data Memory</title>
  3468. <para>This is the memory that is used for storing GVariant data in
  3469. serialised form. This is what would be sent over the network or
  3470. what would end up on disk, not counting any indicator of the
  3471. endianness, or of the length or type of the top-level variant.
  3472. </para>
  3473. <para>The amount of memory required to store a boolean is 1 byte. 16,
  3474. 32 and 64 bit integers and double precision floating point numbers
  3475. use their &quot;natural&quot; size. Strings (including object path and
  3476. signature strings) are stored with a nul terminator, and as such
  3477. use the length of the string plus 1 byte.
  3478. </para>
  3479. <para>Maybe types use no space at all to represent the null value and
  3480. use the same amount of space (sometimes plus one byte) as the
  3481. equivalent non-maybe-typed value to represent the non-null case.
  3482. </para>
  3483. <para>Arrays use the amount of space required to store each of their
  3484. members, concatenated. Additionally, if the items stored in an
  3485. array are not of a fixed-size (ie: strings, other arrays, etc)
  3486. then an additional framing offset is stored for each item. The
  3487. size of this offset is either 1, 2 or 4 bytes depending on the
  3488. overall size of the container. Additionally, extra padding bytes
  3489. are added as required for alignment of child values.
  3490. </para>
  3491. <para>Tuples (including dictionary entries) use the amount of space
  3492. required to store each of their members, concatenated, plus one
  3493. framing offset (as per arrays) for each non-fixed-sized item in
  3494. the tuple, except for the last one. Additionally, extra padding
  3495. bytes are added as required for alignment of child values.
  3496. </para>
  3497. <para>Variants use the same amount of space as the item inside of the
  3498. variant, plus 1 byte, plus the length of the type string for the
  3499. item inside the variant.
  3500. </para>
  3501. <para>As an example, consider a dictionary mapping strings to variants.
  3502. In the case that the dictionary is empty, 0 bytes are required for
  3503. the serialisation.
  3504. </para>
  3505. <para>If we add an item &quot;width&quot; that maps to the int32 value of 500 then
  3506. we will use 4 byte to store the int32 (so 6 for the variant
  3507. containing it) and 6 bytes for the string. The variant must be
  3508. aligned to 8 after the 6 bytes of the string, so that's 2 extra
  3509. bytes. 6 (string) + 2 (padding) + 6 (variant) is 14 bytes used
  3510. for the dictionary entry. An additional 1 byte is added to the
  3511. array as a framing offset making a total of 15 bytes.
  3512. </para>
  3513. <para>If we add another entry, &quot;title&quot; that maps to a nullable string
  3514. that happens to have a value of null, then we use 0 bytes for the
  3515. null value (and 3 bytes for the variant to contain it along with
  3516. its type string) plus 6 bytes for the string. Again, we need 2
  3517. padding bytes. That makes a total of 6 + 2 + 3 = 11 bytes.
  3518. </para>
  3519. <para>We now require extra padding between the two items in the array.
  3520. After the 14 bytes of the first item, that's 2 bytes required.
  3521. We now require 2 framing offsets for an extra two
  3522. bytes. 14 + 2 + 11 + 2 = 29 bytes to encode the entire two-item
  3523. dictionary.
  3524. </para>
  3525. </refsect2><refsect2><title>Type Information Cache</title>
  3526. <para>For each GVariant type that currently exists in the program a type
  3527. information structure is kept in the type information cache. The
  3528. type information structure is required for rapid deserialisation.
  3529. </para>
  3530. <para>Continuing with the above example, if a <type>GVariant</type> exists with the
  3531. type &quot;a{sv}&quot; then a type information struct will exist for
  3532. &quot;a{sv}&quot;, &quot;{sv}&quot;, &quot;s&quot;, and &quot;v&quot;. Multiple uses of the same type
  3533. will share the same type information. Additionally, all
  3534. single-digit types are stored in read-only static memory and do
  3535. not contribute to the writable memory footprint of a program using
  3536. <type>GVariant</type>.
  3537. </para>
  3538. <para>Aside from the type information structures stored in read-only
  3539. memory, there are two forms of type information. One is used for
  3540. container types where there is a single element type: arrays and
  3541. maybe types. The other is used for container types where there
  3542. are multiple element types: tuples and dictionary entries.
  3543. </para>
  3544. <para>Array type info structures are 6 * sizeof (void *), plus the
  3545. memory required to store the type string itself. This means that
  3546. on 32-bit systems, the cache entry for &quot;a{sv}&quot; would require 30
  3547. bytes of memory (plus malloc overhead).
  3548. </para>
  3549. <para>Tuple type info structures are 6 * sizeof (void *), plus 4 *
  3550. sizeof (void *) for each item in the tuple, plus the memory
  3551. required to store the type string itself. A 2-item tuple, for
  3552. example, would have a type information structure that consumed
  3553. writable memory in the size of 14 * sizeof (void *) (plus type
  3554. string) This means that on 32-bit systems, the cache entry for
  3555. &quot;{sv}&quot; would require 61 bytes of memory (plus malloc overhead).
  3556. </para>
  3557. <para>This means that in total, for our &quot;a{sv}&quot; example, 91 bytes of
  3558. type information would be allocated.
  3559. </para>
  3560. <para>The type information cache, additionally, uses a <type>GHashTable</type> to
  3561. store and look up the cached items and stores a pointer to this
  3562. hash table in static storage. The hash table is freed when there
  3563. are zero items in the type cache.
  3564. </para>
  3565. <para>Although these sizes may seem large it is important to remember
  3566. that a program will probably only have a very small number of
  3567. different types of values in it and that only one type information
  3568. structure is required for many different values of the same type.
  3569. </para>
  3570. </refsect2><refsect2><title>Buffer Management Memory</title>
  3571. <para><type>GVariant</type> uses an internal buffer management structure to deal
  3572. with the various different possible sources of serialised data
  3573. that it uses. The buffer is responsible for ensuring that the
  3574. correct call is made when the data is no longer in use by
  3575. <type>GVariant</type>. This may involve a <function>g_free()</function> or a <function>g_slice_free()</function> or
  3576. even <function>g_mapped_file_unref()</function>.
  3577. </para>
  3578. <para>One buffer management structure is used for each chunk of
  3579. serialised data. The size of the buffer management structure
  3580. is 4 * (void *). On 32-bit systems, that's 16 bytes.
  3581. </para>
  3582. </refsect2><refsect2><title>GVariant structure</title>
  3583. <para>The size of a <type>GVariant</type> structure is 6 * (void *). On 32-bit
  3584. systems, that's 24 bytes.
  3585. </para>
  3586. <para><type>GVariant</type> structures only exist if they are explicitly created
  3587. with API calls. For example, if a <type>GVariant</type> is constructed out of
  3588. serialised data for the example given above (with the dictionary)
  3589. then although there are 9 individual values that comprise the
  3590. entire dictionary (two keys, two values, two variants containing
  3591. the values, two dictionary entries, plus the dictionary itself),
  3592. only 1 <type>GVariant</type> instance exists -- the one referring to the
  3593. dictionary.
  3594. </para>
  3595. <para>If calls are made to start accessing the other values then
  3596. <type>GVariant</type> instances will exist for those values only for as long
  3597. as they are in use (ie: until you call <function>g_variant_unref()</function>). The
  3598. type information is shared. The serialised data and the buffer
  3599. management structure for that serialised data is shared by the
  3600. child.
  3601. </para>
  3602. </refsect2><refsect2><title>Summary</title>
  3603. <para>To put the entire example together, for our dictionary mapping
  3604. strings to variants (with two entries, as given above), we are
  3605. using 91 bytes of memory for type information, 29 bytes of memory
  3606. for the serialised data, 16 bytes for buffer management and 24
  3607. bytes for the <type>GVariant</type> instance, or a total of 160 bytes, plus
  3608. malloc overhead. If we were to use <function>g_variant_get_child_value()</function> to
  3609. access the two dictionary entries, we would use an additional 48
  3610. bytes. If we were to have other dictionaries of the same type, we
  3611. would use more memory for the serialised data and buffer
  3612. management for those dictionaries, but the type information would
  3613. be shared.</para></refsect2></refsect1><refsect1><title>Functions</title><refsect2><title>byteswap</title><informalexample><programlisting>(define-values (%return) (variant:byteswap self))
  3614. </programlisting></informalexample><para>Performs a byteswapping operation on the contents of <parameter>value</parameter>. The
  3615. result is that all multi-byte numeric data contained in <parameter>value</parameter> is
  3616. byteswapped. That includes 16, 32, and 64bit signed and unsigned
  3617. integers as well as file handles and double precision floating point
  3618. values.
  3619. </para>
  3620. <para>This function is an identity mapping on any value that does not
  3621. contain multi-byte numeric data. That include strings, booleans,
  3622. bytes and containers containing only these things (recursively).
  3623. </para>
  3624. <para>The returned value is always in normal form and is marked as trusted.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>check-format-string?</title><informalexample><programlisting>(define-values
  3625. (%return)
  3626. (variant:check-format-string? self format-string copy-only))
  3627. </programlisting></informalexample><para>Checks if calling <function>g_variant_get()</function> with <parameter>format_string</parameter> on <parameter>value</parameter> would
  3628. be valid from a type-compatibility standpoint. <parameter>format_string</parameter> is
  3629. assumed to be a valid format string (from a syntactic standpoint).
  3630. </para>
  3631. <para>If <parameter>copy_only</parameter> is <constant>TRUE</constant> then this function additionally checks that it
  3632. would be safe to call <function>g_variant_unref()</function> on <parameter>value</parameter> immediately after
  3633. the call to <function>g_variant_get()</function> without invalidating the result. This is
  3634. only possible if deep copies are made (ie: there are no pointers to
  3635. the data inside of the soon-to-be-freed <type>GVariant</type> instance). If this
  3636. check fails then a <function>g_critical()</function> is printed and <constant>FALSE</constant> is returned.
  3637. </para>
  3638. <para>This function is meant to be used by functions that wish to provide
  3639. varargs accessors to <type>GVariant</type> values of uncertain values (eg:
  3640. <function>g_variant_lookup()</function> or <function>g_menu_model_get_item_attribute()</function>).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>format_string</para></td><td class="parameter_description"><para>a valid <type>GVariant</type> format string</para><para>Passed as <code>format-string</code></para></td></tr><tr><td class="parameter_name"><para>copy_only</para></td><td class="parameter_description"><para><constant>TRUE</constant> to ensure the format string makes deep copies</para><para>Passed as <code>copy-only</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>classify</title><informalexample><programlisting>(define-values (%return) (variant:classify self))
  3641. </programlisting></informalexample><para>Classifies <parameter>value</parameter> according to its top-level type.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>compare</title><informalexample><programlisting>(define-values (%return) (variant:compare self two))
  3642. </programlisting></informalexample><para>Compares <parameter>one</parameter> and <parameter>two</parameter>.
  3643. </para>
  3644. <para>The types of <parameter>one</parameter> and <parameter>two</parameter> are <type>gconstpointer</type> only to allow use of
  3645. this function with <type>GTree</type>, <type>GPtrArray</type>, etc. They must each be a
  3646. <type>GVariant</type>.
  3647. </para>
  3648. <para>Comparison is only defined for basic types (ie: booleans, numbers,
  3649. strings). For booleans, <constant>FALSE</constant> is less than <constant>TRUE</constant>. Numbers are
  3650. ordered in the usual way. Strings are in ASCII lexographical order.
  3651. </para>
  3652. <para>It is a programmer error to attempt to compare container values or
  3653. two values that have types that are not exactly equal. For example,
  3654. you cannot compare a 32-bit signed integer with a 32-bit unsigned
  3655. integer. Also note that this function is not particularly
  3656. well-behaved when it comes to comparison of doubles; in particular,
  3657. the handling of incomparable values (ie: NaN) is undefined.
  3658. </para>
  3659. <para>If you only require an equality comparison, <function>g_variant_equal()</function> is more
  3660. general.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>one</para></td><td class="parameter_description"><para>a basic-typed <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>two</para></td><td class="parameter_description"><para>a <type>GVariant</type> instance of the same type</para><para>Passed as <code>two</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dup-bytestring</title><informalexample><programlisting>(define-values (%return length) (variant:dup-bytestring self))
  3661. </programlisting></informalexample><para>Similar to <function>g_variant_get_bytestring()</function> except that instead of
  3662. returning a constant string, the string is duplicated.
  3663. </para>
  3664. <para>The return value must be freed using <function>g_free()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an array-of-bytes <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>a pointer to a <type>gsize</type>, to store
  3665. the length (not including the nul terminator)</para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dup-bytestring-array</title><informalexample><programlisting>(define-values (%return length) (variant:dup-bytestring-array self))
  3666. </programlisting></informalexample><para>Gets the contents of an array of array of bytes <type>GVariant</type>. This call
  3667. makes a deep copy; the return result should be released with
  3668. <function>g_strfreev()</function>.
  3669. </para>
  3670. <para>If <parameter>length</parameter> is non-<constant>NULL</constant> then the number of elements in the result is
  3671. stored there. In any case, the resulting array will be
  3672. <constant>NULL</constant>-terminated.
  3673. </para>
  3674. <para>For an empty array, <parameter>length</parameter> will be set to 0 and a pointer to a
  3675. <constant>NULL</constant> pointer will be returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an array of array of bytes <type>GVariant</type> ('aay')</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of the result, or <constant>NULL</constant></para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dup-objv</title><informalexample><programlisting>(define-values (%return length) (variant:dup-objv self))
  3676. </programlisting></informalexample><para>Gets the contents of an array of object paths <type>GVariant</type>. This call
  3677. makes a deep copy; the return result should be released with
  3678. <function>g_strfreev()</function>.
  3679. </para>
  3680. <para>If <parameter>length</parameter> is non-<constant>NULL</constant> then the number of elements in the result
  3681. is stored there. In any case, the resulting array will be
  3682. <constant>NULL</constant>-terminated.
  3683. </para>
  3684. <para>For an empty array, <parameter>length</parameter> will be set to 0 and a pointer to a
  3685. <constant>NULL</constant> pointer will be returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an array of object paths <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of the result, or <constant>NULL</constant></para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dup-string</title><informalexample><programlisting>(define-values (%return length) (variant:dup-string self))
  3686. </programlisting></informalexample><para>Similar to <function>g_variant_get_string()</function> except that instead of returning
  3687. a constant string, the string is duplicated.
  3688. </para>
  3689. <para>The string will always be UTF-8 encoded.
  3690. </para>
  3691. <para>The return value must be freed using <function>g_free()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a string <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>a pointer to a <type>gsize</type>, to store the length</para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dup-strv</title><informalexample><programlisting>(define-values (%return length) (variant:dup-strv self))
  3692. </programlisting></informalexample><para>Gets the contents of an array of strings <type>GVariant</type>. This call
  3693. makes a deep copy; the return result should be released with
  3694. <function>g_strfreev()</function>.
  3695. </para>
  3696. <para>If <parameter>length</parameter> is non-<constant>NULL</constant> then the number of elements in the result
  3697. is stored there. In any case, the resulting array will be
  3698. <constant>NULL</constant>-terminated.
  3699. </para>
  3700. <para>For an empty array, <parameter>length</parameter> will be set to 0 and a pointer to a
  3701. <constant>NULL</constant> pointer will be returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an array of strings <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of the result, or <constant>NULL</constant></para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>equal?</title><informalexample><programlisting>(define-values (%return) (variant:equal? self two))
  3702. </programlisting></informalexample><para>Checks if <parameter>one</parameter> and <parameter>two</parameter> have the same type and value.
  3703. </para>
  3704. <para>The types of <parameter>one</parameter> and <parameter>two</parameter> are <type>gconstpointer</type> only to allow use of
  3705. this function with <type>GHashTable</type>. They must each be a <type>GVariant</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>one</para></td><td class="parameter_description"><para>a <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>two</para></td><td class="parameter_description"><para>a <type>GVariant</type> instance</para><para>Passed as <code>two</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-boolean?</title><informalexample><programlisting>(define-values (%return) (variant:get-boolean? self))
  3706. </programlisting></informalexample><para>Returns the boolean value of <parameter>value</parameter>.
  3707. </para>
  3708. <para>It is an error to call this function with a <parameter>value</parameter> of any type
  3709. other than <constant>G_VARIANT_TYPE_BOOLEAN</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a boolean <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-byte</title><informalexample><programlisting>(define-values (%return) (variant:get-byte self))
  3710. </programlisting></informalexample><para>Returns the byte value of <parameter>value</parameter>.
  3711. </para>
  3712. <para>It is an error to call this function with a <parameter>value</parameter> of any type
  3713. other than <constant>G_VARIANT_TYPE_BYTE</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a byte <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-bytestring</title><informalexample><programlisting>(define-values (%return) (variant:get-bytestring self))
  3714. </programlisting></informalexample><para>Returns the string value of a <type>GVariant</type> instance with an
  3715. array-of-bytes type. The string has no particular encoding.
  3716. </para>
  3717. <para>If the array does not end with a nul terminator character, the empty
  3718. string is returned. For this reason, you can always trust that a
  3719. non-<constant>NULL</constant> nul-terminated string will be returned by this function.
  3720. </para>
  3721. <para>If the array contains a nul terminator character somewhere other than
  3722. the last byte then the returned string is the string, up to the first
  3723. such nul character.
  3724. </para>
  3725. <para><function>g_variant_get_fixed_array()</function> should be used instead if the array contains
  3726. arbitrary data that could not be nul-terminated or could contain nul bytes.
  3727. </para>
  3728. <para>It is an error to call this function with a <parameter>value</parameter> that is not an
  3729. array of bytes.
  3730. </para>
  3731. <para>The return value remains valid as long as <parameter>value</parameter> exists.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an array-of-bytes <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-bytestring-array</title><informalexample><programlisting>(define-values (%return length) (variant:get-bytestring-array self))
  3732. </programlisting></informalexample><para>Gets the contents of an array of array of bytes <type>GVariant</type>. This call
  3733. makes a shallow copy; the return result should be released with
  3734. <function>g_free()</function>, but the individual strings must not be modified.
  3735. </para>
  3736. <para>If <parameter>length</parameter> is non-<constant>NULL</constant> then the number of elements in the result is
  3737. stored there. In any case, the resulting array will be
  3738. <constant>NULL</constant>-terminated.
  3739. </para>
  3740. <para>For an empty array, <parameter>length</parameter> will be set to 0 and a pointer to a
  3741. <constant>NULL</constant> pointer will be returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an array of array of bytes <type>GVariant</type> ('aay')</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of the result, or <constant>NULL</constant></para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-child-value</title><informalexample><programlisting>(define-values (%return) (variant:get-child-value self index-))
  3742. </programlisting></informalexample><para>Reads a child item out of a container <type>GVariant</type> instance. This
  3743. includes variants, maybes, arrays, tuples and dictionary
  3744. entries. It is an error to call this function on any other type of
  3745. <type>GVariant</type>.
  3746. </para>
  3747. <para>It is an error if <parameter>index_</parameter> is greater than the number of child items
  3748. in the container. See <function>g_variant_n_children()</function>.
  3749. </para>
  3750. <para>The returned value is never floating. You should free it with
  3751. <function>g_variant_unref()</function> when you're done with it.
  3752. </para>
  3753. <para>Note that values borrowed from the returned child are not guaranteed to
  3754. still be valid after the child is freed even if you still hold a reference
  3755. to <parameter>value</parameter>, if <parameter>value</parameter> has not been serialised at the time this function is
  3756. called. To avoid this, you can serialize <parameter>value</parameter> by calling
  3757. <function>g_variant_get_data()</function> and optionally ignoring the return value.
  3758. </para>
  3759. <para>There may be implementation specific restrictions on deeply nested values,
  3760. which would result in the unit tuple being returned as the child value,
  3761. instead of further nested children. <type>GVariant</type> is guaranteed to handle
  3762. nesting up to at least 64 levels.
  3763. </para>
  3764. <para>This function is O(1).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a container <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>index_</para></td><td class="parameter_description"><para>the index of the child to fetch</para><para>Passed as <code>index-</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-data</title><informalexample><programlisting>(define-values (%return) (variant:get-data self))
  3765. </programlisting></informalexample><para>Returns a pointer to the serialised form of a <type>GVariant</type> instance.
  3766. The returned data may not be in fully-normalised form if read from an
  3767. untrusted source. The returned data must not be freed; it remains
  3768. valid for as long as <parameter>value</parameter> exists.
  3769. </para>
  3770. <para>If <parameter>value</parameter> is a fixed-sized value that was deserialised from a
  3771. corrupted serialised container then <constant>NULL</constant> may be returned. In this
  3772. case, the proper thing to do is typically to use the appropriate
  3773. number of nul bytes in place of <parameter>value</parameter>. If <parameter>value</parameter> is not fixed-sized
  3774. then <constant>NULL</constant> is never returned.
  3775. </para>
  3776. <para>In the case that <parameter>value</parameter> is already in serialised form, this function
  3777. is O(1). If the value is not already in serialised form,
  3778. serialisation occurs implicitly and is approximately O(n) in the size
  3779. of the result.
  3780. </para>
  3781. <para>To deserialise the data returned by this function, in addition to the
  3782. serialised data, you must know the type of the <type>GVariant</type>, and (if the
  3783. machine might be different) the endianness of the machine that stored
  3784. it. As a result, file formats or network messages that incorporate
  3785. serialised <type>GVariants</type> must include this information either
  3786. implicitly (for instance &quot;the file always contains a
  3787. <constant>G_VARIANT_TYPE_VARIANT</constant> and it is always in little-endian order&quot;) or
  3788. explicitly (by storing the type and/or endianness in addition to the
  3789. serialised data).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-data-as-bytes</title><informalexample><programlisting>(define-values (%return) (variant:get-data-as-bytes self))
  3790. </programlisting></informalexample><para>Returns a pointer to the serialised form of a <type>GVariant</type> instance.
  3791. The semantics of this function are exactly the same as
  3792. <function>g_variant_get_data()</function>, except that the returned <type>GBytes</type> holds
  3793. a reference to the variant data.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-double</title><informalexample><programlisting>(define-values (%return) (variant:get-double self))
  3794. </programlisting></informalexample><para>Returns the double precision floating point value of <parameter>value</parameter>.
  3795. </para>
  3796. <para>It is an error to call this function with a <parameter>value</parameter> of any type
  3797. other than <constant>G_VARIANT_TYPE_DOUBLE</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a double <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-handle</title><informalexample><programlisting>(define-values (%return) (variant:get-handle self))
  3798. </programlisting></informalexample><para>Returns the 32-bit signed integer value of <parameter>value</parameter>.
  3799. </para>
  3800. <para>It is an error to call this function with a <parameter>value</parameter> of any type other
  3801. than <constant>G_VARIANT_TYPE_HANDLE</constant>.
  3802. </para>
  3803. <para>By convention, handles are indexes into an array of file descriptors
  3804. that are sent alongside a D-Bus message. If you're not interacting
  3805. with D-Bus, you probably don't need them.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a handle <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-int16</title><informalexample><programlisting>(define-values (%return) (variant:get-int16 self))
  3806. </programlisting></informalexample><para>Returns the 16-bit signed integer value of <parameter>value</parameter>.
  3807. </para>
  3808. <para>It is an error to call this function with a <parameter>value</parameter> of any type
  3809. other than <constant>G_VARIANT_TYPE_INT16</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an int16 <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-int32</title><informalexample><programlisting>(define-values (%return) (variant:get-int32 self))
  3810. </programlisting></informalexample><para>Returns the 32-bit signed integer value of <parameter>value</parameter>.
  3811. </para>
  3812. <para>It is an error to call this function with a <parameter>value</parameter> of any type
  3813. other than <constant>G_VARIANT_TYPE_INT32</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an int32 <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-int64</title><informalexample><programlisting>(define-values (%return) (variant:get-int64 self))
  3814. </programlisting></informalexample><para>Returns the 64-bit signed integer value of <parameter>value</parameter>.
  3815. </para>
  3816. <para>It is an error to call this function with a <parameter>value</parameter> of any type
  3817. other than <constant>G_VARIANT_TYPE_INT64</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an int64 <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-maybe</title><informalexample><programlisting>(define-values (%return) (variant:get-maybe self))
  3818. </programlisting></informalexample><para>Given a maybe-typed <type>GVariant</type> instance, extract its value. If the
  3819. value is Nothing, then this function returns <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a maybe-typed value</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-normal-form</title><informalexample><programlisting>(define-values (%return) (variant:get-normal-form self))
  3820. </programlisting></informalexample><para>Gets a <type>GVariant</type> instance that has the same value as <parameter>value</parameter> and is
  3821. trusted to be in normal form.
  3822. </para>
  3823. <para>If <parameter>value</parameter> is already trusted to be in normal form then a new
  3824. reference to <parameter>value</parameter> is returned.
  3825. </para>
  3826. <para>If <parameter>value</parameter> is not already trusted, then it is scanned to check if it
  3827. is in normal form. If it is found to be in normal form then it is
  3828. marked as trusted and a new reference to it is returned.
  3829. </para>
  3830. <para>If <parameter>value</parameter> is found not to be in normal form then a new trusted
  3831. <type>GVariant</type> is created with the same value as <parameter>value</parameter>.
  3832. </para>
  3833. <para>It makes sense to call this function if you've received <type>GVariant</type>
  3834. data from untrusted sources and you want to ensure your serialised
  3835. output is definitely in normal form.
  3836. </para>
  3837. <para>If <parameter>value</parameter> is already in normal form, a new reference will be returned
  3838. (which will be floating if <parameter>value</parameter> is floating). If it is not in normal form,
  3839. the newly created <type>GVariant</type> will be returned with a single non-floating
  3840. reference. Typically, <function>g_variant_take_ref()</function> should be called on the return
  3841. value from this function to guarantee ownership of a single non-floating
  3842. reference to it.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-objv</title><informalexample><programlisting>(define-values (%return length) (variant:get-objv self))
  3843. </programlisting></informalexample><para>Gets the contents of an array of object paths <type>GVariant</type>. This call
  3844. makes a shallow copy; the return result should be released with
  3845. <function>g_free()</function>, but the individual strings must not be modified.
  3846. </para>
  3847. <para>If <parameter>length</parameter> is non-<constant>NULL</constant> then the number of elements in the result
  3848. is stored there. In any case, the resulting array will be
  3849. <constant>NULL</constant>-terminated.
  3850. </para>
  3851. <para>For an empty array, <parameter>length</parameter> will be set to 0 and a pointer to a
  3852. <constant>NULL</constant> pointer will be returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an array of object paths <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of the result, or <constant>NULL</constant></para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-size</title><informalexample><programlisting>(define-values (%return) (variant:get-size self))
  3853. </programlisting></informalexample><para>Determines the number of bytes that would be required to store <parameter>value</parameter>
  3854. with <function>g_variant_store()</function>.
  3855. </para>
  3856. <para>If <parameter>value</parameter> has a fixed-sized type then this function always returned
  3857. that fixed size.
  3858. </para>
  3859. <para>In the case that <parameter>value</parameter> is already in serialised form or the size has
  3860. already been calculated (ie: this function has been called before)
  3861. then this function is O(1). Otherwise, the size is calculated, an
  3862. operation which is approximately O(n) in the number of values
  3863. involved.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-string</title><informalexample><programlisting>(define-values (%return length) (variant:get-string self))
  3864. </programlisting></informalexample><para>Returns the string value of a <type>GVariant</type> instance with a string
  3865. type. This includes the types <constant>G_VARIANT_TYPE_STRING</constant>,
  3866. <constant>G_VARIANT_TYPE_OBJECT_PATH</constant> and <constant>G_VARIANT_TYPE_SIGNATURE</constant>.
  3867. </para>
  3868. <para>The string will always be UTF-8 encoded, will never be <constant>NULL</constant>, and will never
  3869. contain nul bytes.
  3870. </para>
  3871. <para>If <parameter>length</parameter> is non-<constant>NULL</constant> then the length of the string (in bytes) is
  3872. returned there. For trusted values, this information is already
  3873. known. Untrusted values will be validated and, if valid, a <function>strlen()</function> will be
  3874. performed. If invalid, a default value will be returned — for
  3875. <constant>G_VARIANT_TYPE_OBJECT_PATH</constant>, this is <code>&quot;/&quot;</code>, and for other types it is the
  3876. empty string.
  3877. </para>
  3878. <para>It is an error to call this function with a <parameter>value</parameter> of any type
  3879. other than those three.
  3880. </para>
  3881. <para>The return value remains valid as long as <parameter>value</parameter> exists.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a string <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>a pointer to a <type>gsize</type>,
  3882. to store the length</para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-strv</title><informalexample><programlisting>(define-values (%return length) (variant:get-strv self))
  3883. </programlisting></informalexample><para>Gets the contents of an array of strings <type>GVariant</type>. This call
  3884. makes a shallow copy; the return result should be released with
  3885. <function>g_free()</function>, but the individual strings must not be modified.
  3886. </para>
  3887. <para>If <parameter>length</parameter> is non-<constant>NULL</constant> then the number of elements in the result
  3888. is stored there. In any case, the resulting array will be
  3889. <constant>NULL</constant>-terminated.
  3890. </para>
  3891. <para>For an empty array, <parameter>length</parameter> will be set to 0 and a pointer to a
  3892. <constant>NULL</constant> pointer will be returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>an array of strings <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of the result, or <constant>NULL</constant></para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-type</title><informalexample><programlisting>(define-values (%return) (variant:get-type self))
  3893. </programlisting></informalexample><para>Determines the type of <parameter>value</parameter>.
  3894. </para>
  3895. <para>The return value is valid for the lifetime of <parameter>value</parameter> and must not
  3896. be freed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-type-string</title><informalexample><programlisting>(define-values (%return) (variant:get-type-string self))
  3897. </programlisting></informalexample><para>Returns the type string of <parameter>value</parameter>. Unlike the result of calling
  3898. <function>g_variant_type_peek_string()</function>, this string is nul-terminated. This
  3899. string belongs to <type>GVariant</type> and must not be freed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-uint16</title><informalexample><programlisting>(define-values (%return) (variant:get-uint16 self))
  3900. </programlisting></informalexample><para>Returns the 16-bit unsigned integer value of <parameter>value</parameter>.
  3901. </para>
  3902. <para>It is an error to call this function with a <parameter>value</parameter> of any type
  3903. other than <constant>G_VARIANT_TYPE_UINT16</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a uint16 <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-uint32</title><informalexample><programlisting>(define-values (%return) (variant:get-uint32 self))
  3904. </programlisting></informalexample><para>Returns the 32-bit unsigned integer value of <parameter>value</parameter>.
  3905. </para>
  3906. <para>It is an error to call this function with a <parameter>value</parameter> of any type
  3907. other than <constant>G_VARIANT_TYPE_UINT32</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a uint32 <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-uint64</title><informalexample><programlisting>(define-values (%return) (variant:get-uint64 self))
  3908. </programlisting></informalexample><para>Returns the 64-bit unsigned integer value of <parameter>value</parameter>.
  3909. </para>
  3910. <para>It is an error to call this function with a <parameter>value</parameter> of any type
  3911. other than <constant>G_VARIANT_TYPE_UINT64</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a uint64 <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-variant</title><informalexample><programlisting>(define-values (%return) (variant:get-variant self))
  3912. </programlisting></informalexample><para>Unboxes <parameter>value</parameter>. The result is the <type>GVariant</type> instance that was
  3913. contained in <parameter>value</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a variant <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash</title><informalexample><programlisting>(define-values (%return) (variant:hash self))
  3914. </programlisting></informalexample><para>Generates a hash value for a <type>GVariant</type> instance.
  3915. </para>
  3916. <para>The output of this function is guaranteed to be the same for a given
  3917. value only per-process. It may change between different processor
  3918. architectures or even different versions of GLib. Do not use this
  3919. function as a basis for building protocols or file formats.
  3920. </para>
  3921. <para>The type of <parameter>value</parameter> is <type>gconstpointer</type> only to allow use of this
  3922. function with <type>GHashTable</type>. <parameter>value</parameter> must be a <type>GVariant</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a basic <type>GVariant</type> value as a <type>gconstpointer</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-container?</title><informalexample><programlisting>(define-values (%return) (variant:is-container? self))
  3923. </programlisting></informalexample><para>Checks if <parameter>value</parameter> is a container.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-floating?</title><informalexample><programlisting>(define-values (%return) (variant:is-floating? self))
  3924. </programlisting></informalexample><para>Checks whether <parameter>value</parameter> has a floating reference count.
  3925. </para>
  3926. <para>This function should only ever be used to assert that a given variant
  3927. is or is not floating, or for debug purposes. To acquire a reference
  3928. to a variant that might be floating, always use <function>g_variant_ref_sink()</function>
  3929. or <function>g_variant_take_ref()</function>.
  3930. </para>
  3931. <para>See <function>g_variant_ref_sink()</function> for more information about floating reference
  3932. counts.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-normal-form?</title><informalexample><programlisting>(define-values (%return) (variant:is-normal-form? self))
  3933. </programlisting></informalexample><para>Checks if <parameter>value</parameter> is in normal form.
  3934. </para>
  3935. <para>The main reason to do this is to detect if a given chunk of
  3936. serialised data is in normal form: load the data into a <type>GVariant</type>
  3937. using <function>g_variant_new_from_data()</function> and then use this function to
  3938. check.
  3939. </para>
  3940. <para>If <parameter>value</parameter> is found to be in normal form then it will be marked as
  3941. being trusted. If the value was already marked as being trusted then
  3942. this function will immediately return <constant>TRUE</constant>.
  3943. </para>
  3944. <para>There may be implementation specific restrictions on deeply nested values.
  3945. GVariant is guaranteed to handle nesting up to at least 64 levels.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-of-type?</title><informalexample><programlisting>(define-values (%return) (variant:is-of-type? self type))
  3946. </programlisting></informalexample><para>Checks if a value has a type matching the provided type.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type> instance</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>type</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>lookup-value</title><informalexample><programlisting>(define-values (%return) (variant:lookup-value self key expected-type))
  3947. </programlisting></informalexample><para>Looks up a value in a dictionary <type>GVariant</type>.
  3948. </para>
  3949. <para>This function works with dictionaries of the type a{s*} (and equally
  3950. well with type a{o*}, but we only further discuss the string case
  3951. for sake of clarity).
  3952. </para>
  3953. <para>In the event that <parameter>dictionary</parameter> has the type a{sv}, the <parameter>expected_type</parameter>
  3954. string specifies what type of value is expected to be inside of the
  3955. variant. If the value inside the variant has a different type then
  3956. <constant>NULL</constant> is returned. In the event that <parameter>dictionary</parameter> has a value type other
  3957. than v then <parameter>expected_type</parameter> must directly match the value type and it is
  3958. used to unpack the value directly or an error occurs.
  3959. </para>
  3960. <para>In either case, if <parameter>key</parameter> is not found in <parameter>dictionary</parameter>, <constant>NULL</constant> is returned.
  3961. </para>
  3962. <para>If the key is found and the value has the correct type, it is
  3963. returned. If <parameter>expected_type</parameter> was specified then any non-<constant>NULL</constant> return
  3964. value will have this type.
  3965. </para>
  3966. <para>This function is currently implemented with a linear scan. If you
  3967. plan to do many lookups then <type>GVariantDict</type> may be more efficient.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dictionary</para></td><td class="parameter_description"><para>a dictionary <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to look up in the dictionary</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>expected_type</para></td><td class="parameter_description"><para>a <type>GVariantType</type>, or <constant>NULL</constant></para><para>Passed as <code>expected-type</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>n-children</title><informalexample><programlisting>(define-values (%return) (variant:n-children self))
  3968. </programlisting></informalexample><para>Determines the number of children in a container <type>GVariant</type> instance.
  3969. This includes variants, maybes, arrays, tuples and dictionary
  3970. entries. It is an error to call this function on any other type of
  3971. <type>GVariant</type>.
  3972. </para>
  3973. <para>For variants, the return value is always 1. For values with maybe
  3974. types, it is always zero or one. For arrays, it is the length of the
  3975. array. For tuples it is the number of tuple items (which depends
  3976. only on the type). For dictionary entries, it is always 2
  3977. </para>
  3978. <para>This function is O(1).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a container <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>print</title><informalexample><programlisting>(define-values (%return) (variant:print self type-annotate))
  3979. </programlisting></informalexample><para>Pretty-prints <parameter>value</parameter> in the format understood by <function>g_variant_parse()</function>.
  3980. </para>
  3981. <para>The format is described [here][gvariant-text].
  3982. </para>
  3983. <para>If <parameter>type_annotate</parameter> is <constant>TRUE</constant>, then type information is included in
  3984. the output.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>type_annotate</para></td><td class="parameter_description"><para><constant>TRUE</constant> if type information should be included in
  3985. the output</para><para>Passed as <code>type-annotate</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (variant:ref self))
  3986. </programlisting></informalexample><para>Increases the reference count of <parameter>value</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref-sink</title><informalexample><programlisting>(define-values (%return) (variant:ref-sink self))
  3987. </programlisting></informalexample><para><type>GVariant</type> uses a floating reference count system. All functions with
  3988. names starting with <code>g_variant_new_</code> return floating
  3989. references.
  3990. </para>
  3991. <para>Calling <function>g_variant_ref_sink()</function> on a <type>GVariant</type> with a floating reference
  3992. will convert the floating reference into a full reference. Calling
  3993. <function>g_variant_ref_sink()</function> on a non-floating <type>GVariant</type> results in an
  3994. additional normal reference being added.
  3995. </para>
  3996. <para>In other words, if the <parameter>value</parameter> is floating, then this call &quot;assumes
  3997. ownership&quot; of the floating reference, converting it to a normal
  3998. reference. If the <parameter>value</parameter> is not floating, then this call adds a
  3999. new normal reference increasing the reference count by one.
  4000. </para>
  4001. <para>All calls that result in a <type>GVariant</type> instance being inserted into a
  4002. container will call <function>g_variant_ref_sink()</function> on the instance. This means
  4003. that if the value was just created (and has only its floating
  4004. reference) then the container will assume sole ownership of the value
  4005. at that point and the caller will not need to unreference it. This
  4006. makes certain common styles of programming much easier while still
  4007. maintaining normal refcounting semantics in situations where values
  4008. are not floating.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>store</title><informalexample><programlisting>(define-values () (variant:store self data))
  4009. </programlisting></informalexample><para>Stores the serialised form of <parameter>value</parameter> at <parameter>data</parameter>. <parameter>data</parameter> should be
  4010. large enough. See <function>g_variant_get_size()</function>.
  4011. </para>
  4012. <para>The stored data is in machine native byte order but may not be in
  4013. fully-normalised form if read from an untrusted source. See
  4014. <function>g_variant_get_normal_form()</function> for a solution.
  4015. </para>
  4016. <para>As with <function>g_variant_get_data()</function>, to be able to deserialise the
  4017. serialised variant successfully, its type and (if the destination
  4018. machine might be different) its endianness must also be available.
  4019. </para>
  4020. <para>This function is approximately O(n) in the size of <parameter>data</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>the <type>GVariant</type> to store</para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>the location to store the serialised data at</para><para>Passed as <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>take-ref</title><informalexample><programlisting>(define-values (%return) (variant:take-ref self))
  4021. </programlisting></informalexample><para>If <parameter>value</parameter> is floating, sink it. Otherwise, do nothing.
  4022. </para>
  4023. <para>Typically you want to use <function>g_variant_ref_sink()</function> in order to
  4024. automatically do the correct thing with respect to floating or
  4025. non-floating references, but there is one specific scenario where
  4026. this function is helpful.
  4027. </para>
  4028. <para>The situation where this function is helpful is when creating an API
  4029. that allows the user to provide a callback function that returns a
  4030. <type>GVariant</type>. We certainly want to allow the user the flexibility to
  4031. return a non-floating reference from this callback (for the case
  4032. where the value that is being returned already exists).
  4033. </para>
  4034. <para>At the same time, the style of the <type>GVariant</type> API makes it likely that
  4035. for newly-created <type>GVariant</type> instances, the user can be saved some
  4036. typing if they are allowed to return a <type>GVariant</type> with a floating
  4037. reference.
  4038. </para>
  4039. <para>Using this function on the return value of the user's callback allows
  4040. the user to do whichever is more convenient for them. The caller
  4041. will always receives exactly one full reference to the value: either
  4042. the one that was returned in the first place, or a floating reference
  4043. that has been converted to a full reference.
  4044. </para>
  4045. <para>This function has an odd interaction when combined with
  4046. <function>g_variant_ref_sink()</function> running at the same time in another thread on
  4047. the same <type>GVariant</type> instance. If <function>g_variant_ref_sink()</function> runs first then
  4048. the result will be that the floating reference is converted to a hard
  4049. reference. If <function>g_variant_take_ref()</function> runs first then the result will
  4050. be that the floating reference is converted to a hard reference and
  4051. an additional reference on top of that one is added. It is best to
  4052. avoid this situation.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (variant:unref self))
  4053. </programlisting></informalexample><para>Decreases the reference count of <parameter>value</parameter>. When its reference count
  4054. drops to 0, the memory used by the variant is freed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-variant</title><informalexample><programlisting>(define-values (%return) (variant:new-variant value))
  4055. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-uint64</title><informalexample><programlisting>(define-values (%return) (variant:new-uint64 value))
  4056. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-uint32</title><informalexample><programlisting>(define-values (%return) (variant:new-uint32 value))
  4057. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-uint16</title><informalexample><programlisting>(define-values (%return) (variant:new-uint16 value))
  4058. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-tuple</title><informalexample><programlisting>(define-values (%return) (variant:new-tuple children))
  4059. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>children</para></td><td class="parameter_description"><para></para><para>Passed as <code>children</code></para></td></tr><tr><td class="parameter_name"><para>n_children</para></td><td class="parameter_description"><para></para><para>Inferred from <code>children</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-strv</title><informalexample><programlisting>(define-values (%return) (variant:new-strv strv))
  4060. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>strv</para></td><td class="parameter_description"><para></para><para>Passed as <code>strv</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para></para><para>Inferred from <code>strv</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-string</title><informalexample><programlisting>(define-values (%return) (variant:new-string string))
  4061. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para></para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-signature</title><informalexample><programlisting>(define-values (%return) (variant:new-signature signature))
  4062. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>signature</para></td><td class="parameter_description"><para></para><para>Passed as <code>signature</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-objv</title><informalexample><programlisting>(define-values (%return) (variant:new-objv strv))
  4063. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>strv</para></td><td class="parameter_description"><para></para><para>Passed as <code>strv</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para></para><para>Inferred from <code>strv</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-object-path</title><informalexample><programlisting>(define-values (%return) (variant:new-object-path object-path))
  4064. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>object_path</para></td><td class="parameter_description"><para></para><para>Passed as <code>object-path</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-maybe</title><informalexample><programlisting>(define-values (%return) (variant:new-maybe child-type child))
  4065. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>child_type</para></td><td class="parameter_description"><para></para><para>Passed as <code>child-type</code></para></td></tr><tr><td class="parameter_name"><para>child</para></td><td class="parameter_description"><para></para><para>Passed as <code>child</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-int64</title><informalexample><programlisting>(define-values (%return) (variant:new-int64 value))
  4066. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-int32</title><informalexample><programlisting>(define-values (%return) (variant:new-int32 value))
  4067. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-int16</title><informalexample><programlisting>(define-values (%return) (variant:new-int16 value))
  4068. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-handle</title><informalexample><programlisting>(define-values (%return) (variant:new-handle value))
  4069. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-from-data</title><informalexample><programlisting>(define-values
  4070. (%return)
  4071. (variant:new-from-data type data trusted notify user-data))
  4072. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para></para><para>Passed as <code>type</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para></para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>size</para></td><td class="parameter_description"><para></para><para>Inferred from <code>data</code></para></td></tr><tr><td class="parameter_name"><para>trusted</para></td><td class="parameter_description"><para></para><para>Passed as <code>trusted</code></para></td></tr><tr><td class="parameter_name"><para>notify</para></td><td class="parameter_description"><para></para><para>Passed as <code>notify</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para></para><para>Passed as <code>user-data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-from-bytes</title><informalexample><programlisting>(define-values (%return) (variant:new-from-bytes type bytes trusted))
  4073. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para></para><para>Passed as <code>type</code></para></td></tr><tr><td class="parameter_name"><para>bytes</para></td><td class="parameter_description"><para></para><para>Passed as <code>bytes</code></para></td></tr><tr><td class="parameter_name"><para>trusted</para></td><td class="parameter_description"><para></para><para>Passed as <code>trusted</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-fixed-array</title><informalexample><programlisting>(define-values
  4074. (%return)
  4075. (variant:new-fixed-array element-type elements n-elements element-size))
  4076. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>element_type</para></td><td class="parameter_description"><para></para><para>Passed as <code>element-type</code></para></td></tr><tr><td class="parameter_name"><para>elements</para></td><td class="parameter_description"><para></para><para>Passed as <code>elements</code></para></td></tr><tr><td class="parameter_name"><para>n_elements</para></td><td class="parameter_description"><para></para><para>Passed as <code>n-elements</code></para></td></tr><tr><td class="parameter_name"><para>element_size</para></td><td class="parameter_description"><para></para><para>Passed as <code>element-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-double</title><informalexample><programlisting>(define-values (%return) (variant:new-double value))
  4077. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-dict-entry</title><informalexample><programlisting>(define-values (%return) (variant:new-dict-entry key value))
  4078. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para></para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-bytestring-array</title><informalexample><programlisting>(define-values (%return) (variant:new-bytestring-array strv))
  4079. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>strv</para></td><td class="parameter_description"><para></para><para>Passed as <code>strv</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para></para><para>Inferred from <code>strv</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-bytestring</title><informalexample><programlisting>(define-values (%return) (variant:new-bytestring string))
  4080. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para></para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-byte</title><informalexample><programlisting>(define-values (%return) (variant:new-byte value))
  4081. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-boolean</title><informalexample><programlisting>(define-values (%return) (variant:new-boolean value))
  4082. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:new-array</title><informalexample><programlisting>(define-values (%return) (variant:new-array child-type children))
  4083. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>child_type</para></td><td class="parameter_description"><para></para><para>Passed as <code>child-type</code></para></td></tr><tr><td class="parameter_name"><para>children</para></td><td class="parameter_description"><para></para><para>Passed as <code>children</code></para></td></tr><tr><td class="parameter_name"><para>n_children</para></td><td class="parameter_description"><para></para><para>Inferred from <code>children</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:is-object-path?</title><informalexample><programlisting>(define-values (%return) (variant:is-object-path? string))
  4084. </programlisting></informalexample><para>Determines if a given string is a valid D-Bus object path. You
  4085. should ensure that a string is a valid D-Bus object path before
  4086. passing it to <function>g_variant_new_object_path()</function>.
  4087. </para>
  4088. <para>A valid object path starts with <code>/</code> followed by zero or more
  4089. sequences of characters separated by <code>/</code> characters. Each sequence
  4090. must contain only the characters <code>[A-Z][a-z][0-9]_</code>. No sequence
  4091. (including the one following the final <code>/</code> character) may be empty.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a normal C nul-terminated string</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:is-signature?</title><informalexample><programlisting>(define-values (%return) (variant:is-signature? string))
  4092. </programlisting></informalexample><para>Determines if a given string is a valid D-Bus type signature. You
  4093. should ensure that a string is a valid D-Bus type signature before
  4094. passing it to <function>g_variant_new_signature()</function>.
  4095. </para>
  4096. <para>D-Bus type signatures consist of zero or more definite <type>GVariantType</type>
  4097. strings in sequence.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a normal C nul-terminated string</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:parse</title><informalexample><programlisting>(define-values (%return) (variant:parse type text limit endptr))
  4098. </programlisting></informalexample><para>Parses a <type>GVariant</type> from a text representation.
  4099. </para>
  4100. <para>A single <type>GVariant</type> is parsed from the content of <parameter>text</parameter>.
  4101. </para>
  4102. <para>The format is described [here][gvariant-text].
  4103. </para>
  4104. <para>The memory at <parameter>limit</parameter> will never be accessed and the parser behaves as
  4105. if the character at <parameter>limit</parameter> is the nul terminator. This has the
  4106. effect of bounding <parameter>text</parameter>.
  4107. </para>
  4108. <para>If <parameter>endptr</parameter> is non-<constant>NULL</constant> then <parameter>text</parameter> is permitted to contain data
  4109. following the value that this function parses and <parameter>endptr</parameter> will be
  4110. updated to point to the first character past the end of the text
  4111. parsed by this function. If <parameter>endptr</parameter> is <constant>NULL</constant> and there is extra data
  4112. then an error is returned.
  4113. </para>
  4114. <para>If <parameter>type</parameter> is non-<constant>NULL</constant> then the value will be parsed to have that
  4115. type. This may result in additional parse errors (in the case that
  4116. the parsed value doesn't fit the type) but may also result in fewer
  4117. errors (in the case that the type would have been ambiguous, such as
  4118. with empty arrays).
  4119. </para>
  4120. <para>In the event that the parsing is successful, the resulting <type>GVariant</type>
  4121. is returned. It is never floating, and must be freed with
  4122. <function>g_variant_unref()</function>.
  4123. </para>
  4124. <para>In case of any error, <constant>NULL</constant> will be returned. If <parameter>error</parameter> is non-<constant>NULL</constant>
  4125. then it will be set to reflect the error that occurred.
  4126. </para>
  4127. <para>Officially, the language understood by the parser is &quot;any string
  4128. produced by <function>g_variant_print()</function>&quot;.
  4129. </para>
  4130. <para>There may be implementation specific restrictions on deeply nested values,
  4131. which would result in a <constant>G_VARIANT_PARSE_ERROR_RECURSION</constant> error. <type>GVariant</type> is
  4132. guaranteed to handle nesting up to at least 64 levels.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type>, or <constant>NULL</constant></para><para>Passed as <code>type</code></para></td></tr><tr><td class="parameter_name"><para>text</para></td><td class="parameter_description"><para>a string containing a GVariant in text form</para><para>Passed as <code>text</code></para></td></tr><tr><td class="parameter_name"><para>limit</para></td><td class="parameter_description"><para>a pointer to the end of <parameter>text</parameter>, or <constant>NULL</constant></para><para>Passed as <code>limit</code></para></td></tr><tr><td class="parameter_name"><para>endptr</para></td><td class="parameter_description"><para>a location to store the end pointer, or <constant>NULL</constant></para><para>Passed as <code>endptr</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:parse-error-print-context</title><informalexample><programlisting>(define-values (%return) (variant:parse-error-print-context error source-str))
  4133. </programlisting></informalexample><para>Pretty-prints a message showing the context of a <type>GVariant</type> parse
  4134. error within the string for which parsing was attempted.
  4135. </para>
  4136. <para>The resulting string is suitable for output to the console or other
  4137. monospace media where newlines are treated in the usual way.
  4138. </para>
  4139. <para>The message will typically look something like one of the following:
  4140. </para>
  4141. <para><informalexample><programlisting>
  4142. unterminated string constant:
  4143. (1, 2, 3, 'abc
  4144. ^^^^
  4145. </programlisting></informalexample></para>
  4146. <para>or
  4147. </para>
  4148. <para><informalexample><programlisting>
  4149. unable to find a common type:
  4150. [1, 2, 3, 'str']
  4151. ^ ^^^^^
  4152. </programlisting></informalexample></para>
  4153. <para>The format of the message may change in a future version.
  4154. </para>
  4155. <para><parameter>error</parameter> must have come from a failed attempt to <function>g_variant_parse()</function> and
  4156. <parameter>source_str</parameter> must be exactly the same string that caused the error.
  4157. If <parameter>source_str</parameter> was not nul-terminated when you passed it to
  4158. <function>g_variant_parse()</function> then you must add nul termination before using this
  4159. function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>error</para></td><td class="parameter_description"><para>a <type>GError</type> from the <type>GVariantParseError</type> domain</para><para>Passed as <code>error</code></para></td></tr><tr><td class="parameter_name"><para>source_str</para></td><td class="parameter_description"><para>the string that was given to the parser</para><para>Passed as <code>source-str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant:parse-error-quark</title><informalexample><programlisting>(define-values (%return) (variant:parse-error-quark))
  4160. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>variant:parser-get-error-quark</title><informalexample><programlisting>(define-values (%return) (variant:parser-get-error-quark))
  4161. </programlisting></informalexample><para>Same as <function>g_variant_error_quark()</function>.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GVariantBuilder&gt;</refname></refnamediv><refsect1><title>Description</title><para>A utility type for constructing container-type <type>GVariant</type> instances.
  4162. </para>
  4163. <para>This is an opaque structure and may only be accessed using the
  4164. following functions.
  4165. </para>
  4166. <para><type>GVariantBuilder</type> is not threadsafe in any way. Do not attempt to
  4167. access it from more than one thread.</para></refsect1><refsect1><title>Functions</title><refsect2><title>add-value</title><informalexample><programlisting>(define-values () (variant-builder:add-value self value))
  4168. </programlisting></informalexample><para>Adds <parameter>value</parameter> to <parameter>builder</parameter>.
  4169. </para>
  4170. <para>It is an error to call this function in any way that would create an
  4171. inconsistent value to be constructed. Some examples of this are
  4172. putting different types of items into an array, putting the wrong
  4173. types or number of items in a tuple, putting more than one value into
  4174. a variant, etc.
  4175. </para>
  4176. <para>If <parameter>value</parameter> is a floating reference (see <function>g_variant_ref_sink()</function>),
  4177. the <parameter>builder</parameter> instance takes ownership of <parameter>value</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>builder</para></td><td class="parameter_description"><para>a <type>GVariantBuilder</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>a <type>GVariant</type></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>close</title><informalexample><programlisting>(define-values () (variant-builder:close self))
  4178. </programlisting></informalexample><para>Closes the subcontainer inside the given <parameter>builder</parameter> that was opened by
  4179. the most recent call to <function>g_variant_builder_open()</function>.
  4180. </para>
  4181. <para>It is an error to call this function in any way that would create an
  4182. inconsistent value to be constructed (ie: too few values added to the
  4183. subcontainer).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>builder</para></td><td class="parameter_description"><para>a <type>GVariantBuilder</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>end</title><informalexample><programlisting>(define-values (%return) (variant-builder:end self))
  4184. </programlisting></informalexample><para>Ends the builder process and returns the constructed value.
  4185. </para>
  4186. <para>It is not permissible to use <parameter>builder</parameter> in any way after this call
  4187. except for reference counting operations (in the case of a
  4188. heap-allocated <type>GVariantBuilder</type>) or by reinitialising it with
  4189. <function>g_variant_builder_init()</function> (in the case of stack-allocated). This
  4190. means that for the stack-allocated builders there is no need to
  4191. call <function>g_variant_builder_clear()</function> after the call to
  4192. <function>g_variant_builder_end()</function>.
  4193. </para>
  4194. <para>It is an error to call this function in any way that would create an
  4195. inconsistent value to be constructed (ie: insufficient number of
  4196. items added to a container with a specific number of children
  4197. required). It is also an error to call this function if the builder
  4198. was created with an indefinite array or maybe type and no children
  4199. have been added; in this case it is impossible to infer the type of
  4200. the empty array.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>builder</para></td><td class="parameter_description"><para>a <type>GVariantBuilder</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>open</title><informalexample><programlisting>(define-values () (variant-builder:open self type))
  4201. </programlisting></informalexample><para>Opens a subcontainer inside the given <parameter>builder</parameter>. When done adding
  4202. items to the subcontainer, <function>g_variant_builder_close()</function> must be called. <parameter>type</parameter>
  4203. is the type of the container: so to build a tuple of several values, <parameter>type</parameter>
  4204. must include the tuple itself.
  4205. </para>
  4206. <para>It is an error to call this function in any way that would cause an
  4207. inconsistent value to be constructed (ie: adding too many values or
  4208. a value of an incorrect type).
  4209. </para>
  4210. <para>Example of building a nested variant:
  4211. <informalexample><programlisting>
  4212. GVariantBuilder builder;
  4213. guint32 some_number = get_number ();
  4214. g_autoptr (GHashTable) some_dict = get_dict ();
  4215. GHashTableIter iter;
  4216. const gchar *key;
  4217. const GVariant *value;
  4218. g_autoptr (GVariant) output = NULL;
  4219. g_variant_builder_init (&amp;builder, G_VARIANT_TYPE (&quot;(ua{sv})&quot;));
  4220. g_variant_builder_add (&amp;builder, &quot;u&quot;, some_number);
  4221. g_variant_builder_open (&amp;builder, G_VARIANT_TYPE (&quot;a{sv}&quot;));
  4222. g_hash_table_iter_init (&amp;iter, some_dict);
  4223. while (g_hash_table_iter_next (&amp;iter, (gpointer *) &amp;key, (gpointer *) &amp;value))
  4224. {
  4225. g_variant_builder_open (&amp;builder, G_VARIANT_TYPE (&quot;{sv}&quot;));
  4226. g_variant_builder_add (&amp;builder, &quot;s&quot;, key);
  4227. g_variant_builder_add (&amp;builder, &quot;v&quot;, value);
  4228. g_variant_builder_close (&amp;builder);
  4229. }
  4230. g_variant_builder_close (&amp;builder);
  4231. output = g_variant_builder_end (&amp;builder);
  4232. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>builder</para></td><td class="parameter_description"><para>a <type>GVariantBuilder</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>the <type>GVariantType</type> of the container</para><para>Passed as <code>type</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (variant-builder:ref self))
  4233. </programlisting></informalexample><para>Increases the reference count on <parameter>builder</parameter>.
  4234. </para>
  4235. <para>Don't call this on stack-allocated <type>GVariantBuilder</type> instances or bad
  4236. things will happen.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>builder</para></td><td class="parameter_description"><para>a <type>GVariantBuilder</type> allocated by <function>g_variant_builder_new()</function></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (variant-builder:unref self))
  4237. </programlisting></informalexample><para>Decreases the reference count on <parameter>builder</parameter>.
  4238. </para>
  4239. <para>In the event that there are no more references, releases all memory
  4240. associated with the <type>GVariantBuilder</type>.
  4241. </para>
  4242. <para>Don't call this on stack-allocated <type>GVariantBuilder</type> instances or bad
  4243. things will happen.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>builder</para></td><td class="parameter_description"><para>a <type>GVariantBuilder</type> allocated by <function>g_variant_builder_new()</function></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-builder:new</title><informalexample><programlisting>(define-values (%return) (variant-builder:new type))
  4244. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para></para><para>Passed as <code>type</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibVariantClass&gt;</refname></refnamediv><refsect1><title>Description</title><para>The range of possible top-level types of <type>GVariant</type> instances.</para></refsect1><refsect1><title>Members</title><refsect2><title>boolean</title><remark>alias <code>G_VARIANT_CLASS_BOOLEAN</code></remark><para>The <type>GVariant</type> is a boolean.</para></refsect2><refsect2><title>byte</title><remark>alias <code>G_VARIANT_CLASS_BYTE</code></remark><para>The <type>GVariant</type> is a byte.</para></refsect2><refsect2><title>int16</title><remark>alias <code>G_VARIANT_CLASS_INT16</code></remark><para>The <type>GVariant</type> is a signed 16 bit integer.</para></refsect2><refsect2><title>uint16</title><remark>alias <code>G_VARIANT_CLASS_UINT16</code></remark><para>The <type>GVariant</type> is an unsigned 16 bit integer.</para></refsect2><refsect2><title>int32</title><remark>alias <code>G_VARIANT_CLASS_INT32</code></remark><para>The <type>GVariant</type> is a signed 32 bit integer.</para></refsect2><refsect2><title>uint32</title><remark>alias <code>G_VARIANT_CLASS_UINT32</code></remark><para>The <type>GVariant</type> is an unsigned 32 bit integer.</para></refsect2><refsect2><title>int64</title><remark>alias <code>G_VARIANT_CLASS_INT64</code></remark><para>The <type>GVariant</type> is a signed 64 bit integer.</para></refsect2><refsect2><title>uint64</title><remark>alias <code>G_VARIANT_CLASS_UINT64</code></remark><para>The <type>GVariant</type> is an unsigned 64 bit integer.</para></refsect2><refsect2><title>handle</title><remark>alias <code>G_VARIANT_CLASS_HANDLE</code></remark><para>The <type>GVariant</type> is a file handle index.</para></refsect2><refsect2><title>double</title><remark>alias <code>G_VARIANT_CLASS_DOUBLE</code></remark><para>The <type>GVariant</type> is a double precision floating
  4245. point value.</para></refsect2><refsect2><title>string</title><remark>alias <code>G_VARIANT_CLASS_STRING</code></remark><para>The <type>GVariant</type> is a normal string.</para></refsect2><refsect2><title>object-path</title><remark>alias <code>G_VARIANT_CLASS_OBJECT_PATH</code></remark><para>The <type>GVariant</type> is a D-Bus object path
  4246. string.</para></refsect2><refsect2><title>signature</title><remark>alias <code>G_VARIANT_CLASS_SIGNATURE</code></remark><para>The <type>GVariant</type> is a D-Bus signature string.</para></refsect2><refsect2><title>variant</title><remark>alias <code>G_VARIANT_CLASS_VARIANT</code></remark><para>The <type>GVariant</type> is a variant.</para></refsect2><refsect2><title>maybe</title><remark>alias <code>G_VARIANT_CLASS_MAYBE</code></remark><para>The <type>GVariant</type> is a maybe-typed value.</para></refsect2><refsect2><title>array</title><remark>alias <code>G_VARIANT_CLASS_ARRAY</code></remark><para>The <type>GVariant</type> is an array.</para></refsect2><refsect2><title>tuple</title><remark>alias <code>G_VARIANT_CLASS_TUPLE</code></remark><para>The <type>GVariant</type> is a tuple.</para></refsect2><refsect2><title>dict-entry</title><remark>alias <code>G_VARIANT_CLASS_DICT_ENTRY</code></remark><para>The <type>GVariant</type> is a dictionary entry.</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GVariantDict&gt;</refname></refnamediv><refsect1><title>Description</title><para><type>GVariantDict</type> is a mutable interface to <type>GVariant</type> dictionaries.
  4247. </para>
  4248. <para>It can be used for doing a sequence of dictionary lookups in an
  4249. efficient way on an existing <type>GVariant</type> dictionary or it can be used
  4250. to construct new dictionaries with a hashtable-like interface. It
  4251. can also be used for taking existing dictionaries and modifying them
  4252. in order to create new ones.
  4253. </para>
  4254. <para><type>GVariantDict</type> can only be used with <constant>G_VARIANT_TYPE_VARDICT</constant>
  4255. dictionaries.
  4256. </para>
  4257. <para>It is possible to use <type>GVariantDict</type> allocated on the stack or on the
  4258. heap. When using a stack-allocated <type>GVariantDict</type>, you begin with a
  4259. call to <function>g_variant_dict_init()</function> and free the resources with a call to
  4260. <function>g_variant_dict_clear()</function>.
  4261. </para>
  4262. <para>Heap-allocated <type>GVariantDict</type> follows normal refcounting rules: you
  4263. allocate it with <function>g_variant_dict_new()</function> and use <function>g_variant_dict_ref()</function>
  4264. and <function>g_variant_dict_unref()</function>.
  4265. </para>
  4266. <para><function>g_variant_dict_end()</function> is used to convert the <type>GVariantDict</type> back into a
  4267. dictionary-type <type>GVariant</type>. When used with stack-allocated instances,
  4268. this also implicitly frees all associated memory, but for
  4269. heap-allocated instances, you must still call <function>g_variant_dict_unref()</function>
  4270. afterwards.
  4271. </para>
  4272. <para>You will typically want to use a heap-allocated <type>GVariantDict</type> when
  4273. you expose it as part of an API. For most other uses, the
  4274. stack-allocated form will be more convenient.
  4275. </para>
  4276. <para>Consider the following two examples that do the same thing in each
  4277. style: take an existing dictionary and look up the &quot;count&quot; uint32
  4278. key, adding 1 to it if it is found, or returning an error if the
  4279. key is not found. Each returns the new dictionary as a floating
  4280. <type>GVariant</type>.
  4281. </para>
  4282. <refsect2><title>Using a stack-allocated GVariantDict</title>
  4283. <para><informalexample><programlisting>
  4284. GVariant *
  4285. add_to_count (GVariant *orig,
  4286. GError **error)
  4287. {
  4288. GVariantDict dict;
  4289. guint32 count;
  4290. g_variant_dict_init (&amp;dict, orig);
  4291. if (!g_variant_dict_lookup (&amp;dict, &quot;count&quot;, &quot;u&quot;, &amp;count))
  4292. {
  4293. g_set_error (...);
  4294. g_variant_dict_clear (&amp;dict);
  4295. return NULL;
  4296. }
  4297. g_variant_dict_insert (&amp;dict, &quot;count&quot;, &quot;u&quot;, count + 1);
  4298. return g_variant_dict_end (&amp;dict);
  4299. }
  4300. </programlisting></informalexample></para>
  4301. </refsect2><refsect2><title>Using heap-allocated GVariantDict</title>
  4302. <para><informalexample><programlisting>
  4303. GVariant *
  4304. add_to_count (GVariant *orig,
  4305. GError **error)
  4306. {
  4307. GVariantDict *dict;
  4308. GVariant *result;
  4309. guint32 count;
  4310. dict = g_variant_dict_new (orig);
  4311. if (g_variant_dict_lookup (dict, &quot;count&quot;, &quot;u&quot;, &amp;count))
  4312. {
  4313. g_variant_dict_insert (dict, &quot;count&quot;, &quot;u&quot;, count + 1);
  4314. result = g_variant_dict_end (dict);
  4315. }
  4316. else
  4317. {
  4318. g_set_error (...);
  4319. result = NULL;
  4320. }
  4321. g_variant_dict_unref (dict);
  4322. return result;
  4323. }
  4324. </programlisting></informalexample></para></refsect2></refsect1><refsect1><title>Functions</title><refsect2><title>clear</title><informalexample><programlisting>(define-values () (variant-dict:clear self))
  4325. </programlisting></informalexample><para>Releases all memory associated with a <type>GVariantDict</type> without freeing
  4326. the <type>GVariantDict</type> structure itself.
  4327. </para>
  4328. <para>It typically only makes sense to do this on a stack-allocated
  4329. <type>GVariantDict</type> if you want to abort building the value part-way
  4330. through. This function need not be called if you call
  4331. <function>g_variant_dict_end()</function> and it also doesn't need to be called on dicts
  4332. allocated with g_variant_dict_new (see <function>g_variant_dict_unref()</function> for
  4333. that).
  4334. </para>
  4335. <para>It is valid to call this function on either an initialised
  4336. <type>GVariantDict</type> or one that was previously cleared by an earlier call
  4337. to <function>g_variant_dict_clear()</function> but it is not valid to call this function
  4338. on uninitialised memory.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dict</para></td><td class="parameter_description"><para>a <type>GVariantDict</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>contains?</title><informalexample><programlisting>(define-values (%return) (variant-dict:contains? self key))
  4339. </programlisting></informalexample><para>Checks if <parameter>key</parameter> exists in <parameter>dict</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dict</para></td><td class="parameter_description"><para>a <type>GVariantDict</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to look up in the dictionary</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>end</title><informalexample><programlisting>(define-values (%return) (variant-dict:end self))
  4340. </programlisting></informalexample><para>Returns the current value of <parameter>dict</parameter> as a <type>GVariant</type> of type
  4341. <constant>G_VARIANT_TYPE_VARDICT</constant>, clearing it in the process.
  4342. </para>
  4343. <para>It is not permissible to use <parameter>dict</parameter> in any way after this call except
  4344. for reference counting operations (in the case of a heap-allocated
  4345. <type>GVariantDict</type>) or by reinitialising it with <function>g_variant_dict_init()</function> (in
  4346. the case of stack-allocated).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dict</para></td><td class="parameter_description"><para>a <type>GVariantDict</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>insert-value</title><informalexample><programlisting>(define-values () (variant-dict:insert-value self key value))
  4347. </programlisting></informalexample><para>Inserts (or replaces) a key in a <type>GVariantDict</type>.
  4348. </para>
  4349. <para><parameter>value</parameter> is consumed if it is floating.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dict</para></td><td class="parameter_description"><para>a <type>GVariantDict</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to insert a value for</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>the value to insert</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>lookup-value</title><informalexample><programlisting>(define-values (%return) (variant-dict:lookup-value self key expected-type))
  4350. </programlisting></informalexample><para>Looks up a value in a <type>GVariantDict</type>.
  4351. </para>
  4352. <para>If <parameter>key</parameter> is not found in <parameter>dictionary</parameter>, <constant>NULL</constant> is returned.
  4353. </para>
  4354. <para>The <parameter>expected_type</parameter> string specifies what type of value is expected.
  4355. If the value associated with <parameter>key</parameter> has a different type then <constant>NULL</constant> is
  4356. returned.
  4357. </para>
  4358. <para>If the key is found and the value has the correct type, it is
  4359. returned. If <parameter>expected_type</parameter> was specified then any non-<constant>NULL</constant> return
  4360. value will have this type.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dict</para></td><td class="parameter_description"><para>a <type>GVariantDict</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to look up in the dictionary</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>expected_type</para></td><td class="parameter_description"><para>a <type>GVariantType</type>, or <constant>NULL</constant></para><para>Passed as <code>expected-type</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref</title><informalexample><programlisting>(define-values (%return) (variant-dict:ref self))
  4361. </programlisting></informalexample><para>Increases the reference count on <parameter>dict</parameter>.
  4362. </para>
  4363. <para>Don't call this on stack-allocated <type>GVariantDict</type> instances or bad
  4364. things will happen.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dict</para></td><td class="parameter_description"><para>a heap-allocated <type>GVariantDict</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>remove?</title><informalexample><programlisting>(define-values (%return) (variant-dict:remove? self key))
  4365. </programlisting></informalexample><para>Removes a key and its associated value from a <type>GVariantDict</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dict</para></td><td class="parameter_description"><para>a <type>GVariantDict</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to remove</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unref</title><informalexample><programlisting>(define-values () (variant-dict:unref self))
  4366. </programlisting></informalexample><para>Decreases the reference count on <parameter>dict</parameter>.
  4367. </para>
  4368. <para>In the event that there are no more references, releases all memory
  4369. associated with the <type>GVariantDict</type>.
  4370. </para>
  4371. <para>Don't call this on stack-allocated <type>GVariantDict</type> instances or bad
  4372. things will happen.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dict</para></td><td class="parameter_description"><para>a heap-allocated <type>GVariantDict</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-dict:new</title><informalexample><programlisting>(define-values (%return) (variant-dict:new from-asv))
  4373. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>from_asv</para></td><td class="parameter_description"><para></para><para>Passed as <code>from-asv</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;%GLibVariantParseError&gt;</refname></refnamediv><refsect1><title>Description</title><para>Error codes returned by parsing text-format GVariants.</para></refsect1><refsect1><title>Members</title><refsect2><title>failed</title><remark>alias <code>G_VARIANT_PARSE_ERROR_FAILED</code></remark><para>generic error (unused)</para></refsect2><refsect2><title>basic-type-expected</title><remark>alias <code>G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED</code></remark><para>a non-basic <type>GVariantType</type> was given where a basic type was expected</para></refsect2><refsect2><title>cannot-infer-type</title><remark>alias <code>G_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE</code></remark><para>cannot infer the <type>GVariantType</type></para></refsect2><refsect2><title>definite-type-expected</title><remark>alias <code>G_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED</code></remark><para>an indefinite <type>GVariantType</type> was given where a definite type was expected</para></refsect2><refsect2><title>input-not-at-end</title><remark>alias <code>G_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END</code></remark><para>extra data after parsing finished</para></refsect2><refsect2><title>invalid-character</title><remark>alias <code>G_VARIANT_PARSE_ERROR_INVALID_CHARACTER</code></remark><para>invalid character in number or unicode escape</para></refsect2><refsect2><title>invalid-format-string</title><remark>alias <code>G_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING</code></remark><para>not a valid <type>GVariant</type> format string</para></refsect2><refsect2><title>invalid-object-path</title><remark>alias <code>G_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH</code></remark><para>not a valid object path</para></refsect2><refsect2><title>invalid-signature</title><remark>alias <code>G_VARIANT_PARSE_ERROR_INVALID_SIGNATURE</code></remark><para>not a valid type signature</para></refsect2><refsect2><title>invalid-type-string</title><remark>alias <code>G_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING</code></remark><para>not a valid <type>GVariant</type> type string</para></refsect2><refsect2><title>no-common-type</title><remark>alias <code>G_VARIANT_PARSE_ERROR_NO_COMMON_TYPE</code></remark><para>could not find a common type for array entries</para></refsect2><refsect2><title>number-out-of-range</title><remark>alias <code>G_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE</code></remark><para>the numerical value is out of range of the given type</para></refsect2><refsect2><title>number-too-big</title><remark>alias <code>G_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG</code></remark><para>the numerical value is out of range for any type</para></refsect2><refsect2><title>type-error</title><remark>alias <code>G_VARIANT_PARSE_ERROR_TYPE_ERROR</code></remark><para>cannot parse as variant of the specified type</para></refsect2><refsect2><title>unexpected-token</title><remark>alias <code>G_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN</code></remark><para>an unexpected token was encountered</para></refsect2><refsect2><title>unknown-keyword</title><remark>alias <code>G_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD</code></remark><para>an unknown keyword was encountered</para></refsect2><refsect2><title>unterminated-string-constant</title><remark>alias <code>G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT</code></remark><para>unterminated string constant</para></refsect2><refsect2><title>value-expected</title><remark>alias <code>G_VARIANT_PARSE_ERROR_VALUE_EXPECTED</code></remark><para>no value given</para></refsect2><refsect2><title>recursion</title><remark>alias <code>G_VARIANT_PARSE_ERROR_RECURSION</code></remark><para>variant was too deeply nested; <type>GVariant</type> is only guaranteed to handle nesting up to 64 levels (Since: 2.64)</para></refsect2></refsect1></refentry><refentry><refnamediv><refname>&lt;GVariantType&gt;</refname></refnamediv><refsect1><title>Description</title><para>This section introduces the GVariant type system. It is based, in
  4374. large part, on the D-Bus type system, with two major changes and
  4375. some minor lifting of restrictions. The
  4376. [D-Bus specification](http://dbus.freedesktop.org/doc/dbus-specification.html),
  4377. therefore, provides a significant amount of
  4378. information that is useful when working with GVariant.
  4379. </para>
  4380. <para>The first major change with respect to the D-Bus type system is the
  4381. introduction of maybe (or &quot;nullable&quot;) types. Any type in GVariant can be
  4382. converted to a maybe type, in which case, &quot;nothing&quot; (or &quot;null&quot;) becomes a
  4383. valid value. Maybe types have been added by introducing the
  4384. character &quot;m&quot; to type strings.
  4385. </para>
  4386. <para>The second major change is that the GVariant type system supports the
  4387. concept of &quot;indefinite types&quot; -- types that are less specific than
  4388. the normal types found in D-Bus. For example, it is possible to speak
  4389. of &quot;an array of any type&quot; in GVariant, where the D-Bus type system
  4390. would require you to speak of &quot;an array of integers&quot; or &quot;an array of
  4391. strings&quot;. Indefinite types have been added by introducing the
  4392. characters &quot;*&quot;, &quot;?&quot; and &quot;r&quot; to type strings.
  4393. </para>
  4394. <para>Finally, all arbitrary restrictions relating to the complexity of
  4395. types are lifted along with the restriction that dictionary entries
  4396. may only appear nested inside of arrays.
  4397. </para>
  4398. <para>Just as in D-Bus, GVariant types are described with strings (&quot;type
  4399. strings&quot;). Subject to the differences mentioned above, these strings
  4400. are of the same form as those found in DBus. Note, however: D-Bus
  4401. always works in terms of messages and therefore individual type
  4402. strings appear nowhere in its interface. Instead, &quot;signatures&quot;
  4403. are a concatenation of the strings of the type of each argument in a
  4404. message. GVariant deals with single values directly so GVariant type
  4405. strings always describe the type of exactly one value. This means
  4406. that a D-Bus signature string is generally not a valid GVariant type
  4407. string -- except in the case that it is the signature of a message
  4408. containing exactly one argument.
  4409. </para>
  4410. <para>An indefinite type is similar in spirit to what may be called an
  4411. abstract type in other type systems. No value can exist that has an
  4412. indefinite type as its type, but values can exist that have types
  4413. that are subtypes of indefinite types. That is to say,
  4414. <function>g_variant_get_type()</function> will never return an indefinite type, but
  4415. calling <function>g_variant_is_of_type()</function> with an indefinite type may return
  4416. <constant>TRUE</constant>. For example, you cannot have a value that represents &quot;an
  4417. array of no particular type&quot;, but you can have an &quot;array of integers&quot;
  4418. which certainly matches the type of &quot;an array of no particular type&quot;,
  4419. since &quot;array of integers&quot; is a subtype of &quot;array of no particular
  4420. type&quot;.
  4421. </para>
  4422. <para>This is similar to how instances of abstract classes may not
  4423. directly exist in other type systems, but instances of their
  4424. non-abstract subtypes may. For example, in GTK, no object that has
  4425. the type of <type>GtkBin</type> can exist (since <type>GtkBin</type> is an abstract class),
  4426. but a <type>GtkWindow</type> can certainly be instantiated, and you would say
  4427. that the <type>GtkWindow</type> is a <type>GtkBin</type> (since <type>GtkWindow</type> is a subclass of
  4428. <type>GtkBin</type>).
  4429. </para>
  4430. <refsect2><title>GVariant Type Strings</title>
  4431. <para>A GVariant type string can be any of the following:
  4432. </para>
  4433. <para>- any basic type string (listed below)
  4434. </para>
  4435. <para>- &quot;v&quot;, &quot;r&quot; or &quot;*&quot;
  4436. </para>
  4437. <para>- one of the characters 'a' or 'm', followed by another type string
  4438. </para>
  4439. <para>- the character '(', followed by a concatenation of zero or more other
  4440. type strings, followed by the character ')'
  4441. </para>
  4442. <para>- the character '{', followed by a basic type string (see below),
  4443. followed by another type string, followed by the character '}'
  4444. </para>
  4445. <para>A basic type string describes a basic type (as per
  4446. <function>g_variant_type_is_basic()</function>) and is always a single character in length.
  4447. The valid basic type strings are &quot;b&quot;, &quot;y&quot;, &quot;n&quot;, &quot;q&quot;, &quot;i&quot;, &quot;u&quot;, &quot;x&quot;, &quot;t&quot;,
  4448. &quot;h&quot;, &quot;d&quot;, &quot;s&quot;, &quot;o&quot;, &quot;g&quot; and &quot;?&quot;.
  4449. </para>
  4450. <para>The above definition is recursive to arbitrary depth. &quot;aaaaai&quot; and
  4451. &quot;(ui(nq((y)))s)&quot; are both valid type strings, as is
  4452. &quot;a(aa(ui)(qna{ya(yd)}))&quot;. In order to not hit memory limits, <type>GVariant</type>
  4453. imposes a limit on recursion depth of 65 nested containers. This is the
  4454. limit in the D-Bus specification (64) plus one to allow a <type>GDBusMessage</type> to
  4455. be nested in a top-level tuple.
  4456. </para>
  4457. <para>The meaning of each of the characters is as follows:
  4458. - <code>b</code>: the type string of <constant>G_VARIANT_TYPE_BOOLEAN</constant>; a boolean value.
  4459. - <code>y</code>: the type string of <constant>G_VARIANT_TYPE_BYTE</constant>; a byte.
  4460. - <code>n</code>: the type string of <constant>G_VARIANT_TYPE_INT16</constant>; a signed 16 bit integer.
  4461. - <code>q</code>: the type string of <constant>G_VARIANT_TYPE_UINT16</constant>; an unsigned 16 bit integer.
  4462. - <code>i</code>: the type string of <constant>G_VARIANT_TYPE_INT32</constant>; a signed 32 bit integer.
  4463. - <code>u</code>: the type string of <constant>G_VARIANT_TYPE_UINT32</constant>; an unsigned 32 bit integer.
  4464. - <code>x</code>: the type string of <constant>G_VARIANT_TYPE_INT64</constant>; a signed 64 bit integer.
  4465. - <code>t</code>: the type string of <constant>G_VARIANT_TYPE_UINT64</constant>; an unsigned 64 bit integer.
  4466. - <code>h</code>: the type string of <constant>G_VARIANT_TYPE_HANDLE</constant>; a signed 32 bit value
  4467. that, by convention, is used as an index into an array of file
  4468. descriptors that are sent alongside a D-Bus message.
  4469. - <code>d</code>: the type string of <constant>G_VARIANT_TYPE_DOUBLE</constant>; a double precision
  4470. floating point value.
  4471. - <code>s</code>: the type string of <constant>G_VARIANT_TYPE_STRING</constant>; a string.
  4472. - <code>o</code>: the type string of <constant>G_VARIANT_TYPE_OBJECT_PATH</constant>; a string in the form
  4473. of a D-Bus object path.
  4474. - <code>g</code>: the type string of <constant>G_VARIANT_TYPE_SIGNATURE</constant>; a string in the form of
  4475. a D-Bus type signature.
  4476. - <code>?</code>: the type string of <constant>G_VARIANT_TYPE_BASIC</constant>; an indefinite type that
  4477. is a supertype of any of the basic types.
  4478. - <code>v</code>: the type string of <constant>G_VARIANT_TYPE_VARIANT</constant>; a container type that
  4479. contain any other type of value.
  4480. - <code>a</code>: used as a prefix on another type string to mean an array of that
  4481. type; the type string &quot;ai&quot;, for example, is the type of an array of
  4482. signed 32-bit integers.
  4483. - <code>m</code>: used as a prefix on another type string to mean a &quot;maybe&quot;, or
  4484. &quot;nullable&quot;, version of that type; the type string &quot;ms&quot;, for example,
  4485. is the type of a value that maybe contains a string, or maybe contains
  4486. nothing.
  4487. - <code>()</code>: used to enclose zero or more other concatenated type strings to
  4488. create a tuple type; the type string &quot;(is)&quot;, for example, is the type of
  4489. a pair of an integer and a string.
  4490. - <code>r</code>: the type string of <constant>G_VARIANT_TYPE_TUPLE</constant>; an indefinite type that is
  4491. a supertype of any tuple type, regardless of the number of items.
  4492. - <code>{}</code>: used to enclose a basic type string concatenated with another type
  4493. string to create a dictionary entry type, which usually appears inside of
  4494. an array to form a dictionary; the type string &quot;a{sd}&quot;, for example, is
  4495. the type of a dictionary that maps strings to double precision floating
  4496. point values.
  4497. </para>
  4498. <para>The first type (the basic type) is the key type and the second type is
  4499. the value type. The reason that the first type is restricted to being a
  4500. basic type is so that it can easily be hashed.
  4501. - <code>*</code>: the type string of <constant>G_VARIANT_TYPE_ANY</constant>; the indefinite type that is
  4502. a supertype of all types. Note that, as with all type strings, this
  4503. character represents exactly one type. It cannot be used inside of tuples
  4504. to mean &quot;any number of items&quot;.
  4505. </para>
  4506. <para>Any type string of a container that contains an indefinite type is,
  4507. itself, an indefinite type. For example, the type string &quot;a*&quot;
  4508. (corresponding to <constant>G_VARIANT_TYPE_ARRAY</constant>) is an indefinite type
  4509. that is a supertype of every array type. &quot;(*s)&quot; is a supertype
  4510. of all tuples that contain exactly two items where the second
  4511. item is a string.
  4512. </para>
  4513. <para>&quot;a{?*}&quot; is an indefinite type that is a supertype of all arrays
  4514. containing dictionary entries where the key is any basic type and
  4515. the value is any type at all. This is, by definition, a dictionary,
  4516. so this type string corresponds to <constant>G_VARIANT_TYPE_DICTIONARY</constant>. Note
  4517. that, due to the restriction that the key of a dictionary entry must
  4518. be a basic type, &quot;{**}&quot; is not a valid type string.</para></refsect2></refsect1><refsect1><title>Functions</title><refsect2><title>copy</title><informalexample><programlisting>(define-values (%return) (variant-type:copy self))
  4519. </programlisting></informalexample><para>Makes a copy of a <type>GVariantType</type>. It is appropriate to call
  4520. <function>g_variant_type_free()</function> on the return value. <parameter>type</parameter> may not be <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dup-string</title><informalexample><programlisting>(define-values (%return) (variant-type:dup-string self))
  4521. </programlisting></informalexample><para>Returns a newly-allocated copy of the type string corresponding to
  4522. <parameter>type</parameter>. The returned string is nul-terminated. It is appropriate to
  4523. call <function>g_free()</function> on the return value.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>element</title><informalexample><programlisting>(define-values (%return) (variant-type:element self))
  4524. </programlisting></informalexample><para>Determines the element type of an array or maybe type.
  4525. </para>
  4526. <para>This function may only be used with array or maybe types.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>an array or maybe <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>equal?</title><informalexample><programlisting>(define-values (%return) (variant-type:equal? self type2))
  4527. </programlisting></informalexample><para>Compares <parameter>type1</parameter> and <parameter>type2</parameter> for equality.
  4528. </para>
  4529. <para>Only returns <constant>TRUE</constant> if the types are exactly equal. Even if one type
  4530. is an indefinite type and the other is a subtype of it, <constant>FALSE</constant> will
  4531. be returned if they are not exactly equal. If you want to check for
  4532. subtypes, use <function>g_variant_type_is_subtype_of()</function>.
  4533. </para>
  4534. <para>The argument types of <parameter>type1</parameter> and <parameter>type2</parameter> are only <type>gconstpointer</type> to
  4535. allow use with <type>GHashTable</type> without function pointer casting. For
  4536. both arguments, a valid <type>GVariantType</type> must be provided.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type1</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>type2</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>type2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>first</title><informalexample><programlisting>(define-values (%return) (variant-type:first self))
  4537. </programlisting></informalexample><para>Determines the first item type of a tuple or dictionary entry
  4538. type.
  4539. </para>
  4540. <para>This function may only be used with tuple or dictionary entry types,
  4541. but must not be used with the generic tuple type
  4542. <constant>G_VARIANT_TYPE_TUPLE</constant>.
  4543. </para>
  4544. <para>In the case of a dictionary entry type, this returns the type of
  4545. the key.
  4546. </para>
  4547. <para><constant>NULL</constant> is returned in case of <parameter>type</parameter> being <constant>G_VARIANT_TYPE_UNIT</constant>.
  4548. </para>
  4549. <para>This call, together with <function>g_variant_type_next()</function> provides an iterator
  4550. interface over tuple and dictionary entry types.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a tuple or dictionary entry <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>free</title><informalexample><programlisting>(define-values () (variant-type:free self))
  4551. </programlisting></informalexample><para>Frees a <type>GVariantType</type> that was allocated with
  4552. <function>g_variant_type_copy()</function>, <function>g_variant_type_new()</function> or one of the container
  4553. type constructor functions.
  4554. </para>
  4555. <para>In the case that <parameter>type</parameter> is <constant>NULL</constant>, this function does nothing.
  4556. </para>
  4557. <para>Since 2.24</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type>, or <constant>NULL</constant></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-string-length</title><informalexample><programlisting>(define-values (%return) (variant-type:get-string-length self))
  4558. </programlisting></informalexample><para>Returns the length of the type string corresponding to the given
  4559. <parameter>type</parameter>. This function must be used to determine the valid extent of
  4560. the memory region returned by <function>g_variant_type_peek_string()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash</title><informalexample><programlisting>(define-values (%return) (variant-type:hash self))
  4561. </programlisting></informalexample><para>Hashes <parameter>type</parameter>.
  4562. </para>
  4563. <para>The argument type of <parameter>type</parameter> is only <type>gconstpointer</type> to allow use with
  4564. <type>GHashTable</type> without function pointer casting. A valid
  4565. <type>GVariantType</type> must be provided.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-array?</title><informalexample><programlisting>(define-values (%return) (variant-type:is-array? self))
  4566. </programlisting></informalexample><para>Determines if the given <parameter>type</parameter> is an array type. This is true if the
  4567. type string for <parameter>type</parameter> starts with an 'a'.
  4568. </para>
  4569. <para>This function returns <constant>TRUE</constant> for any indefinite type for which every
  4570. definite subtype is an array type -- <constant>G_VARIANT_TYPE_ARRAY</constant>, for
  4571. example.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-basic?</title><informalexample><programlisting>(define-values (%return) (variant-type:is-basic? self))
  4572. </programlisting></informalexample><para>Determines if the given <parameter>type</parameter> is a basic type.
  4573. </para>
  4574. <para>Basic types are booleans, bytes, integers, doubles, strings, object
  4575. paths and signatures.
  4576. </para>
  4577. <para>Only a basic type may be used as the key of a dictionary entry.
  4578. </para>
  4579. <para>This function returns <constant>FALSE</constant> for all indefinite types except
  4580. <constant>G_VARIANT_TYPE_BASIC</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-container?</title><informalexample><programlisting>(define-values (%return) (variant-type:is-container? self))
  4581. </programlisting></informalexample><para>Determines if the given <parameter>type</parameter> is a container type.
  4582. </para>
  4583. <para>Container types are any array, maybe, tuple, or dictionary
  4584. entry types plus the variant type.
  4585. </para>
  4586. <para>This function returns <constant>TRUE</constant> for any indefinite type for which every
  4587. definite subtype is a container -- <constant>G_VARIANT_TYPE_ARRAY</constant>, for
  4588. example.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-definite?</title><informalexample><programlisting>(define-values (%return) (variant-type:is-definite? self))
  4589. </programlisting></informalexample><para>Determines if the given <parameter>type</parameter> is definite (ie: not indefinite).
  4590. </para>
  4591. <para>A type is definite if its type string does not contain any indefinite
  4592. type characters ('*', '?', or 'r').
  4593. </para>
  4594. <para>A <type>GVariant</type> instance may not have an indefinite type, so calling
  4595. this function on the result of <function>g_variant_get_type()</function> will always
  4596. result in <constant>TRUE</constant> being returned. Calling this function on an
  4597. indefinite type like <constant>G_VARIANT_TYPE_ARRAY</constant>, however, will result in
  4598. <constant>FALSE</constant> being returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-dict-entry?</title><informalexample><programlisting>(define-values (%return) (variant-type:is-dict-entry? self))
  4599. </programlisting></informalexample><para>Determines if the given <parameter>type</parameter> is a dictionary entry type. This is
  4600. true if the type string for <parameter>type</parameter> starts with a '{'.
  4601. </para>
  4602. <para>This function returns <constant>TRUE</constant> for any indefinite type for which every
  4603. definite subtype is a dictionary entry type --
  4604. <constant>G_VARIANT_TYPE_DICT_ENTRY</constant>, for example.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-maybe?</title><informalexample><programlisting>(define-values (%return) (variant-type:is-maybe? self))
  4605. </programlisting></informalexample><para>Determines if the given <parameter>type</parameter> is a maybe type. This is true if the
  4606. type string for <parameter>type</parameter> starts with an 'm'.
  4607. </para>
  4608. <para>This function returns <constant>TRUE</constant> for any indefinite type for which every
  4609. definite subtype is a maybe type -- <constant>G_VARIANT_TYPE_MAYBE</constant>, for
  4610. example.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-subtype-of?</title><informalexample><programlisting>(define-values (%return) (variant-type:is-subtype-of? self supertype))
  4611. </programlisting></informalexample><para>Checks if <parameter>type</parameter> is a subtype of <parameter>supertype</parameter>.
  4612. </para>
  4613. <para>This function returns <constant>TRUE</constant> if <parameter>type</parameter> is a subtype of <parameter>supertype</parameter>. All
  4614. types are considered to be subtypes of themselves. Aside from that,
  4615. only indefinite types can have subtypes.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr><tr><td class="parameter_name"><para>supertype</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>supertype</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-tuple?</title><informalexample><programlisting>(define-values (%return) (variant-type:is-tuple? self))
  4616. </programlisting></informalexample><para>Determines if the given <parameter>type</parameter> is a tuple type. This is true if the
  4617. type string for <parameter>type</parameter> starts with a '(' or if <parameter>type</parameter> is
  4618. <constant>G_VARIANT_TYPE_TUPLE</constant>.
  4619. </para>
  4620. <para>This function returns <constant>TRUE</constant> for any indefinite type for which every
  4621. definite subtype is a tuple type -- <constant>G_VARIANT_TYPE_TUPLE</constant>, for
  4622. example.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>is-variant?</title><informalexample><programlisting>(define-values (%return) (variant-type:is-variant? self))
  4623. </programlisting></informalexample><para>Determines if the given <parameter>type</parameter> is the variant type.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>key</title><informalexample><programlisting>(define-values (%return) (variant-type:key self))
  4624. </programlisting></informalexample><para>Determines the key type of a dictionary entry type.
  4625. </para>
  4626. <para>This function may only be used with a dictionary entry type. Other
  4627. than the additional restriction, this call is equivalent to
  4628. <function>g_variant_type_first()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a dictionary entry <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>n-items</title><informalexample><programlisting>(define-values (%return) (variant-type:n-items self))
  4629. </programlisting></informalexample><para>Determines the number of items contained in a tuple or
  4630. dictionary entry type.
  4631. </para>
  4632. <para>This function may only be used with tuple or dictionary entry types,
  4633. but must not be used with the generic tuple type
  4634. <constant>G_VARIANT_TYPE_TUPLE</constant>.
  4635. </para>
  4636. <para>In the case of a dictionary entry type, this function will always
  4637. return 2.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a tuple or dictionary entry <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>next</title><informalexample><programlisting>(define-values (%return) (variant-type:next self))
  4638. </programlisting></informalexample><para>Determines the next item type of a tuple or dictionary entry
  4639. type.
  4640. </para>
  4641. <para><parameter>type</parameter> must be the result of a previous call to
  4642. <function>g_variant_type_first()</function> or <function>g_variant_type_next()</function>.
  4643. </para>
  4644. <para>If called on the key type of a dictionary entry then this call
  4645. returns the value type. If called on the value type of a dictionary
  4646. entry then this call returns <constant>NULL</constant>.
  4647. </para>
  4648. <para>For tuples, <constant>NULL</constant> is returned when <parameter>type</parameter> is the last item in a tuple.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type> from a previous call</para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>value</title><informalexample><programlisting>(define-values (%return) (variant-type:value self))
  4649. </programlisting></informalexample><para>Determines the value type of a dictionary entry type.
  4650. </para>
  4651. <para>This function may only be used with a dictionary entry type.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a dictionary entry <type>GVariantType</type></para><para>Passed as <code>self</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type:new-tuple</title><informalexample><programlisting>(define-values (%return) (variant-type:new-tuple items))
  4652. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>items</para></td><td class="parameter_description"><para></para><para>Passed as <code>items</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para></para><para>Inferred from <code>items</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type:new-maybe</title><informalexample><programlisting>(define-values (%return) (variant-type:new-maybe element))
  4653. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>element</para></td><td class="parameter_description"><para></para><para>Passed as <code>element</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type:new-dict-entry</title><informalexample><programlisting>(define-values (%return) (variant-type:new-dict-entry key value))
  4654. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para></para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type:new-array</title><informalexample><programlisting>(define-values (%return) (variant-type:new-array element))
  4655. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>element</para></td><td class="parameter_description"><para></para><para>Passed as <code>element</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type:new</title><informalexample><programlisting>(define-values (%return) (variant-type:new type-string))
  4656. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type_string</para></td><td class="parameter_description"><para></para><para>Passed as <code>type-string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type:checked-</title><informalexample><programlisting>(define-values (%return) (variant-type:checked- arg0))
  4657. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>arg0</para></td><td class="parameter_description"><para></para><para>Passed as <code>arg0</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type:string-get-depth-</title><informalexample><programlisting>(define-values (%return) (variant-type:string-get-depth- type-string))
  4658. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type_string</para></td><td class="parameter_description"><para></para><para>Passed as <code>type-string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type:string-is-valid?</title><informalexample><programlisting>(define-values (%return) (variant-type:string-is-valid? type-string))
  4659. </programlisting></informalexample><para>Checks if <parameter>type_string</parameter> is a valid GVariant type string. This call is
  4660. equivalent to calling <function>g_variant_type_string_scan()</function> and confirming
  4661. that the following character is a nul terminator.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type_string</para></td><td class="parameter_description"><para>a pointer to any string</para><para>Passed as <code>type-string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type:string-scan</title><informalexample><programlisting>(define-values (%return endptr) (variant-type:string-scan string limit))
  4662. </programlisting></informalexample><para>Scan for a single complete and valid GVariant type string in <parameter>string</parameter>.
  4663. The memory pointed to by <parameter>limit</parameter> (or bytes beyond it) is never
  4664. accessed.
  4665. </para>
  4666. <para>If a valid type string is found, <parameter>endptr</parameter> is updated to point to the
  4667. first character past the end of the string that was found and <constant>TRUE</constant>
  4668. is returned.
  4669. </para>
  4670. <para>If there is no valid type string starting at <parameter>string</parameter>, or if the type
  4671. string does not end before <parameter>limit</parameter> then <constant>FALSE</constant> is returned.
  4672. </para>
  4673. <para>For the simple case of checking if a string is a valid type string,
  4674. see <function>g_variant_type_string_is_valid()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a pointer to any string</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>limit</para></td><td class="parameter_description"><para>the end of <parameter>string</parameter>, or <constant>NULL</constant></para><para>Passed as <code>limit</code></para></td></tr><tr><td class="parameter_name"><para>endptr</para></td><td class="parameter_description"><para>location to store the end pointer, or <constant>NULL</constant></para><para>Passed as <code>endptr</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry><refentry><refnamediv><refname>Functions</refname></refnamediv><refsect1><title>Functions</title><refsect2><title>byte-array:free</title><informalexample><programlisting>(define-values (%return) (byte-array:free array free-segment))
  4675. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>free_segment</para></td><td class="parameter_description"><para></para><para>Passed as <code>free-segment</code></para></td></tr><tr><td class="parameter_name"><para>array</para></td><td class="parameter_description"><para></para><para>Passed as <code>array</code></para></td></tr><tr><td class="parameter_name"><para>mem</para></td><td class="parameter_description"><para></para><para>Passed as <code>mem</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>access</title><informalexample><programlisting>(define-values (%return) (access filename mode))
  4676. </programlisting></informalexample><para>A wrapper for the POSIX <function>access()</function> function. This function is used to
  4677. test a pathname for one or several of read, write or execute
  4678. permissions, or just existence.
  4679. </para>
  4680. <para>On Windows, the file protection mechanism is not at all POSIX-like,
  4681. and the underlying function in the C library only checks the
  4682. FAT-style READONLY attribute, and does not look at the ACL of a
  4683. file at all. This function is this in practise almost useless on
  4684. Windows. Software that needs to handle file permissions on Windows
  4685. more exactly should use the Win32 API.
  4686. </para>
  4687. <para>See your C library manual for more details about <function>access()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>a pathname in the GLib file name encoding
  4688. (UTF-8 on Windows)</para><para>Passed as <code>filename</code></para></td></tr><tr><td class="parameter_name"><para>mode</para></td><td class="parameter_description"><para>as in <function>access()</function></para><para>Passed as <code>mode</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-digit-value</title><informalexample><programlisting>(define-values (%return) (ascii-digit-value c))
  4689. </programlisting></informalexample><para>Determines the numeric value of a character as a decimal digit.
  4690. Differs from <function>g_unichar_digit_value()</function> because it takes a char, so
  4691. there's no worry about sign extension if characters are signed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>an ASCII character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-dtostr</title><informalexample><programlisting>(define-values (%return) (ascii-dtostr buffer buf-len d))
  4692. </programlisting></informalexample><para>Converts a <type>gdouble</type> to a string, using the '.' as
  4693. decimal point.
  4694. </para>
  4695. <para>This function generates enough precision that converting
  4696. the string back using <function>g_ascii_strtod()</function> gives the same machine-number
  4697. (on machines with IEEE compatible 64bit doubles). It is
  4698. guaranteed that the size of the resulting string will never
  4699. be larger than <parameter>G_ASCII_DTOSTR_BUF_SIZE</parameter> bytes, including the terminating
  4700. nul character, which is always added.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>buffer</para></td><td class="parameter_description"><para>A buffer to place the resulting string in</para><para>Passed as <code>buffer</code></para></td></tr><tr><td class="parameter_name"><para>buf_len</para></td><td class="parameter_description"><para>The length of the buffer.</para><para>Passed as <code>buf-len</code></para></td></tr><tr><td class="parameter_name"><para>d</para></td><td class="parameter_description"><para>The <type>gdouble</type> to convert</para><para>Passed as <code>d</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-formatd</title><informalexample><programlisting>(define-values (%return) (ascii-formatd buffer buf-len format d))
  4701. </programlisting></informalexample><para>Converts a <type>gdouble</type> to a string, using the '.' as
  4702. decimal point. To format the number you pass in
  4703. a <function>printf()</function>-style format string. Allowed conversion
  4704. specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
  4705. </para>
  4706. <para>The returned buffer is guaranteed to be nul-terminated.
  4707. </para>
  4708. <para>If you just want to want to serialize the value into a
  4709. string, use <function>g_ascii_dtostr()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>buffer</para></td><td class="parameter_description"><para>A buffer to place the resulting string in</para><para>Passed as <code>buffer</code></para></td></tr><tr><td class="parameter_name"><para>buf_len</para></td><td class="parameter_description"><para>The length of the buffer.</para><para>Passed as <code>buf-len</code></para></td></tr><tr><td class="parameter_name"><para>format</para></td><td class="parameter_description"><para>The <function>printf()</function>-style format to use for the
  4710. code to use for converting.</para><para>Passed as <code>format</code></para></td></tr><tr><td class="parameter_name"><para>d</para></td><td class="parameter_description"><para>The <type>gdouble</type> to convert</para><para>Passed as <code>d</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-strcasecmp</title><informalexample><programlisting>(define-values (%return) (ascii-strcasecmp s1 s2))
  4711. </programlisting></informalexample><para>Compare two strings, ignoring the case of ASCII characters.
  4712. </para>
  4713. <para>Unlike the BSD <function>strcasecmp()</function> function, this only recognizes standard
  4714. ASCII letters and ignores the locale, treating all non-ASCII
  4715. bytes as if they are not letters.
  4716. </para>
  4717. <para>This function should be used only on strings that are known to be
  4718. in encodings where the bytes corresponding to ASCII letters always
  4719. represent themselves. This includes UTF-8 and the ISO-8859-*
  4720. charsets, but not for instance double-byte encodings like the
  4721. Windows Codepage 932, where the trailing bytes of double-byte
  4722. characters include all ASCII letters. If you compare two CP932
  4723. strings using this function, you will get false matches.
  4724. </para>
  4725. <para>Both <parameter>s1</parameter> and <parameter>s2</parameter> must be non-<constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>s1</para></td><td class="parameter_description"><para>string to compare with <parameter>s2</parameter></para><para>Passed as <code>s1</code></para></td></tr><tr><td class="parameter_name"><para>s2</para></td><td class="parameter_description"><para>string to compare with <parameter>s1</parameter></para><para>Passed as <code>s2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-strdown</title><informalexample><programlisting>(define-values (%return) (ascii-strdown str len))
  4726. </programlisting></informalexample><para>Converts all upper case ASCII letters to lower case ASCII letters.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>str</parameter> in bytes, or -1 if <parameter>str</parameter> is nul-terminated</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-string-to-signed</title><informalexample><programlisting>(define-values (%return out-num) (ascii-string-to-signed str base min max))
  4727. </programlisting></informalexample><para>A convenience function for converting a string to a signed number.
  4728. </para>
  4729. <para>This function assumes that <parameter>str</parameter> contains only a number of the given
  4730. <parameter>base</parameter> that is within inclusive bounds limited by <parameter>min</parameter> and <parameter>max</parameter>. If
  4731. this is true, then the converted number is stored in <parameter>out_num</parameter>. An
  4732. empty string is not a valid input. A string with leading or
  4733. trailing whitespace is also an invalid input.
  4734. </para>
  4735. <para><parameter>base</parameter> can be between 2 and 36 inclusive. Hexadecimal numbers must
  4736. not be prefixed with &quot;0x&quot; or &quot;0X&quot;. Such a problem does not exist
  4737. for octal numbers, since they were usually prefixed with a zero
  4738. which does not change the value of the parsed number.
  4739. </para>
  4740. <para>Parsing failures result in an error with the <constant>G_NUMBER_PARSER_ERROR</constant>
  4741. domain. If the input is invalid, the error code will be
  4742. <constant>G_NUMBER_PARSER_ERROR_INVALID</constant>. If the parsed number is out of
  4743. bounds - <constant>G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS</constant>.
  4744. </para>
  4745. <para>See <function>g_ascii_strtoll()</function> if you have more complex needs such as
  4746. parsing a string which starts with a number, but then has other
  4747. characters.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>base</para></td><td class="parameter_description"><para>base of a parsed number</para><para>Passed as <code>base</code></para></td></tr><tr><td class="parameter_name"><para>min</para></td><td class="parameter_description"><para>a lower bound (inclusive)</para><para>Passed as <code>min</code></para></td></tr><tr><td class="parameter_name"><para>max</para></td><td class="parameter_description"><para>an upper bound (inclusive)</para><para>Passed as <code>max</code></para></td></tr><tr><td class="parameter_name"><para>out_num</para></td><td class="parameter_description"><para>a return location for a number</para><para>Passed as <code>out-num</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-string-to-unsigned</title><informalexample><programlisting>(define-values (%return out-num) (ascii-string-to-unsigned str base min max))
  4748. </programlisting></informalexample><para>A convenience function for converting a string to an unsigned number.
  4749. </para>
  4750. <para>This function assumes that <parameter>str</parameter> contains only a number of the given
  4751. <parameter>base</parameter> that is within inclusive bounds limited by <parameter>min</parameter> and <parameter>max</parameter>. If
  4752. this is true, then the converted number is stored in <parameter>out_num</parameter>. An
  4753. empty string is not a valid input. A string with leading or
  4754. trailing whitespace is also an invalid input. A string with a leading sign
  4755. (<code>-</code> or <code>+</code>) is not a valid input for the unsigned parser.
  4756. </para>
  4757. <para><parameter>base</parameter> can be between 2 and 36 inclusive. Hexadecimal numbers must
  4758. not be prefixed with &quot;0x&quot; or &quot;0X&quot;. Such a problem does not exist
  4759. for octal numbers, since they were usually prefixed with a zero
  4760. which does not change the value of the parsed number.
  4761. </para>
  4762. <para>Parsing failures result in an error with the <constant>G_NUMBER_PARSER_ERROR</constant>
  4763. domain. If the input is invalid, the error code will be
  4764. <constant>G_NUMBER_PARSER_ERROR_INVALID</constant>. If the parsed number is out of
  4765. bounds - <constant>G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS</constant>.
  4766. </para>
  4767. <para>See <function>g_ascii_strtoull()</function> if you have more complex needs such as
  4768. parsing a string which starts with a number, but then has other
  4769. characters.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>base</para></td><td class="parameter_description"><para>base of a parsed number</para><para>Passed as <code>base</code></para></td></tr><tr><td class="parameter_name"><para>min</para></td><td class="parameter_description"><para>a lower bound (inclusive)</para><para>Passed as <code>min</code></para></td></tr><tr><td class="parameter_name"><para>max</para></td><td class="parameter_description"><para>an upper bound (inclusive)</para><para>Passed as <code>max</code></para></td></tr><tr><td class="parameter_name"><para>out_num</para></td><td class="parameter_description"><para>a return location for a number</para><para>Passed as <code>out-num</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-strncasecmp</title><informalexample><programlisting>(define-values (%return) (ascii-strncasecmp s1 s2 n))
  4770. </programlisting></informalexample><para>Compare <parameter>s1</parameter> and <parameter>s2</parameter>, ignoring the case of ASCII characters and any
  4771. characters after the first <parameter>n</parameter> in each string.
  4772. </para>
  4773. <para>Unlike the BSD <function>strcasecmp()</function> function, this only recognizes standard
  4774. ASCII letters and ignores the locale, treating all non-ASCII
  4775. characters as if they are not letters.
  4776. </para>
  4777. <para>The same warning as in <function>g_ascii_strcasecmp()</function> applies: Use this
  4778. function only on strings known to be in encodings where bytes
  4779. corresponding to ASCII letters always represent themselves.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>s1</para></td><td class="parameter_description"><para>string to compare with <parameter>s2</parameter></para><para>Passed as <code>s1</code></para></td></tr><tr><td class="parameter_name"><para>s2</para></td><td class="parameter_description"><para>string to compare with <parameter>s1</parameter></para><para>Passed as <code>s2</code></para></td></tr><tr><td class="parameter_name"><para>n</para></td><td class="parameter_description"><para>number of characters to compare</para><para>Passed as <code>n</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-strtod</title><informalexample><programlisting>(define-values (%return endptr) (ascii-strtod nptr))
  4780. </programlisting></informalexample><para>Converts a string to a <type>gdouble</type> value.
  4781. </para>
  4782. <para>This function behaves like the standard <function>strtod()</function> function
  4783. does in the C locale. It does this without actually changing
  4784. the current locale, since that would not be thread-safe.
  4785. A limitation of the implementation is that this function
  4786. will still accept localized versions of infinities and NANs.
  4787. </para>
  4788. <para>This function is typically used when reading configuration
  4789. files or other non-user input that should be locale independent.
  4790. To handle input from the user you should normally use the
  4791. locale-sensitive system <function>strtod()</function> function.
  4792. </para>
  4793. <para>To convert from a <type>gdouble</type> to a string in a locale-insensitive
  4794. way, use <function>g_ascii_dtostr()</function>.
  4795. </para>
  4796. <para>If the correct value would cause overflow, plus or minus <constant>HUGE_VAL</constant>
  4797. is returned (according to the sign of the value), and <constant>ERANGE</constant> is
  4798. stored in <constant>errno</constant>. If the correct value would cause underflow,
  4799. zero is returned and <constant>ERANGE</constant> is stored in <constant>errno</constant>.
  4800. </para>
  4801. <para>This function resets <constant>errno</constant> before calling <function>strtod()</function> so that
  4802. you can reliably detect overflow and underflow.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>nptr</para></td><td class="parameter_description"><para>the string to convert to a numeric value.</para><para>Passed as <code>nptr</code></para></td></tr><tr><td class="parameter_name"><para>endptr</para></td><td class="parameter_description"><para>if non-<constant>NULL</constant>, it returns the
  4803. character after the last character used in the conversion.</para><para>Passed as <code>endptr</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-strtoll</title><informalexample><programlisting>(define-values (%return endptr) (ascii-strtoll nptr base))
  4804. </programlisting></informalexample><para>Converts a string to a <type>gint64</type> value.
  4805. This function behaves like the standard <function>strtoll()</function> function
  4806. does in the C locale. It does this without actually
  4807. changing the current locale, since that would not be
  4808. thread-safe.
  4809. </para>
  4810. <para>This function is typically used when reading configuration
  4811. files or other non-user input that should be locale independent.
  4812. To handle input from the user you should normally use the
  4813. locale-sensitive system <function>strtoll()</function> function.
  4814. </para>
  4815. <para>If the correct value would cause overflow, <constant>G_MAXINT64</constant> or <constant>G_MININT64</constant>
  4816. is returned, and <code>ERANGE</code> is stored in <code>errno</code>.
  4817. If the base is outside the valid range, zero is returned, and
  4818. <code>EINVAL</code> is stored in <code>errno</code>. If the
  4819. string conversion fails, zero is returned, and <parameter>endptr</parameter> returns <parameter>nptr</parameter>
  4820. (if <parameter>endptr</parameter> is non-<constant>NULL</constant>).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>nptr</para></td><td class="parameter_description"><para>the string to convert to a numeric value.</para><para>Passed as <code>nptr</code></para></td></tr><tr><td class="parameter_name"><para>endptr</para></td><td class="parameter_description"><para>if non-<constant>NULL</constant>, it returns the
  4821. character after the last character used in the conversion.</para><para>Passed as <code>endptr</code></para></td></tr><tr><td class="parameter_name"><para>base</para></td><td class="parameter_description"><para>to be used for the conversion, 2..36 or 0</para><para>Passed as <code>base</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-strtoull</title><informalexample><programlisting>(define-values (%return endptr) (ascii-strtoull nptr base))
  4822. </programlisting></informalexample><para>Converts a string to a <type>guint64</type> value.
  4823. This function behaves like the standard <function>strtoull()</function> function
  4824. does in the C locale. It does this without actually
  4825. changing the current locale, since that would not be
  4826. thread-safe.
  4827. </para>
  4828. <para>Note that input with a leading minus sign (<code>-</code>) is accepted, and will return
  4829. the negation of the parsed number, unless that would overflow a <type>guint64</type>.
  4830. Critically, this means you cannot assume that a short fixed length input will
  4831. never result in a low return value, as the input could have a leading <code>-</code>.
  4832. </para>
  4833. <para>This function is typically used when reading configuration
  4834. files or other non-user input that should be locale independent.
  4835. To handle input from the user you should normally use the
  4836. locale-sensitive system <function>strtoull()</function> function.
  4837. </para>
  4838. <para>If the correct value would cause overflow, <constant>G_MAXUINT64</constant>
  4839. is returned, and <code>ERANGE</code> is stored in <code>errno</code>.
  4840. If the base is outside the valid range, zero is returned, and
  4841. <code>EINVAL</code> is stored in <code>errno</code>.
  4842. If the string conversion fails, zero is returned, and <parameter>endptr</parameter> returns
  4843. <parameter>nptr</parameter> (if <parameter>endptr</parameter> is non-<constant>NULL</constant>).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>nptr</para></td><td class="parameter_description"><para>the string to convert to a numeric value.</para><para>Passed as <code>nptr</code></para></td></tr><tr><td class="parameter_name"><para>endptr</para></td><td class="parameter_description"><para>if non-<constant>NULL</constant>, it returns the
  4844. character after the last character used in the conversion.</para><para>Passed as <code>endptr</code></para></td></tr><tr><td class="parameter_name"><para>base</para></td><td class="parameter_description"><para>to be used for the conversion, 2..36 or 0</para><para>Passed as <code>base</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-strup</title><informalexample><programlisting>(define-values (%return) (ascii-strup str len))
  4845. </programlisting></informalexample><para>Converts all lower case ASCII letters to upper case ASCII letters.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>str</parameter> in bytes, or -1 if <parameter>str</parameter> is nul-terminated</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-tolower</title><informalexample><programlisting>(define-values (%return) (ascii-tolower c))
  4846. </programlisting></informalexample><para>Convert a character to ASCII lower case.
  4847. </para>
  4848. <para>Unlike the standard C library <function>tolower()</function> function, this only
  4849. recognizes standard ASCII letters and ignores the locale, returning
  4850. all non-ASCII characters unchanged, even if they are lower case
  4851. letters in a particular character set. Also unlike the standard
  4852. library function, this takes and returns a char, not an int, so
  4853. don't call it on <constant>EOF</constant> but no need to worry about casting to <type>guchar</type>
  4854. before passing a possibly non-ASCII character in.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>any character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-toupper</title><informalexample><programlisting>(define-values (%return) (ascii-toupper c))
  4855. </programlisting></informalexample><para>Convert a character to ASCII upper case.
  4856. </para>
  4857. <para>Unlike the standard C library <function>toupper()</function> function, this only
  4858. recognizes standard ASCII letters and ignores the locale, returning
  4859. all non-ASCII characters unchanged, even if they are upper case
  4860. letters in a particular character set. Also unlike the standard
  4861. library function, this takes and returns a char, not an int, so
  4862. don't call it on <constant>EOF</constant> but no need to worry about casting to <type>guchar</type>
  4863. before passing a possibly non-ASCII character in.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>any character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ascii-xdigit-value</title><informalexample><programlisting>(define-values (%return) (ascii-xdigit-value c))
  4864. </programlisting></informalexample><para>Determines the numeric value of a character as a hexadecimal
  4865. digit. Differs from <function>g_unichar_xdigit_value()</function> because it takes
  4866. a char, so there's no worry about sign extension if characters
  4867. are signed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>an ASCII character.</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>assert-warning</title><informalexample><programlisting>(define-values
  4868. ()
  4869. (assert-warning log-domain file line pretty-function expression))
  4870. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>log_domain</para></td><td class="parameter_description"><para></para><para>Passed as <code>log-domain</code></para></td></tr><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para></para><para>Passed as <code>file</code></para></td></tr><tr><td class="parameter_name"><para>line</para></td><td class="parameter_description"><para></para><para>Passed as <code>line</code></para></td></tr><tr><td class="parameter_name"><para>pretty_function</para></td><td class="parameter_description"><para></para><para>Passed as <code>pretty-function</code></para></td></tr><tr><td class="parameter_name"><para>expression</para></td><td class="parameter_description"><para></para><para>Passed as <code>expression</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>assertion-message</title><informalexample><programlisting>(define-values () (assertion-message domain file line func message))
  4871. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para></para><para>Passed as <code>file</code></para></td></tr><tr><td class="parameter_name"><para>line</para></td><td class="parameter_description"><para></para><para>Passed as <code>line</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para></para><para>Passed as <code>func</code></para></td></tr><tr><td class="parameter_name"><para>message</para></td><td class="parameter_description"><para></para><para>Passed as <code>message</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>assertion-message-cmpstr</title><informalexample><programlisting>(define-values
  4872. ()
  4873. (assertion-message-cmpstr domain file line func expr arg1 cmp arg2))
  4874. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para></para><para>Passed as <code>file</code></para></td></tr><tr><td class="parameter_name"><para>line</para></td><td class="parameter_description"><para></para><para>Passed as <code>line</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para></para><para>Passed as <code>func</code></para></td></tr><tr><td class="parameter_name"><para>expr</para></td><td class="parameter_description"><para></para><para>Passed as <code>expr</code></para></td></tr><tr><td class="parameter_name"><para>arg1</para></td><td class="parameter_description"><para></para><para>Passed as <code>arg1</code></para></td></tr><tr><td class="parameter_name"><para>cmp</para></td><td class="parameter_description"><para></para><para>Passed as <code>cmp</code></para></td></tr><tr><td class="parameter_name"><para>arg2</para></td><td class="parameter_description"><para></para><para>Passed as <code>arg2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>assertion-message-cmpstrv</title><informalexample><programlisting>(define-values
  4875. ()
  4876. (assertion-message-cmpstrv
  4877. domain
  4878. file
  4879. line
  4880. func
  4881. expr
  4882. arg1
  4883. arg2
  4884. first-wrong-idx))
  4885. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para></para><para>Passed as <code>file</code></para></td></tr><tr><td class="parameter_name"><para>line</para></td><td class="parameter_description"><para></para><para>Passed as <code>line</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para></para><para>Passed as <code>func</code></para></td></tr><tr><td class="parameter_name"><para>expr</para></td><td class="parameter_description"><para></para><para>Passed as <code>expr</code></para></td></tr><tr><td class="parameter_name"><para>arg1</para></td><td class="parameter_description"><para></para><para>Passed as <code>arg1</code></para></td></tr><tr><td class="parameter_name"><para>arg2</para></td><td class="parameter_description"><para></para><para>Passed as <code>arg2</code></para></td></tr><tr><td class="parameter_name"><para>first_wrong_idx</para></td><td class="parameter_description"><para></para><para>Passed as <code>first-wrong-idx</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>assertion-message-error</title><informalexample><programlisting>(define-values
  4886. ()
  4887. (assertion-message-error
  4888. domain
  4889. file
  4890. line
  4891. func
  4892. expr
  4893. error
  4894. error-domain
  4895. error-code))
  4896. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para></para><para>Passed as <code>file</code></para></td></tr><tr><td class="parameter_name"><para>line</para></td><td class="parameter_description"><para></para><para>Passed as <code>line</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para></para><para>Passed as <code>func</code></para></td></tr><tr><td class="parameter_name"><para>expr</para></td><td class="parameter_description"><para></para><para>Passed as <code>expr</code></para></td></tr><tr><td class="parameter_name"><para>error</para></td><td class="parameter_description"><para></para><para>Passed as <code>error</code></para></td></tr><tr><td class="parameter_name"><para>error_domain</para></td><td class="parameter_description"><para></para><para>Passed as <code>error-domain</code></para></td></tr><tr><td class="parameter_name"><para>error_code</para></td><td class="parameter_description"><para></para><para>Passed as <code>error-code</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-int-add</title><informalexample><programlisting>(define-values (%return) (atomic-int-add atomic val))
  4897. </programlisting></informalexample><para>Atomically adds <parameter>val</parameter> to the value of <parameter>atomic</parameter>.
  4898. </para>
  4899. <para>Think of this operation as an atomic version of
  4900. <code>{ tmp = *atomic; *atomic += val; return tmp; }</code>.
  4901. </para>
  4902. <para>This call acts as a full compiler and hardware memory barrier.
  4903. </para>
  4904. <para>Before version 2.30, this function did not return a value
  4905. (but <function>g_atomic_int_exchange_and_add()</function> did, and had the same meaning).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> or <type>guint</type></para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the value to add</para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-int-and</title><informalexample><programlisting>(define-values (%return) (atomic-int-and atomic val))
  4906. </programlisting></informalexample><para>Performs an atomic bitwise 'and' of the value of <parameter>atomic</parameter> and <parameter>val</parameter>,
  4907. storing the result back in <parameter>atomic</parameter>.
  4908. </para>
  4909. <para>This call acts as a full compiler and hardware memory barrier.
  4910. </para>
  4911. <para>Think of this operation as an atomic version of
  4912. <code>{ tmp = *atomic; *atomic &amp;= val; return tmp; }</code>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> or <type>guint</type></para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the value to 'and'</para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-int-compare-and-exchange?</title><informalexample><programlisting>(define-values
  4913. (%return)
  4914. (atomic-int-compare-and-exchange? atomic oldval newval))
  4915. </programlisting></informalexample><para>Compares <parameter>atomic</parameter> to <parameter>oldval</parameter> and, if equal, sets it to <parameter>newval</parameter>.
  4916. If <parameter>atomic</parameter> was not equal to <parameter>oldval</parameter> then no change occurs.
  4917. </para>
  4918. <para>This compare and exchange is done atomically.
  4919. </para>
  4920. <para>Think of this operation as an atomic version of
  4921. <code>{ if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }</code>.
  4922. </para>
  4923. <para>This call acts as a full compiler and hardware memory barrier.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> or <type>guint</type></para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>oldval</para></td><td class="parameter_description"><para>the value to compare with</para><para>Passed as <code>oldval</code></para></td></tr><tr><td class="parameter_name"><para>newval</para></td><td class="parameter_description"><para>the value to conditionally replace with</para><para>Passed as <code>newval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-int-dec-and-test?</title><informalexample><programlisting>(define-values (%return) (atomic-int-dec-and-test? atomic))
  4924. </programlisting></informalexample><para>Decrements the value of <parameter>atomic</parameter> by 1.
  4925. </para>
  4926. <para>Think of this operation as an atomic version of
  4927. <code>{ *atomic -= 1; return (*atomic == 0); }</code>.
  4928. </para>
  4929. <para>This call acts as a full compiler and hardware memory barrier.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> or <type>guint</type></para><para>Passed as <code>atomic</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-int-get</title><informalexample><programlisting>(define-values (%return) (atomic-int-get atomic))
  4930. </programlisting></informalexample><para>Gets the current value of <parameter>atomic</parameter>.
  4931. </para>
  4932. <para>This call acts as a full compiler and hardware
  4933. memory barrier (before the get).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> or <type>guint</type></para><para>Passed as <code>atomic</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-int-inc</title><informalexample><programlisting>(define-values () (atomic-int-inc atomic))
  4934. </programlisting></informalexample><para>Increments the value of <parameter>atomic</parameter> by 1.
  4935. </para>
  4936. <para>Think of this operation as an atomic version of <code>{ *atomic += 1; }</code>.
  4937. </para>
  4938. <para>This call acts as a full compiler and hardware memory barrier.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> or <type>guint</type></para><para>Passed as <code>atomic</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-int-or</title><informalexample><programlisting>(define-values (%return) (atomic-int-or atomic val))
  4939. </programlisting></informalexample><para>Performs an atomic bitwise 'or' of the value of <parameter>atomic</parameter> and <parameter>val</parameter>,
  4940. storing the result back in <parameter>atomic</parameter>.
  4941. </para>
  4942. <para>Think of this operation as an atomic version of
  4943. <code>{ tmp = *atomic; *atomic |= val; return tmp; }</code>.
  4944. </para>
  4945. <para>This call acts as a full compiler and hardware memory barrier.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> or <type>guint</type></para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the value to 'or'</para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-int-set</title><informalexample><programlisting>(define-values () (atomic-int-set atomic newval))
  4946. </programlisting></informalexample><para>Sets the value of <parameter>atomic</parameter> to <parameter>newval</parameter>.
  4947. </para>
  4948. <para>This call acts as a full compiler and hardware
  4949. memory barrier (after the set).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> or <type>guint</type></para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>newval</para></td><td class="parameter_description"><para>a new value to store</para><para>Passed as <code>newval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-int-xor</title><informalexample><programlisting>(define-values (%return) (atomic-int-xor atomic val))
  4950. </programlisting></informalexample><para>Performs an atomic bitwise 'xor' of the value of <parameter>atomic</parameter> and <parameter>val</parameter>,
  4951. storing the result back in <parameter>atomic</parameter>.
  4952. </para>
  4953. <para>Think of this operation as an atomic version of
  4954. <code>{ tmp = *atomic; *atomic ^= val; return tmp; }</code>.
  4955. </para>
  4956. <para>This call acts as a full compiler and hardware memory barrier.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> or <type>guint</type></para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the value to 'xor'</para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-pointer-add</title><informalexample><programlisting>(define-values (%return) (atomic-pointer-add atomic val))
  4957. </programlisting></informalexample><para>Atomically adds <parameter>val</parameter> to the value of <parameter>atomic</parameter>.
  4958. </para>
  4959. <para>Think of this operation as an atomic version of
  4960. <code>{ tmp = *atomic; *atomic += val; return tmp; }</code>.
  4961. </para>
  4962. <para>This call acts as a full compiler and hardware memory barrier.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gpointer</type>-sized value</para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the value to add</para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-pointer-and</title><informalexample><programlisting>(define-values (%return) (atomic-pointer-and atomic val))
  4963. </programlisting></informalexample><para>Performs an atomic bitwise 'and' of the value of <parameter>atomic</parameter> and <parameter>val</parameter>,
  4964. storing the result back in <parameter>atomic</parameter>.
  4965. </para>
  4966. <para>Think of this operation as an atomic version of
  4967. <code>{ tmp = *atomic; *atomic &amp;= val; return tmp; }</code>.
  4968. </para>
  4969. <para>This call acts as a full compiler and hardware memory barrier.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gpointer</type>-sized value</para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the value to 'and'</para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-pointer-compare-and-exchange?</title><informalexample><programlisting>(define-values
  4970. (%return)
  4971. (atomic-pointer-compare-and-exchange? atomic oldval newval))
  4972. </programlisting></informalexample><para>Compares <parameter>atomic</parameter> to <parameter>oldval</parameter> and, if equal, sets it to <parameter>newval</parameter>.
  4973. If <parameter>atomic</parameter> was not equal to <parameter>oldval</parameter> then no change occurs.
  4974. </para>
  4975. <para>This compare and exchange is done atomically.
  4976. </para>
  4977. <para>Think of this operation as an atomic version of
  4978. <code>{ if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }</code>.
  4979. </para>
  4980. <para>This call acts as a full compiler and hardware memory barrier.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gpointer</type>-sized value</para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>oldval</para></td><td class="parameter_description"><para>the value to compare with</para><para>Passed as <code>oldval</code></para></td></tr><tr><td class="parameter_name"><para>newval</para></td><td class="parameter_description"><para>the value to conditionally replace with</para><para>Passed as <code>newval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-pointer-get</title><informalexample><programlisting>(define-values (%return) (atomic-pointer-get atomic))
  4981. </programlisting></informalexample><para>Gets the current value of <parameter>atomic</parameter>.
  4982. </para>
  4983. <para>This call acts as a full compiler and hardware
  4984. memory barrier (before the get).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gpointer</type>-sized value</para><para>Passed as <code>atomic</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-pointer-or</title><informalexample><programlisting>(define-values (%return) (atomic-pointer-or atomic val))
  4985. </programlisting></informalexample><para>Performs an atomic bitwise 'or' of the value of <parameter>atomic</parameter> and <parameter>val</parameter>,
  4986. storing the result back in <parameter>atomic</parameter>.
  4987. </para>
  4988. <para>Think of this operation as an atomic version of
  4989. <code>{ tmp = *atomic; *atomic |= val; return tmp; }</code>.
  4990. </para>
  4991. <para>This call acts as a full compiler and hardware memory barrier.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gpointer</type>-sized value</para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the value to 'or'</para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-pointer-set</title><informalexample><programlisting>(define-values () (atomic-pointer-set atomic newval))
  4992. </programlisting></informalexample><para>Sets the value of <parameter>atomic</parameter> to <parameter>newval</parameter>.
  4993. </para>
  4994. <para>This call acts as a full compiler and hardware
  4995. memory barrier (after the set).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gpointer</type>-sized value</para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>newval</para></td><td class="parameter_description"><para>a new value to store</para><para>Passed as <code>newval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-pointer-xor</title><informalexample><programlisting>(define-values (%return) (atomic-pointer-xor atomic val))
  4996. </programlisting></informalexample><para>Performs an atomic bitwise 'xor' of the value of <parameter>atomic</parameter> and <parameter>val</parameter>,
  4997. storing the result back in <parameter>atomic</parameter>.
  4998. </para>
  4999. <para>Think of this operation as an atomic version of
  5000. <code>{ tmp = *atomic; *atomic ^= val; return tmp; }</code>.
  5001. </para>
  5002. <para>This call acts as a full compiler and hardware memory barrier.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>atomic</para></td><td class="parameter_description"><para>a pointer to a <type>gpointer</type>-sized value</para><para>Passed as <code>atomic</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the value to 'xor'</para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-rc-box-acquire</title><informalexample><programlisting>(define-values (%return) (atomic-rc-box-acquire mem-block))
  5003. </programlisting></informalexample><para>Atomically acquires a reference on the data pointed by <parameter>mem_block</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>a pointer to reference counted data</para><para>Passed as <code>mem-block</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-rc-box-alloc</title><informalexample><programlisting>(define-values (%return) (atomic-rc-box-alloc block-size))
  5004. </programlisting></informalexample><para>Allocates <parameter>block_size</parameter> bytes of memory, and adds atomic
  5005. reference counting semantics to it.
  5006. </para>
  5007. <para>The data will be freed when its reference count drops to
  5008. zero.
  5009. </para>
  5010. <para>The allocated data is guaranteed to be suitably aligned for any
  5011. built-in type.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>block_size</para></td><td class="parameter_description"><para>the size of the allocation, must be greater than 0</para><para>Passed as <code>block-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-rc-box-alloc0</title><informalexample><programlisting>(define-values (%return) (atomic-rc-box-alloc0 block-size))
  5012. </programlisting></informalexample><para>Allocates <parameter>block_size</parameter> bytes of memory, and adds atomic
  5013. reference counting semantics to it.
  5014. </para>
  5015. <para>The contents of the returned data is set to zero.
  5016. </para>
  5017. <para>The data will be freed when its reference count drops to
  5018. zero.
  5019. </para>
  5020. <para>The allocated data is guaranteed to be suitably aligned for any
  5021. built-in type.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>block_size</para></td><td class="parameter_description"><para>the size of the allocation, must be greater than 0</para><para>Passed as <code>block-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-rc-box-dup</title><informalexample><programlisting>(define-values (%return) (atomic-rc-box-dup block-size mem-block))
  5022. </programlisting></informalexample><para>Allocates a new block of data with atomic reference counting
  5023. semantics, and copies <parameter>block_size</parameter> bytes of <parameter>mem_block</parameter>
  5024. into it.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>block_size</para></td><td class="parameter_description"><para>the number of bytes to copy, must be greater than 0</para><para>Passed as <code>block-size</code></para></td></tr><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>the memory to copy</para><para>Passed as <code>mem-block</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-rc-box-get-size</title><informalexample><programlisting>(define-values (%return) (atomic-rc-box-get-size mem-block))
  5025. </programlisting></informalexample><para>Retrieves the size of the reference counted data pointed by <parameter>mem_block</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>a pointer to reference counted data</para><para>Passed as <code>mem-block</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-rc-box-release</title><informalexample><programlisting>(define-values () (atomic-rc-box-release mem-block))
  5026. </programlisting></informalexample><para>Atomically releases a reference on the data pointed by <parameter>mem_block</parameter>.
  5027. </para>
  5028. <para>If the reference was the last one, it will free the
  5029. resources allocated for <parameter>mem_block</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>a pointer to reference counted data</para><para>Passed as <code>mem-block</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-rc-box-release-full</title><informalexample><programlisting>(define-values () (atomic-rc-box-release-full mem-block clear-func))
  5030. </programlisting></informalexample><para>Atomically releases a reference on the data pointed by <parameter>mem_block</parameter>.
  5031. </para>
  5032. <para>If the reference was the last one, it will call <parameter>clear_func</parameter>
  5033. to clear the contents of <parameter>mem_block</parameter>, and then will free the
  5034. resources allocated for <parameter>mem_block</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>a pointer to reference counted data</para><para>Passed as <code>mem-block</code></para></td></tr><tr><td class="parameter_name"><para>clear_func</para></td><td class="parameter_description"><para>a function to call when clearing the data</para><para>Passed as <code>clear-func</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-ref-count-compare?</title><informalexample><programlisting>(define-values (%return) (atomic-ref-count-compare? arc val))
  5035. </programlisting></informalexample><para>Atomically compares the current value of <parameter>arc</parameter> with <parameter>val</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>arc</para></td><td class="parameter_description"><para>the address of an atomic reference count variable</para><para>Passed as <code>arc</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the value to compare</para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-ref-count-dec?</title><informalexample><programlisting>(define-values (%return) (atomic-ref-count-dec? arc))
  5036. </programlisting></informalexample><para>Atomically decreases the reference count.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>arc</para></td><td class="parameter_description"><para>the address of an atomic reference count variable</para><para>Passed as <code>arc</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-ref-count-inc</title><informalexample><programlisting>(define-values () (atomic-ref-count-inc arc))
  5037. </programlisting></informalexample><para>Atomically increases the reference count.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>arc</para></td><td class="parameter_description"><para>the address of an atomic reference count variable</para><para>Passed as <code>arc</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>atomic-ref-count-init</title><informalexample><programlisting>(define-values () (atomic-ref-count-init arc))
  5038. </programlisting></informalexample><para>Initializes a reference count variable.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>arc</para></td><td class="parameter_description"><para>the address of an atomic reference count variable</para><para>Passed as <code>arc</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>base64-decode</title><informalexample><programlisting>(define-values (%return out-len) (base64-decode text))
  5039. </programlisting></informalexample><para>Decode a sequence of Base-64 encoded text into binary data. Note
  5040. that the returned binary data is not necessarily zero-terminated,
  5041. so it should not be used as a character string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>text</para></td><td class="parameter_description"><para>zero-terminated string with base64 text to decode</para><para>Passed as <code>text</code></para></td></tr><tr><td class="parameter_name"><para>out_len</para></td><td class="parameter_description"><para>The length of the decoded data is written here</para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>base64-decode-inplace!</title><informalexample><programlisting>(define-values (%return text out-len) (base64-decode-inplace! text))
  5042. </programlisting></informalexample><para>Decode a sequence of Base-64 encoded text into binary data
  5043. by overwriting the input data.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>text</para></td><td class="parameter_description"><para>zero-terminated
  5044. string with base64 text to decode</para><para>Passed as <code>text</code></para></td></tr><tr><td class="parameter_name"><para>out_len</para></td><td class="parameter_description"><para>The length of the decoded data is written here</para><para>Inferred from <code>text</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>base64-encode</title><informalexample><programlisting>(define-values (%return) (base64-encode data))
  5045. </programlisting></informalexample><para>Encode a sequence of binary data into its Base-64 stringified
  5046. representation.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>the binary data to encode</para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the length of <parameter>data</parameter></para><para>Inferred from <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>base64-encode-close</title><informalexample><programlisting>(define-values
  5047. (%return out state save)
  5048. (base64-encode-close break-lines state save))
  5049. </programlisting></informalexample><para>Flush the status from a sequence of calls to <function>g_base64_encode_step()</function>.
  5050. </para>
  5051. <para>The output buffer must be large enough to fit all the data that will
  5052. be written to it. It will need up to 4 bytes, or up to 5 bytes if
  5053. line-breaking is enabled.
  5054. </para>
  5055. <para>The <parameter>out</parameter> array will not be automatically nul-terminated.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>break_lines</para></td><td class="parameter_description"><para>whether to break long lines</para><para>Passed as <code>break-lines</code></para></td></tr><tr><td class="parameter_name"><para>out</para></td><td class="parameter_description"><para>pointer to destination buffer</para><para>Passed as <code>out</code></para></td></tr><tr><td class="parameter_name"><para>state</para></td><td class="parameter_description"><para>Saved state from <function>g_base64_encode_step()</function></para><para>Passed as <code>state</code></para></td></tr><tr><td class="parameter_name"><para>save</para></td><td class="parameter_description"><para>Saved state from <function>g_base64_encode_step()</function></para><para>Passed as <code>save</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>base64-encode-step</title><informalexample><programlisting>(define-values
  5056. (%return out state save)
  5057. (base64-encode-step in break-lines state save))
  5058. </programlisting></informalexample><para>Incrementally encode a sequence of binary data into its Base-64 stringified
  5059. representation. By calling this function multiple times you can convert
  5060. data in chunks to avoid having to have the full encoded data in memory.
  5061. </para>
  5062. <para>When all of the data has been converted you must call
  5063. <function>g_base64_encode_close()</function> to flush the saved state.
  5064. </para>
  5065. <para>The output buffer must be large enough to fit all the data that will
  5066. be written to it. Due to the way base64 encodes you will need
  5067. at least: (<parameter>len</parameter> / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
  5068. non-zero state). If you enable line-breaking you will need at least:
  5069. ((<parameter>len</parameter> / 3 + 1) * 4 + 4) / 76 + 1 bytes of extra space.
  5070. </para>
  5071. <para><parameter>break_lines</parameter> is typically used when putting base64-encoded data in emails.
  5072. It breaks the lines at 76 columns instead of putting all of the text on
  5073. the same line. This avoids problems with long lines in the email system.
  5074. Note however that it breaks the lines with <code>LF</code> characters, not
  5075. <code>CR LF</code> sequences, so the result cannot be passed directly to SMTP
  5076. or certain other protocols.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>in</para></td><td class="parameter_description"><para>the binary data to encode</para><para>Passed as <code>in</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the length of <parameter>in</parameter></para><para>Inferred from <code>in</code></para></td></tr><tr><td class="parameter_name"><para>break_lines</para></td><td class="parameter_description"><para>whether to break long lines</para><para>Passed as <code>break-lines</code></para></td></tr><tr><td class="parameter_name"><para>out</para></td><td class="parameter_description"><para>pointer to destination buffer</para><para>Passed as <code>out</code></para></td></tr><tr><td class="parameter_name"><para>state</para></td><td class="parameter_description"><para>Saved state between steps, initialize to 0</para><para>Passed as <code>state</code></para></td></tr><tr><td class="parameter_name"><para>save</para></td><td class="parameter_description"><para>Saved state between steps, initialize to 0</para><para>Passed as <code>save</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>bit-lock</title><informalexample><programlisting>(define-values () (bit-lock address lock-bit))
  5077. </programlisting></informalexample><para>Sets the indicated <parameter>lock_bit</parameter> in <parameter>address</parameter>. If the bit is already
  5078. set, this call will block until <function>g_bit_unlock()</function> unsets the
  5079. corresponding bit.
  5080. </para>
  5081. <para>Attempting to lock on two different bits within the same integer is
  5082. not supported and will very probably cause deadlocks.
  5083. </para>
  5084. <para>The value of the bit that is set is (1u &lt;&lt; <parameter>bit</parameter>). If <parameter>bit</parameter> is not
  5085. between 0 and 31 then the result is undefined.
  5086. </para>
  5087. <para>This function accesses <parameter>address</parameter> atomically. All other accesses to
  5088. <parameter>address</parameter> must be atomic in order for this function to work
  5089. reliably.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>address</para></td><td class="parameter_description"><para>a pointer to an integer</para><para>Passed as <code>address</code></para></td></tr><tr><td class="parameter_name"><para>lock_bit</para></td><td class="parameter_description"><para>a bit value between 0 and 31</para><para>Passed as <code>lock-bit</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>bit-nth-lsf</title><informalexample><programlisting>(define-values (%return) (bit-nth-lsf mask nth-bit))
  5090. </programlisting></informalexample><para>Find the position of the first bit set in <parameter>mask</parameter>, searching
  5091. from (but not including) <parameter>nth_bit</parameter> upwards. Bits are numbered
  5092. from 0 (least significant) to sizeof(<type>gulong</type>) * 8 - 1 (31 or 63,
  5093. usually). To start searching from the 0th bit, set <parameter>nth_bit</parameter> to -1.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mask</para></td><td class="parameter_description"><para>a <type>gulong</type> containing flags</para><para>Passed as <code>mask</code></para></td></tr><tr><td class="parameter_name"><para>nth_bit</para></td><td class="parameter_description"><para>the index of the bit to start the search from</para><para>Passed as <code>nth-bit</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>bit-nth-msf</title><informalexample><programlisting>(define-values (%return) (bit-nth-msf mask nth-bit))
  5094. </programlisting></informalexample><para>Find the position of the first bit set in <parameter>mask</parameter>, searching
  5095. from (but not including) <parameter>nth_bit</parameter> downwards. Bits are numbered
  5096. from 0 (least significant) to sizeof(<type>gulong</type>) * 8 - 1 (31 or 63,
  5097. usually). To start searching from the last bit, set <parameter>nth_bit</parameter> to
  5098. -1 or GLIB_SIZEOF_LONG * 8.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mask</para></td><td class="parameter_description"><para>a <type>gulong</type> containing flags</para><para>Passed as <code>mask</code></para></td></tr><tr><td class="parameter_name"><para>nth_bit</para></td><td class="parameter_description"><para>the index of the bit to start the search from</para><para>Passed as <code>nth-bit</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>bit-storage</title><informalexample><programlisting>(define-values (%return) (bit-storage number))
  5099. </programlisting></informalexample><para>Gets the number of bits used to hold <parameter>number</parameter>,
  5100. e.g. if <parameter>number</parameter> is 4, 3 bits are needed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>number</para></td><td class="parameter_description"><para>a <type>guint</type></para><para>Passed as <code>number</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>bit-trylock?</title><informalexample><programlisting>(define-values (%return) (bit-trylock? address lock-bit))
  5101. </programlisting></informalexample><para>Sets the indicated <parameter>lock_bit</parameter> in <parameter>address</parameter>, returning <constant>TRUE</constant> if
  5102. successful. If the bit is already set, returns <constant>FALSE</constant> immediately.
  5103. </para>
  5104. <para>Attempting to lock on two different bits within the same integer is
  5105. not supported.
  5106. </para>
  5107. <para>The value of the bit that is set is (1u &lt;&lt; <parameter>bit</parameter>). If <parameter>bit</parameter> is not
  5108. between 0 and 31 then the result is undefined.
  5109. </para>
  5110. <para>This function accesses <parameter>address</parameter> atomically. All other accesses to
  5111. <parameter>address</parameter> must be atomic in order for this function to work
  5112. reliably.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>address</para></td><td class="parameter_description"><para>a pointer to an integer</para><para>Passed as <code>address</code></para></td></tr><tr><td class="parameter_name"><para>lock_bit</para></td><td class="parameter_description"><para>a bit value between 0 and 31</para><para>Passed as <code>lock-bit</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>bit-unlock</title><informalexample><programlisting>(define-values () (bit-unlock address lock-bit))
  5113. </programlisting></informalexample><para>Clears the indicated <parameter>lock_bit</parameter> in <parameter>address</parameter>. If another thread is
  5114. currently blocked in <function>g_bit_lock()</function> on this same bit then it will be
  5115. woken up.
  5116. </para>
  5117. <para>This function accesses <parameter>address</parameter> atomically. All other accesses to
  5118. <parameter>address</parameter> must be atomic in order for this function to work
  5119. reliably.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>address</para></td><td class="parameter_description"><para>a pointer to an integer</para><para>Passed as <code>address</code></para></td></tr><tr><td class="parameter_name"><para>lock_bit</para></td><td class="parameter_description"><para>a bit value between 0 and 31</para><para>Passed as <code>lock-bit</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>bookmark-file-error-quark</title><informalexample><programlisting>(define-values (%return) (bookmark-file-error-quark))
  5120. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>build-filenamev</title><informalexample><programlisting>(define-values (%return) (build-filenamev args))
  5121. </programlisting></informalexample><para>Behaves exactly like <function>g_build_filename()</function>, but takes the path elements
  5122. as a string array, instead of varargs. This function is mainly
  5123. meant for language bindings.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>args</para></td><td class="parameter_description"><para><constant>NULL</constant>-terminated
  5124. array of strings containing the path elements.</para><para>Passed as <code>args</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>build-pathv</title><informalexample><programlisting>(define-values (%return) (build-pathv separator args))
  5125. </programlisting></informalexample><para>Behaves exactly like <function>g_build_path()</function>, but takes the path elements
  5126. as a string array, instead of varargs. This function is mainly
  5127. meant for language bindings.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>separator</para></td><td class="parameter_description"><para>a string used to separator the elements of the path.</para><para>Passed as <code>separator</code></para></td></tr><tr><td class="parameter_name"><para>args</para></td><td class="parameter_description"><para><constant>NULL</constant>-terminated
  5128. array of strings containing the path elements.</para><para>Passed as <code>args</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>byte-array-free</title><informalexample><programlisting>(define-values (%return) (byte-array-free array free-segment))
  5129. </programlisting></informalexample><para>Frees the memory allocated by the <type>GByteArray</type>. If <parameter>free_segment</parameter> is
  5130. <constant>TRUE</constant> it frees the actual byte data. If the reference count of
  5131. <parameter>array</parameter> is greater than one, the <type>GByteArray</type> wrapper is preserved but
  5132. the size of <parameter>array</parameter> will be set to zero.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>array</para></td><td class="parameter_description"><para>a <type>GByteArray</type></para><para>Passed as <code>array</code></para></td></tr><tr><td class="parameter_name"><para>free_segment</para></td><td class="parameter_description"><para>if <constant>TRUE</constant> the actual byte data is freed as well</para><para>Passed as <code>free-segment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>byte-array-free-to-bytes</title><informalexample><programlisting>(define-values (%return) (byte-array-free-to-bytes array))
  5133. </programlisting></informalexample><para>Transfers the data from the <type>GByteArray</type> into a new immutable <type>GBytes</type>.
  5134. </para>
  5135. <para>The <type>GByteArray</type> is freed unless the reference count of <parameter>array</parameter> is greater
  5136. than one, the <type>GByteArray</type> wrapper is preserved but the size of <parameter>array</parameter>
  5137. will be set to zero.
  5138. </para>
  5139. <para>This is identical to using <function>g_bytes_new_take()</function> and <function>g_byte_array_free()</function>
  5140. together.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>array</para></td><td class="parameter_description"><para>a <type>GByteArray</type></para><para>Passed as <code>array</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>byte-array-new</title><informalexample><programlisting>(define-values (%return) (byte-array-new))
  5141. </programlisting></informalexample><para>Creates a new <type>GByteArray</type> with a reference count of 1.</para></refsect2><refsect2><title>byte-array-new-take</title><informalexample><programlisting>(define-values (%return) (byte-array-new-take data))
  5142. </programlisting></informalexample><para>Create byte array containing the data. The data will be owned by the array
  5143. and will be freed with <function>g_free()</function>, i.e. it could be allocated using <function>g_strdup()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>byte data for the array</para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>data</parameter></para><para>Inferred from <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>byte-array-steal</title><informalexample><programlisting>(define-values (%return len) (byte-array-steal array len))
  5144. </programlisting></informalexample><para>Frees the data in the array and resets the size to zero, while
  5145. the underlying array is preserved for use elsewhere and returned
  5146. to the caller.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>array</para></td><td class="parameter_description"><para>a <type>GByteArray</type>.</para><para>Passed as <code>array</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>pointer to retrieve the number of
  5147. elements of the original array</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>byte-array-unref</title><informalexample><programlisting>(define-values () (byte-array-unref array))
  5148. </programlisting></informalexample><para>Atomically decrements the reference count of <parameter>array</parameter> by one. If the
  5149. reference count drops to 0, all memory allocated by the array is
  5150. released. This function is thread-safe and may be called from any
  5151. thread.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>array</para></td><td class="parameter_description"><para>A <type>GByteArray</type></para><para>Passed as <code>array</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>canonicalize-filename</title><informalexample><programlisting>(define-values (%return) (canonicalize-filename filename relative-to))
  5152. </programlisting></informalexample><para>Gets the canonical file name from <parameter>filename</parameter>. All triple slashes are turned into
  5153. single slashes, and all <code>..</code> and <code>.</code>s resolved against <parameter>relative_to</parameter>.
  5154. </para>
  5155. <para>Symlinks are not followed, and the returned path is guaranteed to be absolute.
  5156. </para>
  5157. <para>If <parameter>filename</parameter> is an absolute path, <parameter>relative_to</parameter> is ignored. Otherwise,
  5158. <parameter>relative_to</parameter> will be prepended to <parameter>filename</parameter> to make it absolute. <parameter>relative_to</parameter>
  5159. must be an absolute path, or <constant>NULL</constant>. If <parameter>relative_to</parameter> is <constant>NULL</constant>, it'll fallback
  5160. to <function>g_get_current_dir()</function>.
  5161. </para>
  5162. <para>This function never fails, and will canonicalize file paths even if they don't
  5163. exist.
  5164. </para>
  5165. <para>No file system I/O is done.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>the name of the file</para><para>Passed as <code>filename</code></para></td></tr><tr><td class="parameter_name"><para>relative_to</para></td><td class="parameter_description"><para>the relative directory, or <constant>NULL</constant>
  5166. to use the current working directory</para><para>Passed as <code>relative-to</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>chdir</title><informalexample><programlisting>(define-values (%return) (chdir path))
  5167. </programlisting></informalexample><para>A wrapper for the POSIX <function>chdir()</function> function. The function changes the
  5168. current directory of the process to <parameter>path</parameter>.
  5169. </para>
  5170. <para>See your C library manual for more details about <function>chdir()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>a pathname in the GLib file name encoding
  5171. (UTF-8 on Windows)</para><para>Passed as <code>path</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>check-version</title><informalexample><programlisting>(define-values
  5172. (%return)
  5173. (check-version required-major required-minor required-micro))
  5174. </programlisting></informalexample><para>Checks that the GLib library in use is compatible with the
  5175. given version. Generally you would pass in the constants
  5176. <type>GLIB_MAJOR_VERSION</type>, <type>GLIB_MINOR_VERSION</type>, <type>GLIB_MICRO_VERSION</type>
  5177. as the three arguments to this function; that produces
  5178. a check that the library in use is compatible with
  5179. the version of GLib the application or module was compiled
  5180. against.
  5181. </para>
  5182. <para>Compatibility is defined by two things: first the version
  5183. of the running library is newer than the version
  5184. <parameter>required_major</parameter>.required_minor.<parameter>required_micro</parameter>. Second
  5185. the running library must be binary compatible with the
  5186. version <parameter>required_major</parameter>.required_minor.<parameter>required_micro</parameter>
  5187. (same major version.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>required_major</para></td><td class="parameter_description"><para>the required major version</para><para>Passed as <code>required-major</code></para></td></tr><tr><td class="parameter_name"><para>required_minor</para></td><td class="parameter_description"><para>the required minor version</para><para>Passed as <code>required-minor</code></para></td></tr><tr><td class="parameter_name"><para>required_micro</para></td><td class="parameter_description"><para>the required micro version</para><para>Passed as <code>required-micro</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>checksum-type-get-length</title><informalexample><programlisting>(define-values (%return) (checksum-type-get-length checksum-type))
  5188. </programlisting></informalexample><para>Gets the length in bytes of digests of type <parameter>checksum_type</parameter></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>checksum_type</para></td><td class="parameter_description"><para>a <type>GChecksumType</type></para><para>Passed as <code>checksum-type</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>child-watch-add</title><informalexample><programlisting>(define-values (%return) (child-watch-add priority pid function data notify))
  5189. </programlisting></informalexample><para>Sets a function to be called when the child indicated by <parameter>pid</parameter>
  5190. exits, at a default priority, <type>G_PRIORITY_DEFAULT</type>.
  5191. </para>
  5192. <para>If you obtain <parameter>pid</parameter> from <function>g_spawn_async()</function> or <function>g_spawn_async_with_pipes()</function>
  5193. you will need to pass <type>G_SPAWN_DO_NOT_REAP_CHILD</type> as flag to
  5194. the spawn function for the child watching to work.
  5195. </para>
  5196. <para>Note that on platforms where <type>GPid</type> must be explicitly closed
  5197. (see <function>g_spawn_close_pid()</function>) <parameter>pid</parameter> must not be closed while the
  5198. source is still active. Typically, you will want to call
  5199. <function>g_spawn_close_pid()</function> in the callback function for the source.
  5200. </para>
  5201. <para>GLib supports only a single callback per process id.
  5202. On POSIX platforms, the same restrictions mentioned for
  5203. <function>g_child_watch_source_new()</function> apply to this function.
  5204. </para>
  5205. <para>This internally creates a main loop source using
  5206. <function>g_child_watch_source_new()</function> and attaches it to the main loop context
  5207. using <function>g_source_attach()</function>. You can do these steps manually if you
  5208. need greater control.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>notify</para></td><td class="parameter_description"><para></para><para>Passed as <code>notify</code></para></td></tr><tr><td class="parameter_name"><para>priority</para></td><td class="parameter_description"><para></para><para>Passed as <code>priority</code></para></td></tr><tr><td class="parameter_name"><para>pid</para></td><td class="parameter_description"><para>process id to watch. On POSIX the positive pid of a child
  5209. process. On Windows a handle for a process (which doesn't have to be
  5210. a child).</para><para>Passed as <code>pid</code></para></td></tr><tr><td class="parameter_name"><para>function</para></td><td class="parameter_description"><para>function to call</para><para>Passed as <code>function</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>data to pass to <parameter>function</parameter></para><para>Passed as <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>child-watch-source-new</title><informalexample><programlisting>(define-values (%return) (child-watch-source-new pid))
  5211. </programlisting></informalexample><para>Creates a new child_watch source.
  5212. </para>
  5213. <para>The source will not initially be associated with any <type>GMainContext</type>
  5214. and must be added to one with <function>g_source_attach()</function> before it will be
  5215. executed.
  5216. </para>
  5217. <para>Note that child watch sources can only be used in conjunction with
  5218. <code>g_spawn...</code> when the <constant>G_SPAWN_DO_NOT_REAP_CHILD</constant> flag is used.
  5219. </para>
  5220. <para>Note that on platforms where <type>GPid</type> must be explicitly closed
  5221. (see <function>g_spawn_close_pid()</function>) <parameter>pid</parameter> must not be closed while the
  5222. source is still active. Typically, you will want to call
  5223. <function>g_spawn_close_pid()</function> in the callback function for the source.
  5224. </para>
  5225. <para>On POSIX platforms, the following restrictions apply to this API
  5226. due to limitations in POSIX process interfaces:
  5227. </para>
  5228. <para>* <parameter>pid</parameter> must be a child of this process
  5229. * <parameter>pid</parameter> must be positive
  5230. * the application must not call <code>waitpid</code> with a non-positive
  5231. first argument, for instance in another thread
  5232. * the application must not wait for <parameter>pid</parameter> to exit by any other
  5233. mechanism, including <code>waitpid(pid, ...)</code> or a second child-watch
  5234. source for the same <parameter>pid</parameter>
  5235. * the application must not ignore SIGCHILD
  5236. </para>
  5237. <para>If any of those conditions are not met, this and related APIs will
  5238. not work correctly. This can often be diagnosed via a GLib warning
  5239. stating that <code>ECHILD</code> was received by <code>waitpid</code>.
  5240. </para>
  5241. <para>Calling <code>waitpid</code> for specific processes other than <parameter>pid</parameter> remains a
  5242. valid thing to do.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pid</para></td><td class="parameter_description"><para>process to watch. On POSIX the positive pid of a child process. On
  5243. Windows a handle for a process (which doesn't have to be a child).</para><para>Passed as <code>pid</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>clear-error</title><informalexample><programlisting>(define-values () (clear-error))
  5244. </programlisting></informalexample><para>If <parameter>err</parameter> or *<parameter>err</parameter> is <constant>NULL</constant>, does nothing. Otherwise,
  5245. calls <function>g_error_free()</function> on *<parameter>err</parameter> and sets *<parameter>err</parameter> to <constant>NULL</constant>.</para></refsect2><refsect2><title>close?</title><informalexample><programlisting>(define-values (%return) (close? fd))
  5246. </programlisting></informalexample><para>This wraps the <function>close()</function> call; in case of error, <constant>errno</constant> will be
  5247. preserved, but the error will also be stored as a <type>GError</type> in <parameter>error</parameter>.
  5248. </para>
  5249. <para>Besides using <type>GError</type>, there is another major reason to prefer this
  5250. function over the call provided by the system; on Unix, it will
  5251. attempt to correctly handle <constant>EINTR</constant>, which has platform-specific
  5252. semantics.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>fd</para></td><td class="parameter_description"><para>A file descriptor</para><para>Passed as <code>fd</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>compute-checksum-for-bytes</title><informalexample><programlisting>(define-values (%return) (compute-checksum-for-bytes checksum-type data))
  5253. </programlisting></informalexample><para>Computes the checksum for a binary <parameter>data</parameter>. This is a
  5254. convenience wrapper for <function>g_checksum_new()</function>, <function>g_checksum_get_string()</function>
  5255. and <function>g_checksum_free()</function>.
  5256. </para>
  5257. <para>The hexadecimal string returned will be in lower case.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>checksum_type</para></td><td class="parameter_description"><para>a <type>GChecksumType</type></para><para>Passed as <code>checksum-type</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>binary blob to compute the digest of</para><para>Passed as <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>compute-checksum-for-data</title><informalexample><programlisting>(define-values (%return) (compute-checksum-for-data checksum-type data))
  5258. </programlisting></informalexample><para>Computes the checksum for a binary <parameter>data</parameter> of <parameter>length</parameter>. This is a
  5259. convenience wrapper for <function>g_checksum_new()</function>, <function>g_checksum_get_string()</function>
  5260. and <function>g_checksum_free()</function>.
  5261. </para>
  5262. <para>The hexadecimal string returned will be in lower case.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>checksum_type</para></td><td class="parameter_description"><para>a <type>GChecksumType</type></para><para>Passed as <code>checksum-type</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>binary blob to compute the digest of</para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>length of <parameter>data</parameter></para><para>Inferred from <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>compute-checksum-for-string</title><informalexample><programlisting>(define-values
  5263. (%return)
  5264. (compute-checksum-for-string checksum-type str length))
  5265. </programlisting></informalexample><para>Computes the checksum of a string.
  5266. </para>
  5267. <para>The hexadecimal string returned will be in lower case.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>checksum_type</para></td><td class="parameter_description"><para>a <type>GChecksumType</type></para><para>Passed as <code>checksum-type</code></para></td></tr><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>the string to compute the checksum of</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of the string, or -1 if the string is null-terminated.</para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>compute-hmac-for-bytes</title><informalexample><programlisting>(define-values (%return) (compute-hmac-for-bytes digest-type key data))
  5268. </programlisting></informalexample><para>Computes the HMAC for a binary <parameter>data</parameter>. This is a
  5269. convenience wrapper for <function>g_hmac_new()</function>, <function>g_hmac_get_string()</function>
  5270. and <function>g_hmac_unref()</function>.
  5271. </para>
  5272. <para>The hexadecimal string returned will be in lower case.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>digest_type</para></td><td class="parameter_description"><para>a <type>GChecksumType</type> to use for the HMAC</para><para>Passed as <code>digest-type</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to use in the HMAC</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>binary blob to compute the HMAC of</para><para>Passed as <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>compute-hmac-for-data</title><informalexample><programlisting>(define-values (%return) (compute-hmac-for-data digest-type key data))
  5273. </programlisting></informalexample><para>Computes the HMAC for a binary <parameter>data</parameter> of <parameter>length</parameter>. This is a
  5274. convenience wrapper for <function>g_hmac_new()</function>, <function>g_hmac_get_string()</function>
  5275. and <function>g_hmac_unref()</function>.
  5276. </para>
  5277. <para>The hexadecimal string returned will be in lower case.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>digest_type</para></td><td class="parameter_description"><para>a <type>GChecksumType</type> to use for the HMAC</para><para>Passed as <code>digest-type</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to use in the HMAC</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>key_len</para></td><td class="parameter_description"><para>the length of the key</para><para>Inferred from <code>key</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>binary blob to compute the HMAC of</para><para>Passed as <code>data</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>length of <parameter>data</parameter></para><para>Inferred from <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>compute-hmac-for-string</title><informalexample><programlisting>(define-values (%return) (compute-hmac-for-string digest-type key str length))
  5278. </programlisting></informalexample><para>Computes the HMAC for a string.
  5279. </para>
  5280. <para>The hexadecimal string returned will be in lower case.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>digest_type</para></td><td class="parameter_description"><para>a <type>GChecksumType</type> to use for the HMAC</para><para>Passed as <code>digest-type</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to use in the HMAC</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>key_len</para></td><td class="parameter_description"><para>the length of the key</para><para>Inferred from <code>key</code></para></td></tr><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>the string to compute the HMAC for</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of the string, or -1 if the string is nul-terminated</para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>convert</title><informalexample><programlisting>(define-values
  5281. (%return bytes-read bytes-written)
  5282. (convert str to-codeset from-codeset))
  5283. </programlisting></informalexample><para>Converts a string from one character set to another.
  5284. </para>
  5285. <para>Note that you should use <function>g_iconv()</function> for streaming conversions.
  5286. Despite the fact that <parameter>bytes_read</parameter> can return information about partial
  5287. characters, the g_convert_... functions are not generally suitable
  5288. for streaming. If the underlying converter maintains internal state,
  5289. then this won't be preserved across successive calls to <function>g_convert()</function>,
  5290. <function>g_convert_with_iconv()</function> or <function>g_convert_with_fallback()</function>. (An example of
  5291. this is the GNU C converter for CP1255 which does not emit a base
  5292. character until it knows that the next character is not a mark that
  5293. could combine with the base character.)
  5294. </para>
  5295. <para>Using extensions such as &quot;//TRANSLIT&quot; may not work (or may not work
  5296. well) on many platforms. Consider using <function>g_str_to_ascii()</function> instead.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>
  5297. <para>the string to convert.</para></para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the length of the string in bytes, or -1 if the string is
  5298. nul-terminated (Note that some encodings may allow nul
  5299. bytes to occur inside strings. In that case, using -1
  5300. for the <parameter>len</parameter> parameter is unsafe)</para><para>Inferred from <code>str</code></para></td></tr><tr><td class="parameter_name"><para>to_codeset</para></td><td class="parameter_description"><para>name of character set into which to convert <parameter>str</parameter></para><para>Passed as <code>to-codeset</code></para></td></tr><tr><td class="parameter_name"><para>from_codeset</para></td><td class="parameter_description"><para>character set of <parameter>str</parameter>.</para><para>Passed as <code>from-codeset</code></para></td></tr><tr><td class="parameter_name"><para>bytes_read</para></td><td class="parameter_description"><para>location to store the number of bytes in
  5301. the input string that were successfully converted, or <constant>NULL</constant>.
  5302. Even if the conversion was successful, this may be
  5303. less than <parameter>len</parameter> if there were partial characters
  5304. at the end of the input. If the error
  5305. <type>G_CONVERT_ERROR_ILLEGAL_SEQUENCE</type> occurs, the value
  5306. stored will be the byte offset after the last valid
  5307. input sequence.</para><para>Passed as <code>bytes-read</code></para></td></tr><tr><td class="parameter_name"><para>bytes_written</para></td><td class="parameter_description"><para>the number of bytes stored in
  5308. the output buffer (not including the terminating nul).</para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>convert-error-quark</title><informalexample><programlisting>(define-values (%return) (convert-error-quark))
  5309. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>convert-with-fallback</title><informalexample><programlisting>(define-values
  5310. (%return bytes-read bytes-written)
  5311. (convert-with-fallback str to-codeset from-codeset fallback))
  5312. </programlisting></informalexample><para>Converts a string from one character set to another, possibly
  5313. including fallback sequences for characters not representable
  5314. in the output. Note that it is not guaranteed that the specification
  5315. for the fallback sequences in <parameter>fallback</parameter> will be honored. Some
  5316. systems may do an approximate conversion from <parameter>from_codeset</parameter>
  5317. to <parameter>to_codeset</parameter> in their <function>iconv()</function> functions,
  5318. in which case GLib will simply return that approximate conversion.
  5319. </para>
  5320. <para>Note that you should use <function>g_iconv()</function> for streaming conversions.
  5321. Despite the fact that <parameter>bytes_read</parameter> can return information about partial
  5322. characters, the g_convert_... functions are not generally suitable
  5323. for streaming. If the underlying converter maintains internal state,
  5324. then this won't be preserved across successive calls to <function>g_convert()</function>,
  5325. <function>g_convert_with_iconv()</function> or <function>g_convert_with_fallback()</function>. (An example of
  5326. this is the GNU C converter for CP1255 which does not emit a base
  5327. character until it knows that the next character is not a mark that
  5328. could combine with the base character.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>
  5329. <para>the string to convert.</para></para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the length of the string in bytes, or -1 if the string is
  5330. nul-terminated (Note that some encodings may allow nul
  5331. bytes to occur inside strings. In that case, using -1
  5332. for the <parameter>len</parameter> parameter is unsafe)</para><para>Inferred from <code>str</code></para></td></tr><tr><td class="parameter_name"><para>to_codeset</para></td><td class="parameter_description"><para>name of character set into which to convert <parameter>str</parameter></para><para>Passed as <code>to-codeset</code></para></td></tr><tr><td class="parameter_name"><para>from_codeset</para></td><td class="parameter_description"><para>character set of <parameter>str</parameter>.</para><para>Passed as <code>from-codeset</code></para></td></tr><tr><td class="parameter_name"><para>fallback</para></td><td class="parameter_description"><para>UTF-8 string to use in place of characters not
  5333. present in the target encoding. (The string must be
  5334. representable in the target encoding).
  5335. If <constant>NULL</constant>, characters not in the target encoding will
  5336. be represented as Unicode escapes \uxxxx or \Uxxxxyyyy.</para><para>Passed as <code>fallback</code></para></td></tr><tr><td class="parameter_name"><para>bytes_read</para></td><td class="parameter_description"><para>location to store the number of bytes in
  5337. the input string that were successfully converted, or <constant>NULL</constant>.
  5338. Even if the conversion was successful, this may be
  5339. less than <parameter>len</parameter> if there were partial characters
  5340. at the end of the input.</para><para>Passed as <code>bytes-read</code></para></td></tr><tr><td class="parameter_name"><para>bytes_written</para></td><td class="parameter_description"><para>the number of bytes stored in
  5341. the output buffer (not including the terminating nul).</para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dataset-destroy</title><informalexample><programlisting>(define-values () (dataset-destroy dataset-location))
  5342. </programlisting></informalexample><para>Destroys the dataset, freeing all memory allocated, and calling any
  5343. destroy functions set for data elements.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dataset_location</para></td><td class="parameter_description"><para>the location identifying the dataset.</para><para>Passed as <code>dataset-location</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dataset-foreach</title><informalexample><programlisting>(define-values () (dataset-foreach dataset-location func user-data))
  5344. </programlisting></informalexample><para>Calls the given function for each data element which is associated
  5345. with the given location. Note that this function is NOT thread-safe.
  5346. So unless <parameter>dataset_location</parameter> can be protected from any modifications
  5347. during invocation of this function, it should not be called.
  5348. </para>
  5349. <para><parameter>func</parameter> can make changes to the dataset, but the iteration will not
  5350. reflect changes made during the <function>g_dataset_foreach()</function> call, other
  5351. than skipping over elements that are removed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dataset_location</para></td><td class="parameter_description"><para>the location identifying the dataset.</para><para>Passed as <code>dataset-location</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para>the function to call for each data element.</para><para>Passed as <code>func</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>user data to pass to the function.</para><para>Passed as <code>user-data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dataset-id-get-data</title><informalexample><programlisting>(define-values (%return) (dataset-id-get-data dataset-location key-id))
  5352. </programlisting></informalexample><para>Gets the data element corresponding to a <type>GQuark</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dataset_location</para></td><td class="parameter_description"><para>the location identifying the dataset.</para><para>Passed as <code>dataset-location</code></para></td></tr><tr><td class="parameter_name"><para>key_id</para></td><td class="parameter_description"><para>the <type>GQuark</type> id to identify the data element.</para><para>Passed as <code>key-id</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-get-days-in-month</title><informalexample><programlisting>(define-values (%return) (date-get-days-in-month month year))
  5353. </programlisting></informalexample><para>Returns the number of days in a month, taking leap
  5354. years into account.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para>month</para><para>Passed as <code>month</code></para></td></tr><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>year</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-get-monday-weeks-in-year</title><informalexample><programlisting>(define-values (%return) (date-get-monday-weeks-in-year year))
  5355. </programlisting></informalexample><para>Returns the number of weeks in the year, where weeks
  5356. are taken to start on Monday. Will be 52 or 53. The
  5357. date must be valid. (Years always have 52 7-day periods,
  5358. plus 1 or 2 extra days depending on whether it's a leap
  5359. year. This function is basically telling you how many
  5360. Mondays are in the year, i.e. there are 53 Mondays if
  5361. one of the extra days happens to be a Monday.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>a year</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-get-sunday-weeks-in-year</title><informalexample><programlisting>(define-values (%return) (date-get-sunday-weeks-in-year year))
  5362. </programlisting></informalexample><para>Returns the number of weeks in the year, where weeks
  5363. are taken to start on Sunday. Will be 52 or 53. The
  5364. date must be valid. (Years always have 52 7-day periods,
  5365. plus 1 or 2 extra days depending on whether it's a leap
  5366. year. This function is basically telling you how many
  5367. Sundays are in the year, i.e. there are 53 Sundays if
  5368. one of the extra days happens to be a Sunday.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>year to count weeks in</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-is-leap-year?</title><informalexample><programlisting>(define-values (%return) (date-is-leap-year? year))
  5369. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the year is a leap year.
  5370. </para>
  5371. <para>For the purposes of this function, leap year is every year
  5372. divisible by 4 unless that year is divisible by 100. If it
  5373. is divisible by 100 it would be a leap year only if that year
  5374. is also divisible by 400.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>year to check</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-strftime</title><informalexample><programlisting>(define-values (%return) (date-strftime s slen format date))
  5375. </programlisting></informalexample><para>Generates a printed representation of the date, in a
  5376. [locale][setlocale]-specific way.
  5377. Works just like the platform's C library <function>strftime()</function> function,
  5378. but only accepts date-related formats; time-related formats
  5379. give undefined results. Date must be valid. Unlike <function>strftime()</function>
  5380. (which uses the locale encoding), works on a UTF-8 format
  5381. string and stores a UTF-8 result.
  5382. </para>
  5383. <para>This function does not provide any conversion specifiers in
  5384. addition to those implemented by the platform's C library.
  5385. For example, don't expect that using <function>g_date_strftime()</function> would
  5386. make the \%F provided by the C99 <function>strftime()</function> work on Windows
  5387. where the C library only complies to C89.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>s</para></td><td class="parameter_description"><para>destination buffer</para><para>Passed as <code>s</code></para></td></tr><tr><td class="parameter_name"><para>slen</para></td><td class="parameter_description"><para>buffer size</para><para>Passed as <code>slen</code></para></td></tr><tr><td class="parameter_name"><para>format</para></td><td class="parameter_description"><para>format string</para><para>Passed as <code>format</code></para></td></tr><tr><td class="parameter_name"><para>date</para></td><td class="parameter_description"><para>valid <type>GDate</type></para><para>Passed as <code>date</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time-compare</title><informalexample><programlisting>(define-values (%return) (date-time-compare dt1 dt2))
  5388. </programlisting></informalexample><para>A comparison function for <type>GDateTimes</type> that is suitable
  5389. as a <type>GCompareFunc</type>. Both <type>GDateTimes</type> must be non-<constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dt1</para></td><td class="parameter_description"><para>first <type>GDateTime</type> to compare</para><para>Passed as <code>dt1</code></para></td></tr><tr><td class="parameter_name"><para>dt2</para></td><td class="parameter_description"><para>second <type>GDateTime</type> to compare</para><para>Passed as <code>dt2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time-equal?</title><informalexample><programlisting>(define-values (%return) (date-time-equal? dt1 dt2))
  5390. </programlisting></informalexample><para>Checks to see if <parameter>dt1</parameter> and <parameter>dt2</parameter> are equal.
  5391. </para>
  5392. <para>Equal here means that they represent the same moment after converting
  5393. them to the same time zone.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dt1</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>dt1</code></para></td></tr><tr><td class="parameter_name"><para>dt2</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>dt2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-time-hash</title><informalexample><programlisting>(define-values (%return) (date-time-hash datetime))
  5394. </programlisting></informalexample><para>Hashes <parameter>datetime</parameter> into a <type>guint</type>, suitable for use within <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>datetime</para></td><td class="parameter_description"><para>a <type>GDateTime</type></para><para>Passed as <code>datetime</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-valid-day?</title><informalexample><programlisting>(define-values (%return) (date-valid-day? day))
  5395. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the day of the month is valid (a day is valid if it's
  5396. between 1 and 31 inclusive).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>day</para></td><td class="parameter_description"><para>day to check</para><para>Passed as <code>day</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-valid-dmy?</title><informalexample><programlisting>(define-values (%return) (date-valid-dmy? day month year))
  5397. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the day-month-year triplet forms a valid, existing day
  5398. in the range of days <type>GDate</type> understands (Year 1 or later, no more than
  5399. a few thousand years in the future).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>day</para></td><td class="parameter_description"><para>day</para><para>Passed as <code>day</code></para></td></tr><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para>month</para><para>Passed as <code>month</code></para></td></tr><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>year</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-valid-julian?</title><informalexample><programlisting>(define-values (%return) (date-valid-julian? julian-date))
  5400. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the Julian day is valid. Anything greater than zero
  5401. is basically a valid Julian, though there is a 32-bit limit.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>julian_date</para></td><td class="parameter_description"><para>Julian day to check</para><para>Passed as <code>julian-date</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-valid-month?</title><informalexample><programlisting>(define-values (%return) (date-valid-month? month))
  5402. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the month value is valid. The 12 <type>GDateMonth</type>
  5403. enumeration values are the only valid months.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>month</para></td><td class="parameter_description"><para>month</para><para>Passed as <code>month</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-valid-weekday?</title><informalexample><programlisting>(define-values (%return) (date-valid-weekday? weekday))
  5404. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the weekday is valid. The seven <type>GDateWeekday</type> enumeration
  5405. values are the only valid weekdays.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>weekday</para></td><td class="parameter_description"><para>weekday</para><para>Passed as <code>weekday</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>date-valid-year?</title><informalexample><programlisting>(define-values (%return) (date-valid-year? year))
  5406. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the year is valid. Any year greater than 0 is valid,
  5407. though there is a 16-bit limit to what <type>GDate</type> will understand.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>year</para></td><td class="parameter_description"><para>year</para><para>Passed as <code>year</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dcgettext</title><informalexample><programlisting>(define-values (%return) (dcgettext domain msgid category))
  5408. </programlisting></informalexample><para>This is a variant of <function>g_dgettext()</function> that allows specifying a locale
  5409. category instead of always using <code>LC_MESSAGES</code>. See <function>g_dgettext()</function> for
  5410. more information about how this functions differs from calling
  5411. <function>dcgettext()</function> directly.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para>the translation domain to use, or <constant>NULL</constant> to use
  5412. the domain set with <function>textdomain()</function></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>msgid</para></td><td class="parameter_description"><para>message to translate</para><para>Passed as <code>msgid</code></para></td></tr><tr><td class="parameter_name"><para>category</para></td><td class="parameter_description"><para>a locale category</para><para>Passed as <code>category</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dgettext</title><informalexample><programlisting>(define-values (%return) (dgettext domain msgid))
  5413. </programlisting></informalexample><para>This function is a wrapper of <function>dgettext()</function> which does not translate
  5414. the message if the default domain as set with <function>textdomain()</function> has no
  5415. translations for the current locale.
  5416. </para>
  5417. <para>The advantage of using this function over <function>dgettext()</function> proper is that
  5418. libraries using this function (like GTK+) will not use translations
  5419. if the application using the library does not have translations for
  5420. the current locale. This results in a consistent English-only
  5421. interface instead of one having partial translations. For this
  5422. feature to work, the call to <function>textdomain()</function> and <function>setlocale()</function> should
  5423. precede any <function>g_dgettext()</function> invocations. For GTK+, it means calling
  5424. <function>textdomain()</function> before gtk_init or its variants.
  5425. </para>
  5426. <para>This function disables translations if and only if upon its first
  5427. call all the following conditions hold:
  5428. </para>
  5429. <para>- <parameter>domain</parameter> is not <constant>NULL</constant>
  5430. </para>
  5431. <para>- <function>textdomain()</function> has been called to set a default text domain
  5432. </para>
  5433. <para>- there is no translations available for the default text domain
  5434. and the current locale
  5435. </para>
  5436. <para>- current locale is not &quot;C&quot; or any English locales (those
  5437. starting with &quot;en_&quot;)
  5438. </para>
  5439. <para>Note that this behavior may not be desired for example if an application
  5440. has its untranslated messages in a language other than English. In those
  5441. cases the application should call <function>textdomain()</function> after initializing GTK+.
  5442. </para>
  5443. <para>Applications should normally not use this function directly,
  5444. but use the <function>_()</function> macro for translations.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para>the translation domain to use, or <constant>NULL</constant> to use
  5445. the domain set with <function>textdomain()</function></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>msgid</para></td><td class="parameter_description"><para>message to translate</para><para>Passed as <code>msgid</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dir-make-tmp</title><informalexample><programlisting>(define-values (%return) (dir-make-tmp tmpl))
  5446. </programlisting></informalexample><para>Creates a subdirectory in the preferred directory for temporary
  5447. files (as returned by <function>g_get_tmp_dir()</function>).
  5448. </para>
  5449. <para><parameter>tmpl</parameter> should be a string in the GLib file name encoding containing
  5450. a sequence of six 'X' characters, as the parameter to <function>g_mkstemp()</function>.
  5451. However, unlike these functions, the template should only be a
  5452. basename, no directory components are allowed. If template is
  5453. <constant>NULL</constant>, a default template is used.
  5454. </para>
  5455. <para>Note that in contrast to <function>g_mkdtemp()</function> (and <function>mkdtemp()</function>) <parameter>tmpl</parameter> is not
  5456. modified, and might thus be a read-only literal string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tmpl</para></td><td class="parameter_description"><para>Template for directory name,
  5457. as in <function>g_mkdtemp()</function>, basename only, or <constant>NULL</constant> for a default template</para><para>Passed as <code>tmpl</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>direct-equal?</title><informalexample><programlisting>(define-values (%return) (direct-equal? v1 v2))
  5458. </programlisting></informalexample><para>Compares two <type>gpointer</type> arguments and returns <constant>TRUE</constant> if they are equal.
  5459. It can be passed to <function>g_hash_table_new()</function> as the <parameter>key_equal_func</parameter>
  5460. parameter, when using opaque pointers compared by pointer value as
  5461. keys in a <type>GHashTable</type>.
  5462. </para>
  5463. <para>This equality function is also appropriate for keys that are integers
  5464. stored in pointers, such as <code>GINT_TO_POINTER (n)</code>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>v1</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>v1</code></para></td></tr><tr><td class="parameter_name"><para>v2</para></td><td class="parameter_description"><para>a key to compare with <parameter>v1</parameter></para><para>Passed as <code>v2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>direct-hash</title><informalexample><programlisting>(define-values (%return) (direct-hash v))
  5465. </programlisting></informalexample><para>Converts a gpointer to a hash value.
  5466. It can be passed to <function>g_hash_table_new()</function> as the <parameter>hash_func</parameter> parameter,
  5467. when using opaque pointers compared by pointer value as keys in a
  5468. <type>GHashTable</type>.
  5469. </para>
  5470. <para>This hash function is also appropriate for keys that are integers
  5471. stored in pointers, such as <code>GINT_TO_POINTER (n)</code>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>v</para></td><td class="parameter_description"><para>a <type>gpointer</type> key</para><para>Passed as <code>v</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dngettext</title><informalexample><programlisting>(define-values (%return) (dngettext domain msgid msgid-plural n))
  5472. </programlisting></informalexample><para>This function is a wrapper of <function>dngettext()</function> which does not translate
  5473. the message if the default domain as set with <function>textdomain()</function> has no
  5474. translations for the current locale.
  5475. </para>
  5476. <para>See <function>g_dgettext()</function> for details of how this differs from <function>dngettext()</function>
  5477. proper.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para>the translation domain to use, or <constant>NULL</constant> to use
  5478. the domain set with <function>textdomain()</function></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>msgid</para></td><td class="parameter_description"><para>message to translate</para><para>Passed as <code>msgid</code></para></td></tr><tr><td class="parameter_name"><para>msgid_plural</para></td><td class="parameter_description"><para>plural form of the message</para><para>Passed as <code>msgid-plural</code></para></td></tr><tr><td class="parameter_name"><para>n</para></td><td class="parameter_description"><para>the quantity for which translation is needed</para><para>Passed as <code>n</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>double-equal?</title><informalexample><programlisting>(define-values (%return) (double-equal? v1 v2))
  5479. </programlisting></informalexample><para>Compares the two <type>gdouble</type> values being pointed to and returns
  5480. <constant>TRUE</constant> if they are equal.
  5481. It can be passed to <function>g_hash_table_new()</function> as the <parameter>key_equal_func</parameter>
  5482. parameter, when using non-<constant>NULL</constant> pointers to doubles as keys in a
  5483. <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>v1</para></td><td class="parameter_description"><para>a pointer to a <type>gdouble</type> key</para><para>Passed as <code>v1</code></para></td></tr><tr><td class="parameter_name"><para>v2</para></td><td class="parameter_description"><para>a pointer to a <type>gdouble</type> key to compare with <parameter>v1</parameter></para><para>Passed as <code>v2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>double-hash</title><informalexample><programlisting>(define-values (%return) (double-hash v))
  5484. </programlisting></informalexample><para>Converts a pointer to a <type>gdouble</type> to a hash value.
  5485. It can be passed to <function>g_hash_table_new()</function> as the <parameter>hash_func</parameter> parameter,
  5486. It can be passed to <function>g_hash_table_new()</function> as the <parameter>hash_func</parameter> parameter,
  5487. when using non-<constant>NULL</constant> pointers to doubles as keys in a <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>v</para></td><td class="parameter_description"><para>a pointer to a <type>gdouble</type> key</para><para>Passed as <code>v</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dpgettext</title><informalexample><programlisting>(define-values (%return) (dpgettext domain msgctxtid msgidoffset))
  5488. </programlisting></informalexample><para>This function is a variant of <function>g_dgettext()</function> which supports
  5489. a disambiguating message context. GNU gettext uses the
  5490. '\004' character to separate the message context and
  5491. message id in <parameter>msgctxtid</parameter>.
  5492. If 0 is passed as <parameter>msgidoffset</parameter>, this function will fall back to
  5493. trying to use the deprecated convention of using &quot;|&quot; as a separation
  5494. character.
  5495. </para>
  5496. <para>This uses <function>g_dgettext()</function> internally. See that functions for differences
  5497. with <function>dgettext()</function> proper.
  5498. </para>
  5499. <para>Applications should normally not use this function directly,
  5500. but use the <function>C_()</function> macro for translations with context.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para>the translation domain to use, or <constant>NULL</constant> to use
  5501. the domain set with <function>textdomain()</function></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>msgctxtid</para></td><td class="parameter_description"><para>a combined message context and message id, separated
  5502. by a \004 character</para><para>Passed as <code>msgctxtid</code></para></td></tr><tr><td class="parameter_name"><para>msgidoffset</para></td><td class="parameter_description"><para>the offset of the message id in <parameter>msgctxid</parameter></para><para>Passed as <code>msgidoffset</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>dpgettext2</title><informalexample><programlisting>(define-values (%return) (dpgettext2 domain context msgid))
  5503. </programlisting></informalexample><para>This function is a variant of <function>g_dgettext()</function> which supports
  5504. a disambiguating message context. GNU gettext uses the
  5505. '\004' character to separate the message context and
  5506. message id in <parameter>msgctxtid</parameter>.
  5507. </para>
  5508. <para>This uses <function>g_dgettext()</function> internally. See that functions for differences
  5509. with <function>dgettext()</function> proper.
  5510. </para>
  5511. <para>This function differs from <function>C_()</function> in that it is not a macro and
  5512. thus you may use non-string-literals as context and msgid arguments.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para>the translation domain to use, or <constant>NULL</constant> to use
  5513. the domain set with <function>textdomain()</function></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>context</para></td><td class="parameter_description"><para>the message context</para><para>Passed as <code>context</code></para></td></tr><tr><td class="parameter_name"><para>msgid</para></td><td class="parameter_description"><para>the message</para><para>Passed as <code>msgid</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>environ-getenv</title><informalexample><programlisting>(define-values (%return) (environ-getenv envp variable))
  5514. </programlisting></informalexample><para>Returns the value of the environment variable <parameter>variable</parameter> in the
  5515. provided list <parameter>envp</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>envp</para></td><td class="parameter_description"><para>
  5516. <para>an environment list (eg, as returned from <function>g_get_environ()</function>), or <constant>NULL</constant>
  5517. for an empty environment list</para></para><para>Passed as <code>envp</code></para></td></tr><tr><td class="parameter_name"><para>variable</para></td><td class="parameter_description"><para>the environment variable to get</para><para>Passed as <code>variable</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>environ-setenv</title><informalexample><programlisting>(define-values (%return) (environ-setenv envp variable value overwrite))
  5518. </programlisting></informalexample><para>Sets the environment variable <parameter>variable</parameter> in the provided list
  5519. <parameter>envp</parameter> to <parameter>value</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>envp</para></td><td class="parameter_description"><para>
  5520. <para>an environment list that can be freed using <function>g_strfreev()</function> (e.g., as
  5521. returned from <function>g_get_environ()</function>), or <constant>NULL</constant> for an empty
  5522. environment list</para></para><para>Passed as <code>envp</code></para></td></tr><tr><td class="parameter_name"><para>variable</para></td><td class="parameter_description"><para>the environment variable to set, must not
  5523. contain '='</para><para>Passed as <code>variable</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>the value for to set the variable to</para><para>Passed as <code>value</code></para></td></tr><tr><td class="parameter_name"><para>overwrite</para></td><td class="parameter_description"><para>whether to change the variable if it already exists</para><para>Passed as <code>overwrite</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>environ-unsetenv</title><informalexample><programlisting>(define-values (%return) (environ-unsetenv envp variable))
  5524. </programlisting></informalexample><para>Removes the environment variable <parameter>variable</parameter> from the provided
  5525. environment <parameter>envp</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>envp</para></td><td class="parameter_description"><para>
  5526. <para>an environment list that can be freed using <function>g_strfreev()</function> (e.g., as
  5527. returned from <function>g_get_environ()</function>), or <constant>NULL</constant> for an empty environment list</para></para><para>Passed as <code>envp</code></para></td></tr><tr><td class="parameter_name"><para>variable</para></td><td class="parameter_description"><para>the environment variable to remove, must not
  5528. contain '='</para><para>Passed as <code>variable</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>file-error-from-errno</title><informalexample><programlisting>(define-values (%return) (file-error-from-errno err-no))
  5529. </programlisting></informalexample><para>Gets a <type>GFileError</type> constant based on the passed-in <parameter>err_no</parameter>.
  5530. For example, if you pass in <code>EEXIST</code> this function returns
  5531. <type>G_FILE_ERROR_EXIST</type>. Unlike <code>errno</code> values, you can portably
  5532. assume that all <type>GFileError</type> values will exist.
  5533. </para>
  5534. <para>Normally a <type>GFileError</type> value goes into a <type>GError</type> returned
  5535. from a function that manipulates files. So you would use
  5536. <function>g_file_error_from_errno()</function> when constructing a <type>GError</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>err_no</para></td><td class="parameter_description"><para>an &quot;errno&quot; value</para><para>Passed as <code>err-no</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>file-error-quark</title><informalexample><programlisting>(define-values (%return) (file-error-quark))
  5537. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>file-get-contents</title><informalexample><programlisting>(define-values (%return contents length) (file-get-contents filename))
  5538. </programlisting></informalexample><para>Reads an entire file into allocated memory, with good error
  5539. checking.
  5540. </para>
  5541. <para>If the call was successful, it returns <constant>TRUE</constant> and sets <parameter>contents</parameter> to the file
  5542. contents and <parameter>length</parameter> to the length of the file contents in bytes. The string
  5543. stored in <parameter>contents</parameter> will be nul-terminated, so for text files you can pass
  5544. <constant>NULL</constant> for the <parameter>length</parameter> argument. If the call was not successful, it returns
  5545. <constant>FALSE</constant> and sets <parameter>error</parameter>. The error domain is <type>G_FILE_ERROR</type>. Possible error
  5546. codes are those in the <type>GFileError</type> enumeration. In the error case,
  5547. <parameter>contents</parameter> is set to <constant>NULL</constant> and <parameter>length</parameter> is set to zero.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>name of a file to read contents from, in the GLib file name encoding</para><para>Passed as <code>filename</code></para></td></tr><tr><td class="parameter_name"><para>contents</para></td><td class="parameter_description"><para>location to store an allocated string, use <function>g_free()</function> to free
  5548. the returned string</para><para>Passed as <code>contents</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>location to store length in bytes of the contents, or <constant>NULL</constant></para><para>Inferred from <code>contents</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>file-open-tmp</title><informalexample><programlisting>(define-values (%return name-used) (file-open-tmp tmpl))
  5549. </programlisting></informalexample><para>Opens a file for writing in the preferred directory for temporary
  5550. files (as returned by <function>g_get_tmp_dir()</function>).
  5551. </para>
  5552. <para><parameter>tmpl</parameter> should be a string in the GLib file name encoding containing
  5553. a sequence of six 'X' characters, as the parameter to <function>g_mkstemp()</function>.
  5554. However, unlike these functions, the template should only be a
  5555. basename, no directory components are allowed. If template is
  5556. <constant>NULL</constant>, a default template is used.
  5557. </para>
  5558. <para>Note that in contrast to <function>g_mkstemp()</function> (and <function>mkstemp()</function>) <parameter>tmpl</parameter> is not
  5559. modified, and might thus be a read-only literal string.
  5560. </para>
  5561. <para>Upon success, and if <parameter>name_used</parameter> is non-<constant>NULL</constant>, the actual name used
  5562. is returned in <parameter>name_used</parameter>. This string should be freed with <function>g_free()</function>
  5563. when not needed any longer. The returned name is in the GLib file
  5564. name encoding.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tmpl</para></td><td class="parameter_description"><para>Template for file name, as in
  5565. <function>g_mkstemp()</function>, basename only, or <constant>NULL</constant> for a default template</para><para>Passed as <code>tmpl</code></para></td></tr><tr><td class="parameter_name"><para>name_used</para></td><td class="parameter_description"><para>location to store actual name used,
  5566. or <constant>NULL</constant></para><para>Passed as <code>name-used</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>file-read-link</title><informalexample><programlisting>(define-values (%return) (file-read-link filename))
  5567. </programlisting></informalexample><para>Reads the contents of the symbolic link <parameter>filename</parameter> like the POSIX
  5568. <function>readlink()</function> function. The returned string is in the encoding used
  5569. for filenames. Use <function>g_filename_to_utf8()</function> to convert it to UTF-8.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>the symbolic link</para><para>Passed as <code>filename</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>file-set-contents?</title><informalexample><programlisting>(define-values (%return) (file-set-contents? filename contents))
  5570. </programlisting></informalexample><para>Writes all of <parameter>contents</parameter> to a file named <parameter>filename</parameter>. This is a convenience
  5571. wrapper around calling <function>g_file_set_contents()</function> with <code>flags</code> set to
  5572. <code>G_FILE_SET_CONTENTS_CONSISTENT | G_FILE_SET_CONTENTS_ONLY_EXISTING</code> and
  5573. <code>mode</code> set to <code>0666</code>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>name of a file to write <parameter>contents</parameter> to, in the GLib file name
  5574. encoding</para><para>Passed as <code>filename</code></para></td></tr><tr><td class="parameter_name"><para>contents</para></td><td class="parameter_description"><para>string to write to the file</para><para>Passed as <code>contents</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>length of <parameter>contents</parameter>, or -1 if <parameter>contents</parameter> is a nul-terminated string</para><para>Inferred from <code>contents</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>file-set-contents-full?</title><informalexample><programlisting>(define-values
  5575. (%return)
  5576. (file-set-contents-full? filename contents flags mode))
  5577. </programlisting></informalexample><para>Writes all of <parameter>contents</parameter> to a file named <parameter>filename</parameter>, with good error checking.
  5578. If a file called <parameter>filename</parameter> already exists it will be overwritten.
  5579. </para>
  5580. <para><parameter>flags</parameter> control the properties of the write operation: whether it’s atomic,
  5581. and what the tradeoff is between returning quickly or being resilient to
  5582. system crashes.
  5583. </para>
  5584. <para>As this function performs file I/O, it is recommended to not call it anywhere
  5585. where blocking would cause problems, such as in the main loop of a graphical
  5586. application. In particular, if <parameter>flags</parameter> has any value other than
  5587. <constant>G_FILE_SET_CONTENTS_NONE</constant> then this function may call <code>fsync()</code>.
  5588. </para>
  5589. <para>If <constant>G_FILE_SET_CONTENTS_CONSISTENT</constant> is set in <parameter>flags</parameter>, the operation is atomic
  5590. in the sense that it is first written to a temporary file which is then
  5591. renamed to the final name.
  5592. </para>
  5593. <para>Notes:
  5594. </para>
  5595. <para>- On UNIX, if <parameter>filename</parameter> already exists hard links to <parameter>filename</parameter> will break.
  5596. Also since the file is recreated, existing permissions, access control
  5597. lists, metadata etc. may be lost. If <parameter>filename</parameter> is a symbolic link,
  5598. the link itself will be replaced, not the linked file.
  5599. </para>
  5600. <para>- On UNIX, if <parameter>filename</parameter> already exists and is non-empty, and if the system
  5601. supports it (via a journalling filesystem or equivalent), and if
  5602. <constant>G_FILE_SET_CONTENTS_CONSISTENT</constant> is set in <parameter>flags</parameter>, the <code>fsync()</code> call (or
  5603. equivalent) will be used to ensure atomic replacement: <parameter>filename</parameter>
  5604. will contain either its old contents or <parameter>contents</parameter>, even in the face of
  5605. system power loss, the disk being unsafely removed, etc.
  5606. </para>
  5607. <para>- On UNIX, if <parameter>filename</parameter> does not already exist or is empty, there is a
  5608. possibility that system power loss etc. after calling this function will
  5609. leave <parameter>filename</parameter> empty or full of NUL bytes, depending on the underlying
  5610. filesystem, unless <constant>G_FILE_SET_CONTENTS_DURABLE</constant> and
  5611. <constant>G_FILE_SET_CONTENTS_CONSISTENT</constant> are set in <parameter>flags</parameter>.
  5612. </para>
  5613. <para>- On Windows renaming a file will not remove an existing file with the
  5614. new name, so on Windows there is a race condition between the existing
  5615. file being removed and the temporary file being renamed.
  5616. </para>
  5617. <para>- On Windows there is no way to remove a file that is open to some
  5618. process, or mapped into memory. Thus, this function will fail if
  5619. <parameter>filename</parameter> already exists and is open.
  5620. </para>
  5621. <para>If the call was successful, it returns <constant>TRUE</constant>. If the call was not successful,
  5622. it returns <constant>FALSE</constant> and sets <parameter>error</parameter>. The error domain is <type>G_FILE_ERROR</type>.
  5623. Possible error codes are those in the <type>GFileError</type> enumeration.
  5624. </para>
  5625. <para>Note that the name for the temporary file is constructed by appending up
  5626. to 7 characters to <parameter>filename</parameter>.
  5627. </para>
  5628. <para>If the file didn’t exist before and is created, it will be given the
  5629. permissions from <parameter>mode</parameter>. Otherwise, the permissions of the existing file may
  5630. be changed to <parameter>mode</parameter> depending on <parameter>flags</parameter>, or they may remain unchanged.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>name of a file to write <parameter>contents</parameter> to, in the GLib file name
  5631. encoding</para><para>Passed as <code>filename</code></para></td></tr><tr><td class="parameter_name"><para>contents</para></td><td class="parameter_description"><para>string to write to the file</para><para>Passed as <code>contents</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>length of <parameter>contents</parameter>, or -1 if <parameter>contents</parameter> is a nul-terminated string</para><para>Inferred from <code>contents</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags controlling the safety vs speed of the operation</para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>mode</para></td><td class="parameter_description"><para>file mode, as passed to <code>open()</code>; typically this will be <code>0666</code></para><para>Passed as <code>mode</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>file-test?</title><informalexample><programlisting>(define-values (%return) (file-test? filename test))
  5632. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if any of the tests in the bitfield <parameter>test</parameter> are
  5633. <constant>TRUE</constant>. For example, <code>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)</code>
  5634. will return <constant>TRUE</constant> if the file exists; the check whether it's a
  5635. directory doesn't matter since the existence test is <constant>TRUE</constant>. With
  5636. the current set of available tests, there's no point passing in
  5637. more than one test at a time.
  5638. </para>
  5639. <para>Apart from <constant>G_FILE_TEST_IS_SYMLINK</constant> all tests follow symbolic links,
  5640. so for a symbolic link to a regular file <function>g_file_test()</function> will return
  5641. <constant>TRUE</constant> for both <constant>G_FILE_TEST_IS_SYMLINK</constant> and <constant>G_FILE_TEST_IS_REGULAR</constant>.
  5642. </para>
  5643. <para>Note, that for a dangling symbolic link <function>g_file_test()</function> will return
  5644. <constant>TRUE</constant> for <constant>G_FILE_TEST_IS_SYMLINK</constant> and <constant>FALSE</constant> for all other flags.
  5645. </para>
  5646. <para>You should never use <function>g_file_test()</function> to test whether it is safe
  5647. to perform an operation, because there is always the possibility
  5648. of the condition changing before you actually perform the operation.
  5649. For example, you might think you could use <constant>G_FILE_TEST_IS_SYMLINK</constant>
  5650. to know whether it is safe to write to a file without being
  5651. tricked into writing into a different location. It doesn't work!
  5652. <informalexample><programlisting>
  5653. // DON'T DO THIS
  5654. if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
  5655. {
  5656. fd = g_open (filename, O_WRONLY);
  5657. // write to fd
  5658. }
  5659. </programlisting></informalexample></para>
  5660. <para>Another thing to note is that <constant>G_FILE_TEST_EXISTS</constant> and
  5661. <constant>G_FILE_TEST_IS_EXECUTABLE</constant> are implemented using the <function>access()</function>
  5662. system call. This usually doesn't matter, but if your program
  5663. is setuid or setgid it means that these tests will give you
  5664. the answer for the real user ID and group ID, rather than the
  5665. effective user ID and group ID.
  5666. </para>
  5667. <para>On Windows, there are no symlinks, so testing for
  5668. <constant>G_FILE_TEST_IS_SYMLINK</constant> will always return <constant>FALSE</constant>. Testing for
  5669. <constant>G_FILE_TEST_IS_EXECUTABLE</constant> will just check that the file exists and
  5670. its name indicates that it is executable, checking for well-known
  5671. extensions and those listed in the <code>PATHEXT</code> environment variable.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>a filename to test in the
  5672. GLib file name encoding</para><para>Passed as <code>filename</code></para></td></tr><tr><td class="parameter_name"><para>test</para></td><td class="parameter_description"><para>bitfield of <type>GFileTest</type> flags</para><para>Passed as <code>test</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>filename-display-basename</title><informalexample><programlisting>(define-values (%return) (filename-display-basename filename))
  5673. </programlisting></informalexample><para>Returns the display basename for the particular filename, guaranteed
  5674. to be valid UTF-8. The display name might not be identical to the filename,
  5675. for instance there might be problems converting it to UTF-8, and some files
  5676. can be translated in the display.
  5677. </para>
  5678. <para>If GLib cannot make sense of the encoding of <parameter>filename</parameter>, as a last resort it
  5679. replaces unknown characters with U+FFFD, the Unicode replacement character.
  5680. You can search the result for the UTF-8 encoding of this character (which is
  5681. &quot;\357\277\275&quot; in octal notation) to find out if <parameter>filename</parameter> was in an invalid
  5682. encoding.
  5683. </para>
  5684. <para>You must pass the whole absolute pathname to this functions so that
  5685. translation of well known locations can be done.
  5686. </para>
  5687. <para>This function is preferred over <function>g_filename_display_name()</function> if you know the
  5688. whole path, as it allows translation.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>an absolute pathname in the
  5689. GLib file name encoding</para><para>Passed as <code>filename</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>filename-display-name</title><informalexample><programlisting>(define-values (%return) (filename-display-name filename))
  5690. </programlisting></informalexample><para>Converts a filename into a valid UTF-8 string. The conversion is
  5691. not necessarily reversible, so you should keep the original around
  5692. and use the return value of this function only for display purposes.
  5693. Unlike <function>g_filename_to_utf8()</function>, the result is guaranteed to be non-<constant>NULL</constant>
  5694. even if the filename actually isn't in the GLib file name encoding.
  5695. </para>
  5696. <para>If GLib cannot make sense of the encoding of <parameter>filename</parameter>, as a last resort it
  5697. replaces unknown characters with U+FFFD, the Unicode replacement character.
  5698. You can search the result for the UTF-8 encoding of this character (which is
  5699. &quot;\357\277\275&quot; in octal notation) to find out if <parameter>filename</parameter> was in an invalid
  5700. encoding.
  5701. </para>
  5702. <para>If you know the whole pathname of the file you should use
  5703. <function>g_filename_display_basename()</function>, since that allows location-based
  5704. translation of filenames.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>a pathname hopefully in the
  5705. GLib file name encoding</para><para>Passed as <code>filename</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>filename-from-uri</title><informalexample><programlisting>(define-values (%return hostname) (filename-from-uri uri))
  5706. </programlisting></informalexample><para>Converts an escaped ASCII-encoded URI to a local filename in the
  5707. encoding used for filenames.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a uri describing a filename (escaped, encoded in ASCII).</para><para>Passed as <code>uri</code></para></td></tr><tr><td class="parameter_name"><para>hostname</para></td><td class="parameter_description"><para>Location to store hostname for the URI.
  5708. If there is no hostname in the URI, <constant>NULL</constant> will be
  5709. stored in this location.</para><para>Passed as <code>hostname</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>filename-from-utf8</title><informalexample><programlisting>(define-values
  5710. (%return bytes-read bytes-written)
  5711. (filename-from-utf8 utf8string len))
  5712. </programlisting></informalexample><para>Converts a string from UTF-8 to the encoding GLib uses for
  5713. filenames. Note that on Windows GLib uses UTF-8 for filenames;
  5714. on other platforms, this function indirectly depends on the
  5715. [current locale][setlocale].
  5716. </para>
  5717. <para>The input string shall not contain nul characters even if the <parameter>len</parameter>
  5718. argument is positive. A nul character found inside the string will result
  5719. in error <constant>G_CONVERT_ERROR_ILLEGAL_SEQUENCE</constant>. If the filename encoding is
  5720. not UTF-8 and the conversion output contains a nul character, the error
  5721. <constant>G_CONVERT_ERROR_EMBEDDED_NUL</constant> is set and the function returns <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>utf8string</para></td><td class="parameter_description"><para>a UTF-8 encoded string.</para><para>Passed as <code>utf8string</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the length of the string, or -1 if the string is
  5722. nul-terminated.</para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>bytes_read</para></td><td class="parameter_description"><para>location to store the number of bytes in
  5723. the input string that were successfully converted, or <constant>NULL</constant>.
  5724. Even if the conversion was successful, this may be
  5725. less than <parameter>len</parameter> if there were partial characters
  5726. at the end of the input. If the error
  5727. <constant>G_CONVERT_ERROR_ILLEGAL_SEQUENCE</constant> occurs, the value
  5728. stored will be the byte offset after the last valid
  5729. input sequence.</para><para>Passed as <code>bytes-read</code></para></td></tr><tr><td class="parameter_name"><para>bytes_written</para></td><td class="parameter_description"><para>the number of bytes stored in
  5730. the output buffer (not including the terminating nul).</para><para>Passed as <code>bytes-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>filename-to-uri</title><informalexample><programlisting>(define-values (%return) (filename-to-uri filename hostname))
  5731. </programlisting></informalexample><para>Converts an absolute filename to an escaped ASCII-encoded URI, with the path
  5732. component following Section 3.3. of RFC 2396.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>an absolute filename specified in the GLib file
  5733. name encoding, which is the on-disk file name bytes on Unix, and UTF-8
  5734. on Windows</para><para>Passed as <code>filename</code></para></td></tr><tr><td class="parameter_name"><para>hostname</para></td><td class="parameter_description"><para>A UTF-8 encoded hostname, or <constant>NULL</constant> for none.</para><para>Passed as <code>hostname</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>filename-to-utf8</title><informalexample><programlisting>(define-values
  5735. (%return bytes-read bytes-written)
  5736. (filename-to-utf8 opsysstring len))
  5737. </programlisting></informalexample><para>Converts a string which is in the encoding used by GLib for
  5738. filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8
  5739. for filenames; on other platforms, this function indirectly depends on
  5740. the [current locale][setlocale].
  5741. </para>
  5742. <para>The input string shall not contain nul characters even if the <parameter>len</parameter>
  5743. argument is positive. A nul character found inside the string will result
  5744. in error <constant>G_CONVERT_ERROR_ILLEGAL_SEQUENCE</constant>.
  5745. If the source encoding is not UTF-8 and the conversion output contains a
  5746. nul character, the error <constant>G_CONVERT_ERROR_EMBEDDED_NUL</constant> is set and the
  5747. function returns <constant>NULL</constant>. Use <function>g_convert()</function> to produce output that
  5748. may contain embedded nul characters.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>opsysstring</para></td><td class="parameter_description"><para>a string in the encoding for filenames</para><para>Passed as <code>opsysstring</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the length of the string, or -1 if the string is
  5749. nul-terminated (Note that some encodings may allow nul
  5750. bytes to occur inside strings. In that case, using -1
  5751. for the <parameter>len</parameter> parameter is unsafe)</para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>bytes_read</para></td><td class="parameter_description"><para>location to store the number of bytes in the
  5752. input string that were successfully converted, or <constant>NULL</constant>.
  5753. Even if the conversion was successful, this may be
  5754. less than <parameter>len</parameter> if there were partial characters
  5755. at the end of the input. If the error
  5756. <constant>G_CONVERT_ERROR_ILLEGAL_SEQUENCE</constant> occurs, the value
  5757. stored will be the byte offset after the last valid
  5758. input sequence.</para><para>Passed as <code>bytes-read</code></para></td></tr><tr><td class="parameter_name"><para>bytes_written</para></td><td class="parameter_description"><para>the number of bytes stored in the output
  5759. buffer (not including the terminating nul).</para><para>Passed as <code>bytes-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>find-program-in-path</title><informalexample><programlisting>(define-values (%return) (find-program-in-path program))
  5760. </programlisting></informalexample><para>Locates the first executable named <parameter>program</parameter> in the user's path, in the
  5761. same way that <function>execvp()</function> would locate it. Returns an allocated string
  5762. with the absolute path name, or <constant>NULL</constant> if the program is not found in
  5763. the path. If <parameter>program</parameter> is already an absolute path, returns a copy of
  5764. <parameter>program</parameter> if <parameter>program</parameter> exists and is executable, and <constant>NULL</constant> otherwise.
  5765. On Windows, if <parameter>program</parameter> does not have a file type suffix, tries
  5766. with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
  5767. the <code>PATHEXT</code> environment variable.
  5768. </para>
  5769. <para>On Windows, it looks for the file in the same way as <function>CreateProcess()</function>
  5770. would. This means first in the directory where the executing
  5771. program was loaded from, then in the current directory, then in the
  5772. Windows 32-bit system directory, then in the Windows directory, and
  5773. finally in the directories in the <code>PATH</code> environment variable. If
  5774. the program is found, the return value contains the full name
  5775. including the type suffix.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>program</para></td><td class="parameter_description"><para>a program name in the GLib file name encoding</para><para>Passed as <code>program</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>format-size</title><informalexample><programlisting>(define-values (%return) (format-size size))
  5776. </programlisting></informalexample><para>Formats a size (for example the size of a file) into a human readable
  5777. string. Sizes are rounded to the nearest size prefix (kB, MB, GB)
  5778. and are displayed rounded to the nearest tenth. E.g. the file size
  5779. 3292528 bytes will be converted into the string &quot;3.2 MB&quot;. The returned string
  5780. is UTF-8, and may use a non-breaking space to separate the number and units,
  5781. to ensure they aren’t separated when line wrapped.
  5782. </para>
  5783. <para>The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
  5784. </para>
  5785. <para>This string should be freed with <function>g_free()</function> when not needed any longer.
  5786. </para>
  5787. <para>See <function>g_format_size_full()</function> for more options about how the size might be
  5788. formatted.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>size</para></td><td class="parameter_description"><para>a size in bytes</para><para>Passed as <code>size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>format-size-full</title><informalexample><programlisting>(define-values (%return) (format-size-full size flags))
  5789. </programlisting></informalexample><para>Formats a size.
  5790. </para>
  5791. <para>This function is similar to <function>g_format_size()</function> but allows for flags
  5792. that modify the output. See <type>GFormatSizeFlags</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>size</para></td><td class="parameter_description"><para>a size in bytes</para><para>Passed as <code>size</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para><type>GFormatSizeFlags</type> to modify the output</para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-application-name</title><informalexample><programlisting>(define-values (%return) (get-application-name))
  5793. </programlisting></informalexample><para>Gets a human-readable name for the application, as set by
  5794. <function>g_set_application_name()</function>. This name should be localized if
  5795. possible, and is intended for display to the user. Contrast with
  5796. <function>g_get_prgname()</function>, which gets a non-localized name. If
  5797. <function>g_set_application_name()</function> has not been called, returns the result of
  5798. <function>g_get_prgname()</function> (which may be <constant>NULL</constant> if <function>g_set_prgname()</function> has also not
  5799. been called).</para></refsect2><refsect2><title>get-charset</title><informalexample><programlisting>(define-values (%return charset) (get-charset))
  5800. </programlisting></informalexample><para>Obtains the character set for the [current locale][setlocale]; you
  5801. might use this character set as an argument to <function>g_convert()</function>, to convert
  5802. from the current locale's encoding to some other encoding. (Frequently
  5803. <function>g_locale_to_utf8()</function> and <function>g_locale_from_utf8()</function> are nice shortcuts, though.)
  5804. </para>
  5805. <para>On Windows the character set returned by this function is the
  5806. so-called system default ANSI code-page. That is the character set
  5807. used by the &quot;narrow&quot; versions of C library and Win32 functions that
  5808. handle file names. It might be different from the character set
  5809. used by the C library's current locale.
  5810. </para>
  5811. <para>On Linux, the character set is found by consulting <function>nl_langinfo()</function> if
  5812. available. If not, the environment variables <code>LC_ALL</code>, <code>LC_CTYPE</code>, <code>LANG</code>
  5813. and <code>CHARSET</code> are queried in order.
  5814. </para>
  5815. <para>The return value is <constant>TRUE</constant> if the locale's encoding is UTF-8, in that
  5816. case you can perhaps avoid calling <function>g_convert()</function>.
  5817. </para>
  5818. <para>The string returned in <parameter>charset</parameter> is not allocated, and should not be
  5819. freed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>charset</para></td><td class="parameter_description"><para>return location for character set
  5820. name, or <constant>NULL</constant>.</para><para>Passed as <code>charset</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-codeset</title><informalexample><programlisting>(define-values (%return) (get-codeset))
  5821. </programlisting></informalexample><para>Gets the character set for the current locale.</para></refsect2><refsect2><title>get-console-charset</title><informalexample><programlisting>(define-values (%return charset) (get-console-charset))
  5822. </programlisting></informalexample><para>Obtains the character set used by the console attached to the process,
  5823. which is suitable for printing output to the terminal.
  5824. </para>
  5825. <para>Usually this matches the result returned by <function>g_get_charset()</function>, but in
  5826. environments where the locale's character set does not match the encoding
  5827. of the console this function tries to guess a more suitable value instead.
  5828. </para>
  5829. <para>On Windows the character set returned by this function is the
  5830. output code page used by the console associated with the calling process.
  5831. If the codepage can't be determined (for example because there is no
  5832. console attached) UTF-8 is assumed.
  5833. </para>
  5834. <para>The return value is <constant>TRUE</constant> if the locale's encoding is UTF-8, in that
  5835. case you can perhaps avoid calling <function>g_convert()</function>.
  5836. </para>
  5837. <para>The string returned in <parameter>charset</parameter> is not allocated, and should not be
  5838. freed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>charset</para></td><td class="parameter_description"><para>return location for character set
  5839. name, or <constant>NULL</constant>.</para><para>Passed as <code>charset</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-current-dir</title><informalexample><programlisting>(define-values (%return) (get-current-dir))
  5840. </programlisting></informalexample><para>Gets the current directory.
  5841. </para>
  5842. <para>The returned string should be freed when no longer needed.
  5843. The encoding of the returned string is system defined.
  5844. On Windows, it is always UTF-8.
  5845. </para>
  5846. <para>Since GLib 2.40, this function will return the value of the &quot;PWD&quot;
  5847. environment variable if it is set and it happens to be the same as
  5848. the current directory. This can make a difference in the case that
  5849. the current directory is the target of a symbolic link.</para></refsect2><refsect2><title>get-environ</title><informalexample><programlisting>(define-values (%return) (get-environ))
  5850. </programlisting></informalexample><para>Gets the list of environment variables for the current process.
  5851. </para>
  5852. <para>The list is <constant>NULL</constant> terminated and each item in the list is of the
  5853. form 'NAME=VALUE'.
  5854. </para>
  5855. <para>This is equivalent to direct access to the 'environ' global variable,
  5856. except portable.
  5857. </para>
  5858. <para>The return value is freshly allocated and it should be freed with
  5859. <function>g_strfreev()</function> when it is no longer needed.</para></refsect2><refsect2><title>get-filename-charsets</title><informalexample><programlisting>(define-values (%return filename-charsets) (get-filename-charsets))
  5860. </programlisting></informalexample><para>Determines the preferred character sets used for filenames.
  5861. The first character set from the <parameter>charsets</parameter> is the filename encoding, the
  5862. subsequent character sets are used when trying to generate a displayable
  5863. representation of a filename, see <function>g_filename_display_name()</function>.
  5864. </para>
  5865. <para>On Unix, the character sets are determined by consulting the
  5866. environment variables <code>G_FILENAME_ENCODING</code> and <code>G_BROKEN_FILENAMES</code>.
  5867. On Windows, the character set used in the GLib API is always UTF-8
  5868. and said environment variables have no effect.
  5869. </para>
  5870. <para><code>G_FILENAME_ENCODING</code> may be set to a comma-separated list of
  5871. character set names. The special token &quot;\@locale&quot; is taken
  5872. to mean the character set for the [current locale][setlocale].
  5873. If <code>G_FILENAME_ENCODING</code> is not set, but <code>G_BROKEN_FILENAMES</code> is,
  5874. the character set of the current locale is taken as the filename
  5875. encoding. If neither environment variable is set, UTF-8 is taken
  5876. as the filename encoding, but the character set of the current locale
  5877. is also put in the list of encodings.
  5878. </para>
  5879. <para>The returned <parameter>charsets</parameter> belong to GLib and must not be freed.
  5880. </para>
  5881. <para>Note that on Unix, regardless of the locale character set or
  5882. <code>G_FILENAME_ENCODING</code> value, the actual file names present
  5883. on a system might be in any random encoding or just gibberish.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename_charsets</para></td><td class="parameter_description"><para>
  5884. <para>return location for the <constant>NULL</constant>-terminated list of encoding names</para></para><para>Passed as <code>filename-charsets</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-home-dir</title><informalexample><programlisting>(define-values (%return) (get-home-dir))
  5885. </programlisting></informalexample><para>Gets the current user's home directory.
  5886. </para>
  5887. <para>As with most UNIX tools, this function will return the value of the
  5888. <code>HOME</code> environment variable if it is set to an existing absolute path
  5889. name, falling back to the <code>passwd</code> file in the case that it is unset.
  5890. </para>
  5891. <para>If the path given in <code>HOME</code> is non-absolute, does not exist, or is
  5892. not a directory, the result is undefined.
  5893. </para>
  5894. <para>Before version 2.36 this function would ignore the <code>HOME</code> environment
  5895. variable, taking the value from the <code>passwd</code> database instead. This was
  5896. changed to increase the compatibility of GLib with other programs (and
  5897. the XDG basedir specification) and to increase testability of programs
  5898. based on GLib (by making it easier to run them from test frameworks).
  5899. </para>
  5900. <para>If your program has a strong requirement for either the new or the
  5901. old behaviour (and if you don't wish to increase your GLib
  5902. dependency to ensure that the new behaviour is in effect) then you
  5903. should either directly check the <code>HOME</code> environment variable yourself
  5904. or unset it before calling any functions in GLib.</para></refsect2><refsect2><title>get-host-name</title><informalexample><programlisting>(define-values (%return) (get-host-name))
  5905. </programlisting></informalexample><para>Return a name for the machine.
  5906. </para>
  5907. <para>The returned name is not necessarily a fully-qualified domain name,
  5908. or even present in DNS or some other name service at all. It need
  5909. not even be unique on your local network or site, but usually it
  5910. is. Callers should not rely on the return value having any specific
  5911. properties like uniqueness for security purposes. Even if the name
  5912. of the machine is changed while an application is running, the
  5913. return value from this function does not change. The returned
  5914. string is owned by GLib and should not be modified or freed. If no
  5915. name can be determined, a default fixed string &quot;localhost&quot; is
  5916. returned.
  5917. </para>
  5918. <para>The encoding of the returned string is UTF-8.</para></refsect2><refsect2><title>get-language-names</title><informalexample><programlisting>(define-values (%return) (get-language-names))
  5919. </programlisting></informalexample><para>Computes a list of applicable locale names, which can be used to
  5920. e.g. construct locale-dependent filenames or search paths. The returned
  5921. list is sorted from most desirable to least desirable and always contains
  5922. the default locale &quot;C&quot;.
  5923. </para>
  5924. <para>For example, if LANGUAGE=de:en_US, then the returned list is
  5925. &quot;de&quot;, &quot;en_US&quot;, &quot;en&quot;, &quot;C&quot;.
  5926. </para>
  5927. <para>This function consults the environment variables <code>LANGUAGE</code>, <code>LC_ALL</code>,
  5928. <code>LC_MESSAGES</code> and <code>LANG</code> to find the list of locales specified by the
  5929. user.</para></refsect2><refsect2><title>get-language-names-with-category</title><informalexample><programlisting>(define-values (%return) (get-language-names-with-category category-name))
  5930. </programlisting></informalexample><para>Computes a list of applicable locale names with a locale category name,
  5931. which can be used to construct the fallback locale-dependent filenames
  5932. or search paths. The returned list is sorted from most desirable to
  5933. least desirable and always contains the default locale &quot;C&quot;.
  5934. </para>
  5935. <para>This function consults the environment variables <code>LANGUAGE</code>, <code>LC_ALL</code>,
  5936. <parameter>category_name</parameter>, and <code>LANG</code> to find the list of locales specified by the
  5937. user.
  5938. </para>
  5939. <para><function>g_get_language_names()</function> returns g_get_language_names_with_category(&quot;LC_MESSAGES&quot;).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>category_name</para></td><td class="parameter_description"><para>a locale category name</para><para>Passed as <code>category-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-locale-variants</title><informalexample><programlisting>(define-values (%return) (get-locale-variants locale))
  5940. </programlisting></informalexample><para>Returns a list of derived variants of <parameter>locale</parameter>, which can be used to
  5941. e.g. construct locale-dependent filenames or search paths. The returned
  5942. list is sorted from most desirable to least desirable.
  5943. This function handles territory, charset and extra locale modifiers. See
  5944. [<code>setlocale(3)</code>](man:setlocale) for information about locales and their format.
  5945. </para>
  5946. <para><parameter>locale</parameter> itself is guaranteed to be returned in the output.
  5947. </para>
  5948. <para>For example, if <parameter>locale</parameter> is <code>fr_BE</code>, then the returned list
  5949. is <code>fr_BE</code>, <code>fr</code>. If <parameter>locale</parameter> is <code>en_GB.UTF-8@euro</code>, then the returned list
  5950. is <code>en_GB.UTF-8@euro</code>, <code>en_GB.UTF-8</code>, <code>en_GB@euro</code>, <code>en_GB</code>, <code>en.UTF-8@euro</code>,
  5951. <code>en.UTF-8</code>, <code>en@euro</code>, <code>en</code>.
  5952. </para>
  5953. <para>If you need the list of variants for the current locale,
  5954. use <function>g_get_language_names()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>locale</para></td><td class="parameter_description"><para>a locale identifier</para><para>Passed as <code>locale</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-monotonic-time</title><informalexample><programlisting>(define-values (%return) (get-monotonic-time))
  5955. </programlisting></informalexample><para>Queries the system monotonic time.
  5956. </para>
  5957. <para>The monotonic clock will always increase and doesn't suffer
  5958. discontinuities when the user (or NTP) changes the system time. It
  5959. may or may not continue to tick during times where the machine is
  5960. suspended.
  5961. </para>
  5962. <para>We try to use the clock that corresponds as closely as possible to
  5963. the passage of time as measured by system calls such as <function>poll()</function> but it
  5964. may not always be possible to do this.</para></refsect2><refsect2><title>get-num-processors</title><informalexample><programlisting>(define-values (%return) (get-num-processors))
  5965. </programlisting></informalexample><para>Determine the approximate number of threads that the system will
  5966. schedule simultaneously for this process. This is intended to be
  5967. used as a parameter to <function>g_thread_pool_new()</function> for CPU bound tasks and
  5968. similar cases.</para></refsect2><refsect2><title>get-os-info</title><informalexample><programlisting>(define-values (%return) (get-os-info key-name))
  5969. </programlisting></informalexample><para>Get information about the operating system.
  5970. </para>
  5971. <para>On Linux this comes from the <code>/etc/os-release</code> file. On other systems, it may
  5972. come from a variety of sources. You can either use the standard key names
  5973. like <constant>G_OS_INFO_KEY_NAME</constant> or pass any UTF-8 string key name. For example,
  5974. <code>/etc/os-release</code> provides a number of other less commonly used values that may
  5975. be useful. No key is guaranteed to be provided, so the caller should always
  5976. check if the result is <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>key_name</para></td><td class="parameter_description"><para>a key for the OS info being requested, for example <constant>G_OS_INFO_KEY_NAME</constant>.</para><para>Passed as <code>key-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>get-prgname</title><informalexample><programlisting>(define-values (%return) (get-prgname))
  5977. </programlisting></informalexample><para>Gets the name of the program. This name should not be localized,
  5978. in contrast to <function>g_get_application_name()</function>.
  5979. </para>
  5980. <para>If you are using <type>GApplication</type> the program name is set in
  5981. <function>g_application_run()</function>. In case of GDK or GTK+ it is set in
  5982. <function>gdk_init()</function>, which is called by <function>gtk_init()</function> and the
  5983. <type>“startup”</type> handler. The program name is found by
  5984. taking the last component of <parameter>argv</parameter>[0].</para></refsect2><refsect2><title>get-real-name</title><informalexample><programlisting>(define-values (%return) (get-real-name))
  5985. </programlisting></informalexample><para>Gets the real name of the user. This usually comes from the user's
  5986. entry in the <code>passwd</code> file. The encoding of the returned string is
  5987. system-defined. (On Windows, it is, however, always UTF-8.) If the
  5988. real user name cannot be determined, the string &quot;Unknown&quot; is
  5989. returned.</para></refsect2><refsect2><title>get-real-time</title><informalexample><programlisting>(define-values (%return) (get-real-time))
  5990. </programlisting></informalexample><para>Queries the system wall-clock time.
  5991. </para>
  5992. <para>This call is functionally equivalent to <function>g_get_current_time()</function> except
  5993. that the return value is often more convenient than dealing with a
  5994. <type>GTimeVal</type>.
  5995. </para>
  5996. <para>You should only use this call if you are actually interested in the real
  5997. wall-clock time. <function>g_get_monotonic_time()</function> is probably more useful for
  5998. measuring intervals.</para></refsect2><refsect2><title>get-system-config-dirs</title><informalexample><programlisting>(define-values (%return) (get-system-config-dirs))
  5999. </programlisting></informalexample><para>Returns an ordered list of base directories in which to access
  6000. system-wide configuration information.
  6001. </para>
  6002. <para>On UNIX platforms this is determined using the mechanisms described
  6003. in the
  6004. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
  6005. In this case the list of directories retrieved will be <code>XDG_CONFIG_DIRS</code>.
  6006. </para>
  6007. <para>On Windows it follows XDG Base Directory Specification if <code>XDG_CONFIG_DIRS</code> is defined.
  6008. If <code>XDG_CONFIG_DIRS</code> is undefined, the directory that contains application
  6009. data for all users is used instead. A typical path is
  6010. <code>C:\Documents and Settings\All Users\Application Data</code>.
  6011. This folder is used for application data
  6012. that is not user specific. For example, an application can store
  6013. a spell-check dictionary, a database of clip art, or a log file in the
  6014. CSIDL_COMMON_APPDATA folder. This information will not roam and is available
  6015. to anyone using the computer.</para></refsect2><refsect2><title>get-system-data-dirs</title><informalexample><programlisting>(define-values (%return) (get-system-data-dirs))
  6016. </programlisting></informalexample><para>Returns an ordered list of base directories in which to access
  6017. system-wide application data.
  6018. </para>
  6019. <para>On UNIX platforms this is determined using the mechanisms described
  6020. in the
  6021. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec)
  6022. In this case the list of directories retrieved will be <code>XDG_DATA_DIRS</code>.
  6023. </para>
  6024. <para>On Windows it follows XDG Base Directory Specification if <code>XDG_DATA_DIRS</code> is defined.
  6025. If <code>XDG_DATA_DIRS</code> is undefined,
  6026. the first elements in the list are the Application Data
  6027. and Documents folders for All Users. (These can be determined only
  6028. on Windows 2000 or later and are not present in the list on other
  6029. Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
  6030. CSIDL_COMMON_DOCUMENTS.
  6031. </para>
  6032. <para>Then follows the &quot;share&quot; subfolder in the installation folder for
  6033. the package containing the DLL that calls this function, if it can
  6034. be determined.
  6035. </para>
  6036. <para>Finally the list contains the &quot;share&quot; subfolder in the installation
  6037. folder for GLib, and in the installation folder for the package the
  6038. application's .exe file belongs to.
  6039. </para>
  6040. <para>The installation folders above are determined by looking up the
  6041. folder where the module (DLL or EXE) in question is located. If the
  6042. folder's name is &quot;bin&quot;, its parent is used, otherwise the folder
  6043. itself.
  6044. </para>
  6045. <para>Note that on Windows the returned list can vary depending on where
  6046. this function is called.</para></refsect2><refsect2><title>get-tmp-dir</title><informalexample><programlisting>(define-values (%return) (get-tmp-dir))
  6047. </programlisting></informalexample><para>Gets the directory to use for temporary files.
  6048. </para>
  6049. <para>On UNIX, this is taken from the <code>TMPDIR</code> environment variable.
  6050. If the variable is not set, <code>P_tmpdir</code> is
  6051. used, as defined by the system C library. Failing that, a
  6052. hard-coded default of &quot;/tmp&quot; is returned.
  6053. </para>
  6054. <para>On Windows, the <code>TEMP</code> environment variable is used, with the
  6055. root directory of the Windows installation (eg: &quot;C:\&quot;) used
  6056. as a default.
  6057. </para>
  6058. <para>The encoding of the returned string is system-defined. On Windows,
  6059. it is always UTF-8. The return value is never <constant>NULL</constant> or the empty
  6060. string.</para></refsect2><refsect2><title>get-user-cache-dir</title><informalexample><programlisting>(define-values (%return) (get-user-cache-dir))
  6061. </programlisting></informalexample><para>Returns a base directory in which to store non-essential, cached
  6062. data specific to particular user.
  6063. </para>
  6064. <para>On UNIX platforms this is determined using the mechanisms described
  6065. in the
  6066. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
  6067. In this case the directory retrieved will be <code>XDG_CACHE_HOME</code>.
  6068. </para>
  6069. <para>On Windows it follows XDG Base Directory Specification if <code>XDG_CACHE_HOME</code> is defined.
  6070. If <code>XDG_CACHE_HOME</code> is undefined, the directory that serves as a common
  6071. repository for temporary Internet files is used instead. A typical path is
  6072. <code>C:\Documents and Settings\username\Local Settings\Temporary Internet Files</code>.
  6073. See the [documentation for <code>CSIDL_INTERNET_CACHE</code>](https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx#csidl_internet_cache).</para></refsect2><refsect2><title>get-user-config-dir</title><informalexample><programlisting>(define-values (%return) (get-user-config-dir))
  6074. </programlisting></informalexample><para>Returns a base directory in which to store user-specific application
  6075. configuration information such as user preferences and settings.
  6076. </para>
  6077. <para>On UNIX platforms this is determined using the mechanisms described
  6078. in the
  6079. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
  6080. In this case the directory retrieved will be <code>XDG_CONFIG_HOME</code>.
  6081. </para>
  6082. <para>On Windows it follows XDG Base Directory Specification if <code>XDG_CONFIG_HOME</code> is defined.
  6083. If <code>XDG_CONFIG_HOME</code> is undefined, the folder to use for local (as opposed
  6084. to roaming) application data is used instead. See the
  6085. [documentation for <code>CSIDL_LOCAL_APPDATA</code>](https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx#csidl_local_appdata).
  6086. Note that in this case on Windows it will be the same
  6087. as what <function>g_get_user_data_dir()</function> returns.</para></refsect2><refsect2><title>get-user-data-dir</title><informalexample><programlisting>(define-values (%return) (get-user-data-dir))
  6088. </programlisting></informalexample><para>Returns a base directory in which to access application data such
  6089. as icons that is customized for a particular user.
  6090. </para>
  6091. <para>On UNIX platforms this is determined using the mechanisms described
  6092. in the
  6093. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
  6094. In this case the directory retrieved will be <code>XDG_DATA_HOME</code>.
  6095. </para>
  6096. <para>On Windows it follows XDG Base Directory Specification if <code>XDG_DATA_HOME</code>
  6097. is defined. If <code>XDG_DATA_HOME</code> is undefined, the folder to use for local (as
  6098. opposed to roaming) application data is used instead. See the
  6099. [documentation for <code>CSIDL_LOCAL_APPDATA</code>](https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx#csidl_local_appdata).
  6100. Note that in this case on Windows it will be the same
  6101. as what <function>g_get_user_config_dir()</function> returns.</para></refsect2><refsect2><title>get-user-name</title><informalexample><programlisting>(define-values (%return) (get-user-name))
  6102. </programlisting></informalexample><para>Gets the user name of the current user. The encoding of the returned
  6103. string is system-defined. On UNIX, it might be the preferred file name
  6104. encoding, or something else, and there is no guarantee that it is even
  6105. consistent on a machine. On Windows, it is always UTF-8.</para></refsect2><refsect2><title>get-user-runtime-dir</title><informalexample><programlisting>(define-values (%return) (get-user-runtime-dir))
  6106. </programlisting></informalexample><para>Returns a directory that is unique to the current user on the local
  6107. system.
  6108. </para>
  6109. <para>This is determined using the mechanisms described
  6110. in the
  6111. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
  6112. This is the directory
  6113. specified in the <code>XDG_RUNTIME_DIR</code> environment variable.
  6114. In the case that this variable is not set, we return the value of
  6115. <function>g_get_user_cache_dir()</function>, after verifying that it exists.</para></refsect2><refsect2><title>get-user-special-dir</title><informalexample><programlisting>(define-values (%return) (get-user-special-dir directory))
  6116. </programlisting></informalexample><para>Returns the full path of a special directory using its logical id.
  6117. </para>
  6118. <para>On UNIX this is done using the XDG special user directories.
  6119. For compatibility with existing practise, <constant>G_USER_DIRECTORY_DESKTOP</constant>
  6120. falls back to <code>$HOME/Desktop</code> when XDG special user directories have
  6121. not been set up.
  6122. </para>
  6123. <para>Depending on the platform, the user might be able to change the path
  6124. of the special directory without requiring the session to restart; GLib
  6125. will not reflect any change once the special directories are loaded.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>directory</para></td><td class="parameter_description"><para>the logical id of special directory</para><para>Passed as <code>directory</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>getenv</title><informalexample><programlisting>(define-values (%return) (getenv variable))
  6126. </programlisting></informalexample><para>Returns the value of an environment variable.
  6127. </para>
  6128. <para>On UNIX, the name and value are byte strings which might or might not
  6129. be in some consistent character set and encoding. On Windows, they are
  6130. in UTF-8.
  6131. On Windows, in case the environment variable's value contains
  6132. references to other environment variables, they are expanded.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>variable</para></td><td class="parameter_description"><para>the environment variable to get</para><para>Passed as <code>variable</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-add?</title><informalexample><programlisting>(define-values (%return) (hash-table-add? hash-table key))
  6133. </programlisting></informalexample><para>This is a convenience function for using a <type>GHashTable</type> as a set. It
  6134. is equivalent to calling <function>g_hash_table_replace()</function> with <parameter>key</parameter> as both the
  6135. key and the value.
  6136. </para>
  6137. <para>In particular, this means that if <parameter>key</parameter> already exists in the hash table, then
  6138. the old copy of <parameter>key</parameter> in the hash table is freed and <parameter>key</parameter> replaces it in the
  6139. table.
  6140. </para>
  6141. <para>When a hash table only ever contains keys that have themselves as the
  6142. corresponding value it is able to be stored more efficiently. See
  6143. the discussion in the section description.
  6144. </para>
  6145. <para>Starting from GLib 2.40, this function returns a boolean value to
  6146. indicate whether the newly added value was already in the hash table
  6147. or not.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key to insert</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-contains?</title><informalexample><programlisting>(define-values (%return) (hash-table-contains? hash-table key))
  6148. </programlisting></informalexample><para>Checks if <parameter>key</parameter> is in <parameter>hash_table</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key to check</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-destroy</title><informalexample><programlisting>(define-values () (hash-table-destroy hash-table))
  6149. </programlisting></informalexample><para>Destroys all keys and values in the <type>GHashTable</type> and decrements its
  6150. reference count by 1. If keys and/or values are dynamically allocated,
  6151. you should either free them first or create the <type>GHashTable</type> with destroy
  6152. notifiers using <function>g_hash_table_new_full()</function>. In the latter case the destroy
  6153. functions you supplied will be called on all keys and values during the
  6154. destruction phase.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-insert?</title><informalexample><programlisting>(define-values (%return) (hash-table-insert? hash-table key value))
  6155. </programlisting></informalexample><para>Inserts a new key and value into a <type>GHashTable</type>.
  6156. </para>
  6157. <para>If the key already exists in the <type>GHashTable</type> its current
  6158. value is replaced with the new value. If you supplied a
  6159. <parameter>value_destroy_func</parameter> when creating the <type>GHashTable</type>, the old
  6160. value is freed using that function. If you supplied a
  6161. <parameter>key_destroy_func</parameter> when creating the <type>GHashTable</type>, the passed
  6162. key is freed using that function.
  6163. </para>
  6164. <para>Starting from GLib 2.40, this function returns a boolean value to
  6165. indicate whether the newly added value was already in the hash table
  6166. or not.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key to insert</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>the value to associate with the key</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-lookup</title><informalexample><programlisting>(define-values (%return) (hash-table-lookup hash-table key))
  6167. </programlisting></informalexample><para>Looks up a key in a <type>GHashTable</type>. Note that this function cannot
  6168. distinguish between a key that is not present and one which is present
  6169. and has the value <constant>NULL</constant>. If you need this distinction, use
  6170. <function>g_hash_table_lookup_extended()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to look up</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-lookup-extended</title><informalexample><programlisting>(define-values
  6171. (%return orig-key value)
  6172. (hash-table-lookup-extended hash-table lookup-key))
  6173. </programlisting></informalexample><para>Looks up a key in the <type>GHashTable</type>, returning the original key and the
  6174. associated value and a <type>gboolean</type> which is <constant>TRUE</constant> if the key was found. This
  6175. is useful if you need to free the memory allocated for the original key,
  6176. for example before calling <function>g_hash_table_remove()</function>.
  6177. </para>
  6178. <para>You can actually pass <constant>NULL</constant> for <parameter>lookup_key</parameter> to test
  6179. whether the <constant>NULL</constant> key exists, provided the hash and equal functions
  6180. of <parameter>hash_table</parameter> are <constant>NULL</constant>-safe.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>lookup_key</para></td><td class="parameter_description"><para>the key to look up</para><para>Passed as <code>lookup-key</code></para></td></tr><tr><td class="parameter_name"><para>orig_key</para></td><td class="parameter_description"><para>return location for the original key</para><para>Passed as <code>orig-key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>return location for the value associated
  6181. with the key</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-remove?</title><informalexample><programlisting>(define-values (%return) (hash-table-remove? hash-table key))
  6182. </programlisting></informalexample><para>Removes a key and its associated value from a <type>GHashTable</type>.
  6183. </para>
  6184. <para>If the <type>GHashTable</type> was created using <function>g_hash_table_new_full()</function>, the
  6185. key and value are freed using the supplied destroy functions, otherwise
  6186. you have to make sure that any dynamically allocated values are freed
  6187. yourself.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to remove</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-remove-all</title><informalexample><programlisting>(define-values () (hash-table-remove-all hash-table))
  6188. </programlisting></informalexample><para>Removes all keys and their associated values from a <type>GHashTable</type>.
  6189. </para>
  6190. <para>If the <type>GHashTable</type> was created using <function>g_hash_table_new_full()</function>,
  6191. the keys and values are freed using the supplied destroy functions,
  6192. otherwise you have to make sure that any dynamically allocated
  6193. values are freed yourself.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-replace?</title><informalexample><programlisting>(define-values (%return) (hash-table-replace? hash-table key value))
  6194. </programlisting></informalexample><para>Inserts a new key and value into a <type>GHashTable</type> similar to
  6195. <function>g_hash_table_insert()</function>. The difference is that if the key
  6196. already exists in the <type>GHashTable</type>, it gets replaced by the
  6197. new key. If you supplied a <parameter>value_destroy_func</parameter> when creating
  6198. the <type>GHashTable</type>, the old value is freed using that function.
  6199. If you supplied a <parameter>key_destroy_func</parameter> when creating the
  6200. <type>GHashTable</type>, the old key is freed using that function.
  6201. </para>
  6202. <para>Starting from GLib 2.40, this function returns a boolean value to
  6203. indicate whether the newly added value was already in the hash table
  6204. or not.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>a key to insert</para><para>Passed as <code>key</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>the value to associate with the key</para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-size</title><informalexample><programlisting>(define-values (%return) (hash-table-size hash-table))
  6205. </programlisting></informalexample><para>Returns the number of elements contained in the <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-steal?</title><informalexample><programlisting>(define-values (%return) (hash-table-steal? hash-table key))
  6206. </programlisting></informalexample><para>Removes a key and its associated value from a <type>GHashTable</type> without
  6207. calling the key and value destroy functions.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>key</para></td><td class="parameter_description"><para>the key to remove</para><para>Passed as <code>key</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-steal-all</title><informalexample><programlisting>(define-values () (hash-table-steal-all hash-table))
  6208. </programlisting></informalexample><para>Removes all keys and their associated values from a <type>GHashTable</type>
  6209. without calling the key and value destroy functions.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-steal-extended</title><informalexample><programlisting>(define-values
  6210. (%return stolen-key stolen-value)
  6211. (hash-table-steal-extended hash-table lookup-key))
  6212. </programlisting></informalexample><para>Looks up a key in the <type>GHashTable</type>, stealing the original key and the
  6213. associated value and returning <constant>TRUE</constant> if the key was found. If the key was
  6214. not found, <constant>FALSE</constant> is returned.
  6215. </para>
  6216. <para>If found, the stolen key and value are removed from the hash table without
  6217. calling the key and value destroy functions, and ownership is transferred to
  6218. the caller of this method; as with <function>g_hash_table_steal()</function>.
  6219. </para>
  6220. <para>You can pass <constant>NULL</constant> for <parameter>lookup_key</parameter>, provided the hash and equal functions
  6221. of <parameter>hash_table</parameter> are <constant>NULL</constant>-safe.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr><tr><td class="parameter_name"><para>lookup_key</para></td><td class="parameter_description"><para>the key to look up</para><para>Passed as <code>lookup-key</code></para></td></tr><tr><td class="parameter_name"><para>stolen_key</para></td><td class="parameter_description"><para>return location for the
  6222. original key</para><para>Passed as <code>stolen-key</code></para></td></tr><tr><td class="parameter_name"><para>stolen_value</para></td><td class="parameter_description"><para>return location
  6223. for the value associated with the key</para><para>Passed as <code>stolen-value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hash-table-unref</title><informalexample><programlisting>(define-values () (hash-table-unref hash-table))
  6224. </programlisting></informalexample><para>Atomically decrements the reference count of <parameter>hash_table</parameter> by one.
  6225. If the reference count drops to 0, all keys and values will be
  6226. destroyed, and all memory allocated by the hash table is released.
  6227. This function is MT-safe and may be called from any thread.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hash_table</para></td><td class="parameter_description"><para>a valid <type>GHashTable</type></para><para>Passed as <code>hash-table</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hostname-is-ascii-encoded?</title><informalexample><programlisting>(define-values (%return) (hostname-is-ascii-encoded? hostname))
  6228. </programlisting></informalexample><para>Tests if <parameter>hostname</parameter> contains segments with an ASCII-compatible
  6229. encoding of an Internationalized Domain Name. If this returns
  6230. <constant>TRUE</constant>, you should decode the hostname with <function>g_hostname_to_unicode()</function>
  6231. before displaying it to the user.
  6232. </para>
  6233. <para>Note that a hostname might contain a mix of encoded and unencoded
  6234. segments, and so it is possible for <function>g_hostname_is_non_ascii()</function> and
  6235. <function>g_hostname_is_ascii_encoded()</function> to both return <constant>TRUE</constant> for a name.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hostname</para></td><td class="parameter_description"><para>a hostname</para><para>Passed as <code>hostname</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hostname-is-ip-address?</title><informalexample><programlisting>(define-values (%return) (hostname-is-ip-address? hostname))
  6236. </programlisting></informalexample><para>Tests if <parameter>hostname</parameter> is the string form of an IPv4 or IPv6 address.
  6237. (Eg, &quot;192.168.0.1&quot;.)
  6238. </para>
  6239. <para>Since 2.66, IPv6 addresses with a zone-id are accepted (RFC6874).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hostname</para></td><td class="parameter_description"><para>a hostname (or IP address in string form)</para><para>Passed as <code>hostname</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hostname-is-non-ascii?</title><informalexample><programlisting>(define-values (%return) (hostname-is-non-ascii? hostname))
  6240. </programlisting></informalexample><para>Tests if <parameter>hostname</parameter> contains Unicode characters. If this returns
  6241. <constant>TRUE</constant>, you need to encode the hostname with <function>g_hostname_to_ascii()</function>
  6242. before using it in non-IDN-aware contexts.
  6243. </para>
  6244. <para>Note that a hostname might contain a mix of encoded and unencoded
  6245. segments, and so it is possible for <function>g_hostname_is_non_ascii()</function> and
  6246. <function>g_hostname_is_ascii_encoded()</function> to both return <constant>TRUE</constant> for a name.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hostname</para></td><td class="parameter_description"><para>a hostname</para><para>Passed as <code>hostname</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hostname-to-ascii</title><informalexample><programlisting>(define-values (%return) (hostname-to-ascii hostname))
  6247. </programlisting></informalexample><para>Converts <parameter>hostname</parameter> to its canonical ASCII form; an ASCII-only
  6248. string containing no uppercase letters and not ending with a
  6249. trailing dot.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hostname</para></td><td class="parameter_description"><para>a valid UTF-8 or ASCII hostname</para><para>Passed as <code>hostname</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>hostname-to-unicode</title><informalexample><programlisting>(define-values (%return) (hostname-to-unicode hostname))
  6250. </programlisting></informalexample><para>Converts <parameter>hostname</parameter> to its canonical presentation form; a UTF-8
  6251. string in Unicode normalization form C, containing no uppercase
  6252. letters, no forbidden characters, and no ASCII-encoded segments,
  6253. and not ending with a trailing dot.
  6254. </para>
  6255. <para>Of course if <parameter>hostname</parameter> is not an internationalized hostname, then
  6256. the canonical presentation form will be entirely ASCII.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>hostname</para></td><td class="parameter_description"><para>a valid UTF-8 or ASCII hostname</para><para>Passed as <code>hostname</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>idle-add</title><informalexample><programlisting>(define-values (%return) (idle-add priority function data notify))
  6257. </programlisting></informalexample><para>Adds a function to be called whenever there are no higher priority
  6258. events pending to the default main loop. The function is given the
  6259. default idle priority, <type>G_PRIORITY_DEFAULT_IDLE</type>. If the function
  6260. returns <constant>FALSE</constant> it is automatically removed from the list of event
  6261. sources and will not be called again.
  6262. </para>
  6263. <para>See [memory management of sources][mainloop-memory-management] for details
  6264. on how to handle the return value and memory management of <parameter>data</parameter>.
  6265. </para>
  6266. <para>This internally creates a main loop source using <function>g_idle_source_new()</function>
  6267. and attaches it to the global <type>GMainContext</type> using <function>g_source_attach()</function>, so
  6268. the callback will be invoked in whichever thread is running that main
  6269. context. You can do these steps manually if you need greater control or to
  6270. use a custom main context.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>notify</para></td><td class="parameter_description"><para></para><para>Passed as <code>notify</code></para></td></tr><tr><td class="parameter_name"><para>priority</para></td><td class="parameter_description"><para></para><para>Passed as <code>priority</code></para></td></tr><tr><td class="parameter_name"><para>function</para></td><td class="parameter_description"><para>function to call</para><para>Passed as <code>function</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>data to pass to <parameter>function</parameter>.</para><para>Passed as <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>idle-remove-by-data?</title><informalexample><programlisting>(define-values (%return) (idle-remove-by-data? data))
  6271. </programlisting></informalexample><para>Removes the idle function with the given data.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>the data for the idle source's callback.</para><para>Passed as <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>idle-source-new</title><informalexample><programlisting>(define-values (%return) (idle-source-new))
  6272. </programlisting></informalexample><para>Creates a new idle source.
  6273. </para>
  6274. <para>The source will not initially be associated with any <type>GMainContext</type>
  6275. and must be added to one with <function>g_source_attach()</function> before it will be
  6276. executed. Note that the default priority for idle sources is
  6277. <constant>G_PRIORITY_DEFAULT_IDLE</constant>, as compared to other sources which
  6278. have a default priority of <constant>G_PRIORITY_DEFAULT</constant>.</para></refsect2><refsect2><title>int64-equal?</title><informalexample><programlisting>(define-values (%return) (int64-equal? v1 v2))
  6279. </programlisting></informalexample><para>Compares the two <type>gint64</type> values being pointed to and returns
  6280. <constant>TRUE</constant> if they are equal.
  6281. It can be passed to <function>g_hash_table_new()</function> as the <parameter>key_equal_func</parameter>
  6282. parameter, when using non-<constant>NULL</constant> pointers to 64-bit integers as keys in a
  6283. <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>v1</para></td><td class="parameter_description"><para>a pointer to a <type>gint64</type> key</para><para>Passed as <code>v1</code></para></td></tr><tr><td class="parameter_name"><para>v2</para></td><td class="parameter_description"><para>a pointer to a <type>gint64</type> key to compare with <parameter>v1</parameter></para><para>Passed as <code>v2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>int64-hash</title><informalexample><programlisting>(define-values (%return) (int64-hash v))
  6284. </programlisting></informalexample><para>Converts a pointer to a <type>gint64</type> to a hash value.
  6285. </para>
  6286. <para>It can be passed to <function>g_hash_table_new()</function> as the <parameter>hash_func</parameter> parameter,
  6287. when using non-<constant>NULL</constant> pointers to 64-bit integer values as keys in a
  6288. <type>GHashTable</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>v</para></td><td class="parameter_description"><para>a pointer to a <type>gint64</type> key</para><para>Passed as <code>v</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>int-equal?</title><informalexample><programlisting>(define-values (%return) (int-equal? v1 v2))
  6289. </programlisting></informalexample><para>Compares the two <type>gint</type> values being pointed to and returns
  6290. <constant>TRUE</constant> if they are equal.
  6291. It can be passed to <function>g_hash_table_new()</function> as the <parameter>key_equal_func</parameter>
  6292. parameter, when using non-<constant>NULL</constant> pointers to integers as keys in a
  6293. <type>GHashTable</type>.
  6294. </para>
  6295. <para>Note that this function acts on pointers to <type>gint</type>, not on <type>gint</type>
  6296. directly: if your hash table's keys are of the form
  6297. <code>GINT_TO_POINTER (n)</code>, use <function>g_direct_equal()</function> instead.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>v1</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> key</para><para>Passed as <code>v1</code></para></td></tr><tr><td class="parameter_name"><para>v2</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> key to compare with <parameter>v1</parameter></para><para>Passed as <code>v2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>int-hash</title><informalexample><programlisting>(define-values (%return) (int-hash v))
  6298. </programlisting></informalexample><para>Converts a pointer to a <type>gint</type> to a hash value.
  6299. It can be passed to <function>g_hash_table_new()</function> as the <parameter>hash_func</parameter> parameter,
  6300. when using non-<constant>NULL</constant> pointers to integer values as keys in a <type>GHashTable</type>.
  6301. </para>
  6302. <para>Note that this function acts on pointers to <type>gint</type>, not on <type>gint</type>
  6303. directly: if your hash table's keys are of the form
  6304. <code>GINT_TO_POINTER (n)</code>, use <function>g_direct_hash()</function> instead.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>v</para></td><td class="parameter_description"><para>a pointer to a <type>gint</type> key</para><para>Passed as <code>v</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>intern-static-string</title><informalexample><programlisting>(define-values (%return) (intern-static-string string))
  6305. </programlisting></informalexample><para>Returns a canonical representation for <parameter>string</parameter>. Interned strings
  6306. can be compared for equality by comparing the pointers, instead of
  6307. using <function>strcmp()</function>. <function>g_intern_static_string()</function> does not copy the string,
  6308. therefore <parameter>string</parameter> must not be freed or modified.
  6309. </para>
  6310. <para>This function must not be used before library constructors have finished
  6311. running. In particular, this means it cannot be used to initialize global
  6312. variables in C++.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a static string</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>intern-string</title><informalexample><programlisting>(define-values (%return) (intern-string string))
  6313. </programlisting></informalexample><para>Returns a canonical representation for <parameter>string</parameter>. Interned strings
  6314. can be compared for equality by comparing the pointers, instead of
  6315. using <function>strcmp()</function>.
  6316. </para>
  6317. <para>This function must not be used before library constructors have finished
  6318. running. In particular, this means it cannot be used to initialize global
  6319. variables in C++.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>io-add-watch</title><informalexample><programlisting>(define-values
  6320. (%return)
  6321. (io-add-watch channel priority condition func user-data notify))
  6322. </programlisting></informalexample><para>Adds the <type>GIOChannel</type> into the default main loop context
  6323. with the default priority.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>notify</para></td><td class="parameter_description"><para></para><para>Passed as <code>notify</code></para></td></tr><tr><td class="parameter_name"><para>priority</para></td><td class="parameter_description"><para></para><para>Passed as <code>priority</code></para></td></tr><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type></para><para>Passed as <code>channel</code></para></td></tr><tr><td class="parameter_name"><para>condition</para></td><td class="parameter_description"><para>the condition to watch for</para><para>Passed as <code>condition</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para>the function to call when the condition is satisfied</para><para>Passed as <code>func</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>user data to pass to <parameter>func</parameter></para><para>Passed as <code>user-data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>io-channel-error-from-errno</title><informalexample><programlisting>(define-values (%return) (io-channel-error-from-errno en))
  6324. </programlisting></informalexample><para>Converts an <code>errno</code> error number to a <type>GIOChannelError</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>en</para></td><td class="parameter_description"><para>an <code>errno</code> error number, e.g. <code>EINVAL</code></para><para>Passed as <code>en</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>io-channel-error-quark</title><informalexample><programlisting>(define-values (%return) (io-channel-error-quark))
  6325. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>io-create-watch</title><informalexample><programlisting>(define-values (%return) (io-create-watch channel condition))
  6326. </programlisting></informalexample><para>Creates a <type>GSource</type> that's dispatched when <parameter>condition</parameter> is met for the
  6327. given <parameter>channel</parameter>. For example, if condition is <type>G_IO_IN</type>, the source will
  6328. be dispatched when there's data available for reading.
  6329. </para>
  6330. <para>The callback function invoked by the <type>GSource</type> should be added with
  6331. <function>g_source_set_callback()</function>, but it has type <type>GIOFunc</type> (not <type>GSourceFunc</type>).
  6332. </para>
  6333. <para><function>g_io_add_watch()</function> is a simpler interface to this same functionality, for
  6334. the case where you want to add the source to the default main loop context
  6335. at the default priority.
  6336. </para>
  6337. <para>On Windows, polling a <type>GSource</type> created to watch a channel for a socket
  6338. puts the socket in non-blocking mode. This is a side-effect of the
  6339. implementation and unavoidable.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>channel</para></td><td class="parameter_description"><para>a <type>GIOChannel</type> to watch</para><para>Passed as <code>channel</code></para></td></tr><tr><td class="parameter_name"><para>condition</para></td><td class="parameter_description"><para>conditions to watch for</para><para>Passed as <code>condition</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>key-file-error-quark</title><informalexample><programlisting>(define-values (%return) (key-file-error-quark))
  6340. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>listenv</title><informalexample><programlisting>(define-values (%return) (listenv))
  6341. </programlisting></informalexample><para>Gets the names of all variables set in the environment.
  6342. </para>
  6343. <para>Programs that want to be portable to Windows should typically use
  6344. this function and <function>g_getenv()</function> instead of using the environ array
  6345. from the C library directly. On Windows, the strings in the environ
  6346. array are in system codepage encoding, while in most of the typical
  6347. use cases for environment variables in GLib-using programs you want
  6348. the UTF-8 encoding that this function and <function>g_getenv()</function> provide.</para></refsect2><refsect2><title>locale-from-utf8</title><informalexample><programlisting>(define-values
  6349. (%return bytes-read bytes-written)
  6350. (locale-from-utf8 utf8string len))
  6351. </programlisting></informalexample><para>Converts a string from UTF-8 to the encoding used for strings by
  6352. the C runtime (usually the same as that used by the operating
  6353. system) in the [current locale][setlocale]. On Windows this means
  6354. the system codepage.
  6355. </para>
  6356. <para>The input string shall not contain nul characters even if the <parameter>len</parameter>
  6357. argument is positive. A nul character found inside the string will result
  6358. in error <constant>G_CONVERT_ERROR_ILLEGAL_SEQUENCE</constant>. Use <function>g_convert()</function> to convert
  6359. input that may contain embedded nul characters.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>utf8string</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>utf8string</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the length of the string, or -1 if the string is
  6360. nul-terminated.</para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>bytes_read</para></td><td class="parameter_description"><para>location to store the number of bytes in the
  6361. input string that were successfully converted, or <constant>NULL</constant>.
  6362. Even if the conversion was successful, this may be
  6363. less than <parameter>len</parameter> if there were partial characters
  6364. at the end of the input. If the error
  6365. <constant>G_CONVERT_ERROR_ILLEGAL_SEQUENCE</constant> occurs, the value
  6366. stored will be the byte offset after the last valid
  6367. input sequence.</para><para>Passed as <code>bytes-read</code></para></td></tr><tr><td class="parameter_name"><para>bytes_written</para></td><td class="parameter_description"><para>the number of bytes stored in the output
  6368. buffer (not including the terminating nul).</para><para>Inferred from <code>%return</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>locale-to-utf8</title><informalexample><programlisting>(define-values
  6369. (%return bytes-read bytes-written)
  6370. (locale-to-utf8 opsysstring))
  6371. </programlisting></informalexample><para>Converts a string which is in the encoding used for strings by
  6372. the C runtime (usually the same as that used by the operating
  6373. system) in the [current locale][setlocale] into a UTF-8 string.
  6374. </para>
  6375. <para>If the source encoding is not UTF-8 and the conversion output contains a
  6376. nul character, the error <constant>G_CONVERT_ERROR_EMBEDDED_NUL</constant> is set and the
  6377. function returns <constant>NULL</constant>.
  6378. If the source encoding is UTF-8, an embedded nul character is treated with
  6379. the <constant>G_CONVERT_ERROR_ILLEGAL_SEQUENCE</constant> error for backward compatibility with
  6380. earlier versions of this library. Use <function>g_convert()</function> to produce output that
  6381. may contain embedded nul characters.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>opsysstring</para></td><td class="parameter_description"><para>a string in the
  6382. encoding of the current locale. On Windows
  6383. this means the system codepage.</para><para>Passed as <code>opsysstring</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the length of the string, or -1 if the string is
  6384. nul-terminated (Note that some encodings may allow nul
  6385. bytes to occur inside strings. In that case, using -1
  6386. for the <parameter>len</parameter> parameter is unsafe)</para><para>Inferred from <code>opsysstring</code></para></td></tr><tr><td class="parameter_name"><para>bytes_read</para></td><td class="parameter_description"><para>location to store the number of bytes in the
  6387. input string that were successfully converted, or <constant>NULL</constant>.
  6388. Even if the conversion was successful, this may be
  6389. less than <parameter>len</parameter> if there were partial characters
  6390. at the end of the input. If the error
  6391. <constant>G_CONVERT_ERROR_ILLEGAL_SEQUENCE</constant> occurs, the value
  6392. stored will be the byte offset after the last valid
  6393. input sequence.</para><para>Passed as <code>bytes-read</code></para></td></tr><tr><td class="parameter_name"><para>bytes_written</para></td><td class="parameter_description"><para>the number of bytes stored in the output
  6394. buffer (not including the terminating nul).</para><para>Passed as <code>bytes-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>log-default-handler</title><informalexample><programlisting>(define-values
  6395. ()
  6396. (log-default-handler log-domain log-level message unused-data))
  6397. </programlisting></informalexample><para>The default log handler set up by GLib; <function>g_log_set_default_handler()</function>
  6398. allows to install an alternate default log handler.
  6399. This is used if no log handler has been set for the particular log
  6400. domain and log level combination. It outputs the message to stderr
  6401. or stdout and if the log level is fatal it calls <function>G_BREAKPOINT()</function>. It automatically
  6402. prints a new-line character after the message, so one does not need to be
  6403. manually included in <parameter>message</parameter>.
  6404. </para>
  6405. <para>The behavior of this log handler can be influenced by a number of
  6406. environment variables:
  6407. </para>
  6408. <para>- <code>G_MESSAGES_PREFIXED</code>: A :-separated list of log levels for which
  6409. messages should be prefixed by the program name and PID of the
  6410. application.
  6411. </para>
  6412. <para>- <code>G_MESSAGES_DEBUG</code>: A space-separated list of log domains for
  6413. which debug and informational messages are printed. By default
  6414. these messages are not printed.
  6415. </para>
  6416. <para>stderr is used for levels <constant>G_LOG_LEVEL_ERROR</constant>, <constant>G_LOG_LEVEL_CRITICAL</constant>,
  6417. <constant>G_LOG_LEVEL_WARNING</constant> and <constant>G_LOG_LEVEL_MESSAGE</constant>. stdout is used for
  6418. the rest.
  6419. </para>
  6420. <para>This has no effect if structured logging is enabled; see
  6421. [Using Structured Logging][using-structured-logging].</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>log_domain</para></td><td class="parameter_description"><para>the log domain of the message, or <constant>NULL</constant> for the
  6422. default &quot;&quot; application domain</para><para>Passed as <code>log-domain</code></para></td></tr><tr><td class="parameter_name"><para>log_level</para></td><td class="parameter_description"><para>the level of the message</para><para>Passed as <code>log-level</code></para></td></tr><tr><td class="parameter_name"><para>message</para></td><td class="parameter_description"><para>the message</para><para>Passed as <code>message</code></para></td></tr><tr><td class="parameter_name"><para>unused_data</para></td><td class="parameter_description"><para>data passed from <function>g_log()</function> which is unused</para><para>Passed as <code>unused-data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>log-remove-handler</title><informalexample><programlisting>(define-values () (log-remove-handler log-domain handler-id))
  6423. </programlisting></informalexample><para>Removes the log handler.
  6424. </para>
  6425. <para>This has no effect if structured logging is enabled; see
  6426. [Using Structured Logging][using-structured-logging].</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>log_domain</para></td><td class="parameter_description"><para>the log domain</para><para>Passed as <code>log-domain</code></para></td></tr><tr><td class="parameter_name"><para>handler_id</para></td><td class="parameter_description"><para>the id of the handler, which was returned
  6427. in <function>g_log_set_handler()</function></para><para>Passed as <code>handler-id</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>log-set-always-fatal</title><informalexample><programlisting>(define-values (%return) (log-set-always-fatal fatal-mask))
  6428. </programlisting></informalexample><para>Sets the message levels which are always fatal, in any log domain.
  6429. When a message with any of these levels is logged the program terminates.
  6430. You can only set the levels defined by GLib to be fatal.
  6431. <constant>G_LOG_LEVEL_ERROR</constant> is always fatal.
  6432. </para>
  6433. <para>You can also make some message levels fatal at runtime by setting
  6434. the <code>G_DEBUG</code> environment variable (see
  6435. [Running GLib Applications](glib-running.html)).
  6436. </para>
  6437. <para>Libraries should not call this function, as it affects all messages logged
  6438. by a process, including those from other libraries.
  6439. </para>
  6440. <para>Structured log messages (using <function>g_log_structured()</function> and
  6441. <function>g_log_structured_array()</function>) are fatal only if the default log writer is used;
  6442. otherwise it is up to the writer function to determine which log messages
  6443. are fatal. See [Using Structured Logging][using-structured-logging].</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>fatal_mask</para></td><td class="parameter_description"><para>the mask containing bits set for each level
  6444. of error which is to be fatal</para><para>Passed as <code>fatal-mask</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>log-set-fatal-mask</title><informalexample><programlisting>(define-values (%return) (log-set-fatal-mask log-domain fatal-mask))
  6445. </programlisting></informalexample><para>Sets the log levels which are fatal in the given domain.
  6446. <constant>G_LOG_LEVEL_ERROR</constant> is always fatal.
  6447. </para>
  6448. <para>This has no effect on structured log messages (using <function>g_log_structured()</function> or
  6449. <function>g_log_structured_array()</function>). To change the fatal behaviour for specific log
  6450. messages, programs must install a custom log writer function using
  6451. <function>g_log_set_writer_func()</function>. See
  6452. [Using Structured Logging][using-structured-logging].
  6453. </para>
  6454. <para>This function is mostly intended to be used with
  6455. <constant>G_LOG_LEVEL_CRITICAL</constant>. You should typically not set
  6456. <constant>G_LOG_LEVEL_WARNING</constant>, <constant>G_LOG_LEVEL_MESSAGE</constant>, <constant>G_LOG_LEVEL_INFO</constant> or
  6457. <constant>G_LOG_LEVEL_DEBUG</constant> as fatal except inside of test programs.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>log_domain</para></td><td class="parameter_description"><para>the log domain</para><para>Passed as <code>log-domain</code></para></td></tr><tr><td class="parameter_name"><para>fatal_mask</para></td><td class="parameter_description"><para>the new fatal mask</para><para>Passed as <code>fatal-mask</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>log-set-handler</title><informalexample><programlisting>(define-values
  6458. (%return)
  6459. (log-set-handler log-domain log-levels log-func user-data destroy))
  6460. </programlisting></informalexample><para>Sets the log handler for a domain and a set of log levels.
  6461. To handle fatal and recursive messages the <parameter>log_levels</parameter> parameter
  6462. must be combined with the <type>G_LOG_FLAG_FATAL</type> and <type>G_LOG_FLAG_RECURSION</type>
  6463. bit flags.
  6464. </para>
  6465. <para>Note that since the <type>G_LOG_LEVEL_ERROR</type> log level is always fatal, if
  6466. you want to set a handler for this log level you must combine it with
  6467. <type>G_LOG_FLAG_FATAL</type>.
  6468. </para>
  6469. <para>This has no effect if structured logging is enabled; see
  6470. [Using Structured Logging][using-structured-logging].
  6471. </para>
  6472. <para>Here is an example for adding a log handler for all warning messages
  6473. in the default domain:
  6474. <informalexample><programlisting>
  6475. g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
  6476. | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
  6477. </programlisting></informalexample></para>
  6478. <para>This example adds a log handler for all critical messages from GTK+:
  6479. <informalexample><programlisting>
  6480. g_log_set_handler (&quot;Gtk&quot;, G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
  6481. | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
  6482. </programlisting></informalexample></para>
  6483. <para>This example adds a log handler for all messages from GLib:
  6484. <informalexample><programlisting>
  6485. g_log_set_handler (&quot;GLib&quot;, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
  6486. | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
  6487. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>destroy</para></td><td class="parameter_description"><para></para><para>Passed as <code>destroy</code></para></td></tr><tr><td class="parameter_name"><para>log_domain</para></td><td class="parameter_description"><para>the log domain, or <constant>NULL</constant> for the default &quot;&quot;
  6488. application domain</para><para>Passed as <code>log-domain</code></para></td></tr><tr><td class="parameter_name"><para>log_levels</para></td><td class="parameter_description"><para>the log levels to apply the log handler for.
  6489. To handle fatal and recursive messages as well, combine
  6490. the log levels with the <type>G_LOG_FLAG_FATAL</type> and
  6491. <type>G_LOG_FLAG_RECURSION</type> bit flags.</para><para>Passed as <code>log-levels</code></para></td></tr><tr><td class="parameter_name"><para>log_func</para></td><td class="parameter_description"><para>the log handler function</para><para>Passed as <code>log-func</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>data passed to the log handler</para><para>Passed as <code>user-data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>log-variant</title><informalexample><programlisting>(define-values () (log-variant log-domain log-level fields))
  6492. </programlisting></informalexample><para>Log a message with structured data, accepting the data within a <type>GVariant</type>. This
  6493. version is especially useful for use in other languages, via introspection.
  6494. </para>
  6495. <para>The only mandatory item in the <parameter>fields</parameter> dictionary is the &quot;MESSAGE&quot; which must
  6496. contain the text shown to the user.
  6497. </para>
  6498. <para>The values in the <parameter>fields</parameter> dictionary are likely to be of type String
  6499. (<type>G_VARIANT_TYPE_STRING</type>). Array of bytes (<type>G_VARIANT_TYPE_BYTESTRING</type>) is also
  6500. supported. In this case the message is handled as binary and will be forwarded
  6501. to the log writer as such. The size of the array should not be higher than
  6502. <constant>G_MAXSSIZE</constant>. Otherwise it will be truncated to this size. For other types
  6503. <function>g_variant_print()</function> will be used to convert the value into a string.
  6504. </para>
  6505. <para>For more details on its usage and about the parameters, see <function>g_log_structured()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>log_domain</para></td><td class="parameter_description"><para>log domain, usually <constant>G_LOG_DOMAIN</constant></para><para>Passed as <code>log-domain</code></para></td></tr><tr><td class="parameter_name"><para>log_level</para></td><td class="parameter_description"><para>log level, either from <type>GLogLevelFlags</type>, or a user-defined
  6506. level</para><para>Passed as <code>log-level</code></para></td></tr><tr><td class="parameter_name"><para>fields</para></td><td class="parameter_description"><para>a dictionary (<type>GVariant</type> of the type <constant>G_VARIANT_TYPE_VARDICT</constant>)
  6507. containing the key-value pairs of message data.</para><para>Passed as <code>fields</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>log-writer-default-set-use-stderr</title><informalexample><programlisting>(define-values () (log-writer-default-set-use-stderr use-stderr))
  6508. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>use_stderr</para></td><td class="parameter_description"><para></para><para>Passed as <code>use-stderr</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>log-writer-default-would-drop?</title><informalexample><programlisting>(define-values
  6509. (%return)
  6510. (log-writer-default-would-drop? log-level log-domain))
  6511. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>log_level</para></td><td class="parameter_description"><para></para><para>Passed as <code>log-level</code></para></td></tr><tr><td class="parameter_name"><para>log_domain</para></td><td class="parameter_description"><para></para><para>Passed as <code>log-domain</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>log-writer-is-journald?</title><informalexample><programlisting>(define-values (%return) (log-writer-is-journald? output-fd))
  6512. </programlisting></informalexample><para>Check whether the given <parameter>output_fd</parameter> file descriptor is a connection to the
  6513. systemd journal, or something else (like a log file or <code>stdout</code> or
  6514. <code>stderr</code>).
  6515. </para>
  6516. <para>Invalid file descriptors are accepted and return <constant>FALSE</constant>, which allows for
  6517. the following construct without needing any additional error handling:
  6518. <informalexample><programlisting>
  6519. is_journald = g_log_writer_is_journald (fileno (stderr));
  6520. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>output_fd</para></td><td class="parameter_description"><para>output file descriptor to check</para><para>Passed as <code>output-fd</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>log-writer-supports-color?</title><informalexample><programlisting>(define-values (%return) (log-writer-supports-color? output-fd))
  6521. </programlisting></informalexample><para>Check whether the given <parameter>output_fd</parameter> file descriptor supports ANSI color
  6522. escape sequences. If so, they can safely be used when formatting log
  6523. messages.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>output_fd</para></td><td class="parameter_description"><para>output file descriptor to check</para><para>Passed as <code>output-fd</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>main-context-default</title><informalexample><programlisting>(define-values (%return) (main-context-default))
  6524. </programlisting></informalexample><para>Returns the global default main context. This is the main context
  6525. used for main loop functions when a main loop is not explicitly
  6526. specified, and corresponds to the &quot;main&quot; main loop. See also
  6527. <function>g_main_context_get_thread_default()</function>.</para></refsect2><refsect2><title>main-context-get-thread-default</title><informalexample><programlisting>(define-values (%return) (main-context-get-thread-default))
  6528. </programlisting></informalexample><para>Gets the thread-default <type>GMainContext</type> for this thread. Asynchronous
  6529. operations that want to be able to be run in contexts other than
  6530. the default one should call this method or
  6531. <function>g_main_context_ref_thread_default()</function> to get a <type>GMainContext</type> to add
  6532. their <type>GSources</type> to. (Note that even in single-threaded
  6533. programs applications may sometimes want to temporarily push a
  6534. non-default context, so it is not safe to assume that this will
  6535. always return <constant>NULL</constant> if you are running in the default thread.)
  6536. </para>
  6537. <para>If you need to hold a reference on the context, use
  6538. <function>g_main_context_ref_thread_default()</function> instead.</para></refsect2><refsect2><title>main-context-ref-thread-default</title><informalexample><programlisting>(define-values (%return) (main-context-ref-thread-default))
  6539. </programlisting></informalexample><para>Gets the thread-default <type>GMainContext</type> for this thread, as with
  6540. <function>g_main_context_get_thread_default()</function>, but also adds a reference to
  6541. it with <function>g_main_context_ref()</function>. In addition, unlike
  6542. <function>g_main_context_get_thread_default()</function>, if the thread-default context
  6543. is the global default context, this will return that <type>GMainContext</type>
  6544. (with a ref added to it) rather than returning <constant>NULL</constant>.</para></refsect2><refsect2><title>main-current-source</title><informalexample><programlisting>(define-values (%return) (main-current-source))
  6545. </programlisting></informalexample><para>Returns the currently firing source for this thread.</para></refsect2><refsect2><title>main-depth</title><informalexample><programlisting>(define-values (%return) (main-depth))
  6546. </programlisting></informalexample><para>Returns the depth of the stack of calls to
  6547. <function>g_main_context_dispatch()</function> on any <type>GMainContext</type> in the current thread.
  6548. That is, when called from the toplevel, it gives 0. When
  6549. called from within a callback from <function>g_main_context_iteration()</function>
  6550. (or <function>g_main_loop_run()</function>, etc.) it returns 1. When called from within
  6551. a callback to a recursive call to <function>g_main_context_iteration()</function>,
  6552. it returns 2. And so forth.
  6553. </para>
  6554. <para>This function is useful in a situation like the following:
  6555. Imagine an extremely simple &quot;garbage collected&quot; system.
  6556. </para>
  6557. <para><informalexample><programlisting>
  6558. static GList *free_list;
  6559. gpointer
  6560. allocate_memory (gsize size)
  6561. {
  6562. gpointer result = g_malloc (size);
  6563. free_list = g_list_prepend (free_list, result);
  6564. return result;
  6565. }
  6566. void
  6567. free_allocated_memory (void)
  6568. {
  6569. GList *l;
  6570. for (l = free_list; l; l = l-&gt;next);
  6571. g_free (l-&gt;data);
  6572. g_list_free (free_list);
  6573. free_list = NULL;
  6574. }
  6575. [...]
  6576. while (TRUE);
  6577. {
  6578. g_main_context_iteration (NULL, TRUE);
  6579. free_allocated_memory();
  6580. }
  6581. </programlisting></informalexample></para>
  6582. <para>This works from an application, however, if you want to do the same
  6583. thing from a library, it gets more difficult, since you no longer
  6584. control the main loop. You might think you can simply use an idle
  6585. function to make the call to <function>free_allocated_memory()</function>, but that
  6586. doesn't work, since the idle function could be called from a
  6587. recursive callback. This can be fixed by using <function>g_main_depth()</function>
  6588. </para>
  6589. <para><informalexample><programlisting>
  6590. gpointer
  6591. allocate_memory (gsize size)
  6592. {
  6593. FreeListBlock *block = g_new (FreeListBlock, 1);
  6594. block-&gt;mem = g_malloc (size);
  6595. block-&gt;depth = g_main_depth ();
  6596. free_list = g_list_prepend (free_list, block);
  6597. return block-&gt;mem;
  6598. }
  6599. void
  6600. free_allocated_memory (void)
  6601. {
  6602. GList *l;
  6603. int depth = g_main_depth ();
  6604. for (l = free_list; l; );
  6605. {
  6606. GList *next = l-&gt;next;
  6607. FreeListBlock *block = l-&gt;data;
  6608. if (block-&gt;depth &gt; depth)
  6609. {
  6610. g_free (block-&gt;mem);
  6611. g_free (block);
  6612. free_list = g_list_delete_link (free_list, l);
  6613. }
  6614. l = next;
  6615. }
  6616. }
  6617. </programlisting></informalexample></para>
  6618. <para>There is a temptation to use <function>g_main_depth()</function> to solve
  6619. problems with reentrancy. For instance, while waiting for data
  6620. to be received from the network in response to a menu item,
  6621. the menu item might be selected again. It might seem that
  6622. one could make the menu item's callback return immediately
  6623. and do nothing if <function>g_main_depth()</function> returns a value greater than 1.
  6624. However, this should be avoided since the user then sees selecting
  6625. the menu item do nothing. Furthermore, you'll find yourself adding
  6626. these checks all over your code, since there are doubtless many,
  6627. many things that the user could do. Instead, you can use the
  6628. following techniques:
  6629. </para>
  6630. <para>1. Use <function>gtk_widget_set_sensitive()</function> or modal dialogs to prevent
  6631. the user from interacting with elements while the main
  6632. loop is recursing.
  6633. </para>
  6634. <para>2. Avoid main loop recursion in situations where you can't handle
  6635. arbitrary callbacks. Instead, structure your code so that you
  6636. simply return to the main loop and then get called again when
  6637. there is more work to do.</para></refsect2><refsect2><title>malloc</title><informalexample><programlisting>(define-values (%return) (malloc n-bytes))
  6638. </programlisting></informalexample><para>Allocates <parameter>n_bytes</parameter> bytes of memory.
  6639. If <parameter>n_bytes</parameter> is 0 it returns <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>n_bytes</para></td><td class="parameter_description"><para>the number of bytes to allocate</para><para>Passed as <code>n-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>malloc0</title><informalexample><programlisting>(define-values (%return) (malloc0 n-bytes))
  6640. </programlisting></informalexample><para>Allocates <parameter>n_bytes</parameter> bytes of memory, initialized to 0's.
  6641. If <parameter>n_bytes</parameter> is 0 it returns <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>n_bytes</para></td><td class="parameter_description"><para>the number of bytes to allocate</para><para>Passed as <code>n-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>malloc0-n</title><informalexample><programlisting>(define-values (%return) (malloc0-n n-blocks n-block-bytes))
  6642. </programlisting></informalexample><para>This function is similar to <function>g_malloc0()</function>, allocating (<parameter>n_blocks</parameter> * <parameter>n_block_bytes</parameter>) bytes,
  6643. but care is taken to detect possible overflow during multiplication.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>n_blocks</para></td><td class="parameter_description"><para>the number of blocks to allocate</para><para>Passed as <code>n-blocks</code></para></td></tr><tr><td class="parameter_name"><para>n_block_bytes</para></td><td class="parameter_description"><para>the size of each block in bytes</para><para>Passed as <code>n-block-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>malloc-n</title><informalexample><programlisting>(define-values (%return) (malloc-n n-blocks n-block-bytes))
  6644. </programlisting></informalexample><para>This function is similar to <function>g_malloc()</function>, allocating (<parameter>n_blocks</parameter> * <parameter>n_block_bytes</parameter>) bytes,
  6645. but care is taken to detect possible overflow during multiplication.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>n_blocks</para></td><td class="parameter_description"><para>the number of blocks to allocate</para><para>Passed as <code>n-blocks</code></para></td></tr><tr><td class="parameter_name"><para>n_block_bytes</para></td><td class="parameter_description"><para>the size of each block in bytes</para><para>Passed as <code>n-block-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>markup-error-quark</title><informalexample><programlisting>(define-values (%return) (markup-error-quark))
  6646. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>markup-escape-text</title><informalexample><programlisting>(define-values (%return) (markup-escape-text text length))
  6647. </programlisting></informalexample><para>Escapes text so that the markup parser will parse it verbatim.
  6648. Less than, greater than, ampersand, etc. are replaced with the
  6649. corresponding entities. This function would typically be used
  6650. when writing out a file to be parsed with the markup parser.
  6651. </para>
  6652. <para>Note that this function doesn't protect whitespace and line endings
  6653. from being processed according to the XML rules for normalization
  6654. of line endings and attribute values.
  6655. </para>
  6656. <para>Note also that this function will produce character references in
  6657. the range of &amp;#x1; ... &amp;#x1f; for all control sequences
  6658. except for tabstop, newline and carriage return. The character
  6659. references in this range are not valid XML 1.0, but they are
  6660. valid XML 1.1 and will be accepted by the GMarkup parser.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>text</para></td><td class="parameter_description"><para>some valid UTF-8 text</para><para>Passed as <code>text</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>length of <parameter>text</parameter> in bytes, or -1 if the text is nul-terminated</para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>memdup</title><informalexample><programlisting>(define-values (%return) (memdup mem byte-size))
  6661. </programlisting></informalexample><para>Allocates <parameter>byte_size</parameter> bytes of memory, and copies <parameter>byte_size</parameter> bytes into it
  6662. from <parameter>mem</parameter>. If <parameter>mem</parameter> is <constant>NULL</constant> it returns <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem</para></td><td class="parameter_description"><para>the memory to copy.</para><para>Passed as <code>mem</code></para></td></tr><tr><td class="parameter_name"><para>byte_size</para></td><td class="parameter_description"><para>the number of bytes to copy.</para><para>Passed as <code>byte-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>memdup2</title><informalexample><programlisting>(define-values (%return) (memdup2 mem byte-size))
  6663. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem</para></td><td class="parameter_description"><para></para><para>Passed as <code>mem</code></para></td></tr><tr><td class="parameter_name"><para>byte_size</para></td><td class="parameter_description"><para></para><para>Passed as <code>byte-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>mkdir-with-parents</title><informalexample><programlisting>(define-values (%return) (mkdir-with-parents pathname mode))
  6664. </programlisting></informalexample><para>Create a directory if it doesn't already exist. Create intermediate
  6665. parent directories as needed, too.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pathname</para></td><td class="parameter_description"><para>a pathname in the GLib file name encoding</para><para>Passed as <code>pathname</code></para></td></tr><tr><td class="parameter_name"><para>mode</para></td><td class="parameter_description"><para>permissions to use for newly created directories</para><para>Passed as <code>mode</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>nullify-pointer</title><informalexample><programlisting>(define-values () (nullify-pointer nullify-location))
  6666. </programlisting></informalexample><para>Set the pointer at the specified location to <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>nullify_location</para></td><td class="parameter_description"><para>the memory address of the pointer.</para><para>Passed as <code>nullify-location</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>number-parser-error-quark</title><informalexample><programlisting>(define-values (%return) (number-parser-error-quark))
  6667. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>on-error-query</title><informalexample><programlisting>(define-values () (on-error-query prg-name))
  6668. </programlisting></informalexample><para>Prompts the user with
  6669. <code>[E]xit, [H]alt, show [S]tack trace or [P]roceed</code>.
  6670. This function is intended to be used for debugging use only.
  6671. The following example shows how it can be used together with
  6672. the <function>g_log()</function> functions.
  6673. </para>
  6674. <para><informalexample><programlisting>
  6675. #include &lt;glib.h&gt;
  6676. static void
  6677. log_handler (const gchar *log_domain,
  6678. GLogLevelFlags log_level,
  6679. const gchar *message,
  6680. gpointer user_data)
  6681. {
  6682. g_log_default_handler (log_domain, log_level, message, user_data);
  6683. g_on_error_query (MY_PROGRAM_NAME);
  6684. }
  6685. int
  6686. main (int argc, char *argv[])
  6687. {
  6688. g_log_set_handler (MY_LOG_DOMAIN,
  6689. G_LOG_LEVEL_WARNING |
  6690. G_LOG_LEVEL_ERROR |
  6691. G_LOG_LEVEL_CRITICAL,
  6692. log_handler,
  6693. NULL);
  6694. ...
  6695. </programlisting></informalexample></para>
  6696. <para>If &quot;[E]xit&quot; is selected, the application terminates with a call
  6697. to _exit(0).
  6698. </para>
  6699. <para>If &quot;[S]tack&quot; trace is selected, <function>g_on_error_stack_trace()</function> is called.
  6700. This invokes gdb, which attaches to the current process and shows
  6701. a stack trace. The prompt is then shown again.
  6702. </para>
  6703. <para>If &quot;[P]roceed&quot; is selected, the function returns.
  6704. </para>
  6705. <para>This function may cause different actions on non-UNIX platforms.
  6706. </para>
  6707. <para>On Windows consider using the <code>G_DEBUGGER</code> environment
  6708. variable (see [Running GLib Applications](glib-running.html)) and
  6709. calling <function>g_on_error_stack_trace()</function> instead.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>prg_name</para></td><td class="parameter_description"><para>the program name, needed by gdb for the &quot;[S]tack trace&quot;
  6710. option. If <parameter>prg_name</parameter> is <constant>NULL</constant>, <function>g_get_prgname()</function> is called to get
  6711. the program name (which will work correctly if <function>gdk_init()</function> or
  6712. <function>gtk_init()</function> has been called)</para><para>Passed as <code>prg-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>on-error-stack-trace</title><informalexample><programlisting>(define-values () (on-error-stack-trace prg-name))
  6713. </programlisting></informalexample><para>Invokes gdb, which attaches to the current process and shows a
  6714. stack trace. Called by <function>g_on_error_query()</function> when the &quot;[S]tack trace&quot;
  6715. option is selected. You can get the current process's program name
  6716. with <function>g_get_prgname()</function>, assuming that you have called <function>gtk_init()</function> or
  6717. <function>gdk_init()</function>.
  6718. </para>
  6719. <para>This function may cause different actions on non-UNIX platforms.
  6720. </para>
  6721. <para>When running on Windows, this function is *not* called by
  6722. <function>g_on_error_query()</function>. If called directly, it will raise an
  6723. exception, which will crash the program. If the <code>G_DEBUGGER</code> environment
  6724. variable is set, a debugger will be invoked to attach and
  6725. handle that exception (see [Running GLib Applications](glib-running.html)).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>prg_name</para></td><td class="parameter_description"><para>the program name, needed by gdb for the &quot;[S]tack trace&quot;
  6726. option</para><para>Passed as <code>prg-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>once-init-enter?</title><informalexample><programlisting>(define-values (%return) (once-init-enter? location))
  6727. </programlisting></informalexample><para>Function to be called when starting a critical initialization
  6728. section. The argument <parameter>location</parameter> must point to a static
  6729. 0-initialized variable that will be set to a value other than 0 at
  6730. the end of the initialization section. In combination with
  6731. <function>g_once_init_leave()</function> and the unique address <parameter>value_location</parameter>, it can
  6732. be ensured that an initialization section will be executed only once
  6733. during a program's life time, and that concurrent threads are
  6734. blocked until initialization completed. To be used in constructs
  6735. like this:
  6736. </para>
  6737. <para><informalexample><programlisting>
  6738. static gsize initialization_value = 0;
  6739. if (g_once_init_enter (&amp;initialization_value))
  6740. {
  6741. gsize setup_value = 42; // initialization code here
  6742. g_once_init_leave (&amp;initialization_value, setup_value);
  6743. }
  6744. // use initialization_value here
  6745. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>location</para></td><td class="parameter_description"><para>location of a static initializable variable
  6746. containing 0</para><para>Passed as <code>location</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>once-init-leave</title><informalexample><programlisting>(define-values () (once-init-leave location result))
  6747. </programlisting></informalexample><para>Counterpart to <function>g_once_init_enter()</function>. Expects a location of a static
  6748. 0-initialized initialization variable, and an initialization value
  6749. other than 0. Sets the variable to the initialization value, and
  6750. releases concurrent threads blocking in <function>g_once_init_enter()</function> on this
  6751. initialization variable.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>location</para></td><td class="parameter_description"><para>location of a static initializable variable
  6752. containing 0</para><para>Passed as <code>location</code></para></td></tr><tr><td class="parameter_name"><para>result</para></td><td class="parameter_description"><para>new non-0 value for *<parameter>value_location</parameter></para><para>Passed as <code>result</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>option-error-quark</title><informalexample><programlisting>(define-values (%return) (option-error-quark))
  6753. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>path-get-basename</title><informalexample><programlisting>(define-values (%return) (path-get-basename file-name))
  6754. </programlisting></informalexample><para>Gets the last component of the filename.
  6755. </para>
  6756. <para>If <parameter>file_name</parameter> ends with a directory separator it gets the component
  6757. before the last slash. If <parameter>file_name</parameter> consists only of directory
  6758. separators (and on Windows, possibly a drive letter), a single
  6759. separator is returned. If <parameter>file_name</parameter> is empty, it gets &quot;.&quot;.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>file_name</para></td><td class="parameter_description"><para>the name of the file</para><para>Passed as <code>file-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>path-get-dirname</title><informalexample><programlisting>(define-values (%return) (path-get-dirname file-name))
  6760. </programlisting></informalexample><para>Gets the directory components of a file name. For example, the directory
  6761. component of <code>/usr/bin/test</code> is <code>/usr/bin</code>. The directory component of <code>/</code>
  6762. is <code>/</code>.
  6763. </para>
  6764. <para>If the file name has no directory components &quot;.&quot; is returned.
  6765. The returned string should be freed when no longer needed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>file_name</para></td><td class="parameter_description"><para>the name of the file</para><para>Passed as <code>file-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>path-is-absolute?</title><informalexample><programlisting>(define-values (%return) (path-is-absolute? file-name))
  6766. </programlisting></informalexample><para>Returns <constant>TRUE</constant> if the given <parameter>file_name</parameter> is an absolute file name.
  6767. Note that this is a somewhat vague concept on Windows.
  6768. </para>
  6769. <para>On POSIX systems, an absolute file name is well-defined. It always
  6770. starts from the single root directory. For example &quot;/usr/local&quot;.
  6771. </para>
  6772. <para>On Windows, the concepts of current drive and drive-specific
  6773. current directory introduce vagueness. This function interprets as
  6774. an absolute file name one that either begins with a directory
  6775. separator such as &quot;\Users\tml&quot; or begins with the root on a drive,
  6776. for example &quot;C:\Windows&quot;. The first case also includes UNC paths
  6777. such as &quot;\\\\myserver\docs\foo&quot;. In all cases, either slashes or
  6778. backslashes are accepted.
  6779. </para>
  6780. <para>Note that a file name relative to the current drive root does not
  6781. truly specify a file uniquely over time and across processes, as
  6782. the current drive is a per-process value and can be changed.
  6783. </para>
  6784. <para>File names relative the current directory on some specific drive,
  6785. such as &quot;D:foo/bar&quot;, are not interpreted as absolute by this
  6786. function, but they obviously are not relative to the normal current
  6787. directory as returned by <function>getcwd()</function> or <function>g_get_current_dir()</function>
  6788. either. Such paths should be avoided, or need to be handled using
  6789. Windows-specific code.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>file_name</para></td><td class="parameter_description"><para>a file name</para><para>Passed as <code>file-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>path-skip-root</title><informalexample><programlisting>(define-values (%return) (path-skip-root file-name))
  6790. </programlisting></informalexample><para>Returns a pointer into <parameter>file_name</parameter> after the root component,
  6791. i.e. after the &quot;/&quot; in UNIX or &quot;C:\&quot; under Windows. If <parameter>file_name</parameter>
  6792. is not an absolute path it returns <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>file_name</para></td><td class="parameter_description"><para>a file name</para><para>Passed as <code>file-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>pattern-match?</title><informalexample><programlisting>(define-values
  6793. (%return)
  6794. (pattern-match? pspec string-length string string-reversed))
  6795. </programlisting></informalexample><para>Matches a string against a compiled pattern. Passing the correct
  6796. length of the string given is mandatory. The reversed string can be
  6797. omitted by passing <constant>NULL</constant>, this is more efficient if the reversed
  6798. version of the string to be matched is not at hand, as
  6799. <function>g_pattern_match()</function> will only construct it if the compiled pattern
  6800. requires reverse matches.
  6801. </para>
  6802. <para>Note that, if the user code will (possibly) match a string against a
  6803. multitude of patterns containing wildcards, chances are high that
  6804. some patterns will require a reversed string. In this case, it's
  6805. more efficient to provide the reversed string to avoid multiple
  6806. constructions thereof in the various calls to <function>g_pattern_match()</function>.
  6807. </para>
  6808. <para>Note also that the reverse of a UTF-8 encoded string can in general
  6809. not be obtained by <function>g_strreverse()</function>. This works only if the string
  6810. does not contain any multibyte characters. GLib offers the
  6811. <function>g_utf8_strreverse()</function> function to reverse UTF-8 encoded strings.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pspec</para></td><td class="parameter_description"><para>a <type>GPatternSpec</type></para><para>Passed as <code>pspec</code></para></td></tr><tr><td class="parameter_name"><para>string_length</para></td><td class="parameter_description"><para>the length of <parameter>string</parameter> (in bytes, i.e. <function>strlen()</function>,
  6812. not <function>g_utf8_strlen()</function>)</para><para>Passed as <code>string-length</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the UTF-8 encoded string to match</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>string_reversed</para></td><td class="parameter_description"><para>the reverse of <parameter>string</parameter> or <constant>NULL</constant></para><para>Passed as <code>string-reversed</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>pattern-match-simple?</title><informalexample><programlisting>(define-values (%return) (pattern-match-simple? pattern string))
  6813. </programlisting></informalexample><para>Matches a string against a pattern given as a string. If this
  6814. function is to be called in a loop, it's more efficient to compile
  6815. the pattern once with <function>g_pattern_spec_new()</function> and call
  6816. <function>g_pattern_match_string()</function> repeatedly.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pattern</para></td><td class="parameter_description"><para>the UTF-8 encoded pattern</para><para>Passed as <code>pattern</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the UTF-8 encoded string to match</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>pattern-match-string?</title><informalexample><programlisting>(define-values (%return) (pattern-match-string? pspec string))
  6817. </programlisting></informalexample><para>Matches a string against a compiled pattern. If the string is to be
  6818. matched against more than one pattern, consider using
  6819. <function>g_pattern_match()</function> instead while supplying the reversed string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pspec</para></td><td class="parameter_description"><para>a <type>GPatternSpec</type></para><para>Passed as <code>pspec</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the UTF-8 encoded string to match</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>pointer-bit-lock</title><informalexample><programlisting>(define-values () (pointer-bit-lock address lock-bit))
  6820. </programlisting></informalexample><para>This is equivalent to g_bit_lock, but working on pointers (or other
  6821. pointer-sized values).
  6822. </para>
  6823. <para>For portability reasons, you may only lock on the bottom 32 bits of
  6824. the pointer.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>address</para></td><td class="parameter_description"><para>a pointer to a <type>gpointer</type>-sized value</para><para>Passed as <code>address</code></para></td></tr><tr><td class="parameter_name"><para>lock_bit</para></td><td class="parameter_description"><para>a bit value between 0 and 31</para><para>Passed as <code>lock-bit</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>pointer-bit-trylock?</title><informalexample><programlisting>(define-values (%return) (pointer-bit-trylock? address lock-bit))
  6825. </programlisting></informalexample><para>This is equivalent to g_bit_trylock, but working on pointers (or
  6826. other pointer-sized values).
  6827. </para>
  6828. <para>For portability reasons, you may only lock on the bottom 32 bits of
  6829. the pointer.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>address</para></td><td class="parameter_description"><para>a pointer to a <type>gpointer</type>-sized value</para><para>Passed as <code>address</code></para></td></tr><tr><td class="parameter_name"><para>lock_bit</para></td><td class="parameter_description"><para>a bit value between 0 and 31</para><para>Passed as <code>lock-bit</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>pointer-bit-unlock</title><informalexample><programlisting>(define-values () (pointer-bit-unlock address lock-bit))
  6830. </programlisting></informalexample><para>This is equivalent to g_bit_unlock, but working on pointers (or other
  6831. pointer-sized values).
  6832. </para>
  6833. <para>For portability reasons, you may only lock on the bottom 32 bits of
  6834. the pointer.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>address</para></td><td class="parameter_description"><para>a pointer to a <type>gpointer</type>-sized value</para><para>Passed as <code>address</code></para></td></tr><tr><td class="parameter_name"><para>lock_bit</para></td><td class="parameter_description"><para>a bit value between 0 and 31</para><para>Passed as <code>lock-bit</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>poll</title><informalexample><programlisting>(define-values (%return) (poll fds nfds timeout))
  6835. </programlisting></informalexample><para>Polls <parameter>fds</parameter>, as with the <function>poll()</function> system call, but portably. (On
  6836. systems that don't have <function>poll()</function>, it is emulated using <function>select()</function>.)
  6837. This is used internally by <type>GMainContext</type>, but it can be called
  6838. directly if you need to block until a file descriptor is ready, but
  6839. don't want to run the full main loop.
  6840. </para>
  6841. <para>Each element of <parameter>fds</parameter> is a <type>GPollFD</type> describing a single file
  6842. descriptor to poll. The <parameter>fd</parameter> field indicates the file descriptor,
  6843. and the <parameter>events</parameter> field indicates the events to poll for. On return,
  6844. the <parameter>revents</parameter> fields will be filled with the events that actually
  6845. occurred.
  6846. </para>
  6847. <para>On POSIX systems, the file descriptors in <parameter>fds</parameter> can be any sort of
  6848. file descriptor, but the situation is much more complicated on
  6849. Windows. If you need to use <function>g_poll()</function> in code that has to run on
  6850. Windows, the easiest solution is to construct all of your
  6851. <type>GPollFDs</type> with <function>g_io_channel_win32_make_pollfd()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>fds</para></td><td class="parameter_description"><para>file descriptors to poll</para><para>Passed as <code>fds</code></para></td></tr><tr><td class="parameter_name"><para>nfds</para></td><td class="parameter_description"><para>the number of file descriptors in <parameter>fds</parameter></para><para>Passed as <code>nfds</code></para></td></tr><tr><td class="parameter_name"><para>timeout</para></td><td class="parameter_description"><para>amount of time to wait, in milliseconds, or -1 to wait forever</para><para>Passed as <code>timeout</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>prefix-error-literal</title><informalexample><programlisting>(define-values () (prefix-error-literal err prefix))
  6852. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>err</para></td><td class="parameter_description"><para></para><para>Passed as <code>err</code></para></td></tr><tr><td class="parameter_name"><para>prefix</para></td><td class="parameter_description"><para></para><para>Passed as <code>prefix</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>propagate-error</title><informalexample><programlisting>(define-values (dest) (propagate-error src))
  6853. </programlisting></informalexample><para>If <parameter>dest</parameter> is <constant>NULL</constant>, free <parameter>src</parameter>; otherwise, moves <parameter>src</parameter> into *<parameter>dest</parameter>.
  6854. The error variable <parameter>dest</parameter> points to must be <constant>NULL</constant>.
  6855. </para>
  6856. <para><parameter>src</parameter> must be non-<constant>NULL</constant>.
  6857. </para>
  6858. <para>Note that <parameter>src</parameter> is no longer valid after this call. If you want
  6859. to keep using the same GError*, you need to set it to <constant>NULL</constant>
  6860. after calling this function on it.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dest</para></td><td class="parameter_description"><para>error return location</para><para>Passed as <code>dest</code></para></td></tr><tr><td class="parameter_name"><para>src</para></td><td class="parameter_description"><para>error to move into the return location</para><para>Passed as <code>src</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>quark-from-static-string</title><informalexample><programlisting>(define-values (%return) (quark-from-static-string string))
  6861. </programlisting></informalexample><para>Gets the <type>GQuark</type> identifying the given (static) string. If the
  6862. string does not currently have an associated <type>GQuark</type>, a new <type>GQuark</type>
  6863. is created, linked to the given string.
  6864. </para>
  6865. <para>Note that this function is identical to <function>g_quark_from_string()</function> except
  6866. that if a new <type>GQuark</type> is created the string itself is used rather
  6867. than a copy. This saves memory, but can only be used if the string
  6868. will continue to exist until the program terminates. It can be used
  6869. with statically allocated strings in the main program, but not with
  6870. statically allocated memory in dynamically loaded modules, if you
  6871. expect to ever unload the module again (e.g. do not use this
  6872. function in GTK+ theme engines).
  6873. </para>
  6874. <para>This function must not be used before library constructors have finished
  6875. running. In particular, this means it cannot be used to initialize global
  6876. variables in C++.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>quark-from-string</title><informalexample><programlisting>(define-values (%return) (quark-from-string string))
  6877. </programlisting></informalexample><para>Gets the <type>GQuark</type> identifying the given string. If the string does
  6878. not currently have an associated <type>GQuark</type>, a new <type>GQuark</type> is created,
  6879. using a copy of the string.
  6880. </para>
  6881. <para>This function must not be used before library constructors have finished
  6882. running. In particular, this means it cannot be used to initialize global
  6883. variables in C++.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>quark-to-string</title><informalexample><programlisting>(define-values (%return) (quark-to-string quark))
  6884. </programlisting></informalexample><para>Gets the string associated with the given <type>GQuark</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>quark</para></td><td class="parameter_description"><para>a <type>GQuark</type>.</para><para>Passed as <code>quark</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>quark-try-string</title><informalexample><programlisting>(define-values (%return) (quark-try-string string))
  6885. </programlisting></informalexample><para>Gets the <type>GQuark</type> associated with the given string, or 0 if string is
  6886. <constant>NULL</constant> or it has no associated <type>GQuark</type>.
  6887. </para>
  6888. <para>If you want the GQuark to be created if it doesn't already exist,
  6889. use <function>g_quark_from_string()</function> or <function>g_quark_from_static_string()</function>.
  6890. </para>
  6891. <para>This function must not be used before library constructors have finished
  6892. running.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>random-double</title><informalexample><programlisting>(define-values (%return) (random-double))
  6893. </programlisting></informalexample><para>Returns a random <type>gdouble</type> equally distributed over the range [0..1).</para></refsect2><refsect2><title>random-double-range</title><informalexample><programlisting>(define-values (%return) (random-double-range begin end))
  6894. </programlisting></informalexample><para>Returns a random <type>gdouble</type> equally distributed over the range
  6895. [<parameter>begin</parameter>..<parameter>end</parameter>).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>begin</para></td><td class="parameter_description"><para>lower closed bound of the interval</para><para>Passed as <code>begin</code></para></td></tr><tr><td class="parameter_name"><para>end</para></td><td class="parameter_description"><para>upper open bound of the interval</para><para>Passed as <code>end</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>random-int</title><informalexample><programlisting>(define-values (%return) (random-int))
  6896. </programlisting></informalexample><para>Return a random <type>guint32</type> equally distributed over the range
  6897. [0..2^32-1].</para></refsect2><refsect2><title>random-int-range</title><informalexample><programlisting>(define-values (%return) (random-int-range begin end))
  6898. </programlisting></informalexample><para>Returns a random <type>gint32</type> equally distributed over the range
  6899. [<parameter>begin</parameter>..<parameter>end</parameter>-1].</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>begin</para></td><td class="parameter_description"><para>lower closed bound of the interval</para><para>Passed as <code>begin</code></para></td></tr><tr><td class="parameter_name"><para>end</para></td><td class="parameter_description"><para>upper open bound of the interval</para><para>Passed as <code>end</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>random-set-seed</title><informalexample><programlisting>(define-values () (random-set-seed seed))
  6900. </programlisting></informalexample><para>Sets the seed for the global random number generator, which is used
  6901. by the g_random_* functions, to <parameter>seed</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>seed</para></td><td class="parameter_description"><para>a value to reinitialize the global random number generator</para><para>Passed as <code>seed</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>rc-box-acquire</title><informalexample><programlisting>(define-values (%return) (rc-box-acquire mem-block))
  6902. </programlisting></informalexample><para>Acquires a reference on the data pointed by <parameter>mem_block</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>a pointer to reference counted data</para><para>Passed as <code>mem-block</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>rc-box-alloc</title><informalexample><programlisting>(define-values (%return) (rc-box-alloc block-size))
  6903. </programlisting></informalexample><para>Allocates <parameter>block_size</parameter> bytes of memory, and adds reference
  6904. counting semantics to it.
  6905. </para>
  6906. <para>The data will be freed when its reference count drops to
  6907. zero.
  6908. </para>
  6909. <para>The allocated data is guaranteed to be suitably aligned for any
  6910. built-in type.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>block_size</para></td><td class="parameter_description"><para>the size of the allocation, must be greater than 0</para><para>Passed as <code>block-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>rc-box-alloc0</title><informalexample><programlisting>(define-values (%return) (rc-box-alloc0 block-size))
  6911. </programlisting></informalexample><para>Allocates <parameter>block_size</parameter> bytes of memory, and adds reference
  6912. counting semantics to it.
  6913. </para>
  6914. <para>The contents of the returned data is set to zero.
  6915. </para>
  6916. <para>The data will be freed when its reference count drops to
  6917. zero.
  6918. </para>
  6919. <para>The allocated data is guaranteed to be suitably aligned for any
  6920. built-in type.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>block_size</para></td><td class="parameter_description"><para>the size of the allocation, must be greater than 0</para><para>Passed as <code>block-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>rc-box-dup</title><informalexample><programlisting>(define-values (%return) (rc-box-dup block-size mem-block))
  6921. </programlisting></informalexample><para>Allocates a new block of data with reference counting
  6922. semantics, and copies <parameter>block_size</parameter> bytes of <parameter>mem_block</parameter>
  6923. into it.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>block_size</para></td><td class="parameter_description"><para>the number of bytes to copy, must be greater than 0</para><para>Passed as <code>block-size</code></para></td></tr><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>the memory to copy</para><para>Passed as <code>mem-block</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>rc-box-get-size</title><informalexample><programlisting>(define-values (%return) (rc-box-get-size mem-block))
  6924. </programlisting></informalexample><para>Retrieves the size of the reference counted data pointed by <parameter>mem_block</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>a pointer to reference counted data</para><para>Passed as <code>mem-block</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>rc-box-release</title><informalexample><programlisting>(define-values () (rc-box-release mem-block))
  6925. </programlisting></informalexample><para>Releases a reference on the data pointed by <parameter>mem_block</parameter>.
  6926. </para>
  6927. <para>If the reference was the last one, it will free the
  6928. resources allocated for <parameter>mem_block</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>a pointer to reference counted data</para><para>Passed as <code>mem-block</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>rc-box-release-full</title><informalexample><programlisting>(define-values () (rc-box-release-full mem-block clear-func))
  6929. </programlisting></informalexample><para>Releases a reference on the data pointed by <parameter>mem_block</parameter>.
  6930. </para>
  6931. <para>If the reference was the last one, it will call <parameter>clear_func</parameter>
  6932. to clear the contents of <parameter>mem_block</parameter>, and then will free the
  6933. resources allocated for <parameter>mem_block</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>a pointer to reference counted data</para><para>Passed as <code>mem-block</code></para></td></tr><tr><td class="parameter_name"><para>clear_func</para></td><td class="parameter_description"><para>a function to call when clearing the data</para><para>Passed as <code>clear-func</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>realloc</title><informalexample><programlisting>(define-values (%return) (realloc mem n-bytes))
  6934. </programlisting></informalexample><para>Reallocates the memory pointed to by <parameter>mem</parameter>, so that it now has space for
  6935. <parameter>n_bytes</parameter> bytes of memory. It returns the new address of the memory, which may
  6936. have been moved. <parameter>mem</parameter> may be <constant>NULL</constant>, in which case it's considered to
  6937. have zero-length. <parameter>n_bytes</parameter> may be 0, in which case <constant>NULL</constant> will be returned
  6938. and <parameter>mem</parameter> will be freed unless it is <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem</para></td><td class="parameter_description"><para>the memory to reallocate</para><para>Passed as <code>mem</code></para></td></tr><tr><td class="parameter_name"><para>n_bytes</para></td><td class="parameter_description"><para>new size of the memory in bytes</para><para>Passed as <code>n-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>realloc-n</title><informalexample><programlisting>(define-values (%return) (realloc-n mem n-blocks n-block-bytes))
  6939. </programlisting></informalexample><para>This function is similar to <function>g_realloc()</function>, allocating (<parameter>n_blocks</parameter> * <parameter>n_block_bytes</parameter>) bytes,
  6940. but care is taken to detect possible overflow during multiplication.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem</para></td><td class="parameter_description"><para>the memory to reallocate</para><para>Passed as <code>mem</code></para></td></tr><tr><td class="parameter_name"><para>n_blocks</para></td><td class="parameter_description"><para>the number of blocks to allocate</para><para>Passed as <code>n-blocks</code></para></td></tr><tr><td class="parameter_name"><para>n_block_bytes</para></td><td class="parameter_description"><para>the size of each block in bytes</para><para>Passed as <code>n-block-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref-count-compare?</title><informalexample><programlisting>(define-values (%return) (ref-count-compare? rc val))
  6941. </programlisting></informalexample><para>Compares the current value of <parameter>rc</parameter> with <parameter>val</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>rc</para></td><td class="parameter_description"><para>the address of a reference count variable</para><para>Passed as <code>rc</code></para></td></tr><tr><td class="parameter_name"><para>val</para></td><td class="parameter_description"><para>the value to compare</para><para>Passed as <code>val</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref-count-dec?</title><informalexample><programlisting>(define-values (%return) (ref-count-dec? rc))
  6942. </programlisting></informalexample><para>Decreases the reference count.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>rc</para></td><td class="parameter_description"><para>the address of a reference count variable</para><para>Passed as <code>rc</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref-count-inc</title><informalexample><programlisting>(define-values () (ref-count-inc rc))
  6943. </programlisting></informalexample><para>Increases the reference count.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>rc</para></td><td class="parameter_description"><para>the address of a reference count variable</para><para>Passed as <code>rc</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref-count-init</title><informalexample><programlisting>(define-values () (ref-count-init rc))
  6944. </programlisting></informalexample><para>Initializes a reference count variable.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>rc</para></td><td class="parameter_description"><para>the address of a reference count variable</para><para>Passed as <code>rc</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref-string-acquire</title><informalexample><programlisting>(define-values (%return) (ref-string-acquire str))
  6945. </programlisting></informalexample><para>Acquires a reference on a string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a reference counted string</para><para>Passed as <code>str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref-string-length</title><informalexample><programlisting>(define-values (%return) (ref-string-length str))
  6946. </programlisting></informalexample><para>Retrieves the length of <parameter>str</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a reference counted string</para><para>Passed as <code>str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref-string-new</title><informalexample><programlisting>(define-values (%return) (ref-string-new str))
  6947. </programlisting></informalexample><para>Creates a new reference counted string and copies the contents of <parameter>str</parameter>
  6948. into it.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a NUL-terminated string</para><para>Passed as <code>str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref-string-new-intern</title><informalexample><programlisting>(define-values (%return) (ref-string-new-intern str))
  6949. </programlisting></informalexample><para>Creates a new reference counted string and copies the content of <parameter>str</parameter>
  6950. into it.
  6951. </para>
  6952. <para>If you call this function multiple times with the same <parameter>str</parameter>, or with
  6953. the same contents of <parameter>str</parameter>, it will return a new reference, instead of
  6954. creating a new string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a NUL-terminated string</para><para>Passed as <code>str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref-string-new-len</title><informalexample><programlisting>(define-values (%return) (ref-string-new-len str len))
  6955. </programlisting></informalexample><para>Creates a new reference counted string and copies the contents of <parameter>str</parameter>
  6956. into it, up to <parameter>len</parameter> bytes.
  6957. </para>
  6958. <para>Since this function does not stop at nul bytes, it is the caller's
  6959. responsibility to ensure that <parameter>str</parameter> has at least <parameter>len</parameter> addressable bytes.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>str</parameter> to use, or -1 if <parameter>str</parameter> is nul-terminated</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ref-string-release</title><informalexample><programlisting>(define-values () (ref-string-release str))
  6960. </programlisting></informalexample><para>Releases a reference on a string; if it was the last reference, the
  6961. resources allocated by the string are freed as well.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a reference counted string</para><para>Passed as <code>str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>regex-check-replacement</title><informalexample><programlisting>(define-values (%return has-references) (regex-check-replacement replacement))
  6962. </programlisting></informalexample><para>Checks whether <parameter>replacement</parameter> is a valid replacement string
  6963. (see <function>g_regex_replace()</function>), i.e. that all escape sequences in
  6964. it are valid.
  6965. </para>
  6966. <para>If <parameter>has_references</parameter> is not <constant>NULL</constant> then <parameter>replacement</parameter> is checked
  6967. for pattern references. For instance, replacement text 'foo\n'
  6968. does not contain references and may be evaluated without information
  6969. about actual match, but '\0\1' (whole match followed by first
  6970. subpattern) requires valid <type>GMatchInfo</type> object.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>replacement</para></td><td class="parameter_description"><para>the replacement string</para><para>Passed as <code>replacement</code></para></td></tr><tr><td class="parameter_name"><para>has_references</para></td><td class="parameter_description"><para>location to store information about
  6971. references in <parameter>replacement</parameter> or <constant>NULL</constant></para><para>Passed as <code>has-references</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>regex-error-quark</title><informalexample><programlisting>(define-values (%return) (regex-error-quark))
  6972. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>regex-escape-nul</title><informalexample><programlisting>(define-values (%return) (regex-escape-nul string length))
  6973. </programlisting></informalexample><para>Escapes the nul characters in <parameter>string</parameter> to &quot;\x00&quot;. It can be used
  6974. to compile a regex with embedded nul characters.
  6975. </para>
  6976. <para>For completeness, <parameter>length</parameter> can be -1 for a nul-terminated string.
  6977. In this case the output string will be of course equal to <parameter>string</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to escape</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of <parameter>string</parameter></para><para>Passed as <code>length</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>regex-escape-string</title><informalexample><programlisting>(define-values (%return) (regex-escape-string string))
  6978. </programlisting></informalexample><para>Escapes the special characters used for regular expressions
  6979. in <parameter>string</parameter>, for instance &quot;a.b*c&quot; becomes &quot;a\.b\*c&quot;. This
  6980. function is useful to dynamically generate regular expressions.
  6981. </para>
  6982. <para><parameter>string</parameter> can contain nul characters that are replaced with &quot;\0&quot;,
  6983. in this case remember to specify the correct length of <parameter>string</parameter>
  6984. in <parameter>length</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to escape</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of <parameter>string</parameter>, in bytes, or -1 if <parameter>string</parameter> is nul-terminated</para><para>Inferred from <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>regex-match-simple?</title><informalexample><programlisting>(define-values
  6985. (%return)
  6986. (regex-match-simple? pattern string compile-options match-options))
  6987. </programlisting></informalexample><para>Scans for a match in <parameter>string</parameter> for <parameter>pattern</parameter>.
  6988. </para>
  6989. <para>This function is equivalent to <function>g_regex_match()</function> but it does not
  6990. require to compile the pattern with <function>g_regex_new()</function>, avoiding some
  6991. lines of code when you need just to do a match without extracting
  6992. substrings, capture counts, and so on.
  6993. </para>
  6994. <para>If this function is to be called on the same <parameter>pattern</parameter> more than
  6995. once, it's more efficient to compile the pattern once with
  6996. <function>g_regex_new()</function> and then use <function>g_regex_match()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pattern</para></td><td class="parameter_description"><para>the regular expression</para><para>Passed as <code>pattern</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to scan for matches</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>compile_options</para></td><td class="parameter_description"><para>compile options for the regular expression, or 0</para><para>Passed as <code>compile-options</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>match options, or 0</para><para>Passed as <code>match-options</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>regex-split-simple</title><informalexample><programlisting>(define-values
  6997. (%return)
  6998. (regex-split-simple pattern string compile-options match-options))
  6999. </programlisting></informalexample><para>Breaks the string on the pattern, and returns an array of
  7000. the tokens. If the pattern contains capturing parentheses,
  7001. then the text for each of the substrings will also be returned.
  7002. If the pattern does not match anywhere in the string, then the
  7003. whole string is returned as the first token.
  7004. </para>
  7005. <para>This function is equivalent to <function>g_regex_split()</function> but it does
  7006. not require to compile the pattern with <function>g_regex_new()</function>, avoiding
  7007. some lines of code when you need just to do a split without
  7008. extracting substrings, capture counts, and so on.
  7009. </para>
  7010. <para>If this function is to be called on the same <parameter>pattern</parameter> more than
  7011. once, it's more efficient to compile the pattern once with
  7012. <function>g_regex_new()</function> and then use <function>g_regex_split()</function>.
  7013. </para>
  7014. <para>As a special case, the result of splitting the empty string &quot;&quot;
  7015. is an empty vector, not a vector containing a single string.
  7016. The reason for this special case is that being able to represent
  7017. an empty vector is typically more useful than consistent handling
  7018. of empty elements. If you do need to represent empty elements,
  7019. you'll need to check for the empty string before calling this
  7020. function.
  7021. </para>
  7022. <para>A pattern that can match empty strings splits <parameter>string</parameter> into
  7023. separate characters wherever it matches the empty string between
  7024. characters. For example splitting &quot;ab c&quot; using as a separator
  7025. &quot;\s*&quot;, you will get &quot;a&quot;, &quot;b&quot; and &quot;c&quot;.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pattern</para></td><td class="parameter_description"><para>the regular expression</para><para>Passed as <code>pattern</code></para></td></tr><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to scan for matches</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>compile_options</para></td><td class="parameter_description"><para>compile options for the regular expression, or 0</para><para>Passed as <code>compile-options</code></para></td></tr><tr><td class="parameter_name"><para>match_options</para></td><td class="parameter_description"><para>match options, or 0</para><para>Passed as <code>match-options</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>reload-user-special-dirs-cache</title><informalexample><programlisting>(define-values () (reload-user-special-dirs-cache))
  7026. </programlisting></informalexample><para>Resets the cache used for <function>g_get_user_special_dir()</function>, so
  7027. that the latest on-disk version is used. Call this only
  7028. if you just changed the data on disk yourself.
  7029. </para>
  7030. <para>Due to thread safety issues this may cause leaking of strings
  7031. that were previously returned from <function>g_get_user_special_dir()</function>
  7032. that can't be freed. We ensure to only leak the data for
  7033. the directories that actually changed value though.</para></refsect2><refsect2><title>rmdir</title><informalexample><programlisting>(define-values (%return) (rmdir filename))
  7034. </programlisting></informalexample><para>A wrapper for the POSIX <function>rmdir()</function> function. The <function>rmdir()</function> function
  7035. deletes a directory from the filesystem.
  7036. </para>
  7037. <para>See your C library manual for more details about how <function>rmdir()</function> works
  7038. on your system.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>a pathname in the GLib file name encoding
  7039. (UTF-8 on Windows)</para><para>Passed as <code>filename</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-application-name</title><informalexample><programlisting>(define-values () (set-application-name application-name))
  7040. </programlisting></informalexample><para>Sets a human-readable name for the application. This name should be
  7041. localized if possible, and is intended for display to the user.
  7042. Contrast with <function>g_set_prgname()</function>, which sets a non-localized name.
  7043. <function>g_set_prgname()</function> will be called automatically by <function>gtk_init()</function>,
  7044. but <function>g_set_application_name()</function> will not.
  7045. </para>
  7046. <para>Note that for thread safety reasons, this function can only
  7047. be called once.
  7048. </para>
  7049. <para>The application name will be used in contexts such as error messages,
  7050. or when displaying an application's name in the task list.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>application_name</para></td><td class="parameter_description"><para>localized name of the application</para><para>Passed as <code>application-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-error-literal</title><informalexample><programlisting>(define-values (err) (set-error-literal domain code message))
  7051. </programlisting></informalexample><para>Does nothing if <parameter>err</parameter> is <constant>NULL</constant>; if <parameter>err</parameter> is non-<constant>NULL</constant>, then *<parameter>err</parameter>
  7052. must be <constant>NULL</constant>. A new <type>GError</type> is created and assigned to *<parameter>err</parameter>.
  7053. Unlike <function>g_set_error()</function>, <parameter>message</parameter> is not a <function>printf()</function>-style format string.
  7054. Use this function if <parameter>message</parameter> contains text you don't have control over,
  7055. that could include <function>printf()</function> escape sequences.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>err</para></td><td class="parameter_description"><para>a return location for a <type>GError</type></para><para>Passed as <code>err</code></para></td></tr><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para>error domain</para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>code</para></td><td class="parameter_description"><para>error code</para><para>Passed as <code>code</code></para></td></tr><tr><td class="parameter_name"><para>message</para></td><td class="parameter_description"><para>error message</para><para>Passed as <code>message</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>set-prgname</title><informalexample><programlisting>(define-values () (set-prgname prgname))
  7056. </programlisting></informalexample><para>Sets the name of the program. This name should not be localized,
  7057. in contrast to <function>g_set_application_name()</function>.
  7058. </para>
  7059. <para>If you are using <type>GApplication</type> the program name is set in
  7060. <function>g_application_run()</function>. In case of GDK or GTK+ it is set in
  7061. <function>gdk_init()</function>, which is called by <function>gtk_init()</function> and the
  7062. <type>“startup”</type> handler. The program name is found by
  7063. taking the last component of <parameter>argv</parameter>[0].
  7064. </para>
  7065. <para>Note that for thread-safety reasons this function can only be called once.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>prgname</para></td><td class="parameter_description"><para>the name of the program.</para><para>Passed as <code>prgname</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>setenv?</title><informalexample><programlisting>(define-values (%return) (setenv? variable value overwrite))
  7066. </programlisting></informalexample><para>Sets an environment variable. On UNIX, both the variable's name and
  7067. value can be arbitrary byte strings, except that the variable's name
  7068. cannot contain '='. On Windows, they should be in UTF-8.
  7069. </para>
  7070. <para>Note that on some systems, when variables are overwritten, the memory
  7071. used for the previous variables and its value isn't reclaimed.
  7072. </para>
  7073. <para>You should be mindful of the fact that environment variable handling
  7074. in UNIX is not thread-safe, and your program may crash if one thread
  7075. calls <function>g_setenv()</function> while another thread is calling <function>getenv()</function>. (And note
  7076. that many functions, such as <function>gettext()</function>, call <function>getenv()</function> internally.)
  7077. This function is only safe to use at the very start of your program,
  7078. before creating any other threads (or creating objects that create
  7079. worker threads of their own).
  7080. </para>
  7081. <para>If you need to set up the environment for a child process, you can
  7082. use <function>g_get_environ()</function> to get an environment array, modify that with
  7083. <function>g_environ_setenv()</function> and <function>g_environ_unsetenv()</function>, and then pass that
  7084. array directly to <function>execvpe()</function>, <function>g_spawn_async()</function>, or the like.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>variable</para></td><td class="parameter_description"><para>the environment variable to set, must not
  7085. contain '='.</para><para>Passed as <code>variable</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para>the value for to set the variable to.</para><para>Passed as <code>value</code></para></td></tr><tr><td class="parameter_name"><para>overwrite</para></td><td class="parameter_description"><para>whether to change the variable if it already exists.</para><para>Passed as <code>overwrite</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>shell-error-quark</title><informalexample><programlisting>(define-values (%return) (shell-error-quark))
  7086. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>shell-parse-argv</title><informalexample><programlisting>(define-values (%return argcp argvp) (shell-parse-argv command-line))
  7087. </programlisting></informalexample><para>Parses a command line into an argument vector, in much the same way
  7088. the shell would, but without many of the expansions the shell would
  7089. perform (variable expansion, globs, operators, filename expansion,
  7090. etc. are not supported). The results are defined to be the same as
  7091. those you would get from a UNIX98 /bin/sh, as long as the input
  7092. contains none of the unsupported shell expansions. If the input
  7093. does contain such expansions, they are passed through
  7094. literally. Possible errors are those from the <type>G_SHELL_ERROR</type>
  7095. domain. Free the returned vector with <function>g_strfreev()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>command_line</para></td><td class="parameter_description"><para>command line to parse</para><para>Passed as <code>command-line</code></para></td></tr><tr><td class="parameter_name"><para>argcp</para></td><td class="parameter_description"><para>return location for number of args</para><para>Inferred from <code>argvp</code></para></td></tr><tr><td class="parameter_name"><para>argvp</para></td><td class="parameter_description"><para>
  7096. <para>return location for array of args</para></para><para>Passed as <code>argvp</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>shell-quote</title><informalexample><programlisting>(define-values (%return) (shell-quote unquoted-string))
  7097. </programlisting></informalexample><para>Quotes a string so that the shell (/bin/sh) will interpret the
  7098. quoted string to mean <parameter>unquoted_string</parameter>. If you pass a filename to
  7099. the shell, for example, you should first quote it with this
  7100. function. The return value must be freed with <function>g_free()</function>. The
  7101. quoting style used is undefined (single or double quotes may be
  7102. used).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>unquoted_string</para></td><td class="parameter_description"><para>a literal string</para><para>Passed as <code>unquoted-string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>shell-unquote</title><informalexample><programlisting>(define-values (%return) (shell-unquote quoted-string))
  7103. </programlisting></informalexample><para>Unquotes a string as the shell (/bin/sh) would. Only handles
  7104. quotes; if a string contains file globs, arithmetic operators,
  7105. variables, backticks, redirections, or other special-to-the-shell
  7106. features, the result will be different from the result a real shell
  7107. would produce (the variables, backticks, etc. will be passed
  7108. through literally instead of being expanded). This function is
  7109. guaranteed to succeed if applied to the result of
  7110. <function>g_shell_quote()</function>. If it fails, it returns <constant>NULL</constant> and sets the
  7111. error. The <parameter>quoted_string</parameter> need not actually contain quoted or
  7112. escaped text; <function>g_shell_unquote()</function> simply goes through the string and
  7113. unquotes/unescapes anything that the shell would. Both single and
  7114. double quotes are handled, as are escapes including escaped
  7115. newlines. The return value must be freed with <function>g_free()</function>. Possible
  7116. errors are in the <type>G_SHELL_ERROR</type> domain.
  7117. </para>
  7118. <para>Shell quoting rules are a bit strange. Single quotes preserve the
  7119. literal string exactly. escape sequences are not allowed; not even
  7120. \' - if you want a ' in the quoted text, you have to do something
  7121. like 'foo'\''bar'. Double quotes allow $, `, &quot;, \, and newline to
  7122. be escaped with backslash. Otherwise double quotes preserve things
  7123. literally.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>quoted_string</para></td><td class="parameter_description"><para>shell-quoted string</para><para>Passed as <code>quoted-string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>slice-alloc</title><informalexample><programlisting>(define-values (%return) (slice-alloc block-size))
  7124. </programlisting></informalexample><para>Allocates a block of memory from the slice allocator.
  7125. The block address handed out can be expected to be aligned
  7126. to at least 1 * sizeof (void*),
  7127. though in general slices are 2 * sizeof (void*) bytes aligned,
  7128. if a <function>malloc()</function> fallback implementation is used instead,
  7129. the alignment may be reduced in a libc dependent fashion.
  7130. Note that the underlying slice allocation mechanism can
  7131. be changed with the [<code>G_SLICE=always-malloc</code>][G_SLICE]
  7132. environment variable.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>block_size</para></td><td class="parameter_description"><para>the number of bytes to allocate</para><para>Passed as <code>block-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>slice-alloc0</title><informalexample><programlisting>(define-values (%return) (slice-alloc0 block-size))
  7133. </programlisting></informalexample><para>Allocates a block of memory via <function>g_slice_alloc()</function> and initializes
  7134. the returned memory to 0. Note that the underlying slice allocation
  7135. mechanism can be changed with the [<code>G_SLICE=always-malloc</code>][G_SLICE]
  7136. environment variable.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>block_size</para></td><td class="parameter_description"><para>the number of bytes to allocate</para><para>Passed as <code>block-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>slice-copy</title><informalexample><programlisting>(define-values (%return) (slice-copy block-size mem-block))
  7137. </programlisting></informalexample><para>Allocates a block of memory from the slice allocator
  7138. and copies <parameter>block_size</parameter> bytes into it from <parameter>mem_block</parameter>.
  7139. </para>
  7140. <para><parameter>mem_block</parameter> must be non-<constant>NULL</constant> if <parameter>block_size</parameter> is non-zero.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>block_size</para></td><td class="parameter_description"><para>the number of bytes to allocate</para><para>Passed as <code>block-size</code></para></td></tr><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>the memory to copy</para><para>Passed as <code>mem-block</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>slice-free1</title><informalexample><programlisting>(define-values () (slice-free1 block-size mem-block))
  7141. </programlisting></informalexample><para>Frees a block of memory.
  7142. </para>
  7143. <para>The memory must have been allocated via <function>g_slice_alloc()</function> or
  7144. <function>g_slice_alloc0()</function> and the <parameter>block_size</parameter> has to match the size
  7145. specified upon allocation. Note that the exact release behaviour
  7146. can be changed with the [<code>G_DEBUG=gc-friendly</code>][G_DEBUG] environment
  7147. variable, also see [<code>G_SLICE</code>][G_SLICE] for related debugging options.
  7148. </para>
  7149. <para>If <parameter>mem_block</parameter> is <constant>NULL</constant>, this function does nothing.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>block_size</para></td><td class="parameter_description"><para>the size of the block</para><para>Passed as <code>block-size</code></para></td></tr><tr><td class="parameter_name"><para>mem_block</para></td><td class="parameter_description"><para>a pointer to the block to free</para><para>Passed as <code>mem-block</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>slice-free-chain-with-offset</title><informalexample><programlisting>(define-values
  7150. ()
  7151. (slice-free-chain-with-offset block-size mem-chain next-offset))
  7152. </programlisting></informalexample><para>Frees a linked list of memory blocks of structure type <parameter>type</parameter>.
  7153. </para>
  7154. <para>The memory blocks must be equal-sized, allocated via
  7155. <function>g_slice_alloc()</function> or <function>g_slice_alloc0()</function> and linked together by a
  7156. <parameter>next</parameter> pointer (similar to <type>GSList</type>). The offset of the <parameter>next</parameter>
  7157. field in each block is passed as third argument.
  7158. Note that the exact release behaviour can be changed with the
  7159. [<code>G_DEBUG=gc-friendly</code>][G_DEBUG] environment variable, also see
  7160. [<code>G_SLICE</code>][G_SLICE] for related debugging options.
  7161. </para>
  7162. <para>If <parameter>mem_chain</parameter> is <constant>NULL</constant>, this function does nothing.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>block_size</para></td><td class="parameter_description"><para>the size of the blocks</para><para>Passed as <code>block-size</code></para></td></tr><tr><td class="parameter_name"><para>mem_chain</para></td><td class="parameter_description"><para>a pointer to the first block of the chain</para><para>Passed as <code>mem-chain</code></para></td></tr><tr><td class="parameter_name"><para>next_offset</para></td><td class="parameter_description"><para>the offset of the <parameter>next</parameter> field in the blocks</para><para>Passed as <code>next-offset</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>slice-get-config</title><informalexample><programlisting>(define-values (%return) (slice-get-config ckey))
  7163. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>ckey</para></td><td class="parameter_description"><para></para><para>Passed as <code>ckey</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>slice-get-config-state</title><informalexample><programlisting>(define-values (%return) (slice-get-config-state ckey address n-values))
  7164. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>ckey</para></td><td class="parameter_description"><para></para><para>Passed as <code>ckey</code></para></td></tr><tr><td class="parameter_name"><para>address</para></td><td class="parameter_description"><para></para><para>Passed as <code>address</code></para></td></tr><tr><td class="parameter_name"><para>n_values</para></td><td class="parameter_description"><para></para><para>Passed as <code>n-values</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>slice-set-config</title><informalexample><programlisting>(define-values () (slice-set-config ckey value))
  7165. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>ckey</para></td><td class="parameter_description"><para></para><para>Passed as <code>ckey</code></para></td></tr><tr><td class="parameter_name"><para>value</para></td><td class="parameter_description"><para></para><para>Passed as <code>value</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>source-remove?</title><informalexample><programlisting>(define-values (%return) (source-remove? tag))
  7166. </programlisting></informalexample><para>Removes the source with the given ID from the default main context. You must
  7167. use <function>g_source_destroy()</function> for sources added to a non-default main context.
  7168. </para>
  7169. <para>The ID of a <type>GSource</type> is given by <function>g_source_get_id()</function>, or will be
  7170. returned by the functions <function>g_source_attach()</function>, <function>g_idle_add()</function>,
  7171. <function>g_idle_add_full()</function>, <function>g_timeout_add()</function>, <function>g_timeout_add_full()</function>,
  7172. <function>g_child_watch_add()</function>, <function>g_child_watch_add_full()</function>, <function>g_io_add_watch()</function>, and
  7173. <function>g_io_add_watch_full()</function>.
  7174. </para>
  7175. <para>It is a programmer error to attempt to remove a non-existent source.
  7176. </para>
  7177. <para>More specifically: source IDs can be reissued after a source has been
  7178. destroyed and therefore it is never valid to use this function with a
  7179. source ID which may have already been removed. An example is when
  7180. scheduling an idle to run in another thread with <function>g_idle_add()</function>: the
  7181. idle may already have run and been removed by the time this function
  7182. is called on its (now invalid) source ID. This source ID may have
  7183. been reissued, leading to the operation being performed against the
  7184. wrong source.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tag</para></td><td class="parameter_description"><para>the ID of the source to remove.</para><para>Passed as <code>tag</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>source-remove-by-user-data?</title><informalexample><programlisting>(define-values (%return) (source-remove-by-user-data? user-data))
  7185. </programlisting></informalexample><para>Removes a source from the default main loop context given the user
  7186. data for the callback. If multiple sources exist with the same user
  7187. data, only one will be destroyed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>the user_data for the callback.</para><para>Passed as <code>user-data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>source-set-name-by-id</title><informalexample><programlisting>(define-values () (source-set-name-by-id tag name))
  7188. </programlisting></informalexample><para>Sets the name of a source using its ID.
  7189. </para>
  7190. <para>This is a convenience utility to set source names from the return
  7191. value of <function>g_idle_add()</function>, <function>g_timeout_add()</function>, etc.
  7192. </para>
  7193. <para>It is a programmer error to attempt to set the name of a non-existent
  7194. source.
  7195. </para>
  7196. <para>More specifically: source IDs can be reissued after a source has been
  7197. destroyed and therefore it is never valid to use this function with a
  7198. source ID which may have already been removed. An example is when
  7199. scheduling an idle to run in another thread with <function>g_idle_add()</function>: the
  7200. idle may already have run and been removed by the time this function
  7201. is called on its (now invalid) source ID. This source ID may have
  7202. been reissued, leading to the operation being performed against the
  7203. wrong source.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>tag</para></td><td class="parameter_description"><para>a <type>GSource</type> ID</para><para>Passed as <code>tag</code></para></td></tr><tr><td class="parameter_name"><para>name</para></td><td class="parameter_description"><para>debug name for the source</para><para>Passed as <code>name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>spaced-primes-closest</title><informalexample><programlisting>(define-values (%return) (spaced-primes-closest num))
  7204. </programlisting></informalexample><para>Gets the smallest prime number from a built-in array of primes which
  7205. is larger than <parameter>num</parameter>. This is used within GLib to calculate the optimum
  7206. size of a <type>GHashTable</type>.
  7207. </para>
  7208. <para>The built-in array of primes ranges from 11 to 13845163 such that
  7209. each prime is approximately 1.5-2 times the previous prime.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>num</para></td><td class="parameter_description"><para>a <type>guint</type></para><para>Passed as <code>num</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>spawn-async</title><informalexample><programlisting>(define-values
  7210. (%return child-pid)
  7211. (spawn-async working-directory argv envp flags child-setup user-data))
  7212. </programlisting></informalexample><para>See <function>g_spawn_async_with_pipes()</function> for a full description; this function
  7213. simply calls the <function>g_spawn_async_with_pipes()</function> without any pipes.
  7214. </para>
  7215. <para>You should call <function>g_spawn_close_pid()</function> on the returned child process
  7216. reference when you don't need it any more.
  7217. </para>
  7218. <para>If you are writing a GTK+ application, and the program you are spawning is a
  7219. graphical application too, then to ensure that the spawned program opens its
  7220. windows on the right screen, you may want to use <type>GdkAppLaunchContext</type>,
  7221. <type>GAppLaunchContext</type>, or set the <constant>DISPLAY</constant> environment variable.
  7222. </para>
  7223. <para>Note that the returned <parameter>child_pid</parameter> on Windows is a handle to the child
  7224. process and not its identifier. Process handles and process identifiers
  7225. are different concepts on Windows.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>working_directory</para></td><td class="parameter_description"><para>child's current working
  7226. directory, or <constant>NULL</constant> to inherit parent's</para><para>Passed as <code>working-directory</code></para></td></tr><tr><td class="parameter_name"><para>argv</para></td><td class="parameter_description"><para>
  7227. <para>child's argument vector</para></para><para>Passed as <code>argv</code></para></td></tr><tr><td class="parameter_name"><para>envp</para></td><td class="parameter_description"><para>
  7228. <para>child's environment, or <constant>NULL</constant> to inherit parent's</para></para><para>Passed as <code>envp</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags from <type>GSpawnFlags</type></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>child_setup</para></td><td class="parameter_description"><para>function to run in the child just before <function>exec()</function></para><para>Passed as <code>child-setup</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>user data for <parameter>child_setup</parameter></para><para>Passed as <code>user-data</code></para></td></tr><tr><td class="parameter_name"><para>child_pid</para></td><td class="parameter_description"><para>return location for child process reference, or <constant>NULL</constant></para><para>Passed as <code>child-pid</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>spawn-async-with-fds</title><informalexample><programlisting>(define-values
  7229. (%return child-pid)
  7230. (spawn-async-with-fds
  7231. working-directory
  7232. argv
  7233. envp
  7234. flags
  7235. child-setup
  7236. user-data
  7237. stdin-fd
  7238. stdout-fd
  7239. stderr-fd))
  7240. </programlisting></informalexample><para>Identical to <function>g_spawn_async_with_pipes()</function> but instead of
  7241. creating pipes for the stdin/stdout/stderr, you can pass existing
  7242. file descriptors into this function through the <parameter>stdin_fd</parameter>,
  7243. <parameter>stdout_fd</parameter> and <parameter>stderr_fd</parameter> parameters. The following <parameter>flags</parameter>
  7244. also have their behaviour slightly tweaked as a result:
  7245. </para>
  7246. <para><constant>G_SPAWN_STDOUT_TO_DEV_NULL</constant> means that the child's standard output
  7247. will be discarded, instead of going to the same location as the parent's
  7248. standard output. If you use this flag, <parameter>standard_output</parameter> must be -1.
  7249. <constant>G_SPAWN_STDERR_TO_DEV_NULL</constant> means that the child's standard error
  7250. will be discarded, instead of going to the same location as the parent's
  7251. standard error. If you use this flag, <parameter>standard_error</parameter> must be -1.
  7252. <constant>G_SPAWN_CHILD_INHERITS_STDIN</constant> means that the child will inherit the parent's
  7253. standard input (by default, the child's standard input is attached to
  7254. /dev/null). If you use this flag, <parameter>standard_input</parameter> must be -1.
  7255. </para>
  7256. <para>It is valid to pass the same fd in multiple parameters (e.g. you can pass
  7257. a single fd for both stdout and stderr).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>working_directory</para></td><td class="parameter_description"><para>child's current working directory, or <constant>NULL</constant> to inherit parent's, in the GLib file name encoding</para><para>Passed as <code>working-directory</code></para></td></tr><tr><td class="parameter_name"><para>argv</para></td><td class="parameter_description"><para>child's argument vector, in the GLib file name encoding</para><para>Passed as <code>argv</code></para></td></tr><tr><td class="parameter_name"><para>envp</para></td><td class="parameter_description"><para>child's environment, or <constant>NULL</constant> to inherit parent's, in the GLib file name encoding</para><para>Passed as <code>envp</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags from <type>GSpawnFlags</type></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>child_setup</para></td><td class="parameter_description"><para>function to run in the child just before <function>exec()</function></para><para>Passed as <code>child-setup</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>user data for <parameter>child_setup</parameter></para><para>Passed as <code>user-data</code></para></td></tr><tr><td class="parameter_name"><para>child_pid</para></td><td class="parameter_description"><para>return location for child process ID, or <constant>NULL</constant></para><para>Passed as <code>child-pid</code></para></td></tr><tr><td class="parameter_name"><para>stdin_fd</para></td><td class="parameter_description"><para>file descriptor to use for child's stdin, or -1</para><para>Passed as <code>stdin-fd</code></para></td></tr><tr><td class="parameter_name"><para>stdout_fd</para></td><td class="parameter_description"><para>file descriptor to use for child's stdout, or -1</para><para>Passed as <code>stdout-fd</code></para></td></tr><tr><td class="parameter_name"><para>stderr_fd</para></td><td class="parameter_description"><para>file descriptor to use for child's stderr, or -1</para><para>Passed as <code>stderr-fd</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>spawn-async-with-pipes</title><informalexample><programlisting>(define-values
  7258. (%return child-pid standard-input standard-output standard-error)
  7259. (spawn-async-with-pipes
  7260. working-directory
  7261. argv
  7262. envp
  7263. flags
  7264. child-setup
  7265. user-data))
  7266. </programlisting></informalexample><para>Executes a child program asynchronously (your program will not
  7267. block waiting for the child to exit). The child program is
  7268. specified by the only argument that must be provided, <parameter>argv</parameter>.
  7269. <parameter>argv</parameter> should be a <constant>NULL</constant>-terminated array of strings, to be passed
  7270. as the argument vector for the child. The first string in <parameter>argv</parameter>
  7271. is of course the name of the program to execute. By default, the
  7272. name of the program must be a full path. If <parameter>flags</parameter> contains the
  7273. <constant>G_SPAWN_SEARCH_PATH</constant> flag, the <code>PATH</code> environment variable is
  7274. used to search for the executable. If <parameter>flags</parameter> contains the
  7275. <constant>G_SPAWN_SEARCH_PATH_FROM_ENVP</constant> flag, the <code>PATH</code> variable from
  7276. <parameter>envp</parameter> is used to search for the executable. If both the
  7277. <constant>G_SPAWN_SEARCH_PATH</constant> and <constant>G_SPAWN_SEARCH_PATH_FROM_ENVP</constant> flags
  7278. are set, the <code>PATH</code> variable from <parameter>envp</parameter> takes precedence over
  7279. the environment variable.
  7280. </para>
  7281. <para>If the program name is not a full path and <constant>G_SPAWN_SEARCH_PATH</constant> flag is not
  7282. used, then the program will be run from the current directory (or
  7283. <parameter>working_directory</parameter>, if specified); this might be unexpected or even
  7284. dangerous in some cases when the current directory is world-writable.
  7285. </para>
  7286. <para>On Windows, note that all the string or string vector arguments to
  7287. this function and the other g_spawn*() functions are in UTF-8, the
  7288. GLib file name encoding. Unicode characters that are not part of
  7289. the system codepage passed in these arguments will be correctly
  7290. available in the spawned program only if it uses wide character API
  7291. to retrieve its command line. For C programs built with Microsoft's
  7292. tools it is enough to make the program have a <function>wmain()</function> instead of
  7293. <function>main()</function>. <function>wmain()</function> has a wide character argument vector as parameter.
  7294. </para>
  7295. <para>At least currently, mingw doesn't support <function>wmain()</function>, so if you use
  7296. mingw to develop the spawned program, it should call
  7297. <function>g_win32_get_command_line()</function> to get arguments in UTF-8.
  7298. </para>
  7299. <para>On Windows the low-level child process creation API <function>CreateProcess()</function>
  7300. doesn't use argument vectors, but a command line. The C runtime
  7301. library's spawn*() family of functions (which <function>g_spawn_async_with_pipes()</function>
  7302. eventually calls) paste the argument vector elements together into
  7303. a command line, and the C runtime startup code does a corresponding
  7304. reconstruction of an argument vector from the command line, to be
  7305. passed to <function>main()</function>. Complications arise when you have argument vector
  7306. elements that contain spaces or double quotes. The <code>spawn*()</code> functions
  7307. don't do any quoting or escaping, but on the other hand the startup
  7308. code does do unquoting and unescaping in order to enable receiving
  7309. arguments with embedded spaces or double quotes. To work around this
  7310. asymmetry, <function>g_spawn_async_with_pipes()</function> will do quoting and escaping on
  7311. argument vector elements that need it before calling the C runtime
  7312. <function>spawn()</function> function.
  7313. </para>
  7314. <para>The returned <parameter>child_pid</parameter> on Windows is a handle to the child
  7315. process, not its identifier. Process handles and process
  7316. identifiers are different concepts on Windows.
  7317. </para>
  7318. <para><parameter>envp</parameter> is a <constant>NULL</constant>-terminated array of strings, where each string
  7319. has the form <code>KEY=VALUE</code>. This will become the child's environment.
  7320. If <parameter>envp</parameter> is <constant>NULL</constant>, the child inherits its parent's environment.
  7321. </para>
  7322. <para><parameter>flags</parameter> should be the bitwise OR of any flags you want to affect the
  7323. function's behaviour. The <constant>G_SPAWN_DO_NOT_REAP_CHILD</constant> means that the
  7324. child will not automatically be reaped; you must use a child watch
  7325. (<function>g_child_watch_add()</function>) to be notified about the death of the child process,
  7326. otherwise it will stay around as a zombie process until this process exits.
  7327. Eventually you must call <function>g_spawn_close_pid()</function> on the <parameter>child_pid</parameter>, in order to
  7328. free resources which may be associated with the child process. (On Unix,
  7329. using a child watch is equivalent to calling <function>waitpid()</function> or handling
  7330. the <constant>SIGCHLD</constant> signal manually. On Windows, calling <function>g_spawn_close_pid()</function>
  7331. is equivalent to calling <function>CloseHandle()</function> on the process handle returned
  7332. in <parameter>child_pid</parameter>). See <function>g_child_watch_add()</function>.
  7333. </para>
  7334. <para>Open UNIX file descriptors marked as <code>FD_CLOEXEC</code> will be automatically
  7335. closed in the child process. <constant>G_SPAWN_LEAVE_DESCRIPTORS_OPEN</constant> means that
  7336. other open file descriptors will be inherited by the child; otherwise all
  7337. descriptors except stdin/stdout/stderr will be closed before calling <function>exec()</function>
  7338. in the child. <constant>G_SPAWN_SEARCH_PATH</constant> means that <parameter>argv</parameter>[0] need not be an
  7339. absolute path, it will be looked for in the <code>PATH</code> environment
  7340. variable. <constant>G_SPAWN_SEARCH_PATH_FROM_ENVP</constant> means need not be an
  7341. absolute path, it will be looked for in the <code>PATH</code> variable from
  7342. <parameter>envp</parameter>. If both <constant>G_SPAWN_SEARCH_PATH</constant> and <constant>G_SPAWN_SEARCH_PATH_FROM_ENVP</constant>
  7343. are used, the value from <parameter>envp</parameter> takes precedence over the environment.
  7344. <constant>G_SPAWN_STDOUT_TO_DEV_NULL</constant> means that the child's standard output
  7345. will be discarded, instead of going to the same location as the parent's
  7346. standard output. If you use this flag, <parameter>standard_output</parameter> must be <constant>NULL</constant>.
  7347. <constant>G_SPAWN_STDERR_TO_DEV_NULL</constant> means that the child's standard error
  7348. will be discarded, instead of going to the same location as the parent's
  7349. standard error. If you use this flag, <parameter>standard_error</parameter> must be <constant>NULL</constant>.
  7350. <constant>G_SPAWN_CHILD_INHERITS_STDIN</constant> means that the child will inherit the parent's
  7351. standard input (by default, the child's standard input is attached to
  7352. <code>/dev/null</code>). If you use this flag, <parameter>standard_input</parameter> must be <constant>NULL</constant>.
  7353. <constant>G_SPAWN_FILE_AND_ARGV_ZERO</constant> means that the first element of <parameter>argv</parameter> is
  7354. the file to execute, while the remaining elements are the actual
  7355. argument vector to pass to the file. Normally <function>g_spawn_async_with_pipes()</function>
  7356. uses <parameter>argv</parameter>[0] as the file to execute, and passes all of <parameter>argv</parameter> to the child.
  7357. </para>
  7358. <para><parameter>child_setup</parameter> and <parameter>user_data</parameter> are a function and user data. On POSIX
  7359. platforms, the function is called in the child after GLib has
  7360. performed all the setup it plans to perform (including creating
  7361. pipes, closing file descriptors, etc.) but before calling <function>exec()</function>.
  7362. That is, <parameter>child_setup</parameter> is called just before calling <function>exec()</function> in the
  7363. child. Obviously actions taken in this function will only affect
  7364. the child, not the parent.
  7365. </para>
  7366. <para>On Windows, there is no separate <function>fork()</function> and <function>exec()</function> functionality.
  7367. Child processes are created and run with a single API call,
  7368. <function>CreateProcess()</function>. There is no sensible thing <parameter>child_setup</parameter>
  7369. could be used for on Windows so it is ignored and not called.
  7370. </para>
  7371. <para>If non-<constant>NULL</constant>, <parameter>child_pid</parameter> will on Unix be filled with the child's
  7372. process ID. You can use the process ID to send signals to the child,
  7373. or to use <function>g_child_watch_add()</function> (or <function>waitpid()</function>) if you specified the
  7374. <constant>G_SPAWN_DO_NOT_REAP_CHILD</constant> flag. On Windows, <parameter>child_pid</parameter> will be
  7375. filled with a handle to the child process only if you specified the
  7376. <constant>G_SPAWN_DO_NOT_REAP_CHILD</constant> flag. You can then access the child
  7377. process using the Win32 API, for example wait for its termination
  7378. with the WaitFor*() functions, or examine its exit code with
  7379. <function>GetExitCodeProcess()</function>. You should close the handle with <function>CloseHandle()</function>
  7380. or <function>g_spawn_close_pid()</function> when you no longer need it.
  7381. </para>
  7382. <para>If non-<constant>NULL</constant>, the <parameter>standard_input</parameter>, <parameter>standard_output</parameter>, <parameter>standard_error</parameter>
  7383. locations will be filled with file descriptors for writing to the child's
  7384. standard input or reading from its standard output or standard error.
  7385. The caller of <function>g_spawn_async_with_pipes()</function> must close these file descriptors
  7386. when they are no longer in use. If these parameters are <constant>NULL</constant>, the
  7387. corresponding pipe won't be created.
  7388. </para>
  7389. <para>If <parameter>standard_input</parameter> is <constant>NULL</constant>, the child's standard input is attached to
  7390. <code>/dev/null</code> unless <constant>G_SPAWN_CHILD_INHERITS_STDIN</constant> is set.
  7391. </para>
  7392. <para>If <parameter>standard_error</parameter> is NULL, the child's standard error goes to the same
  7393. location as the parent's standard error unless <constant>G_SPAWN_STDERR_TO_DEV_NULL</constant>
  7394. is set.
  7395. </para>
  7396. <para>If <parameter>standard_output</parameter> is NULL, the child's standard output goes to the same
  7397. location as the parent's standard output unless <constant>G_SPAWN_STDOUT_TO_DEV_NULL</constant>
  7398. is set.
  7399. </para>
  7400. <para><parameter>error</parameter> can be <constant>NULL</constant> to ignore errors, or non-<constant>NULL</constant> to report errors.
  7401. If an error is set, the function returns <constant>FALSE</constant>. Errors are reported
  7402. even if they occur in the child (for example if the executable in
  7403. <parameter>argv</parameter>[0] is not found). Typically the <code>message</code> field of returned
  7404. errors should be displayed to users. Possible errors are those from
  7405. the <type>G_SPAWN_ERROR</type> domain.
  7406. </para>
  7407. <para>If an error occurs, <parameter>child_pid</parameter>, <parameter>standard_input</parameter>, <parameter>standard_output</parameter>,
  7408. and <parameter>standard_error</parameter> will not be filled with valid values.
  7409. </para>
  7410. <para>If <parameter>child_pid</parameter> is not <constant>NULL</constant> and an error does not occur then the returned
  7411. process reference must be closed using <function>g_spawn_close_pid()</function>.
  7412. </para>
  7413. <para>On modern UNIX platforms, GLib can use an efficient process launching
  7414. codepath driven internally by <function>posix_spawn()</function>. This has the advantage of
  7415. avoiding the fork-time performance costs of cloning the parent process
  7416. address space, and avoiding associated memory overcommit checks that are
  7417. not relevant in the context of immediately executing a distinct process.
  7418. This optimized codepath will be used provided that the following conditions
  7419. are met:
  7420. </para>
  7421. <para>1. <constant>G_SPAWN_DO_NOT_REAP_CHILD</constant> is set
  7422. 2. <constant>G_SPAWN_LEAVE_DESCRIPTORS_OPEN</constant> is set
  7423. 3. <constant>G_SPAWN_SEARCH_PATH_FROM_ENVP</constant> is not set
  7424. 4. <parameter>working_directory</parameter> is <constant>NULL</constant>
  7425. 5. <parameter>child_setup</parameter> is <constant>NULL</constant>
  7426. 6. The program is of a recognised binary format, or has a shebang. Otherwise, GLib will have to execute the program through the shell, which is not done using the optimized codepath.
  7427. </para>
  7428. <para>If you are writing a GTK+ application, and the program you are spawning is a
  7429. graphical application too, then to ensure that the spawned program opens its
  7430. windows on the right screen, you may want to use <type>GdkAppLaunchContext</type>,
  7431. <type>GAppLaunchContext</type>, or set the <constant>DISPLAY</constant> environment variable.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>working_directory</para></td><td class="parameter_description"><para>child's current working
  7432. directory, or <constant>NULL</constant> to inherit parent's, in the GLib file name encoding</para><para>Passed as <code>working-directory</code></para></td></tr><tr><td class="parameter_name"><para>argv</para></td><td class="parameter_description"><para>child's argument
  7433. vector, in the GLib file name encoding</para><para>Passed as <code>argv</code></para></td></tr><tr><td class="parameter_name"><para>envp</para></td><td class="parameter_description"><para>
  7434. <para>child's environment, or <constant>NULL</constant> to inherit parent's, in the GLib file
  7435. name encoding</para></para><para>Passed as <code>envp</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags from <type>GSpawnFlags</type></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>child_setup</para></td><td class="parameter_description"><para>function to run in the child just before <function>exec()</function></para><para>Passed as <code>child-setup</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>user data for <parameter>child_setup</parameter></para><para>Passed as <code>user-data</code></para></td></tr><tr><td class="parameter_name"><para>child_pid</para></td><td class="parameter_description"><para>return location for child process ID, or <constant>NULL</constant></para><para>Passed as <code>child-pid</code></para></td></tr><tr><td class="parameter_name"><para>standard_input</para></td><td class="parameter_description"><para>return location for file descriptor to write to child's stdin, or <constant>NULL</constant></para><para>Passed as <code>standard-input</code></para></td></tr><tr><td class="parameter_name"><para>standard_output</para></td><td class="parameter_description"><para>return location for file descriptor to read child's stdout, or <constant>NULL</constant></para><para>Passed as <code>standard-output</code></para></td></tr><tr><td class="parameter_name"><para>standard_error</para></td><td class="parameter_description"><para>return location for file descriptor to read child's stderr, or <constant>NULL</constant></para><para>Passed as <code>standard-error</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>spawn-check-exit-status?</title><informalexample><programlisting>(define-values (%return) (spawn-check-exit-status? wait-status))
  7436. </programlisting></informalexample><para>Set <parameter>error</parameter> if <parameter>exit_status</parameter> indicates the child exited abnormally
  7437. (e.g. with a nonzero exit code, or via a fatal signal).
  7438. </para>
  7439. <para>The <function>g_spawn_sync()</function> and <function>g_child_watch_add()</function> family of APIs return an
  7440. exit status for subprocesses encoded in a platform-specific way.
  7441. On Unix, this is guaranteed to be in the same format <function>waitpid()</function> returns,
  7442. and on Windows it is guaranteed to be the result of <function>GetExitCodeProcess()</function>.
  7443. </para>
  7444. <para>Prior to the introduction of this function in GLib 2.34, interpreting
  7445. <parameter>exit_status</parameter> required use of platform-specific APIs, which is problematic
  7446. for software using GLib as a cross-platform layer.
  7447. </para>
  7448. <para>Additionally, many programs simply want to determine whether or not
  7449. the child exited successfully, and either propagate a <type>GError</type> or
  7450. print a message to standard error. In that common case, this function
  7451. can be used. Note that the error message in <parameter>error</parameter> will contain
  7452. human-readable information about the exit status.
  7453. </para>
  7454. <para>The <parameter>domain</parameter> and <parameter>code</parameter> of <parameter>error</parameter> have special semantics in the case
  7455. where the process has an &quot;exit code&quot;, as opposed to being killed by
  7456. a signal. On Unix, this happens if <function>WIFEXITED()</function> would be true of
  7457. <parameter>exit_status</parameter>. On Windows, it is always the case.
  7458. </para>
  7459. <para>The special semantics are that the actual exit code will be the
  7460. code set in <parameter>error</parameter>, and the domain will be <constant>G_SPAWN_EXIT_ERROR</constant>.
  7461. This allows you to differentiate between different exit codes.
  7462. </para>
  7463. <para>If the process was terminated by some means other than an exit
  7464. status, the domain will be <constant>G_SPAWN_ERROR</constant>, and the code will be
  7465. <constant>G_SPAWN_ERROR_FAILED</constant>.
  7466. </para>
  7467. <para>This function just offers convenience; you can of course also check
  7468. the available platform via a macro such as <constant>G_OS_UNIX</constant>, and use
  7469. <function>WIFEXITED()</function> and <function>WEXITSTATUS()</function> on <parameter>exit_status</parameter> directly. Do not attempt
  7470. to scan or parse the error message string; it may be translated and/or
  7471. change in future versions of GLib.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>wait_status</para></td><td class="parameter_description"><para></para><para>Passed as <code>wait-status</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>spawn-check-wait-status?</title><informalexample><programlisting>(define-values (%return) (spawn-check-wait-status? wait-status))
  7472. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>wait_status</para></td><td class="parameter_description"><para></para><para>Passed as <code>wait-status</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>spawn-close-pid</title><informalexample><programlisting>(define-values () (spawn-close-pid pid))
  7473. </programlisting></informalexample><para>On some platforms, notably Windows, the <type>GPid</type> type represents a resource
  7474. which must be closed to prevent resource leaking. <function>g_spawn_close_pid()</function>
  7475. is provided for this purpose. It should be used on all platforms, even
  7476. though it doesn't do anything under UNIX.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>pid</para></td><td class="parameter_description"><para>The process reference to close</para><para>Passed as <code>pid</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>spawn-command-line-async?</title><informalexample><programlisting>(define-values (%return) (spawn-command-line-async? command-line))
  7477. </programlisting></informalexample><para>A simple version of <function>g_spawn_async()</function> that parses a command line with
  7478. <function>g_shell_parse_argv()</function> and passes it to <function>g_spawn_async()</function>. Runs a
  7479. command line in the background. Unlike <function>g_spawn_async()</function>, the
  7480. <constant>G_SPAWN_SEARCH_PATH</constant> flag is enabled, other flags are not. Note
  7481. that <constant>G_SPAWN_SEARCH_PATH</constant> can have security implications, so
  7482. consider using <function>g_spawn_async()</function> directly if appropriate. Possible
  7483. errors are those from <function>g_shell_parse_argv()</function> and <function>g_spawn_async()</function>.
  7484. </para>
  7485. <para>The same concerns on Windows apply as for <function>g_spawn_command_line_sync()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>command_line</para></td><td class="parameter_description"><para>a command line</para><para>Passed as <code>command-line</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>spawn-command-line-sync</title><informalexample><programlisting>(define-values
  7486. (%return standard-output standard-error)
  7487. (spawn-command-line-sync command-line wait-status))
  7488. </programlisting></informalexample><para>A simple version of <function>g_spawn_sync()</function> with little-used parameters
  7489. removed, taking a command line instead of an argument vector. See
  7490. <function>g_spawn_sync()</function> for full details. <parameter>command_line</parameter> will be parsed by
  7491. <function>g_shell_parse_argv()</function>. Unlike <function>g_spawn_sync()</function>, the <constant>G_SPAWN_SEARCH_PATH</constant> flag
  7492. is enabled. Note that <constant>G_SPAWN_SEARCH_PATH</constant> can have security
  7493. implications, so consider using <function>g_spawn_sync()</function> directly if
  7494. appropriate. Possible errors are those from <function>g_spawn_sync()</function> and those
  7495. from <function>g_shell_parse_argv()</function>.
  7496. </para>
  7497. <para>If <parameter>exit_status</parameter> is non-<constant>NULL</constant>, the platform-specific exit status of
  7498. the child is stored there; see the documentation of
  7499. <function>g_spawn_check_exit_status()</function> for how to use and interpret this.
  7500. </para>
  7501. <para>On Windows, please note the implications of <function>g_shell_parse_argv()</function>
  7502. parsing <parameter>command_line</parameter>. Parsing is done according to Unix shell rules, not
  7503. Windows command interpreter rules.
  7504. Space is a separator, and backslashes are
  7505. special. Thus you cannot simply pass a <parameter>command_line</parameter> containing
  7506. canonical Windows paths, like &quot;c:\\program files\\app\\app.exe&quot;, as
  7507. the backslashes will be eaten, and the space will act as a
  7508. separator. You need to enclose such paths with single quotes, like
  7509. &quot;'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'&quot;.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>command_line</para></td><td class="parameter_description"><para>a command line</para><para>Passed as <code>command-line</code></para></td></tr><tr><td class="parameter_name"><para>standard_output</para></td><td class="parameter_description"><para>return location for child output</para><para>Passed as <code>standard-output</code></para></td></tr><tr><td class="parameter_name"><para>standard_error</para></td><td class="parameter_description"><para>return location for child errors</para><para>Passed as <code>standard-error</code></para></td></tr><tr><td class="parameter_name"><para>wait_status</para></td><td class="parameter_description"><para></para><para>Passed as <code>wait-status</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>spawn-error-quark</title><informalexample><programlisting>(define-values (%return) (spawn-error-quark))
  7510. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>spawn-exit-error-quark</title><informalexample><programlisting>(define-values (%return) (spawn-exit-error-quark))
  7511. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>spawn-sync</title><informalexample><programlisting>(define-values
  7512. (%return standard-output standard-error)
  7513. (spawn-sync
  7514. working-directory
  7515. argv
  7516. envp
  7517. flags
  7518. child-setup
  7519. user-data
  7520. wait-status))
  7521. </programlisting></informalexample><para>Executes a child synchronously (waits for the child to exit before returning).
  7522. All output from the child is stored in <parameter>standard_output</parameter> and <parameter>standard_error</parameter>,
  7523. if those parameters are non-<constant>NULL</constant>. Note that you must set the
  7524. <constant>G_SPAWN_STDOUT_TO_DEV_NULL</constant> and <constant>G_SPAWN_STDERR_TO_DEV_NULL</constant> flags when
  7525. passing <constant>NULL</constant> for <parameter>standard_output</parameter> and <parameter>standard_error</parameter>.
  7526. </para>
  7527. <para>If <parameter>exit_status</parameter> is non-<constant>NULL</constant>, the platform-specific exit status of
  7528. the child is stored there; see the documentation of
  7529. <function>g_spawn_check_exit_status()</function> for how to use and interpret this.
  7530. Note that it is invalid to pass <constant>G_SPAWN_DO_NOT_REAP_CHILD</constant> in
  7531. <parameter>flags</parameter>, and on POSIX platforms, the same restrictions as for
  7532. <function>g_child_watch_source_new()</function> apply.
  7533. </para>
  7534. <para>If an error occurs, no data is returned in <parameter>standard_output</parameter>,
  7535. <parameter>standard_error</parameter>, or <parameter>exit_status</parameter>.
  7536. </para>
  7537. <para>This function calls <function>g_spawn_async_with_pipes()</function> internally; see that
  7538. function for full details on the other parameters and details on
  7539. how these functions work on Windows.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>working_directory</para></td><td class="parameter_description"><para>child's current working
  7540. directory, or <constant>NULL</constant> to inherit parent's</para><para>Passed as <code>working-directory</code></para></td></tr><tr><td class="parameter_name"><para>argv</para></td><td class="parameter_description"><para>
  7541. <para>child's argument vector</para></para><para>Passed as <code>argv</code></para></td></tr><tr><td class="parameter_name"><para>envp</para></td><td class="parameter_description"><para>
  7542. <para>child's environment, or <constant>NULL</constant> to inherit parent's</para></para><para>Passed as <code>envp</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags from <type>GSpawnFlags</type></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>child_setup</para></td><td class="parameter_description"><para>function to run in the child just before <function>exec()</function></para><para>Passed as <code>child-setup</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>user data for <parameter>child_setup</parameter></para><para>Passed as <code>user-data</code></para></td></tr><tr><td class="parameter_name"><para>standard_output</para></td><td class="parameter_description"><para>return location for child output, or <constant>NULL</constant></para><para>Passed as <code>standard-output</code></para></td></tr><tr><td class="parameter_name"><para>standard_error</para></td><td class="parameter_description"><para>return location for child error messages, or <constant>NULL</constant></para><para>Passed as <code>standard-error</code></para></td></tr><tr><td class="parameter_name"><para>wait_status</para></td><td class="parameter_description"><para></para><para>Passed as <code>wait-status</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>stpcpy</title><informalexample><programlisting>(define-values (%return) (stpcpy dest src))
  7543. </programlisting></informalexample><para>Copies a nul-terminated string into the dest buffer, include the
  7544. trailing nul, and return a pointer to the trailing nul byte.
  7545. This is useful for concatenating multiple strings together
  7546. without having to repeatedly scan for the end.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dest</para></td><td class="parameter_description"><para>destination buffer.</para><para>Passed as <code>dest</code></para></td></tr><tr><td class="parameter_name"><para>src</para></td><td class="parameter_description"><para>source string.</para><para>Passed as <code>src</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>str-equal?</title><informalexample><programlisting>(define-values (%return) (str-equal? v1 v2))
  7547. </programlisting></informalexample><para>Compares two strings for byte-by-byte equality and returns <constant>TRUE</constant>
  7548. if they are equal. It can be passed to <function>g_hash_table_new()</function> as the
  7549. <parameter>key_equal_func</parameter> parameter, when using non-<constant>NULL</constant> strings as keys in a
  7550. <type>GHashTable</type>.
  7551. </para>
  7552. <para>This function is typically used for hash table comparisons, but can be used
  7553. for general purpose comparisons of non-<constant>NULL</constant> strings. For a <constant>NULL</constant>-safe string
  7554. comparison function, see <function>g_strcmp0()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>v1</para></td><td class="parameter_description"><para>a key</para><para>Passed as <code>v1</code></para></td></tr><tr><td class="parameter_name"><para>v2</para></td><td class="parameter_description"><para>a key to compare with <parameter>v1</parameter></para><para>Passed as <code>v2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>str-has-prefix?</title><informalexample><programlisting>(define-values (%return) (str-has-prefix? str prefix))
  7555. </programlisting></informalexample><para>Looks whether the string <parameter>str</parameter> begins with <parameter>prefix</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a nul-terminated string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>prefix</para></td><td class="parameter_description"><para>the nul-terminated prefix to look for</para><para>Passed as <code>prefix</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>str-has-suffix?</title><informalexample><programlisting>(define-values (%return) (str-has-suffix? str suffix))
  7556. </programlisting></informalexample><para>Looks whether the string <parameter>str</parameter> ends with <parameter>suffix</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a nul-terminated string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>suffix</para></td><td class="parameter_description"><para>the nul-terminated suffix to look for</para><para>Passed as <code>suffix</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>str-hash</title><informalexample><programlisting>(define-values (%return) (str-hash v))
  7557. </programlisting></informalexample><para>Converts a string to a hash value.
  7558. </para>
  7559. <para>This function implements the widely used &quot;djb&quot; hash apparently
  7560. posted by Daniel Bernstein to comp.lang.c some time ago. The 32
  7561. bit unsigned hash value starts at 5381 and for each byte 'c' in
  7562. the string, is updated: <code>hash = hash * 33 + c</code>. This function
  7563. uses the signed value of each byte.
  7564. </para>
  7565. <para>It can be passed to <function>g_hash_table_new()</function> as the <parameter>hash_func</parameter> parameter,
  7566. when using non-<constant>NULL</constant> strings as keys in a <type>GHashTable</type>.
  7567. </para>
  7568. <para>Note that this function may not be a perfect fit for all use cases.
  7569. For example, it produces some hash collisions with strings as short
  7570. as 2.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>v</para></td><td class="parameter_description"><para>a string key</para><para>Passed as <code>v</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>str-is-ascii?</title><informalexample><programlisting>(define-values (%return) (str-is-ascii? str))
  7571. </programlisting></informalexample><para>Determines if a string is pure ASCII. A string is pure ASCII if it
  7572. contains no bytes with the high bit set.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>str-match-string?</title><informalexample><programlisting>(define-values
  7573. (%return)
  7574. (str-match-string? search-term potential-hit accept-alternates))
  7575. </programlisting></informalexample><para>Checks if a search conducted for <parameter>search_term</parameter> should match
  7576. <parameter>potential_hit</parameter>.
  7577. </para>
  7578. <para>This function calls <function>g_str_tokenize_and_fold()</function> on both
  7579. <parameter>search_term</parameter> and <parameter>potential_hit</parameter>. ASCII alternates are never taken
  7580. for <parameter>search_term</parameter> but will be taken for <parameter>potential_hit</parameter> according to
  7581. the value of <parameter>accept_alternates</parameter>.
  7582. </para>
  7583. <para>A hit occurs when each folded token in <parameter>search_term</parameter> is a prefix of a
  7584. folded token from <parameter>potential_hit</parameter>.
  7585. </para>
  7586. <para>Depending on how you're performing the search, it will typically be
  7587. faster to call <function>g_str_tokenize_and_fold()</function> on each string in
  7588. your corpus and build an index on the returned folded tokens, then
  7589. call <function>g_str_tokenize_and_fold()</function> on the search term and
  7590. perform lookups into that index.
  7591. </para>
  7592. <para>As some examples, searching for ‘fred’ would match the potential hit
  7593. ‘Smith, Fred’ and also ‘Frédéric’. Searching for ‘Fréd’ would match
  7594. ‘Frédéric’ but not ‘Frederic’ (due to the one-directional nature of
  7595. accent matching). Searching ‘fo’ would match ‘Foo’ and ‘Bar Foo
  7596. Baz’, but not ‘SFO’ (because no word has ‘fo’ as a prefix).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>search_term</para></td><td class="parameter_description"><para>the search term from the user</para><para>Passed as <code>search-term</code></para></td></tr><tr><td class="parameter_name"><para>potential_hit</para></td><td class="parameter_description"><para>the text that may be a hit</para><para>Passed as <code>potential-hit</code></para></td></tr><tr><td class="parameter_name"><para>accept_alternates</para></td><td class="parameter_description"><para><constant>TRUE</constant> to accept ASCII alternates</para><para>Passed as <code>accept-alternates</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>str-to-ascii</title><informalexample><programlisting>(define-values (%return) (str-to-ascii str from-locale))
  7597. </programlisting></informalexample><para>Transliterate <parameter>str</parameter> to plain ASCII.
  7598. </para>
  7599. <para>For best results, <parameter>str</parameter> should be in composed normalised form.
  7600. </para>
  7601. <para>This function performs a reasonably good set of character
  7602. replacements. The particular set of replacements that is done may
  7603. change by version or even by runtime environment.
  7604. </para>
  7605. <para>If the source language of <parameter>str</parameter> is known, it can used to improve the
  7606. accuracy of the translation by passing it as <parameter>from_locale</parameter>. It should
  7607. be a valid POSIX locale string (of the form
  7608. <code>language[_territory][.codeset][@modifier]</code>).
  7609. </para>
  7610. <para>If <parameter>from_locale</parameter> is <constant>NULL</constant> then the current locale is used.
  7611. </para>
  7612. <para>If you want to do translation for no specific locale, and you want it
  7613. to be done independently of the currently locale, specify <code>&quot;C&quot;</code> for
  7614. <parameter>from_locale</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a string, in UTF-8</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>from_locale</para></td><td class="parameter_description"><para>the source locale, if known</para><para>Passed as <code>from-locale</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>str-tokenize-and-fold</title><informalexample><programlisting>(define-values
  7615. (%return ascii-alternates)
  7616. (str-tokenize-and-fold string translit-locale))
  7617. </programlisting></informalexample><para>Tokenises <parameter>string</parameter> and performs folding on each token.
  7618. </para>
  7619. <para>A token is a non-empty sequence of alphanumeric characters in the
  7620. source string, separated by non-alphanumeric characters. An
  7621. &quot;alphanumeric&quot; character for this purpose is one that matches
  7622. <function>g_unichar_isalnum()</function> or <function>g_unichar_ismark()</function>.
  7623. </para>
  7624. <para>Each token is then (Unicode) normalised and case-folded. If
  7625. <parameter>ascii_alternates</parameter> is non-<constant>NULL</constant> and some of the returned tokens
  7626. contain non-ASCII characters, ASCII alternatives will be generated.
  7627. </para>
  7628. <para>The number of ASCII alternatives that are generated and the method
  7629. for doing so is unspecified, but <parameter>translit_locale</parameter> (if specified) may
  7630. improve the transliteration if the language of the source string is
  7631. known.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>translit_locale</para></td><td class="parameter_description"><para>the language code (like 'de' or
  7632. 'en_GB') from which <parameter>string</parameter> originates</para><para>Passed as <code>translit-locale</code></para></td></tr><tr><td class="parameter_name"><para>ascii_alternates</para></td><td class="parameter_description"><para>a
  7633. return location for ASCII alternates</para><para>Passed as <code>ascii-alternates</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strcanon</title><informalexample><programlisting>(define-values (%return) (strcanon string valid-chars substitutor))
  7634. </programlisting></informalexample><para>For each character in <parameter>string</parameter>, if the character is not in <parameter>valid_chars</parameter>,
  7635. replaces the character with <parameter>substitutor</parameter>. Modifies <parameter>string</parameter> in place,
  7636. and return <parameter>string</parameter> itself, not a copy. The return value is to allow
  7637. nesting such as
  7638. <informalexample><programlisting>
  7639. g_ascii_strup (g_strcanon (str, &quot;abc&quot;, '?'))
  7640. </programlisting></informalexample></para>
  7641. <para>In order to modify a copy, you may use <code>g_strdup()</code>:
  7642. <informalexample><programlisting>
  7643. reformatted = g_strcanon (g_strdup (const_str), &quot;abc&quot;, '?');
  7644. ...
  7645. g_free (reformatted);
  7646. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a nul-terminated array of bytes</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>valid_chars</para></td><td class="parameter_description"><para>bytes permitted in <parameter>string</parameter></para><para>Passed as <code>valid-chars</code></para></td></tr><tr><td class="parameter_name"><para>substitutor</para></td><td class="parameter_description"><para>replacement character for disallowed bytes</para><para>Passed as <code>substitutor</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strchomp</title><informalexample><programlisting>(define-values (%return) (strchomp string))
  7647. </programlisting></informalexample><para>Removes trailing whitespace from a string.
  7648. </para>
  7649. <para>This function doesn't allocate or reallocate any memory;
  7650. it modifies <parameter>string</parameter> in place. Therefore, it cannot be used
  7651. on statically allocated strings.
  7652. </para>
  7653. <para>The pointer to <parameter>string</parameter> is returned to allow the nesting of functions.
  7654. </para>
  7655. <para>Also see <function>g_strchug()</function> and <function>g_strstrip()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a string to remove the trailing whitespace from</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strchug</title><informalexample><programlisting>(define-values (%return) (strchug string))
  7656. </programlisting></informalexample><para>Removes leading whitespace from a string, by moving the rest
  7657. of the characters forward.
  7658. </para>
  7659. <para>This function doesn't allocate or reallocate any memory;
  7660. it modifies <parameter>string</parameter> in place. Therefore, it cannot be used on
  7661. statically allocated strings.
  7662. </para>
  7663. <para>The pointer to <parameter>string</parameter> is returned to allow the nesting of functions.
  7664. </para>
  7665. <para>Also see <function>g_strchomp()</function> and <function>g_strstrip()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a string to remove the leading whitespace from</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strcmp0</title><informalexample><programlisting>(define-values (%return) (strcmp0 str1 str2))
  7666. </programlisting></informalexample><para>Compares <parameter>str1</parameter> and <parameter>str2</parameter> like <function>strcmp()</function>. Handles <constant>NULL</constant>
  7667. gracefully by sorting it before non-<constant>NULL</constant> strings.
  7668. Comparing two <constant>NULL</constant> pointers returns 0.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str1</para></td><td class="parameter_description"><para>a C string or <constant>NULL</constant></para><para>Passed as <code>str1</code></para></td></tr><tr><td class="parameter_name"><para>str2</para></td><td class="parameter_description"><para>another C string or <constant>NULL</constant></para><para>Passed as <code>str2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strcompress</title><informalexample><programlisting>(define-values (%return) (strcompress source))
  7669. </programlisting></informalexample><para>Replaces all escaped characters with their one byte equivalent.
  7670. </para>
  7671. <para>This function does the reverse conversion of <function>g_strescape()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a string to compress</para><para>Passed as <code>source</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strdelimit</title><informalexample><programlisting>(define-values (%return) (strdelimit string delimiters new-delimiter))
  7672. </programlisting></informalexample><para>Converts any delimiter characters in <parameter>string</parameter> to <parameter>new_delimiter</parameter>.
  7673. Any characters in <parameter>string</parameter> which are found in <parameter>delimiters</parameter> are
  7674. changed to the <parameter>new_delimiter</parameter> character. Modifies <parameter>string</parameter> in place,
  7675. and returns <parameter>string</parameter> itself, not a copy. The return value is to
  7676. allow nesting such as
  7677. <informalexample><programlisting>
  7678. g_ascii_strup (g_strdelimit (str, &quot;abc&quot;, '?'))
  7679. </programlisting></informalexample></para>
  7680. <para>In order to modify a copy, you may use <code>g_strdup()</code>:
  7681. <informalexample><programlisting>
  7682. reformatted = g_strdelimit (g_strdup (const_str), &quot;abc&quot;, '?');
  7683. ...
  7684. g_free (reformatted);
  7685. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to convert</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>delimiters</para></td><td class="parameter_description"><para>a string containing the current delimiters,
  7686. or <constant>NULL</constant> to use the standard delimiters defined in <type>G_STR_DELIMITERS</type></para><para>Passed as <code>delimiters</code></para></td></tr><tr><td class="parameter_name"><para>new_delimiter</para></td><td class="parameter_description"><para>the new delimiter character</para><para>Passed as <code>new-delimiter</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strdup</title><informalexample><programlisting>(define-values (%return) (strdup str))
  7687. </programlisting></informalexample><para>Duplicates a string. If <parameter>str</parameter> is <constant>NULL</constant> it returns <constant>NULL</constant>.
  7688. The returned string should be freed with <function>g_free()</function>
  7689. when no longer needed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>the string to duplicate</para><para>Passed as <code>str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strerror</title><informalexample><programlisting>(define-values (%return) (strerror errnum))
  7690. </programlisting></informalexample><para>Returns a string corresponding to the given error code, e.g. &quot;no
  7691. such process&quot;. Unlike <function>strerror()</function>, this always returns a string in
  7692. UTF-8 encoding, and the pointer is guaranteed to remain valid for
  7693. the lifetime of the process.
  7694. </para>
  7695. <para>Note that the string may be translated according to the current locale.
  7696. </para>
  7697. <para>The value of <constant>errno</constant> will not be changed by this function. However, it may
  7698. be changed by intermediate function calls, so you should save its value
  7699. as soon as the call returns:
  7700. <informalexample><programlisting>
  7701. int saved_errno;
  7702. ret = read (blah);
  7703. saved_errno = errno;
  7704. g_strerror (saved_errno);
  7705. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>errnum</para></td><td class="parameter_description"><para>the system error number. See the standard C <constant>errno</constant>
  7706. documentation</para><para>Passed as <code>errnum</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strescape</title><informalexample><programlisting>(define-values (%return) (strescape source exceptions))
  7707. </programlisting></informalexample><para>Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
  7708. and '&quot;' in the string <parameter>source</parameter> by inserting a '\' before
  7709. them. Additionally all characters in the range 0x01-0x1F (everything
  7710. below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
  7711. replaced with a '\' followed by their octal representation.
  7712. Characters supplied in <parameter>exceptions</parameter> are not escaped.
  7713. </para>
  7714. <para><function>g_strcompress()</function> does the reverse conversion.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>source</para></td><td class="parameter_description"><para>a string to escape</para><para>Passed as <code>source</code></para></td></tr><tr><td class="parameter_name"><para>exceptions</para></td><td class="parameter_description"><para>a string of characters not to escape in <parameter>source</parameter></para><para>Passed as <code>exceptions</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strfreev</title><informalexample><programlisting>(define-values () (strfreev str-array))
  7715. </programlisting></informalexample><para>Frees a <constant>NULL</constant>-terminated array of strings, as well as each
  7716. string it contains.
  7717. </para>
  7718. <para>If <parameter>str_array</parameter> is <constant>NULL</constant>, this function simply returns.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str_array</para></td><td class="parameter_description"><para>a <constant>NULL</constant>-terminated array of strings to free</para><para>Passed as <code>str-array</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>string-new</title><informalexample><programlisting>(define-values (%return) (string-new init))
  7719. </programlisting></informalexample><para>Creates a new <type>GString</type>, initialized with the given string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>init</para></td><td class="parameter_description"><para>the initial text to copy into the string, or <constant>NULL</constant> to
  7720. start with an empty string</para><para>Passed as <code>init</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>string-new-len</title><informalexample><programlisting>(define-values (%return) (string-new-len init len))
  7721. </programlisting></informalexample><para>Creates a new <type>GString</type> with <parameter>len</parameter> bytes of the <parameter>init</parameter> buffer.
  7722. Because a length is provided, <parameter>init</parameter> need not be nul-terminated,
  7723. and can contain embedded nul bytes.
  7724. </para>
  7725. <para>Since this function does not stop at nul bytes, it is the caller's
  7726. responsibility to ensure that <parameter>init</parameter> has at least <parameter>len</parameter> addressable
  7727. bytes.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>init</para></td><td class="parameter_description"><para>initial contents of the string</para><para>Passed as <code>init</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>init</parameter> to use</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>string-sized-new</title><informalexample><programlisting>(define-values (%return) (string-sized-new dfl-size))
  7728. </programlisting></informalexample><para>Creates a new <type>GString</type>, with enough space for <parameter>dfl_size</parameter>
  7729. bytes. This is useful if you are going to add a lot of
  7730. text to the string and don't want it to be reallocated
  7731. too often.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dfl_size</para></td><td class="parameter_description"><para>the default size of the space allocated to
  7732. hold the string</para><para>Passed as <code>dfl-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strip-context</title><informalexample><programlisting>(define-values (%return) (strip-context msgid msgval))
  7733. </programlisting></informalexample><para>An auxiliary function for <function>gettext()</function> support (see <function>Q_()</function>).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>msgid</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>msgid</code></para></td></tr><tr><td class="parameter_name"><para>msgval</para></td><td class="parameter_description"><para>another string</para><para>Passed as <code>msgval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strjoinv</title><informalexample><programlisting>(define-values (%return) (strjoinv separator str-array))
  7734. </programlisting></informalexample><para>Joins a number of strings together to form one long string, with the
  7735. optional <parameter>separator</parameter> inserted between each of them. The returned string
  7736. should be freed with <function>g_free()</function>.
  7737. </para>
  7738. <para>If <parameter>str_array</parameter> has no items, the return value will be an
  7739. empty string. If <parameter>str_array</parameter> contains a single item, <parameter>separator</parameter> will not
  7740. appear in the resulting string.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>separator</para></td><td class="parameter_description"><para>a string to insert between each of the
  7741. strings, or <constant>NULL</constant></para><para>Passed as <code>separator</code></para></td></tr><tr><td class="parameter_name"><para>str_array</para></td><td class="parameter_description"><para>a <constant>NULL</constant>-terminated array of strings to join</para><para>Passed as <code>str-array</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strlcat</title><informalexample><programlisting>(define-values (%return) (strlcat dest src dest-size))
  7742. </programlisting></informalexample><para>Portability wrapper that calls <function>strlcat()</function> on systems which have it,
  7743. and emulates it otherwise. Appends nul-terminated <parameter>src</parameter> string to <parameter>dest</parameter>,
  7744. guaranteeing nul-termination for <parameter>dest</parameter>. The total size of <parameter>dest</parameter> won't
  7745. exceed <parameter>dest_size</parameter>.
  7746. </para>
  7747. <para>At most <parameter>dest_size</parameter> - 1 characters will be copied. Unlike <function>strncat()</function>,
  7748. <parameter>dest_size</parameter> is the full size of dest, not the space left over. This
  7749. function does not allocate memory. It always nul-terminates (unless
  7750. <parameter>dest_size</parameter> == 0 or there were no nul characters in the <parameter>dest_size</parameter>
  7751. characters of dest to start with).
  7752. </para>
  7753. <para>Caveat: this is supposedly a more secure alternative to <function>strcat()</function> or
  7754. <function>strncat()</function>, but for real security <function>g_strconcat()</function> is harder to mess up.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dest</para></td><td class="parameter_description"><para>destination buffer, already containing one nul-terminated string</para><para>Passed as <code>dest</code></para></td></tr><tr><td class="parameter_name"><para>src</para></td><td class="parameter_description"><para>source buffer</para><para>Passed as <code>src</code></para></td></tr><tr><td class="parameter_name"><para>dest_size</para></td><td class="parameter_description"><para>length of <parameter>dest</parameter> buffer in bytes (not length of existing string
  7755. inside <parameter>dest</parameter>)</para><para>Passed as <code>dest-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strlcpy</title><informalexample><programlisting>(define-values (%return) (strlcpy dest src dest-size))
  7756. </programlisting></informalexample><para>Portability wrapper that calls <function>strlcpy()</function> on systems which have it,
  7757. and emulates <function>strlcpy()</function> otherwise. Copies <parameter>src</parameter> to <parameter>dest</parameter>; <parameter>dest</parameter> is
  7758. guaranteed to be nul-terminated; <parameter>src</parameter> must be nul-terminated;
  7759. <parameter>dest_size</parameter> is the buffer size, not the number of bytes to copy.
  7760. </para>
  7761. <para>At most <parameter>dest_size</parameter> - 1 characters will be copied. Always nul-terminates
  7762. (unless <parameter>dest_size</parameter> is 0). This function does not allocate memory. Unlike
  7763. <function>strncpy()</function>, this function doesn't pad <parameter>dest</parameter> (so it's often faster). It
  7764. returns the size of the attempted result, strlen (src), so if
  7765. <parameter>retval</parameter> &gt;= <parameter>dest_size</parameter>, truncation occurred.
  7766. </para>
  7767. <para>Caveat: <function>strlcpy()</function> is supposedly more secure than <function>strcpy()</function> or <function>strncpy()</function>,
  7768. but if you really want to avoid screwups, <function>g_strdup()</function> is an even better
  7769. idea.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dest</para></td><td class="parameter_description"><para>destination buffer</para><para>Passed as <code>dest</code></para></td></tr><tr><td class="parameter_name"><para>src</para></td><td class="parameter_description"><para>source buffer</para><para>Passed as <code>src</code></para></td></tr><tr><td class="parameter_name"><para>dest_size</para></td><td class="parameter_description"><para>length of <parameter>dest</parameter> in bytes</para><para>Passed as <code>dest-size</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strndup</title><informalexample><programlisting>(define-values (%return) (strndup str n))
  7770. </programlisting></informalexample><para>Duplicates the first <parameter>n</parameter> bytes of a string, returning a newly-allocated
  7771. buffer <parameter>n</parameter> + 1 bytes long which will always be nul-terminated. If <parameter>str</parameter>
  7772. is less than <parameter>n</parameter> bytes long the buffer is padded with nuls. If <parameter>str</parameter> is
  7773. <constant>NULL</constant> it returns <constant>NULL</constant>. The returned value should be freed when no longer
  7774. needed.
  7775. </para>
  7776. <para>To copy a number of characters from a UTF-8 encoded string,
  7777. use <function>g_utf8_strncpy()</function> instead.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>the string to duplicate</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>n</para></td><td class="parameter_description"><para>the maximum number of bytes to copy from <parameter>str</parameter></para><para>Passed as <code>n</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strnfill</title><informalexample><programlisting>(define-values (%return) (strnfill length fill-char))
  7778. </programlisting></informalexample><para>Creates a new string <parameter>length</parameter> bytes long filled with <parameter>fill_char</parameter>.
  7779. The returned string should be freed when no longer needed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of the new string</para><para>Passed as <code>length</code></para></td></tr><tr><td class="parameter_name"><para>fill_char</para></td><td class="parameter_description"><para>the byte to fill the string with</para><para>Passed as <code>fill-char</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strreverse</title><informalexample><programlisting>(define-values (%return) (strreverse string))
  7780. </programlisting></informalexample><para>Reverses all of the bytes in a string. For example,
  7781. <code>g_strreverse (&quot;abcdef&quot;)</code> will result in &quot;fedcba&quot;.
  7782. </para>
  7783. <para>Note that <function>g_strreverse()</function> doesn't work on UTF-8 strings
  7784. containing multibyte characters. For that purpose, use
  7785. <function>g_utf8_strreverse()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>the string to reverse</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strrstr</title><informalexample><programlisting>(define-values (%return) (strrstr haystack needle))
  7786. </programlisting></informalexample><para>Searches the string <parameter>haystack</parameter> for the last occurrence
  7787. of the string <parameter>needle</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>haystack</para></td><td class="parameter_description"><para>a nul-terminated string</para><para>Passed as <code>haystack</code></para></td></tr><tr><td class="parameter_name"><para>needle</para></td><td class="parameter_description"><para>the nul-terminated string to search for</para><para>Passed as <code>needle</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strrstr-len</title><informalexample><programlisting>(define-values (%return) (strrstr-len haystack haystack-len needle))
  7788. </programlisting></informalexample><para>Searches the string <parameter>haystack</parameter> for the last occurrence
  7789. of the string <parameter>needle</parameter>, limiting the length of the search
  7790. to <parameter>haystack_len</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>haystack</para></td><td class="parameter_description"><para>a nul-terminated string</para><para>Passed as <code>haystack</code></para></td></tr><tr><td class="parameter_name"><para>haystack_len</para></td><td class="parameter_description"><para>the maximum length of <parameter>haystack</parameter></para><para>Passed as <code>haystack-len</code></para></td></tr><tr><td class="parameter_name"><para>needle</para></td><td class="parameter_description"><para>the nul-terminated string to search for</para><para>Passed as <code>needle</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strsignal</title><informalexample><programlisting>(define-values (%return) (strsignal signum))
  7791. </programlisting></informalexample><para>Returns a string describing the given signal, e.g. &quot;Segmentation fault&quot;.
  7792. You should use this function in preference to <function>strsignal()</function>, because it
  7793. returns a string in UTF-8 encoding, and since not all platforms support
  7794. the <function>strsignal()</function> function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>signum</para></td><td class="parameter_description"><para>the signal number. See the <code>signal</code> documentation</para><para>Passed as <code>signum</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strstr-len</title><informalexample><programlisting>(define-values (%return) (strstr-len haystack haystack-len needle))
  7795. </programlisting></informalexample><para>Searches the string <parameter>haystack</parameter> for the first occurrence
  7796. of the string <parameter>needle</parameter>, limiting the length of the search
  7797. to <parameter>haystack_len</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>haystack</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>haystack</code></para></td></tr><tr><td class="parameter_name"><para>haystack_len</para></td><td class="parameter_description"><para>the maximum length of <parameter>haystack</parameter>. Note that -1 is
  7798. a valid length, if <parameter>haystack</parameter> is nul-terminated, meaning it will
  7799. search through the whole string.</para><para>Passed as <code>haystack-len</code></para></td></tr><tr><td class="parameter_name"><para>needle</para></td><td class="parameter_description"><para>the string to search for</para><para>Passed as <code>needle</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strtod</title><informalexample><programlisting>(define-values (%return endptr) (strtod nptr))
  7800. </programlisting></informalexample><para>Converts a string to a <type>gdouble</type> value.
  7801. It calls the standard <function>strtod()</function> function to handle the conversion, but
  7802. if the string is not completely converted it attempts the conversion
  7803. again with <function>g_ascii_strtod()</function>, and returns the best match.
  7804. </para>
  7805. <para>This function should seldom be used. The normal situation when reading
  7806. numbers not for human consumption is to use <function>g_ascii_strtod()</function>. Only when
  7807. you know that you must expect both locale formatted and C formatted numbers
  7808. should you use this. Make sure that you don't pass strings such as comma
  7809. separated lists of values, since the commas may be interpreted as a decimal
  7810. point in some locales, causing unexpected results.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>nptr</para></td><td class="parameter_description"><para>the string to convert to a numeric value.</para><para>Passed as <code>nptr</code></para></td></tr><tr><td class="parameter_name"><para>endptr</para></td><td class="parameter_description"><para>if non-<constant>NULL</constant>, it returns the
  7811. character after the last character used in the conversion.</para><para>Passed as <code>endptr</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strv-contains?</title><informalexample><programlisting>(define-values (%return) (strv-contains? strv str))
  7812. </programlisting></informalexample><para>Checks if <parameter>strv</parameter> contains <parameter>str</parameter>. <parameter>strv</parameter> must not be <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>strv</para></td><td class="parameter_description"><para>a <constant>NULL</constant>-terminated array of strings</para><para>Passed as <code>strv</code></para></td></tr><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a string</para><para>Passed as <code>str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strv-equal?</title><informalexample><programlisting>(define-values (%return) (strv-equal? strv1 strv2))
  7813. </programlisting></informalexample><para>Checks if <parameter>strv1</parameter> and <parameter>strv2</parameter> contain exactly the same elements in exactly the
  7814. same order. Elements are compared using <function>g_str_equal()</function>. To match independently
  7815. of order, sort the arrays first (using <function>g_qsort_with_data()</function> or similar).
  7816. </para>
  7817. <para>Two empty arrays are considered equal. Neither <parameter>strv1</parameter> not <parameter>strv2</parameter> may be
  7818. <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>strv1</para></td><td class="parameter_description"><para>a <constant>NULL</constant>-terminated array of strings</para><para>Passed as <code>strv1</code></para></td></tr><tr><td class="parameter_name"><para>strv2</para></td><td class="parameter_description"><para>another <constant>NULL</constant>-terminated array of strings</para><para>Passed as <code>strv2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>strv-get-type</title><informalexample><programlisting>(define-values (%return) (strv-get-type))
  7819. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>strv-length</title><informalexample><programlisting>(define-values (%return) (strv-length str-array))
  7820. </programlisting></informalexample><para>Returns the length of the given <constant>NULL</constant>-terminated
  7821. string array <parameter>str_array</parameter>. <parameter>str_array</parameter> must not be <constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str_array</para></td><td class="parameter_description"><para>a <constant>NULL</constant>-terminated array of strings</para><para>Passed as <code>str-array</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-add-data-func</title><informalexample><programlisting>(define-values () (test-add-data-func testpath test-data test-func))
  7822. </programlisting></informalexample><para>Create a new test case, similar to <function>g_test_create_case()</function>. However
  7823. the test is assumed to use no fixture, and test suites are automatically
  7824. created on the fly and added to the root fixture, based on the
  7825. slash-separated portions of <parameter>testpath</parameter>. The <parameter>test_data</parameter> argument
  7826. will be passed as first argument to <parameter>test_func</parameter>.
  7827. </para>
  7828. <para>If <parameter>testpath</parameter> includes the component &quot;subprocess&quot; anywhere in it,
  7829. the test will be skipped by default, and only run if explicitly
  7830. required via the <code>-p</code> command-line option or <function>g_test_trap_subprocess()</function>.
  7831. </para>
  7832. <para>No component of <parameter>testpath</parameter> may start with a dot (<code>.</code>) if the
  7833. <constant>G_TEST_OPTION_ISOLATE_DIRS</constant> option is being used; and it is recommended to
  7834. do so even if it isn’t.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>testpath</para></td><td class="parameter_description"><para>/-separated test case path name for the test.</para><para>Passed as <code>testpath</code></para></td></tr><tr><td class="parameter_name"><para>test_data</para></td><td class="parameter_description"><para>Test data argument for the test function.</para><para>Passed as <code>test-data</code></para></td></tr><tr><td class="parameter_name"><para>test_func</para></td><td class="parameter_description"><para>The test function to invoke for this test.</para><para>Passed as <code>test-func</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-add-data-func-full</title><informalexample><programlisting>(define-values
  7835. ()
  7836. (test-add-data-func-full testpath test-data test-func data-free-func))
  7837. </programlisting></informalexample><para>Create a new test case, as with <function>g_test_add_data_func()</function>, but freeing
  7838. <parameter>test_data</parameter> after the test run is complete.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>testpath</para></td><td class="parameter_description"><para>/-separated test case path name for the test.</para><para>Passed as <code>testpath</code></para></td></tr><tr><td class="parameter_name"><para>test_data</para></td><td class="parameter_description"><para>Test data argument for the test function.</para><para>Passed as <code>test-data</code></para></td></tr><tr><td class="parameter_name"><para>test_func</para></td><td class="parameter_description"><para>The test function to invoke for this test.</para><para>Passed as <code>test-func</code></para></td></tr><tr><td class="parameter_name"><para>data_free_func</para></td><td class="parameter_description"><para><type>GDestroyNotify</type> for <parameter>test_data</parameter>.</para><para>Passed as <code>data-free-func</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-add-func</title><informalexample><programlisting>(define-values () (test-add-func testpath test-func))
  7839. </programlisting></informalexample><para>Create a new test case, similar to <function>g_test_create_case()</function>. However
  7840. the test is assumed to use no fixture, and test suites are automatically
  7841. created on the fly and added to the root fixture, based on the
  7842. slash-separated portions of <parameter>testpath</parameter>.
  7843. </para>
  7844. <para>If <parameter>testpath</parameter> includes the component &quot;subprocess&quot; anywhere in it,
  7845. the test will be skipped by default, and only run if explicitly
  7846. required via the <code>-p</code> command-line option or <function>g_test_trap_subprocess()</function>.
  7847. </para>
  7848. <para>No component of <parameter>testpath</parameter> may start with a dot (<code>.</code>) if the
  7849. <constant>G_TEST_OPTION_ISOLATE_DIRS</constant> option is being used; and it is recommended to
  7850. do so even if it isn’t.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>testpath</para></td><td class="parameter_description"><para>/-separated test case path name for the test.</para><para>Passed as <code>testpath</code></para></td></tr><tr><td class="parameter_name"><para>test_func</para></td><td class="parameter_description"><para>The test function to invoke for this test.</para><para>Passed as <code>test-func</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-assert-expected-messages-internal</title><informalexample><programlisting>(define-values
  7851. ()
  7852. (test-assert-expected-messages-internal domain file line func))
  7853. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para></para><para>Passed as <code>file</code></para></td></tr><tr><td class="parameter_name"><para>line</para></td><td class="parameter_description"><para></para><para>Passed as <code>line</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para></para><para>Passed as <code>func</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-bug</title><informalexample><programlisting>(define-values () (test-bug bug-uri-snippet))
  7854. </programlisting></informalexample><para>This function adds a message to test reports that
  7855. associates a bug URI with a test case.
  7856. Bug URIs are constructed from a base URI set with <function>g_test_bug_base()</function>
  7857. and <parameter>bug_uri_snippet</parameter>. If <function>g_test_bug_base()</function> has not been called, it is
  7858. assumed to be the empty string, so a full URI can be provided to
  7859. <function>g_test_bug()</function> instead.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>bug_uri_snippet</para></td><td class="parameter_description"><para>Bug specific bug tracker URI portion.</para><para>Passed as <code>bug-uri-snippet</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-bug-base</title><informalexample><programlisting>(define-values () (test-bug-base uri-pattern))
  7860. </programlisting></informalexample><para>Specify the base URI for bug reports.
  7861. </para>
  7862. <para>The base URI is used to construct bug report messages for
  7863. <function>g_test_message()</function> when <function>g_test_bug()</function> is called.
  7864. Calling this function outside of a test case sets the
  7865. default base URI for all test cases. Calling it from within
  7866. a test case changes the base URI for the scope of the test
  7867. case only.
  7868. Bug URIs are constructed by appending a bug specific URI
  7869. portion to <parameter>uri_pattern</parameter>, or by replacing the special string
  7870. '\%s' within <parameter>uri_pattern</parameter> if that is present.
  7871. </para>
  7872. <para>If <function>g_test_bug_base()</function> is not called, bug URIs are formed solely
  7873. from the value provided by <function>g_test_bug()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_pattern</para></td><td class="parameter_description"><para>the base pattern for bug URIs</para><para>Passed as <code>uri-pattern</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-expect-message</title><informalexample><programlisting>(define-values () (test-expect-message log-domain log-level pattern))
  7874. </programlisting></informalexample><para>Indicates that a message with the given <parameter>log_domain</parameter> and <parameter>log_level</parameter>,
  7875. with text matching <parameter>pattern</parameter>, is expected to be logged. When this
  7876. message is logged, it will not be printed, and the test case will
  7877. not abort.
  7878. </para>
  7879. <para>This API may only be used with the old logging API (<function>g_log()</function> without
  7880. <constant>G_LOG_USE_STRUCTURED</constant> defined). It will not work with the structured logging
  7881. API. See [Testing for Messages][testing-for-messages].
  7882. </para>
  7883. <para>Use <function>g_test_assert_expected_messages()</function> to assert that all
  7884. previously-expected messages have been seen and suppressed.
  7885. </para>
  7886. <para>You can call this multiple times in a row, if multiple messages are
  7887. expected as a result of a single call. (The messages must appear in
  7888. the same order as the calls to <function>g_test_expect_message()</function>.)
  7889. </para>
  7890. <para>For example:
  7891. </para>
  7892. <para><informalexample><programlisting>
  7893. // g_main_context_push_thread_default() should fail if the
  7894. // context is already owned by another thread.
  7895. g_test_expect_message (G_LOG_DOMAIN,
  7896. G_LOG_LEVEL_CRITICAL,
  7897. &quot;assertion*acquired_context*failed&quot;);
  7898. g_main_context_push_thread_default (bad_context);
  7899. g_test_assert_expected_messages ();
  7900. </programlisting></informalexample></para>
  7901. <para>Note that you cannot use this to test <function>g_error()</function> messages, since
  7902. <function>g_error()</function> intentionally never returns even if the program doesn't
  7903. abort; use <function>g_test_trap_subprocess()</function> in this case.
  7904. </para>
  7905. <para>If messages at <constant>G_LOG_LEVEL_DEBUG</constant> are emitted, but not explicitly
  7906. expected via <function>g_test_expect_message()</function> then they will be ignored.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>log_domain</para></td><td class="parameter_description"><para>the log domain of the message</para><para>Passed as <code>log-domain</code></para></td></tr><tr><td class="parameter_name"><para>log_level</para></td><td class="parameter_description"><para>the log level of the message</para><para>Passed as <code>log-level</code></para></td></tr><tr><td class="parameter_name"><para>pattern</para></td><td class="parameter_description"><para>a glob-style [pattern][glib-Glob-style-pattern-matching]</para><para>Passed as <code>pattern</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-fail</title><informalexample><programlisting>(define-values () (test-fail))
  7907. </programlisting></informalexample><para>Indicates that a test failed. This function can be called
  7908. multiple times from the same test. You can use this function
  7909. if your test failed in a recoverable way.
  7910. </para>
  7911. <para>Do not use this function if the failure of a test could cause
  7912. other tests to malfunction.
  7913. </para>
  7914. <para>Calling this function will not stop the test from running, you
  7915. need to return from the test function yourself. So you can
  7916. produce additional diagnostic messages or even continue running
  7917. the test.
  7918. </para>
  7919. <para>If not called from inside a test, this function does nothing.</para></refsect2><refsect2><title>test-failed?</title><informalexample><programlisting>(define-values (%return) (test-failed?))
  7920. </programlisting></informalexample><para>Returns whether a test has already failed. This will
  7921. be the case when <function>g_test_fail()</function>, <function>g_test_incomplete()</function>
  7922. or <function>g_test_skip()</function> have been called, but also if an
  7923. assertion has failed.
  7924. </para>
  7925. <para>This can be useful to return early from a test if
  7926. continuing after a failed assertion might be harmful.
  7927. </para>
  7928. <para>The return value of this function is only meaningful
  7929. if it is called from inside a test function.</para></refsect2><refsect2><title>test-get-dir</title><informalexample><programlisting>(define-values (%return) (test-get-dir file-type))
  7930. </programlisting></informalexample><para>Gets the pathname of the directory containing test files of the type
  7931. specified by <parameter>file_type</parameter>.
  7932. </para>
  7933. <para>This is approximately the same as calling g_test_build_filename(&quot;.&quot;),
  7934. but you don't need to free the return value.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>file_type</para></td><td class="parameter_description"><para>the type of file (built vs. distributed)</para><para>Passed as <code>file-type</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-get-path</title><informalexample><programlisting>(define-values (%return) (test-get-path))
  7935. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>test-incomplete</title><informalexample><programlisting>(define-values () (test-incomplete msg))
  7936. </programlisting></informalexample><para>Indicates that a test failed because of some incomplete
  7937. functionality. This function can be called multiple times
  7938. from the same test.
  7939. </para>
  7940. <para>Calling this function will not stop the test from running, you
  7941. need to return from the test function yourself. So you can
  7942. produce additional diagnostic messages or even continue running
  7943. the test.
  7944. </para>
  7945. <para>If not called from inside a test, this function does nothing.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>msg</para></td><td class="parameter_description"><para>explanation</para><para>Passed as <code>msg</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-log-type-name</title><informalexample><programlisting>(define-values (%return) (test-log-type-name log-type))
  7946. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>log_type</para></td><td class="parameter_description"><para></para><para>Passed as <code>log-type</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-queue-destroy</title><informalexample><programlisting>(define-values () (test-queue-destroy destroy-func destroy-data))
  7947. </programlisting></informalexample><para>This function enqueus a callback <parameter>destroy_func</parameter> to be executed
  7948. during the next test case teardown phase. This is most useful
  7949. to auto destruct allocated test resources at the end of a test run.
  7950. Resources are released in reverse queue order, that means enqueueing
  7951. callback A before callback B will cause <function>B()</function> to be called before
  7952. <function>A()</function> during teardown.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>destroy_func</para></td><td class="parameter_description"><para>Destroy callback for teardown phase.</para><para>Passed as <code>destroy-func</code></para></td></tr><tr><td class="parameter_name"><para>destroy_data</para></td><td class="parameter_description"><para>Destroy callback data.</para><para>Passed as <code>destroy-data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-queue-free</title><informalexample><programlisting>(define-values () (test-queue-free gfree-pointer))
  7953. </programlisting></informalexample><para>Enqueue a pointer to be released with <function>g_free()</function> during the next
  7954. teardown phase. This is equivalent to calling <function>g_test_queue_destroy()</function>
  7955. with a destroy callback of <function>g_free()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>gfree_pointer</para></td><td class="parameter_description"><para>the pointer to be stored.</para><para>Passed as <code>gfree-pointer</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-rand-double</title><informalexample><programlisting>(define-values (%return) (test-rand-double))
  7956. </programlisting></informalexample><para>Get a reproducible random floating point number,
  7957. see <function>g_test_rand_int()</function> for details on test case random numbers.</para></refsect2><refsect2><title>test-rand-double-range</title><informalexample><programlisting>(define-values (%return) (test-rand-double-range range-start range-end))
  7958. </programlisting></informalexample><para>Get a reproducible random floating pointer number out of a specified range,
  7959. see <function>g_test_rand_int()</function> for details on test case random numbers.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>range_start</para></td><td class="parameter_description"><para>the minimum value returned by this function</para><para>Passed as <code>range-start</code></para></td></tr><tr><td class="parameter_name"><para>range_end</para></td><td class="parameter_description"><para>the minimum value not returned by this function</para><para>Passed as <code>range-end</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-rand-int</title><informalexample><programlisting>(define-values (%return) (test-rand-int))
  7960. </programlisting></informalexample><para>Get a reproducible random integer number.
  7961. </para>
  7962. <para>The random numbers generated by the g_test_rand_*() family of functions
  7963. change with every new test program start, unless the --seed option is
  7964. given when starting test programs.
  7965. </para>
  7966. <para>For individual test cases however, the random number generator is
  7967. reseeded, to avoid dependencies between tests and to make --seed
  7968. effective for all test cases.</para></refsect2><refsect2><title>test-rand-int-range</title><informalexample><programlisting>(define-values (%return) (test-rand-int-range begin end))
  7969. </programlisting></informalexample><para>Get a reproducible random integer number out of a specified range,
  7970. see <function>g_test_rand_int()</function> for details on test case random numbers.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>begin</para></td><td class="parameter_description"><para>the minimum value returned by this function</para><para>Passed as <code>begin</code></para></td></tr><tr><td class="parameter_name"><para>end</para></td><td class="parameter_description"><para>the smallest value not to be returned by this function</para><para>Passed as <code>end</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-run</title><informalexample><programlisting>(define-values (%return) (test-run))
  7971. </programlisting></informalexample><para>Runs all tests under the toplevel suite which can be retrieved
  7972. with <function>g_test_get_root()</function>. Similar to <function>g_test_run_suite()</function>, the test
  7973. cases to be run are filtered according to test path arguments
  7974. (<code>-p testpath</code> and <code>-s testpath</code>) as parsed by <function>g_test_init()</function>.
  7975. <function>g_test_run_suite()</function> or <function>g_test_run()</function> may only be called once in a
  7976. program.
  7977. </para>
  7978. <para>In general, the tests and sub-suites within each suite are run in
  7979. the order in which they are defined. However, note that prior to
  7980. GLib 2.36, there was a bug in the <code>g_test_add_*</code>
  7981. functions which caused them to create multiple suites with the same
  7982. name, meaning that if you created tests &quot;/foo/simple&quot;,
  7983. &quot;/bar/simple&quot;, and &quot;/foo/using-bar&quot; in that order, they would get
  7984. run in that order (since <function>g_test_run()</function> would run the first &quot;/foo&quot;
  7985. suite, then the &quot;/bar&quot; suite, then the second &quot;/foo&quot; suite). As of
  7986. 2.36, this bug is fixed, and adding the tests in that order would
  7987. result in a running order of &quot;/foo/simple&quot;, &quot;/foo/using-bar&quot;,
  7988. &quot;/bar/simple&quot;. If this new ordering is sub-optimal (because it puts
  7989. more-complicated tests before simpler ones, making it harder to
  7990. figure out exactly what has failed), you can fix it by changing the
  7991. test paths to group tests by suite in a way that will result in the
  7992. desired running order. Eg, &quot;/simple/foo&quot;, &quot;/simple/bar&quot;,
  7993. &quot;/complex/foo-using-bar&quot;.
  7994. </para>
  7995. <para>However, you should never make the actual result of a test depend
  7996. on the order that tests are run in. If you need to ensure that some
  7997. particular code runs before or after a given test case, use
  7998. <function>g_test_add()</function>, which lets you specify setup and teardown functions.
  7999. </para>
  8000. <para>If all tests are skipped or marked as incomplete (expected failures),
  8001. this function will return 0 if producing TAP output, or 77 (treated
  8002. as &quot;skip test&quot; by Automake) otherwise.</para></refsect2><refsect2><title>test-set-nonfatal-assertions</title><informalexample><programlisting>(define-values () (test-set-nonfatal-assertions))
  8003. </programlisting></informalexample><para>Changes the behaviour of the various <code>g_assert_*()</code> macros,
  8004. <function>g_test_assert_expected_messages()</function> and the various
  8005. <code>g_test_trap_assert_*()</code> macros to not abort to program, but instead
  8006. call <function>g_test_fail()</function> and continue. (This also changes the behavior of
  8007. <function>g_test_fail()</function> so that it will not cause the test program to abort
  8008. after completing the failed test.)
  8009. </para>
  8010. <para>Note that the <function>g_assert_not_reached()</function> and <function>g_assert()</function> macros are not
  8011. affected by this.
  8012. </para>
  8013. <para>This function can only be called after <function>g_test_init()</function>.</para></refsect2><refsect2><title>test-skip</title><informalexample><programlisting>(define-values () (test-skip msg))
  8014. </programlisting></informalexample><para>Indicates that a test was skipped.
  8015. </para>
  8016. <para>Calling this function will not stop the test from running, you
  8017. need to return from the test function yourself. So you can
  8018. produce additional diagnostic messages or even continue running
  8019. the test.
  8020. </para>
  8021. <para>If not called from inside a test, this function does nothing.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>msg</para></td><td class="parameter_description"><para>explanation</para><para>Passed as <code>msg</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-subprocess?</title><informalexample><programlisting>(define-values (%return) (test-subprocess?))
  8022. </programlisting></informalexample><para>Returns <constant>TRUE</constant> (after <function>g_test_init()</function> has been called) if the test
  8023. program is running under <function>g_test_trap_subprocess()</function>.</para></refsect2><refsect2><title>test-summary</title><informalexample><programlisting>(define-values () (test-summary summary))
  8024. </programlisting></informalexample><para>Set the summary for a test, which describes what the test checks, and how it
  8025. goes about checking it. This may be included in test report output, and is
  8026. useful documentation for anyone reading the source code or modifying a test
  8027. in future. It must be a single line.
  8028. </para>
  8029. <para>This should be called at the top of a test function.
  8030. </para>
  8031. <para>For example:
  8032. <informalexample><programlisting>
  8033. static void
  8034. test_array_sort (void)
  8035. {
  8036. g_test_summary (&quot;Test my_array_sort() sorts the array correctly and stably, &quot;
  8037. &quot;including testing zero length and one-element arrays.&quot;);
  8038. }
  8039. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>summary</para></td><td class="parameter_description"><para>One or two sentences summarising what the test checks, and how it
  8040. checks it.</para><para>Passed as <code>summary</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-timer-elapsed</title><informalexample><programlisting>(define-values (%return) (test-timer-elapsed))
  8041. </programlisting></informalexample><para>Get the time since the last start of the timer with <function>g_test_timer_start()</function>.</para></refsect2><refsect2><title>test-timer-last</title><informalexample><programlisting>(define-values (%return) (test-timer-last))
  8042. </programlisting></informalexample><para>Report the last result of <function>g_test_timer_elapsed()</function>.</para></refsect2><refsect2><title>test-timer-start</title><informalexample><programlisting>(define-values () (test-timer-start))
  8043. </programlisting></informalexample><para>Start a timing test. Call <function>g_test_timer_elapsed()</function> when the task is supposed
  8044. to be done. Call this function again to restart the timer.</para></refsect2><refsect2><title>test-trap-assertions</title><informalexample><programlisting>(define-values
  8045. ()
  8046. (test-trap-assertions domain file line func assertion-flags pattern))
  8047. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>domain</para></td><td class="parameter_description"><para></para><para>Passed as <code>domain</code></para></td></tr><tr><td class="parameter_name"><para>file</para></td><td class="parameter_description"><para></para><para>Passed as <code>file</code></para></td></tr><tr><td class="parameter_name"><para>line</para></td><td class="parameter_description"><para></para><para>Passed as <code>line</code></para></td></tr><tr><td class="parameter_name"><para>func</para></td><td class="parameter_description"><para></para><para>Passed as <code>func</code></para></td></tr><tr><td class="parameter_name"><para>assertion_flags</para></td><td class="parameter_description"><para></para><para>Passed as <code>assertion-flags</code></para></td></tr><tr><td class="parameter_name"><para>pattern</para></td><td class="parameter_description"><para></para><para>Passed as <code>pattern</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>test-trap-has-passed?</title><informalexample><programlisting>(define-values (%return) (test-trap-has-passed?))
  8048. </programlisting></informalexample><para>Check the result of the last <function>g_test_trap_subprocess()</function> call.</para></refsect2><refsect2><title>test-trap-reached-timeout?</title><informalexample><programlisting>(define-values (%return) (test-trap-reached-timeout?))
  8049. </programlisting></informalexample><para>Check the result of the last <function>g_test_trap_subprocess()</function> call.</para></refsect2><refsect2><title>test-trap-subprocess</title><informalexample><programlisting>(define-values () (test-trap-subprocess test-path usec-timeout test-flags))
  8050. </programlisting></informalexample><para>Respawns the test program to run only <parameter>test_path</parameter> in a subprocess.
  8051. This can be used for a test case that might not return, or that
  8052. might abort.
  8053. </para>
  8054. <para>If <parameter>test_path</parameter> is <constant>NULL</constant> then the same test is re-run in a subprocess.
  8055. You can use <function>g_test_subprocess()</function> to determine whether the test is in
  8056. a subprocess or not.
  8057. </para>
  8058. <para><parameter>test_path</parameter> can also be the name of the parent test, followed by
  8059. &quot;`/subprocess/<code>&quot; and then a name for the specific subtest (or just
  8060. ending with &quot;</code>/subprocess`&quot; if the test only has one child test);
  8061. tests with names of this form will automatically be skipped in the
  8062. parent process.
  8063. </para>
  8064. <para>If <parameter>usec_timeout</parameter> is non-0, the test subprocess is aborted and
  8065. considered failing if its run time exceeds it.
  8066. </para>
  8067. <para>The subprocess behavior can be configured with the
  8068. <type>GTestSubprocessFlags</type> flags.
  8069. </para>
  8070. <para>You can use methods such as <function>g_test_trap_assert_passed()</function>,
  8071. <function>g_test_trap_assert_failed()</function>, and <function>g_test_trap_assert_stderr()</function> to
  8072. check the results of the subprocess. (But note that
  8073. <function>g_test_trap_assert_stdout()</function> and <function>g_test_trap_assert_stderr()</function>
  8074. cannot be used if <parameter>test_flags</parameter> specifies that the child should
  8075. inherit the parent stdout/stderr.)
  8076. </para>
  8077. <para>If your <code>main ()</code> needs to behave differently in
  8078. the subprocess, you can call <function>g_test_subprocess()</function> (after calling
  8079. <function>g_test_init()</function>) to see whether you are in a subprocess.
  8080. </para>
  8081. <para>The following example tests that calling
  8082. <code>my_object_new(1000000)</code> will abort with an error
  8083. message.
  8084. </para>
  8085. <para><informalexample><programlisting>
  8086. static void
  8087. test_create_large_object (void)
  8088. {
  8089. if (g_test_subprocess ())
  8090. {
  8091. my_object_new (1000000);
  8092. return;
  8093. }
  8094. // Reruns this same test in a subprocess
  8095. g_test_trap_subprocess (NULL, 0, 0);
  8096. g_test_trap_assert_failed ();
  8097. g_test_trap_assert_stderr (&quot;*ERROR*too large*&quot;);
  8098. }
  8099. int
  8100. main (int argc, char **argv)
  8101. {
  8102. g_test_init (&amp;argc, &amp;argv, NULL);
  8103. g_test_add_func (&quot;/myobject/create_large_object&quot;,
  8104. test_create_large_object);
  8105. return g_test_run ();
  8106. }
  8107. </programlisting></informalexample></para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>test_path</para></td><td class="parameter_description"><para>Test to run in a subprocess</para><para>Passed as <code>test-path</code></para></td></tr><tr><td class="parameter_name"><para>usec_timeout</para></td><td class="parameter_description"><para>Timeout for the subprocess test in micro seconds.</para><para>Passed as <code>usec-timeout</code></para></td></tr><tr><td class="parameter_name"><para>test_flags</para></td><td class="parameter_description"><para>Flags to modify subprocess behaviour.</para><para>Passed as <code>test-flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>thread-error-quark</title><informalexample><programlisting>(define-values (%return) (thread-error-quark))
  8108. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>thread-exit</title><informalexample><programlisting>(define-values () (thread-exit retval))
  8109. </programlisting></informalexample><para>Terminates the current thread.
  8110. </para>
  8111. <para>If another thread is waiting for us using <function>g_thread_join()</function> then the
  8112. waiting thread will be woken up and get <parameter>retval</parameter> as the return value
  8113. of <function>g_thread_join()</function>.
  8114. </para>
  8115. <para>Calling <function>g_thread_exit()</function> with a parameter <parameter>retval</parameter> is equivalent to
  8116. returning <parameter>retval</parameter> from the function <parameter>func</parameter>, as given to <function>g_thread_new()</function>.
  8117. </para>
  8118. <para>You must only call <function>g_thread_exit()</function> from a thread that you created
  8119. yourself with <function>g_thread_new()</function> or related APIs. You must not call
  8120. this function from a thread created with another threading library
  8121. or or from within a <type>GThreadPool</type>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>retval</para></td><td class="parameter_description"><para>the return value of this thread</para><para>Passed as <code>retval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>thread-pool-get-max-idle-time</title><informalexample><programlisting>(define-values (%return) (thread-pool-get-max-idle-time))
  8122. </programlisting></informalexample><para>This function will return the maximum <parameter>interval</parameter> that a
  8123. thread will wait in the thread pool for new tasks before
  8124. being stopped.
  8125. </para>
  8126. <para>If this function returns 0, threads waiting in the thread
  8127. pool for new work are not stopped.</para></refsect2><refsect2><title>thread-pool-get-max-unused-threads</title><informalexample><programlisting>(define-values (%return) (thread-pool-get-max-unused-threads))
  8128. </programlisting></informalexample><para>Returns the maximal allowed number of unused threads.</para></refsect2><refsect2><title>thread-pool-get-num-unused-threads</title><informalexample><programlisting>(define-values (%return) (thread-pool-get-num-unused-threads))
  8129. </programlisting></informalexample><para>Returns the number of currently unused threads.</para></refsect2><refsect2><title>thread-pool-set-max-idle-time</title><informalexample><programlisting>(define-values () (thread-pool-set-max-idle-time interval))
  8130. </programlisting></informalexample><para>This function will set the maximum <parameter>interval</parameter> that a thread
  8131. waiting in the pool for new tasks can be idle for before
  8132. being stopped. This function is similar to calling
  8133. <function>g_thread_pool_stop_unused_threads()</function> on a regular timeout,
  8134. except this is done on a per thread basis.
  8135. </para>
  8136. <para>By setting <parameter>interval</parameter> to 0, idle threads will not be stopped.
  8137. </para>
  8138. <para>The default value is 15000 (15 seconds).</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>interval</para></td><td class="parameter_description"><para>the maximum <parameter>interval</parameter> (in milliseconds)
  8139. a thread can be idle</para><para>Passed as <code>interval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>thread-pool-set-max-unused-threads</title><informalexample><programlisting>(define-values () (thread-pool-set-max-unused-threads max-threads))
  8140. </programlisting></informalexample><para>Sets the maximal number of unused threads to <parameter>max_threads</parameter>.
  8141. If <parameter>max_threads</parameter> is -1, no limit is imposed on the number
  8142. of unused threads.
  8143. </para>
  8144. <para>The default value is 2.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>max_threads</para></td><td class="parameter_description"><para>maximal number of unused threads</para><para>Passed as <code>max-threads</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>thread-pool-stop-unused-threads</title><informalexample><programlisting>(define-values () (thread-pool-stop-unused-threads))
  8145. </programlisting></informalexample><para>Stops all currently unused threads. This does not change the
  8146. maximal number of unused threads. This function can be used to
  8147. regularly stop all unused threads e.g. from <function>g_timeout_add()</function>.</para></refsect2><refsect2><title>thread-self</title><informalexample><programlisting>(define-values (%return) (thread-self))
  8148. </programlisting></informalexample><para>This function returns the <type>GThread</type> corresponding to the
  8149. current thread. Note that this function does not increase
  8150. the reference count of the returned struct.
  8151. </para>
  8152. <para>This function will return a <type>GThread</type> even for threads that
  8153. were not created by GLib (i.e. those created by other threading
  8154. APIs). This may be useful for thread identification purposes
  8155. (i.e. comparisons) but you must not use GLib functions (such
  8156. as <function>g_thread_join()</function>) on these threads.</para></refsect2><refsect2><title>thread-yield</title><informalexample><programlisting>(define-values () (thread-yield))
  8157. </programlisting></informalexample><para>Causes the calling thread to voluntarily relinquish the CPU, so
  8158. that other threads can run.
  8159. </para>
  8160. <para>This function is often used as a method to make busy wait less evil.</para></refsect2><refsect2><title>timeout-add</title><informalexample><programlisting>(define-values (%return) (timeout-add priority interval function data notify))
  8161. </programlisting></informalexample><para>Sets a function to be called at regular intervals, with the default
  8162. priority, <type>G_PRIORITY_DEFAULT</type>. The function is called repeatedly
  8163. until it returns <constant>FALSE</constant>, at which point the timeout is automatically
  8164. destroyed and the function will not be called again. The first call
  8165. to the function will be at the end of the first <parameter>interval</parameter>.
  8166. </para>
  8167. <para>Note that timeout functions may be delayed, due to the processing of other
  8168. event sources. Thus they should not be relied on for precise timing.
  8169. After each call to the timeout function, the time of the next
  8170. timeout is recalculated based on the current time and the given interval
  8171. (it does not try to 'catch up' time lost in delays).
  8172. </para>
  8173. <para>See [memory management of sources][mainloop-memory-management] for details
  8174. on how to handle the return value and memory management of <parameter>data</parameter>.
  8175. </para>
  8176. <para>If you want to have a timer in the &quot;seconds&quot; range and do not care
  8177. about the exact time of the first call of the timer, use the
  8178. <function>g_timeout_add_seconds()</function> function; this function allows for more
  8179. optimizations and more efficient system power usage.
  8180. </para>
  8181. <para>This internally creates a main loop source using <function>g_timeout_source_new()</function>
  8182. and attaches it to the global <type>GMainContext</type> using <function>g_source_attach()</function>, so
  8183. the callback will be invoked in whichever thread is running that main
  8184. context. You can do these steps manually if you need greater control or to
  8185. use a custom main context.
  8186. </para>
  8187. <para>It is safe to call this function from any thread.
  8188. </para>
  8189. <para>The interval given is in terms of monotonic time, not wall clock
  8190. time. See <function>g_get_monotonic_time()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>notify</para></td><td class="parameter_description"><para></para><para>Passed as <code>notify</code></para></td></tr><tr><td class="parameter_name"><para>priority</para></td><td class="parameter_description"><para></para><para>Passed as <code>priority</code></para></td></tr><tr><td class="parameter_name"><para>interval</para></td><td class="parameter_description"><para>the time between calls to the function, in milliseconds
  8191. (1/1000ths of a second)</para><para>Passed as <code>interval</code></para></td></tr><tr><td class="parameter_name"><para>function</para></td><td class="parameter_description"><para>function to call</para><para>Passed as <code>function</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>data to pass to <parameter>function</parameter></para><para>Passed as <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>timeout-add-seconds</title><informalexample><programlisting>(define-values
  8192. (%return)
  8193. (timeout-add-seconds priority interval function data notify))
  8194. </programlisting></informalexample><para>Sets a function to be called at regular intervals with the default
  8195. priority, <type>G_PRIORITY_DEFAULT</type>. The function is called repeatedly until
  8196. it returns <constant>FALSE</constant>, at which point the timeout is automatically destroyed
  8197. and the function will not be called again.
  8198. </para>
  8199. <para>This internally creates a main loop source using
  8200. <function>g_timeout_source_new_seconds()</function> and attaches it to the main loop context
  8201. using <function>g_source_attach()</function>. You can do these steps manually if you need
  8202. greater control. Also see <function>g_timeout_add_seconds_full()</function>.
  8203. </para>
  8204. <para>It is safe to call this function from any thread.
  8205. </para>
  8206. <para>Note that the first call of the timer may not be precise for timeouts
  8207. of one second. If you need finer precision and have such a timeout,
  8208. you may want to use <function>g_timeout_add()</function> instead.
  8209. </para>
  8210. <para>See [memory management of sources][mainloop-memory-management] for details
  8211. on how to handle the return value and memory management of <parameter>data</parameter>.
  8212. </para>
  8213. <para>The interval given is in terms of monotonic time, not wall clock
  8214. time. See <function>g_get_monotonic_time()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>notify</para></td><td class="parameter_description"><para></para><para>Passed as <code>notify</code></para></td></tr><tr><td class="parameter_name"><para>priority</para></td><td class="parameter_description"><para></para><para>Passed as <code>priority</code></para></td></tr><tr><td class="parameter_name"><para>interval</para></td><td class="parameter_description"><para>the time between calls to the function, in seconds</para><para>Passed as <code>interval</code></para></td></tr><tr><td class="parameter_name"><para>function</para></td><td class="parameter_description"><para>function to call</para><para>Passed as <code>function</code></para></td></tr><tr><td class="parameter_name"><para>data</para></td><td class="parameter_description"><para>data to pass to <parameter>function</parameter></para><para>Passed as <code>data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>timeout-source-new</title><informalexample><programlisting>(define-values (%return) (timeout-source-new interval))
  8215. </programlisting></informalexample><para>Creates a new timeout source.
  8216. </para>
  8217. <para>The source will not initially be associated with any <type>GMainContext</type>
  8218. and must be added to one with <function>g_source_attach()</function> before it will be
  8219. executed.
  8220. </para>
  8221. <para>The interval given is in terms of monotonic time, not wall clock
  8222. time. See <function>g_get_monotonic_time()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>interval</para></td><td class="parameter_description"><para>the timeout interval in milliseconds.</para><para>Passed as <code>interval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>timeout-source-new-seconds</title><informalexample><programlisting>(define-values (%return) (timeout-source-new-seconds interval))
  8223. </programlisting></informalexample><para>Creates a new timeout source.
  8224. </para>
  8225. <para>The source will not initially be associated with any <type>GMainContext</type>
  8226. and must be added to one with <function>g_source_attach()</function> before it will be
  8227. executed.
  8228. </para>
  8229. <para>The scheduling granularity/accuracy of this timeout source will be
  8230. in seconds.
  8231. </para>
  8232. <para>The interval given is in terms of monotonic time, not wall clock time.
  8233. See <function>g_get_monotonic_time()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>interval</para></td><td class="parameter_description"><para>the timeout interval in seconds</para><para>Passed as <code>interval</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>try-malloc</title><informalexample><programlisting>(define-values (%return) (try-malloc n-bytes))
  8234. </programlisting></informalexample><para>Attempts to allocate <parameter>n_bytes</parameter>, and returns <constant>NULL</constant> on failure.
  8235. Contrast with <function>g_malloc()</function>, which aborts the program on failure.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>n_bytes</para></td><td class="parameter_description"><para>number of bytes to allocate.</para><para>Passed as <code>n-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>try-malloc0</title><informalexample><programlisting>(define-values (%return) (try-malloc0 n-bytes))
  8236. </programlisting></informalexample><para>Attempts to allocate <parameter>n_bytes</parameter>, initialized to 0's, and returns <constant>NULL</constant> on
  8237. failure. Contrast with <function>g_malloc0()</function>, which aborts the program on failure.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>n_bytes</para></td><td class="parameter_description"><para>number of bytes to allocate</para><para>Passed as <code>n-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>try-malloc0-n</title><informalexample><programlisting>(define-values (%return) (try-malloc0-n n-blocks n-block-bytes))
  8238. </programlisting></informalexample><para>This function is similar to <function>g_try_malloc0()</function>, allocating (<parameter>n_blocks</parameter> * <parameter>n_block_bytes</parameter>) bytes,
  8239. but care is taken to detect possible overflow during multiplication.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>n_blocks</para></td><td class="parameter_description"><para>the number of blocks to allocate</para><para>Passed as <code>n-blocks</code></para></td></tr><tr><td class="parameter_name"><para>n_block_bytes</para></td><td class="parameter_description"><para>the size of each block in bytes</para><para>Passed as <code>n-block-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>try-malloc-n</title><informalexample><programlisting>(define-values (%return) (try-malloc-n n-blocks n-block-bytes))
  8240. </programlisting></informalexample><para>This function is similar to <function>g_try_malloc()</function>, allocating (<parameter>n_blocks</parameter> * <parameter>n_block_bytes</parameter>) bytes,
  8241. but care is taken to detect possible overflow during multiplication.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>n_blocks</para></td><td class="parameter_description"><para>the number of blocks to allocate</para><para>Passed as <code>n-blocks</code></para></td></tr><tr><td class="parameter_name"><para>n_block_bytes</para></td><td class="parameter_description"><para>the size of each block in bytes</para><para>Passed as <code>n-block-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>try-realloc</title><informalexample><programlisting>(define-values (%return) (try-realloc mem n-bytes))
  8242. </programlisting></informalexample><para>Attempts to realloc <parameter>mem</parameter> to a new size, <parameter>n_bytes</parameter>, and returns <constant>NULL</constant>
  8243. on failure. Contrast with <function>g_realloc()</function>, which aborts the program
  8244. on failure.
  8245. </para>
  8246. <para>If <parameter>mem</parameter> is <constant>NULL</constant>, behaves the same as <function>g_try_malloc()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem</para></td><td class="parameter_description"><para>previously-allocated memory, or <constant>NULL</constant>.</para><para>Passed as <code>mem</code></para></td></tr><tr><td class="parameter_name"><para>n_bytes</para></td><td class="parameter_description"><para>number of bytes to allocate.</para><para>Passed as <code>n-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>try-realloc-n</title><informalexample><programlisting>(define-values (%return) (try-realloc-n mem n-blocks n-block-bytes))
  8247. </programlisting></informalexample><para>This function is similar to <function>g_try_realloc()</function>, allocating (<parameter>n_blocks</parameter> * <parameter>n_block_bytes</parameter>) bytes,
  8248. but care is taken to detect possible overflow during multiplication.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>mem</para></td><td class="parameter_description"><para>previously-allocated memory, or <constant>NULL</constant>.</para><para>Passed as <code>mem</code></para></td></tr><tr><td class="parameter_name"><para>n_blocks</para></td><td class="parameter_description"><para>the number of blocks to allocate</para><para>Passed as <code>n-blocks</code></para></td></tr><tr><td class="parameter_name"><para>n_block_bytes</para></td><td class="parameter_description"><para>the size of each block in bytes</para><para>Passed as <code>n-block-bytes</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ucs4-to-utf16</title><informalexample><programlisting>(define-values
  8249. (%return items-read items-written)
  8250. (ucs4-to-utf16 str len items-read items-written))
  8251. </programlisting></informalexample><para>Convert a string from UCS-4 to UTF-16. A 0 character will be
  8252. added to the result after the converted text.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UCS-4 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length (number of characters) of <parameter>str</parameter> to use.
  8253. If <parameter>len</parameter> &lt; 0, then the string is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>items_read</para></td><td class="parameter_description"><para>location to store number of
  8254. bytes read, or <constant>NULL</constant>. If an error occurs then the index of the invalid
  8255. input is stored here.</para><para>Passed as <code>items-read</code></para></td></tr><tr><td class="parameter_name"><para>items_written</para></td><td class="parameter_description"><para>location to store number
  8256. of <type>gunichar2</type> written, or <constant>NULL</constant>. The value stored here does not include
  8257. the trailing 0.</para><para>Passed as <code>items-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>ucs4-to-utf8</title><informalexample><programlisting>(define-values
  8258. (%return items-read items-written)
  8259. (ucs4-to-utf8 str len items-read items-written))
  8260. </programlisting></informalexample><para>Convert a string from a 32-bit fixed width representation as UCS-4.
  8261. to UTF-8. The result will be terminated with a 0 byte.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UCS-4 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length (number of characters) of <parameter>str</parameter> to use.
  8262. If <parameter>len</parameter> &lt; 0, then the string is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>items_read</para></td><td class="parameter_description"><para>location to store number of
  8263. characters read, or <constant>NULL</constant>.</para><para>Passed as <code>items-read</code></para></td></tr><tr><td class="parameter_name"><para>items_written</para></td><td class="parameter_description"><para>location to store number
  8264. of bytes written or <constant>NULL</constant>. The value here stored does not include the
  8265. trailing 0 byte.</para><para>Passed as <code>items-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-break-type</title><informalexample><programlisting>(define-values (%return) (unichar-break-type c))
  8266. </programlisting></informalexample><para>Determines the break type of <parameter>c</parameter>. <parameter>c</parameter> should be a Unicode character
  8267. (to derive a character from UTF-8 encoded text, use
  8268. <function>g_utf8_get_char()</function>). The break type is used to find word and line
  8269. breaks (&quot;text boundaries&quot;), Pango implements the Unicode boundary
  8270. resolution algorithms and normally you would use a function such
  8271. as <function>pango_break()</function> instead of caring about break types yourself.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-combining-class</title><informalexample><programlisting>(define-values (%return) (unichar-combining-class uc))
  8272. </programlisting></informalexample><para>Determines the canonical combining class of a Unicode character.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uc</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>uc</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-compose</title><informalexample><programlisting>(define-values (%return ch) (unichar-compose a b))
  8273. </programlisting></informalexample><para>Performs a single composition step of the
  8274. Unicode canonical composition algorithm.
  8275. </para>
  8276. <para>This function includes algorithmic Hangul Jamo composition,
  8277. but it is not exactly the inverse of <function>g_unichar_decompose()</function>.
  8278. No composition can have either of <parameter>a</parameter> or <parameter>b</parameter> equal to zero.
  8279. To be precise, this function composes if and only if
  8280. there exists a Primary Composite P which is canonically
  8281. equivalent to the sequence &lt;<parameter>a</parameter>,<parameter>b</parameter>&gt;. See the Unicode
  8282. Standard for the definition of Primary Composite.
  8283. </para>
  8284. <para>If <parameter>a</parameter> and <parameter>b</parameter> do not compose a new character, <parameter>ch</parameter> is set to zero.
  8285. </para>
  8286. <para>See
  8287. [UAX#15](http://unicode.org/reports/tr15/)
  8288. for details.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>a</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>a</code></para></td></tr><tr><td class="parameter_name"><para>b</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>b</code></para></td></tr><tr><td class="parameter_name"><para>ch</para></td><td class="parameter_description"><para>return location for the composed character</para><para>Passed as <code>ch</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-decompose</title><informalexample><programlisting>(define-values (%return a b) (unichar-decompose ch))
  8289. </programlisting></informalexample><para>Performs a single decomposition step of the
  8290. Unicode canonical decomposition algorithm.
  8291. </para>
  8292. <para>This function does not include compatibility
  8293. decompositions. It does, however, include algorithmic
  8294. Hangul Jamo decomposition, as well as 'singleton'
  8295. decompositions which replace a character by a single
  8296. other character. In the case of singletons *<parameter>b</parameter> will
  8297. be set to zero.
  8298. </para>
  8299. <para>If <parameter>ch</parameter> is not decomposable, *<parameter>a</parameter> is set to <parameter>ch</parameter> and *<parameter>b</parameter>
  8300. is set to zero.
  8301. </para>
  8302. <para>Note that the way Unicode decomposition pairs are
  8303. defined, it is guaranteed that <parameter>b</parameter> would not decompose
  8304. further, but <parameter>a</parameter> may itself decompose. To get the full
  8305. canonical decomposition for <parameter>ch</parameter>, one would need to
  8306. recursively call this function on <parameter>a</parameter>. Or use
  8307. <function>g_unichar_fully_decompose()</function>.
  8308. </para>
  8309. <para>See
  8310. [UAX#15](http://unicode.org/reports/tr15/)
  8311. for details.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>ch</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>ch</code></para></td></tr><tr><td class="parameter_name"><para>a</para></td><td class="parameter_description"><para>return location for the first component of <parameter>ch</parameter></para><para>Passed as <code>a</code></para></td></tr><tr><td class="parameter_name"><para>b</para></td><td class="parameter_description"><para>return location for the second component of <parameter>ch</parameter></para><para>Passed as <code>b</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-digit-value</title><informalexample><programlisting>(define-values (%return) (unichar-digit-value c))
  8312. </programlisting></informalexample><para>Determines the numeric value of a character as a decimal
  8313. digit.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-fully-decompose</title><informalexample><programlisting>(define-values
  8314. (%return result)
  8315. (unichar-fully-decompose ch compat result result-len))
  8316. </programlisting></informalexample><para>Computes the canonical or compatibility decomposition of a
  8317. Unicode character. For compatibility decomposition,
  8318. pass <constant>TRUE</constant> for <parameter>compat</parameter>; for canonical decomposition
  8319. pass <constant>FALSE</constant> for <parameter>compat</parameter>.
  8320. </para>
  8321. <para>The decomposed sequence is placed in <parameter>result</parameter>. Only up to
  8322. <parameter>result_len</parameter> characters are written into <parameter>result</parameter>. The length
  8323. of the full decomposition (irrespective of <parameter>result_len</parameter>) is
  8324. returned by the function. For canonical decomposition,
  8325. currently all decompositions are of length at most 4, but
  8326. this may change in the future (very unlikely though).
  8327. At any rate, Unicode does guarantee that a buffer of length
  8328. 18 is always enough for both compatibility and canonical
  8329. decompositions, so that is the size recommended. This is provided
  8330. as <constant>G_UNICHAR_MAX_DECOMPOSITION_LENGTH</constant>.
  8331. </para>
  8332. <para>See
  8333. [UAX#15](http://unicode.org/reports/tr15/)
  8334. for details.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>ch</para></td><td class="parameter_description"><para>a Unicode character.</para><para>Passed as <code>ch</code></para></td></tr><tr><td class="parameter_name"><para>compat</para></td><td class="parameter_description"><para>whether perform canonical or compatibility decomposition</para><para>Passed as <code>compat</code></para></td></tr><tr><td class="parameter_name"><para>result</para></td><td class="parameter_description"><para>location to store decomposed result, or <constant>NULL</constant></para><para>Passed as <code>result</code></para></td></tr><tr><td class="parameter_name"><para>result_len</para></td><td class="parameter_description"><para>length of <parameter>result</parameter></para><para>Passed as <code>result-len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-get-mirror-char?</title><informalexample><programlisting>(define-values (%return) (unichar-get-mirror-char? ch mirrored-ch))
  8335. </programlisting></informalexample><para>In Unicode, some characters are &quot;mirrored&quot;. This means that their
  8336. images are mirrored horizontally in text that is laid out from right
  8337. to left. For instance, &quot;(&quot; would become its mirror image, &quot;)&quot;, in
  8338. right-to-left text.
  8339. </para>
  8340. <para>If <parameter>ch</parameter> has the Unicode mirrored property and there is another unicode
  8341. character that typically has a glyph that is the mirror image of <parameter>ch</parameter>'s
  8342. glyph and <parameter>mirrored_ch</parameter> is set, it puts that character in the address
  8343. pointed to by <parameter>mirrored_ch</parameter>. Otherwise the original character is put.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>ch</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>ch</code></para></td></tr><tr><td class="parameter_name"><para>mirrored_ch</para></td><td class="parameter_description"><para>location to store the mirrored character</para><para>Passed as <code>mirrored-ch</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-get-script</title><informalexample><programlisting>(define-values (%return) (unichar-get-script ch))
  8344. </programlisting></informalexample><para>Looks up the <type>GUnicodeScript</type> for a particular character (as defined
  8345. by Unicode Standard Annex \#24). No check is made for <parameter>ch</parameter> being a
  8346. valid Unicode character; if you pass in invalid character, the
  8347. result is undefined.
  8348. </para>
  8349. <para>This function is equivalent to <function>pango_script_for_unichar()</function> and the
  8350. two are interchangeable.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>ch</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>ch</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-isalnum?</title><informalexample><programlisting>(define-values (%return) (unichar-isalnum? c))
  8351. </programlisting></informalexample><para>Determines whether a character is alphanumeric.
  8352. Given some UTF-8 text, obtain a character value
  8353. with <function>g_utf8_get_char()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-isalpha?</title><informalexample><programlisting>(define-values (%return) (unichar-isalpha? c))
  8354. </programlisting></informalexample><para>Determines whether a character is alphabetic (i.e. a letter).
  8355. Given some UTF-8 text, obtain a character value with
  8356. <function>g_utf8_get_char()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-iscntrl?</title><informalexample><programlisting>(define-values (%return) (unichar-iscntrl? c))
  8357. </programlisting></informalexample><para>Determines whether a character is a control character.
  8358. Given some UTF-8 text, obtain a character value with
  8359. <function>g_utf8_get_char()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-isdefined?</title><informalexample><programlisting>(define-values (%return) (unichar-isdefined? c))
  8360. </programlisting></informalexample><para>Determines if a given character is assigned in the Unicode
  8361. standard.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-isdigit?</title><informalexample><programlisting>(define-values (%return) (unichar-isdigit? c))
  8362. </programlisting></informalexample><para>Determines whether a character is numeric (i.e. a digit). This
  8363. covers ASCII 0-9 and also digits in other languages/scripts. Given
  8364. some UTF-8 text, obtain a character value with <function>g_utf8_get_char()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-isgraph?</title><informalexample><programlisting>(define-values (%return) (unichar-isgraph? c))
  8365. </programlisting></informalexample><para>Determines whether a character is printable and not a space
  8366. (returns <constant>FALSE</constant> for control characters, format characters, and
  8367. spaces). <function>g_unichar_isprint()</function> is similar, but returns <constant>TRUE</constant> for
  8368. spaces. Given some UTF-8 text, obtain a character value with
  8369. <function>g_utf8_get_char()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-islower?</title><informalexample><programlisting>(define-values (%return) (unichar-islower? c))
  8370. </programlisting></informalexample><para>Determines whether a character is a lowercase letter.
  8371. Given some UTF-8 text, obtain a character value with
  8372. <function>g_utf8_get_char()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-ismark?</title><informalexample><programlisting>(define-values (%return) (unichar-ismark? c))
  8373. </programlisting></informalexample><para>Determines whether a character is a mark (non-spacing mark,
  8374. combining mark, or enclosing mark in Unicode speak).
  8375. Given some UTF-8 text, obtain a character value
  8376. with <function>g_utf8_get_char()</function>.
  8377. </para>
  8378. <para>Note: in most cases where isalpha characters are allowed,
  8379. ismark characters should be allowed to as they are essential
  8380. for writing most European languages as well as many non-Latin
  8381. scripts.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-isprint?</title><informalexample><programlisting>(define-values (%return) (unichar-isprint? c))
  8382. </programlisting></informalexample><para>Determines whether a character is printable.
  8383. Unlike <function>g_unichar_isgraph()</function>, returns <constant>TRUE</constant> for spaces.
  8384. Given some UTF-8 text, obtain a character value with
  8385. <function>g_utf8_get_char()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-ispunct?</title><informalexample><programlisting>(define-values (%return) (unichar-ispunct? c))
  8386. </programlisting></informalexample><para>Determines whether a character is punctuation or a symbol.
  8387. Given some UTF-8 text, obtain a character value with
  8388. <function>g_utf8_get_char()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-isspace?</title><informalexample><programlisting>(define-values (%return) (unichar-isspace? c))
  8389. </programlisting></informalexample><para>Determines whether a character is a space, tab, or line separator
  8390. (newline, carriage return, etc.). Given some UTF-8 text, obtain a
  8391. character value with <function>g_utf8_get_char()</function>.
  8392. </para>
  8393. <para>(Note: don't use this to do word breaking; you have to use
  8394. Pango or equivalent to get word breaking right, the algorithm
  8395. is fairly complex.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-istitle?</title><informalexample><programlisting>(define-values (%return) (unichar-istitle? c))
  8396. </programlisting></informalexample><para>Determines if a character is titlecase. Some characters in
  8397. Unicode which are composites, such as the DZ digraph
  8398. have three case variants instead of just two. The titlecase
  8399. form is used at the beginning of a word where only the
  8400. first letter is capitalized. The titlecase form of the DZ
  8401. digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-isupper?</title><informalexample><programlisting>(define-values (%return) (unichar-isupper? c))
  8402. </programlisting></informalexample><para>Determines if a character is uppercase.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-iswide?</title><informalexample><programlisting>(define-values (%return) (unichar-iswide? c))
  8403. </programlisting></informalexample><para>Determines if a character is typically rendered in a double-width
  8404. cell.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-iswide-cjk?</title><informalexample><programlisting>(define-values (%return) (unichar-iswide-cjk? c))
  8405. </programlisting></informalexample><para>Determines if a character is typically rendered in a double-width
  8406. cell under legacy East Asian locales. If a character is wide according to
  8407. <function>g_unichar_iswide()</function>, then it is also reported wide with this function, but
  8408. the converse is not necessarily true. See the
  8409. [Unicode Standard Annex <type>11</type>](http://www.unicode.org/reports/tr11/)
  8410. for details.
  8411. </para>
  8412. <para>If a character passes the <function>g_unichar_iswide()</function> test then it will also pass
  8413. this test, but not the other way around. Note that some characters may
  8414. pass both this test and <function>g_unichar_iszerowidth()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-isxdigit?</title><informalexample><programlisting>(define-values (%return) (unichar-isxdigit? c))
  8415. </programlisting></informalexample><para>Determines if a character is a hexadecimal digit.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character.</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-iszerowidth?</title><informalexample><programlisting>(define-values (%return) (unichar-iszerowidth? c))
  8416. </programlisting></informalexample><para>Determines if a given character typically takes zero width when rendered.
  8417. The return value is <constant>TRUE</constant> for all non-spacing and enclosing marks
  8418. (e.g., combining accents), format characters, zero-width
  8419. space, but not U+00AD SOFT HYPHEN.
  8420. </para>
  8421. <para>A typical use of this function is with one of <function>g_unichar_iswide()</function> or
  8422. <function>g_unichar_iswide_cjk()</function> to determine the number of cells a string occupies
  8423. when displayed on a grid display (terminals). However, note that not all
  8424. terminals support zero-width rendering of zero-width marks.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-to-utf8!</title><informalexample><programlisting>(define-values (%return outbuf) (unichar-to-utf8! c outbuf))
  8425. </programlisting></informalexample><para>Converts a single character to UTF-8.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character code</para><para>Passed as <code>c</code></para></td></tr><tr><td class="parameter_name"><para>outbuf</para></td><td class="parameter_description"><para>output buffer, must have at
  8426. least 6 bytes of space. If <constant>NULL</constant>, the length will be computed and
  8427. returned and nothing will be written to <parameter>outbuf</parameter>.</para><para>Passed as <code>outbuf</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-tolower</title><informalexample><programlisting>(define-values (%return) (unichar-tolower c))
  8428. </programlisting></informalexample><para>Converts a character to lower case.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character.</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-totitle</title><informalexample><programlisting>(define-values (%return) (unichar-totitle c))
  8429. </programlisting></informalexample><para>Converts a character to the titlecase.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-toupper</title><informalexample><programlisting>(define-values (%return) (unichar-toupper c))
  8430. </programlisting></informalexample><para>Converts a character to uppercase.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-type</title><informalexample><programlisting>(define-values (%return) (unichar-type c))
  8431. </programlisting></informalexample><para>Classifies a Unicode character by type.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-validate?</title><informalexample><programlisting>(define-values (%return) (unichar-validate? ch))
  8432. </programlisting></informalexample><para>Checks whether <parameter>ch</parameter> is a valid Unicode character. Some possible
  8433. integer values of <parameter>ch</parameter> will not be valid. 0 is considered a valid
  8434. character, though it's normally a string terminator.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>ch</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>ch</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unichar-xdigit-value</title><informalexample><programlisting>(define-values (%return) (unichar-xdigit-value c))
  8435. </programlisting></informalexample><para>Determines the numeric value of a character as a hexadecimal
  8436. digit.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unicode-canonical-ordering</title><informalexample><programlisting>(define-values () (unicode-canonical-ordering string len))
  8437. </programlisting></informalexample><para>Computes the canonical ordering of a string in-place.
  8438. This rearranges decomposed characters in the string
  8439. according to their combining classes. See the Unicode
  8440. manual for more information.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a UCS-4 encoded string.</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length of <parameter>string</parameter> to use.</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unicode-script-from-iso15924</title><informalexample><programlisting>(define-values (%return) (unicode-script-from-iso15924 iso15924))
  8441. </programlisting></informalexample><para>Looks up the Unicode script for <parameter>iso15924</parameter>. ISO 15924 assigns four-letter
  8442. codes to scripts. For example, the code for Arabic is 'Arab'.
  8443. This function accepts four letter codes encoded as a <parameter>guint32</parameter> in a
  8444. big-endian fashion. That is, the code expected for Arabic is
  8445. 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
  8446. </para>
  8447. <para>See
  8448. [Codes for the representation of names of scripts](http://unicode.org/iso15924/codelists.html)
  8449. for details.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>iso15924</para></td><td class="parameter_description"><para>a Unicode script</para><para>Passed as <code>iso15924</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unicode-script-to-iso15924</title><informalexample><programlisting>(define-values (%return) (unicode-script-to-iso15924 script))
  8450. </programlisting></informalexample><para>Looks up the ISO 15924 code for <parameter>script</parameter>. ISO 15924 assigns four-letter
  8451. codes to scripts. For example, the code for Arabic is 'Arab'. The
  8452. four letter codes are encoded as a <parameter>guint32</parameter> by this function in a
  8453. big-endian fashion. That is, the code returned for Arabic is
  8454. 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
  8455. </para>
  8456. <para>See
  8457. [Codes for the representation of names of scripts](http://unicode.org/iso15924/codelists.html)
  8458. for details.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>script</para></td><td class="parameter_description"><para>a Unicode script</para><para>Passed as <code>script</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unix-error-quark</title><informalexample><programlisting>(define-values (%return) (unix-error-quark))
  8459. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>unix-fd-add-full</title><informalexample><programlisting>(define-values
  8460. (%return)
  8461. (unix-fd-add-full priority fd condition function user-data notify))
  8462. </programlisting></informalexample><para>Sets a function to be called when the IO condition, as specified by
  8463. <parameter>condition</parameter> becomes true for <parameter>fd</parameter>.
  8464. </para>
  8465. <para>This is the same as <function>g_unix_fd_add()</function>, except that it allows you to
  8466. specify a non-default priority and a provide a <type>GDestroyNotify</type> for
  8467. <parameter>user_data</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>priority</para></td><td class="parameter_description"><para>the priority of the source</para><para>Passed as <code>priority</code></para></td></tr><tr><td class="parameter_name"><para>fd</para></td><td class="parameter_description"><para>a file descriptor</para><para>Passed as <code>fd</code></para></td></tr><tr><td class="parameter_name"><para>condition</para></td><td class="parameter_description"><para>IO conditions to watch for on <parameter>fd</parameter></para><para>Passed as <code>condition</code></para></td></tr><tr><td class="parameter_name"><para>function</para></td><td class="parameter_description"><para>a <type>GUnixFDSourceFunc</type></para><para>Passed as <code>function</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>data to pass to <parameter>function</parameter></para><para>Passed as <code>user-data</code></para></td></tr><tr><td class="parameter_name"><para>notify</para></td><td class="parameter_description"><para>function to call when the idle is removed, or <constant>NULL</constant></para><para>Passed as <code>notify</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unix-fd-source-new</title><informalexample><programlisting>(define-values (%return) (unix-fd-source-new fd condition))
  8468. </programlisting></informalexample><para>Creates a <type>GSource</type> to watch for a particular IO condition on a file
  8469. descriptor.
  8470. </para>
  8471. <para>The source will never close the fd -- you must do it yourself.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>fd</para></td><td class="parameter_description"><para>a file descriptor</para><para>Passed as <code>fd</code></para></td></tr><tr><td class="parameter_name"><para>condition</para></td><td class="parameter_description"><para>IO conditions to watch for on <parameter>fd</parameter></para><para>Passed as <code>condition</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unix-get-passwd-entry</title><informalexample><programlisting>(define-values (%return) (unix-get-passwd-entry user-name))
  8472. </programlisting></informalexample><para>Get the <code>passwd</code> file entry for the given <parameter>user_name</parameter> using <code>getpwnam_r()</code>.
  8473. This can fail if the given <parameter>user_name</parameter> doesn’t exist.
  8474. </para>
  8475. <para>The returned <code>struct passwd</code> has been allocated using <function>g_malloc()</function> and should
  8476. be freed using <function>g_free()</function>. The strings referenced by the returned struct are
  8477. included in the same allocation, so are valid until the <code>struct passwd</code> is
  8478. freed.
  8479. </para>
  8480. <para>This function is safe to call from multiple threads concurrently.
  8481. </para>
  8482. <para>You will need to include <code>pwd.h</code> to get the definition of <code>struct passwd</code>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>user_name</para></td><td class="parameter_description"><para>the username to get the passwd file entry for</para><para>Passed as <code>user-name</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unix-open-pipe?</title><informalexample><programlisting>(define-values (%return) (unix-open-pipe? fds flags))
  8483. </programlisting></informalexample><para>Similar to the UNIX <function>pipe()</function> call, but on modern systems like Linux
  8484. uses the <function>pipe2()</function> system call, which atomically creates a pipe with
  8485. the configured flags. The only supported flag currently is
  8486. <constant>FD_CLOEXEC</constant>. If for example you want to configure <constant>O_NONBLOCK</constant>, that
  8487. must still be done separately with <function>fcntl()</function>.
  8488. </para>
  8489. <para>This function does not take <constant>O_CLOEXEC</constant>, it takes <constant>FD_CLOEXEC</constant> as if
  8490. for <function>fcntl()</function>; these are different on Linux/glibc.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>fds</para></td><td class="parameter_description"><para>Array of two integers</para><para>Passed as <code>fds</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>Bitfield of file descriptor flags, as for <function>fcntl()</function></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unix-set-fd-nonblocking?</title><informalexample><programlisting>(define-values (%return) (unix-set-fd-nonblocking? fd nonblock))
  8491. </programlisting></informalexample><para>Control the non-blocking state of the given file descriptor,
  8492. according to <parameter>nonblock</parameter>. On most systems this uses <constant>O_NONBLOCK</constant>, but
  8493. on some older ones may use <constant>O_NDELAY</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>fd</para></td><td class="parameter_description"><para>A file descriptor</para><para>Passed as <code>fd</code></para></td></tr><tr><td class="parameter_name"><para>nonblock</para></td><td class="parameter_description"><para>If <constant>TRUE</constant>, set the descriptor to be non-blocking</para><para>Passed as <code>nonblock</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unix-signal-add</title><informalexample><programlisting>(define-values
  8494. (%return)
  8495. (unix-signal-add priority signum handler user-data notify))
  8496. </programlisting></informalexample><para>A convenience function for <function>g_unix_signal_source_new()</function>, which
  8497. attaches to the default <type>GMainContext</type>. You can remove the watch
  8498. using <function>g_source_remove()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>notify</para></td><td class="parameter_description"><para></para><para>Passed as <code>notify</code></para></td></tr><tr><td class="parameter_name"><para>priority</para></td><td class="parameter_description"><para></para><para>Passed as <code>priority</code></para></td></tr><tr><td class="parameter_name"><para>signum</para></td><td class="parameter_description"><para>Signal number</para><para>Passed as <code>signum</code></para></td></tr><tr><td class="parameter_name"><para>handler</para></td><td class="parameter_description"><para>Callback</para><para>Passed as <code>handler</code></para></td></tr><tr><td class="parameter_name"><para>user_data</para></td><td class="parameter_description"><para>Data for <parameter>handler</parameter></para><para>Passed as <code>user-data</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unix-signal-source-new</title><informalexample><programlisting>(define-values (%return) (unix-signal-source-new signum))
  8499. </programlisting></informalexample><para>Create a <type>GSource</type> that will be dispatched upon delivery of the UNIX
  8500. signal <parameter>signum</parameter>. In GLib versions before 2.36, only <code>SIGHUP</code>, <code>SIGINT</code>,
  8501. <code>SIGTERM</code> can be monitored. In GLib 2.36, <code>SIGUSR1</code> and <code>SIGUSR2</code>
  8502. were added. In GLib 2.54, <code>SIGWINCH</code> was added.
  8503. </para>
  8504. <para>Note that unlike the UNIX default, all sources which have created a
  8505. watch will be dispatched, regardless of which underlying thread
  8506. invoked <function>g_unix_signal_source_new()</function>.
  8507. </para>
  8508. <para>For example, an effective use of this function is to handle <code>SIGTERM</code>
  8509. cleanly; flushing any outstanding files, and then calling
  8510. g_main_loop_quit (). It is not safe to do any of this a regular
  8511. UNIX signal handler; your handler may be invoked while <function>malloc()</function> or
  8512. another library function is running, causing reentrancy if you
  8513. attempt to use it from the handler. None of the GLib/GObject API
  8514. is safe against this kind of reentrancy.
  8515. </para>
  8516. <para>The interaction of this source when combined with native UNIX
  8517. functions like <function>sigprocmask()</function> is not defined.
  8518. </para>
  8519. <para>The source will not initially be associated with any <type>GMainContext</type>
  8520. and must be added to one with <function>g_source_attach()</function> before it will be
  8521. executed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>signum</para></td><td class="parameter_description"><para>A signal number</para><para>Passed as <code>signum</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unlink</title><informalexample><programlisting>(define-values (%return) (unlink filename))
  8522. </programlisting></informalexample><para>A wrapper for the POSIX <function>unlink()</function> function. The <function>unlink()</function> function
  8523. deletes a name from the filesystem. If this was the last link to the
  8524. file and no processes have it opened, the diskspace occupied by the
  8525. file is freed.
  8526. </para>
  8527. <para>See your C library manual for more details about <function>unlink()</function>. Note
  8528. that on Windows, it is in general not possible to delete files that
  8529. are open to some process, or mapped into memory.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>filename</para></td><td class="parameter_description"><para>a pathname in the GLib file name encoding
  8530. (UTF-8 on Windows)</para><para>Passed as <code>filename</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>unsetenv</title><informalexample><programlisting>(define-values () (unsetenv variable))
  8531. </programlisting></informalexample><para>Removes an environment variable from the environment.
  8532. </para>
  8533. <para>Note that on some systems, when variables are overwritten, the
  8534. memory used for the previous variables and its value isn't reclaimed.
  8535. </para>
  8536. <para>You should be mindful of the fact that environment variable handling
  8537. in UNIX is not thread-safe, and your program may crash if one thread
  8538. calls <function>g_unsetenv()</function> while another thread is calling <function>getenv()</function>. (And note
  8539. that many functions, such as <function>gettext()</function>, call <function>getenv()</function> internally.) This
  8540. function is only safe to use at the very start of your program, before
  8541. creating any other threads (or creating objects that create worker
  8542. threads of their own).
  8543. </para>
  8544. <para>If you need to set up the environment for a child process, you can
  8545. use <function>g_get_environ()</function> to get an environment array, modify that with
  8546. <function>g_environ_setenv()</function> and <function>g_environ_unsetenv()</function>, and then pass that
  8547. array directly to <function>execvpe()</function>, <function>g_spawn_async()</function>, or the like.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>variable</para></td><td class="parameter_description"><para>the environment variable to remove, must
  8548. not contain '='</para><para>Passed as <code>variable</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-build</title><informalexample><programlisting>(define-values
  8549. (%return)
  8550. (uri-build flags scheme userinfo host port path query fragment))
  8551. </programlisting></informalexample><para>Creates a new <type>GUri</type> from the given components according to <parameter>flags</parameter>.
  8552. </para>
  8553. <para>See also <function>g_uri_build_with_user()</function>, which allows specifying the
  8554. components of the &quot;userinfo&quot; separately.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to build the <type>GUri</type></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>the URI scheme</para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>userinfo</para></td><td class="parameter_description"><para>the userinfo component, or <constant>NULL</constant></para><para>Passed as <code>userinfo</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>the host component, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>the port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>the path component</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>the query component, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-build-with-user</title><informalexample><programlisting>(define-values
  8555. (%return)
  8556. (uri-build-with-user
  8557. flags
  8558. scheme
  8559. user
  8560. password
  8561. auth-params
  8562. host
  8563. port
  8564. path
  8565. query
  8566. fragment))
  8567. </programlisting></informalexample><para>Creates a new <type>GUri</type> from the given components according to <parameter>flags</parameter>
  8568. (<constant>G_URI_FLAGS_HAS_PASSWORD</constant> is added unconditionally). The <parameter>flags</parameter> must be
  8569. coherent with the passed values, in particular use <code>%</code>-encoded values with
  8570. <constant>G_URI_FLAGS_ENCODED</constant>.
  8571. </para>
  8572. <para>In contrast to <function>g_uri_build()</function>, this allows specifying the components
  8573. of the ‘userinfo’ field separately. Note that <parameter>user</parameter> must be non-<constant>NULL</constant>
  8574. if either <parameter>password</parameter> or <parameter>auth_params</parameter> is non-<constant>NULL</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to build the <type>GUri</type></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>the URI scheme</para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>user</para></td><td class="parameter_description"><para>the user component of the userinfo, or <constant>NULL</constant></para><para>Passed as <code>user</code></para></td></tr><tr><td class="parameter_name"><para>password</para></td><td class="parameter_description"><para>the password component of the userinfo, or <constant>NULL</constant></para><para>Passed as <code>password</code></para></td></tr><tr><td class="parameter_name"><para>auth_params</para></td><td class="parameter_description"><para>the auth params of the userinfo, or <constant>NULL</constant></para><para>Passed as <code>auth-params</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>the host component, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>the port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>the path component</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>the query component, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-error-quark</title><informalexample><programlisting>(define-values (%return) (uri-error-quark))
  8575. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>uri-escape-bytes</title><informalexample><programlisting>(define-values (%return) (uri-escape-bytes unescaped reserved-chars-allowed))
  8576. </programlisting></informalexample><para>Escapes arbitrary data for use in a URI.
  8577. </para>
  8578. <para>Normally all characters that are not ‘unreserved’ (i.e. ASCII
  8579. alphanumerical characters plus dash, dot, underscore and tilde) are
  8580. escaped. But if you specify characters in <parameter>reserved_chars_allowed</parameter>
  8581. they are not escaped. This is useful for the ‘reserved’ characters
  8582. in the URI specification, since those are allowed unescaped in some
  8583. portions of a URI.
  8584. </para>
  8585. <para>Though technically incorrect, this will also allow escaping nul
  8586. bytes as <code>%</code><code>00</code>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>unescaped</para></td><td class="parameter_description"><para>the unescaped input data.</para><para>Passed as <code>unescaped</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of <parameter>unescaped</parameter></para><para>Inferred from <code>unescaped</code></para></td></tr><tr><td class="parameter_name"><para>reserved_chars_allowed</para></td><td class="parameter_description"><para>a string of reserved
  8587. characters that are allowed to be used, or <constant>NULL</constant>.</para><para>Passed as <code>reserved-chars-allowed</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-escape-string</title><informalexample><programlisting>(define-values
  8588. (%return)
  8589. (uri-escape-string unescaped reserved-chars-allowed allow-utf8))
  8590. </programlisting></informalexample><para>Escapes a string for use in a URI.
  8591. </para>
  8592. <para>Normally all characters that are not &quot;unreserved&quot; (i.e. ASCII
  8593. alphanumerical characters plus dash, dot, underscore and tilde) are
  8594. escaped. But if you specify characters in <parameter>reserved_chars_allowed</parameter>
  8595. they are not escaped. This is useful for the &quot;reserved&quot; characters
  8596. in the URI specification, since those are allowed unescaped in some
  8597. portions of a URI.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>unescaped</para></td><td class="parameter_description"><para>the unescaped input string.</para><para>Passed as <code>unescaped</code></para></td></tr><tr><td class="parameter_name"><para>reserved_chars_allowed</para></td><td class="parameter_description"><para>a string of reserved
  8598. characters that are allowed to be used, or <constant>NULL</constant>.</para><para>Passed as <code>reserved-chars-allowed</code></para></td></tr><tr><td class="parameter_name"><para>allow_utf8</para></td><td class="parameter_description"><para><constant>TRUE</constant> if the result can include UTF-8 characters.</para><para>Passed as <code>allow-utf8</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-is-valid?</title><informalexample><programlisting>(define-values (%return) (uri-is-valid? uri-string flags))
  8599. </programlisting></informalexample><para>Parses <parameter>uri_string</parameter> according to <parameter>flags</parameter>, to determine whether it is a valid
  8600. [absolute URI][relative-absolute-uris], i.e. it does not need to be resolved
  8601. relative to another URI using <function>g_uri_parse_relative()</function>.
  8602. </para>
  8603. <para>If it’s not a valid URI, an error is returned explaining how it’s invalid.
  8604. </para>
  8605. <para>See <function>g_uri_split()</function>, and the definition of <type>GUriFlags</type>, for more
  8606. information on the effect of <parameter>flags</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_string</para></td><td class="parameter_description"><para>a string containing an absolute URI</para><para>Passed as <code>uri-string</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags for parsing <parameter>uri_string</parameter></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-join</title><informalexample><programlisting>(define-values
  8607. (%return)
  8608. (uri-join flags scheme userinfo host port path query fragment))
  8609. </programlisting></informalexample><para>Joins the given components together according to <parameter>flags</parameter> to create
  8610. an absolute URI string. <parameter>path</parameter> may not be <constant>NULL</constant> (though it may be the empty
  8611. string).
  8612. </para>
  8613. <para>When <parameter>host</parameter> is present, <parameter>path</parameter> must either be empty or begin with a slash (<code>/</code>)
  8614. character. When <parameter>host</parameter> is not present, <parameter>path</parameter> cannot begin with two slash
  8615. characters (<code>//</code>). See
  8616. [RFC 3986, section 3](https://tools.ietf.org/html/rfc3986#section-3).
  8617. </para>
  8618. <para>See also <function>g_uri_join_with_user()</function>, which allows specifying the
  8619. components of the ‘userinfo’ separately.
  8620. </para>
  8621. <para><constant>G_URI_FLAGS_HAS_PASSWORD</constant> and <constant>G_URI_FLAGS_HAS_AUTH_PARAMS</constant> are ignored if set
  8622. in <parameter>flags</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to build the URI string</para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>the URI scheme, or <constant>NULL</constant></para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>userinfo</para></td><td class="parameter_description"><para>the userinfo component, or <constant>NULL</constant></para><para>Passed as <code>userinfo</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>the host component, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>the port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>the path component</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>the query component, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-join-with-user</title><informalexample><programlisting>(define-values
  8623. (%return)
  8624. (uri-join-with-user
  8625. flags
  8626. scheme
  8627. user
  8628. password
  8629. auth-params
  8630. host
  8631. port
  8632. path
  8633. query
  8634. fragment))
  8635. </programlisting></informalexample><para>Joins the given components together according to <parameter>flags</parameter> to create
  8636. an absolute URI string. <parameter>path</parameter> may not be <constant>NULL</constant> (though it may be the empty
  8637. string).
  8638. </para>
  8639. <para>In contrast to <function>g_uri_join()</function>, this allows specifying the components
  8640. of the ‘userinfo’ separately. It otherwise behaves the same.
  8641. </para>
  8642. <para><constant>G_URI_FLAGS_HAS_PASSWORD</constant> and <constant>G_URI_FLAGS_HAS_AUTH_PARAMS</constant> are ignored if set
  8643. in <parameter>flags</parameter>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to build the URI string</para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>the URI scheme, or <constant>NULL</constant></para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>user</para></td><td class="parameter_description"><para>the user component of the userinfo, or <constant>NULL</constant></para><para>Passed as <code>user</code></para></td></tr><tr><td class="parameter_name"><para>password</para></td><td class="parameter_description"><para>the password component of the userinfo, or
  8644. <constant>NULL</constant></para><para>Passed as <code>password</code></para></td></tr><tr><td class="parameter_name"><para>auth_params</para></td><td class="parameter_description"><para>the auth params of the userinfo, or
  8645. <constant>NULL</constant></para><para>Passed as <code>auth-params</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>the host component, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>the port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>the path component</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>the query component, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-list-extract-uris</title><informalexample><programlisting>(define-values (%return) (uri-list-extract-uris uri-list))
  8646. </programlisting></informalexample><para>Splits an URI list conforming to the text/uri-list
  8647. mime type defined in RFC 2483 into individual URIs,
  8648. discarding any comments. The URIs are not validated.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_list</para></td><td class="parameter_description"><para>an URI list</para><para>Passed as <code>uri-list</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-parse</title><informalexample><programlisting>(define-values (%return) (uri-parse uri-string flags))
  8649. </programlisting></informalexample><para>Parses <parameter>uri_string</parameter> according to <parameter>flags</parameter>. If the result is not a
  8650. valid [absolute URI][relative-absolute-uris], it will be discarded, and an
  8651. error returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_string</para></td><td class="parameter_description"><para>a string representing an absolute URI</para><para>Passed as <code>uri-string</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to parse <parameter>uri_string</parameter></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-parse-params</title><informalexample><programlisting>(define-values (%return) (uri-parse-params params length separators flags))
  8652. </programlisting></informalexample><para>Many URI schemes include one or more attribute/value pairs as part of the URI
  8653. value. This method can be used to parse them into a hash table. When an
  8654. attribute has multiple occurrences, the last value is the final returned
  8655. value. If you need to handle repeated attributes differently, use
  8656. <type>GUriParamsIter</type>.
  8657. </para>
  8658. <para>The <parameter>params</parameter> string is assumed to still be <code>%</code>-encoded, but the returned
  8659. values will be fully decoded. (Thus it is possible that the returned values
  8660. may contain <code>=</code> or <parameter>separators</parameter>, if the value was encoded in the input.)
  8661. Invalid <code>%</code>-encoding is treated as with the <constant>G_URI_FLAGS_PARSE_RELAXED</constant>
  8662. rules for <function>g_uri_parse()</function>. (However, if <parameter>params</parameter> is the path or query string
  8663. from a <type>GUri</type> that was parsed without <constant>G_URI_FLAGS_PARSE_RELAXED</constant> and
  8664. <constant>G_URI_FLAGS_ENCODED</constant>, then you already know that it does not contain any
  8665. invalid encoding.)
  8666. </para>
  8667. <para><constant>G_URI_PARAMS_WWW_FORM</constant> is handled as documented for <function>g_uri_params_iter_init()</function>.
  8668. </para>
  8669. <para>If <constant>G_URI_PARAMS_CASE_INSENSITIVE</constant> is passed to <parameter>flags</parameter>, attributes will be
  8670. compared case-insensitively, so a params string <code>attr=123&amp;Attr=456</code> will only
  8671. return a single attribute–value pair, <code>Attr=456</code>. Case will be preserved in
  8672. the returned attributes.
  8673. </para>
  8674. <para>If <parameter>params</parameter> cannot be parsed (for example, it contains two <parameter>separators</parameter>
  8675. characters in a row), then <parameter>error</parameter> is set and <constant>NULL</constant> is returned.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>params</para></td><td class="parameter_description"><para>a <code>%</code>-encoded string containing <code>attribute=value</code>
  8676. parameters</para><para>Passed as <code>params</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length of <parameter>params</parameter>, or <code>-1</code> if it is nul-terminated</para><para>Passed as <code>length</code></para></td></tr><tr><td class="parameter_name"><para>separators</para></td><td class="parameter_description"><para>the separator byte character set between parameters. (usually
  8677. <code>&amp;</code>, but sometimes <code>;</code> or both <code>&amp;;</code>). Note that this function works on
  8678. bytes not characters, so it can't be used to delimit UTF-8 strings for
  8679. anything but ASCII characters. You may pass an empty set, in which case
  8680. no splitting will occur.</para><para>Passed as <code>separators</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags to modify the way the parameters are handled.</para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-parse-scheme</title><informalexample><programlisting>(define-values (%return) (uri-parse-scheme uri))
  8681. </programlisting></informalexample><para>Gets the scheme portion of a URI string.
  8682. [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3) decodes the scheme
  8683. as:
  8684. <informalexample><programlisting>
  8685. URI = scheme &quot;:&quot; hier-part [ &quot;?&quot; query ] [ &quot;#&quot; fragment ]
  8686. </programlisting></informalexample></para>
  8687. <para>Common schemes include <code>file</code>, <code>https</code>, <code>svn+ssh</code>, etc.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a valid URI.</para><para>Passed as <code>uri</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-peek-scheme</title><informalexample><programlisting>(define-values (%return) (uri-peek-scheme uri))
  8688. </programlisting></informalexample><para>Gets the scheme portion of a URI string.
  8689. [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3) decodes the scheme
  8690. as:
  8691. <informalexample><programlisting>
  8692. URI = scheme &quot;:&quot; hier-part [ &quot;?&quot; query ] [ &quot;#&quot; fragment ]
  8693. </programlisting></informalexample></para>
  8694. <para>Common schemes include <code>file</code>, <code>https</code>, <code>svn+ssh</code>, etc.
  8695. </para>
  8696. <para>Unlike <function>g_uri_parse_scheme()</function>, the returned scheme is normalized to
  8697. all-lowercase and does not need to be freed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri</para></td><td class="parameter_description"><para>a valid URI.</para><para>Passed as <code>uri</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-resolve-relative</title><informalexample><programlisting>(define-values (%return) (uri-resolve-relative base-uri-string uri-ref flags))
  8698. </programlisting></informalexample><para>Parses <parameter>uri_ref</parameter> according to <parameter>flags</parameter> and, if it is a
  8699. [relative URI][relative-absolute-uris], resolves it relative to
  8700. <parameter>base_uri_string</parameter>. If the result is not a valid absolute URI, it will be
  8701. discarded, and an error returned.
  8702. </para>
  8703. <para>(If <parameter>base_uri_string</parameter> is <constant>NULL</constant>, this just returns <parameter>uri_ref</parameter>, or
  8704. <constant>NULL</constant> if <parameter>uri_ref</parameter> is invalid or not absolute.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>base_uri_string</para></td><td class="parameter_description"><para>a string representing a base URI</para><para>Passed as <code>base-uri-string</code></para></td></tr><tr><td class="parameter_name"><para>uri_ref</para></td><td class="parameter_description"><para>a string representing a relative or absolute URI</para><para>Passed as <code>uri-ref</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags describing how to parse <parameter>uri_ref</parameter></para><para>Passed as <code>flags</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-split</title><informalexample><programlisting>(define-values
  8705. (%return scheme userinfo host port path query fragment)
  8706. (uri-split uri-ref flags))
  8707. </programlisting></informalexample><para>Parses <parameter>uri_ref</parameter> (which can be an
  8708. [absolute or relative URI][relative-absolute-uris]) according to <parameter>flags</parameter>, and
  8709. returns the pieces. Any component that doesn't appear in <parameter>uri_ref</parameter> will be
  8710. returned as <constant>NULL</constant> (but note that all URIs always have a path component,
  8711. though it may be the empty string).
  8712. </para>
  8713. <para>If <parameter>flags</parameter> contains <constant>G_URI_FLAGS_ENCODED</constant>, then <code>%</code>-encoded characters in
  8714. <parameter>uri_ref</parameter> will remain encoded in the output strings. (If not,
  8715. then all such characters will be decoded.) Note that decoding will
  8716. only work if the URI components are ASCII or UTF-8, so you will
  8717. need to use <constant>G_URI_FLAGS_ENCODED</constant> if they are not.
  8718. </para>
  8719. <para>Note that the <constant>G_URI_FLAGS_HAS_PASSWORD</constant> and
  8720. <constant>G_URI_FLAGS_HAS_AUTH_PARAMS</constant> <parameter>flags</parameter> are ignored by <function>g_uri_split()</function>,
  8721. since it always returns only the full userinfo; use
  8722. <function>g_uri_split_with_user()</function> if you want it split up.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_ref</para></td><td class="parameter_description"><para>a string containing a relative or absolute URI</para><para>Passed as <code>uri-ref</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags for parsing <parameter>uri_ref</parameter></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>on return, contains
  8723. the scheme (converted to lowercase), or <constant>NULL</constant></para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>userinfo</para></td><td class="parameter_description"><para>on return, contains
  8724. the userinfo, or <constant>NULL</constant></para><para>Passed as <code>userinfo</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>on return, contains the
  8725. host, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>on return, contains the
  8726. port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>on return, contains the
  8727. path</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>on return, contains the
  8728. query, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>on return, contains
  8729. the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-split-network</title><informalexample><programlisting>(define-values
  8730. (%return scheme host port)
  8731. (uri-split-network uri-string flags))
  8732. </programlisting></informalexample><para>Parses <parameter>uri_string</parameter> (which must be an [absolute URI][relative-absolute-uris])
  8733. according to <parameter>flags</parameter>, and returns the pieces relevant to connecting to a host.
  8734. See the documentation for <function>g_uri_split()</function> for more details; this is
  8735. mostly a wrapper around that function with simpler arguments.
  8736. However, it will return an error if <parameter>uri_string</parameter> is a relative URI,
  8737. or does not contain a hostname component.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_string</para></td><td class="parameter_description"><para>a string containing an absolute URI</para><para>Passed as <code>uri-string</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags for parsing <parameter>uri_string</parameter></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>on return, contains
  8738. the scheme (converted to lowercase), or <constant>NULL</constant></para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>on return, contains the
  8739. host, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>on return, contains the
  8740. port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-split-with-user</title><informalexample><programlisting>(define-values
  8741. (%return scheme user password auth-params host port path query fragment)
  8742. (uri-split-with-user uri-ref flags))
  8743. </programlisting></informalexample><para>Parses <parameter>uri_ref</parameter> (which can be an
  8744. [absolute or relative URI][relative-absolute-uris]) according to <parameter>flags</parameter>, and
  8745. returns the pieces. Any component that doesn't appear in <parameter>uri_ref</parameter> will be
  8746. returned as <constant>NULL</constant> (but note that all URIs always have a path component,
  8747. though it may be the empty string).
  8748. </para>
  8749. <para>See <function>g_uri_split()</function>, and the definition of <type>GUriFlags</type>, for more
  8750. information on the effect of <parameter>flags</parameter>. Note that <parameter>password</parameter> will only
  8751. be parsed out if <parameter>flags</parameter> contains <constant>G_URI_FLAGS_HAS_PASSWORD</constant>, and
  8752. <parameter>auth_params</parameter> will only be parsed out if <parameter>flags</parameter> contains
  8753. <constant>G_URI_FLAGS_HAS_AUTH_PARAMS</constant>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>uri_ref</para></td><td class="parameter_description"><para>a string containing a relative or absolute URI</para><para>Passed as <code>uri-ref</code></para></td></tr><tr><td class="parameter_name"><para>flags</para></td><td class="parameter_description"><para>flags for parsing <parameter>uri_ref</parameter></para><para>Passed as <code>flags</code></para></td></tr><tr><td class="parameter_name"><para>scheme</para></td><td class="parameter_description"><para>on return, contains
  8754. the scheme (converted to lowercase), or <constant>NULL</constant></para><para>Passed as <code>scheme</code></para></td></tr><tr><td class="parameter_name"><para>user</para></td><td class="parameter_description"><para>on return, contains
  8755. the user, or <constant>NULL</constant></para><para>Passed as <code>user</code></para></td></tr><tr><td class="parameter_name"><para>password</para></td><td class="parameter_description"><para>on return, contains
  8756. the password, or <constant>NULL</constant></para><para>Passed as <code>password</code></para></td></tr><tr><td class="parameter_name"><para>auth_params</para></td><td class="parameter_description"><para>on return, contains
  8757. the auth_params, or <constant>NULL</constant></para><para>Passed as <code>auth-params</code></para></td></tr><tr><td class="parameter_name"><para>host</para></td><td class="parameter_description"><para>on return, contains the
  8758. host, or <constant>NULL</constant></para><para>Passed as <code>host</code></para></td></tr><tr><td class="parameter_name"><para>port</para></td><td class="parameter_description"><para>on return, contains the
  8759. port, or <code>-1</code></para><para>Passed as <code>port</code></para></td></tr><tr><td class="parameter_name"><para>path</para></td><td class="parameter_description"><para>on return, contains the
  8760. path</para><para>Passed as <code>path</code></para></td></tr><tr><td class="parameter_name"><para>query</para></td><td class="parameter_description"><para>on return, contains the
  8761. query, or <constant>NULL</constant></para><para>Passed as <code>query</code></para></td></tr><tr><td class="parameter_name"><para>fragment</para></td><td class="parameter_description"><para>on return, contains
  8762. the fragment, or <constant>NULL</constant></para><para>Passed as <code>fragment</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-unescape-bytes</title><informalexample><programlisting>(define-values
  8763. (%return)
  8764. (uri-unescape-bytes escaped-string length illegal-characters))
  8765. </programlisting></informalexample><para>Unescapes a segment of an escaped string as binary data.
  8766. </para>
  8767. <para>Note that in contrast to <function>g_uri_unescape_string()</function>, this does allow
  8768. nul bytes to appear in the output.
  8769. </para>
  8770. <para>If any of the characters in <parameter>illegal_characters</parameter> appears as an escaped
  8771. character in <parameter>escaped_string</parameter>, then that is an error and <constant>NULL</constant> will be
  8772. returned. This is useful if you want to avoid for instance having a slash
  8773. being expanded in an escaped path element, which might confuse pathname
  8774. handling.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>escaped_string</para></td><td class="parameter_description"><para>A URI-escaped string</para><para>Passed as <code>escaped-string</code></para></td></tr><tr><td class="parameter_name"><para>length</para></td><td class="parameter_description"><para>the length (in bytes) of <parameter>escaped_string</parameter> to escape, or <code>-1</code> if it
  8775. is nul-terminated.</para><para>Passed as <code>length</code></para></td></tr><tr><td class="parameter_name"><para>illegal_characters</para></td><td class="parameter_description"><para>a string of illegal characters
  8776. not to be allowed, or <constant>NULL</constant>.</para><para>Passed as <code>illegal-characters</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-unescape-segment</title><informalexample><programlisting>(define-values
  8777. (%return)
  8778. (uri-unescape-segment escaped-string escaped-string-end illegal-characters))
  8779. </programlisting></informalexample><para>Unescapes a segment of an escaped string.
  8780. </para>
  8781. <para>If any of the characters in <parameter>illegal_characters</parameter> or the NUL
  8782. character appears as an escaped character in <parameter>escaped_string</parameter>, then
  8783. that is an error and <constant>NULL</constant> will be returned. This is useful if you
  8784. want to avoid for instance having a slash being expanded in an
  8785. escaped path element, which might confuse pathname handling.
  8786. </para>
  8787. <para>Note: <code>NUL</code> byte is not accepted in the output, in contrast to
  8788. <function>g_uri_unescape_bytes()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>escaped_string</para></td><td class="parameter_description"><para>A string, may be <constant>NULL</constant></para><para>Passed as <code>escaped-string</code></para></td></tr><tr><td class="parameter_name"><para>escaped_string_end</para></td><td class="parameter_description"><para>Pointer to end of <parameter>escaped_string</parameter>,
  8789. may be <constant>NULL</constant></para><para>Passed as <code>escaped-string-end</code></para></td></tr><tr><td class="parameter_name"><para>illegal_characters</para></td><td class="parameter_description"><para>An optional string of illegal
  8790. characters not to be allowed, may be <constant>NULL</constant></para><para>Passed as <code>illegal-characters</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uri-unescape-string</title><informalexample><programlisting>(define-values
  8791. (%return)
  8792. (uri-unescape-string escaped-string illegal-characters))
  8793. </programlisting></informalexample><para>Unescapes a whole escaped string.
  8794. </para>
  8795. <para>If any of the characters in <parameter>illegal_characters</parameter> or the NUL
  8796. character appears as an escaped character in <parameter>escaped_string</parameter>, then
  8797. that is an error and <constant>NULL</constant> will be returned. This is useful if you
  8798. want to avoid for instance having a slash being expanded in an
  8799. escaped path element, which might confuse pathname handling.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>escaped_string</para></td><td class="parameter_description"><para>an escaped string to be unescaped.</para><para>Passed as <code>escaped-string</code></para></td></tr><tr><td class="parameter_name"><para>illegal_characters</para></td><td class="parameter_description"><para>a string of illegal characters
  8800. not to be allowed, or <constant>NULL</constant>.</para><para>Passed as <code>illegal-characters</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>usleep</title><informalexample><programlisting>(define-values () (usleep microseconds))
  8801. </programlisting></informalexample><para>Pauses the current thread for the given number of microseconds.
  8802. </para>
  8803. <para>There are 1 million microseconds per second (represented by the
  8804. <type>G_USEC_PER_SEC</type> macro). <function>g_usleep()</function> may have limited precision,
  8805. depending on hardware and operating system; don't rely on the exact
  8806. length of the sleep.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>microseconds</para></td><td class="parameter_description"><para>number of microseconds to pause</para><para>Passed as <code>microseconds</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf16-to-ucs4</title><informalexample><programlisting>(define-values
  8807. (%return items-read items-written)
  8808. (utf16-to-ucs4 str len items-read items-written))
  8809. </programlisting></informalexample><para>Convert a string from UTF-16 to UCS-4. The result will be
  8810. nul-terminated.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-16 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length (number of <type>gunichar2</type>) of <parameter>str</parameter> to use.
  8811. If <parameter>len</parameter> &lt; 0, then the string is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>items_read</para></td><td class="parameter_description"><para>location to store number of
  8812. words read, or <constant>NULL</constant>. If <constant>NULL</constant>, then <constant>G_CONVERT_ERROR_PARTIAL_INPUT</constant> will
  8813. be returned in case <parameter>str</parameter> contains a trailing partial character. If
  8814. an error occurs then the index of the invalid input is stored here.</para><para>Passed as <code>items-read</code></para></td></tr><tr><td class="parameter_name"><para>items_written</para></td><td class="parameter_description"><para>location to store number
  8815. of characters written, or <constant>NULL</constant>. The value stored here does not include
  8816. the trailing 0 character.</para><para>Passed as <code>items-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf16-to-utf8</title><informalexample><programlisting>(define-values
  8817. (%return items-read items-written)
  8818. (utf16-to-utf8 str len items-read items-written))
  8819. </programlisting></informalexample><para>Convert a string from UTF-16 to UTF-8. The result will be
  8820. terminated with a 0 byte.
  8821. </para>
  8822. <para>Note that the input is expected to be already in native endianness,
  8823. an initial byte-order-mark character is not handled specially.
  8824. <function>g_convert()</function> can be used to convert a byte buffer of UTF-16 data of
  8825. ambiguous endianness.
  8826. </para>
  8827. <para>Further note that this function does not validate the result
  8828. string; it may e.g. include embedded NUL characters. The only
  8829. validation done by this function is to ensure that the input can
  8830. be correctly interpreted as UTF-16, i.e. it doesn't contain
  8831. unpaired surrogates or partial character sequences.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-16 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length (number of <type>gunichar2</type>) of <parameter>str</parameter> to use.
  8832. If <parameter>len</parameter> &lt; 0, then the string is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>items_read</para></td><td class="parameter_description"><para>location to store number of
  8833. words read, or <constant>NULL</constant>. If <constant>NULL</constant>, then <constant>G_CONVERT_ERROR_PARTIAL_INPUT</constant> will
  8834. be returned in case <parameter>str</parameter> contains a trailing partial character. If
  8835. an error occurs then the index of the invalid input is stored here.</para><para>Passed as <code>items-read</code></para></td></tr><tr><td class="parameter_name"><para>items_written</para></td><td class="parameter_description"><para>location to store number
  8836. of bytes written, or <constant>NULL</constant>. The value stored here does not include the
  8837. trailing 0 byte.</para><para>Passed as <code>items-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-casefold</title><informalexample><programlisting>(define-values (%return) (utf8-casefold str len))
  8838. </programlisting></informalexample><para>Converts a string into a form that is independent of case. The
  8839. result will not correspond to any particular case, but can be
  8840. compared for equality or ordered with the results of calling
  8841. <function>g_utf8_casefold()</function> on other strings.
  8842. </para>
  8843. <para>Note that calling <function>g_utf8_casefold()</function> followed by <function>g_utf8_collate()</function> is
  8844. only an approximation to the correct linguistic case insensitive
  8845. ordering, though it is a fairly good one. Getting this exactly
  8846. right would require a more sophisticated collation function that
  8847. takes case sensitivity into account. GLib does not currently
  8848. provide such a function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>str</parameter>, in bytes, or -1 if <parameter>str</parameter> is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-collate</title><informalexample><programlisting>(define-values (%return) (utf8-collate str1 str2))
  8849. </programlisting></informalexample><para>Compares two strings for ordering using the linguistically
  8850. correct rules for the [current locale][setlocale].
  8851. When sorting a large number of strings, it will be significantly
  8852. faster to obtain collation keys with <function>g_utf8_collate_key()</function> and
  8853. compare the keys with <function>strcmp()</function> when sorting instead of sorting
  8854. the original strings.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str1</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str1</code></para></td></tr><tr><td class="parameter_name"><para>str2</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str2</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-collate-key</title><informalexample><programlisting>(define-values (%return) (utf8-collate-key str len))
  8855. </programlisting></informalexample><para>Converts a string into a collation key that can be compared
  8856. with other collation keys produced by the same function using
  8857. <function>strcmp()</function>.
  8858. </para>
  8859. <para>The results of comparing the collation keys of two strings
  8860. with <function>strcmp()</function> will always be the same as comparing the two
  8861. original keys with <function>g_utf8_collate()</function>.
  8862. </para>
  8863. <para>Note that this function depends on the [current locale][setlocale].</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string.</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>str</parameter>, in bytes, or -1 if <parameter>str</parameter> is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-collate-key-for-filename</title><informalexample><programlisting>(define-values (%return) (utf8-collate-key-for-filename str len))
  8864. </programlisting></informalexample><para>Converts a string into a collation key that can be compared
  8865. with other collation keys produced by the same function using <function>strcmp()</function>.
  8866. </para>
  8867. <para>In order to sort filenames correctly, this function treats the dot '.'
  8868. as a special case. Most dictionary orderings seem to consider it
  8869. insignificant, thus producing the ordering &quot;event.c&quot; &quot;eventgenerator.c&quot;
  8870. &quot;event.h&quot; instead of &quot;event.c&quot; &quot;event.h&quot; &quot;eventgenerator.c&quot;. Also, we
  8871. would like to treat numbers intelligently so that &quot;file1&quot; &quot;file10&quot; &quot;file5&quot;
  8872. is sorted as &quot;file1&quot; &quot;file5&quot; &quot;file10&quot;.
  8873. </para>
  8874. <para>Note that this function depends on the [current locale][setlocale].</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string.</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>str</parameter>, in bytes, or -1 if <parameter>str</parameter> is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-find-next-char</title><informalexample><programlisting>(define-values (%return) (utf8-find-next-char p end))
  8875. </programlisting></informalexample><para>Finds the start of the next UTF-8 character in the string after <parameter>p</parameter>.
  8876. </para>
  8877. <para><parameter>p</parameter> does not have to be at the beginning of a UTF-8 character. No check
  8878. is made to see if the character found is actually valid other than
  8879. it starts with an appropriate byte.
  8880. </para>
  8881. <para>If <parameter>end</parameter> is <constant>NULL</constant>, the return value will never be <constant>NULL</constant>: if the end of the
  8882. string is reached, a pointer to the terminating nul byte is returned. If
  8883. <parameter>end</parameter> is non-<constant>NULL</constant>, the return value will be <constant>NULL</constant> if the end of the string
  8884. is reached.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>p</para></td><td class="parameter_description"><para>a pointer to a position within a UTF-8 encoded string</para><para>Passed as <code>p</code></para></td></tr><tr><td class="parameter_name"><para>end</para></td><td class="parameter_description"><para>a pointer to the byte following the end of the string,
  8885. or <constant>NULL</constant> to indicate that the string is nul-terminated</para><para>Passed as <code>end</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-find-prev-char</title><informalexample><programlisting>(define-values (%return) (utf8-find-prev-char str p))
  8886. </programlisting></informalexample><para>Given a position <parameter>p</parameter> with a UTF-8 encoded string <parameter>str</parameter>, find the start
  8887. of the previous UTF-8 character starting before <parameter>p</parameter>. Returns <constant>NULL</constant> if no
  8888. UTF-8 characters are present in <parameter>str</parameter> before <parameter>p</parameter>.
  8889. </para>
  8890. <para><parameter>p</parameter> does not have to be at the beginning of a UTF-8 character. No check
  8891. is made to see if the character found is actually valid other than
  8892. it starts with an appropriate byte.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>pointer to the beginning of a UTF-8 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>p</para></td><td class="parameter_description"><para>pointer to some position within <parameter>str</parameter></para><para>Passed as <code>p</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-get-char</title><informalexample><programlisting>(define-values (%return) (utf8-get-char p))
  8893. </programlisting></informalexample><para>Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
  8894. </para>
  8895. <para>If <parameter>p</parameter> does not point to a valid UTF-8 encoded character, results
  8896. are undefined. If you are not sure that the bytes are complete
  8897. valid Unicode characters, you should use <function>g_utf8_get_char_validated()</function>
  8898. instead.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>p</para></td><td class="parameter_description"><para>a pointer to Unicode character encoded as UTF-8</para><para>Passed as <code>p</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-get-char-validated</title><informalexample><programlisting>(define-values (%return) (utf8-get-char-validated p max-len))
  8899. </programlisting></informalexample><para>Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
  8900. This function checks for incomplete characters, for invalid characters
  8901. such as characters that are out of the range of Unicode, and for
  8902. overlong encodings of valid characters.
  8903. </para>
  8904. <para>Note that <function>g_utf8_get_char_validated()</function> returns (gunichar)-2 if
  8905. <parameter>max_len</parameter> is positive and any of the bytes in the first UTF-8 character
  8906. sequence are nul.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>p</para></td><td class="parameter_description"><para>a pointer to Unicode character encoded as UTF-8</para><para>Passed as <code>p</code></para></td></tr><tr><td class="parameter_name"><para>max_len</para></td><td class="parameter_description"><para>the maximum number of bytes to read, or -1 if <parameter>p</parameter> is nul-terminated</para><para>Passed as <code>max-len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-make-valid</title><informalexample><programlisting>(define-values (%return) (utf8-make-valid str len))
  8907. </programlisting></informalexample><para>If the provided string is valid UTF-8, return a copy of it. If not,
  8908. return a copy in which bytes that could not be interpreted as valid Unicode
  8909. are replaced with the Unicode replacement character (U+FFFD).
  8910. </para>
  8911. <para>For example, this is an appropriate function to use if you have received
  8912. a string that was incorrectly declared to be UTF-8, and you need a valid
  8913. UTF-8 version of it that can be logged or displayed to the user, with the
  8914. assumption that it is close enough to ASCII or UTF-8 to be mostly
  8915. readable as-is.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>string to coerce into UTF-8</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length of <parameter>str</parameter> to use, in bytes. If <parameter>len</parameter> &lt; 0,
  8916. then the string is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-normalize</title><informalexample><programlisting>(define-values (%return) (utf8-normalize str len mode))
  8917. </programlisting></informalexample><para>Converts a string into canonical form, standardizing
  8918. such issues as whether a character with an accent
  8919. is represented as a base character and combining
  8920. accent or as a single precomposed character. The
  8921. string has to be valid UTF-8, otherwise <constant>NULL</constant> is
  8922. returned. You should generally call <function>g_utf8_normalize()</function>
  8923. before comparing two Unicode strings.
  8924. </para>
  8925. <para>The normalization mode <constant>G_NORMALIZE_DEFAULT</constant> only
  8926. standardizes differences that do not affect the
  8927. text content, such as the above-mentioned accent
  8928. representation. <constant>G_NORMALIZE_ALL</constant> also standardizes
  8929. the &quot;compatibility&quot; characters in Unicode, such
  8930. as SUPERSCRIPT THREE to the standard forms
  8931. (in this case DIGIT THREE). Formatting information
  8932. may be lost but for most text operations such
  8933. characters should be considered the same.
  8934. </para>
  8935. <para><constant>G_NORMALIZE_DEFAULT_COMPOSE</constant> and <constant>G_NORMALIZE_ALL_COMPOSE</constant>
  8936. are like <constant>G_NORMALIZE_DEFAULT</constant> and <constant>G_NORMALIZE_ALL</constant>,
  8937. but returned a result with composed forms rather
  8938. than a maximally decomposed form. This is often
  8939. useful if you intend to convert the string to
  8940. a legacy encoding or pass it to a system with
  8941. less capable Unicode handling.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string.</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>str</parameter>, in bytes, or -1 if <parameter>str</parameter> is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>mode</para></td><td class="parameter_description"><para>the type of normalization to perform.</para><para>Passed as <code>mode</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-offset-to-pointer</title><informalexample><programlisting>(define-values (%return) (utf8-offset-to-pointer str offset))
  8942. </programlisting></informalexample><para>Converts from an integer character offset to a pointer to a position
  8943. within the string.
  8944. </para>
  8945. <para>Since 2.10, this function allows to pass a negative <parameter>offset</parameter> to
  8946. step backwards. It is usually worth stepping backwards from the end
  8947. instead of forwards if <parameter>offset</parameter> is in the last fourth of the string,
  8948. since moving forward is about 3 times faster than moving backward.
  8949. </para>
  8950. <para>Note that this function doesn't abort when reaching the end of <parameter>str</parameter>.
  8951. Therefore you should be sure that <parameter>offset</parameter> is within string boundaries
  8952. before calling that function. Call <function>g_utf8_strlen()</function> when unsure.
  8953. This limitation exists as this function is called frequently during
  8954. text rendering and therefore has to be as fast as possible.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>offset</para></td><td class="parameter_description"><para>a character offset within <parameter>str</parameter></para><para>Passed as <code>offset</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-pointer-to-offset</title><informalexample><programlisting>(define-values (%return) (utf8-pointer-to-offset str pos))
  8955. </programlisting></informalexample><para>Converts from a pointer to position within a string to an integer
  8956. character offset.
  8957. </para>
  8958. <para>Since 2.10, this function allows <parameter>pos</parameter> to be before <parameter>str</parameter>, and returns
  8959. a negative offset in this case.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>pos</para></td><td class="parameter_description"><para>a pointer to a position within <parameter>str</parameter></para><para>Passed as <code>pos</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-prev-char</title><informalexample><programlisting>(define-values (%return) (utf8-prev-char p))
  8960. </programlisting></informalexample><para>Finds the previous UTF-8 character in the string before <parameter>p</parameter>.
  8961. </para>
  8962. <para><parameter>p</parameter> does not have to be at the beginning of a UTF-8 character. No check
  8963. is made to see if the character found is actually valid other than
  8964. it starts with an appropriate byte. If <parameter>p</parameter> might be the first
  8965. character of the string, you must use <function>g_utf8_find_prev_char()</function> instead.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>p</para></td><td class="parameter_description"><para>a pointer to a position within a UTF-8 encoded string</para><para>Passed as <code>p</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-strchr</title><informalexample><programlisting>(define-values (%return) (utf8-strchr p len c))
  8966. </programlisting></informalexample><para>Finds the leftmost occurrence of the given Unicode character
  8967. in a UTF-8 encoded string, while limiting the search to <parameter>len</parameter> bytes.
  8968. If <parameter>len</parameter> is -1, allow unbounded search.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>p</para></td><td class="parameter_description"><para>a nul-terminated UTF-8 encoded string</para><para>Passed as <code>p</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length of <parameter>p</parameter></para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-strdown</title><informalexample><programlisting>(define-values (%return) (utf8-strdown str len))
  8969. </programlisting></informalexample><para>Converts all Unicode characters in the string that have a case
  8970. to lowercase. The exact manner that this is done depends
  8971. on the current locale, and may result in the number of
  8972. characters in the string changing.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>str</parameter>, in bytes, or -1 if <parameter>str</parameter> is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-strlen</title><informalexample><programlisting>(define-values (%return) (utf8-strlen p max))
  8973. </programlisting></informalexample><para>Computes the length of the string in characters, not including
  8974. the terminating nul character. If the <parameter>max</parameter>'th byte falls in the
  8975. middle of a character, the last (partial) character is not counted.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>p</para></td><td class="parameter_description"><para>pointer to the start of a UTF-8 encoded string</para><para>Passed as <code>p</code></para></td></tr><tr><td class="parameter_name"><para>max</para></td><td class="parameter_description"><para>the maximum number of bytes to examine. If <parameter>max</parameter>
  8976. is less than 0, then the string is assumed to be
  8977. nul-terminated. If <parameter>max</parameter> is 0, <parameter>p</parameter> will not be examined and
  8978. may be <constant>NULL</constant>. If <parameter>max</parameter> is greater than 0, up to <parameter>max</parameter>
  8979. bytes are examined</para><para>Passed as <code>max</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-strncpy</title><informalexample><programlisting>(define-values (%return) (utf8-strncpy dest src n))
  8980. </programlisting></informalexample><para>Like the standard C <function>strncpy()</function> function, but copies a given number
  8981. of characters instead of a given number of bytes. The <parameter>src</parameter> string
  8982. must be valid UTF-8 encoded text. (Use <function>g_utf8_validate()</function> on all
  8983. text before trying to use UTF-8 utility functions with it.)
  8984. </para>
  8985. <para>Note you must ensure <parameter>dest</parameter> is at least 4 * <parameter>n</parameter> to fit the
  8986. largest possible UTF-8 characters</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>dest</para></td><td class="parameter_description"><para>buffer to fill with characters from <parameter>src</parameter></para><para>Passed as <code>dest</code></para></td></tr><tr><td class="parameter_name"><para>src</para></td><td class="parameter_description"><para>UTF-8 encoded string</para><para>Passed as <code>src</code></para></td></tr><tr><td class="parameter_name"><para>n</para></td><td class="parameter_description"><para>character count</para><para>Passed as <code>n</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-strrchr</title><informalexample><programlisting>(define-values (%return) (utf8-strrchr p len c))
  8987. </programlisting></informalexample><para>Find the rightmost occurrence of the given Unicode character
  8988. in a UTF-8 encoded string, while limiting the search to <parameter>len</parameter> bytes.
  8989. If <parameter>len</parameter> is -1, allow unbounded search.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>p</para></td><td class="parameter_description"><para>a nul-terminated UTF-8 encoded string</para><para>Passed as <code>p</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length of <parameter>p</parameter></para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>c</para></td><td class="parameter_description"><para>a Unicode character</para><para>Passed as <code>c</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-strreverse</title><informalexample><programlisting>(define-values (%return) (utf8-strreverse str len))
  8990. </programlisting></informalexample><para>Reverses a UTF-8 string. <parameter>str</parameter> must be valid UTF-8 encoded text.
  8991. (Use <function>g_utf8_validate()</function> on all text before trying to use UTF-8
  8992. utility functions with it.)
  8993. </para>
  8994. <para>This function is intended for programmatic uses of reversed strings.
  8995. It pays no attention to decomposed characters, combining marks, byte
  8996. order marks, directional indicators (LRM, LRO, etc) and similar
  8997. characters which might need special handling when reversing a string
  8998. for display purposes.
  8999. </para>
  9000. <para>Note that unlike <function>g_strreverse()</function>, this function returns
  9001. newly-allocated memory, which should be freed with <function>g_free()</function> when
  9002. no longer needed.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length of <parameter>str</parameter> to use, in bytes. If <parameter>len</parameter> &lt; 0,
  9003. then the string is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-strup</title><informalexample><programlisting>(define-values (%return) (utf8-strup str len))
  9004. </programlisting></informalexample><para>Converts all Unicode characters in the string that have a case
  9005. to uppercase. The exact manner that this is done depends
  9006. on the current locale, and may result in the number of
  9007. characters in the string increasing. (For instance, the
  9008. German ess-zet will be changed to SS.)</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>length of <parameter>str</parameter>, in bytes, or -1 if <parameter>str</parameter> is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-substring</title><informalexample><programlisting>(define-values (%return) (utf8-substring str start-pos end-pos))
  9009. </programlisting></informalexample><para>Copies a substring out of a UTF-8 encoded string.
  9010. The substring will contain <parameter>end_pos</parameter> - <parameter>start_pos</parameter> characters.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>start_pos</para></td><td class="parameter_description"><para>a character offset within <parameter>str</parameter></para><para>Passed as <code>start-pos</code></para></td></tr><tr><td class="parameter_name"><para>end_pos</para></td><td class="parameter_description"><para>another character offset within <parameter>str</parameter></para><para>Passed as <code>end-pos</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-to-ucs4</title><informalexample><programlisting>(define-values
  9011. (%return items-read items-written)
  9012. (utf8-to-ucs4 str len items-read items-written))
  9013. </programlisting></informalexample><para>Convert a string from UTF-8 to a 32-bit fixed width
  9014. representation as UCS-4. A trailing 0 character will be added to the
  9015. string after the converted text.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length of <parameter>str</parameter> to use, in bytes. If <parameter>len</parameter> &lt; 0,
  9016. then the string is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>items_read</para></td><td class="parameter_description"><para>location to store number of
  9017. bytes read, or <constant>NULL</constant>.
  9018. If <constant>NULL</constant>, then <constant>G_CONVERT_ERROR_PARTIAL_INPUT</constant> will be
  9019. returned in case <parameter>str</parameter> contains a trailing partial
  9020. character. If an error occurs then the index of the
  9021. invalid input is stored here.</para><para>Passed as <code>items-read</code></para></td></tr><tr><td class="parameter_name"><para>items_written</para></td><td class="parameter_description"><para>location to store number
  9022. of characters written or <constant>NULL</constant>. The value here stored does not include
  9023. the trailing 0 character.</para><para>Passed as <code>items-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-to-ucs4-fast</title><informalexample><programlisting>(define-values
  9024. (%return items-written)
  9025. (utf8-to-ucs4-fast str len items-written))
  9026. </programlisting></informalexample><para>Convert a string from UTF-8 to a 32-bit fixed width
  9027. representation as UCS-4, assuming valid UTF-8 input.
  9028. This function is roughly twice as fast as <function>g_utf8_to_ucs4()</function>
  9029. but does no error checking on the input. A trailing 0 character
  9030. will be added to the string after the converted text.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length of <parameter>str</parameter> to use, in bytes. If <parameter>len</parameter> &lt; 0,
  9031. then the string is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>items_written</para></td><td class="parameter_description"><para>location to store the
  9032. number of characters in the result, or <constant>NULL</constant>.</para><para>Passed as <code>items-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-to-utf16</title><informalexample><programlisting>(define-values
  9033. (%return items-read items-written)
  9034. (utf8-to-utf16 str len items-read items-written))
  9035. </programlisting></informalexample><para>Convert a string from UTF-8 to UTF-16. A 0 character will be
  9036. added to the result after the converted text.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a UTF-8 encoded string</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>len</para></td><td class="parameter_description"><para>the maximum length (number of bytes) of <parameter>str</parameter> to use.
  9037. If <parameter>len</parameter> &lt; 0, then the string is nul-terminated.</para><para>Passed as <code>len</code></para></td></tr><tr><td class="parameter_name"><para>items_read</para></td><td class="parameter_description"><para>location to store number of
  9038. bytes read, or <constant>NULL</constant>. If <constant>NULL</constant>, then <constant>G_CONVERT_ERROR_PARTIAL_INPUT</constant> will
  9039. be returned in case <parameter>str</parameter> contains a trailing partial character. If
  9040. an error occurs then the index of the invalid input is stored here.</para><para>Passed as <code>items-read</code></para></td></tr><tr><td class="parameter_name"><para>items_written</para></td><td class="parameter_description"><para>location to store number
  9041. of <type>gunichar2</type> written, or <constant>NULL</constant>. The value stored here does not include
  9042. the trailing 0.</para><para>Passed as <code>items-written</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-validate</title><informalexample><programlisting>(define-values (%return end) (utf8-validate str))
  9043. </programlisting></informalexample><para>Validates UTF-8 encoded text. <parameter>str</parameter> is the text to validate;
  9044. if <parameter>str</parameter> is nul-terminated, then <parameter>max_len</parameter> can be -1, otherwise
  9045. <parameter>max_len</parameter> should be the number of bytes to validate.
  9046. If <parameter>end</parameter> is non-<constant>NULL</constant>, then the end of the valid range
  9047. will be stored there (i.e. the start of the first invalid
  9048. character if some bytes were invalid, or the end of the text
  9049. being validated otherwise).
  9050. </para>
  9051. <para>Note that <function>g_utf8_validate()</function> returns <constant>FALSE</constant> if <parameter>max_len</parameter> is
  9052. positive and any of the <parameter>max_len</parameter> bytes are nul.
  9053. </para>
  9054. <para>Returns <constant>TRUE</constant> if all of <parameter>str</parameter> was valid. Many GLib and GTK+
  9055. routines require valid UTF-8 as input; so data read from a file
  9056. or the network should be checked with <function>g_utf8_validate()</function> before
  9057. doing anything else with it.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a pointer to character data</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>max_len</para></td><td class="parameter_description"><para>max bytes to validate, or -1 to go until NUL</para><para>Inferred from <code>str</code></para></td></tr><tr><td class="parameter_name"><para>end</para></td><td class="parameter_description"><para>return location for end of valid data</para><para>Passed as <code>end</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>utf8-validate-len</title><informalexample><programlisting>(define-values (%return end) (utf8-validate-len str))
  9058. </programlisting></informalexample><para>Validates UTF-8 encoded text.
  9059. </para>
  9060. <para>As with <function>g_utf8_validate()</function>, but <parameter>max_len</parameter> must be set, and hence this function
  9061. will always return <constant>FALSE</constant> if any of the bytes of <parameter>str</parameter> are nul.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a pointer to character data</para><para>Passed as <code>str</code></para></td></tr><tr><td class="parameter_name"><para>max_len</para></td><td class="parameter_description"><para>max bytes to validate</para><para>Inferred from <code>str</code></para></td></tr><tr><td class="parameter_name"><para>end</para></td><td class="parameter_description"><para>return location for end of valid data</para><para>Passed as <code>end</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uuid-string-is-valid?</title><informalexample><programlisting>(define-values (%return) (uuid-string-is-valid? str))
  9062. </programlisting></informalexample><para>Parses the string <parameter>str</parameter> and verify if it is a UUID.
  9063. </para>
  9064. <para>The function accepts the following syntax:
  9065. </para>
  9066. <para>- simple forms (e.g. <code>f81d4fae-7dec-11d0-a765-00a0c91e6bf6</code>)
  9067. </para>
  9068. <para>Note that hyphens are required within the UUID string itself,
  9069. as per the aforementioned RFC.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>str</para></td><td class="parameter_description"><para>a string representing a UUID</para><para>Passed as <code>str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>uuid-string-random</title><informalexample><programlisting>(define-values (%return) (uuid-string-random))
  9070. </programlisting></informalexample><para>Generates a random UUID (RFC 4122 version 4) as a string. It has the same
  9071. randomness guarantees as <type>GRand</type>, so must not be used for cryptographic
  9072. purposes such as key generation, nonces, salts or one-time pads.</para></refsect2><refsect2><title>variant-get-gtype</title><informalexample><programlisting>(define-values (%return) (variant-get-gtype))
  9073. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>variant-is-object-path?</title><informalexample><programlisting>(define-values (%return) (variant-is-object-path? string))
  9074. </programlisting></informalexample><para>Determines if a given string is a valid D-Bus object path. You
  9075. should ensure that a string is a valid D-Bus object path before
  9076. passing it to <function>g_variant_new_object_path()</function>.
  9077. </para>
  9078. <para>A valid object path starts with <code>/</code> followed by zero or more
  9079. sequences of characters separated by <code>/</code> characters. Each sequence
  9080. must contain only the characters <code>[A-Z][a-z][0-9]_</code>. No sequence
  9081. (including the one following the final <code>/</code> character) may be empty.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a normal C nul-terminated string</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-is-signature?</title><informalexample><programlisting>(define-values (%return) (variant-is-signature? string))
  9082. </programlisting></informalexample><para>Determines if a given string is a valid D-Bus type signature. You
  9083. should ensure that a string is a valid D-Bus type signature before
  9084. passing it to <function>g_variant_new_signature()</function>.
  9085. </para>
  9086. <para>D-Bus type signatures consist of zero or more definite <type>GVariantType</type>
  9087. strings in sequence.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a normal C nul-terminated string</para><para>Passed as <code>string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-parse</title><informalexample><programlisting>(define-values (%return) (variant-parse type text limit endptr))
  9088. </programlisting></informalexample><para>Parses a <type>GVariant</type> from a text representation.
  9089. </para>
  9090. <para>A single <type>GVariant</type> is parsed from the content of <parameter>text</parameter>.
  9091. </para>
  9092. <para>The format is described [here][gvariant-text].
  9093. </para>
  9094. <para>The memory at <parameter>limit</parameter> will never be accessed and the parser behaves as
  9095. if the character at <parameter>limit</parameter> is the nul terminator. This has the
  9096. effect of bounding <parameter>text</parameter>.
  9097. </para>
  9098. <para>If <parameter>endptr</parameter> is non-<constant>NULL</constant> then <parameter>text</parameter> is permitted to contain data
  9099. following the value that this function parses and <parameter>endptr</parameter> will be
  9100. updated to point to the first character past the end of the text
  9101. parsed by this function. If <parameter>endptr</parameter> is <constant>NULL</constant> and there is extra data
  9102. then an error is returned.
  9103. </para>
  9104. <para>If <parameter>type</parameter> is non-<constant>NULL</constant> then the value will be parsed to have that
  9105. type. This may result in additional parse errors (in the case that
  9106. the parsed value doesn't fit the type) but may also result in fewer
  9107. errors (in the case that the type would have been ambiguous, such as
  9108. with empty arrays).
  9109. </para>
  9110. <para>In the event that the parsing is successful, the resulting <type>GVariant</type>
  9111. is returned. It is never floating, and must be freed with
  9112. <function>g_variant_unref()</function>.
  9113. </para>
  9114. <para>In case of any error, <constant>NULL</constant> will be returned. If <parameter>error</parameter> is non-<constant>NULL</constant>
  9115. then it will be set to reflect the error that occurred.
  9116. </para>
  9117. <para>Officially, the language understood by the parser is &quot;any string
  9118. produced by <function>g_variant_print()</function>&quot;.
  9119. </para>
  9120. <para>There may be implementation specific restrictions on deeply nested values,
  9121. which would result in a <constant>G_VARIANT_PARSE_ERROR_RECURSION</constant> error. <type>GVariant</type> is
  9122. guaranteed to handle nesting up to at least 64 levels.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type</para></td><td class="parameter_description"><para>a <type>GVariantType</type>, or <constant>NULL</constant></para><para>Passed as <code>type</code></para></td></tr><tr><td class="parameter_name"><para>text</para></td><td class="parameter_description"><para>a string containing a GVariant in text form</para><para>Passed as <code>text</code></para></td></tr><tr><td class="parameter_name"><para>limit</para></td><td class="parameter_description"><para>a pointer to the end of <parameter>text</parameter>, or <constant>NULL</constant></para><para>Passed as <code>limit</code></para></td></tr><tr><td class="parameter_name"><para>endptr</para></td><td class="parameter_description"><para>a location to store the end pointer, or <constant>NULL</constant></para><para>Passed as <code>endptr</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-parse-error-print-context</title><informalexample><programlisting>(define-values (%return) (variant-parse-error-print-context error source-str))
  9123. </programlisting></informalexample><para>Pretty-prints a message showing the context of a <type>GVariant</type> parse
  9124. error within the string for which parsing was attempted.
  9125. </para>
  9126. <para>The resulting string is suitable for output to the console or other
  9127. monospace media where newlines are treated in the usual way.
  9128. </para>
  9129. <para>The message will typically look something like one of the following:
  9130. </para>
  9131. <para><informalexample><programlisting>
  9132. unterminated string constant:
  9133. (1, 2, 3, 'abc
  9134. ^^^^
  9135. </programlisting></informalexample></para>
  9136. <para>or
  9137. </para>
  9138. <para><informalexample><programlisting>
  9139. unable to find a common type:
  9140. [1, 2, 3, 'str']
  9141. ^ ^^^^^
  9142. </programlisting></informalexample></para>
  9143. <para>The format of the message may change in a future version.
  9144. </para>
  9145. <para><parameter>error</parameter> must have come from a failed attempt to <function>g_variant_parse()</function> and
  9146. <parameter>source_str</parameter> must be exactly the same string that caused the error.
  9147. If <parameter>source_str</parameter> was not nul-terminated when you passed it to
  9148. <function>g_variant_parse()</function> then you must add nul termination before using this
  9149. function.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>error</para></td><td class="parameter_description"><para>a <type>GError</type> from the <type>GVariantParseError</type> domain</para><para>Passed as <code>error</code></para></td></tr><tr><td class="parameter_name"><para>source_str</para></td><td class="parameter_description"><para>the string that was given to the parser</para><para>Passed as <code>source-str</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-parse-error-quark</title><informalexample><programlisting>(define-values (%return) (variant-parse-error-quark))
  9150. </programlisting></informalexample><para>Undocumented</para></refsect2><refsect2><title>variant-type-checked-</title><informalexample><programlisting>(define-values (%return) (variant-type-checked- arg0))
  9151. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>arg0</para></td><td class="parameter_description"><para></para><para>Passed as <code>arg0</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type-string-get-depth-</title><informalexample><programlisting>(define-values (%return) (variant-type-string-get-depth- type-string))
  9152. </programlisting></informalexample><para>Undocumented</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type_string</para></td><td class="parameter_description"><para></para><para>Passed as <code>type-string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type-string-is-valid?</title><informalexample><programlisting>(define-values (%return) (variant-type-string-is-valid? type-string))
  9153. </programlisting></informalexample><para>Checks if <parameter>type_string</parameter> is a valid GVariant type string. This call is
  9154. equivalent to calling <function>g_variant_type_string_scan()</function> and confirming
  9155. that the following character is a nul terminator.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>type_string</para></td><td class="parameter_description"><para>a pointer to any string</para><para>Passed as <code>type-string</code></para></td></tr></informaltable></refsect3></refsect2><refsect2><title>variant-type-string-scan</title><informalexample><programlisting>(define-values (%return endptr) (variant-type-string-scan string limit))
  9156. </programlisting></informalexample><para>Scan for a single complete and valid GVariant type string in <parameter>string</parameter>.
  9157. The memory pointed to by <parameter>limit</parameter> (or bytes beyond it) is never
  9158. accessed.
  9159. </para>
  9160. <para>If a valid type string is found, <parameter>endptr</parameter> is updated to point to the
  9161. first character past the end of the string that was found and <constant>TRUE</constant>
  9162. is returned.
  9163. </para>
  9164. <para>If there is no valid type string starting at <parameter>string</parameter>, or if the type
  9165. string does not end before <parameter>limit</parameter> then <constant>FALSE</constant> is returned.
  9166. </para>
  9167. <para>For the simple case of checking if a string is a valid type string,
  9168. see <function>g_variant_type_string_is_valid()</function>.</para><refsect3><title>Parameters</title><informaltable><tr><td class="parameter_name"><para>string</para></td><td class="parameter_description"><para>a pointer to any string</para><para>Passed as <code>string</code></para></td></tr><tr><td class="parameter_name"><para>limit</para></td><td class="parameter_description"><para>the end of <parameter>string</parameter>, or <constant>NULL</constant></para><para>Passed as <code>limit</code></para></td></tr><tr><td class="parameter_name"><para>endptr</para></td><td class="parameter_description"><para>location to store the end pointer, or <constant>NULL</constant></para><para>Passed as <code>endptr</code></para></td></tr></informaltable></refsect3></refsect2></refsect1></refentry></chapter></book>