re89.html 618 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <title>Functions: </title>
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.79.2">
  7. <link rel="home" href="index.html" title="">
  8. <link rel="up" href="ch01.html" title="GLib">
  9. <link rel="prev" href="re88.html" title="&lt;GVariantType&gt;">
  10. <meta name="generator" content="GTK-Doc V1.33.1 (XML mode)">
  11. <link rel="stylesheet" href="style.css" type="text/css">
  12. </head>
  13. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  14. <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
  15. <td width="100%" align="left" class="shortcuts"></td>
  16. <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
  17. <td><img src="up-insensitive.png" width="16" height="16" border="0"></td>
  18. <td><a accesskey="p" href="re88.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
  19. <td><img src="right-insensitive.png" width="16" height="16" border="0"></td>
  20. </tr></table>
  21. <div class="refentry">
  22. <a name="id-1.1.90"></a><div class="titlepage"></div>
  23. <div class="refnamediv">
  24. <h2>Functions</h2>
  25. <p>Functions</p>
  26. </div>
  27. <div class="refsect1">
  28. <a name="id-1.1.90.2"></a><h2>Functions</h2>
  29. <div class="refsect2">
  30. <a name="id-1.1.90.2.2"></a><h3>byte-array:free</h3>
  31. <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array:free array free-segment))
  32. </pre></div>
  33. <p>Undocumented</p>
  34. <div class="refsect3">
  35. <a name="id-1.1.90.2.2.4"></a><h4>Parameters</h4>
  36. <div class="informaltable"><table>
  37. <tr>
  38. <td class="parameter_name"><p>free_segment</p></td>
  39. <td class="parameter_description">
  40. <p></p>
  41. <p>Passed as <code class="code">free-segment</code></p>
  42. </td>
  43. </tr>
  44. <tr>
  45. <td class="parameter_name"><p>array</p></td>
  46. <td class="parameter_description">
  47. <p></p>
  48. <p>Passed as <code class="code">array</code></p>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td class="parameter_name"><p>mem</p></td>
  53. <td class="parameter_description">
  54. <p></p>
  55. <p>Passed as <code class="code">mem</code></p>
  56. </td>
  57. </tr>
  58. </table></div>
  59. </div>
  60. </div>
  61. <div class="refsect2">
  62. <a name="id-1.1.90.2.3"></a><h3>access</h3>
  63. <div class="informalexample"><pre class="programlisting">(define-values (%return) (access filename mode))
  64. </pre></div>
  65. <p>A wrapper for the POSIX <code class="function">access()</code> function. This function is used to
  66. test a pathname for one or several of read, write or execute
  67. permissions, or just existence.
  68. </p>
  69. <p>On Windows, the file protection mechanism is not at all POSIX-like,
  70. and the underlying function in the C library only checks the
  71. FAT-style READONLY attribute, and does not look at the ACL of a
  72. file at all. This function is this in practise almost useless on
  73. Windows. Software that needs to handle file permissions on Windows
  74. more exactly should use the Win32 API.
  75. </p>
  76. <p>See your C library manual for more details about <code class="function">access()</code>.</p>
  77. <div class="refsect3">
  78. <a name="id-1.1.90.2.3.6"></a><h4>Parameters</h4>
  79. <div class="informaltable"><table>
  80. <tr>
  81. <td class="parameter_name"><p>filename</p></td>
  82. <td class="parameter_description">
  83. <p>a pathname in the GLib file name encoding
  84. (UTF-8 on Windows)</p>
  85. <p>Passed as <code class="code">filename</code></p>
  86. </td>
  87. </tr>
  88. <tr>
  89. <td class="parameter_name"><p>mode</p></td>
  90. <td class="parameter_description">
  91. <p>as in <code class="function">access()</code></p>
  92. <p>Passed as <code class="code">mode</code></p>
  93. </td>
  94. </tr>
  95. </table></div>
  96. </div>
  97. </div>
  98. <div class="refsect2">
  99. <a name="id-1.1.90.2.4"></a><h3>ascii-digit-value</h3>
  100. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ascii-digit-value c))
  101. </pre></div>
  102. <p>Determines the numeric value of a character as a decimal digit.
  103. Differs from <code class="function">g_unichar_digit_value()</code> because it takes a char, so
  104. there's no worry about sign extension if characters are signed.</p>
  105. <div class="refsect3">
  106. <a name="id-1.1.90.2.4.4"></a><h4>Parameters</h4>
  107. <div class="informaltable"><table><tr>
  108. <td class="parameter_name"><p>c</p></td>
  109. <td class="parameter_description">
  110. <p>an ASCII character</p>
  111. <p>Passed as <code class="code">c</code></p>
  112. </td>
  113. </tr></table></div>
  114. </div>
  115. </div>
  116. <div class="refsect2">
  117. <a name="id-1.1.90.2.5"></a><h3>ascii-dtostr</h3>
  118. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ascii-dtostr buffer buf-len d))
  119. </pre></div>
  120. <p>Converts a <span class="type">gdouble</span> to a string, using the '.' as
  121. decimal point.
  122. </p>
  123. <p>This function generates enough precision that converting
  124. the string back using <code class="function">g_ascii_strtod()</code> gives the same machine-number
  125. (on machines with IEEE compatible 64bit doubles). It is
  126. guaranteed that the size of the resulting string will never
  127. be larger than <em class="parameter"><code>G_ASCII_DTOSTR_BUF_SIZE</code></em> bytes, including the terminating
  128. nul character, which is always added.</p>
  129. <div class="refsect3">
  130. <a name="id-1.1.90.2.5.5"></a><h4>Parameters</h4>
  131. <div class="informaltable"><table>
  132. <tr>
  133. <td class="parameter_name"><p>buffer</p></td>
  134. <td class="parameter_description">
  135. <p>A buffer to place the resulting string in</p>
  136. <p>Passed as <code class="code">buffer</code></p>
  137. </td>
  138. </tr>
  139. <tr>
  140. <td class="parameter_name"><p>buf_len</p></td>
  141. <td class="parameter_description">
  142. <p>The length of the buffer.</p>
  143. <p>Passed as <code class="code">buf-len</code></p>
  144. </td>
  145. </tr>
  146. <tr>
  147. <td class="parameter_name"><p>d</p></td>
  148. <td class="parameter_description">
  149. <p>The <span class="type">gdouble</span> to convert</p>
  150. <p>Passed as <code class="code">d</code></p>
  151. </td>
  152. </tr>
  153. </table></div>
  154. </div>
  155. </div>
  156. <div class="refsect2">
  157. <a name="id-1.1.90.2.6"></a><h3>ascii-formatd</h3>
  158. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ascii-formatd buffer buf-len format d))
  159. </pre></div>
  160. <p>Converts a <span class="type">gdouble</span> to a string, using the '.' as
  161. decimal point. To format the number you pass in
  162. a <code class="function">printf()</code>-style format string. Allowed conversion
  163. specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
  164. </p>
  165. <p>The returned buffer is guaranteed to be nul-terminated.
  166. </p>
  167. <p>If you just want to want to serialize the value into a
  168. string, use <code class="function">g_ascii_dtostr()</code>.</p>
  169. <div class="refsect3">
  170. <a name="id-1.1.90.2.6.6"></a><h4>Parameters</h4>
  171. <div class="informaltable"><table>
  172. <tr>
  173. <td class="parameter_name"><p>buffer</p></td>
  174. <td class="parameter_description">
  175. <p>A buffer to place the resulting string in</p>
  176. <p>Passed as <code class="code">buffer</code></p>
  177. </td>
  178. </tr>
  179. <tr>
  180. <td class="parameter_name"><p>buf_len</p></td>
  181. <td class="parameter_description">
  182. <p>The length of the buffer.</p>
  183. <p>Passed as <code class="code">buf-len</code></p>
  184. </td>
  185. </tr>
  186. <tr>
  187. <td class="parameter_name"><p>format</p></td>
  188. <td class="parameter_description">
  189. <p>The <code class="function">printf()</code>-style format to use for the
  190. code to use for converting.</p>
  191. <p>Passed as <code class="code">format</code></p>
  192. </td>
  193. </tr>
  194. <tr>
  195. <td class="parameter_name"><p>d</p></td>
  196. <td class="parameter_description">
  197. <p>The <span class="type">gdouble</span> to convert</p>
  198. <p>Passed as <code class="code">d</code></p>
  199. </td>
  200. </tr>
  201. </table></div>
  202. </div>
  203. </div>
  204. <div class="refsect2">
  205. <a name="id-1.1.90.2.7"></a><h3>ascii-strcasecmp</h3>
  206. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ascii-strcasecmp s1 s2))
  207. </pre></div>
  208. <p>Compare two strings, ignoring the case of ASCII characters.
  209. </p>
  210. <p>Unlike the BSD <code class="function">strcasecmp()</code> function, this only recognizes standard
  211. ASCII letters and ignores the locale, treating all non-ASCII
  212. bytes as if they are not letters.
  213. </p>
  214. <p>This function should be used only on strings that are known to be
  215. in encodings where the bytes corresponding to ASCII letters always
  216. represent themselves. This includes UTF-8 and the ISO-8859-*
  217. charsets, but not for instance double-byte encodings like the
  218. Windows Codepage 932, where the trailing bytes of double-byte
  219. characters include all ASCII letters. If you compare two CP932
  220. strings using this function, you will get false matches.
  221. </p>
  222. <p>Both <em class="parameter"><code>s1</code></em> and <em class="parameter"><code>s2</code></em> must be non-<code class="constant">NULL</code>.</p>
  223. <div class="refsect3">
  224. <a name="id-1.1.90.2.7.7"></a><h4>Parameters</h4>
  225. <div class="informaltable"><table>
  226. <tr>
  227. <td class="parameter_name"><p>s1</p></td>
  228. <td class="parameter_description">
  229. <p>string to compare with <em class="parameter"><code>s2</code></em></p>
  230. <p>Passed as <code class="code">s1</code></p>
  231. </td>
  232. </tr>
  233. <tr>
  234. <td class="parameter_name"><p>s2</p></td>
  235. <td class="parameter_description">
  236. <p>string to compare with <em class="parameter"><code>s1</code></em></p>
  237. <p>Passed as <code class="code">s2</code></p>
  238. </td>
  239. </tr>
  240. </table></div>
  241. </div>
  242. </div>
  243. <div class="refsect2">
  244. <a name="id-1.1.90.2.8"></a><h3>ascii-strdown</h3>
  245. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ascii-strdown str len))
  246. </pre></div>
  247. <p>Converts all upper case ASCII letters to lower case ASCII letters.</p>
  248. <div class="refsect3">
  249. <a name="id-1.1.90.2.8.4"></a><h4>Parameters</h4>
  250. <div class="informaltable"><table>
  251. <tr>
  252. <td class="parameter_name"><p>str</p></td>
  253. <td class="parameter_description">
  254. <p>a string</p>
  255. <p>Passed as <code class="code">str</code></p>
  256. </td>
  257. </tr>
  258. <tr>
  259. <td class="parameter_name"><p>len</p></td>
  260. <td class="parameter_description">
  261. <p>length of <em class="parameter"><code>str</code></em> in bytes, or -1 if <em class="parameter"><code>str</code></em> is nul-terminated</p>
  262. <p>Passed as <code class="code">len</code></p>
  263. </td>
  264. </tr>
  265. </table></div>
  266. </div>
  267. </div>
  268. <div class="refsect2">
  269. <a name="id-1.1.90.2.9"></a><h3>ascii-string-to-signed</h3>
  270. <div class="informalexample"><pre class="programlisting">(define-values (%return out-num) (ascii-string-to-signed str base min max))
  271. </pre></div>
  272. <p>A convenience function for converting a string to a signed number.
  273. </p>
  274. <p>This function assumes that <em class="parameter"><code>str</code></em> contains only a number of the given
  275. <em class="parameter"><code>base</code></em> that is within inclusive bounds limited by <em class="parameter"><code>min</code></em> and <em class="parameter"><code>max</code></em>. If
  276. this is true, then the converted number is stored in <em class="parameter"><code>out_num</code></em>. An
  277. empty string is not a valid input. A string with leading or
  278. trailing whitespace is also an invalid input.
  279. </p>
  280. <p><em class="parameter"><code>base</code></em> can be between 2 and 36 inclusive. Hexadecimal numbers must
  281. not be prefixed with "0x" or "0X". Such a problem does not exist
  282. for octal numbers, since they were usually prefixed with a zero
  283. which does not change the value of the parsed number.
  284. </p>
  285. <p>Parsing failures result in an error with the <code class="constant">G_NUMBER_PARSER_ERROR</code>
  286. domain. If the input is invalid, the error code will be
  287. <code class="constant">G_NUMBER_PARSER_ERROR_INVALID</code>. If the parsed number is out of
  288. bounds - <code class="constant">G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS</code>.
  289. </p>
  290. <p>See <code class="function">g_ascii_strtoll()</code> if you have more complex needs such as
  291. parsing a string which starts with a number, but then has other
  292. characters.</p>
  293. <div class="refsect3">
  294. <a name="id-1.1.90.2.9.8"></a><h4>Parameters</h4>
  295. <div class="informaltable"><table>
  296. <tr>
  297. <td class="parameter_name"><p>str</p></td>
  298. <td class="parameter_description">
  299. <p>a string</p>
  300. <p>Passed as <code class="code">str</code></p>
  301. </td>
  302. </tr>
  303. <tr>
  304. <td class="parameter_name"><p>base</p></td>
  305. <td class="parameter_description">
  306. <p>base of a parsed number</p>
  307. <p>Passed as <code class="code">base</code></p>
  308. </td>
  309. </tr>
  310. <tr>
  311. <td class="parameter_name"><p>min</p></td>
  312. <td class="parameter_description">
  313. <p>a lower bound (inclusive)</p>
  314. <p>Passed as <code class="code">min</code></p>
  315. </td>
  316. </tr>
  317. <tr>
  318. <td class="parameter_name"><p>max</p></td>
  319. <td class="parameter_description">
  320. <p>an upper bound (inclusive)</p>
  321. <p>Passed as <code class="code">max</code></p>
  322. </td>
  323. </tr>
  324. <tr>
  325. <td class="parameter_name"><p>out_num</p></td>
  326. <td class="parameter_description">
  327. <p>a return location for a number</p>
  328. <p>Passed as <code class="code">out-num</code></p>
  329. </td>
  330. </tr>
  331. </table></div>
  332. </div>
  333. </div>
  334. <div class="refsect2">
  335. <a name="id-1.1.90.2.10"></a><h3>ascii-string-to-unsigned</h3>
  336. <div class="informalexample"><pre class="programlisting">(define-values (%return out-num) (ascii-string-to-unsigned str base min max))
  337. </pre></div>
  338. <p>A convenience function for converting a string to an unsigned number.
  339. </p>
  340. <p>This function assumes that <em class="parameter"><code>str</code></em> contains only a number of the given
  341. <em class="parameter"><code>base</code></em> that is within inclusive bounds limited by <em class="parameter"><code>min</code></em> and <em class="parameter"><code>max</code></em>. If
  342. this is true, then the converted number is stored in <em class="parameter"><code>out_num</code></em>. An
  343. empty string is not a valid input. A string with leading or
  344. trailing whitespace is also an invalid input. A string with a leading sign
  345. (<code class="code">-</code> or <code class="code">+</code>) is not a valid input for the unsigned parser.
  346. </p>
  347. <p><em class="parameter"><code>base</code></em> can be between 2 and 36 inclusive. Hexadecimal numbers must
  348. not be prefixed with "0x" or "0X". Such a problem does not exist
  349. for octal numbers, since they were usually prefixed with a zero
  350. which does not change the value of the parsed number.
  351. </p>
  352. <p>Parsing failures result in an error with the <code class="constant">G_NUMBER_PARSER_ERROR</code>
  353. domain. If the input is invalid, the error code will be
  354. <code class="constant">G_NUMBER_PARSER_ERROR_INVALID</code>. If the parsed number is out of
  355. bounds - <code class="constant">G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS</code>.
  356. </p>
  357. <p>See <code class="function">g_ascii_strtoull()</code> if you have more complex needs such as
  358. parsing a string which starts with a number, but then has other
  359. characters.</p>
  360. <div class="refsect3">
  361. <a name="id-1.1.90.2.10.8"></a><h4>Parameters</h4>
  362. <div class="informaltable"><table>
  363. <tr>
  364. <td class="parameter_name"><p>str</p></td>
  365. <td class="parameter_description">
  366. <p>a string</p>
  367. <p>Passed as <code class="code">str</code></p>
  368. </td>
  369. </tr>
  370. <tr>
  371. <td class="parameter_name"><p>base</p></td>
  372. <td class="parameter_description">
  373. <p>base of a parsed number</p>
  374. <p>Passed as <code class="code">base</code></p>
  375. </td>
  376. </tr>
  377. <tr>
  378. <td class="parameter_name"><p>min</p></td>
  379. <td class="parameter_description">
  380. <p>a lower bound (inclusive)</p>
  381. <p>Passed as <code class="code">min</code></p>
  382. </td>
  383. </tr>
  384. <tr>
  385. <td class="parameter_name"><p>max</p></td>
  386. <td class="parameter_description">
  387. <p>an upper bound (inclusive)</p>
  388. <p>Passed as <code class="code">max</code></p>
  389. </td>
  390. </tr>
  391. <tr>
  392. <td class="parameter_name"><p>out_num</p></td>
  393. <td class="parameter_description">
  394. <p>a return location for a number</p>
  395. <p>Passed as <code class="code">out-num</code></p>
  396. </td>
  397. </tr>
  398. </table></div>
  399. </div>
  400. </div>
  401. <div class="refsect2">
  402. <a name="id-1.1.90.2.11"></a><h3>ascii-strncasecmp</h3>
  403. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ascii-strncasecmp s1 s2 n))
  404. </pre></div>
  405. <p>Compare <em class="parameter"><code>s1</code></em> and <em class="parameter"><code>s2</code></em>, ignoring the case of ASCII characters and any
  406. characters after the first <em class="parameter"><code>n</code></em> in each string.
  407. </p>
  408. <p>Unlike the BSD <code class="function">strcasecmp()</code> function, this only recognizes standard
  409. ASCII letters and ignores the locale, treating all non-ASCII
  410. characters as if they are not letters.
  411. </p>
  412. <p>The same warning as in <code class="function">g_ascii_strcasecmp()</code> applies: Use this
  413. function only on strings known to be in encodings where bytes
  414. corresponding to ASCII letters always represent themselves.</p>
  415. <div class="refsect3">
  416. <a name="id-1.1.90.2.11.6"></a><h4>Parameters</h4>
  417. <div class="informaltable"><table>
  418. <tr>
  419. <td class="parameter_name"><p>s1</p></td>
  420. <td class="parameter_description">
  421. <p>string to compare with <em class="parameter"><code>s2</code></em></p>
  422. <p>Passed as <code class="code">s1</code></p>
  423. </td>
  424. </tr>
  425. <tr>
  426. <td class="parameter_name"><p>s2</p></td>
  427. <td class="parameter_description">
  428. <p>string to compare with <em class="parameter"><code>s1</code></em></p>
  429. <p>Passed as <code class="code">s2</code></p>
  430. </td>
  431. </tr>
  432. <tr>
  433. <td class="parameter_name"><p>n</p></td>
  434. <td class="parameter_description">
  435. <p>number of characters to compare</p>
  436. <p>Passed as <code class="code">n</code></p>
  437. </td>
  438. </tr>
  439. </table></div>
  440. </div>
  441. </div>
  442. <div class="refsect2">
  443. <a name="id-1.1.90.2.12"></a><h3>ascii-strtod</h3>
  444. <div class="informalexample"><pre class="programlisting">(define-values (%return endptr) (ascii-strtod nptr))
  445. </pre></div>
  446. <p>Converts a string to a <span class="type">gdouble</span> value.
  447. </p>
  448. <p>This function behaves like the standard <code class="function">strtod()</code> function
  449. does in the C locale. It does this without actually changing
  450. the current locale, since that would not be thread-safe.
  451. A limitation of the implementation is that this function
  452. will still accept localized versions of infinities and NANs.
  453. </p>
  454. <p>This function is typically used when reading configuration
  455. files or other non-user input that should be locale independent.
  456. To handle input from the user you should normally use the
  457. locale-sensitive system <code class="function">strtod()</code> function.
  458. </p>
  459. <p>To convert from a <span class="type">gdouble</span> to a string in a locale-insensitive
  460. way, use <code class="function">g_ascii_dtostr()</code>.
  461. </p>
  462. <p>If the correct value would cause overflow, plus or minus <code class="constant">HUGE_VAL</code>
  463. is returned (according to the sign of the value), and <code class="constant">ERANGE</code> is
  464. stored in <code class="constant">errno</code>. If the correct value would cause underflow,
  465. zero is returned and <code class="constant">ERANGE</code> is stored in <code class="constant">errno</code>.
  466. </p>
  467. <p>This function resets <code class="constant">errno</code> before calling <code class="function">strtod()</code> so that
  468. you can reliably detect overflow and underflow.</p>
  469. <div class="refsect3">
  470. <a name="id-1.1.90.2.12.9"></a><h4>Parameters</h4>
  471. <div class="informaltable"><table>
  472. <tr>
  473. <td class="parameter_name"><p>nptr</p></td>
  474. <td class="parameter_description">
  475. <p>the string to convert to a numeric value.</p>
  476. <p>Passed as <code class="code">nptr</code></p>
  477. </td>
  478. </tr>
  479. <tr>
  480. <td class="parameter_name"><p>endptr</p></td>
  481. <td class="parameter_description">
  482. <p>if non-<code class="constant">NULL</code>, it returns the
  483. character after the last character used in the conversion.</p>
  484. <p>Passed as <code class="code">endptr</code></p>
  485. </td>
  486. </tr>
  487. </table></div>
  488. </div>
  489. </div>
  490. <div class="refsect2">
  491. <a name="id-1.1.90.2.13"></a><h3>ascii-strtoll</h3>
  492. <div class="informalexample"><pre class="programlisting">(define-values (%return endptr) (ascii-strtoll nptr base))
  493. </pre></div>
  494. <p>Converts a string to a <span class="type">gint64</span> value.
  495. This function behaves like the standard <code class="function">strtoll()</code> function
  496. does in the C locale. It does this without actually
  497. changing the current locale, since that would not be
  498. thread-safe.
  499. </p>
  500. <p>This function is typically used when reading configuration
  501. files or other non-user input that should be locale independent.
  502. To handle input from the user you should normally use the
  503. locale-sensitive system <code class="function">strtoll()</code> function.
  504. </p>
  505. <p>If the correct value would cause overflow, <code class="constant">G_MAXINT64</code> or <code class="constant">G_MININT64</code>
  506. is returned, and <code class="code">ERANGE</code> is stored in <code class="code">errno</code>.
  507. If the base is outside the valid range, zero is returned, and
  508. <code class="code">EINVAL</code> is stored in <code class="code">errno</code>. If the
  509. string conversion fails, zero is returned, and <em class="parameter"><code>endptr</code></em> returns <em class="parameter"><code>nptr</code></em>
  510. (if <em class="parameter"><code>endptr</code></em> is non-<code class="constant">NULL</code>).</p>
  511. <div class="refsect3">
  512. <a name="id-1.1.90.2.13.6"></a><h4>Parameters</h4>
  513. <div class="informaltable"><table>
  514. <tr>
  515. <td class="parameter_name"><p>nptr</p></td>
  516. <td class="parameter_description">
  517. <p>the string to convert to a numeric value.</p>
  518. <p>Passed as <code class="code">nptr</code></p>
  519. </td>
  520. </tr>
  521. <tr>
  522. <td class="parameter_name"><p>endptr</p></td>
  523. <td class="parameter_description">
  524. <p>if non-<code class="constant">NULL</code>, it returns the
  525. character after the last character used in the conversion.</p>
  526. <p>Passed as <code class="code">endptr</code></p>
  527. </td>
  528. </tr>
  529. <tr>
  530. <td class="parameter_name"><p>base</p></td>
  531. <td class="parameter_description">
  532. <p>to be used for the conversion, 2..36 or 0</p>
  533. <p>Passed as <code class="code">base</code></p>
  534. </td>
  535. </tr>
  536. </table></div>
  537. </div>
  538. </div>
  539. <div class="refsect2">
  540. <a name="id-1.1.90.2.14"></a><h3>ascii-strtoull</h3>
  541. <div class="informalexample"><pre class="programlisting">(define-values (%return endptr) (ascii-strtoull nptr base))
  542. </pre></div>
  543. <p>Converts a string to a <span class="type">guint64</span> value.
  544. This function behaves like the standard <code class="function">strtoull()</code> function
  545. does in the C locale. It does this without actually
  546. changing the current locale, since that would not be
  547. thread-safe.
  548. </p>
  549. <p>Note that input with a leading minus sign (<code class="code">-</code>) is accepted, and will return
  550. the negation of the parsed number, unless that would overflow a <span class="type">guint64</span>.
  551. Critically, this means you cannot assume that a short fixed length input will
  552. never result in a low return value, as the input could have a leading <code class="code">-</code>.
  553. </p>
  554. <p>This function is typically used when reading configuration
  555. files or other non-user input that should be locale independent.
  556. To handle input from the user you should normally use the
  557. locale-sensitive system <code class="function">strtoull()</code> function.
  558. </p>
  559. <p>If the correct value would cause overflow, <code class="constant">G_MAXUINT64</code>
  560. is returned, and <code class="code">ERANGE</code> is stored in <code class="code">errno</code>.
  561. If the base is outside the valid range, zero is returned, and
  562. <code class="code">EINVAL</code> is stored in <code class="code">errno</code>.
  563. If the string conversion fails, zero is returned, and <em class="parameter"><code>endptr</code></em> returns
  564. <em class="parameter"><code>nptr</code></em> (if <em class="parameter"><code>endptr</code></em> is non-<code class="constant">NULL</code>).</p>
  565. <div class="refsect3">
  566. <a name="id-1.1.90.2.14.7"></a><h4>Parameters</h4>
  567. <div class="informaltable"><table>
  568. <tr>
  569. <td class="parameter_name"><p>nptr</p></td>
  570. <td class="parameter_description">
  571. <p>the string to convert to a numeric value.</p>
  572. <p>Passed as <code class="code">nptr</code></p>
  573. </td>
  574. </tr>
  575. <tr>
  576. <td class="parameter_name"><p>endptr</p></td>
  577. <td class="parameter_description">
  578. <p>if non-<code class="constant">NULL</code>, it returns the
  579. character after the last character used in the conversion.</p>
  580. <p>Passed as <code class="code">endptr</code></p>
  581. </td>
  582. </tr>
  583. <tr>
  584. <td class="parameter_name"><p>base</p></td>
  585. <td class="parameter_description">
  586. <p>to be used for the conversion, 2..36 or 0</p>
  587. <p>Passed as <code class="code">base</code></p>
  588. </td>
  589. </tr>
  590. </table></div>
  591. </div>
  592. </div>
  593. <div class="refsect2">
  594. <a name="id-1.1.90.2.15"></a><h3>ascii-strup</h3>
  595. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ascii-strup str len))
  596. </pre></div>
  597. <p>Converts all lower case ASCII letters to upper case ASCII letters.</p>
  598. <div class="refsect3">
  599. <a name="id-1.1.90.2.15.4"></a><h4>Parameters</h4>
  600. <div class="informaltable"><table>
  601. <tr>
  602. <td class="parameter_name"><p>str</p></td>
  603. <td class="parameter_description">
  604. <p>a string</p>
  605. <p>Passed as <code class="code">str</code></p>
  606. </td>
  607. </tr>
  608. <tr>
  609. <td class="parameter_name"><p>len</p></td>
  610. <td class="parameter_description">
  611. <p>length of <em class="parameter"><code>str</code></em> in bytes, or -1 if <em class="parameter"><code>str</code></em> is nul-terminated</p>
  612. <p>Passed as <code class="code">len</code></p>
  613. </td>
  614. </tr>
  615. </table></div>
  616. </div>
  617. </div>
  618. <div class="refsect2">
  619. <a name="id-1.1.90.2.16"></a><h3>ascii-tolower</h3>
  620. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ascii-tolower c))
  621. </pre></div>
  622. <p>Convert a character to ASCII lower case.
  623. </p>
  624. <p>Unlike the standard C library <code class="function">tolower()</code> function, this only
  625. recognizes standard ASCII letters and ignores the locale, returning
  626. all non-ASCII characters unchanged, even if they are lower case
  627. letters in a particular character set. Also unlike the standard
  628. library function, this takes and returns a char, not an int, so
  629. don't call it on <code class="constant">EOF</code> but no need to worry about casting to <span class="type">guchar</span>
  630. before passing a possibly non-ASCII character in.</p>
  631. <div class="refsect3">
  632. <a name="id-1.1.90.2.16.5"></a><h4>Parameters</h4>
  633. <div class="informaltable"><table><tr>
  634. <td class="parameter_name"><p>c</p></td>
  635. <td class="parameter_description">
  636. <p>any character</p>
  637. <p>Passed as <code class="code">c</code></p>
  638. </td>
  639. </tr></table></div>
  640. </div>
  641. </div>
  642. <div class="refsect2">
  643. <a name="id-1.1.90.2.17"></a><h3>ascii-toupper</h3>
  644. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ascii-toupper c))
  645. </pre></div>
  646. <p>Convert a character to ASCII upper case.
  647. </p>
  648. <p>Unlike the standard C library <code class="function">toupper()</code> function, this only
  649. recognizes standard ASCII letters and ignores the locale, returning
  650. all non-ASCII characters unchanged, even if they are upper case
  651. letters in a particular character set. Also unlike the standard
  652. library function, this takes and returns a char, not an int, so
  653. don't call it on <code class="constant">EOF</code> but no need to worry about casting to <span class="type">guchar</span>
  654. before passing a possibly non-ASCII character in.</p>
  655. <div class="refsect3">
  656. <a name="id-1.1.90.2.17.5"></a><h4>Parameters</h4>
  657. <div class="informaltable"><table><tr>
  658. <td class="parameter_name"><p>c</p></td>
  659. <td class="parameter_description">
  660. <p>any character</p>
  661. <p>Passed as <code class="code">c</code></p>
  662. </td>
  663. </tr></table></div>
  664. </div>
  665. </div>
  666. <div class="refsect2">
  667. <a name="id-1.1.90.2.18"></a><h3>ascii-xdigit-value</h3>
  668. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ascii-xdigit-value c))
  669. </pre></div>
  670. <p>Determines the numeric value of a character as a hexadecimal
  671. digit. Differs from <code class="function">g_unichar_xdigit_value()</code> because it takes
  672. a char, so there's no worry about sign extension if characters
  673. are signed.</p>
  674. <div class="refsect3">
  675. <a name="id-1.1.90.2.18.4"></a><h4>Parameters</h4>
  676. <div class="informaltable"><table><tr>
  677. <td class="parameter_name"><p>c</p></td>
  678. <td class="parameter_description">
  679. <p>an ASCII character.</p>
  680. <p>Passed as <code class="code">c</code></p>
  681. </td>
  682. </tr></table></div>
  683. </div>
  684. </div>
  685. <div class="refsect2">
  686. <a name="id-1.1.90.2.19"></a><h3>assert-warning</h3>
  687. <div class="informalexample"><pre class="programlisting">(define-values
  688. ()
  689. (assert-warning log-domain file line pretty-function expression))
  690. </pre></div>
  691. <p>Undocumented</p>
  692. <div class="refsect3">
  693. <a name="id-1.1.90.2.19.4"></a><h4>Parameters</h4>
  694. <div class="informaltable"><table>
  695. <tr>
  696. <td class="parameter_name"><p>log_domain</p></td>
  697. <td class="parameter_description">
  698. <p></p>
  699. <p>Passed as <code class="code">log-domain</code></p>
  700. </td>
  701. </tr>
  702. <tr>
  703. <td class="parameter_name"><p>file</p></td>
  704. <td class="parameter_description">
  705. <p></p>
  706. <p>Passed as <code class="code">file</code></p>
  707. </td>
  708. </tr>
  709. <tr>
  710. <td class="parameter_name"><p>line</p></td>
  711. <td class="parameter_description">
  712. <p></p>
  713. <p>Passed as <code class="code">line</code></p>
  714. </td>
  715. </tr>
  716. <tr>
  717. <td class="parameter_name"><p>pretty_function</p></td>
  718. <td class="parameter_description">
  719. <p></p>
  720. <p>Passed as <code class="code">pretty-function</code></p>
  721. </td>
  722. </tr>
  723. <tr>
  724. <td class="parameter_name"><p>expression</p></td>
  725. <td class="parameter_description">
  726. <p></p>
  727. <p>Passed as <code class="code">expression</code></p>
  728. </td>
  729. </tr>
  730. </table></div>
  731. </div>
  732. </div>
  733. <div class="refsect2">
  734. <a name="id-1.1.90.2.20"></a><h3>assertion-message</h3>
  735. <div class="informalexample"><pre class="programlisting">(define-values () (assertion-message domain file line func message))
  736. </pre></div>
  737. <p>Undocumented</p>
  738. <div class="refsect3">
  739. <a name="id-1.1.90.2.20.4"></a><h4>Parameters</h4>
  740. <div class="informaltable"><table>
  741. <tr>
  742. <td class="parameter_name"><p>domain</p></td>
  743. <td class="parameter_description">
  744. <p></p>
  745. <p>Passed as <code class="code">domain</code></p>
  746. </td>
  747. </tr>
  748. <tr>
  749. <td class="parameter_name"><p>file</p></td>
  750. <td class="parameter_description">
  751. <p></p>
  752. <p>Passed as <code class="code">file</code></p>
  753. </td>
  754. </tr>
  755. <tr>
  756. <td class="parameter_name"><p>line</p></td>
  757. <td class="parameter_description">
  758. <p></p>
  759. <p>Passed as <code class="code">line</code></p>
  760. </td>
  761. </tr>
  762. <tr>
  763. <td class="parameter_name"><p>func</p></td>
  764. <td class="parameter_description">
  765. <p></p>
  766. <p>Passed as <code class="code">func</code></p>
  767. </td>
  768. </tr>
  769. <tr>
  770. <td class="parameter_name"><p>message</p></td>
  771. <td class="parameter_description">
  772. <p></p>
  773. <p>Passed as <code class="code">message</code></p>
  774. </td>
  775. </tr>
  776. </table></div>
  777. </div>
  778. </div>
  779. <div class="refsect2">
  780. <a name="id-1.1.90.2.21"></a><h3>assertion-message-cmpstr</h3>
  781. <div class="informalexample"><pre class="programlisting">(define-values
  782. ()
  783. (assertion-message-cmpstr domain file line func expr arg1 cmp arg2))
  784. </pre></div>
  785. <p>Undocumented</p>
  786. <div class="refsect3">
  787. <a name="id-1.1.90.2.21.4"></a><h4>Parameters</h4>
  788. <div class="informaltable"><table>
  789. <tr>
  790. <td class="parameter_name"><p>domain</p></td>
  791. <td class="parameter_description">
  792. <p></p>
  793. <p>Passed as <code class="code">domain</code></p>
  794. </td>
  795. </tr>
  796. <tr>
  797. <td class="parameter_name"><p>file</p></td>
  798. <td class="parameter_description">
  799. <p></p>
  800. <p>Passed as <code class="code">file</code></p>
  801. </td>
  802. </tr>
  803. <tr>
  804. <td class="parameter_name"><p>line</p></td>
  805. <td class="parameter_description">
  806. <p></p>
  807. <p>Passed as <code class="code">line</code></p>
  808. </td>
  809. </tr>
  810. <tr>
  811. <td class="parameter_name"><p>func</p></td>
  812. <td class="parameter_description">
  813. <p></p>
  814. <p>Passed as <code class="code">func</code></p>
  815. </td>
  816. </tr>
  817. <tr>
  818. <td class="parameter_name"><p>expr</p></td>
  819. <td class="parameter_description">
  820. <p></p>
  821. <p>Passed as <code class="code">expr</code></p>
  822. </td>
  823. </tr>
  824. <tr>
  825. <td class="parameter_name"><p>arg1</p></td>
  826. <td class="parameter_description">
  827. <p></p>
  828. <p>Passed as <code class="code">arg1</code></p>
  829. </td>
  830. </tr>
  831. <tr>
  832. <td class="parameter_name"><p>cmp</p></td>
  833. <td class="parameter_description">
  834. <p></p>
  835. <p>Passed as <code class="code">cmp</code></p>
  836. </td>
  837. </tr>
  838. <tr>
  839. <td class="parameter_name"><p>arg2</p></td>
  840. <td class="parameter_description">
  841. <p></p>
  842. <p>Passed as <code class="code">arg2</code></p>
  843. </td>
  844. </tr>
  845. </table></div>
  846. </div>
  847. </div>
  848. <div class="refsect2">
  849. <a name="id-1.1.90.2.22"></a><h3>assertion-message-cmpstrv</h3>
  850. <div class="informalexample"><pre class="programlisting">(define-values
  851. ()
  852. (assertion-message-cmpstrv
  853. domain
  854. file
  855. line
  856. func
  857. expr
  858. arg1
  859. arg2
  860. first-wrong-idx))
  861. </pre></div>
  862. <p>Undocumented</p>
  863. <div class="refsect3">
  864. <a name="id-1.1.90.2.22.4"></a><h4>Parameters</h4>
  865. <div class="informaltable"><table>
  866. <tr>
  867. <td class="parameter_name"><p>domain</p></td>
  868. <td class="parameter_description">
  869. <p></p>
  870. <p>Passed as <code class="code">domain</code></p>
  871. </td>
  872. </tr>
  873. <tr>
  874. <td class="parameter_name"><p>file</p></td>
  875. <td class="parameter_description">
  876. <p></p>
  877. <p>Passed as <code class="code">file</code></p>
  878. </td>
  879. </tr>
  880. <tr>
  881. <td class="parameter_name"><p>line</p></td>
  882. <td class="parameter_description">
  883. <p></p>
  884. <p>Passed as <code class="code">line</code></p>
  885. </td>
  886. </tr>
  887. <tr>
  888. <td class="parameter_name"><p>func</p></td>
  889. <td class="parameter_description">
  890. <p></p>
  891. <p>Passed as <code class="code">func</code></p>
  892. </td>
  893. </tr>
  894. <tr>
  895. <td class="parameter_name"><p>expr</p></td>
  896. <td class="parameter_description">
  897. <p></p>
  898. <p>Passed as <code class="code">expr</code></p>
  899. </td>
  900. </tr>
  901. <tr>
  902. <td class="parameter_name"><p>arg1</p></td>
  903. <td class="parameter_description">
  904. <p></p>
  905. <p>Passed as <code class="code">arg1</code></p>
  906. </td>
  907. </tr>
  908. <tr>
  909. <td class="parameter_name"><p>arg2</p></td>
  910. <td class="parameter_description">
  911. <p></p>
  912. <p>Passed as <code class="code">arg2</code></p>
  913. </td>
  914. </tr>
  915. <tr>
  916. <td class="parameter_name"><p>first_wrong_idx</p></td>
  917. <td class="parameter_description">
  918. <p></p>
  919. <p>Passed as <code class="code">first-wrong-idx</code></p>
  920. </td>
  921. </tr>
  922. </table></div>
  923. </div>
  924. </div>
  925. <div class="refsect2">
  926. <a name="id-1.1.90.2.23"></a><h3>assertion-message-error</h3>
  927. <div class="informalexample"><pre class="programlisting">(define-values
  928. ()
  929. (assertion-message-error
  930. domain
  931. file
  932. line
  933. func
  934. expr
  935. error
  936. error-domain
  937. error-code))
  938. </pre></div>
  939. <p>Undocumented</p>
  940. <div class="refsect3">
  941. <a name="id-1.1.90.2.23.4"></a><h4>Parameters</h4>
  942. <div class="informaltable"><table>
  943. <tr>
  944. <td class="parameter_name"><p>domain</p></td>
  945. <td class="parameter_description">
  946. <p></p>
  947. <p>Passed as <code class="code">domain</code></p>
  948. </td>
  949. </tr>
  950. <tr>
  951. <td class="parameter_name"><p>file</p></td>
  952. <td class="parameter_description">
  953. <p></p>
  954. <p>Passed as <code class="code">file</code></p>
  955. </td>
  956. </tr>
  957. <tr>
  958. <td class="parameter_name"><p>line</p></td>
  959. <td class="parameter_description">
  960. <p></p>
  961. <p>Passed as <code class="code">line</code></p>
  962. </td>
  963. </tr>
  964. <tr>
  965. <td class="parameter_name"><p>func</p></td>
  966. <td class="parameter_description">
  967. <p></p>
  968. <p>Passed as <code class="code">func</code></p>
  969. </td>
  970. </tr>
  971. <tr>
  972. <td class="parameter_name"><p>expr</p></td>
  973. <td class="parameter_description">
  974. <p></p>
  975. <p>Passed as <code class="code">expr</code></p>
  976. </td>
  977. </tr>
  978. <tr>
  979. <td class="parameter_name"><p>error</p></td>
  980. <td class="parameter_description">
  981. <p></p>
  982. <p>Passed as <code class="code">error</code></p>
  983. </td>
  984. </tr>
  985. <tr>
  986. <td class="parameter_name"><p>error_domain</p></td>
  987. <td class="parameter_description">
  988. <p></p>
  989. <p>Passed as <code class="code">error-domain</code></p>
  990. </td>
  991. </tr>
  992. <tr>
  993. <td class="parameter_name"><p>error_code</p></td>
  994. <td class="parameter_description">
  995. <p></p>
  996. <p>Passed as <code class="code">error-code</code></p>
  997. </td>
  998. </tr>
  999. </table></div>
  1000. </div>
  1001. </div>
  1002. <div class="refsect2">
  1003. <a name="id-1.1.90.2.24"></a><h3>atomic-int-add</h3>
  1004. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-int-add atomic val))
  1005. </pre></div>
  1006. <p>Atomically adds <em class="parameter"><code>val</code></em> to the value of <em class="parameter"><code>atomic</code></em>.
  1007. </p>
  1008. <p>Think of this operation as an atomic version of
  1009. <code class="code">{ tmp = *atomic; *atomic += val; return tmp; }</code>.
  1010. </p>
  1011. <p>This call acts as a full compiler and hardware memory barrier.
  1012. </p>
  1013. <p>Before version 2.30, this function did not return a value
  1014. (but <code class="function">g_atomic_int_exchange_and_add()</code> did, and had the same meaning).</p>
  1015. <div class="refsect3">
  1016. <a name="id-1.1.90.2.24.7"></a><h4>Parameters</h4>
  1017. <div class="informaltable"><table>
  1018. <tr>
  1019. <td class="parameter_name"><p>atomic</p></td>
  1020. <td class="parameter_description">
  1021. <p>a pointer to a <span class="type">gint</span> or <span class="type">guint</span></p>
  1022. <p>Passed as <code class="code">atomic</code></p>
  1023. </td>
  1024. </tr>
  1025. <tr>
  1026. <td class="parameter_name"><p>val</p></td>
  1027. <td class="parameter_description">
  1028. <p>the value to add</p>
  1029. <p>Passed as <code class="code">val</code></p>
  1030. </td>
  1031. </tr>
  1032. </table></div>
  1033. </div>
  1034. </div>
  1035. <div class="refsect2">
  1036. <a name="id-1.1.90.2.25"></a><h3>atomic-int-and</h3>
  1037. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-int-and atomic val))
  1038. </pre></div>
  1039. <p>Performs an atomic bitwise 'and' of the value of <em class="parameter"><code>atomic</code></em> and <em class="parameter"><code>val</code></em>,
  1040. storing the result back in <em class="parameter"><code>atomic</code></em>.
  1041. </p>
  1042. <p>This call acts as a full compiler and hardware memory barrier.
  1043. </p>
  1044. <p>Think of this operation as an atomic version of
  1045. <code class="code">{ tmp = *atomic; *atomic &amp;= val; return tmp; }</code>.</p>
  1046. <div class="refsect3">
  1047. <a name="id-1.1.90.2.25.6"></a><h4>Parameters</h4>
  1048. <div class="informaltable"><table>
  1049. <tr>
  1050. <td class="parameter_name"><p>atomic</p></td>
  1051. <td class="parameter_description">
  1052. <p>a pointer to a <span class="type">gint</span> or <span class="type">guint</span></p>
  1053. <p>Passed as <code class="code">atomic</code></p>
  1054. </td>
  1055. </tr>
  1056. <tr>
  1057. <td class="parameter_name"><p>val</p></td>
  1058. <td class="parameter_description">
  1059. <p>the value to 'and'</p>
  1060. <p>Passed as <code class="code">val</code></p>
  1061. </td>
  1062. </tr>
  1063. </table></div>
  1064. </div>
  1065. </div>
  1066. <div class="refsect2">
  1067. <a name="id-1.1.90.2.26"></a><h3>atomic-int-compare-and-exchange?</h3>
  1068. <div class="informalexample"><pre class="programlisting">(define-values
  1069. (%return)
  1070. (atomic-int-compare-and-exchange? atomic oldval newval))
  1071. </pre></div>
  1072. <p>Compares <em class="parameter"><code>atomic</code></em> to <em class="parameter"><code>oldval</code></em> and, if equal, sets it to <em class="parameter"><code>newval</code></em>.
  1073. If <em class="parameter"><code>atomic</code></em> was not equal to <em class="parameter"><code>oldval</code></em> then no change occurs.
  1074. </p>
  1075. <p>This compare and exchange is done atomically.
  1076. </p>
  1077. <p>Think of this operation as an atomic version of
  1078. <code class="code">{ if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }</code>.
  1079. </p>
  1080. <p>This call acts as a full compiler and hardware memory barrier.</p>
  1081. <div class="refsect3">
  1082. <a name="id-1.1.90.2.26.7"></a><h4>Parameters</h4>
  1083. <div class="informaltable"><table>
  1084. <tr>
  1085. <td class="parameter_name"><p>atomic</p></td>
  1086. <td class="parameter_description">
  1087. <p>a pointer to a <span class="type">gint</span> or <span class="type">guint</span></p>
  1088. <p>Passed as <code class="code">atomic</code></p>
  1089. </td>
  1090. </tr>
  1091. <tr>
  1092. <td class="parameter_name"><p>oldval</p></td>
  1093. <td class="parameter_description">
  1094. <p>the value to compare with</p>
  1095. <p>Passed as <code class="code">oldval</code></p>
  1096. </td>
  1097. </tr>
  1098. <tr>
  1099. <td class="parameter_name"><p>newval</p></td>
  1100. <td class="parameter_description">
  1101. <p>the value to conditionally replace with</p>
  1102. <p>Passed as <code class="code">newval</code></p>
  1103. </td>
  1104. </tr>
  1105. </table></div>
  1106. </div>
  1107. </div>
  1108. <div class="refsect2">
  1109. <a name="id-1.1.90.2.27"></a><h3>atomic-int-dec-and-test?</h3>
  1110. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-int-dec-and-test? atomic))
  1111. </pre></div>
  1112. <p>Decrements the value of <em class="parameter"><code>atomic</code></em> by 1.
  1113. </p>
  1114. <p>Think of this operation as an atomic version of
  1115. <code class="code">{ *atomic -= 1; return (*atomic == 0); }</code>.
  1116. </p>
  1117. <p>This call acts as a full compiler and hardware memory barrier.</p>
  1118. <div class="refsect3">
  1119. <a name="id-1.1.90.2.27.6"></a><h4>Parameters</h4>
  1120. <div class="informaltable"><table><tr>
  1121. <td class="parameter_name"><p>atomic</p></td>
  1122. <td class="parameter_description">
  1123. <p>a pointer to a <span class="type">gint</span> or <span class="type">guint</span></p>
  1124. <p>Passed as <code class="code">atomic</code></p>
  1125. </td>
  1126. </tr></table></div>
  1127. </div>
  1128. </div>
  1129. <div class="refsect2">
  1130. <a name="id-1.1.90.2.28"></a><h3>atomic-int-get</h3>
  1131. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-int-get atomic))
  1132. </pre></div>
  1133. <p>Gets the current value of <em class="parameter"><code>atomic</code></em>.
  1134. </p>
  1135. <p>This call acts as a full compiler and hardware
  1136. memory barrier (before the get).</p>
  1137. <div class="refsect3">
  1138. <a name="id-1.1.90.2.28.5"></a><h4>Parameters</h4>
  1139. <div class="informaltable"><table><tr>
  1140. <td class="parameter_name"><p>atomic</p></td>
  1141. <td class="parameter_description">
  1142. <p>a pointer to a <span class="type">gint</span> or <span class="type">guint</span></p>
  1143. <p>Passed as <code class="code">atomic</code></p>
  1144. </td>
  1145. </tr></table></div>
  1146. </div>
  1147. </div>
  1148. <div class="refsect2">
  1149. <a name="id-1.1.90.2.29"></a><h3>atomic-int-inc</h3>
  1150. <div class="informalexample"><pre class="programlisting">(define-values () (atomic-int-inc atomic))
  1151. </pre></div>
  1152. <p>Increments the value of <em class="parameter"><code>atomic</code></em> by 1.
  1153. </p>
  1154. <p>Think of this operation as an atomic version of <code class="code">{ *atomic += 1; }</code>.
  1155. </p>
  1156. <p>This call acts as a full compiler and hardware memory barrier.</p>
  1157. <div class="refsect3">
  1158. <a name="id-1.1.90.2.29.6"></a><h4>Parameters</h4>
  1159. <div class="informaltable"><table><tr>
  1160. <td class="parameter_name"><p>atomic</p></td>
  1161. <td class="parameter_description">
  1162. <p>a pointer to a <span class="type">gint</span> or <span class="type">guint</span></p>
  1163. <p>Passed as <code class="code">atomic</code></p>
  1164. </td>
  1165. </tr></table></div>
  1166. </div>
  1167. </div>
  1168. <div class="refsect2">
  1169. <a name="id-1.1.90.2.30"></a><h3>atomic-int-or</h3>
  1170. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-int-or atomic val))
  1171. </pre></div>
  1172. <p>Performs an atomic bitwise 'or' of the value of <em class="parameter"><code>atomic</code></em> and <em class="parameter"><code>val</code></em>,
  1173. storing the result back in <em class="parameter"><code>atomic</code></em>.
  1174. </p>
  1175. <p>Think of this operation as an atomic version of
  1176. <code class="code">{ tmp = *atomic; *atomic |= val; return tmp; }</code>.
  1177. </p>
  1178. <p>This call acts as a full compiler and hardware memory barrier.</p>
  1179. <div class="refsect3">
  1180. <a name="id-1.1.90.2.30.6"></a><h4>Parameters</h4>
  1181. <div class="informaltable"><table>
  1182. <tr>
  1183. <td class="parameter_name"><p>atomic</p></td>
  1184. <td class="parameter_description">
  1185. <p>a pointer to a <span class="type">gint</span> or <span class="type">guint</span></p>
  1186. <p>Passed as <code class="code">atomic</code></p>
  1187. </td>
  1188. </tr>
  1189. <tr>
  1190. <td class="parameter_name"><p>val</p></td>
  1191. <td class="parameter_description">
  1192. <p>the value to 'or'</p>
  1193. <p>Passed as <code class="code">val</code></p>
  1194. </td>
  1195. </tr>
  1196. </table></div>
  1197. </div>
  1198. </div>
  1199. <div class="refsect2">
  1200. <a name="id-1.1.90.2.31"></a><h3>atomic-int-set</h3>
  1201. <div class="informalexample"><pre class="programlisting">(define-values () (atomic-int-set atomic newval))
  1202. </pre></div>
  1203. <p>Sets the value of <em class="parameter"><code>atomic</code></em> to <em class="parameter"><code>newval</code></em>.
  1204. </p>
  1205. <p>This call acts as a full compiler and hardware
  1206. memory barrier (after the set).</p>
  1207. <div class="refsect3">
  1208. <a name="id-1.1.90.2.31.5"></a><h4>Parameters</h4>
  1209. <div class="informaltable"><table>
  1210. <tr>
  1211. <td class="parameter_name"><p>atomic</p></td>
  1212. <td class="parameter_description">
  1213. <p>a pointer to a <span class="type">gint</span> or <span class="type">guint</span></p>
  1214. <p>Passed as <code class="code">atomic</code></p>
  1215. </td>
  1216. </tr>
  1217. <tr>
  1218. <td class="parameter_name"><p>newval</p></td>
  1219. <td class="parameter_description">
  1220. <p>a new value to store</p>
  1221. <p>Passed as <code class="code">newval</code></p>
  1222. </td>
  1223. </tr>
  1224. </table></div>
  1225. </div>
  1226. </div>
  1227. <div class="refsect2">
  1228. <a name="id-1.1.90.2.32"></a><h3>atomic-int-xor</h3>
  1229. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-int-xor atomic val))
  1230. </pre></div>
  1231. <p>Performs an atomic bitwise 'xor' of the value of <em class="parameter"><code>atomic</code></em> and <em class="parameter"><code>val</code></em>,
  1232. storing the result back in <em class="parameter"><code>atomic</code></em>.
  1233. </p>
  1234. <p>Think of this operation as an atomic version of
  1235. <code class="code">{ tmp = *atomic; *atomic ^= val; return tmp; }</code>.
  1236. </p>
  1237. <p>This call acts as a full compiler and hardware memory barrier.</p>
  1238. <div class="refsect3">
  1239. <a name="id-1.1.90.2.32.6"></a><h4>Parameters</h4>
  1240. <div class="informaltable"><table>
  1241. <tr>
  1242. <td class="parameter_name"><p>atomic</p></td>
  1243. <td class="parameter_description">
  1244. <p>a pointer to a <span class="type">gint</span> or <span class="type">guint</span></p>
  1245. <p>Passed as <code class="code">atomic</code></p>
  1246. </td>
  1247. </tr>
  1248. <tr>
  1249. <td class="parameter_name"><p>val</p></td>
  1250. <td class="parameter_description">
  1251. <p>the value to 'xor'</p>
  1252. <p>Passed as <code class="code">val</code></p>
  1253. </td>
  1254. </tr>
  1255. </table></div>
  1256. </div>
  1257. </div>
  1258. <div class="refsect2">
  1259. <a name="id-1.1.90.2.33"></a><h3>atomic-pointer-add</h3>
  1260. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-pointer-add atomic val))
  1261. </pre></div>
  1262. <p>Atomically adds <em class="parameter"><code>val</code></em> to the value of <em class="parameter"><code>atomic</code></em>.
  1263. </p>
  1264. <p>Think of this operation as an atomic version of
  1265. <code class="code">{ tmp = *atomic; *atomic += val; return tmp; }</code>.
  1266. </p>
  1267. <p>This call acts as a full compiler and hardware memory barrier.</p>
  1268. <div class="refsect3">
  1269. <a name="id-1.1.90.2.33.6"></a><h4>Parameters</h4>
  1270. <div class="informaltable"><table>
  1271. <tr>
  1272. <td class="parameter_name"><p>atomic</p></td>
  1273. <td class="parameter_description">
  1274. <p>a pointer to a <span class="type">gpointer</span>-sized value</p>
  1275. <p>Passed as <code class="code">atomic</code></p>
  1276. </td>
  1277. </tr>
  1278. <tr>
  1279. <td class="parameter_name"><p>val</p></td>
  1280. <td class="parameter_description">
  1281. <p>the value to add</p>
  1282. <p>Passed as <code class="code">val</code></p>
  1283. </td>
  1284. </tr>
  1285. </table></div>
  1286. </div>
  1287. </div>
  1288. <div class="refsect2">
  1289. <a name="id-1.1.90.2.34"></a><h3>atomic-pointer-and</h3>
  1290. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-pointer-and atomic val))
  1291. </pre></div>
  1292. <p>Performs an atomic bitwise 'and' of the value of <em class="parameter"><code>atomic</code></em> and <em class="parameter"><code>val</code></em>,
  1293. storing the result back in <em class="parameter"><code>atomic</code></em>.
  1294. </p>
  1295. <p>Think of this operation as an atomic version of
  1296. <code class="code">{ tmp = *atomic; *atomic &amp;= val; return tmp; }</code>.
  1297. </p>
  1298. <p>This call acts as a full compiler and hardware memory barrier.</p>
  1299. <div class="refsect3">
  1300. <a name="id-1.1.90.2.34.6"></a><h4>Parameters</h4>
  1301. <div class="informaltable"><table>
  1302. <tr>
  1303. <td class="parameter_name"><p>atomic</p></td>
  1304. <td class="parameter_description">
  1305. <p>a pointer to a <span class="type">gpointer</span>-sized value</p>
  1306. <p>Passed as <code class="code">atomic</code></p>
  1307. </td>
  1308. </tr>
  1309. <tr>
  1310. <td class="parameter_name"><p>val</p></td>
  1311. <td class="parameter_description">
  1312. <p>the value to 'and'</p>
  1313. <p>Passed as <code class="code">val</code></p>
  1314. </td>
  1315. </tr>
  1316. </table></div>
  1317. </div>
  1318. </div>
  1319. <div class="refsect2">
  1320. <a name="id-1.1.90.2.35"></a><h3>atomic-pointer-compare-and-exchange?</h3>
  1321. <div class="informalexample"><pre class="programlisting">(define-values
  1322. (%return)
  1323. (atomic-pointer-compare-and-exchange? atomic oldval newval))
  1324. </pre></div>
  1325. <p>Compares <em class="parameter"><code>atomic</code></em> to <em class="parameter"><code>oldval</code></em> and, if equal, sets it to <em class="parameter"><code>newval</code></em>.
  1326. If <em class="parameter"><code>atomic</code></em> was not equal to <em class="parameter"><code>oldval</code></em> then no change occurs.
  1327. </p>
  1328. <p>This compare and exchange is done atomically.
  1329. </p>
  1330. <p>Think of this operation as an atomic version of
  1331. <code class="code">{ if (*atomic == oldval) { *atomic = newval; return TRUE; } else return FALSE; }</code>.
  1332. </p>
  1333. <p>This call acts as a full compiler and hardware memory barrier.</p>
  1334. <div class="refsect3">
  1335. <a name="id-1.1.90.2.35.7"></a><h4>Parameters</h4>
  1336. <div class="informaltable"><table>
  1337. <tr>
  1338. <td class="parameter_name"><p>atomic</p></td>
  1339. <td class="parameter_description">
  1340. <p>a pointer to a <span class="type">gpointer</span>-sized value</p>
  1341. <p>Passed as <code class="code">atomic</code></p>
  1342. </td>
  1343. </tr>
  1344. <tr>
  1345. <td class="parameter_name"><p>oldval</p></td>
  1346. <td class="parameter_description">
  1347. <p>the value to compare with</p>
  1348. <p>Passed as <code class="code">oldval</code></p>
  1349. </td>
  1350. </tr>
  1351. <tr>
  1352. <td class="parameter_name"><p>newval</p></td>
  1353. <td class="parameter_description">
  1354. <p>the value to conditionally replace with</p>
  1355. <p>Passed as <code class="code">newval</code></p>
  1356. </td>
  1357. </tr>
  1358. </table></div>
  1359. </div>
  1360. </div>
  1361. <div class="refsect2">
  1362. <a name="id-1.1.90.2.36"></a><h3>atomic-pointer-get</h3>
  1363. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-pointer-get atomic))
  1364. </pre></div>
  1365. <p>Gets the current value of <em class="parameter"><code>atomic</code></em>.
  1366. </p>
  1367. <p>This call acts as a full compiler and hardware
  1368. memory barrier (before the get).</p>
  1369. <div class="refsect3">
  1370. <a name="id-1.1.90.2.36.5"></a><h4>Parameters</h4>
  1371. <div class="informaltable"><table><tr>
  1372. <td class="parameter_name"><p>atomic</p></td>
  1373. <td class="parameter_description">
  1374. <p>a pointer to a <span class="type">gpointer</span>-sized value</p>
  1375. <p>Passed as <code class="code">atomic</code></p>
  1376. </td>
  1377. </tr></table></div>
  1378. </div>
  1379. </div>
  1380. <div class="refsect2">
  1381. <a name="id-1.1.90.2.37"></a><h3>atomic-pointer-or</h3>
  1382. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-pointer-or atomic val))
  1383. </pre></div>
  1384. <p>Performs an atomic bitwise 'or' of the value of <em class="parameter"><code>atomic</code></em> and <em class="parameter"><code>val</code></em>,
  1385. storing the result back in <em class="parameter"><code>atomic</code></em>.
  1386. </p>
  1387. <p>Think of this operation as an atomic version of
  1388. <code class="code">{ tmp = *atomic; *atomic |= val; return tmp; }</code>.
  1389. </p>
  1390. <p>This call acts as a full compiler and hardware memory barrier.</p>
  1391. <div class="refsect3">
  1392. <a name="id-1.1.90.2.37.6"></a><h4>Parameters</h4>
  1393. <div class="informaltable"><table>
  1394. <tr>
  1395. <td class="parameter_name"><p>atomic</p></td>
  1396. <td class="parameter_description">
  1397. <p>a pointer to a <span class="type">gpointer</span>-sized value</p>
  1398. <p>Passed as <code class="code">atomic</code></p>
  1399. </td>
  1400. </tr>
  1401. <tr>
  1402. <td class="parameter_name"><p>val</p></td>
  1403. <td class="parameter_description">
  1404. <p>the value to 'or'</p>
  1405. <p>Passed as <code class="code">val</code></p>
  1406. </td>
  1407. </tr>
  1408. </table></div>
  1409. </div>
  1410. </div>
  1411. <div class="refsect2">
  1412. <a name="id-1.1.90.2.38"></a><h3>atomic-pointer-set</h3>
  1413. <div class="informalexample"><pre class="programlisting">(define-values () (atomic-pointer-set atomic newval))
  1414. </pre></div>
  1415. <p>Sets the value of <em class="parameter"><code>atomic</code></em> to <em class="parameter"><code>newval</code></em>.
  1416. </p>
  1417. <p>This call acts as a full compiler and hardware
  1418. memory barrier (after the set).</p>
  1419. <div class="refsect3">
  1420. <a name="id-1.1.90.2.38.5"></a><h4>Parameters</h4>
  1421. <div class="informaltable"><table>
  1422. <tr>
  1423. <td class="parameter_name"><p>atomic</p></td>
  1424. <td class="parameter_description">
  1425. <p>a pointer to a <span class="type">gpointer</span>-sized value</p>
  1426. <p>Passed as <code class="code">atomic</code></p>
  1427. </td>
  1428. </tr>
  1429. <tr>
  1430. <td class="parameter_name"><p>newval</p></td>
  1431. <td class="parameter_description">
  1432. <p>a new value to store</p>
  1433. <p>Passed as <code class="code">newval</code></p>
  1434. </td>
  1435. </tr>
  1436. </table></div>
  1437. </div>
  1438. </div>
  1439. <div class="refsect2">
  1440. <a name="id-1.1.90.2.39"></a><h3>atomic-pointer-xor</h3>
  1441. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-pointer-xor atomic val))
  1442. </pre></div>
  1443. <p>Performs an atomic bitwise 'xor' of the value of <em class="parameter"><code>atomic</code></em> and <em class="parameter"><code>val</code></em>,
  1444. storing the result back in <em class="parameter"><code>atomic</code></em>.
  1445. </p>
  1446. <p>Think of this operation as an atomic version of
  1447. <code class="code">{ tmp = *atomic; *atomic ^= val; return tmp; }</code>.
  1448. </p>
  1449. <p>This call acts as a full compiler and hardware memory barrier.</p>
  1450. <div class="refsect3">
  1451. <a name="id-1.1.90.2.39.6"></a><h4>Parameters</h4>
  1452. <div class="informaltable"><table>
  1453. <tr>
  1454. <td class="parameter_name"><p>atomic</p></td>
  1455. <td class="parameter_description">
  1456. <p>a pointer to a <span class="type">gpointer</span>-sized value</p>
  1457. <p>Passed as <code class="code">atomic</code></p>
  1458. </td>
  1459. </tr>
  1460. <tr>
  1461. <td class="parameter_name"><p>val</p></td>
  1462. <td class="parameter_description">
  1463. <p>the value to 'xor'</p>
  1464. <p>Passed as <code class="code">val</code></p>
  1465. </td>
  1466. </tr>
  1467. </table></div>
  1468. </div>
  1469. </div>
  1470. <div class="refsect2">
  1471. <a name="id-1.1.90.2.40"></a><h3>atomic-rc-box-acquire</h3>
  1472. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-rc-box-acquire mem-block))
  1473. </pre></div>
  1474. <p>Atomically acquires a reference on the data pointed by <em class="parameter"><code>mem_block</code></em>.</p>
  1475. <div class="refsect3">
  1476. <a name="id-1.1.90.2.40.4"></a><h4>Parameters</h4>
  1477. <div class="informaltable"><table><tr>
  1478. <td class="parameter_name"><p>mem_block</p></td>
  1479. <td class="parameter_description">
  1480. <p>a pointer to reference counted data</p>
  1481. <p>Passed as <code class="code">mem-block</code></p>
  1482. </td>
  1483. </tr></table></div>
  1484. </div>
  1485. </div>
  1486. <div class="refsect2">
  1487. <a name="id-1.1.90.2.41"></a><h3>atomic-rc-box-alloc</h3>
  1488. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-rc-box-alloc block-size))
  1489. </pre></div>
  1490. <p>Allocates <em class="parameter"><code>block_size</code></em> bytes of memory, and adds atomic
  1491. reference counting semantics to it.
  1492. </p>
  1493. <p>The data will be freed when its reference count drops to
  1494. zero.
  1495. </p>
  1496. <p>The allocated data is guaranteed to be suitably aligned for any
  1497. built-in type.</p>
  1498. <div class="refsect3">
  1499. <a name="id-1.1.90.2.41.6"></a><h4>Parameters</h4>
  1500. <div class="informaltable"><table><tr>
  1501. <td class="parameter_name"><p>block_size</p></td>
  1502. <td class="parameter_description">
  1503. <p>the size of the allocation, must be greater than 0</p>
  1504. <p>Passed as <code class="code">block-size</code></p>
  1505. </td>
  1506. </tr></table></div>
  1507. </div>
  1508. </div>
  1509. <div class="refsect2">
  1510. <a name="id-1.1.90.2.42"></a><h3>atomic-rc-box-alloc0</h3>
  1511. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-rc-box-alloc0 block-size))
  1512. </pre></div>
  1513. <p>Allocates <em class="parameter"><code>block_size</code></em> bytes of memory, and adds atomic
  1514. reference counting semantics to it.
  1515. </p>
  1516. <p>The contents of the returned data is set to zero.
  1517. </p>
  1518. <p>The data will be freed when its reference count drops to
  1519. zero.
  1520. </p>
  1521. <p>The allocated data is guaranteed to be suitably aligned for any
  1522. built-in type.</p>
  1523. <div class="refsect3">
  1524. <a name="id-1.1.90.2.42.7"></a><h4>Parameters</h4>
  1525. <div class="informaltable"><table><tr>
  1526. <td class="parameter_name"><p>block_size</p></td>
  1527. <td class="parameter_description">
  1528. <p>the size of the allocation, must be greater than 0</p>
  1529. <p>Passed as <code class="code">block-size</code></p>
  1530. </td>
  1531. </tr></table></div>
  1532. </div>
  1533. </div>
  1534. <div class="refsect2">
  1535. <a name="id-1.1.90.2.43"></a><h3>atomic-rc-box-dup</h3>
  1536. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-rc-box-dup block-size mem-block))
  1537. </pre></div>
  1538. <p>Allocates a new block of data with atomic reference counting
  1539. semantics, and copies <em class="parameter"><code>block_size</code></em> bytes of <em class="parameter"><code>mem_block</code></em>
  1540. into it.</p>
  1541. <div class="refsect3">
  1542. <a name="id-1.1.90.2.43.4"></a><h4>Parameters</h4>
  1543. <div class="informaltable"><table>
  1544. <tr>
  1545. <td class="parameter_name"><p>block_size</p></td>
  1546. <td class="parameter_description">
  1547. <p>the number of bytes to copy, must be greater than 0</p>
  1548. <p>Passed as <code class="code">block-size</code></p>
  1549. </td>
  1550. </tr>
  1551. <tr>
  1552. <td class="parameter_name"><p>mem_block</p></td>
  1553. <td class="parameter_description">
  1554. <p>the memory to copy</p>
  1555. <p>Passed as <code class="code">mem-block</code></p>
  1556. </td>
  1557. </tr>
  1558. </table></div>
  1559. </div>
  1560. </div>
  1561. <div class="refsect2">
  1562. <a name="id-1.1.90.2.44"></a><h3>atomic-rc-box-get-size</h3>
  1563. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-rc-box-get-size mem-block))
  1564. </pre></div>
  1565. <p>Retrieves the size of the reference counted data pointed by <em class="parameter"><code>mem_block</code></em>.</p>
  1566. <div class="refsect3">
  1567. <a name="id-1.1.90.2.44.4"></a><h4>Parameters</h4>
  1568. <div class="informaltable"><table><tr>
  1569. <td class="parameter_name"><p>mem_block</p></td>
  1570. <td class="parameter_description">
  1571. <p>a pointer to reference counted data</p>
  1572. <p>Passed as <code class="code">mem-block</code></p>
  1573. </td>
  1574. </tr></table></div>
  1575. </div>
  1576. </div>
  1577. <div class="refsect2">
  1578. <a name="id-1.1.90.2.45"></a><h3>atomic-rc-box-release</h3>
  1579. <div class="informalexample"><pre class="programlisting">(define-values () (atomic-rc-box-release mem-block))
  1580. </pre></div>
  1581. <p>Atomically releases a reference on the data pointed by <em class="parameter"><code>mem_block</code></em>.
  1582. </p>
  1583. <p>If the reference was the last one, it will free the
  1584. resources allocated for <em class="parameter"><code>mem_block</code></em>.</p>
  1585. <div class="refsect3">
  1586. <a name="id-1.1.90.2.45.5"></a><h4>Parameters</h4>
  1587. <div class="informaltable"><table><tr>
  1588. <td class="parameter_name"><p>mem_block</p></td>
  1589. <td class="parameter_description">
  1590. <p>a pointer to reference counted data</p>
  1591. <p>Passed as <code class="code">mem-block</code></p>
  1592. </td>
  1593. </tr></table></div>
  1594. </div>
  1595. </div>
  1596. <div class="refsect2">
  1597. <a name="id-1.1.90.2.46"></a><h3>atomic-rc-box-release-full</h3>
  1598. <div class="informalexample"><pre class="programlisting">(define-values () (atomic-rc-box-release-full mem-block clear-func))
  1599. </pre></div>
  1600. <p>Atomically releases a reference on the data pointed by <em class="parameter"><code>mem_block</code></em>.
  1601. </p>
  1602. <p>If the reference was the last one, it will call <em class="parameter"><code>clear_func</code></em>
  1603. to clear the contents of <em class="parameter"><code>mem_block</code></em>, and then will free the
  1604. resources allocated for <em class="parameter"><code>mem_block</code></em>.</p>
  1605. <div class="refsect3">
  1606. <a name="id-1.1.90.2.46.5"></a><h4>Parameters</h4>
  1607. <div class="informaltable"><table>
  1608. <tr>
  1609. <td class="parameter_name"><p>mem_block</p></td>
  1610. <td class="parameter_description">
  1611. <p>a pointer to reference counted data</p>
  1612. <p>Passed as <code class="code">mem-block</code></p>
  1613. </td>
  1614. </tr>
  1615. <tr>
  1616. <td class="parameter_name"><p>clear_func</p></td>
  1617. <td class="parameter_description">
  1618. <p>a function to call when clearing the data</p>
  1619. <p>Passed as <code class="code">clear-func</code></p>
  1620. </td>
  1621. </tr>
  1622. </table></div>
  1623. </div>
  1624. </div>
  1625. <div class="refsect2">
  1626. <a name="id-1.1.90.2.47"></a><h3>atomic-ref-count-compare?</h3>
  1627. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-ref-count-compare? arc val))
  1628. </pre></div>
  1629. <p>Atomically compares the current value of <em class="parameter"><code>arc</code></em> with <em class="parameter"><code>val</code></em>.</p>
  1630. <div class="refsect3">
  1631. <a name="id-1.1.90.2.47.4"></a><h4>Parameters</h4>
  1632. <div class="informaltable"><table>
  1633. <tr>
  1634. <td class="parameter_name"><p>arc</p></td>
  1635. <td class="parameter_description">
  1636. <p>the address of an atomic reference count variable</p>
  1637. <p>Passed as <code class="code">arc</code></p>
  1638. </td>
  1639. </tr>
  1640. <tr>
  1641. <td class="parameter_name"><p>val</p></td>
  1642. <td class="parameter_description">
  1643. <p>the value to compare</p>
  1644. <p>Passed as <code class="code">val</code></p>
  1645. </td>
  1646. </tr>
  1647. </table></div>
  1648. </div>
  1649. </div>
  1650. <div class="refsect2">
  1651. <a name="id-1.1.90.2.48"></a><h3>atomic-ref-count-dec?</h3>
  1652. <div class="informalexample"><pre class="programlisting">(define-values (%return) (atomic-ref-count-dec? arc))
  1653. </pre></div>
  1654. <p>Atomically decreases the reference count.</p>
  1655. <div class="refsect3">
  1656. <a name="id-1.1.90.2.48.4"></a><h4>Parameters</h4>
  1657. <div class="informaltable"><table><tr>
  1658. <td class="parameter_name"><p>arc</p></td>
  1659. <td class="parameter_description">
  1660. <p>the address of an atomic reference count variable</p>
  1661. <p>Passed as <code class="code">arc</code></p>
  1662. </td>
  1663. </tr></table></div>
  1664. </div>
  1665. </div>
  1666. <div class="refsect2">
  1667. <a name="id-1.1.90.2.49"></a><h3>atomic-ref-count-inc</h3>
  1668. <div class="informalexample"><pre class="programlisting">(define-values () (atomic-ref-count-inc arc))
  1669. </pre></div>
  1670. <p>Atomically increases the reference count.</p>
  1671. <div class="refsect3">
  1672. <a name="id-1.1.90.2.49.4"></a><h4>Parameters</h4>
  1673. <div class="informaltable"><table><tr>
  1674. <td class="parameter_name"><p>arc</p></td>
  1675. <td class="parameter_description">
  1676. <p>the address of an atomic reference count variable</p>
  1677. <p>Passed as <code class="code">arc</code></p>
  1678. </td>
  1679. </tr></table></div>
  1680. </div>
  1681. </div>
  1682. <div class="refsect2">
  1683. <a name="id-1.1.90.2.50"></a><h3>atomic-ref-count-init</h3>
  1684. <div class="informalexample"><pre class="programlisting">(define-values () (atomic-ref-count-init arc))
  1685. </pre></div>
  1686. <p>Initializes a reference count variable.</p>
  1687. <div class="refsect3">
  1688. <a name="id-1.1.90.2.50.4"></a><h4>Parameters</h4>
  1689. <div class="informaltable"><table><tr>
  1690. <td class="parameter_name"><p>arc</p></td>
  1691. <td class="parameter_description">
  1692. <p>the address of an atomic reference count variable</p>
  1693. <p>Passed as <code class="code">arc</code></p>
  1694. </td>
  1695. </tr></table></div>
  1696. </div>
  1697. </div>
  1698. <div class="refsect2">
  1699. <a name="id-1.1.90.2.51"></a><h3>base64-decode</h3>
  1700. <div class="informalexample"><pre class="programlisting">(define-values (%return out-len) (base64-decode text))
  1701. </pre></div>
  1702. <p>Decode a sequence of Base-64 encoded text into binary data. Note
  1703. that the returned binary data is not necessarily zero-terminated,
  1704. so it should not be used as a character string.</p>
  1705. <div class="refsect3">
  1706. <a name="id-1.1.90.2.51.4"></a><h4>Parameters</h4>
  1707. <div class="informaltable"><table>
  1708. <tr>
  1709. <td class="parameter_name"><p>text</p></td>
  1710. <td class="parameter_description">
  1711. <p>zero-terminated string with base64 text to decode</p>
  1712. <p>Passed as <code class="code">text</code></p>
  1713. </td>
  1714. </tr>
  1715. <tr>
  1716. <td class="parameter_name"><p>out_len</p></td>
  1717. <td class="parameter_description">
  1718. <p>The length of the decoded data is written here</p>
  1719. <p>Inferred from <code class="code">%return</code></p>
  1720. </td>
  1721. </tr>
  1722. </table></div>
  1723. </div>
  1724. </div>
  1725. <div class="refsect2">
  1726. <a name="id-1.1.90.2.52"></a><h3>base64-decode-inplace!</h3>
  1727. <div class="informalexample"><pre class="programlisting">(define-values (%return text out-len) (base64-decode-inplace! text))
  1728. </pre></div>
  1729. <p>Decode a sequence of Base-64 encoded text into binary data
  1730. by overwriting the input data.</p>
  1731. <div class="refsect3">
  1732. <a name="id-1.1.90.2.52.4"></a><h4>Parameters</h4>
  1733. <div class="informaltable"><table>
  1734. <tr>
  1735. <td class="parameter_name"><p>text</p></td>
  1736. <td class="parameter_description">
  1737. <p>zero-terminated
  1738. string with base64 text to decode</p>
  1739. <p>Passed as <code class="code">text</code></p>
  1740. </td>
  1741. </tr>
  1742. <tr>
  1743. <td class="parameter_name"><p>out_len</p></td>
  1744. <td class="parameter_description">
  1745. <p>The length of the decoded data is written here</p>
  1746. <p>Inferred from <code class="code">text</code></p>
  1747. </td>
  1748. </tr>
  1749. </table></div>
  1750. </div>
  1751. </div>
  1752. <div class="refsect2">
  1753. <a name="id-1.1.90.2.53"></a><h3>base64-encode</h3>
  1754. <div class="informalexample"><pre class="programlisting">(define-values (%return) (base64-encode data))
  1755. </pre></div>
  1756. <p>Encode a sequence of binary data into its Base-64 stringified
  1757. representation.</p>
  1758. <div class="refsect3">
  1759. <a name="id-1.1.90.2.53.4"></a><h4>Parameters</h4>
  1760. <div class="informaltable"><table>
  1761. <tr>
  1762. <td class="parameter_name"><p>data</p></td>
  1763. <td class="parameter_description">
  1764. <p>the binary data to encode</p>
  1765. <p>Passed as <code class="code">data</code></p>
  1766. </td>
  1767. </tr>
  1768. <tr>
  1769. <td class="parameter_name"><p>len</p></td>
  1770. <td class="parameter_description">
  1771. <p>the length of <em class="parameter"><code>data</code></em></p>
  1772. <p>Inferred from <code class="code">data</code></p>
  1773. </td>
  1774. </tr>
  1775. </table></div>
  1776. </div>
  1777. </div>
  1778. <div class="refsect2">
  1779. <a name="id-1.1.90.2.54"></a><h3>base64-encode-close</h3>
  1780. <div class="informalexample"><pre class="programlisting">(define-values
  1781. (%return out state save)
  1782. (base64-encode-close break-lines state save))
  1783. </pre></div>
  1784. <p>Flush the status from a sequence of calls to <code class="function">g_base64_encode_step()</code>.
  1785. </p>
  1786. <p>The output buffer must be large enough to fit all the data that will
  1787. be written to it. It will need up to 4 bytes, or up to 5 bytes if
  1788. line-breaking is enabled.
  1789. </p>
  1790. <p>The <em class="parameter"><code>out</code></em> array will not be automatically nul-terminated.</p>
  1791. <div class="refsect3">
  1792. <a name="id-1.1.90.2.54.6"></a><h4>Parameters</h4>
  1793. <div class="informaltable"><table>
  1794. <tr>
  1795. <td class="parameter_name"><p>break_lines</p></td>
  1796. <td class="parameter_description">
  1797. <p>whether to break long lines</p>
  1798. <p>Passed as <code class="code">break-lines</code></p>
  1799. </td>
  1800. </tr>
  1801. <tr>
  1802. <td class="parameter_name"><p>out</p></td>
  1803. <td class="parameter_description">
  1804. <p>pointer to destination buffer</p>
  1805. <p>Passed as <code class="code">out</code></p>
  1806. </td>
  1807. </tr>
  1808. <tr>
  1809. <td class="parameter_name"><p>state</p></td>
  1810. <td class="parameter_description">
  1811. <p>Saved state from <code class="function">g_base64_encode_step()</code></p>
  1812. <p>Passed as <code class="code">state</code></p>
  1813. </td>
  1814. </tr>
  1815. <tr>
  1816. <td class="parameter_name"><p>save</p></td>
  1817. <td class="parameter_description">
  1818. <p>Saved state from <code class="function">g_base64_encode_step()</code></p>
  1819. <p>Passed as <code class="code">save</code></p>
  1820. </td>
  1821. </tr>
  1822. </table></div>
  1823. </div>
  1824. </div>
  1825. <div class="refsect2">
  1826. <a name="id-1.1.90.2.55"></a><h3>base64-encode-step</h3>
  1827. <div class="informalexample"><pre class="programlisting">(define-values
  1828. (%return out state save)
  1829. (base64-encode-step in break-lines state save))
  1830. </pre></div>
  1831. <p>Incrementally encode a sequence of binary data into its Base-64 stringified
  1832. representation. By calling this function multiple times you can convert
  1833. data in chunks to avoid having to have the full encoded data in memory.
  1834. </p>
  1835. <p>When all of the data has been converted you must call
  1836. <code class="function">g_base64_encode_close()</code> to flush the saved state.
  1837. </p>
  1838. <p>The output buffer must be large enough to fit all the data that will
  1839. be written to it. Due to the way base64 encodes you will need
  1840. at least: (<em class="parameter"><code>len</code></em> / 3 + 1) * 4 + 4 bytes (+ 4 may be needed in case of
  1841. non-zero state). If you enable line-breaking you will need at least:
  1842. ((<em class="parameter"><code>len</code></em> / 3 + 1) * 4 + 4) / 76 + 1 bytes of extra space.
  1843. </p>
  1844. <p><em class="parameter"><code>break_lines</code></em> is typically used when putting base64-encoded data in emails.
  1845. It breaks the lines at 76 columns instead of putting all of the text on
  1846. the same line. This avoids problems with long lines in the email system.
  1847. Note however that it breaks the lines with <code class="code">LF</code> characters, not
  1848. <code class="code">CR LF</code> sequences, so the result cannot be passed directly to SMTP
  1849. or certain other protocols.</p>
  1850. <div class="refsect3">
  1851. <a name="id-1.1.90.2.55.7"></a><h4>Parameters</h4>
  1852. <div class="informaltable"><table>
  1853. <tr>
  1854. <td class="parameter_name"><p>in</p></td>
  1855. <td class="parameter_description">
  1856. <p>the binary data to encode</p>
  1857. <p>Passed as <code class="code">in</code></p>
  1858. </td>
  1859. </tr>
  1860. <tr>
  1861. <td class="parameter_name"><p>len</p></td>
  1862. <td class="parameter_description">
  1863. <p>the length of <em class="parameter"><code>in</code></em></p>
  1864. <p>Inferred from <code class="code">in</code></p>
  1865. </td>
  1866. </tr>
  1867. <tr>
  1868. <td class="parameter_name"><p>break_lines</p></td>
  1869. <td class="parameter_description">
  1870. <p>whether to break long lines</p>
  1871. <p>Passed as <code class="code">break-lines</code></p>
  1872. </td>
  1873. </tr>
  1874. <tr>
  1875. <td class="parameter_name"><p>out</p></td>
  1876. <td class="parameter_description">
  1877. <p>pointer to destination buffer</p>
  1878. <p>Passed as <code class="code">out</code></p>
  1879. </td>
  1880. </tr>
  1881. <tr>
  1882. <td class="parameter_name"><p>state</p></td>
  1883. <td class="parameter_description">
  1884. <p>Saved state between steps, initialize to 0</p>
  1885. <p>Passed as <code class="code">state</code></p>
  1886. </td>
  1887. </tr>
  1888. <tr>
  1889. <td class="parameter_name"><p>save</p></td>
  1890. <td class="parameter_description">
  1891. <p>Saved state between steps, initialize to 0</p>
  1892. <p>Passed as <code class="code">save</code></p>
  1893. </td>
  1894. </tr>
  1895. </table></div>
  1896. </div>
  1897. </div>
  1898. <div class="refsect2">
  1899. <a name="id-1.1.90.2.56"></a><h3>bit-lock</h3>
  1900. <div class="informalexample"><pre class="programlisting">(define-values () (bit-lock address lock-bit))
  1901. </pre></div>
  1902. <p>Sets the indicated <em class="parameter"><code>lock_bit</code></em> in <em class="parameter"><code>address</code></em>. If the bit is already
  1903. set, this call will block until <code class="function">g_bit_unlock()</code> unsets the
  1904. corresponding bit.
  1905. </p>
  1906. <p>Attempting to lock on two different bits within the same integer is
  1907. not supported and will very probably cause deadlocks.
  1908. </p>
  1909. <p>The value of the bit that is set is (1u &lt;&lt; <em class="parameter"><code>bit</code></em>). If <em class="parameter"><code>bit</code></em> is not
  1910. between 0 and 31 then the result is undefined.
  1911. </p>
  1912. <p>This function accesses <em class="parameter"><code>address</code></em> atomically. All other accesses to
  1913. <em class="parameter"><code>address</code></em> must be atomic in order for this function to work
  1914. reliably.</p>
  1915. <div class="refsect3">
  1916. <a name="id-1.1.90.2.56.7"></a><h4>Parameters</h4>
  1917. <div class="informaltable"><table>
  1918. <tr>
  1919. <td class="parameter_name"><p>address</p></td>
  1920. <td class="parameter_description">
  1921. <p>a pointer to an integer</p>
  1922. <p>Passed as <code class="code">address</code></p>
  1923. </td>
  1924. </tr>
  1925. <tr>
  1926. <td class="parameter_name"><p>lock_bit</p></td>
  1927. <td class="parameter_description">
  1928. <p>a bit value between 0 and 31</p>
  1929. <p>Passed as <code class="code">lock-bit</code></p>
  1930. </td>
  1931. </tr>
  1932. </table></div>
  1933. </div>
  1934. </div>
  1935. <div class="refsect2">
  1936. <a name="id-1.1.90.2.57"></a><h3>bit-nth-lsf</h3>
  1937. <div class="informalexample"><pre class="programlisting">(define-values (%return) (bit-nth-lsf mask nth-bit))
  1938. </pre></div>
  1939. <p>Find the position of the first bit set in <em class="parameter"><code>mask</code></em>, searching
  1940. from (but not including) <em class="parameter"><code>nth_bit</code></em> upwards. Bits are numbered
  1941. from 0 (least significant) to sizeof(<span class="type">gulong</span>) * 8 - 1 (31 or 63,
  1942. usually). To start searching from the 0th bit, set <em class="parameter"><code>nth_bit</code></em> to -1.</p>
  1943. <div class="refsect3">
  1944. <a name="id-1.1.90.2.57.4"></a><h4>Parameters</h4>
  1945. <div class="informaltable"><table>
  1946. <tr>
  1947. <td class="parameter_name"><p>mask</p></td>
  1948. <td class="parameter_description">
  1949. <p>a <span class="type">gulong</span> containing flags</p>
  1950. <p>Passed as <code class="code">mask</code></p>
  1951. </td>
  1952. </tr>
  1953. <tr>
  1954. <td class="parameter_name"><p>nth_bit</p></td>
  1955. <td class="parameter_description">
  1956. <p>the index of the bit to start the search from</p>
  1957. <p>Passed as <code class="code">nth-bit</code></p>
  1958. </td>
  1959. </tr>
  1960. </table></div>
  1961. </div>
  1962. </div>
  1963. <div class="refsect2">
  1964. <a name="id-1.1.90.2.58"></a><h3>bit-nth-msf</h3>
  1965. <div class="informalexample"><pre class="programlisting">(define-values (%return) (bit-nth-msf mask nth-bit))
  1966. </pre></div>
  1967. <p>Find the position of the first bit set in <em class="parameter"><code>mask</code></em>, searching
  1968. from (but not including) <em class="parameter"><code>nth_bit</code></em> downwards. Bits are numbered
  1969. from 0 (least significant) to sizeof(<span class="type">gulong</span>) * 8 - 1 (31 or 63,
  1970. usually). To start searching from the last bit, set <em class="parameter"><code>nth_bit</code></em> to
  1971. -1 or GLIB_SIZEOF_LONG * 8.</p>
  1972. <div class="refsect3">
  1973. <a name="id-1.1.90.2.58.4"></a><h4>Parameters</h4>
  1974. <div class="informaltable"><table>
  1975. <tr>
  1976. <td class="parameter_name"><p>mask</p></td>
  1977. <td class="parameter_description">
  1978. <p>a <span class="type">gulong</span> containing flags</p>
  1979. <p>Passed as <code class="code">mask</code></p>
  1980. </td>
  1981. </tr>
  1982. <tr>
  1983. <td class="parameter_name"><p>nth_bit</p></td>
  1984. <td class="parameter_description">
  1985. <p>the index of the bit to start the search from</p>
  1986. <p>Passed as <code class="code">nth-bit</code></p>
  1987. </td>
  1988. </tr>
  1989. </table></div>
  1990. </div>
  1991. </div>
  1992. <div class="refsect2">
  1993. <a name="id-1.1.90.2.59"></a><h3>bit-storage</h3>
  1994. <div class="informalexample"><pre class="programlisting">(define-values (%return) (bit-storage number))
  1995. </pre></div>
  1996. <p>Gets the number of bits used to hold <em class="parameter"><code>number</code></em>,
  1997. e.g. if <em class="parameter"><code>number</code></em> is 4, 3 bits are needed.</p>
  1998. <div class="refsect3">
  1999. <a name="id-1.1.90.2.59.4"></a><h4>Parameters</h4>
  2000. <div class="informaltable"><table><tr>
  2001. <td class="parameter_name"><p>number</p></td>
  2002. <td class="parameter_description">
  2003. <p>a <span class="type">guint</span></p>
  2004. <p>Passed as <code class="code">number</code></p>
  2005. </td>
  2006. </tr></table></div>
  2007. </div>
  2008. </div>
  2009. <div class="refsect2">
  2010. <a name="id-1.1.90.2.60"></a><h3>bit-trylock?</h3>
  2011. <div class="informalexample"><pre class="programlisting">(define-values (%return) (bit-trylock? address lock-bit))
  2012. </pre></div>
  2013. <p>Sets the indicated <em class="parameter"><code>lock_bit</code></em> in <em class="parameter"><code>address</code></em>, returning <code class="constant">TRUE</code> if
  2014. successful. If the bit is already set, returns <code class="constant">FALSE</code> immediately.
  2015. </p>
  2016. <p>Attempting to lock on two different bits within the same integer is
  2017. not supported.
  2018. </p>
  2019. <p>The value of the bit that is set is (1u &lt;&lt; <em class="parameter"><code>bit</code></em>). If <em class="parameter"><code>bit</code></em> is not
  2020. between 0 and 31 then the result is undefined.
  2021. </p>
  2022. <p>This function accesses <em class="parameter"><code>address</code></em> atomically. All other accesses to
  2023. <em class="parameter"><code>address</code></em> must be atomic in order for this function to work
  2024. reliably.</p>
  2025. <div class="refsect3">
  2026. <a name="id-1.1.90.2.60.7"></a><h4>Parameters</h4>
  2027. <div class="informaltable"><table>
  2028. <tr>
  2029. <td class="parameter_name"><p>address</p></td>
  2030. <td class="parameter_description">
  2031. <p>a pointer to an integer</p>
  2032. <p>Passed as <code class="code">address</code></p>
  2033. </td>
  2034. </tr>
  2035. <tr>
  2036. <td class="parameter_name"><p>lock_bit</p></td>
  2037. <td class="parameter_description">
  2038. <p>a bit value between 0 and 31</p>
  2039. <p>Passed as <code class="code">lock-bit</code></p>
  2040. </td>
  2041. </tr>
  2042. </table></div>
  2043. </div>
  2044. </div>
  2045. <div class="refsect2">
  2046. <a name="id-1.1.90.2.61"></a><h3>bit-unlock</h3>
  2047. <div class="informalexample"><pre class="programlisting">(define-values () (bit-unlock address lock-bit))
  2048. </pre></div>
  2049. <p>Clears the indicated <em class="parameter"><code>lock_bit</code></em> in <em class="parameter"><code>address</code></em>. If another thread is
  2050. currently blocked in <code class="function">g_bit_lock()</code> on this same bit then it will be
  2051. woken up.
  2052. </p>
  2053. <p>This function accesses <em class="parameter"><code>address</code></em> atomically. All other accesses to
  2054. <em class="parameter"><code>address</code></em> must be atomic in order for this function to work
  2055. reliably.</p>
  2056. <div class="refsect3">
  2057. <a name="id-1.1.90.2.61.5"></a><h4>Parameters</h4>
  2058. <div class="informaltable"><table>
  2059. <tr>
  2060. <td class="parameter_name"><p>address</p></td>
  2061. <td class="parameter_description">
  2062. <p>a pointer to an integer</p>
  2063. <p>Passed as <code class="code">address</code></p>
  2064. </td>
  2065. </tr>
  2066. <tr>
  2067. <td class="parameter_name"><p>lock_bit</p></td>
  2068. <td class="parameter_description">
  2069. <p>a bit value between 0 and 31</p>
  2070. <p>Passed as <code class="code">lock-bit</code></p>
  2071. </td>
  2072. </tr>
  2073. </table></div>
  2074. </div>
  2075. </div>
  2076. <div class="refsect2">
  2077. <a name="id-1.1.90.2.62"></a><h3>bookmark-file-error-quark</h3>
  2078. <div class="informalexample"><pre class="programlisting">(define-values (%return) (bookmark-file-error-quark))
  2079. </pre></div>
  2080. <p>Undocumented</p>
  2081. </div>
  2082. <div class="refsect2">
  2083. <a name="id-1.1.90.2.63"></a><h3>build-filenamev</h3>
  2084. <div class="informalexample"><pre class="programlisting">(define-values (%return) (build-filenamev args))
  2085. </pre></div>
  2086. <p>Behaves exactly like <code class="function">g_build_filename()</code>, but takes the path elements
  2087. as a string array, instead of varargs. This function is mainly
  2088. meant for language bindings.</p>
  2089. <div class="refsect3">
  2090. <a name="id-1.1.90.2.63.4"></a><h4>Parameters</h4>
  2091. <div class="informaltable"><table><tr>
  2092. <td class="parameter_name"><p>args</p></td>
  2093. <td class="parameter_description">
  2094. <p><code class="constant">NULL</code>-terminated
  2095. array of strings containing the path elements.</p>
  2096. <p>Passed as <code class="code">args</code></p>
  2097. </td>
  2098. </tr></table></div>
  2099. </div>
  2100. </div>
  2101. <div class="refsect2">
  2102. <a name="id-1.1.90.2.64"></a><h3>build-pathv</h3>
  2103. <div class="informalexample"><pre class="programlisting">(define-values (%return) (build-pathv separator args))
  2104. </pre></div>
  2105. <p>Behaves exactly like <code class="function">g_build_path()</code>, but takes the path elements
  2106. as a string array, instead of varargs. This function is mainly
  2107. meant for language bindings.</p>
  2108. <div class="refsect3">
  2109. <a name="id-1.1.90.2.64.4"></a><h4>Parameters</h4>
  2110. <div class="informaltable"><table>
  2111. <tr>
  2112. <td class="parameter_name"><p>separator</p></td>
  2113. <td class="parameter_description">
  2114. <p>a string used to separator the elements of the path.</p>
  2115. <p>Passed as <code class="code">separator</code></p>
  2116. </td>
  2117. </tr>
  2118. <tr>
  2119. <td class="parameter_name"><p>args</p></td>
  2120. <td class="parameter_description">
  2121. <p><code class="constant">NULL</code>-terminated
  2122. array of strings containing the path elements.</p>
  2123. <p>Passed as <code class="code">args</code></p>
  2124. </td>
  2125. </tr>
  2126. </table></div>
  2127. </div>
  2128. </div>
  2129. <div class="refsect2">
  2130. <a name="id-1.1.90.2.65"></a><h3>byte-array-free</h3>
  2131. <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array-free array free-segment))
  2132. </pre></div>
  2133. <p>Frees the memory allocated by the <span class="type">GByteArray</span>. If <em class="parameter"><code>free_segment</code></em> is
  2134. <code class="constant">TRUE</code> it frees the actual byte data. If the reference count of
  2135. <em class="parameter"><code>array</code></em> is greater than one, the <span class="type">GByteArray</span> wrapper is preserved but
  2136. the size of <em class="parameter"><code>array</code></em> will be set to zero.</p>
  2137. <div class="refsect3">
  2138. <a name="id-1.1.90.2.65.4"></a><h4>Parameters</h4>
  2139. <div class="informaltable"><table>
  2140. <tr>
  2141. <td class="parameter_name"><p>array</p></td>
  2142. <td class="parameter_description">
  2143. <p>a <span class="type">GByteArray</span></p>
  2144. <p>Passed as <code class="code">array</code></p>
  2145. </td>
  2146. </tr>
  2147. <tr>
  2148. <td class="parameter_name"><p>free_segment</p></td>
  2149. <td class="parameter_description">
  2150. <p>if <code class="constant">TRUE</code> the actual byte data is freed as well</p>
  2151. <p>Passed as <code class="code">free-segment</code></p>
  2152. </td>
  2153. </tr>
  2154. </table></div>
  2155. </div>
  2156. </div>
  2157. <div class="refsect2">
  2158. <a name="id-1.1.90.2.66"></a><h3>byte-array-free-to-bytes</h3>
  2159. <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array-free-to-bytes array))
  2160. </pre></div>
  2161. <p>Transfers the data from the <span class="type">GByteArray</span> into a new immutable <span class="type">GBytes</span>.
  2162. </p>
  2163. <p>The <span class="type">GByteArray</span> is freed unless the reference count of <em class="parameter"><code>array</code></em> is greater
  2164. than one, the <span class="type">GByteArray</span> wrapper is preserved but the size of <em class="parameter"><code>array</code></em>
  2165. will be set to zero.
  2166. </p>
  2167. <p>This is identical to using <code class="function">g_bytes_new_take()</code> and <code class="function">g_byte_array_free()</code>
  2168. together.</p>
  2169. <div class="refsect3">
  2170. <a name="id-1.1.90.2.66.6"></a><h4>Parameters</h4>
  2171. <div class="informaltable"><table><tr>
  2172. <td class="parameter_name"><p>array</p></td>
  2173. <td class="parameter_description">
  2174. <p>a <span class="type">GByteArray</span></p>
  2175. <p>Passed as <code class="code">array</code></p>
  2176. </td>
  2177. </tr></table></div>
  2178. </div>
  2179. </div>
  2180. <div class="refsect2">
  2181. <a name="id-1.1.90.2.67"></a><h3>byte-array-new</h3>
  2182. <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array-new))
  2183. </pre></div>
  2184. <p>Creates a new <span class="type">GByteArray</span> with a reference count of 1.</p>
  2185. </div>
  2186. <div class="refsect2">
  2187. <a name="id-1.1.90.2.68"></a><h3>byte-array-new-take</h3>
  2188. <div class="informalexample"><pre class="programlisting">(define-values (%return) (byte-array-new-take data))
  2189. </pre></div>
  2190. <p>Create byte array containing the data. The data will be owned by the array
  2191. and will be freed with <code class="function">g_free()</code>, i.e. it could be allocated using <code class="function">g_strdup()</code>.</p>
  2192. <div class="refsect3">
  2193. <a name="id-1.1.90.2.68.4"></a><h4>Parameters</h4>
  2194. <div class="informaltable"><table>
  2195. <tr>
  2196. <td class="parameter_name"><p>data</p></td>
  2197. <td class="parameter_description">
  2198. <p>byte data for the array</p>
  2199. <p>Passed as <code class="code">data</code></p>
  2200. </td>
  2201. </tr>
  2202. <tr>
  2203. <td class="parameter_name"><p>len</p></td>
  2204. <td class="parameter_description">
  2205. <p>length of <em class="parameter"><code>data</code></em></p>
  2206. <p>Inferred from <code class="code">data</code></p>
  2207. </td>
  2208. </tr>
  2209. </table></div>
  2210. </div>
  2211. </div>
  2212. <div class="refsect2">
  2213. <a name="id-1.1.90.2.69"></a><h3>byte-array-steal</h3>
  2214. <div class="informalexample"><pre class="programlisting">(define-values (%return len) (byte-array-steal array len))
  2215. </pre></div>
  2216. <p>Frees the data in the array and resets the size to zero, while
  2217. the underlying array is preserved for use elsewhere and returned
  2218. to the caller.</p>
  2219. <div class="refsect3">
  2220. <a name="id-1.1.90.2.69.4"></a><h4>Parameters</h4>
  2221. <div class="informaltable"><table>
  2222. <tr>
  2223. <td class="parameter_name"><p>array</p></td>
  2224. <td class="parameter_description">
  2225. <p>a <span class="type">GByteArray</span>.</p>
  2226. <p>Passed as <code class="code">array</code></p>
  2227. </td>
  2228. </tr>
  2229. <tr>
  2230. <td class="parameter_name"><p>len</p></td>
  2231. <td class="parameter_description">
  2232. <p>pointer to retrieve the number of
  2233. elements of the original array</p>
  2234. <p>Passed as <code class="code">len</code></p>
  2235. </td>
  2236. </tr>
  2237. </table></div>
  2238. </div>
  2239. </div>
  2240. <div class="refsect2">
  2241. <a name="id-1.1.90.2.70"></a><h3>byte-array-unref</h3>
  2242. <div class="informalexample"><pre class="programlisting">(define-values () (byte-array-unref array))
  2243. </pre></div>
  2244. <p>Atomically decrements the reference count of <em class="parameter"><code>array</code></em> by one. If the
  2245. reference count drops to 0, all memory allocated by the array is
  2246. released. This function is thread-safe and may be called from any
  2247. thread.</p>
  2248. <div class="refsect3">
  2249. <a name="id-1.1.90.2.70.4"></a><h4>Parameters</h4>
  2250. <div class="informaltable"><table><tr>
  2251. <td class="parameter_name"><p>array</p></td>
  2252. <td class="parameter_description">
  2253. <p>A <span class="type">GByteArray</span></p>
  2254. <p>Passed as <code class="code">array</code></p>
  2255. </td>
  2256. </tr></table></div>
  2257. </div>
  2258. </div>
  2259. <div class="refsect2">
  2260. <a name="id-1.1.90.2.71"></a><h3>canonicalize-filename</h3>
  2261. <div class="informalexample"><pre class="programlisting">(define-values (%return) (canonicalize-filename filename relative-to))
  2262. </pre></div>
  2263. <p>Gets the canonical file name from <em class="parameter"><code>filename</code></em>. All triple slashes are turned into
  2264. single slashes, and all <code class="code">..</code> and <code class="code">.</code>s resolved against <em class="parameter"><code>relative_to</code></em>.
  2265. </p>
  2266. <p>Symlinks are not followed, and the returned path is guaranteed to be absolute.
  2267. </p>
  2268. <p>If <em class="parameter"><code>filename</code></em> is an absolute path, <em class="parameter"><code>relative_to</code></em> is ignored. Otherwise,
  2269. <em class="parameter"><code>relative_to</code></em> will be prepended to <em class="parameter"><code>filename</code></em> to make it absolute. <em class="parameter"><code>relative_to</code></em>
  2270. must be an absolute path, or <code class="constant">NULL</code>. If <em class="parameter"><code>relative_to</code></em> is <code class="constant">NULL</code>, it'll fallback
  2271. to <code class="function">g_get_current_dir()</code>.
  2272. </p>
  2273. <p>This function never fails, and will canonicalize file paths even if they don't
  2274. exist.
  2275. </p>
  2276. <p>No file system I/O is done.</p>
  2277. <div class="refsect3">
  2278. <a name="id-1.1.90.2.71.8"></a><h4>Parameters</h4>
  2279. <div class="informaltable"><table>
  2280. <tr>
  2281. <td class="parameter_name"><p>filename</p></td>
  2282. <td class="parameter_description">
  2283. <p>the name of the file</p>
  2284. <p>Passed as <code class="code">filename</code></p>
  2285. </td>
  2286. </tr>
  2287. <tr>
  2288. <td class="parameter_name"><p>relative_to</p></td>
  2289. <td class="parameter_description">
  2290. <p>the relative directory, or <code class="constant">NULL</code>
  2291. to use the current working directory</p>
  2292. <p>Passed as <code class="code">relative-to</code></p>
  2293. </td>
  2294. </tr>
  2295. </table></div>
  2296. </div>
  2297. </div>
  2298. <div class="refsect2">
  2299. <a name="id-1.1.90.2.72"></a><h3>chdir</h3>
  2300. <div class="informalexample"><pre class="programlisting">(define-values (%return) (chdir path))
  2301. </pre></div>
  2302. <p>A wrapper for the POSIX <code class="function">chdir()</code> function. The function changes the
  2303. current directory of the process to <em class="parameter"><code>path</code></em>.
  2304. </p>
  2305. <p>See your C library manual for more details about <code class="function">chdir()</code>.</p>
  2306. <div class="refsect3">
  2307. <a name="id-1.1.90.2.72.5"></a><h4>Parameters</h4>
  2308. <div class="informaltable"><table><tr>
  2309. <td class="parameter_name"><p>path</p></td>
  2310. <td class="parameter_description">
  2311. <p>a pathname in the GLib file name encoding
  2312. (UTF-8 on Windows)</p>
  2313. <p>Passed as <code class="code">path</code></p>
  2314. </td>
  2315. </tr></table></div>
  2316. </div>
  2317. </div>
  2318. <div class="refsect2">
  2319. <a name="id-1.1.90.2.73"></a><h3>check-version</h3>
  2320. <div class="informalexample"><pre class="programlisting">(define-values
  2321. (%return)
  2322. (check-version required-major required-minor required-micro))
  2323. </pre></div>
  2324. <p>Checks that the GLib library in use is compatible with the
  2325. given version. Generally you would pass in the constants
  2326. <span class="type">GLIB_MAJOR_VERSION</span>, <span class="type">GLIB_MINOR_VERSION</span>, <span class="type">GLIB_MICRO_VERSION</span>
  2327. as the three arguments to this function; that produces
  2328. a check that the library in use is compatible with
  2329. the version of GLib the application or module was compiled
  2330. against.
  2331. </p>
  2332. <p>Compatibility is defined by two things: first the version
  2333. of the running library is newer than the version
  2334. <em class="parameter"><code>required_major</code></em>.required_minor.<em class="parameter"><code>required_micro</code></em>. Second
  2335. the running library must be binary compatible with the
  2336. version <em class="parameter"><code>required_major</code></em>.required_minor.<em class="parameter"><code>required_micro</code></em>
  2337. (same major version.)</p>
  2338. <div class="refsect3">
  2339. <a name="id-1.1.90.2.73.5"></a><h4>Parameters</h4>
  2340. <div class="informaltable"><table>
  2341. <tr>
  2342. <td class="parameter_name"><p>required_major</p></td>
  2343. <td class="parameter_description">
  2344. <p>the required major version</p>
  2345. <p>Passed as <code class="code">required-major</code></p>
  2346. </td>
  2347. </tr>
  2348. <tr>
  2349. <td class="parameter_name"><p>required_minor</p></td>
  2350. <td class="parameter_description">
  2351. <p>the required minor version</p>
  2352. <p>Passed as <code class="code">required-minor</code></p>
  2353. </td>
  2354. </tr>
  2355. <tr>
  2356. <td class="parameter_name"><p>required_micro</p></td>
  2357. <td class="parameter_description">
  2358. <p>the required micro version</p>
  2359. <p>Passed as <code class="code">required-micro</code></p>
  2360. </td>
  2361. </tr>
  2362. </table></div>
  2363. </div>
  2364. </div>
  2365. <div class="refsect2">
  2366. <a name="id-1.1.90.2.74"></a><h3>checksum-type-get-length</h3>
  2367. <div class="informalexample"><pre class="programlisting">(define-values (%return) (checksum-type-get-length checksum-type))
  2368. </pre></div>
  2369. <p>Gets the length in bytes of digests of type <em class="parameter"><code>checksum_type</code></em></p>
  2370. <div class="refsect3">
  2371. <a name="id-1.1.90.2.74.4"></a><h4>Parameters</h4>
  2372. <div class="informaltable"><table><tr>
  2373. <td class="parameter_name"><p>checksum_type</p></td>
  2374. <td class="parameter_description">
  2375. <p>a <span class="type">GChecksumType</span></p>
  2376. <p>Passed as <code class="code">checksum-type</code></p>
  2377. </td>
  2378. </tr></table></div>
  2379. </div>
  2380. </div>
  2381. <div class="refsect2">
  2382. <a name="id-1.1.90.2.75"></a><h3>child-watch-add</h3>
  2383. <div class="informalexample"><pre class="programlisting">(define-values (%return) (child-watch-add priority pid function data notify))
  2384. </pre></div>
  2385. <p>Sets a function to be called when the child indicated by <em class="parameter"><code>pid</code></em>
  2386. exits, at a default priority, <span class="type">G_PRIORITY_DEFAULT</span>.
  2387. </p>
  2388. <p>If you obtain <em class="parameter"><code>pid</code></em> from <code class="function">g_spawn_async()</code> or <code class="function">g_spawn_async_with_pipes()</code>
  2389. you will need to pass <span class="type">G_SPAWN_DO_NOT_REAP_CHILD</span> as flag to
  2390. the spawn function for the child watching to work.
  2391. </p>
  2392. <p>Note that on platforms where <span class="type">GPid</span> must be explicitly closed
  2393. (see <code class="function">g_spawn_close_pid()</code>) <em class="parameter"><code>pid</code></em> must not be closed while the
  2394. source is still active. Typically, you will want to call
  2395. <code class="function">g_spawn_close_pid()</code> in the callback function for the source.
  2396. </p>
  2397. <p>GLib supports only a single callback per process id.
  2398. On POSIX platforms, the same restrictions mentioned for
  2399. <code class="function">g_child_watch_source_new()</code> apply to this function.
  2400. </p>
  2401. <p>This internally creates a main loop source using
  2402. <code class="function">g_child_watch_source_new()</code> and attaches it to the main loop context
  2403. using <code class="function">g_source_attach()</code>. You can do these steps manually if you
  2404. need greater control.</p>
  2405. <div class="refsect3">
  2406. <a name="id-1.1.90.2.75.8"></a><h4>Parameters</h4>
  2407. <div class="informaltable"><table>
  2408. <tr>
  2409. <td class="parameter_name"><p>notify</p></td>
  2410. <td class="parameter_description">
  2411. <p></p>
  2412. <p>Passed as <code class="code">notify</code></p>
  2413. </td>
  2414. </tr>
  2415. <tr>
  2416. <td class="parameter_name"><p>priority</p></td>
  2417. <td class="parameter_description">
  2418. <p></p>
  2419. <p>Passed as <code class="code">priority</code></p>
  2420. </td>
  2421. </tr>
  2422. <tr>
  2423. <td class="parameter_name"><p>pid</p></td>
  2424. <td class="parameter_description">
  2425. <p>process id to watch. On POSIX the positive pid of a child
  2426. process. On Windows a handle for a process (which doesn't have to be
  2427. a child).</p>
  2428. <p>Passed as <code class="code">pid</code></p>
  2429. </td>
  2430. </tr>
  2431. <tr>
  2432. <td class="parameter_name"><p>function</p></td>
  2433. <td class="parameter_description">
  2434. <p>function to call</p>
  2435. <p>Passed as <code class="code">function</code></p>
  2436. </td>
  2437. </tr>
  2438. <tr>
  2439. <td class="parameter_name"><p>data</p></td>
  2440. <td class="parameter_description">
  2441. <p>data to pass to <em class="parameter"><code>function</code></em></p>
  2442. <p>Passed as <code class="code">data</code></p>
  2443. </td>
  2444. </tr>
  2445. </table></div>
  2446. </div>
  2447. </div>
  2448. <div class="refsect2">
  2449. <a name="id-1.1.90.2.76"></a><h3>child-watch-source-new</h3>
  2450. <div class="informalexample"><pre class="programlisting">(define-values (%return) (child-watch-source-new pid))
  2451. </pre></div>
  2452. <p>Creates a new child_watch source.
  2453. </p>
  2454. <p>The source will not initially be associated with any <span class="type">GMainContext</span>
  2455. and must be added to one with <code class="function">g_source_attach()</code> before it will be
  2456. executed.
  2457. </p>
  2458. <p>Note that child watch sources can only be used in conjunction with
  2459. <code class="code">g_spawn...</code> when the <code class="constant">G_SPAWN_DO_NOT_REAP_CHILD</code> flag is used.
  2460. </p>
  2461. <p>Note that on platforms where <span class="type">GPid</span> must be explicitly closed
  2462. (see <code class="function">g_spawn_close_pid()</code>) <em class="parameter"><code>pid</code></em> must not be closed while the
  2463. source is still active. Typically, you will want to call
  2464. <code class="function">g_spawn_close_pid()</code> in the callback function for the source.
  2465. </p>
  2466. <p>On POSIX platforms, the following restrictions apply to this API
  2467. due to limitations in POSIX process interfaces:
  2468. </p>
  2469. <p>* <em class="parameter"><code>pid</code></em> must be a child of this process
  2470. * <em class="parameter"><code>pid</code></em> must be positive
  2471. * the application must not call <code class="code">waitpid</code> with a non-positive
  2472. first argument, for instance in another thread
  2473. * the application must not wait for <em class="parameter"><code>pid</code></em> to exit by any other
  2474. mechanism, including <code class="code">waitpid(pid, ...)</code> or a second child-watch
  2475. source for the same <em class="parameter"><code>pid</code></em>
  2476. * the application must not ignore SIGCHILD
  2477. </p>
  2478. <p>If any of those conditions are not met, this and related APIs will
  2479. not work correctly. This can often be diagnosed via a GLib warning
  2480. stating that <code class="code">ECHILD</code> was received by <code class="code">waitpid</code>.
  2481. </p>
  2482. <p>Calling <code class="code">waitpid</code> for specific processes other than <em class="parameter"><code>pid</code></em> remains a
  2483. valid thing to do.</p>
  2484. <div class="refsect3">
  2485. <a name="id-1.1.90.2.76.11"></a><h4>Parameters</h4>
  2486. <div class="informaltable"><table><tr>
  2487. <td class="parameter_name"><p>pid</p></td>
  2488. <td class="parameter_description">
  2489. <p>process to watch. On POSIX the positive pid of a child process. On
  2490. Windows a handle for a process (which doesn't have to be a child).</p>
  2491. <p>Passed as <code class="code">pid</code></p>
  2492. </td>
  2493. </tr></table></div>
  2494. </div>
  2495. </div>
  2496. <div class="refsect2">
  2497. <a name="id-1.1.90.2.77"></a><h3>clear-error</h3>
  2498. <div class="informalexample"><pre class="programlisting">(define-values () (clear-error))
  2499. </pre></div>
  2500. <p>If <em class="parameter"><code>err</code></em> or *<em class="parameter"><code>err</code></em> is <code class="constant">NULL</code>, does nothing. Otherwise,
  2501. calls <code class="function">g_error_free()</code> on *<em class="parameter"><code>err</code></em> and sets *<em class="parameter"><code>err</code></em> to <code class="constant">NULL</code>.</p>
  2502. </div>
  2503. <div class="refsect2">
  2504. <a name="id-1.1.90.2.78"></a><h3>close?</h3>
  2505. <div class="informalexample"><pre class="programlisting">(define-values (%return) (close? fd))
  2506. </pre></div>
  2507. <p>This wraps the <code class="function">close()</code> call; in case of error, <code class="constant">errno</code> will be
  2508. preserved, but the error will also be stored as a <span class="type">GError</span> in <em class="parameter"><code>error</code></em>.
  2509. </p>
  2510. <p>Besides using <span class="type">GError</span>, there is another major reason to prefer this
  2511. function over the call provided by the system; on Unix, it will
  2512. attempt to correctly handle <code class="constant">EINTR</code>, which has platform-specific
  2513. semantics.</p>
  2514. <div class="refsect3">
  2515. <a name="id-1.1.90.2.78.5"></a><h4>Parameters</h4>
  2516. <div class="informaltable"><table><tr>
  2517. <td class="parameter_name"><p>fd</p></td>
  2518. <td class="parameter_description">
  2519. <p>A file descriptor</p>
  2520. <p>Passed as <code class="code">fd</code></p>
  2521. </td>
  2522. </tr></table></div>
  2523. </div>
  2524. </div>
  2525. <div class="refsect2">
  2526. <a name="id-1.1.90.2.79"></a><h3>compute-checksum-for-bytes</h3>
  2527. <div class="informalexample"><pre class="programlisting">(define-values (%return) (compute-checksum-for-bytes checksum-type data))
  2528. </pre></div>
  2529. <p>Computes the checksum for a binary <em class="parameter"><code>data</code></em>. This is a
  2530. convenience wrapper for <code class="function">g_checksum_new()</code>, <code class="function">g_checksum_get_string()</code>
  2531. and <code class="function">g_checksum_free()</code>.
  2532. </p>
  2533. <p>The hexadecimal string returned will be in lower case.</p>
  2534. <div class="refsect3">
  2535. <a name="id-1.1.90.2.79.5"></a><h4>Parameters</h4>
  2536. <div class="informaltable"><table>
  2537. <tr>
  2538. <td class="parameter_name"><p>checksum_type</p></td>
  2539. <td class="parameter_description">
  2540. <p>a <span class="type">GChecksumType</span></p>
  2541. <p>Passed as <code class="code">checksum-type</code></p>
  2542. </td>
  2543. </tr>
  2544. <tr>
  2545. <td class="parameter_name"><p>data</p></td>
  2546. <td class="parameter_description">
  2547. <p>binary blob to compute the digest of</p>
  2548. <p>Passed as <code class="code">data</code></p>
  2549. </td>
  2550. </tr>
  2551. </table></div>
  2552. </div>
  2553. </div>
  2554. <div class="refsect2">
  2555. <a name="id-1.1.90.2.80"></a><h3>compute-checksum-for-data</h3>
  2556. <div class="informalexample"><pre class="programlisting">(define-values (%return) (compute-checksum-for-data checksum-type data))
  2557. </pre></div>
  2558. <p>Computes the checksum for a binary <em class="parameter"><code>data</code></em> of <em class="parameter"><code>length</code></em>. This is a
  2559. convenience wrapper for <code class="function">g_checksum_new()</code>, <code class="function">g_checksum_get_string()</code>
  2560. and <code class="function">g_checksum_free()</code>.
  2561. </p>
  2562. <p>The hexadecimal string returned will be in lower case.</p>
  2563. <div class="refsect3">
  2564. <a name="id-1.1.90.2.80.5"></a><h4>Parameters</h4>
  2565. <div class="informaltable"><table>
  2566. <tr>
  2567. <td class="parameter_name"><p>checksum_type</p></td>
  2568. <td class="parameter_description">
  2569. <p>a <span class="type">GChecksumType</span></p>
  2570. <p>Passed as <code class="code">checksum-type</code></p>
  2571. </td>
  2572. </tr>
  2573. <tr>
  2574. <td class="parameter_name"><p>data</p></td>
  2575. <td class="parameter_description">
  2576. <p>binary blob to compute the digest of</p>
  2577. <p>Passed as <code class="code">data</code></p>
  2578. </td>
  2579. </tr>
  2580. <tr>
  2581. <td class="parameter_name"><p>length</p></td>
  2582. <td class="parameter_description">
  2583. <p>length of <em class="parameter"><code>data</code></em></p>
  2584. <p>Inferred from <code class="code">data</code></p>
  2585. </td>
  2586. </tr>
  2587. </table></div>
  2588. </div>
  2589. </div>
  2590. <div class="refsect2">
  2591. <a name="id-1.1.90.2.81"></a><h3>compute-checksum-for-string</h3>
  2592. <div class="informalexample"><pre class="programlisting">(define-values
  2593. (%return)
  2594. (compute-checksum-for-string checksum-type str length))
  2595. </pre></div>
  2596. <p>Computes the checksum of a string.
  2597. </p>
  2598. <p>The hexadecimal string returned will be in lower case.</p>
  2599. <div class="refsect3">
  2600. <a name="id-1.1.90.2.81.5"></a><h4>Parameters</h4>
  2601. <div class="informaltable"><table>
  2602. <tr>
  2603. <td class="parameter_name"><p>checksum_type</p></td>
  2604. <td class="parameter_description">
  2605. <p>a <span class="type">GChecksumType</span></p>
  2606. <p>Passed as <code class="code">checksum-type</code></p>
  2607. </td>
  2608. </tr>
  2609. <tr>
  2610. <td class="parameter_name"><p>str</p></td>
  2611. <td class="parameter_description">
  2612. <p>the string to compute the checksum of</p>
  2613. <p>Passed as <code class="code">str</code></p>
  2614. </td>
  2615. </tr>
  2616. <tr>
  2617. <td class="parameter_name"><p>length</p></td>
  2618. <td class="parameter_description">
  2619. <p>the length of the string, or -1 if the string is null-terminated.</p>
  2620. <p>Passed as <code class="code">length</code></p>
  2621. </td>
  2622. </tr>
  2623. </table></div>
  2624. </div>
  2625. </div>
  2626. <div class="refsect2">
  2627. <a name="id-1.1.90.2.82"></a><h3>compute-hmac-for-bytes</h3>
  2628. <div class="informalexample"><pre class="programlisting">(define-values (%return) (compute-hmac-for-bytes digest-type key data))
  2629. </pre></div>
  2630. <p>Computes the HMAC for a binary <em class="parameter"><code>data</code></em>. This is a
  2631. convenience wrapper for <code class="function">g_hmac_new()</code>, <code class="function">g_hmac_get_string()</code>
  2632. and <code class="function">g_hmac_unref()</code>.
  2633. </p>
  2634. <p>The hexadecimal string returned will be in lower case.</p>
  2635. <div class="refsect3">
  2636. <a name="id-1.1.90.2.82.5"></a><h4>Parameters</h4>
  2637. <div class="informaltable"><table>
  2638. <tr>
  2639. <td class="parameter_name"><p>digest_type</p></td>
  2640. <td class="parameter_description">
  2641. <p>a <span class="type">GChecksumType</span> to use for the HMAC</p>
  2642. <p>Passed as <code class="code">digest-type</code></p>
  2643. </td>
  2644. </tr>
  2645. <tr>
  2646. <td class="parameter_name"><p>key</p></td>
  2647. <td class="parameter_description">
  2648. <p>the key to use in the HMAC</p>
  2649. <p>Passed as <code class="code">key</code></p>
  2650. </td>
  2651. </tr>
  2652. <tr>
  2653. <td class="parameter_name"><p>data</p></td>
  2654. <td class="parameter_description">
  2655. <p>binary blob to compute the HMAC of</p>
  2656. <p>Passed as <code class="code">data</code></p>
  2657. </td>
  2658. </tr>
  2659. </table></div>
  2660. </div>
  2661. </div>
  2662. <div class="refsect2">
  2663. <a name="id-1.1.90.2.83"></a><h3>compute-hmac-for-data</h3>
  2664. <div class="informalexample"><pre class="programlisting">(define-values (%return) (compute-hmac-for-data digest-type key data))
  2665. </pre></div>
  2666. <p>Computes the HMAC for a binary <em class="parameter"><code>data</code></em> of <em class="parameter"><code>length</code></em>. This is a
  2667. convenience wrapper for <code class="function">g_hmac_new()</code>, <code class="function">g_hmac_get_string()</code>
  2668. and <code class="function">g_hmac_unref()</code>.
  2669. </p>
  2670. <p>The hexadecimal string returned will be in lower case.</p>
  2671. <div class="refsect3">
  2672. <a name="id-1.1.90.2.83.5"></a><h4>Parameters</h4>
  2673. <div class="informaltable"><table>
  2674. <tr>
  2675. <td class="parameter_name"><p>digest_type</p></td>
  2676. <td class="parameter_description">
  2677. <p>a <span class="type">GChecksumType</span> to use for the HMAC</p>
  2678. <p>Passed as <code class="code">digest-type</code></p>
  2679. </td>
  2680. </tr>
  2681. <tr>
  2682. <td class="parameter_name"><p>key</p></td>
  2683. <td class="parameter_description">
  2684. <p>the key to use in the HMAC</p>
  2685. <p>Passed as <code class="code">key</code></p>
  2686. </td>
  2687. </tr>
  2688. <tr>
  2689. <td class="parameter_name"><p>key_len</p></td>
  2690. <td class="parameter_description">
  2691. <p>the length of the key</p>
  2692. <p>Inferred from <code class="code">key</code></p>
  2693. </td>
  2694. </tr>
  2695. <tr>
  2696. <td class="parameter_name"><p>data</p></td>
  2697. <td class="parameter_description">
  2698. <p>binary blob to compute the HMAC of</p>
  2699. <p>Passed as <code class="code">data</code></p>
  2700. </td>
  2701. </tr>
  2702. <tr>
  2703. <td class="parameter_name"><p>length</p></td>
  2704. <td class="parameter_description">
  2705. <p>length of <em class="parameter"><code>data</code></em></p>
  2706. <p>Inferred from <code class="code">data</code></p>
  2707. </td>
  2708. </tr>
  2709. </table></div>
  2710. </div>
  2711. </div>
  2712. <div class="refsect2">
  2713. <a name="id-1.1.90.2.84"></a><h3>compute-hmac-for-string</h3>
  2714. <div class="informalexample"><pre class="programlisting">(define-values (%return) (compute-hmac-for-string digest-type key str length))
  2715. </pre></div>
  2716. <p>Computes the HMAC for a string.
  2717. </p>
  2718. <p>The hexadecimal string returned will be in lower case.</p>
  2719. <div class="refsect3">
  2720. <a name="id-1.1.90.2.84.5"></a><h4>Parameters</h4>
  2721. <div class="informaltable"><table>
  2722. <tr>
  2723. <td class="parameter_name"><p>digest_type</p></td>
  2724. <td class="parameter_description">
  2725. <p>a <span class="type">GChecksumType</span> to use for the HMAC</p>
  2726. <p>Passed as <code class="code">digest-type</code></p>
  2727. </td>
  2728. </tr>
  2729. <tr>
  2730. <td class="parameter_name"><p>key</p></td>
  2731. <td class="parameter_description">
  2732. <p>the key to use in the HMAC</p>
  2733. <p>Passed as <code class="code">key</code></p>
  2734. </td>
  2735. </tr>
  2736. <tr>
  2737. <td class="parameter_name"><p>key_len</p></td>
  2738. <td class="parameter_description">
  2739. <p>the length of the key</p>
  2740. <p>Inferred from <code class="code">key</code></p>
  2741. </td>
  2742. </tr>
  2743. <tr>
  2744. <td class="parameter_name"><p>str</p></td>
  2745. <td class="parameter_description">
  2746. <p>the string to compute the HMAC for</p>
  2747. <p>Passed as <code class="code">str</code></p>
  2748. </td>
  2749. </tr>
  2750. <tr>
  2751. <td class="parameter_name"><p>length</p></td>
  2752. <td class="parameter_description">
  2753. <p>the length of the string, or -1 if the string is nul-terminated</p>
  2754. <p>Passed as <code class="code">length</code></p>
  2755. </td>
  2756. </tr>
  2757. </table></div>
  2758. </div>
  2759. </div>
  2760. <div class="refsect2">
  2761. <a name="id-1.1.90.2.85"></a><h3>convert</h3>
  2762. <div class="informalexample"><pre class="programlisting">(define-values
  2763. (%return bytes-read bytes-written)
  2764. (convert str to-codeset from-codeset))
  2765. </pre></div>
  2766. <p>Converts a string from one character set to another.
  2767. </p>
  2768. <p>Note that you should use <code class="function">g_iconv()</code> for streaming conversions.
  2769. Despite the fact that <em class="parameter"><code>bytes_read</code></em> can return information about partial
  2770. characters, the g_convert_... functions are not generally suitable
  2771. for streaming. If the underlying converter maintains internal state,
  2772. then this won't be preserved across successive calls to <code class="function">g_convert()</code>,
  2773. <code class="function">g_convert_with_iconv()</code> or <code class="function">g_convert_with_fallback()</code>. (An example of
  2774. this is the GNU C converter for CP1255 which does not emit a base
  2775. character until it knows that the next character is not a mark that
  2776. could combine with the base character.)
  2777. </p>
  2778. <p>Using extensions such as "//TRANSLIT" may not work (or may not work
  2779. well) on many platforms. Consider using <code class="function">g_str_to_ascii()</code> instead.</p>
  2780. <div class="refsect3">
  2781. <a name="id-1.1.90.2.85.6"></a><h4>Parameters</h4>
  2782. <div class="informaltable"><table>
  2783. <tr>
  2784. <td class="parameter_name"><p>str</p></td>
  2785. <td class="parameter_description">
  2786. <p>
  2787. </p>
  2788. <p>the string to convert.</p>
  2789. <p>Passed as <code class="code">str</code></p>
  2790. </td>
  2791. </tr>
  2792. <tr>
  2793. <td class="parameter_name"><p>len</p></td>
  2794. <td class="parameter_description">
  2795. <p>the length of the string in bytes, or -1 if the string is
  2796. nul-terminated (Note that some encodings may allow nul
  2797. bytes to occur inside strings. In that case, using -1
  2798. for the <em class="parameter"><code>len</code></em> parameter is unsafe)</p>
  2799. <p>Inferred from <code class="code">str</code></p>
  2800. </td>
  2801. </tr>
  2802. <tr>
  2803. <td class="parameter_name"><p>to_codeset</p></td>
  2804. <td class="parameter_description">
  2805. <p>name of character set into which to convert <em class="parameter"><code>str</code></em></p>
  2806. <p>Passed as <code class="code">to-codeset</code></p>
  2807. </td>
  2808. </tr>
  2809. <tr>
  2810. <td class="parameter_name"><p>from_codeset</p></td>
  2811. <td class="parameter_description">
  2812. <p>character set of <em class="parameter"><code>str</code></em>.</p>
  2813. <p>Passed as <code class="code">from-codeset</code></p>
  2814. </td>
  2815. </tr>
  2816. <tr>
  2817. <td class="parameter_name"><p>bytes_read</p></td>
  2818. <td class="parameter_description">
  2819. <p>location to store the number of bytes in
  2820. the input string that were successfully converted, or <code class="constant">NULL</code>.
  2821. Even if the conversion was successful, this may be
  2822. less than <em class="parameter"><code>len</code></em> if there were partial characters
  2823. at the end of the input. If the error
  2824. <span class="type">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</span> occurs, the value
  2825. stored will be the byte offset after the last valid
  2826. input sequence.</p>
  2827. <p>Passed as <code class="code">bytes-read</code></p>
  2828. </td>
  2829. </tr>
  2830. <tr>
  2831. <td class="parameter_name"><p>bytes_written</p></td>
  2832. <td class="parameter_description">
  2833. <p>the number of bytes stored in
  2834. the output buffer (not including the terminating nul).</p>
  2835. <p>Inferred from <code class="code">%return</code></p>
  2836. </td>
  2837. </tr>
  2838. </table></div>
  2839. </div>
  2840. </div>
  2841. <div class="refsect2">
  2842. <a name="id-1.1.90.2.86"></a><h3>convert-error-quark</h3>
  2843. <div class="informalexample"><pre class="programlisting">(define-values (%return) (convert-error-quark))
  2844. </pre></div>
  2845. <p>Undocumented</p>
  2846. </div>
  2847. <div class="refsect2">
  2848. <a name="id-1.1.90.2.87"></a><h3>convert-with-fallback</h3>
  2849. <div class="informalexample"><pre class="programlisting">(define-values
  2850. (%return bytes-read bytes-written)
  2851. (convert-with-fallback str to-codeset from-codeset fallback))
  2852. </pre></div>
  2853. <p>Converts a string from one character set to another, possibly
  2854. including fallback sequences for characters not representable
  2855. in the output. Note that it is not guaranteed that the specification
  2856. for the fallback sequences in <em class="parameter"><code>fallback</code></em> will be honored. Some
  2857. systems may do an approximate conversion from <em class="parameter"><code>from_codeset</code></em>
  2858. to <em class="parameter"><code>to_codeset</code></em> in their <code class="function">iconv()</code> functions,
  2859. in which case GLib will simply return that approximate conversion.
  2860. </p>
  2861. <p>Note that you should use <code class="function">g_iconv()</code> for streaming conversions.
  2862. Despite the fact that <em class="parameter"><code>bytes_read</code></em> can return information about partial
  2863. characters, the g_convert_... functions are not generally suitable
  2864. for streaming. If the underlying converter maintains internal state,
  2865. then this won't be preserved across successive calls to <code class="function">g_convert()</code>,
  2866. <code class="function">g_convert_with_iconv()</code> or <code class="function">g_convert_with_fallback()</code>. (An example of
  2867. this is the GNU C converter for CP1255 which does not emit a base
  2868. character until it knows that the next character is not a mark that
  2869. could combine with the base character.)</p>
  2870. <div class="refsect3">
  2871. <a name="id-1.1.90.2.87.5"></a><h4>Parameters</h4>
  2872. <div class="informaltable"><table>
  2873. <tr>
  2874. <td class="parameter_name"><p>str</p></td>
  2875. <td class="parameter_description">
  2876. <p>
  2877. </p>
  2878. <p>the string to convert.</p>
  2879. <p>Passed as <code class="code">str</code></p>
  2880. </td>
  2881. </tr>
  2882. <tr>
  2883. <td class="parameter_name"><p>len</p></td>
  2884. <td class="parameter_description">
  2885. <p>the length of the string in bytes, or -1 if the string is
  2886. nul-terminated (Note that some encodings may allow nul
  2887. bytes to occur inside strings. In that case, using -1
  2888. for the <em class="parameter"><code>len</code></em> parameter is unsafe)</p>
  2889. <p>Inferred from <code class="code">str</code></p>
  2890. </td>
  2891. </tr>
  2892. <tr>
  2893. <td class="parameter_name"><p>to_codeset</p></td>
  2894. <td class="parameter_description">
  2895. <p>name of character set into which to convert <em class="parameter"><code>str</code></em></p>
  2896. <p>Passed as <code class="code">to-codeset</code></p>
  2897. </td>
  2898. </tr>
  2899. <tr>
  2900. <td class="parameter_name"><p>from_codeset</p></td>
  2901. <td class="parameter_description">
  2902. <p>character set of <em class="parameter"><code>str</code></em>.</p>
  2903. <p>Passed as <code class="code">from-codeset</code></p>
  2904. </td>
  2905. </tr>
  2906. <tr>
  2907. <td class="parameter_name"><p>fallback</p></td>
  2908. <td class="parameter_description">
  2909. <p>UTF-8 string to use in place of characters not
  2910. present in the target encoding. (The string must be
  2911. representable in the target encoding).
  2912. If <code class="constant">NULL</code>, characters not in the target encoding will
  2913. be represented as Unicode escapes \uxxxx or \Uxxxxyyyy.</p>
  2914. <p>Passed as <code class="code">fallback</code></p>
  2915. </td>
  2916. </tr>
  2917. <tr>
  2918. <td class="parameter_name"><p>bytes_read</p></td>
  2919. <td class="parameter_description">
  2920. <p>location to store the number of bytes in
  2921. the input string that were successfully converted, or <code class="constant">NULL</code>.
  2922. Even if the conversion was successful, this may be
  2923. less than <em class="parameter"><code>len</code></em> if there were partial characters
  2924. at the end of the input.</p>
  2925. <p>Passed as <code class="code">bytes-read</code></p>
  2926. </td>
  2927. </tr>
  2928. <tr>
  2929. <td class="parameter_name"><p>bytes_written</p></td>
  2930. <td class="parameter_description">
  2931. <p>the number of bytes stored in
  2932. the output buffer (not including the terminating nul).</p>
  2933. <p>Inferred from <code class="code">%return</code></p>
  2934. </td>
  2935. </tr>
  2936. </table></div>
  2937. </div>
  2938. </div>
  2939. <div class="refsect2">
  2940. <a name="id-1.1.90.2.88"></a><h3>dataset-destroy</h3>
  2941. <div class="informalexample"><pre class="programlisting">(define-values () (dataset-destroy dataset-location))
  2942. </pre></div>
  2943. <p>Destroys the dataset, freeing all memory allocated, and calling any
  2944. destroy functions set for data elements.</p>
  2945. <div class="refsect3">
  2946. <a name="id-1.1.90.2.88.4"></a><h4>Parameters</h4>
  2947. <div class="informaltable"><table><tr>
  2948. <td class="parameter_name"><p>dataset_location</p></td>
  2949. <td class="parameter_description">
  2950. <p>the location identifying the dataset.</p>
  2951. <p>Passed as <code class="code">dataset-location</code></p>
  2952. </td>
  2953. </tr></table></div>
  2954. </div>
  2955. </div>
  2956. <div class="refsect2">
  2957. <a name="id-1.1.90.2.89"></a><h3>dataset-foreach</h3>
  2958. <div class="informalexample"><pre class="programlisting">(define-values () (dataset-foreach dataset-location func user-data))
  2959. </pre></div>
  2960. <p>Calls the given function for each data element which is associated
  2961. with the given location. Note that this function is NOT thread-safe.
  2962. So unless <em class="parameter"><code>dataset_location</code></em> can be protected from any modifications
  2963. during invocation of this function, it should not be called.
  2964. </p>
  2965. <p><em class="parameter"><code>func</code></em> can make changes to the dataset, but the iteration will not
  2966. reflect changes made during the <code class="function">g_dataset_foreach()</code> call, other
  2967. than skipping over elements that are removed.</p>
  2968. <div class="refsect3">
  2969. <a name="id-1.1.90.2.89.5"></a><h4>Parameters</h4>
  2970. <div class="informaltable"><table>
  2971. <tr>
  2972. <td class="parameter_name"><p>dataset_location</p></td>
  2973. <td class="parameter_description">
  2974. <p>the location identifying the dataset.</p>
  2975. <p>Passed as <code class="code">dataset-location</code></p>
  2976. </td>
  2977. </tr>
  2978. <tr>
  2979. <td class="parameter_name"><p>func</p></td>
  2980. <td class="parameter_description">
  2981. <p>the function to call for each data element.</p>
  2982. <p>Passed as <code class="code">func</code></p>
  2983. </td>
  2984. </tr>
  2985. <tr>
  2986. <td class="parameter_name"><p>user_data</p></td>
  2987. <td class="parameter_description">
  2988. <p>user data to pass to the function.</p>
  2989. <p>Passed as <code class="code">user-data</code></p>
  2990. </td>
  2991. </tr>
  2992. </table></div>
  2993. </div>
  2994. </div>
  2995. <div class="refsect2">
  2996. <a name="id-1.1.90.2.90"></a><h3>dataset-id-get-data</h3>
  2997. <div class="informalexample"><pre class="programlisting">(define-values (%return) (dataset-id-get-data dataset-location key-id))
  2998. </pre></div>
  2999. <p>Gets the data element corresponding to a <span class="type">GQuark</span>.</p>
  3000. <div class="refsect3">
  3001. <a name="id-1.1.90.2.90.4"></a><h4>Parameters</h4>
  3002. <div class="informaltable"><table>
  3003. <tr>
  3004. <td class="parameter_name"><p>dataset_location</p></td>
  3005. <td class="parameter_description">
  3006. <p>the location identifying the dataset.</p>
  3007. <p>Passed as <code class="code">dataset-location</code></p>
  3008. </td>
  3009. </tr>
  3010. <tr>
  3011. <td class="parameter_name"><p>key_id</p></td>
  3012. <td class="parameter_description">
  3013. <p>the <span class="type">GQuark</span> id to identify the data element.</p>
  3014. <p>Passed as <code class="code">key-id</code></p>
  3015. </td>
  3016. </tr>
  3017. </table></div>
  3018. </div>
  3019. </div>
  3020. <div class="refsect2">
  3021. <a name="id-1.1.90.2.91"></a><h3>date-get-days-in-month</h3>
  3022. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-get-days-in-month month year))
  3023. </pre></div>
  3024. <p>Returns the number of days in a month, taking leap
  3025. years into account.</p>
  3026. <div class="refsect3">
  3027. <a name="id-1.1.90.2.91.4"></a><h4>Parameters</h4>
  3028. <div class="informaltable"><table>
  3029. <tr>
  3030. <td class="parameter_name"><p>month</p></td>
  3031. <td class="parameter_description">
  3032. <p>month</p>
  3033. <p>Passed as <code class="code">month</code></p>
  3034. </td>
  3035. </tr>
  3036. <tr>
  3037. <td class="parameter_name"><p>year</p></td>
  3038. <td class="parameter_description">
  3039. <p>year</p>
  3040. <p>Passed as <code class="code">year</code></p>
  3041. </td>
  3042. </tr>
  3043. </table></div>
  3044. </div>
  3045. </div>
  3046. <div class="refsect2">
  3047. <a name="id-1.1.90.2.92"></a><h3>date-get-monday-weeks-in-year</h3>
  3048. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-get-monday-weeks-in-year year))
  3049. </pre></div>
  3050. <p>Returns the number of weeks in the year, where weeks
  3051. are taken to start on Monday. Will be 52 or 53. The
  3052. date must be valid. (Years always have 52 7-day periods,
  3053. plus 1 or 2 extra days depending on whether it's a leap
  3054. year. This function is basically telling you how many
  3055. Mondays are in the year, i.e. there are 53 Mondays if
  3056. one of the extra days happens to be a Monday.)</p>
  3057. <div class="refsect3">
  3058. <a name="id-1.1.90.2.92.4"></a><h4>Parameters</h4>
  3059. <div class="informaltable"><table><tr>
  3060. <td class="parameter_name"><p>year</p></td>
  3061. <td class="parameter_description">
  3062. <p>a year</p>
  3063. <p>Passed as <code class="code">year</code></p>
  3064. </td>
  3065. </tr></table></div>
  3066. </div>
  3067. </div>
  3068. <div class="refsect2">
  3069. <a name="id-1.1.90.2.93"></a><h3>date-get-sunday-weeks-in-year</h3>
  3070. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-get-sunday-weeks-in-year year))
  3071. </pre></div>
  3072. <p>Returns the number of weeks in the year, where weeks
  3073. are taken to start on Sunday. Will be 52 or 53. The
  3074. date must be valid. (Years always have 52 7-day periods,
  3075. plus 1 or 2 extra days depending on whether it's a leap
  3076. year. This function is basically telling you how many
  3077. Sundays are in the year, i.e. there are 53 Sundays if
  3078. one of the extra days happens to be a Sunday.)</p>
  3079. <div class="refsect3">
  3080. <a name="id-1.1.90.2.93.4"></a><h4>Parameters</h4>
  3081. <div class="informaltable"><table><tr>
  3082. <td class="parameter_name"><p>year</p></td>
  3083. <td class="parameter_description">
  3084. <p>year to count weeks in</p>
  3085. <p>Passed as <code class="code">year</code></p>
  3086. </td>
  3087. </tr></table></div>
  3088. </div>
  3089. </div>
  3090. <div class="refsect2">
  3091. <a name="id-1.1.90.2.94"></a><h3>date-is-leap-year?</h3>
  3092. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-is-leap-year? year))
  3093. </pre></div>
  3094. <p>Returns <code class="constant">TRUE</code> if the year is a leap year.
  3095. </p>
  3096. <p>For the purposes of this function, leap year is every year
  3097. divisible by 4 unless that year is divisible by 100. If it
  3098. is divisible by 100 it would be a leap year only if that year
  3099. is also divisible by 400.</p>
  3100. <div class="refsect3">
  3101. <a name="id-1.1.90.2.94.5"></a><h4>Parameters</h4>
  3102. <div class="informaltable"><table><tr>
  3103. <td class="parameter_name"><p>year</p></td>
  3104. <td class="parameter_description">
  3105. <p>year to check</p>
  3106. <p>Passed as <code class="code">year</code></p>
  3107. </td>
  3108. </tr></table></div>
  3109. </div>
  3110. </div>
  3111. <div class="refsect2">
  3112. <a name="id-1.1.90.2.95"></a><h3>date-strftime</h3>
  3113. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-strftime s slen format date))
  3114. </pre></div>
  3115. <p>Generates a printed representation of the date, in a
  3116. [locale][setlocale]-specific way.
  3117. Works just like the platform's C library <code class="function">strftime()</code> function,
  3118. but only accepts date-related formats; time-related formats
  3119. give undefined results. Date must be valid. Unlike <code class="function">strftime()</code>
  3120. (which uses the locale encoding), works on a UTF-8 format
  3121. string and stores a UTF-8 result.
  3122. </p>
  3123. <p>This function does not provide any conversion specifiers in
  3124. addition to those implemented by the platform's C library.
  3125. For example, don't expect that using <code class="function">g_date_strftime()</code> would
  3126. make the \%F provided by the C99 <code class="function">strftime()</code> work on Windows
  3127. where the C library only complies to C89.</p>
  3128. <div class="refsect3">
  3129. <a name="id-1.1.90.2.95.5"></a><h4>Parameters</h4>
  3130. <div class="informaltable"><table>
  3131. <tr>
  3132. <td class="parameter_name"><p>s</p></td>
  3133. <td class="parameter_description">
  3134. <p>destination buffer</p>
  3135. <p>Passed as <code class="code">s</code></p>
  3136. </td>
  3137. </tr>
  3138. <tr>
  3139. <td class="parameter_name"><p>slen</p></td>
  3140. <td class="parameter_description">
  3141. <p>buffer size</p>
  3142. <p>Passed as <code class="code">slen</code></p>
  3143. </td>
  3144. </tr>
  3145. <tr>
  3146. <td class="parameter_name"><p>format</p></td>
  3147. <td class="parameter_description">
  3148. <p>format string</p>
  3149. <p>Passed as <code class="code">format</code></p>
  3150. </td>
  3151. </tr>
  3152. <tr>
  3153. <td class="parameter_name"><p>date</p></td>
  3154. <td class="parameter_description">
  3155. <p>valid <span class="type">GDate</span></p>
  3156. <p>Passed as <code class="code">date</code></p>
  3157. </td>
  3158. </tr>
  3159. </table></div>
  3160. </div>
  3161. </div>
  3162. <div class="refsect2">
  3163. <a name="id-1.1.90.2.96"></a><h3>date-time-compare</h3>
  3164. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-time-compare dt1 dt2))
  3165. </pre></div>
  3166. <p>A comparison function for <span class="type">GDateTimes</span> that is suitable
  3167. as a <span class="type">GCompareFunc</span>. Both <span class="type">GDateTimes</span> must be non-<code class="constant">NULL</code>.</p>
  3168. <div class="refsect3">
  3169. <a name="id-1.1.90.2.96.4"></a><h4>Parameters</h4>
  3170. <div class="informaltable"><table>
  3171. <tr>
  3172. <td class="parameter_name"><p>dt1</p></td>
  3173. <td class="parameter_description">
  3174. <p>first <span class="type">GDateTime</span> to compare</p>
  3175. <p>Passed as <code class="code">dt1</code></p>
  3176. </td>
  3177. </tr>
  3178. <tr>
  3179. <td class="parameter_name"><p>dt2</p></td>
  3180. <td class="parameter_description">
  3181. <p>second <span class="type">GDateTime</span> to compare</p>
  3182. <p>Passed as <code class="code">dt2</code></p>
  3183. </td>
  3184. </tr>
  3185. </table></div>
  3186. </div>
  3187. </div>
  3188. <div class="refsect2">
  3189. <a name="id-1.1.90.2.97"></a><h3>date-time-equal?</h3>
  3190. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-time-equal? dt1 dt2))
  3191. </pre></div>
  3192. <p>Checks to see if <em class="parameter"><code>dt1</code></em> and <em class="parameter"><code>dt2</code></em> are equal.
  3193. </p>
  3194. <p>Equal here means that they represent the same moment after converting
  3195. them to the same time zone.</p>
  3196. <div class="refsect3">
  3197. <a name="id-1.1.90.2.97.5"></a><h4>Parameters</h4>
  3198. <div class="informaltable"><table>
  3199. <tr>
  3200. <td class="parameter_name"><p>dt1</p></td>
  3201. <td class="parameter_description">
  3202. <p>a <span class="type">GDateTime</span></p>
  3203. <p>Passed as <code class="code">dt1</code></p>
  3204. </td>
  3205. </tr>
  3206. <tr>
  3207. <td class="parameter_name"><p>dt2</p></td>
  3208. <td class="parameter_description">
  3209. <p>a <span class="type">GDateTime</span></p>
  3210. <p>Passed as <code class="code">dt2</code></p>
  3211. </td>
  3212. </tr>
  3213. </table></div>
  3214. </div>
  3215. </div>
  3216. <div class="refsect2">
  3217. <a name="id-1.1.90.2.98"></a><h3>date-time-hash</h3>
  3218. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-time-hash datetime))
  3219. </pre></div>
  3220. <p>Hashes <em class="parameter"><code>datetime</code></em> into a <span class="type">guint</span>, suitable for use within <span class="type">GHashTable</span>.</p>
  3221. <div class="refsect3">
  3222. <a name="id-1.1.90.2.98.4"></a><h4>Parameters</h4>
  3223. <div class="informaltable"><table><tr>
  3224. <td class="parameter_name"><p>datetime</p></td>
  3225. <td class="parameter_description">
  3226. <p>a <span class="type">GDateTime</span></p>
  3227. <p>Passed as <code class="code">datetime</code></p>
  3228. </td>
  3229. </tr></table></div>
  3230. </div>
  3231. </div>
  3232. <div class="refsect2">
  3233. <a name="id-1.1.90.2.99"></a><h3>date-valid-day?</h3>
  3234. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-valid-day? day))
  3235. </pre></div>
  3236. <p>Returns <code class="constant">TRUE</code> if the day of the month is valid (a day is valid if it's
  3237. between 1 and 31 inclusive).</p>
  3238. <div class="refsect3">
  3239. <a name="id-1.1.90.2.99.4"></a><h4>Parameters</h4>
  3240. <div class="informaltable"><table><tr>
  3241. <td class="parameter_name"><p>day</p></td>
  3242. <td class="parameter_description">
  3243. <p>day to check</p>
  3244. <p>Passed as <code class="code">day</code></p>
  3245. </td>
  3246. </tr></table></div>
  3247. </div>
  3248. </div>
  3249. <div class="refsect2">
  3250. <a name="id-1.1.90.2.100"></a><h3>date-valid-dmy?</h3>
  3251. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-valid-dmy? day month year))
  3252. </pre></div>
  3253. <p>Returns <code class="constant">TRUE</code> if the day-month-year triplet forms a valid, existing day
  3254. in the range of days <span class="type">GDate</span> understands (Year 1 or later, no more than
  3255. a few thousand years in the future).</p>
  3256. <div class="refsect3">
  3257. <a name="id-1.1.90.2.100.4"></a><h4>Parameters</h4>
  3258. <div class="informaltable"><table>
  3259. <tr>
  3260. <td class="parameter_name"><p>day</p></td>
  3261. <td class="parameter_description">
  3262. <p>day</p>
  3263. <p>Passed as <code class="code">day</code></p>
  3264. </td>
  3265. </tr>
  3266. <tr>
  3267. <td class="parameter_name"><p>month</p></td>
  3268. <td class="parameter_description">
  3269. <p>month</p>
  3270. <p>Passed as <code class="code">month</code></p>
  3271. </td>
  3272. </tr>
  3273. <tr>
  3274. <td class="parameter_name"><p>year</p></td>
  3275. <td class="parameter_description">
  3276. <p>year</p>
  3277. <p>Passed as <code class="code">year</code></p>
  3278. </td>
  3279. </tr>
  3280. </table></div>
  3281. </div>
  3282. </div>
  3283. <div class="refsect2">
  3284. <a name="id-1.1.90.2.101"></a><h3>date-valid-julian?</h3>
  3285. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-valid-julian? julian-date))
  3286. </pre></div>
  3287. <p>Returns <code class="constant">TRUE</code> if the Julian day is valid. Anything greater than zero
  3288. is basically a valid Julian, though there is a 32-bit limit.</p>
  3289. <div class="refsect3">
  3290. <a name="id-1.1.90.2.101.4"></a><h4>Parameters</h4>
  3291. <div class="informaltable"><table><tr>
  3292. <td class="parameter_name"><p>julian_date</p></td>
  3293. <td class="parameter_description">
  3294. <p>Julian day to check</p>
  3295. <p>Passed as <code class="code">julian-date</code></p>
  3296. </td>
  3297. </tr></table></div>
  3298. </div>
  3299. </div>
  3300. <div class="refsect2">
  3301. <a name="id-1.1.90.2.102"></a><h3>date-valid-month?</h3>
  3302. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-valid-month? month))
  3303. </pre></div>
  3304. <p>Returns <code class="constant">TRUE</code> if the month value is valid. The 12 <span class="type">GDateMonth</span>
  3305. enumeration values are the only valid months.</p>
  3306. <div class="refsect3">
  3307. <a name="id-1.1.90.2.102.4"></a><h4>Parameters</h4>
  3308. <div class="informaltable"><table><tr>
  3309. <td class="parameter_name"><p>month</p></td>
  3310. <td class="parameter_description">
  3311. <p>month</p>
  3312. <p>Passed as <code class="code">month</code></p>
  3313. </td>
  3314. </tr></table></div>
  3315. </div>
  3316. </div>
  3317. <div class="refsect2">
  3318. <a name="id-1.1.90.2.103"></a><h3>date-valid-weekday?</h3>
  3319. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-valid-weekday? weekday))
  3320. </pre></div>
  3321. <p>Returns <code class="constant">TRUE</code> if the weekday is valid. The seven <span class="type">GDateWeekday</span> enumeration
  3322. values are the only valid weekdays.</p>
  3323. <div class="refsect3">
  3324. <a name="id-1.1.90.2.103.4"></a><h4>Parameters</h4>
  3325. <div class="informaltable"><table><tr>
  3326. <td class="parameter_name"><p>weekday</p></td>
  3327. <td class="parameter_description">
  3328. <p>weekday</p>
  3329. <p>Passed as <code class="code">weekday</code></p>
  3330. </td>
  3331. </tr></table></div>
  3332. </div>
  3333. </div>
  3334. <div class="refsect2">
  3335. <a name="id-1.1.90.2.104"></a><h3>date-valid-year?</h3>
  3336. <div class="informalexample"><pre class="programlisting">(define-values (%return) (date-valid-year? year))
  3337. </pre></div>
  3338. <p>Returns <code class="constant">TRUE</code> if the year is valid. Any year greater than 0 is valid,
  3339. though there is a 16-bit limit to what <span class="type">GDate</span> will understand.</p>
  3340. <div class="refsect3">
  3341. <a name="id-1.1.90.2.104.4"></a><h4>Parameters</h4>
  3342. <div class="informaltable"><table><tr>
  3343. <td class="parameter_name"><p>year</p></td>
  3344. <td class="parameter_description">
  3345. <p>year</p>
  3346. <p>Passed as <code class="code">year</code></p>
  3347. </td>
  3348. </tr></table></div>
  3349. </div>
  3350. </div>
  3351. <div class="refsect2">
  3352. <a name="id-1.1.90.2.105"></a><h3>dcgettext</h3>
  3353. <div class="informalexample"><pre class="programlisting">(define-values (%return) (dcgettext domain msgid category))
  3354. </pre></div>
  3355. <p>This is a variant of <code class="function">g_dgettext()</code> that allows specifying a locale
  3356. category instead of always using <code class="code">LC_MESSAGES</code>. See <code class="function">g_dgettext()</code> for
  3357. more information about how this functions differs from calling
  3358. <code class="function">dcgettext()</code> directly.</p>
  3359. <div class="refsect3">
  3360. <a name="id-1.1.90.2.105.4"></a><h4>Parameters</h4>
  3361. <div class="informaltable"><table>
  3362. <tr>
  3363. <td class="parameter_name"><p>domain</p></td>
  3364. <td class="parameter_description">
  3365. <p>the translation domain to use, or <code class="constant">NULL</code> to use
  3366. the domain set with <code class="function">textdomain()</code></p>
  3367. <p>Passed as <code class="code">domain</code></p>
  3368. </td>
  3369. </tr>
  3370. <tr>
  3371. <td class="parameter_name"><p>msgid</p></td>
  3372. <td class="parameter_description">
  3373. <p>message to translate</p>
  3374. <p>Passed as <code class="code">msgid</code></p>
  3375. </td>
  3376. </tr>
  3377. <tr>
  3378. <td class="parameter_name"><p>category</p></td>
  3379. <td class="parameter_description">
  3380. <p>a locale category</p>
  3381. <p>Passed as <code class="code">category</code></p>
  3382. </td>
  3383. </tr>
  3384. </table></div>
  3385. </div>
  3386. </div>
  3387. <div class="refsect2">
  3388. <a name="id-1.1.90.2.106"></a><h3>dgettext</h3>
  3389. <div class="informalexample"><pre class="programlisting">(define-values (%return) (dgettext domain msgid))
  3390. </pre></div>
  3391. <p>This function is a wrapper of <code class="function">dgettext()</code> which does not translate
  3392. the message if the default domain as set with <code class="function">textdomain()</code> has no
  3393. translations for the current locale.
  3394. </p>
  3395. <p>The advantage of using this function over <code class="function">dgettext()</code> proper is that
  3396. libraries using this function (like GTK+) will not use translations
  3397. if the application using the library does not have translations for
  3398. the current locale. This results in a consistent English-only
  3399. interface instead of one having partial translations. For this
  3400. feature to work, the call to <code class="function">textdomain()</code> and <code class="function">setlocale()</code> should
  3401. precede any <code class="function">g_dgettext()</code> invocations. For GTK+, it means calling
  3402. <code class="function">textdomain()</code> before gtk_init or its variants.
  3403. </p>
  3404. <p>This function disables translations if and only if upon its first
  3405. call all the following conditions hold:
  3406. </p>
  3407. <p>- <em class="parameter"><code>domain</code></em> is not <code class="constant">NULL</code>
  3408. </p>
  3409. <p>- <code class="function">textdomain()</code> has been called to set a default text domain
  3410. </p>
  3411. <p>- there is no translations available for the default text domain
  3412. and the current locale
  3413. </p>
  3414. <p>- current locale is not "C" or any English locales (those
  3415. starting with "en_")
  3416. </p>
  3417. <p>Note that this behavior may not be desired for example if an application
  3418. has its untranslated messages in a language other than English. In those
  3419. cases the application should call <code class="function">textdomain()</code> after initializing GTK+.
  3420. </p>
  3421. <p>Applications should normally not use this function directly,
  3422. but use the <code class="function">_()</code> macro for translations.</p>
  3423. <div class="refsect3">
  3424. <a name="id-1.1.90.2.106.12"></a><h4>Parameters</h4>
  3425. <div class="informaltable"><table>
  3426. <tr>
  3427. <td class="parameter_name"><p>domain</p></td>
  3428. <td class="parameter_description">
  3429. <p>the translation domain to use, or <code class="constant">NULL</code> to use
  3430. the domain set with <code class="function">textdomain()</code></p>
  3431. <p>Passed as <code class="code">domain</code></p>
  3432. </td>
  3433. </tr>
  3434. <tr>
  3435. <td class="parameter_name"><p>msgid</p></td>
  3436. <td class="parameter_description">
  3437. <p>message to translate</p>
  3438. <p>Passed as <code class="code">msgid</code></p>
  3439. </td>
  3440. </tr>
  3441. </table></div>
  3442. </div>
  3443. </div>
  3444. <div class="refsect2">
  3445. <a name="id-1.1.90.2.107"></a><h3>dir-make-tmp</h3>
  3446. <div class="informalexample"><pre class="programlisting">(define-values (%return) (dir-make-tmp tmpl))
  3447. </pre></div>
  3448. <p>Creates a subdirectory in the preferred directory for temporary
  3449. files (as returned by <code class="function">g_get_tmp_dir()</code>).
  3450. </p>
  3451. <p><em class="parameter"><code>tmpl</code></em> should be a string in the GLib file name encoding containing
  3452. a sequence of six 'X' characters, as the parameter to <code class="function">g_mkstemp()</code>.
  3453. However, unlike these functions, the template should only be a
  3454. basename, no directory components are allowed. If template is
  3455. <code class="constant">NULL</code>, a default template is used.
  3456. </p>
  3457. <p>Note that in contrast to <code class="function">g_mkdtemp()</code> (and <code class="function">mkdtemp()</code>) <em class="parameter"><code>tmpl</code></em> is not
  3458. modified, and might thus be a read-only literal string.</p>
  3459. <div class="refsect3">
  3460. <a name="id-1.1.90.2.107.6"></a><h4>Parameters</h4>
  3461. <div class="informaltable"><table><tr>
  3462. <td class="parameter_name"><p>tmpl</p></td>
  3463. <td class="parameter_description">
  3464. <p>Template for directory name,
  3465. as in <code class="function">g_mkdtemp()</code>, basename only, or <code class="constant">NULL</code> for a default template</p>
  3466. <p>Passed as <code class="code">tmpl</code></p>
  3467. </td>
  3468. </tr></table></div>
  3469. </div>
  3470. </div>
  3471. <div class="refsect2">
  3472. <a name="id-1.1.90.2.108"></a><h3>direct-equal?</h3>
  3473. <div class="informalexample"><pre class="programlisting">(define-values (%return) (direct-equal? v1 v2))
  3474. </pre></div>
  3475. <p>Compares two <span class="type">gpointer</span> arguments and returns <code class="constant">TRUE</code> if they are equal.
  3476. It can be passed to <code class="function">g_hash_table_new()</code> as the <em class="parameter"><code>key_equal_func</code></em>
  3477. parameter, when using opaque pointers compared by pointer value as
  3478. keys in a <span class="type">GHashTable</span>.
  3479. </p>
  3480. <p>This equality function is also appropriate for keys that are integers
  3481. stored in pointers, such as <code class="code">GINT_TO_POINTER (n)</code>.</p>
  3482. <div class="refsect3">
  3483. <a name="id-1.1.90.2.108.5"></a><h4>Parameters</h4>
  3484. <div class="informaltable"><table>
  3485. <tr>
  3486. <td class="parameter_name"><p>v1</p></td>
  3487. <td class="parameter_description">
  3488. <p>a key</p>
  3489. <p>Passed as <code class="code">v1</code></p>
  3490. </td>
  3491. </tr>
  3492. <tr>
  3493. <td class="parameter_name"><p>v2</p></td>
  3494. <td class="parameter_description">
  3495. <p>a key to compare with <em class="parameter"><code>v1</code></em></p>
  3496. <p>Passed as <code class="code">v2</code></p>
  3497. </td>
  3498. </tr>
  3499. </table></div>
  3500. </div>
  3501. </div>
  3502. <div class="refsect2">
  3503. <a name="id-1.1.90.2.109"></a><h3>direct-hash</h3>
  3504. <div class="informalexample"><pre class="programlisting">(define-values (%return) (direct-hash v))
  3505. </pre></div>
  3506. <p>Converts a gpointer to a hash value.
  3507. It can be passed to <code class="function">g_hash_table_new()</code> as the <em class="parameter"><code>hash_func</code></em> parameter,
  3508. when using opaque pointers compared by pointer value as keys in a
  3509. <span class="type">GHashTable</span>.
  3510. </p>
  3511. <p>This hash function is also appropriate for keys that are integers
  3512. stored in pointers, such as <code class="code">GINT_TO_POINTER (n)</code>.</p>
  3513. <div class="refsect3">
  3514. <a name="id-1.1.90.2.109.5"></a><h4>Parameters</h4>
  3515. <div class="informaltable"><table><tr>
  3516. <td class="parameter_name"><p>v</p></td>
  3517. <td class="parameter_description">
  3518. <p>a <span class="type">gpointer</span> key</p>
  3519. <p>Passed as <code class="code">v</code></p>
  3520. </td>
  3521. </tr></table></div>
  3522. </div>
  3523. </div>
  3524. <div class="refsect2">
  3525. <a name="id-1.1.90.2.110"></a><h3>dngettext</h3>
  3526. <div class="informalexample"><pre class="programlisting">(define-values (%return) (dngettext domain msgid msgid-plural n))
  3527. </pre></div>
  3528. <p>This function is a wrapper of <code class="function">dngettext()</code> which does not translate
  3529. the message if the default domain as set with <code class="function">textdomain()</code> has no
  3530. translations for the current locale.
  3531. </p>
  3532. <p>See <code class="function">g_dgettext()</code> for details of how this differs from <code class="function">dngettext()</code>
  3533. proper.</p>
  3534. <div class="refsect3">
  3535. <a name="id-1.1.90.2.110.5"></a><h4>Parameters</h4>
  3536. <div class="informaltable"><table>
  3537. <tr>
  3538. <td class="parameter_name"><p>domain</p></td>
  3539. <td class="parameter_description">
  3540. <p>the translation domain to use, or <code class="constant">NULL</code> to use
  3541. the domain set with <code class="function">textdomain()</code></p>
  3542. <p>Passed as <code class="code">domain</code></p>
  3543. </td>
  3544. </tr>
  3545. <tr>
  3546. <td class="parameter_name"><p>msgid</p></td>
  3547. <td class="parameter_description">
  3548. <p>message to translate</p>
  3549. <p>Passed as <code class="code">msgid</code></p>
  3550. </td>
  3551. </tr>
  3552. <tr>
  3553. <td class="parameter_name"><p>msgid_plural</p></td>
  3554. <td class="parameter_description">
  3555. <p>plural form of the message</p>
  3556. <p>Passed as <code class="code">msgid-plural</code></p>
  3557. </td>
  3558. </tr>
  3559. <tr>
  3560. <td class="parameter_name"><p>n</p></td>
  3561. <td class="parameter_description">
  3562. <p>the quantity for which translation is needed</p>
  3563. <p>Passed as <code class="code">n</code></p>
  3564. </td>
  3565. </tr>
  3566. </table></div>
  3567. </div>
  3568. </div>
  3569. <div class="refsect2">
  3570. <a name="id-1.1.90.2.111"></a><h3>double-equal?</h3>
  3571. <div class="informalexample"><pre class="programlisting">(define-values (%return) (double-equal? v1 v2))
  3572. </pre></div>
  3573. <p>Compares the two <span class="type">gdouble</span> values being pointed to and returns
  3574. <code class="constant">TRUE</code> if they are equal.
  3575. It can be passed to <code class="function">g_hash_table_new()</code> as the <em class="parameter"><code>key_equal_func</code></em>
  3576. parameter, when using non-<code class="constant">NULL</code> pointers to doubles as keys in a
  3577. <span class="type">GHashTable</span>.</p>
  3578. <div class="refsect3">
  3579. <a name="id-1.1.90.2.111.4"></a><h4>Parameters</h4>
  3580. <div class="informaltable"><table>
  3581. <tr>
  3582. <td class="parameter_name"><p>v1</p></td>
  3583. <td class="parameter_description">
  3584. <p>a pointer to a <span class="type">gdouble</span> key</p>
  3585. <p>Passed as <code class="code">v1</code></p>
  3586. </td>
  3587. </tr>
  3588. <tr>
  3589. <td class="parameter_name"><p>v2</p></td>
  3590. <td class="parameter_description">
  3591. <p>a pointer to a <span class="type">gdouble</span> key to compare with <em class="parameter"><code>v1</code></em></p>
  3592. <p>Passed as <code class="code">v2</code></p>
  3593. </td>
  3594. </tr>
  3595. </table></div>
  3596. </div>
  3597. </div>
  3598. <div class="refsect2">
  3599. <a name="id-1.1.90.2.112"></a><h3>double-hash</h3>
  3600. <div class="informalexample"><pre class="programlisting">(define-values (%return) (double-hash v))
  3601. </pre></div>
  3602. <p>Converts a pointer to a <span class="type">gdouble</span> to a hash value.
  3603. It can be passed to <code class="function">g_hash_table_new()</code> as the <em class="parameter"><code>hash_func</code></em> parameter,
  3604. It can be passed to <code class="function">g_hash_table_new()</code> as the <em class="parameter"><code>hash_func</code></em> parameter,
  3605. when using non-<code class="constant">NULL</code> pointers to doubles as keys in a <span class="type">GHashTable</span>.</p>
  3606. <div class="refsect3">
  3607. <a name="id-1.1.90.2.112.4"></a><h4>Parameters</h4>
  3608. <div class="informaltable"><table><tr>
  3609. <td class="parameter_name"><p>v</p></td>
  3610. <td class="parameter_description">
  3611. <p>a pointer to a <span class="type">gdouble</span> key</p>
  3612. <p>Passed as <code class="code">v</code></p>
  3613. </td>
  3614. </tr></table></div>
  3615. </div>
  3616. </div>
  3617. <div class="refsect2">
  3618. <a name="id-1.1.90.2.113"></a><h3>dpgettext</h3>
  3619. <div class="informalexample"><pre class="programlisting">(define-values (%return) (dpgettext domain msgctxtid msgidoffset))
  3620. </pre></div>
  3621. <p>This function is a variant of <code class="function">g_dgettext()</code> which supports
  3622. a disambiguating message context. GNU gettext uses the
  3623. '\004' character to separate the message context and
  3624. message id in <em class="parameter"><code>msgctxtid</code></em>.
  3625. If 0 is passed as <em class="parameter"><code>msgidoffset</code></em>, this function will fall back to
  3626. trying to use the deprecated convention of using "|" as a separation
  3627. character.
  3628. </p>
  3629. <p>This uses <code class="function">g_dgettext()</code> internally. See that functions for differences
  3630. with <code class="function">dgettext()</code> proper.
  3631. </p>
  3632. <p>Applications should normally not use this function directly,
  3633. but use the <code class="function">C_()</code> macro for translations with context.</p>
  3634. <div class="refsect3">
  3635. <a name="id-1.1.90.2.113.6"></a><h4>Parameters</h4>
  3636. <div class="informaltable"><table>
  3637. <tr>
  3638. <td class="parameter_name"><p>domain</p></td>
  3639. <td class="parameter_description">
  3640. <p>the translation domain to use, or <code class="constant">NULL</code> to use
  3641. the domain set with <code class="function">textdomain()</code></p>
  3642. <p>Passed as <code class="code">domain</code></p>
  3643. </td>
  3644. </tr>
  3645. <tr>
  3646. <td class="parameter_name"><p>msgctxtid</p></td>
  3647. <td class="parameter_description">
  3648. <p>a combined message context and message id, separated
  3649. by a \004 character</p>
  3650. <p>Passed as <code class="code">msgctxtid</code></p>
  3651. </td>
  3652. </tr>
  3653. <tr>
  3654. <td class="parameter_name"><p>msgidoffset</p></td>
  3655. <td class="parameter_description">
  3656. <p>the offset of the message id in <em class="parameter"><code>msgctxid</code></em></p>
  3657. <p>Passed as <code class="code">msgidoffset</code></p>
  3658. </td>
  3659. </tr>
  3660. </table></div>
  3661. </div>
  3662. </div>
  3663. <div class="refsect2">
  3664. <a name="id-1.1.90.2.114"></a><h3>dpgettext2</h3>
  3665. <div class="informalexample"><pre class="programlisting">(define-values (%return) (dpgettext2 domain context msgid))
  3666. </pre></div>
  3667. <p>This function is a variant of <code class="function">g_dgettext()</code> which supports
  3668. a disambiguating message context. GNU gettext uses the
  3669. '\004' character to separate the message context and
  3670. message id in <em class="parameter"><code>msgctxtid</code></em>.
  3671. </p>
  3672. <p>This uses <code class="function">g_dgettext()</code> internally. See that functions for differences
  3673. with <code class="function">dgettext()</code> proper.
  3674. </p>
  3675. <p>This function differs from <code class="function">C_()</code> in that it is not a macro and
  3676. thus you may use non-string-literals as context and msgid arguments.</p>
  3677. <div class="refsect3">
  3678. <a name="id-1.1.90.2.114.6"></a><h4>Parameters</h4>
  3679. <div class="informaltable"><table>
  3680. <tr>
  3681. <td class="parameter_name"><p>domain</p></td>
  3682. <td class="parameter_description">
  3683. <p>the translation domain to use, or <code class="constant">NULL</code> to use
  3684. the domain set with <code class="function">textdomain()</code></p>
  3685. <p>Passed as <code class="code">domain</code></p>
  3686. </td>
  3687. </tr>
  3688. <tr>
  3689. <td class="parameter_name"><p>context</p></td>
  3690. <td class="parameter_description">
  3691. <p>the message context</p>
  3692. <p>Passed as <code class="code">context</code></p>
  3693. </td>
  3694. </tr>
  3695. <tr>
  3696. <td class="parameter_name"><p>msgid</p></td>
  3697. <td class="parameter_description">
  3698. <p>the message</p>
  3699. <p>Passed as <code class="code">msgid</code></p>
  3700. </td>
  3701. </tr>
  3702. </table></div>
  3703. </div>
  3704. </div>
  3705. <div class="refsect2">
  3706. <a name="id-1.1.90.2.115"></a><h3>environ-getenv</h3>
  3707. <div class="informalexample"><pre class="programlisting">(define-values (%return) (environ-getenv envp variable))
  3708. </pre></div>
  3709. <p>Returns the value of the environment variable <em class="parameter"><code>variable</code></em> in the
  3710. provided list <em class="parameter"><code>envp</code></em>.</p>
  3711. <div class="refsect3">
  3712. <a name="id-1.1.90.2.115.4"></a><h4>Parameters</h4>
  3713. <div class="informaltable"><table>
  3714. <tr>
  3715. <td class="parameter_name"><p>envp</p></td>
  3716. <td class="parameter_description">
  3717. <p>
  3718. </p>
  3719. <p>an environment list (eg, as returned from <code class="function">g_get_environ()</code>), or <code class="constant">NULL</code>
  3720. for an empty environment list</p>
  3721. <p>Passed as <code class="code">envp</code></p>
  3722. </td>
  3723. </tr>
  3724. <tr>
  3725. <td class="parameter_name"><p>variable</p></td>
  3726. <td class="parameter_description">
  3727. <p>the environment variable to get</p>
  3728. <p>Passed as <code class="code">variable</code></p>
  3729. </td>
  3730. </tr>
  3731. </table></div>
  3732. </div>
  3733. </div>
  3734. <div class="refsect2">
  3735. <a name="id-1.1.90.2.116"></a><h3>environ-setenv</h3>
  3736. <div class="informalexample"><pre class="programlisting">(define-values (%return) (environ-setenv envp variable value overwrite))
  3737. </pre></div>
  3738. <p>Sets the environment variable <em class="parameter"><code>variable</code></em> in the provided list
  3739. <em class="parameter"><code>envp</code></em> to <em class="parameter"><code>value</code></em>.</p>
  3740. <div class="refsect3">
  3741. <a name="id-1.1.90.2.116.4"></a><h4>Parameters</h4>
  3742. <div class="informaltable"><table>
  3743. <tr>
  3744. <td class="parameter_name"><p>envp</p></td>
  3745. <td class="parameter_description">
  3746. <p>
  3747. </p>
  3748. <p>an environment list that can be freed using <code class="function">g_strfreev()</code> (e.g., as
  3749. returned from <code class="function">g_get_environ()</code>), or <code class="constant">NULL</code> for an empty
  3750. environment list</p>
  3751. <p>Passed as <code class="code">envp</code></p>
  3752. </td>
  3753. </tr>
  3754. <tr>
  3755. <td class="parameter_name"><p>variable</p></td>
  3756. <td class="parameter_description">
  3757. <p>the environment variable to set, must not
  3758. contain '='</p>
  3759. <p>Passed as <code class="code">variable</code></p>
  3760. </td>
  3761. </tr>
  3762. <tr>
  3763. <td class="parameter_name"><p>value</p></td>
  3764. <td class="parameter_description">
  3765. <p>the value for to set the variable to</p>
  3766. <p>Passed as <code class="code">value</code></p>
  3767. </td>
  3768. </tr>
  3769. <tr>
  3770. <td class="parameter_name"><p>overwrite</p></td>
  3771. <td class="parameter_description">
  3772. <p>whether to change the variable if it already exists</p>
  3773. <p>Passed as <code class="code">overwrite</code></p>
  3774. </td>
  3775. </tr>
  3776. </table></div>
  3777. </div>
  3778. </div>
  3779. <div class="refsect2">
  3780. <a name="id-1.1.90.2.117"></a><h3>environ-unsetenv</h3>
  3781. <div class="informalexample"><pre class="programlisting">(define-values (%return) (environ-unsetenv envp variable))
  3782. </pre></div>
  3783. <p>Removes the environment variable <em class="parameter"><code>variable</code></em> from the provided
  3784. environment <em class="parameter"><code>envp</code></em>.</p>
  3785. <div class="refsect3">
  3786. <a name="id-1.1.90.2.117.4"></a><h4>Parameters</h4>
  3787. <div class="informaltable"><table>
  3788. <tr>
  3789. <td class="parameter_name"><p>envp</p></td>
  3790. <td class="parameter_description">
  3791. <p>
  3792. </p>
  3793. <p>an environment list that can be freed using <code class="function">g_strfreev()</code> (e.g., as
  3794. returned from <code class="function">g_get_environ()</code>), or <code class="constant">NULL</code> for an empty environment list</p>
  3795. <p>Passed as <code class="code">envp</code></p>
  3796. </td>
  3797. </tr>
  3798. <tr>
  3799. <td class="parameter_name"><p>variable</p></td>
  3800. <td class="parameter_description">
  3801. <p>the environment variable to remove, must not
  3802. contain '='</p>
  3803. <p>Passed as <code class="code">variable</code></p>
  3804. </td>
  3805. </tr>
  3806. </table></div>
  3807. </div>
  3808. </div>
  3809. <div class="refsect2">
  3810. <a name="id-1.1.90.2.118"></a><h3>file-error-from-errno</h3>
  3811. <div class="informalexample"><pre class="programlisting">(define-values (%return) (file-error-from-errno err-no))
  3812. </pre></div>
  3813. <p>Gets a <span class="type">GFileError</span> constant based on the passed-in <em class="parameter"><code>err_no</code></em>.
  3814. For example, if you pass in <code class="code">EEXIST</code> this function returns
  3815. <span class="type">G_FILE_ERROR_EXIST</span>. Unlike <code class="code">errno</code> values, you can portably
  3816. assume that all <span class="type">GFileError</span> values will exist.
  3817. </p>
  3818. <p>Normally a <span class="type">GFileError</span> value goes into a <span class="type">GError</span> returned
  3819. from a function that manipulates files. So you would use
  3820. <code class="function">g_file_error_from_errno()</code> when constructing a <span class="type">GError</span>.</p>
  3821. <div class="refsect3">
  3822. <a name="id-1.1.90.2.118.5"></a><h4>Parameters</h4>
  3823. <div class="informaltable"><table><tr>
  3824. <td class="parameter_name"><p>err_no</p></td>
  3825. <td class="parameter_description">
  3826. <p>an "errno" value</p>
  3827. <p>Passed as <code class="code">err-no</code></p>
  3828. </td>
  3829. </tr></table></div>
  3830. </div>
  3831. </div>
  3832. <div class="refsect2">
  3833. <a name="id-1.1.90.2.119"></a><h3>file-error-quark</h3>
  3834. <div class="informalexample"><pre class="programlisting">(define-values (%return) (file-error-quark))
  3835. </pre></div>
  3836. <p>Undocumented</p>
  3837. </div>
  3838. <div class="refsect2">
  3839. <a name="id-1.1.90.2.120"></a><h3>file-get-contents</h3>
  3840. <div class="informalexample"><pre class="programlisting">(define-values (%return contents length) (file-get-contents filename))
  3841. </pre></div>
  3842. <p>Reads an entire file into allocated memory, with good error
  3843. checking.
  3844. </p>
  3845. <p>If the call was successful, it returns <code class="constant">TRUE</code> and sets <em class="parameter"><code>contents</code></em> to the file
  3846. contents and <em class="parameter"><code>length</code></em> to the length of the file contents in bytes. The string
  3847. stored in <em class="parameter"><code>contents</code></em> will be nul-terminated, so for text files you can pass
  3848. <code class="constant">NULL</code> for the <em class="parameter"><code>length</code></em> argument. If the call was not successful, it returns
  3849. <code class="constant">FALSE</code> and sets <em class="parameter"><code>error</code></em>. The error domain is <span class="type">G_FILE_ERROR</span>. Possible error
  3850. codes are those in the <span class="type">GFileError</span> enumeration. In the error case,
  3851. <em class="parameter"><code>contents</code></em> is set to <code class="constant">NULL</code> and <em class="parameter"><code>length</code></em> is set to zero.</p>
  3852. <div class="refsect3">
  3853. <a name="id-1.1.90.2.120.5"></a><h4>Parameters</h4>
  3854. <div class="informaltable"><table>
  3855. <tr>
  3856. <td class="parameter_name"><p>filename</p></td>
  3857. <td class="parameter_description">
  3858. <p>name of a file to read contents from, in the GLib file name encoding</p>
  3859. <p>Passed as <code class="code">filename</code></p>
  3860. </td>
  3861. </tr>
  3862. <tr>
  3863. <td class="parameter_name"><p>contents</p></td>
  3864. <td class="parameter_description">
  3865. <p>location to store an allocated string, use <code class="function">g_free()</code> to free
  3866. the returned string</p>
  3867. <p>Passed as <code class="code">contents</code></p>
  3868. </td>
  3869. </tr>
  3870. <tr>
  3871. <td class="parameter_name"><p>length</p></td>
  3872. <td class="parameter_description">
  3873. <p>location to store length in bytes of the contents, or <code class="constant">NULL</code></p>
  3874. <p>Inferred from <code class="code">contents</code></p>
  3875. </td>
  3876. </tr>
  3877. </table></div>
  3878. </div>
  3879. </div>
  3880. <div class="refsect2">
  3881. <a name="id-1.1.90.2.121"></a><h3>file-open-tmp</h3>
  3882. <div class="informalexample"><pre class="programlisting">(define-values (%return name-used) (file-open-tmp tmpl))
  3883. </pre></div>
  3884. <p>Opens a file for writing in the preferred directory for temporary
  3885. files (as returned by <code class="function">g_get_tmp_dir()</code>).
  3886. </p>
  3887. <p><em class="parameter"><code>tmpl</code></em> should be a string in the GLib file name encoding containing
  3888. a sequence of six 'X' characters, as the parameter to <code class="function">g_mkstemp()</code>.
  3889. However, unlike these functions, the template should only be a
  3890. basename, no directory components are allowed. If template is
  3891. <code class="constant">NULL</code>, a default template is used.
  3892. </p>
  3893. <p>Note that in contrast to <code class="function">g_mkstemp()</code> (and <code class="function">mkstemp()</code>) <em class="parameter"><code>tmpl</code></em> is not
  3894. modified, and might thus be a read-only literal string.
  3895. </p>
  3896. <p>Upon success, and if <em class="parameter"><code>name_used</code></em> is non-<code class="constant">NULL</code>, the actual name used
  3897. is returned in <em class="parameter"><code>name_used</code></em>. This string should be freed with <code class="function">g_free()</code>
  3898. when not needed any longer. The returned name is in the GLib file
  3899. name encoding.</p>
  3900. <div class="refsect3">
  3901. <a name="id-1.1.90.2.121.7"></a><h4>Parameters</h4>
  3902. <div class="informaltable"><table>
  3903. <tr>
  3904. <td class="parameter_name"><p>tmpl</p></td>
  3905. <td class="parameter_description">
  3906. <p>Template for file name, as in
  3907. <code class="function">g_mkstemp()</code>, basename only, or <code class="constant">NULL</code> for a default template</p>
  3908. <p>Passed as <code class="code">tmpl</code></p>
  3909. </td>
  3910. </tr>
  3911. <tr>
  3912. <td class="parameter_name"><p>name_used</p></td>
  3913. <td class="parameter_description">
  3914. <p>location to store actual name used,
  3915. or <code class="constant">NULL</code></p>
  3916. <p>Passed as <code class="code">name-used</code></p>
  3917. </td>
  3918. </tr>
  3919. </table></div>
  3920. </div>
  3921. </div>
  3922. <div class="refsect2">
  3923. <a name="id-1.1.90.2.122"></a><h3>file-read-link</h3>
  3924. <div class="informalexample"><pre class="programlisting">(define-values (%return) (file-read-link filename))
  3925. </pre></div>
  3926. <p>Reads the contents of the symbolic link <em class="parameter"><code>filename</code></em> like the POSIX
  3927. <code class="function">readlink()</code> function. The returned string is in the encoding used
  3928. for filenames. Use <code class="function">g_filename_to_utf8()</code> to convert it to UTF-8.</p>
  3929. <div class="refsect3">
  3930. <a name="id-1.1.90.2.122.4"></a><h4>Parameters</h4>
  3931. <div class="informaltable"><table><tr>
  3932. <td class="parameter_name"><p>filename</p></td>
  3933. <td class="parameter_description">
  3934. <p>the symbolic link</p>
  3935. <p>Passed as <code class="code">filename</code></p>
  3936. </td>
  3937. </tr></table></div>
  3938. </div>
  3939. </div>
  3940. <div class="refsect2">
  3941. <a name="id-1.1.90.2.123"></a><h3>file-set-contents?</h3>
  3942. <div class="informalexample"><pre class="programlisting">(define-values (%return) (file-set-contents? filename contents))
  3943. </pre></div>
  3944. <p>Writes all of <em class="parameter"><code>contents</code></em> to a file named <em class="parameter"><code>filename</code></em>. This is a convenience
  3945. wrapper around calling <code class="function">g_file_set_contents()</code> with <code class="code">flags</code> set to
  3946. <code class="code">G_FILE_SET_CONTENTS_CONSISTENT | G_FILE_SET_CONTENTS_ONLY_EXISTING</code> and
  3947. <code class="code">mode</code> set to <code class="code">0666</code>.</p>
  3948. <div class="refsect3">
  3949. <a name="id-1.1.90.2.123.4"></a><h4>Parameters</h4>
  3950. <div class="informaltable"><table>
  3951. <tr>
  3952. <td class="parameter_name"><p>filename</p></td>
  3953. <td class="parameter_description">
  3954. <p>name of a file to write <em class="parameter"><code>contents</code></em> to, in the GLib file name
  3955. encoding</p>
  3956. <p>Passed as <code class="code">filename</code></p>
  3957. </td>
  3958. </tr>
  3959. <tr>
  3960. <td class="parameter_name"><p>contents</p></td>
  3961. <td class="parameter_description">
  3962. <p>string to write to the file</p>
  3963. <p>Passed as <code class="code">contents</code></p>
  3964. </td>
  3965. </tr>
  3966. <tr>
  3967. <td class="parameter_name"><p>length</p></td>
  3968. <td class="parameter_description">
  3969. <p>length of <em class="parameter"><code>contents</code></em>, or -1 if <em class="parameter"><code>contents</code></em> is a nul-terminated string</p>
  3970. <p>Inferred from <code class="code">contents</code></p>
  3971. </td>
  3972. </tr>
  3973. </table></div>
  3974. </div>
  3975. </div>
  3976. <div class="refsect2">
  3977. <a name="id-1.1.90.2.124"></a><h3>file-set-contents-full?</h3>
  3978. <div class="informalexample"><pre class="programlisting">(define-values
  3979. (%return)
  3980. (file-set-contents-full? filename contents flags mode))
  3981. </pre></div>
  3982. <p>Writes all of <em class="parameter"><code>contents</code></em> to a file named <em class="parameter"><code>filename</code></em>, with good error checking.
  3983. If a file called <em class="parameter"><code>filename</code></em> already exists it will be overwritten.
  3984. </p>
  3985. <p><em class="parameter"><code>flags</code></em> control the properties of the write operation: whether it’s atomic,
  3986. and what the tradeoff is between returning quickly or being resilient to
  3987. system crashes.
  3988. </p>
  3989. <p>As this function performs file I/O, it is recommended to not call it anywhere
  3990. where blocking would cause problems, such as in the main loop of a graphical
  3991. application. In particular, if <em class="parameter"><code>flags</code></em> has any value other than
  3992. <code class="constant">G_FILE_SET_CONTENTS_NONE</code> then this function may call <code class="code">fsync()</code>.
  3993. </p>
  3994. <p>If <code class="constant">G_FILE_SET_CONTENTS_CONSISTENT</code> is set in <em class="parameter"><code>flags</code></em>, the operation is atomic
  3995. in the sense that it is first written to a temporary file which is then
  3996. renamed to the final name.
  3997. </p>
  3998. <p>Notes:
  3999. </p>
  4000. <p>- On UNIX, if <em class="parameter"><code>filename</code></em> already exists hard links to <em class="parameter"><code>filename</code></em> will break.
  4001. Also since the file is recreated, existing permissions, access control
  4002. lists, metadata etc. may be lost. If <em class="parameter"><code>filename</code></em> is a symbolic link,
  4003. the link itself will be replaced, not the linked file.
  4004. </p>
  4005. <p>- On UNIX, if <em class="parameter"><code>filename</code></em> already exists and is non-empty, and if the system
  4006. supports it (via a journalling filesystem or equivalent), and if
  4007. <code class="constant">G_FILE_SET_CONTENTS_CONSISTENT</code> is set in <em class="parameter"><code>flags</code></em>, the <code class="code">fsync()</code> call (or
  4008. equivalent) will be used to ensure atomic replacement: <em class="parameter"><code>filename</code></em>
  4009. will contain either its old contents or <em class="parameter"><code>contents</code></em>, even in the face of
  4010. system power loss, the disk being unsafely removed, etc.
  4011. </p>
  4012. <p>- On UNIX, if <em class="parameter"><code>filename</code></em> does not already exist or is empty, there is a
  4013. possibility that system power loss etc. after calling this function will
  4014. leave <em class="parameter"><code>filename</code></em> empty or full of NUL bytes, depending on the underlying
  4015. filesystem, unless <code class="constant">G_FILE_SET_CONTENTS_DURABLE</code> and
  4016. <code class="constant">G_FILE_SET_CONTENTS_CONSISTENT</code> are set in <em class="parameter"><code>flags</code></em>.
  4017. </p>
  4018. <p>- On Windows renaming a file will not remove an existing file with the
  4019. new name, so on Windows there is a race condition between the existing
  4020. file being removed and the temporary file being renamed.
  4021. </p>
  4022. <p>- On Windows there is no way to remove a file that is open to some
  4023. process, or mapped into memory. Thus, this function will fail if
  4024. <em class="parameter"><code>filename</code></em> already exists and is open.
  4025. </p>
  4026. <p>If the call was successful, it returns <code class="constant">TRUE</code>. If the call was not successful,
  4027. it returns <code class="constant">FALSE</code> and sets <em class="parameter"><code>error</code></em>. The error domain is <span class="type">G_FILE_ERROR</span>.
  4028. Possible error codes are those in the <span class="type">GFileError</span> enumeration.
  4029. </p>
  4030. <p>Note that the name for the temporary file is constructed by appending up
  4031. to 7 characters to <em class="parameter"><code>filename</code></em>.
  4032. </p>
  4033. <p>If the file didn’t exist before and is created, it will be given the
  4034. permissions from <em class="parameter"><code>mode</code></em>. Otherwise, the permissions of the existing file may
  4035. be changed to <em class="parameter"><code>mode</code></em> depending on <em class="parameter"><code>flags</code></em>, or they may remain unchanged.</p>
  4036. <div class="refsect3">
  4037. <a name="id-1.1.90.2.124.16"></a><h4>Parameters</h4>
  4038. <div class="informaltable"><table>
  4039. <tr>
  4040. <td class="parameter_name"><p>filename</p></td>
  4041. <td class="parameter_description">
  4042. <p>name of a file to write <em class="parameter"><code>contents</code></em> to, in the GLib file name
  4043. encoding</p>
  4044. <p>Passed as <code class="code">filename</code></p>
  4045. </td>
  4046. </tr>
  4047. <tr>
  4048. <td class="parameter_name"><p>contents</p></td>
  4049. <td class="parameter_description">
  4050. <p>string to write to the file</p>
  4051. <p>Passed as <code class="code">contents</code></p>
  4052. </td>
  4053. </tr>
  4054. <tr>
  4055. <td class="parameter_name"><p>length</p></td>
  4056. <td class="parameter_description">
  4057. <p>length of <em class="parameter"><code>contents</code></em>, or -1 if <em class="parameter"><code>contents</code></em> is a nul-terminated string</p>
  4058. <p>Inferred from <code class="code">contents</code></p>
  4059. </td>
  4060. </tr>
  4061. <tr>
  4062. <td class="parameter_name"><p>flags</p></td>
  4063. <td class="parameter_description">
  4064. <p>flags controlling the safety vs speed of the operation</p>
  4065. <p>Passed as <code class="code">flags</code></p>
  4066. </td>
  4067. </tr>
  4068. <tr>
  4069. <td class="parameter_name"><p>mode</p></td>
  4070. <td class="parameter_description">
  4071. <p>file mode, as passed to <code class="code">open()</code>; typically this will be <code class="code">0666</code></p>
  4072. <p>Passed as <code class="code">mode</code></p>
  4073. </td>
  4074. </tr>
  4075. </table></div>
  4076. </div>
  4077. </div>
  4078. <div class="refsect2">
  4079. <a name="id-1.1.90.2.125"></a><h3>file-test?</h3>
  4080. <div class="informalexample"><pre class="programlisting">(define-values (%return) (file-test? filename test))
  4081. </pre></div>
  4082. <p>Returns <code class="constant">TRUE</code> if any of the tests in the bitfield <em class="parameter"><code>test</code></em> are
  4083. <code class="constant">TRUE</code>. For example, <code class="code">(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)</code>
  4084. will return <code class="constant">TRUE</code> if the file exists; the check whether it's a
  4085. directory doesn't matter since the existence test is <code class="constant">TRUE</code>. With
  4086. the current set of available tests, there's no point passing in
  4087. more than one test at a time.
  4088. </p>
  4089. <p>Apart from <code class="constant">G_FILE_TEST_IS_SYMLINK</code> all tests follow symbolic links,
  4090. so for a symbolic link to a regular file <code class="function">g_file_test()</code> will return
  4091. <code class="constant">TRUE</code> for both <code class="constant">G_FILE_TEST_IS_SYMLINK</code> and <code class="constant">G_FILE_TEST_IS_REGULAR</code>.
  4092. </p>
  4093. <p>Note, that for a dangling symbolic link <code class="function">g_file_test()</code> will return
  4094. <code class="constant">TRUE</code> for <code class="constant">G_FILE_TEST_IS_SYMLINK</code> and <code class="constant">FALSE</code> for all other flags.
  4095. </p>
  4096. <p>You should never use <code class="function">g_file_test()</code> to test whether it is safe
  4097. to perform an operation, because there is always the possibility
  4098. of the condition changing before you actually perform the operation.
  4099. For example, you might think you could use <code class="constant">G_FILE_TEST_IS_SYMLINK</code>
  4100. to know whether it is safe to write to a file without being
  4101. tricked into writing into a different location. It doesn't work!
  4102. </p>
  4103. <div class="informalexample"><pre class="programlisting">
  4104. // DON'T DO THIS
  4105. if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
  4106. {
  4107. fd = g_open (filename, O_WRONLY);
  4108. // write to fd
  4109. }
  4110. </pre></div>
  4111. <p>Another thing to note is that <code class="constant">G_FILE_TEST_EXISTS</code> and
  4112. <code class="constant">G_FILE_TEST_IS_EXECUTABLE</code> are implemented using the <code class="function">access()</code>
  4113. system call. This usually doesn't matter, but if your program
  4114. is setuid or setgid it means that these tests will give you
  4115. the answer for the real user ID and group ID, rather than the
  4116. effective user ID and group ID.
  4117. </p>
  4118. <p>On Windows, there are no symlinks, so testing for
  4119. <code class="constant">G_FILE_TEST_IS_SYMLINK</code> will always return <code class="constant">FALSE</code>. Testing for
  4120. <code class="constant">G_FILE_TEST_IS_EXECUTABLE</code> will just check that the file exists and
  4121. its name indicates that it is executable, checking for well-known
  4122. extensions and those listed in the <code class="code">PATHEXT</code> environment variable.</p>
  4123. <div class="refsect3">
  4124. <a name="id-1.1.90.2.125.9"></a><h4>Parameters</h4>
  4125. <div class="informaltable"><table>
  4126. <tr>
  4127. <td class="parameter_name"><p>filename</p></td>
  4128. <td class="parameter_description">
  4129. <p>a filename to test in the
  4130. GLib file name encoding</p>
  4131. <p>Passed as <code class="code">filename</code></p>
  4132. </td>
  4133. </tr>
  4134. <tr>
  4135. <td class="parameter_name"><p>test</p></td>
  4136. <td class="parameter_description">
  4137. <p>bitfield of <span class="type">GFileTest</span> flags</p>
  4138. <p>Passed as <code class="code">test</code></p>
  4139. </td>
  4140. </tr>
  4141. </table></div>
  4142. </div>
  4143. </div>
  4144. <div class="refsect2">
  4145. <a name="id-1.1.90.2.126"></a><h3>filename-display-basename</h3>
  4146. <div class="informalexample"><pre class="programlisting">(define-values (%return) (filename-display-basename filename))
  4147. </pre></div>
  4148. <p>Returns the display basename for the particular filename, guaranteed
  4149. to be valid UTF-8. The display name might not be identical to the filename,
  4150. for instance there might be problems converting it to UTF-8, and some files
  4151. can be translated in the display.
  4152. </p>
  4153. <p>If GLib cannot make sense of the encoding of <em class="parameter"><code>filename</code></em>, as a last resort it
  4154. replaces unknown characters with U+FFFD, the Unicode replacement character.
  4155. You can search the result for the UTF-8 encoding of this character (which is
  4156. "\357\277\275" in octal notation) to find out if <em class="parameter"><code>filename</code></em> was in an invalid
  4157. encoding.
  4158. </p>
  4159. <p>You must pass the whole absolute pathname to this functions so that
  4160. translation of well known locations can be done.
  4161. </p>
  4162. <p>This function is preferred over <code class="function">g_filename_display_name()</code> if you know the
  4163. whole path, as it allows translation.</p>
  4164. <div class="refsect3">
  4165. <a name="id-1.1.90.2.126.7"></a><h4>Parameters</h4>
  4166. <div class="informaltable"><table><tr>
  4167. <td class="parameter_name"><p>filename</p></td>
  4168. <td class="parameter_description">
  4169. <p>an absolute pathname in the
  4170. GLib file name encoding</p>
  4171. <p>Passed as <code class="code">filename</code></p>
  4172. </td>
  4173. </tr></table></div>
  4174. </div>
  4175. </div>
  4176. <div class="refsect2">
  4177. <a name="id-1.1.90.2.127"></a><h3>filename-display-name</h3>
  4178. <div class="informalexample"><pre class="programlisting">(define-values (%return) (filename-display-name filename))
  4179. </pre></div>
  4180. <p>Converts a filename into a valid UTF-8 string. The conversion is
  4181. not necessarily reversible, so you should keep the original around
  4182. and use the return value of this function only for display purposes.
  4183. Unlike <code class="function">g_filename_to_utf8()</code>, the result is guaranteed to be non-<code class="constant">NULL</code>
  4184. even if the filename actually isn't in the GLib file name encoding.
  4185. </p>
  4186. <p>If GLib cannot make sense of the encoding of <em class="parameter"><code>filename</code></em>, as a last resort it
  4187. replaces unknown characters with U+FFFD, the Unicode replacement character.
  4188. You can search the result for the UTF-8 encoding of this character (which is
  4189. "\357\277\275" in octal notation) to find out if <em class="parameter"><code>filename</code></em> was in an invalid
  4190. encoding.
  4191. </p>
  4192. <p>If you know the whole pathname of the file you should use
  4193. <code class="function">g_filename_display_basename()</code>, since that allows location-based
  4194. translation of filenames.</p>
  4195. <div class="refsect3">
  4196. <a name="id-1.1.90.2.127.6"></a><h4>Parameters</h4>
  4197. <div class="informaltable"><table><tr>
  4198. <td class="parameter_name"><p>filename</p></td>
  4199. <td class="parameter_description">
  4200. <p>a pathname hopefully in the
  4201. GLib file name encoding</p>
  4202. <p>Passed as <code class="code">filename</code></p>
  4203. </td>
  4204. </tr></table></div>
  4205. </div>
  4206. </div>
  4207. <div class="refsect2">
  4208. <a name="id-1.1.90.2.128"></a><h3>filename-from-uri</h3>
  4209. <div class="informalexample"><pre class="programlisting">(define-values (%return hostname) (filename-from-uri uri))
  4210. </pre></div>
  4211. <p>Converts an escaped ASCII-encoded URI to a local filename in the
  4212. encoding used for filenames.</p>
  4213. <div class="refsect3">
  4214. <a name="id-1.1.90.2.128.4"></a><h4>Parameters</h4>
  4215. <div class="informaltable"><table>
  4216. <tr>
  4217. <td class="parameter_name"><p>uri</p></td>
  4218. <td class="parameter_description">
  4219. <p>a uri describing a filename (escaped, encoded in ASCII).</p>
  4220. <p>Passed as <code class="code">uri</code></p>
  4221. </td>
  4222. </tr>
  4223. <tr>
  4224. <td class="parameter_name"><p>hostname</p></td>
  4225. <td class="parameter_description">
  4226. <p>Location to store hostname for the URI.
  4227. If there is no hostname in the URI, <code class="constant">NULL</code> will be
  4228. stored in this location.</p>
  4229. <p>Passed as <code class="code">hostname</code></p>
  4230. </td>
  4231. </tr>
  4232. </table></div>
  4233. </div>
  4234. </div>
  4235. <div class="refsect2">
  4236. <a name="id-1.1.90.2.129"></a><h3>filename-from-utf8</h3>
  4237. <div class="informalexample"><pre class="programlisting">(define-values
  4238. (%return bytes-read bytes-written)
  4239. (filename-from-utf8 utf8string len))
  4240. </pre></div>
  4241. <p>Converts a string from UTF-8 to the encoding GLib uses for
  4242. filenames. Note that on Windows GLib uses UTF-8 for filenames;
  4243. on other platforms, this function indirectly depends on the
  4244. [current locale][setlocale].
  4245. </p>
  4246. <p>The input string shall not contain nul characters even if the <em class="parameter"><code>len</code></em>
  4247. argument is positive. A nul character found inside the string will result
  4248. in error <code class="constant">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</code>. If the filename encoding is
  4249. not UTF-8 and the conversion output contains a nul character, the error
  4250. <code class="constant">G_CONVERT_ERROR_EMBEDDED_NUL</code> is set and the function returns <code class="constant">NULL</code>.</p>
  4251. <div class="refsect3">
  4252. <a name="id-1.1.90.2.129.5"></a><h4>Parameters</h4>
  4253. <div class="informaltable"><table>
  4254. <tr>
  4255. <td class="parameter_name"><p>utf8string</p></td>
  4256. <td class="parameter_description">
  4257. <p>a UTF-8 encoded string.</p>
  4258. <p>Passed as <code class="code">utf8string</code></p>
  4259. </td>
  4260. </tr>
  4261. <tr>
  4262. <td class="parameter_name"><p>len</p></td>
  4263. <td class="parameter_description">
  4264. <p>the length of the string, or -1 if the string is
  4265. nul-terminated.</p>
  4266. <p>Passed as <code class="code">len</code></p>
  4267. </td>
  4268. </tr>
  4269. <tr>
  4270. <td class="parameter_name"><p>bytes_read</p></td>
  4271. <td class="parameter_description">
  4272. <p>location to store the number of bytes in
  4273. the input string that were successfully converted, or <code class="constant">NULL</code>.
  4274. Even if the conversion was successful, this may be
  4275. less than <em class="parameter"><code>len</code></em> if there were partial characters
  4276. at the end of the input. If the error
  4277. <code class="constant">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</code> occurs, the value
  4278. stored will be the byte offset after the last valid
  4279. input sequence.</p>
  4280. <p>Passed as <code class="code">bytes-read</code></p>
  4281. </td>
  4282. </tr>
  4283. <tr>
  4284. <td class="parameter_name"><p>bytes_written</p></td>
  4285. <td class="parameter_description">
  4286. <p>the number of bytes stored in
  4287. the output buffer (not including the terminating nul).</p>
  4288. <p>Passed as <code class="code">bytes-written</code></p>
  4289. </td>
  4290. </tr>
  4291. </table></div>
  4292. </div>
  4293. </div>
  4294. <div class="refsect2">
  4295. <a name="id-1.1.90.2.130"></a><h3>filename-to-uri</h3>
  4296. <div class="informalexample"><pre class="programlisting">(define-values (%return) (filename-to-uri filename hostname))
  4297. </pre></div>
  4298. <p>Converts an absolute filename to an escaped ASCII-encoded URI, with the path
  4299. component following Section 3.3. of RFC 2396.</p>
  4300. <div class="refsect3">
  4301. <a name="id-1.1.90.2.130.4"></a><h4>Parameters</h4>
  4302. <div class="informaltable"><table>
  4303. <tr>
  4304. <td class="parameter_name"><p>filename</p></td>
  4305. <td class="parameter_description">
  4306. <p>an absolute filename specified in the GLib file
  4307. name encoding, which is the on-disk file name bytes on Unix, and UTF-8
  4308. on Windows</p>
  4309. <p>Passed as <code class="code">filename</code></p>
  4310. </td>
  4311. </tr>
  4312. <tr>
  4313. <td class="parameter_name"><p>hostname</p></td>
  4314. <td class="parameter_description">
  4315. <p>A UTF-8 encoded hostname, or <code class="constant">NULL</code> for none.</p>
  4316. <p>Passed as <code class="code">hostname</code></p>
  4317. </td>
  4318. </tr>
  4319. </table></div>
  4320. </div>
  4321. </div>
  4322. <div class="refsect2">
  4323. <a name="id-1.1.90.2.131"></a><h3>filename-to-utf8</h3>
  4324. <div class="informalexample"><pre class="programlisting">(define-values
  4325. (%return bytes-read bytes-written)
  4326. (filename-to-utf8 opsysstring len))
  4327. </pre></div>
  4328. <p>Converts a string which is in the encoding used by GLib for
  4329. filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8
  4330. for filenames; on other platforms, this function indirectly depends on
  4331. the [current locale][setlocale].
  4332. </p>
  4333. <p>The input string shall not contain nul characters even if the <em class="parameter"><code>len</code></em>
  4334. argument is positive. A nul character found inside the string will result
  4335. in error <code class="constant">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</code>.
  4336. If the source encoding is not UTF-8 and the conversion output contains a
  4337. nul character, the error <code class="constant">G_CONVERT_ERROR_EMBEDDED_NUL</code> is set and the
  4338. function returns <code class="constant">NULL</code>. Use <code class="function">g_convert()</code> to produce output that
  4339. may contain embedded nul characters.</p>
  4340. <div class="refsect3">
  4341. <a name="id-1.1.90.2.131.5"></a><h4>Parameters</h4>
  4342. <div class="informaltable"><table>
  4343. <tr>
  4344. <td class="parameter_name"><p>opsysstring</p></td>
  4345. <td class="parameter_description">
  4346. <p>a string in the encoding for filenames</p>
  4347. <p>Passed as <code class="code">opsysstring</code></p>
  4348. </td>
  4349. </tr>
  4350. <tr>
  4351. <td class="parameter_name"><p>len</p></td>
  4352. <td class="parameter_description">
  4353. <p>the length of the string, or -1 if the string is
  4354. nul-terminated (Note that some encodings may allow nul
  4355. bytes to occur inside strings. In that case, using -1
  4356. for the <em class="parameter"><code>len</code></em> parameter is unsafe)</p>
  4357. <p>Passed as <code class="code">len</code></p>
  4358. </td>
  4359. </tr>
  4360. <tr>
  4361. <td class="parameter_name"><p>bytes_read</p></td>
  4362. <td class="parameter_description">
  4363. <p>location to store the number of bytes in the
  4364. input string that were successfully converted, or <code class="constant">NULL</code>.
  4365. Even if the conversion was successful, this may be
  4366. less than <em class="parameter"><code>len</code></em> if there were partial characters
  4367. at the end of the input. If the error
  4368. <code class="constant">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</code> occurs, the value
  4369. stored will be the byte offset after the last valid
  4370. input sequence.</p>
  4371. <p>Passed as <code class="code">bytes-read</code></p>
  4372. </td>
  4373. </tr>
  4374. <tr>
  4375. <td class="parameter_name"><p>bytes_written</p></td>
  4376. <td class="parameter_description">
  4377. <p>the number of bytes stored in the output
  4378. buffer (not including the terminating nul).</p>
  4379. <p>Passed as <code class="code">bytes-written</code></p>
  4380. </td>
  4381. </tr>
  4382. </table></div>
  4383. </div>
  4384. </div>
  4385. <div class="refsect2">
  4386. <a name="id-1.1.90.2.132"></a><h3>find-program-in-path</h3>
  4387. <div class="informalexample"><pre class="programlisting">(define-values (%return) (find-program-in-path program))
  4388. </pre></div>
  4389. <p>Locates the first executable named <em class="parameter"><code>program</code></em> in the user's path, in the
  4390. same way that <code class="function">execvp()</code> would locate it. Returns an allocated string
  4391. with the absolute path name, or <code class="constant">NULL</code> if the program is not found in
  4392. the path. If <em class="parameter"><code>program</code></em> is already an absolute path, returns a copy of
  4393. <em class="parameter"><code>program</code></em> if <em class="parameter"><code>program</code></em> exists and is executable, and <code class="constant">NULL</code> otherwise.
  4394. On Windows, if <em class="parameter"><code>program</code></em> does not have a file type suffix, tries
  4395. with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
  4396. the <code class="code">PATHEXT</code> environment variable.
  4397. </p>
  4398. <p>On Windows, it looks for the file in the same way as <code class="function">CreateProcess()</code>
  4399. would. This means first in the directory where the executing
  4400. program was loaded from, then in the current directory, then in the
  4401. Windows 32-bit system directory, then in the Windows directory, and
  4402. finally in the directories in the <code class="code">PATH</code> environment variable. If
  4403. the program is found, the return value contains the full name
  4404. including the type suffix.</p>
  4405. <div class="refsect3">
  4406. <a name="id-1.1.90.2.132.5"></a><h4>Parameters</h4>
  4407. <div class="informaltable"><table><tr>
  4408. <td class="parameter_name"><p>program</p></td>
  4409. <td class="parameter_description">
  4410. <p>a program name in the GLib file name encoding</p>
  4411. <p>Passed as <code class="code">program</code></p>
  4412. </td>
  4413. </tr></table></div>
  4414. </div>
  4415. </div>
  4416. <div class="refsect2">
  4417. <a name="id-1.1.90.2.133"></a><h3>format-size</h3>
  4418. <div class="informalexample"><pre class="programlisting">(define-values (%return) (format-size size))
  4419. </pre></div>
  4420. <p>Formats a size (for example the size of a file) into a human readable
  4421. string. Sizes are rounded to the nearest size prefix (kB, MB, GB)
  4422. and are displayed rounded to the nearest tenth. E.g. the file size
  4423. 3292528 bytes will be converted into the string "3.2 MB". The returned string
  4424. is UTF-8, and may use a non-breaking space to separate the number and units,
  4425. to ensure they aren’t separated when line wrapped.
  4426. </p>
  4427. <p>The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).
  4428. </p>
  4429. <p>This string should be freed with <code class="function">g_free()</code> when not needed any longer.
  4430. </p>
  4431. <p>See <code class="function">g_format_size_full()</code> for more options about how the size might be
  4432. formatted.</p>
  4433. <div class="refsect3">
  4434. <a name="id-1.1.90.2.133.7"></a><h4>Parameters</h4>
  4435. <div class="informaltable"><table><tr>
  4436. <td class="parameter_name"><p>size</p></td>
  4437. <td class="parameter_description">
  4438. <p>a size in bytes</p>
  4439. <p>Passed as <code class="code">size</code></p>
  4440. </td>
  4441. </tr></table></div>
  4442. </div>
  4443. </div>
  4444. <div class="refsect2">
  4445. <a name="id-1.1.90.2.134"></a><h3>format-size-full</h3>
  4446. <div class="informalexample"><pre class="programlisting">(define-values (%return) (format-size-full size flags))
  4447. </pre></div>
  4448. <p>Formats a size.
  4449. </p>
  4450. <p>This function is similar to <code class="function">g_format_size()</code> but allows for flags
  4451. that modify the output. See <span class="type">GFormatSizeFlags</span>.</p>
  4452. <div class="refsect3">
  4453. <a name="id-1.1.90.2.134.5"></a><h4>Parameters</h4>
  4454. <div class="informaltable"><table>
  4455. <tr>
  4456. <td class="parameter_name"><p>size</p></td>
  4457. <td class="parameter_description">
  4458. <p>a size in bytes</p>
  4459. <p>Passed as <code class="code">size</code></p>
  4460. </td>
  4461. </tr>
  4462. <tr>
  4463. <td class="parameter_name"><p>flags</p></td>
  4464. <td class="parameter_description">
  4465. <p><span class="type">GFormatSizeFlags</span> to modify the output</p>
  4466. <p>Passed as <code class="code">flags</code></p>
  4467. </td>
  4468. </tr>
  4469. </table></div>
  4470. </div>
  4471. </div>
  4472. <div class="refsect2">
  4473. <a name="id-1.1.90.2.135"></a><h3>get-application-name</h3>
  4474. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-application-name))
  4475. </pre></div>
  4476. <p>Gets a human-readable name for the application, as set by
  4477. <code class="function">g_set_application_name()</code>. This name should be localized if
  4478. possible, and is intended for display to the user. Contrast with
  4479. <code class="function">g_get_prgname()</code>, which gets a non-localized name. If
  4480. <code class="function">g_set_application_name()</code> has not been called, returns the result of
  4481. <code class="function">g_get_prgname()</code> (which may be <code class="constant">NULL</code> if <code class="function">g_set_prgname()</code> has also not
  4482. been called).</p>
  4483. </div>
  4484. <div class="refsect2">
  4485. <a name="id-1.1.90.2.136"></a><h3>get-charset</h3>
  4486. <div class="informalexample"><pre class="programlisting">(define-values (%return charset) (get-charset))
  4487. </pre></div>
  4488. <p>Obtains the character set for the [current locale][setlocale]; you
  4489. might use this character set as an argument to <code class="function">g_convert()</code>, to convert
  4490. from the current locale's encoding to some other encoding. (Frequently
  4491. <code class="function">g_locale_to_utf8()</code> and <code class="function">g_locale_from_utf8()</code> are nice shortcuts, though.)
  4492. </p>
  4493. <p>On Windows the character set returned by this function is the
  4494. so-called system default ANSI code-page. That is the character set
  4495. used by the "narrow" versions of C library and Win32 functions that
  4496. handle file names. It might be different from the character set
  4497. used by the C library's current locale.
  4498. </p>
  4499. <p>On Linux, the character set is found by consulting <code class="function">nl_langinfo()</code> if
  4500. available. If not, the environment variables <code class="code">LC_ALL</code>, <code class="code">LC_CTYPE</code>, <code class="code">LANG</code>
  4501. and <code class="code">CHARSET</code> are queried in order.
  4502. </p>
  4503. <p>The return value is <code class="constant">TRUE</code> if the locale's encoding is UTF-8, in that
  4504. case you can perhaps avoid calling <code class="function">g_convert()</code>.
  4505. </p>
  4506. <p>The string returned in <em class="parameter"><code>charset</code></em> is not allocated, and should not be
  4507. freed.</p>
  4508. <div class="refsect3">
  4509. <a name="id-1.1.90.2.136.8"></a><h4>Parameters</h4>
  4510. <div class="informaltable"><table><tr>
  4511. <td class="parameter_name"><p>charset</p></td>
  4512. <td class="parameter_description">
  4513. <p>return location for character set
  4514. name, or <code class="constant">NULL</code>.</p>
  4515. <p>Passed as <code class="code">charset</code></p>
  4516. </td>
  4517. </tr></table></div>
  4518. </div>
  4519. </div>
  4520. <div class="refsect2">
  4521. <a name="id-1.1.90.2.137"></a><h3>get-codeset</h3>
  4522. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-codeset))
  4523. </pre></div>
  4524. <p>Gets the character set for the current locale.</p>
  4525. </div>
  4526. <div class="refsect2">
  4527. <a name="id-1.1.90.2.138"></a><h3>get-console-charset</h3>
  4528. <div class="informalexample"><pre class="programlisting">(define-values (%return charset) (get-console-charset))
  4529. </pre></div>
  4530. <p>Obtains the character set used by the console attached to the process,
  4531. which is suitable for printing output to the terminal.
  4532. </p>
  4533. <p>Usually this matches the result returned by <code class="function">g_get_charset()</code>, but in
  4534. environments where the locale's character set does not match the encoding
  4535. of the console this function tries to guess a more suitable value instead.
  4536. </p>
  4537. <p>On Windows the character set returned by this function is the
  4538. output code page used by the console associated with the calling process.
  4539. If the codepage can't be determined (for example because there is no
  4540. console attached) UTF-8 is assumed.
  4541. </p>
  4542. <p>The return value is <code class="constant">TRUE</code> if the locale's encoding is UTF-8, in that
  4543. case you can perhaps avoid calling <code class="function">g_convert()</code>.
  4544. </p>
  4545. <p>The string returned in <em class="parameter"><code>charset</code></em> is not allocated, and should not be
  4546. freed.</p>
  4547. <div class="refsect3">
  4548. <a name="id-1.1.90.2.138.8"></a><h4>Parameters</h4>
  4549. <div class="informaltable"><table><tr>
  4550. <td class="parameter_name"><p>charset</p></td>
  4551. <td class="parameter_description">
  4552. <p>return location for character set
  4553. name, or <code class="constant">NULL</code>.</p>
  4554. <p>Passed as <code class="code">charset</code></p>
  4555. </td>
  4556. </tr></table></div>
  4557. </div>
  4558. </div>
  4559. <div class="refsect2">
  4560. <a name="id-1.1.90.2.139"></a><h3>get-current-dir</h3>
  4561. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-current-dir))
  4562. </pre></div>
  4563. <p>Gets the current directory.
  4564. </p>
  4565. <p>The returned string should be freed when no longer needed.
  4566. The encoding of the returned string is system defined.
  4567. On Windows, it is always UTF-8.
  4568. </p>
  4569. <p>Since GLib 2.40, this function will return the value of the "PWD"
  4570. environment variable if it is set and it happens to be the same as
  4571. the current directory. This can make a difference in the case that
  4572. the current directory is the target of a symbolic link.</p>
  4573. </div>
  4574. <div class="refsect2">
  4575. <a name="id-1.1.90.2.140"></a><h3>get-environ</h3>
  4576. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-environ))
  4577. </pre></div>
  4578. <p>Gets the list of environment variables for the current process.
  4579. </p>
  4580. <p>The list is <code class="constant">NULL</code> terminated and each item in the list is of the
  4581. form 'NAME=VALUE'.
  4582. </p>
  4583. <p>This is equivalent to direct access to the 'environ' global variable,
  4584. except portable.
  4585. </p>
  4586. <p>The return value is freshly allocated and it should be freed with
  4587. <code class="function">g_strfreev()</code> when it is no longer needed.</p>
  4588. </div>
  4589. <div class="refsect2">
  4590. <a name="id-1.1.90.2.141"></a><h3>get-filename-charsets</h3>
  4591. <div class="informalexample"><pre class="programlisting">(define-values (%return filename-charsets) (get-filename-charsets))
  4592. </pre></div>
  4593. <p>Determines the preferred character sets used for filenames.
  4594. The first character set from the <em class="parameter"><code>charsets</code></em> is the filename encoding, the
  4595. subsequent character sets are used when trying to generate a displayable
  4596. representation of a filename, see <code class="function">g_filename_display_name()</code>.
  4597. </p>
  4598. <p>On Unix, the character sets are determined by consulting the
  4599. environment variables <code class="code">G_FILENAME_ENCODING</code> and <code class="code">G_BROKEN_FILENAMES</code>.
  4600. On Windows, the character set used in the GLib API is always UTF-8
  4601. and said environment variables have no effect.
  4602. </p>
  4603. <p><code class="code">G_FILENAME_ENCODING</code> may be set to a comma-separated list of
  4604. character set names. The special token "\@locale" is taken
  4605. to mean the character set for the [current locale][setlocale].
  4606. If <code class="code">G_FILENAME_ENCODING</code> is not set, but <code class="code">G_BROKEN_FILENAMES</code> is,
  4607. the character set of the current locale is taken as the filename
  4608. encoding. If neither environment variable is set, UTF-8 is taken
  4609. as the filename encoding, but the character set of the current locale
  4610. is also put in the list of encodings.
  4611. </p>
  4612. <p>The returned <em class="parameter"><code>charsets</code></em> belong to GLib and must not be freed.
  4613. </p>
  4614. <p>Note that on Unix, regardless of the locale character set or
  4615. <code class="code">G_FILENAME_ENCODING</code> value, the actual file names present
  4616. on a system might be in any random encoding or just gibberish.</p>
  4617. <div class="refsect3">
  4618. <a name="id-1.1.90.2.141.8"></a><h4>Parameters</h4>
  4619. <div class="informaltable"><table><tr>
  4620. <td class="parameter_name"><p>filename_charsets</p></td>
  4621. <td class="parameter_description">
  4622. <p>
  4623. </p>
  4624. <p>return location for the <code class="constant">NULL</code>-terminated list of encoding names</p>
  4625. <p>Passed as <code class="code">filename-charsets</code></p>
  4626. </td>
  4627. </tr></table></div>
  4628. </div>
  4629. </div>
  4630. <div class="refsect2">
  4631. <a name="id-1.1.90.2.142"></a><h3>get-home-dir</h3>
  4632. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-home-dir))
  4633. </pre></div>
  4634. <p>Gets the current user's home directory.
  4635. </p>
  4636. <p>As with most UNIX tools, this function will return the value of the
  4637. <code class="code">HOME</code> environment variable if it is set to an existing absolute path
  4638. name, falling back to the <code class="code">passwd</code> file in the case that it is unset.
  4639. </p>
  4640. <p>If the path given in <code class="code">HOME</code> is non-absolute, does not exist, or is
  4641. not a directory, the result is undefined.
  4642. </p>
  4643. <p>Before version 2.36 this function would ignore the <code class="code">HOME</code> environment
  4644. variable, taking the value from the <code class="code">passwd</code> database instead. This was
  4645. changed to increase the compatibility of GLib with other programs (and
  4646. the XDG basedir specification) and to increase testability of programs
  4647. based on GLib (by making it easier to run them from test frameworks).
  4648. </p>
  4649. <p>If your program has a strong requirement for either the new or the
  4650. old behaviour (and if you don't wish to increase your GLib
  4651. dependency to ensure that the new behaviour is in effect) then you
  4652. should either directly check the <code class="code">HOME</code> environment variable yourself
  4653. or unset it before calling any functions in GLib.</p>
  4654. </div>
  4655. <div class="refsect2">
  4656. <a name="id-1.1.90.2.143"></a><h3>get-host-name</h3>
  4657. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-host-name))
  4658. </pre></div>
  4659. <p>Return a name for the machine.
  4660. </p>
  4661. <p>The returned name is not necessarily a fully-qualified domain name,
  4662. or even present in DNS or some other name service at all. It need
  4663. not even be unique on your local network or site, but usually it
  4664. is. Callers should not rely on the return value having any specific
  4665. properties like uniqueness for security purposes. Even if the name
  4666. of the machine is changed while an application is running, the
  4667. return value from this function does not change. The returned
  4668. string is owned by GLib and should not be modified or freed. If no
  4669. name can be determined, a default fixed string "localhost" is
  4670. returned.
  4671. </p>
  4672. <p>The encoding of the returned string is UTF-8.</p>
  4673. </div>
  4674. <div class="refsect2">
  4675. <a name="id-1.1.90.2.144"></a><h3>get-language-names</h3>
  4676. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-language-names))
  4677. </pre></div>
  4678. <p>Computes a list of applicable locale names, which can be used to
  4679. e.g. construct locale-dependent filenames or search paths. The returned
  4680. list is sorted from most desirable to least desirable and always contains
  4681. the default locale "C".
  4682. </p>
  4683. <p>For example, if LANGUAGE=de:en_US, then the returned list is
  4684. "de", "en_US", "en", "C".
  4685. </p>
  4686. <p>This function consults the environment variables <code class="code">LANGUAGE</code>, <code class="code">LC_ALL</code>,
  4687. <code class="code">LC_MESSAGES</code> and <code class="code">LANG</code> to find the list of locales specified by the
  4688. user.</p>
  4689. </div>
  4690. <div class="refsect2">
  4691. <a name="id-1.1.90.2.145"></a><h3>get-language-names-with-category</h3>
  4692. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-language-names-with-category category-name))
  4693. </pre></div>
  4694. <p>Computes a list of applicable locale names with a locale category name,
  4695. which can be used to construct the fallback locale-dependent filenames
  4696. or search paths. The returned list is sorted from most desirable to
  4697. least desirable and always contains the default locale "C".
  4698. </p>
  4699. <p>This function consults the environment variables <code class="code">LANGUAGE</code>, <code class="code">LC_ALL</code>,
  4700. <em class="parameter"><code>category_name</code></em>, and <code class="code">LANG</code> to find the list of locales specified by the
  4701. user.
  4702. </p>
  4703. <p><code class="function">g_get_language_names()</code> returns g_get_language_names_with_category("LC_MESSAGES").</p>
  4704. <div class="refsect3">
  4705. <a name="id-1.1.90.2.145.6"></a><h4>Parameters</h4>
  4706. <div class="informaltable"><table><tr>
  4707. <td class="parameter_name"><p>category_name</p></td>
  4708. <td class="parameter_description">
  4709. <p>a locale category name</p>
  4710. <p>Passed as <code class="code">category-name</code></p>
  4711. </td>
  4712. </tr></table></div>
  4713. </div>
  4714. </div>
  4715. <div class="refsect2">
  4716. <a name="id-1.1.90.2.146"></a><h3>get-locale-variants</h3>
  4717. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-locale-variants locale))
  4718. </pre></div>
  4719. <p>Returns a list of derived variants of <em class="parameter"><code>locale</code></em>, which can be used to
  4720. e.g. construct locale-dependent filenames or search paths. The returned
  4721. list is sorted from most desirable to least desirable.
  4722. This function handles territory, charset and extra locale modifiers. See
  4723. [<code class="code">setlocale(3)</code>](man:setlocale) for information about locales and their format.
  4724. </p>
  4725. <p><em class="parameter"><code>locale</code></em> itself is guaranteed to be returned in the output.
  4726. </p>
  4727. <p>For example, if <em class="parameter"><code>locale</code></em> is <code class="code">fr_BE</code>, then the returned list
  4728. is <code class="code">fr_BE</code>, <code class="code">fr</code>. If <em class="parameter"><code>locale</code></em> is <code class="code">en_GB.UTF-8@euro</code>, then the returned list
  4729. is <code class="code">en_GB.UTF-8@euro</code>, <code class="code">en_GB.UTF-8</code>, <code class="code">en_GB@euro</code>, <code class="code">en_GB</code>, <code class="code">en.UTF-8@euro</code>,
  4730. <code class="code">en.UTF-8</code>, <code class="code">en@euro</code>, <code class="code">en</code>.
  4731. </p>
  4732. <p>If you need the list of variants for the current locale,
  4733. use <code class="function">g_get_language_names()</code>.</p>
  4734. <div class="refsect3">
  4735. <a name="id-1.1.90.2.146.7"></a><h4>Parameters</h4>
  4736. <div class="informaltable"><table><tr>
  4737. <td class="parameter_name"><p>locale</p></td>
  4738. <td class="parameter_description">
  4739. <p>a locale identifier</p>
  4740. <p>Passed as <code class="code">locale</code></p>
  4741. </td>
  4742. </tr></table></div>
  4743. </div>
  4744. </div>
  4745. <div class="refsect2">
  4746. <a name="id-1.1.90.2.147"></a><h3>get-monotonic-time</h3>
  4747. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-monotonic-time))
  4748. </pre></div>
  4749. <p>Queries the system monotonic time.
  4750. </p>
  4751. <p>The monotonic clock will always increase and doesn't suffer
  4752. discontinuities when the user (or NTP) changes the system time. It
  4753. may or may not continue to tick during times where the machine is
  4754. suspended.
  4755. </p>
  4756. <p>We try to use the clock that corresponds as closely as possible to
  4757. the passage of time as measured by system calls such as <code class="function">poll()</code> but it
  4758. may not always be possible to do this.</p>
  4759. </div>
  4760. <div class="refsect2">
  4761. <a name="id-1.1.90.2.148"></a><h3>get-num-processors</h3>
  4762. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-num-processors))
  4763. </pre></div>
  4764. <p>Determine the approximate number of threads that the system will
  4765. schedule simultaneously for this process. This is intended to be
  4766. used as a parameter to <code class="function">g_thread_pool_new()</code> for CPU bound tasks and
  4767. similar cases.</p>
  4768. </div>
  4769. <div class="refsect2">
  4770. <a name="id-1.1.90.2.149"></a><h3>get-os-info</h3>
  4771. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-os-info key-name))
  4772. </pre></div>
  4773. <p>Get information about the operating system.
  4774. </p>
  4775. <p>On Linux this comes from the <code class="code">/etc/os-release</code> file. On other systems, it may
  4776. come from a variety of sources. You can either use the standard key names
  4777. like <code class="constant">G_OS_INFO_KEY_NAME</code> or pass any UTF-8 string key name. For example,
  4778. <code class="code">/etc/os-release</code> provides a number of other less commonly used values that may
  4779. be useful. No key is guaranteed to be provided, so the caller should always
  4780. check if the result is <code class="constant">NULL</code>.</p>
  4781. <div class="refsect3">
  4782. <a name="id-1.1.90.2.149.5"></a><h4>Parameters</h4>
  4783. <div class="informaltable"><table><tr>
  4784. <td class="parameter_name"><p>key_name</p></td>
  4785. <td class="parameter_description">
  4786. <p>a key for the OS info being requested, for example <code class="constant">G_OS_INFO_KEY_NAME</code>.</p>
  4787. <p>Passed as <code class="code">key-name</code></p>
  4788. </td>
  4789. </tr></table></div>
  4790. </div>
  4791. </div>
  4792. <div class="refsect2">
  4793. <a name="id-1.1.90.2.150"></a><h3>get-prgname</h3>
  4794. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-prgname))
  4795. </pre></div>
  4796. <p>Gets the name of the program. This name should not be localized,
  4797. in contrast to <code class="function">g_get_application_name()</code>.
  4798. </p>
  4799. <p>If you are using <span class="type">GApplication</span> the program name is set in
  4800. <code class="function">g_application_run()</code>. In case of GDK or GTK+ it is set in
  4801. <code class="function">gdk_init()</code>, which is called by <code class="function">gtk_init()</code> and the
  4802. <span class="type">“startup”</span> handler. The program name is found by
  4803. taking the last component of <em class="parameter"><code>argv</code></em>[0].</p>
  4804. </div>
  4805. <div class="refsect2">
  4806. <a name="id-1.1.90.2.151"></a><h3>get-real-name</h3>
  4807. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-real-name))
  4808. </pre></div>
  4809. <p>Gets the real name of the user. This usually comes from the user's
  4810. entry in the <code class="code">passwd</code> file. The encoding of the returned string is
  4811. system-defined. (On Windows, it is, however, always UTF-8.) If the
  4812. real user name cannot be determined, the string "Unknown" is
  4813. returned.</p>
  4814. </div>
  4815. <div class="refsect2">
  4816. <a name="id-1.1.90.2.152"></a><h3>get-real-time</h3>
  4817. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-real-time))
  4818. </pre></div>
  4819. <p>Queries the system wall-clock time.
  4820. </p>
  4821. <p>This call is functionally equivalent to <code class="function">g_get_current_time()</code> except
  4822. that the return value is often more convenient than dealing with a
  4823. <span class="type">GTimeVal</span>.
  4824. </p>
  4825. <p>You should only use this call if you are actually interested in the real
  4826. wall-clock time. <code class="function">g_get_monotonic_time()</code> is probably more useful for
  4827. measuring intervals.</p>
  4828. </div>
  4829. <div class="refsect2">
  4830. <a name="id-1.1.90.2.153"></a><h3>get-system-config-dirs</h3>
  4831. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-system-config-dirs))
  4832. </pre></div>
  4833. <p>Returns an ordered list of base directories in which to access
  4834. system-wide configuration information.
  4835. </p>
  4836. <p>On UNIX platforms this is determined using the mechanisms described
  4837. in the
  4838. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
  4839. In this case the list of directories retrieved will be <code class="code">XDG_CONFIG_DIRS</code>.
  4840. </p>
  4841. <p>On Windows it follows XDG Base Directory Specification if <code class="code">XDG_CONFIG_DIRS</code> is defined.
  4842. If <code class="code">XDG_CONFIG_DIRS</code> is undefined, the directory that contains application
  4843. data for all users is used instead. A typical path is
  4844. <code class="code">C:\Documents and Settings\All Users\Application Data</code>.
  4845. This folder is used for application data
  4846. that is not user specific. For example, an application can store
  4847. a spell-check dictionary, a database of clip art, or a log file in the
  4848. CSIDL_COMMON_APPDATA folder. This information will not roam and is available
  4849. to anyone using the computer.</p>
  4850. </div>
  4851. <div class="refsect2">
  4852. <a name="id-1.1.90.2.154"></a><h3>get-system-data-dirs</h3>
  4853. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-system-data-dirs))
  4854. </pre></div>
  4855. <p>Returns an ordered list of base directories in which to access
  4856. system-wide application data.
  4857. </p>
  4858. <p>On UNIX platforms this is determined using the mechanisms described
  4859. in the
  4860. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec)
  4861. In this case the list of directories retrieved will be <code class="code">XDG_DATA_DIRS</code>.
  4862. </p>
  4863. <p>On Windows it follows XDG Base Directory Specification if <code class="code">XDG_DATA_DIRS</code> is defined.
  4864. If <code class="code">XDG_DATA_DIRS</code> is undefined,
  4865. the first elements in the list are the Application Data
  4866. and Documents folders for All Users. (These can be determined only
  4867. on Windows 2000 or later and are not present in the list on other
  4868. Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
  4869. CSIDL_COMMON_DOCUMENTS.
  4870. </p>
  4871. <p>Then follows the "share" subfolder in the installation folder for
  4872. the package containing the DLL that calls this function, if it can
  4873. be determined.
  4874. </p>
  4875. <p>Finally the list contains the "share" subfolder in the installation
  4876. folder for GLib, and in the installation folder for the package the
  4877. application's .exe file belongs to.
  4878. </p>
  4879. <p>The installation folders above are determined by looking up the
  4880. folder where the module (DLL or EXE) in question is located. If the
  4881. folder's name is "bin", its parent is used, otherwise the folder
  4882. itself.
  4883. </p>
  4884. <p>Note that on Windows the returned list can vary depending on where
  4885. this function is called.</p>
  4886. </div>
  4887. <div class="refsect2">
  4888. <a name="id-1.1.90.2.155"></a><h3>get-tmp-dir</h3>
  4889. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-tmp-dir))
  4890. </pre></div>
  4891. <p>Gets the directory to use for temporary files.
  4892. </p>
  4893. <p>On UNIX, this is taken from the <code class="code">TMPDIR</code> environment variable.
  4894. If the variable is not set, <code class="code">P_tmpdir</code> is
  4895. used, as defined by the system C library. Failing that, a
  4896. hard-coded default of "/tmp" is returned.
  4897. </p>
  4898. <p>On Windows, the <code class="code">TEMP</code> environment variable is used, with the
  4899. root directory of the Windows installation (eg: "C:\") used
  4900. as a default.
  4901. </p>
  4902. <p>The encoding of the returned string is system-defined. On Windows,
  4903. it is always UTF-8. The return value is never <code class="constant">NULL</code> or the empty
  4904. string.</p>
  4905. </div>
  4906. <div class="refsect2">
  4907. <a name="id-1.1.90.2.156"></a><h3>get-user-cache-dir</h3>
  4908. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-user-cache-dir))
  4909. </pre></div>
  4910. <p>Returns a base directory in which to store non-essential, cached
  4911. data specific to particular user.
  4912. </p>
  4913. <p>On UNIX platforms this is determined using the mechanisms described
  4914. in the
  4915. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
  4916. In this case the directory retrieved will be <code class="code">XDG_CACHE_HOME</code>.
  4917. </p>
  4918. <p>On Windows it follows XDG Base Directory Specification if <code class="code">XDG_CACHE_HOME</code> is defined.
  4919. If <code class="code">XDG_CACHE_HOME</code> is undefined, the directory that serves as a common
  4920. repository for temporary Internet files is used instead. A typical path is
  4921. <code class="code">C:\Documents and Settings\username\Local Settings\Temporary Internet Files</code>.
  4922. See the [documentation for <code class="code">CSIDL_INTERNET_CACHE</code>](https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx#csidl_internet_cache).</p>
  4923. </div>
  4924. <div class="refsect2">
  4925. <a name="id-1.1.90.2.157"></a><h3>get-user-config-dir</h3>
  4926. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-user-config-dir))
  4927. </pre></div>
  4928. <p>Returns a base directory in which to store user-specific application
  4929. configuration information such as user preferences and settings.
  4930. </p>
  4931. <p>On UNIX platforms this is determined using the mechanisms described
  4932. in the
  4933. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
  4934. In this case the directory retrieved will be <code class="code">XDG_CONFIG_HOME</code>.
  4935. </p>
  4936. <p>On Windows it follows XDG Base Directory Specification if <code class="code">XDG_CONFIG_HOME</code> is defined.
  4937. If <code class="code">XDG_CONFIG_HOME</code> is undefined, the folder to use for local (as opposed
  4938. to roaming) application data is used instead. See the
  4939. [documentation for <code class="code">CSIDL_LOCAL_APPDATA</code>](https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx#csidl_local_appdata).
  4940. Note that in this case on Windows it will be the same
  4941. as what <code class="function">g_get_user_data_dir()</code> returns.</p>
  4942. </div>
  4943. <div class="refsect2">
  4944. <a name="id-1.1.90.2.158"></a><h3>get-user-data-dir</h3>
  4945. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-user-data-dir))
  4946. </pre></div>
  4947. <p>Returns a base directory in which to access application data such
  4948. as icons that is customized for a particular user.
  4949. </p>
  4950. <p>On UNIX platforms this is determined using the mechanisms described
  4951. in the
  4952. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
  4953. In this case the directory retrieved will be <code class="code">XDG_DATA_HOME</code>.
  4954. </p>
  4955. <p>On Windows it follows XDG Base Directory Specification if <code class="code">XDG_DATA_HOME</code>
  4956. is defined. If <code class="code">XDG_DATA_HOME</code> is undefined, the folder to use for local (as
  4957. opposed to roaming) application data is used instead. See the
  4958. [documentation for <code class="code">CSIDL_LOCAL_APPDATA</code>](https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx#csidl_local_appdata).
  4959. Note that in this case on Windows it will be the same
  4960. as what <code class="function">g_get_user_config_dir()</code> returns.</p>
  4961. </div>
  4962. <div class="refsect2">
  4963. <a name="id-1.1.90.2.159"></a><h3>get-user-name</h3>
  4964. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-user-name))
  4965. </pre></div>
  4966. <p>Gets the user name of the current user. The encoding of the returned
  4967. string is system-defined. On UNIX, it might be the preferred file name
  4968. encoding, or something else, and there is no guarantee that it is even
  4969. consistent on a machine. On Windows, it is always UTF-8.</p>
  4970. </div>
  4971. <div class="refsect2">
  4972. <a name="id-1.1.90.2.160"></a><h3>get-user-runtime-dir</h3>
  4973. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-user-runtime-dir))
  4974. </pre></div>
  4975. <p>Returns a directory that is unique to the current user on the local
  4976. system.
  4977. </p>
  4978. <p>This is determined using the mechanisms described
  4979. in the
  4980. [XDG Base Directory Specification](http://www.freedesktop.org/Standards/basedir-spec).
  4981. This is the directory
  4982. specified in the <code class="code">XDG_RUNTIME_DIR</code> environment variable.
  4983. In the case that this variable is not set, we return the value of
  4984. <code class="function">g_get_user_cache_dir()</code>, after verifying that it exists.</p>
  4985. </div>
  4986. <div class="refsect2">
  4987. <a name="id-1.1.90.2.161"></a><h3>get-user-special-dir</h3>
  4988. <div class="informalexample"><pre class="programlisting">(define-values (%return) (get-user-special-dir directory))
  4989. </pre></div>
  4990. <p>Returns the full path of a special directory using its logical id.
  4991. </p>
  4992. <p>On UNIX this is done using the XDG special user directories.
  4993. For compatibility with existing practise, <code class="constant">G_USER_DIRECTORY_DESKTOP</code>
  4994. falls back to <code class="code">$HOME/Desktop</code> when XDG special user directories have
  4995. not been set up.
  4996. </p>
  4997. <p>Depending on the platform, the user might be able to change the path
  4998. of the special directory without requiring the session to restart; GLib
  4999. will not reflect any change once the special directories are loaded.</p>
  5000. <div class="refsect3">
  5001. <a name="id-1.1.90.2.161.6"></a><h4>Parameters</h4>
  5002. <div class="informaltable"><table><tr>
  5003. <td class="parameter_name"><p>directory</p></td>
  5004. <td class="parameter_description">
  5005. <p>the logical id of special directory</p>
  5006. <p>Passed as <code class="code">directory</code></p>
  5007. </td>
  5008. </tr></table></div>
  5009. </div>
  5010. </div>
  5011. <div class="refsect2">
  5012. <a name="id-1.1.90.2.162"></a><h3>getenv</h3>
  5013. <div class="informalexample"><pre class="programlisting">(define-values (%return) (getenv variable))
  5014. </pre></div>
  5015. <p>Returns the value of an environment variable.
  5016. </p>
  5017. <p>On UNIX, the name and value are byte strings which might or might not
  5018. be in some consistent character set and encoding. On Windows, they are
  5019. in UTF-8.
  5020. On Windows, in case the environment variable's value contains
  5021. references to other environment variables, they are expanded.</p>
  5022. <div class="refsect3">
  5023. <a name="id-1.1.90.2.162.5"></a><h4>Parameters</h4>
  5024. <div class="informaltable"><table><tr>
  5025. <td class="parameter_name"><p>variable</p></td>
  5026. <td class="parameter_description">
  5027. <p>the environment variable to get</p>
  5028. <p>Passed as <code class="code">variable</code></p>
  5029. </td>
  5030. </tr></table></div>
  5031. </div>
  5032. </div>
  5033. <div class="refsect2">
  5034. <a name="id-1.1.90.2.163"></a><h3>hash-table-add?</h3>
  5035. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hash-table-add? hash-table key))
  5036. </pre></div>
  5037. <p>This is a convenience function for using a <span class="type">GHashTable</span> as a set. It
  5038. is equivalent to calling <code class="function">g_hash_table_replace()</code> with <em class="parameter"><code>key</code></em> as both the
  5039. key and the value.
  5040. </p>
  5041. <p>In particular, this means that if <em class="parameter"><code>key</code></em> already exists in the hash table, then
  5042. the old copy of <em class="parameter"><code>key</code></em> in the hash table is freed and <em class="parameter"><code>key</code></em> replaces it in the
  5043. table.
  5044. </p>
  5045. <p>When a hash table only ever contains keys that have themselves as the
  5046. corresponding value it is able to be stored more efficiently. See
  5047. the discussion in the section description.
  5048. </p>
  5049. <p>Starting from GLib 2.40, this function returns a boolean value to
  5050. indicate whether the newly added value was already in the hash table
  5051. or not.</p>
  5052. <div class="refsect3">
  5053. <a name="id-1.1.90.2.163.7"></a><h4>Parameters</h4>
  5054. <div class="informaltable"><table>
  5055. <tr>
  5056. <td class="parameter_name"><p>hash_table</p></td>
  5057. <td class="parameter_description">
  5058. <p>a <span class="type">GHashTable</span></p>
  5059. <p>Passed as <code class="code">hash-table</code></p>
  5060. </td>
  5061. </tr>
  5062. <tr>
  5063. <td class="parameter_name"><p>key</p></td>
  5064. <td class="parameter_description">
  5065. <p>a key to insert</p>
  5066. <p>Passed as <code class="code">key</code></p>
  5067. </td>
  5068. </tr>
  5069. </table></div>
  5070. </div>
  5071. </div>
  5072. <div class="refsect2">
  5073. <a name="id-1.1.90.2.164"></a><h3>hash-table-contains?</h3>
  5074. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hash-table-contains? hash-table key))
  5075. </pre></div>
  5076. <p>Checks if <em class="parameter"><code>key</code></em> is in <em class="parameter"><code>hash_table</code></em>.</p>
  5077. <div class="refsect3">
  5078. <a name="id-1.1.90.2.164.4"></a><h4>Parameters</h4>
  5079. <div class="informaltable"><table>
  5080. <tr>
  5081. <td class="parameter_name"><p>hash_table</p></td>
  5082. <td class="parameter_description">
  5083. <p>a <span class="type">GHashTable</span></p>
  5084. <p>Passed as <code class="code">hash-table</code></p>
  5085. </td>
  5086. </tr>
  5087. <tr>
  5088. <td class="parameter_name"><p>key</p></td>
  5089. <td class="parameter_description">
  5090. <p>a key to check</p>
  5091. <p>Passed as <code class="code">key</code></p>
  5092. </td>
  5093. </tr>
  5094. </table></div>
  5095. </div>
  5096. </div>
  5097. <div class="refsect2">
  5098. <a name="id-1.1.90.2.165"></a><h3>hash-table-destroy</h3>
  5099. <div class="informalexample"><pre class="programlisting">(define-values () (hash-table-destroy hash-table))
  5100. </pre></div>
  5101. <p>Destroys all keys and values in the <span class="type">GHashTable</span> and decrements its
  5102. reference count by 1. If keys and/or values are dynamically allocated,
  5103. you should either free them first or create the <span class="type">GHashTable</span> with destroy
  5104. notifiers using <code class="function">g_hash_table_new_full()</code>. In the latter case the destroy
  5105. functions you supplied will be called on all keys and values during the
  5106. destruction phase.</p>
  5107. <div class="refsect3">
  5108. <a name="id-1.1.90.2.165.4"></a><h4>Parameters</h4>
  5109. <div class="informaltable"><table><tr>
  5110. <td class="parameter_name"><p>hash_table</p></td>
  5111. <td class="parameter_description">
  5112. <p>a <span class="type">GHashTable</span></p>
  5113. <p>Passed as <code class="code">hash-table</code></p>
  5114. </td>
  5115. </tr></table></div>
  5116. </div>
  5117. </div>
  5118. <div class="refsect2">
  5119. <a name="id-1.1.90.2.166"></a><h3>hash-table-insert?</h3>
  5120. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hash-table-insert? hash-table key value))
  5121. </pre></div>
  5122. <p>Inserts a new key and value into a <span class="type">GHashTable</span>.
  5123. </p>
  5124. <p>If the key already exists in the <span class="type">GHashTable</span> its current
  5125. value is replaced with the new value. If you supplied a
  5126. <em class="parameter"><code>value_destroy_func</code></em> when creating the <span class="type">GHashTable</span>, the old
  5127. value is freed using that function. If you supplied a
  5128. <em class="parameter"><code>key_destroy_func</code></em> when creating the <span class="type">GHashTable</span>, the passed
  5129. key is freed using that function.
  5130. </p>
  5131. <p>Starting from GLib 2.40, this function returns a boolean value to
  5132. indicate whether the newly added value was already in the hash table
  5133. or not.</p>
  5134. <div class="refsect3">
  5135. <a name="id-1.1.90.2.166.6"></a><h4>Parameters</h4>
  5136. <div class="informaltable"><table>
  5137. <tr>
  5138. <td class="parameter_name"><p>hash_table</p></td>
  5139. <td class="parameter_description">
  5140. <p>a <span class="type">GHashTable</span></p>
  5141. <p>Passed as <code class="code">hash-table</code></p>
  5142. </td>
  5143. </tr>
  5144. <tr>
  5145. <td class="parameter_name"><p>key</p></td>
  5146. <td class="parameter_description">
  5147. <p>a key to insert</p>
  5148. <p>Passed as <code class="code">key</code></p>
  5149. </td>
  5150. </tr>
  5151. <tr>
  5152. <td class="parameter_name"><p>value</p></td>
  5153. <td class="parameter_description">
  5154. <p>the value to associate with the key</p>
  5155. <p>Passed as <code class="code">value</code></p>
  5156. </td>
  5157. </tr>
  5158. </table></div>
  5159. </div>
  5160. </div>
  5161. <div class="refsect2">
  5162. <a name="id-1.1.90.2.167"></a><h3>hash-table-lookup</h3>
  5163. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hash-table-lookup hash-table key))
  5164. </pre></div>
  5165. <p>Looks up a key in a <span class="type">GHashTable</span>. Note that this function cannot
  5166. distinguish between a key that is not present and one which is present
  5167. and has the value <code class="constant">NULL</code>. If you need this distinction, use
  5168. <code class="function">g_hash_table_lookup_extended()</code>.</p>
  5169. <div class="refsect3">
  5170. <a name="id-1.1.90.2.167.4"></a><h4>Parameters</h4>
  5171. <div class="informaltable"><table>
  5172. <tr>
  5173. <td class="parameter_name"><p>hash_table</p></td>
  5174. <td class="parameter_description">
  5175. <p>a <span class="type">GHashTable</span></p>
  5176. <p>Passed as <code class="code">hash-table</code></p>
  5177. </td>
  5178. </tr>
  5179. <tr>
  5180. <td class="parameter_name"><p>key</p></td>
  5181. <td class="parameter_description">
  5182. <p>the key to look up</p>
  5183. <p>Passed as <code class="code">key</code></p>
  5184. </td>
  5185. </tr>
  5186. </table></div>
  5187. </div>
  5188. </div>
  5189. <div class="refsect2">
  5190. <a name="id-1.1.90.2.168"></a><h3>hash-table-lookup-extended</h3>
  5191. <div class="informalexample"><pre class="programlisting">(define-values
  5192. (%return orig-key value)
  5193. (hash-table-lookup-extended hash-table lookup-key))
  5194. </pre></div>
  5195. <p>Looks up a key in the <span class="type">GHashTable</span>, returning the original key and the
  5196. associated value and a <span class="type">gboolean</span> which is <code class="constant">TRUE</code> if the key was found. This
  5197. is useful if you need to free the memory allocated for the original key,
  5198. for example before calling <code class="function">g_hash_table_remove()</code>.
  5199. </p>
  5200. <p>You can actually pass <code class="constant">NULL</code> for <em class="parameter"><code>lookup_key</code></em> to test
  5201. whether the <code class="constant">NULL</code> key exists, provided the hash and equal functions
  5202. of <em class="parameter"><code>hash_table</code></em> are <code class="constant">NULL</code>-safe.</p>
  5203. <div class="refsect3">
  5204. <a name="id-1.1.90.2.168.5"></a><h4>Parameters</h4>
  5205. <div class="informaltable"><table>
  5206. <tr>
  5207. <td class="parameter_name"><p>hash_table</p></td>
  5208. <td class="parameter_description">
  5209. <p>a <span class="type">GHashTable</span></p>
  5210. <p>Passed as <code class="code">hash-table</code></p>
  5211. </td>
  5212. </tr>
  5213. <tr>
  5214. <td class="parameter_name"><p>lookup_key</p></td>
  5215. <td class="parameter_description">
  5216. <p>the key to look up</p>
  5217. <p>Passed as <code class="code">lookup-key</code></p>
  5218. </td>
  5219. </tr>
  5220. <tr>
  5221. <td class="parameter_name"><p>orig_key</p></td>
  5222. <td class="parameter_description">
  5223. <p>return location for the original key</p>
  5224. <p>Passed as <code class="code">orig-key</code></p>
  5225. </td>
  5226. </tr>
  5227. <tr>
  5228. <td class="parameter_name"><p>value</p></td>
  5229. <td class="parameter_description">
  5230. <p>return location for the value associated
  5231. with the key</p>
  5232. <p>Passed as <code class="code">value</code></p>
  5233. </td>
  5234. </tr>
  5235. </table></div>
  5236. </div>
  5237. </div>
  5238. <div class="refsect2">
  5239. <a name="id-1.1.90.2.169"></a><h3>hash-table-remove?</h3>
  5240. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hash-table-remove? hash-table key))
  5241. </pre></div>
  5242. <p>Removes a key and its associated value from a <span class="type">GHashTable</span>.
  5243. </p>
  5244. <p>If the <span class="type">GHashTable</span> was created using <code class="function">g_hash_table_new_full()</code>, the
  5245. key and value are freed using the supplied destroy functions, otherwise
  5246. you have to make sure that any dynamically allocated values are freed
  5247. yourself.</p>
  5248. <div class="refsect3">
  5249. <a name="id-1.1.90.2.169.5"></a><h4>Parameters</h4>
  5250. <div class="informaltable"><table>
  5251. <tr>
  5252. <td class="parameter_name"><p>hash_table</p></td>
  5253. <td class="parameter_description">
  5254. <p>a <span class="type">GHashTable</span></p>
  5255. <p>Passed as <code class="code">hash-table</code></p>
  5256. </td>
  5257. </tr>
  5258. <tr>
  5259. <td class="parameter_name"><p>key</p></td>
  5260. <td class="parameter_description">
  5261. <p>the key to remove</p>
  5262. <p>Passed as <code class="code">key</code></p>
  5263. </td>
  5264. </tr>
  5265. </table></div>
  5266. </div>
  5267. </div>
  5268. <div class="refsect2">
  5269. <a name="id-1.1.90.2.170"></a><h3>hash-table-remove-all</h3>
  5270. <div class="informalexample"><pre class="programlisting">(define-values () (hash-table-remove-all hash-table))
  5271. </pre></div>
  5272. <p>Removes all keys and their associated values from a <span class="type">GHashTable</span>.
  5273. </p>
  5274. <p>If the <span class="type">GHashTable</span> was created using <code class="function">g_hash_table_new_full()</code>,
  5275. the keys and values are freed using the supplied destroy functions,
  5276. otherwise you have to make sure that any dynamically allocated
  5277. values are freed yourself.</p>
  5278. <div class="refsect3">
  5279. <a name="id-1.1.90.2.170.5"></a><h4>Parameters</h4>
  5280. <div class="informaltable"><table><tr>
  5281. <td class="parameter_name"><p>hash_table</p></td>
  5282. <td class="parameter_description">
  5283. <p>a <span class="type">GHashTable</span></p>
  5284. <p>Passed as <code class="code">hash-table</code></p>
  5285. </td>
  5286. </tr></table></div>
  5287. </div>
  5288. </div>
  5289. <div class="refsect2">
  5290. <a name="id-1.1.90.2.171"></a><h3>hash-table-replace?</h3>
  5291. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hash-table-replace? hash-table key value))
  5292. </pre></div>
  5293. <p>Inserts a new key and value into a <span class="type">GHashTable</span> similar to
  5294. <code class="function">g_hash_table_insert()</code>. The difference is that if the key
  5295. already exists in the <span class="type">GHashTable</span>, it gets replaced by the
  5296. new key. If you supplied a <em class="parameter"><code>value_destroy_func</code></em> when creating
  5297. the <span class="type">GHashTable</span>, the old value is freed using that function.
  5298. If you supplied a <em class="parameter"><code>key_destroy_func</code></em> when creating the
  5299. <span class="type">GHashTable</span>, the old key is freed using that function.
  5300. </p>
  5301. <p>Starting from GLib 2.40, this function returns a boolean value to
  5302. indicate whether the newly added value was already in the hash table
  5303. or not.</p>
  5304. <div class="refsect3">
  5305. <a name="id-1.1.90.2.171.5"></a><h4>Parameters</h4>
  5306. <div class="informaltable"><table>
  5307. <tr>
  5308. <td class="parameter_name"><p>hash_table</p></td>
  5309. <td class="parameter_description">
  5310. <p>a <span class="type">GHashTable</span></p>
  5311. <p>Passed as <code class="code">hash-table</code></p>
  5312. </td>
  5313. </tr>
  5314. <tr>
  5315. <td class="parameter_name"><p>key</p></td>
  5316. <td class="parameter_description">
  5317. <p>a key to insert</p>
  5318. <p>Passed as <code class="code">key</code></p>
  5319. </td>
  5320. </tr>
  5321. <tr>
  5322. <td class="parameter_name"><p>value</p></td>
  5323. <td class="parameter_description">
  5324. <p>the value to associate with the key</p>
  5325. <p>Passed as <code class="code">value</code></p>
  5326. </td>
  5327. </tr>
  5328. </table></div>
  5329. </div>
  5330. </div>
  5331. <div class="refsect2">
  5332. <a name="id-1.1.90.2.172"></a><h3>hash-table-size</h3>
  5333. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hash-table-size hash-table))
  5334. </pre></div>
  5335. <p>Returns the number of elements contained in the <span class="type">GHashTable</span>.</p>
  5336. <div class="refsect3">
  5337. <a name="id-1.1.90.2.172.4"></a><h4>Parameters</h4>
  5338. <div class="informaltable"><table><tr>
  5339. <td class="parameter_name"><p>hash_table</p></td>
  5340. <td class="parameter_description">
  5341. <p>a <span class="type">GHashTable</span></p>
  5342. <p>Passed as <code class="code">hash-table</code></p>
  5343. </td>
  5344. </tr></table></div>
  5345. </div>
  5346. </div>
  5347. <div class="refsect2">
  5348. <a name="id-1.1.90.2.173"></a><h3>hash-table-steal?</h3>
  5349. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hash-table-steal? hash-table key))
  5350. </pre></div>
  5351. <p>Removes a key and its associated value from a <span class="type">GHashTable</span> without
  5352. calling the key and value destroy functions.</p>
  5353. <div class="refsect3">
  5354. <a name="id-1.1.90.2.173.4"></a><h4>Parameters</h4>
  5355. <div class="informaltable"><table>
  5356. <tr>
  5357. <td class="parameter_name"><p>hash_table</p></td>
  5358. <td class="parameter_description">
  5359. <p>a <span class="type">GHashTable</span></p>
  5360. <p>Passed as <code class="code">hash-table</code></p>
  5361. </td>
  5362. </tr>
  5363. <tr>
  5364. <td class="parameter_name"><p>key</p></td>
  5365. <td class="parameter_description">
  5366. <p>the key to remove</p>
  5367. <p>Passed as <code class="code">key</code></p>
  5368. </td>
  5369. </tr>
  5370. </table></div>
  5371. </div>
  5372. </div>
  5373. <div class="refsect2">
  5374. <a name="id-1.1.90.2.174"></a><h3>hash-table-steal-all</h3>
  5375. <div class="informalexample"><pre class="programlisting">(define-values () (hash-table-steal-all hash-table))
  5376. </pre></div>
  5377. <p>Removes all keys and their associated values from a <span class="type">GHashTable</span>
  5378. without calling the key and value destroy functions.</p>
  5379. <div class="refsect3">
  5380. <a name="id-1.1.90.2.174.4"></a><h4>Parameters</h4>
  5381. <div class="informaltable"><table><tr>
  5382. <td class="parameter_name"><p>hash_table</p></td>
  5383. <td class="parameter_description">
  5384. <p>a <span class="type">GHashTable</span></p>
  5385. <p>Passed as <code class="code">hash-table</code></p>
  5386. </td>
  5387. </tr></table></div>
  5388. </div>
  5389. </div>
  5390. <div class="refsect2">
  5391. <a name="id-1.1.90.2.175"></a><h3>hash-table-steal-extended</h3>
  5392. <div class="informalexample"><pre class="programlisting">(define-values
  5393. (%return stolen-key stolen-value)
  5394. (hash-table-steal-extended hash-table lookup-key))
  5395. </pre></div>
  5396. <p>Looks up a key in the <span class="type">GHashTable</span>, stealing the original key and the
  5397. associated value and returning <code class="constant">TRUE</code> if the key was found. If the key was
  5398. not found, <code class="constant">FALSE</code> is returned.
  5399. </p>
  5400. <p>If found, the stolen key and value are removed from the hash table without
  5401. calling the key and value destroy functions, and ownership is transferred to
  5402. the caller of this method; as with <code class="function">g_hash_table_steal()</code>.
  5403. </p>
  5404. <p>You can pass <code class="constant">NULL</code> for <em class="parameter"><code>lookup_key</code></em>, provided the hash and equal functions
  5405. of <em class="parameter"><code>hash_table</code></em> are <code class="constant">NULL</code>-safe.</p>
  5406. <div class="refsect3">
  5407. <a name="id-1.1.90.2.175.6"></a><h4>Parameters</h4>
  5408. <div class="informaltable"><table>
  5409. <tr>
  5410. <td class="parameter_name"><p>hash_table</p></td>
  5411. <td class="parameter_description">
  5412. <p>a <span class="type">GHashTable</span></p>
  5413. <p>Passed as <code class="code">hash-table</code></p>
  5414. </td>
  5415. </tr>
  5416. <tr>
  5417. <td class="parameter_name"><p>lookup_key</p></td>
  5418. <td class="parameter_description">
  5419. <p>the key to look up</p>
  5420. <p>Passed as <code class="code">lookup-key</code></p>
  5421. </td>
  5422. </tr>
  5423. <tr>
  5424. <td class="parameter_name"><p>stolen_key</p></td>
  5425. <td class="parameter_description">
  5426. <p>return location for the
  5427. original key</p>
  5428. <p>Passed as <code class="code">stolen-key</code></p>
  5429. </td>
  5430. </tr>
  5431. <tr>
  5432. <td class="parameter_name"><p>stolen_value</p></td>
  5433. <td class="parameter_description">
  5434. <p>return location
  5435. for the value associated with the key</p>
  5436. <p>Passed as <code class="code">stolen-value</code></p>
  5437. </td>
  5438. </tr>
  5439. </table></div>
  5440. </div>
  5441. </div>
  5442. <div class="refsect2">
  5443. <a name="id-1.1.90.2.176"></a><h3>hash-table-unref</h3>
  5444. <div class="informalexample"><pre class="programlisting">(define-values () (hash-table-unref hash-table))
  5445. </pre></div>
  5446. <p>Atomically decrements the reference count of <em class="parameter"><code>hash_table</code></em> by one.
  5447. If the reference count drops to 0, all keys and values will be
  5448. destroyed, and all memory allocated by the hash table is released.
  5449. This function is MT-safe and may be called from any thread.</p>
  5450. <div class="refsect3">
  5451. <a name="id-1.1.90.2.176.4"></a><h4>Parameters</h4>
  5452. <div class="informaltable"><table><tr>
  5453. <td class="parameter_name"><p>hash_table</p></td>
  5454. <td class="parameter_description">
  5455. <p>a valid <span class="type">GHashTable</span></p>
  5456. <p>Passed as <code class="code">hash-table</code></p>
  5457. </td>
  5458. </tr></table></div>
  5459. </div>
  5460. </div>
  5461. <div class="refsect2">
  5462. <a name="id-1.1.90.2.177"></a><h3>hostname-is-ascii-encoded?</h3>
  5463. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hostname-is-ascii-encoded? hostname))
  5464. </pre></div>
  5465. <p>Tests if <em class="parameter"><code>hostname</code></em> contains segments with an ASCII-compatible
  5466. encoding of an Internationalized Domain Name. If this returns
  5467. <code class="constant">TRUE</code>, you should decode the hostname with <code class="function">g_hostname_to_unicode()</code>
  5468. before displaying it to the user.
  5469. </p>
  5470. <p>Note that a hostname might contain a mix of encoded and unencoded
  5471. segments, and so it is possible for <code class="function">g_hostname_is_non_ascii()</code> and
  5472. <code class="function">g_hostname_is_ascii_encoded()</code> to both return <code class="constant">TRUE</code> for a name.</p>
  5473. <div class="refsect3">
  5474. <a name="id-1.1.90.2.177.5"></a><h4>Parameters</h4>
  5475. <div class="informaltable"><table><tr>
  5476. <td class="parameter_name"><p>hostname</p></td>
  5477. <td class="parameter_description">
  5478. <p>a hostname</p>
  5479. <p>Passed as <code class="code">hostname</code></p>
  5480. </td>
  5481. </tr></table></div>
  5482. </div>
  5483. </div>
  5484. <div class="refsect2">
  5485. <a name="id-1.1.90.2.178"></a><h3>hostname-is-ip-address?</h3>
  5486. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hostname-is-ip-address? hostname))
  5487. </pre></div>
  5488. <p>Tests if <em class="parameter"><code>hostname</code></em> is the string form of an IPv4 or IPv6 address.
  5489. (Eg, "192.168.0.1".)
  5490. </p>
  5491. <p>Since 2.66, IPv6 addresses with a zone-id are accepted (RFC6874).</p>
  5492. <div class="refsect3">
  5493. <a name="id-1.1.90.2.178.5"></a><h4>Parameters</h4>
  5494. <div class="informaltable"><table><tr>
  5495. <td class="parameter_name"><p>hostname</p></td>
  5496. <td class="parameter_description">
  5497. <p>a hostname (or IP address in string form)</p>
  5498. <p>Passed as <code class="code">hostname</code></p>
  5499. </td>
  5500. </tr></table></div>
  5501. </div>
  5502. </div>
  5503. <div class="refsect2">
  5504. <a name="id-1.1.90.2.179"></a><h3>hostname-is-non-ascii?</h3>
  5505. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hostname-is-non-ascii? hostname))
  5506. </pre></div>
  5507. <p>Tests if <em class="parameter"><code>hostname</code></em> contains Unicode characters. If this returns
  5508. <code class="constant">TRUE</code>, you need to encode the hostname with <code class="function">g_hostname_to_ascii()</code>
  5509. before using it in non-IDN-aware contexts.
  5510. </p>
  5511. <p>Note that a hostname might contain a mix of encoded and unencoded
  5512. segments, and so it is possible for <code class="function">g_hostname_is_non_ascii()</code> and
  5513. <code class="function">g_hostname_is_ascii_encoded()</code> to both return <code class="constant">TRUE</code> for a name.</p>
  5514. <div class="refsect3">
  5515. <a name="id-1.1.90.2.179.5"></a><h4>Parameters</h4>
  5516. <div class="informaltable"><table><tr>
  5517. <td class="parameter_name"><p>hostname</p></td>
  5518. <td class="parameter_description">
  5519. <p>a hostname</p>
  5520. <p>Passed as <code class="code">hostname</code></p>
  5521. </td>
  5522. </tr></table></div>
  5523. </div>
  5524. </div>
  5525. <div class="refsect2">
  5526. <a name="id-1.1.90.2.180"></a><h3>hostname-to-ascii</h3>
  5527. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hostname-to-ascii hostname))
  5528. </pre></div>
  5529. <p>Converts <em class="parameter"><code>hostname</code></em> to its canonical ASCII form; an ASCII-only
  5530. string containing no uppercase letters and not ending with a
  5531. trailing dot.</p>
  5532. <div class="refsect3">
  5533. <a name="id-1.1.90.2.180.4"></a><h4>Parameters</h4>
  5534. <div class="informaltable"><table><tr>
  5535. <td class="parameter_name"><p>hostname</p></td>
  5536. <td class="parameter_description">
  5537. <p>a valid UTF-8 or ASCII hostname</p>
  5538. <p>Passed as <code class="code">hostname</code></p>
  5539. </td>
  5540. </tr></table></div>
  5541. </div>
  5542. </div>
  5543. <div class="refsect2">
  5544. <a name="id-1.1.90.2.181"></a><h3>hostname-to-unicode</h3>
  5545. <div class="informalexample"><pre class="programlisting">(define-values (%return) (hostname-to-unicode hostname))
  5546. </pre></div>
  5547. <p>Converts <em class="parameter"><code>hostname</code></em> to its canonical presentation form; a UTF-8
  5548. string in Unicode normalization form C, containing no uppercase
  5549. letters, no forbidden characters, and no ASCII-encoded segments,
  5550. and not ending with a trailing dot.
  5551. </p>
  5552. <p>Of course if <em class="parameter"><code>hostname</code></em> is not an internationalized hostname, then
  5553. the canonical presentation form will be entirely ASCII.</p>
  5554. <div class="refsect3">
  5555. <a name="id-1.1.90.2.181.5"></a><h4>Parameters</h4>
  5556. <div class="informaltable"><table><tr>
  5557. <td class="parameter_name"><p>hostname</p></td>
  5558. <td class="parameter_description">
  5559. <p>a valid UTF-8 or ASCII hostname</p>
  5560. <p>Passed as <code class="code">hostname</code></p>
  5561. </td>
  5562. </tr></table></div>
  5563. </div>
  5564. </div>
  5565. <div class="refsect2">
  5566. <a name="id-1.1.90.2.182"></a><h3>idle-add</h3>
  5567. <div class="informalexample"><pre class="programlisting">(define-values (%return) (idle-add priority function data notify))
  5568. </pre></div>
  5569. <p>Adds a function to be called whenever there are no higher priority
  5570. events pending to the default main loop. The function is given the
  5571. default idle priority, <span class="type">G_PRIORITY_DEFAULT_IDLE</span>. If the function
  5572. returns <code class="constant">FALSE</code> it is automatically removed from the list of event
  5573. sources and will not be called again.
  5574. </p>
  5575. <p>See [memory management of sources][mainloop-memory-management] for details
  5576. on how to handle the return value and memory management of <em class="parameter"><code>data</code></em>.
  5577. </p>
  5578. <p>This internally creates a main loop source using <code class="function">g_idle_source_new()</code>
  5579. and attaches it to the global <span class="type">GMainContext</span> using <code class="function">g_source_attach()</code>, so
  5580. the callback will be invoked in whichever thread is running that main
  5581. context. You can do these steps manually if you need greater control or to
  5582. use a custom main context.</p>
  5583. <div class="refsect3">
  5584. <a name="id-1.1.90.2.182.6"></a><h4>Parameters</h4>
  5585. <div class="informaltable"><table>
  5586. <tr>
  5587. <td class="parameter_name"><p>notify</p></td>
  5588. <td class="parameter_description">
  5589. <p></p>
  5590. <p>Passed as <code class="code">notify</code></p>
  5591. </td>
  5592. </tr>
  5593. <tr>
  5594. <td class="parameter_name"><p>priority</p></td>
  5595. <td class="parameter_description">
  5596. <p></p>
  5597. <p>Passed as <code class="code">priority</code></p>
  5598. </td>
  5599. </tr>
  5600. <tr>
  5601. <td class="parameter_name"><p>function</p></td>
  5602. <td class="parameter_description">
  5603. <p>function to call</p>
  5604. <p>Passed as <code class="code">function</code></p>
  5605. </td>
  5606. </tr>
  5607. <tr>
  5608. <td class="parameter_name"><p>data</p></td>
  5609. <td class="parameter_description">
  5610. <p>data to pass to <em class="parameter"><code>function</code></em>.</p>
  5611. <p>Passed as <code class="code">data</code></p>
  5612. </td>
  5613. </tr>
  5614. </table></div>
  5615. </div>
  5616. </div>
  5617. <div class="refsect2">
  5618. <a name="id-1.1.90.2.183"></a><h3>idle-remove-by-data?</h3>
  5619. <div class="informalexample"><pre class="programlisting">(define-values (%return) (idle-remove-by-data? data))
  5620. </pre></div>
  5621. <p>Removes the idle function with the given data.</p>
  5622. <div class="refsect3">
  5623. <a name="id-1.1.90.2.183.4"></a><h4>Parameters</h4>
  5624. <div class="informaltable"><table><tr>
  5625. <td class="parameter_name"><p>data</p></td>
  5626. <td class="parameter_description">
  5627. <p>the data for the idle source's callback.</p>
  5628. <p>Passed as <code class="code">data</code></p>
  5629. </td>
  5630. </tr></table></div>
  5631. </div>
  5632. </div>
  5633. <div class="refsect2">
  5634. <a name="id-1.1.90.2.184"></a><h3>idle-source-new</h3>
  5635. <div class="informalexample"><pre class="programlisting">(define-values (%return) (idle-source-new))
  5636. </pre></div>
  5637. <p>Creates a new idle source.
  5638. </p>
  5639. <p>The source will not initially be associated with any <span class="type">GMainContext</span>
  5640. and must be added to one with <code class="function">g_source_attach()</code> before it will be
  5641. executed. Note that the default priority for idle sources is
  5642. <code class="constant">G_PRIORITY_DEFAULT_IDLE</code>, as compared to other sources which
  5643. have a default priority of <code class="constant">G_PRIORITY_DEFAULT</code>.</p>
  5644. </div>
  5645. <div class="refsect2">
  5646. <a name="id-1.1.90.2.185"></a><h3>int64-equal?</h3>
  5647. <div class="informalexample"><pre class="programlisting">(define-values (%return) (int64-equal? v1 v2))
  5648. </pre></div>
  5649. <p>Compares the two <span class="type">gint64</span> values being pointed to and returns
  5650. <code class="constant">TRUE</code> if they are equal.
  5651. It can be passed to <code class="function">g_hash_table_new()</code> as the <em class="parameter"><code>key_equal_func</code></em>
  5652. parameter, when using non-<code class="constant">NULL</code> pointers to 64-bit integers as keys in a
  5653. <span class="type">GHashTable</span>.</p>
  5654. <div class="refsect3">
  5655. <a name="id-1.1.90.2.185.4"></a><h4>Parameters</h4>
  5656. <div class="informaltable"><table>
  5657. <tr>
  5658. <td class="parameter_name"><p>v1</p></td>
  5659. <td class="parameter_description">
  5660. <p>a pointer to a <span class="type">gint64</span> key</p>
  5661. <p>Passed as <code class="code">v1</code></p>
  5662. </td>
  5663. </tr>
  5664. <tr>
  5665. <td class="parameter_name"><p>v2</p></td>
  5666. <td class="parameter_description">
  5667. <p>a pointer to a <span class="type">gint64</span> key to compare with <em class="parameter"><code>v1</code></em></p>
  5668. <p>Passed as <code class="code">v2</code></p>
  5669. </td>
  5670. </tr>
  5671. </table></div>
  5672. </div>
  5673. </div>
  5674. <div class="refsect2">
  5675. <a name="id-1.1.90.2.186"></a><h3>int64-hash</h3>
  5676. <div class="informalexample"><pre class="programlisting">(define-values (%return) (int64-hash v))
  5677. </pre></div>
  5678. <p>Converts a pointer to a <span class="type">gint64</span> to a hash value.
  5679. </p>
  5680. <p>It can be passed to <code class="function">g_hash_table_new()</code> as the <em class="parameter"><code>hash_func</code></em> parameter,
  5681. when using non-<code class="constant">NULL</code> pointers to 64-bit integer values as keys in a
  5682. <span class="type">GHashTable</span>.</p>
  5683. <div class="refsect3">
  5684. <a name="id-1.1.90.2.186.5"></a><h4>Parameters</h4>
  5685. <div class="informaltable"><table><tr>
  5686. <td class="parameter_name"><p>v</p></td>
  5687. <td class="parameter_description">
  5688. <p>a pointer to a <span class="type">gint64</span> key</p>
  5689. <p>Passed as <code class="code">v</code></p>
  5690. </td>
  5691. </tr></table></div>
  5692. </div>
  5693. </div>
  5694. <div class="refsect2">
  5695. <a name="id-1.1.90.2.187"></a><h3>int-equal?</h3>
  5696. <div class="informalexample"><pre class="programlisting">(define-values (%return) (int-equal? v1 v2))
  5697. </pre></div>
  5698. <p>Compares the two <span class="type">gint</span> values being pointed to and returns
  5699. <code class="constant">TRUE</code> if they are equal.
  5700. It can be passed to <code class="function">g_hash_table_new()</code> as the <em class="parameter"><code>key_equal_func</code></em>
  5701. parameter, when using non-<code class="constant">NULL</code> pointers to integers as keys in a
  5702. <span class="type">GHashTable</span>.
  5703. </p>
  5704. <p>Note that this function acts on pointers to <span class="type">gint</span>, not on <span class="type">gint</span>
  5705. directly: if your hash table's keys are of the form
  5706. <code class="code">GINT_TO_POINTER (n)</code>, use <code class="function">g_direct_equal()</code> instead.</p>
  5707. <div class="refsect3">
  5708. <a name="id-1.1.90.2.187.5"></a><h4>Parameters</h4>
  5709. <div class="informaltable"><table>
  5710. <tr>
  5711. <td class="parameter_name"><p>v1</p></td>
  5712. <td class="parameter_description">
  5713. <p>a pointer to a <span class="type">gint</span> key</p>
  5714. <p>Passed as <code class="code">v1</code></p>
  5715. </td>
  5716. </tr>
  5717. <tr>
  5718. <td class="parameter_name"><p>v2</p></td>
  5719. <td class="parameter_description">
  5720. <p>a pointer to a <span class="type">gint</span> key to compare with <em class="parameter"><code>v1</code></em></p>
  5721. <p>Passed as <code class="code">v2</code></p>
  5722. </td>
  5723. </tr>
  5724. </table></div>
  5725. </div>
  5726. </div>
  5727. <div class="refsect2">
  5728. <a name="id-1.1.90.2.188"></a><h3>int-hash</h3>
  5729. <div class="informalexample"><pre class="programlisting">(define-values (%return) (int-hash v))
  5730. </pre></div>
  5731. <p>Converts a pointer to a <span class="type">gint</span> to a hash value.
  5732. It can be passed to <code class="function">g_hash_table_new()</code> as the <em class="parameter"><code>hash_func</code></em> parameter,
  5733. when using non-<code class="constant">NULL</code> pointers to integer values as keys in a <span class="type">GHashTable</span>.
  5734. </p>
  5735. <p>Note that this function acts on pointers to <span class="type">gint</span>, not on <span class="type">gint</span>
  5736. directly: if your hash table's keys are of the form
  5737. <code class="code">GINT_TO_POINTER (n)</code>, use <code class="function">g_direct_hash()</code> instead.</p>
  5738. <div class="refsect3">
  5739. <a name="id-1.1.90.2.188.5"></a><h4>Parameters</h4>
  5740. <div class="informaltable"><table><tr>
  5741. <td class="parameter_name"><p>v</p></td>
  5742. <td class="parameter_description">
  5743. <p>a pointer to a <span class="type">gint</span> key</p>
  5744. <p>Passed as <code class="code">v</code></p>
  5745. </td>
  5746. </tr></table></div>
  5747. </div>
  5748. </div>
  5749. <div class="refsect2">
  5750. <a name="id-1.1.90.2.189"></a><h3>intern-static-string</h3>
  5751. <div class="informalexample"><pre class="programlisting">(define-values (%return) (intern-static-string string))
  5752. </pre></div>
  5753. <p>Returns a canonical representation for <em class="parameter"><code>string</code></em>. Interned strings
  5754. can be compared for equality by comparing the pointers, instead of
  5755. using <code class="function">strcmp()</code>. <code class="function">g_intern_static_string()</code> does not copy the string,
  5756. therefore <em class="parameter"><code>string</code></em> must not be freed or modified.
  5757. </p>
  5758. <p>This function must not be used before library constructors have finished
  5759. running. In particular, this means it cannot be used to initialize global
  5760. variables in C++.</p>
  5761. <div class="refsect3">
  5762. <a name="id-1.1.90.2.189.5"></a><h4>Parameters</h4>
  5763. <div class="informaltable"><table><tr>
  5764. <td class="parameter_name"><p>string</p></td>
  5765. <td class="parameter_description">
  5766. <p>a static string</p>
  5767. <p>Passed as <code class="code">string</code></p>
  5768. </td>
  5769. </tr></table></div>
  5770. </div>
  5771. </div>
  5772. <div class="refsect2">
  5773. <a name="id-1.1.90.2.190"></a><h3>intern-string</h3>
  5774. <div class="informalexample"><pre class="programlisting">(define-values (%return) (intern-string string))
  5775. </pre></div>
  5776. <p>Returns a canonical representation for <em class="parameter"><code>string</code></em>. Interned strings
  5777. can be compared for equality by comparing the pointers, instead of
  5778. using <code class="function">strcmp()</code>.
  5779. </p>
  5780. <p>This function must not be used before library constructors have finished
  5781. running. In particular, this means it cannot be used to initialize global
  5782. variables in C++.</p>
  5783. <div class="refsect3">
  5784. <a name="id-1.1.90.2.190.5"></a><h4>Parameters</h4>
  5785. <div class="informaltable"><table><tr>
  5786. <td class="parameter_name"><p>string</p></td>
  5787. <td class="parameter_description">
  5788. <p>a string</p>
  5789. <p>Passed as <code class="code">string</code></p>
  5790. </td>
  5791. </tr></table></div>
  5792. </div>
  5793. </div>
  5794. <div class="refsect2">
  5795. <a name="id-1.1.90.2.191"></a><h3>io-add-watch</h3>
  5796. <div class="informalexample"><pre class="programlisting">(define-values
  5797. (%return)
  5798. (io-add-watch channel priority condition func user-data notify))
  5799. </pre></div>
  5800. <p>Adds the <span class="type">GIOChannel</span> into the default main loop context
  5801. with the default priority.</p>
  5802. <div class="refsect3">
  5803. <a name="id-1.1.90.2.191.4"></a><h4>Parameters</h4>
  5804. <div class="informaltable"><table>
  5805. <tr>
  5806. <td class="parameter_name"><p>notify</p></td>
  5807. <td class="parameter_description">
  5808. <p></p>
  5809. <p>Passed as <code class="code">notify</code></p>
  5810. </td>
  5811. </tr>
  5812. <tr>
  5813. <td class="parameter_name"><p>priority</p></td>
  5814. <td class="parameter_description">
  5815. <p></p>
  5816. <p>Passed as <code class="code">priority</code></p>
  5817. </td>
  5818. </tr>
  5819. <tr>
  5820. <td class="parameter_name"><p>channel</p></td>
  5821. <td class="parameter_description">
  5822. <p>a <span class="type">GIOChannel</span></p>
  5823. <p>Passed as <code class="code">channel</code></p>
  5824. </td>
  5825. </tr>
  5826. <tr>
  5827. <td class="parameter_name"><p>condition</p></td>
  5828. <td class="parameter_description">
  5829. <p>the condition to watch for</p>
  5830. <p>Passed as <code class="code">condition</code></p>
  5831. </td>
  5832. </tr>
  5833. <tr>
  5834. <td class="parameter_name"><p>func</p></td>
  5835. <td class="parameter_description">
  5836. <p>the function to call when the condition is satisfied</p>
  5837. <p>Passed as <code class="code">func</code></p>
  5838. </td>
  5839. </tr>
  5840. <tr>
  5841. <td class="parameter_name"><p>user_data</p></td>
  5842. <td class="parameter_description">
  5843. <p>user data to pass to <em class="parameter"><code>func</code></em></p>
  5844. <p>Passed as <code class="code">user-data</code></p>
  5845. </td>
  5846. </tr>
  5847. </table></div>
  5848. </div>
  5849. </div>
  5850. <div class="refsect2">
  5851. <a name="id-1.1.90.2.192"></a><h3>io-channel-error-from-errno</h3>
  5852. <div class="informalexample"><pre class="programlisting">(define-values (%return) (io-channel-error-from-errno en))
  5853. </pre></div>
  5854. <p>Converts an <code class="code">errno</code> error number to a <span class="type">GIOChannelError</span>.</p>
  5855. <div class="refsect3">
  5856. <a name="id-1.1.90.2.192.4"></a><h4>Parameters</h4>
  5857. <div class="informaltable"><table><tr>
  5858. <td class="parameter_name"><p>en</p></td>
  5859. <td class="parameter_description">
  5860. <p>an <code class="code">errno</code> error number, e.g. <code class="code">EINVAL</code></p>
  5861. <p>Passed as <code class="code">en</code></p>
  5862. </td>
  5863. </tr></table></div>
  5864. </div>
  5865. </div>
  5866. <div class="refsect2">
  5867. <a name="id-1.1.90.2.193"></a><h3>io-channel-error-quark</h3>
  5868. <div class="informalexample"><pre class="programlisting">(define-values (%return) (io-channel-error-quark))
  5869. </pre></div>
  5870. <p>Undocumented</p>
  5871. </div>
  5872. <div class="refsect2">
  5873. <a name="id-1.1.90.2.194"></a><h3>io-create-watch</h3>
  5874. <div class="informalexample"><pre class="programlisting">(define-values (%return) (io-create-watch channel condition))
  5875. </pre></div>
  5876. <p>Creates a <span class="type">GSource</span> that's dispatched when <em class="parameter"><code>condition</code></em> is met for the
  5877. given <em class="parameter"><code>channel</code></em>. For example, if condition is <span class="type">G_IO_IN</span>, the source will
  5878. be dispatched when there's data available for reading.
  5879. </p>
  5880. <p>The callback function invoked by the <span class="type">GSource</span> should be added with
  5881. <code class="function">g_source_set_callback()</code>, but it has type <span class="type">GIOFunc</span> (not <span class="type">GSourceFunc</span>).
  5882. </p>
  5883. <p><code class="function">g_io_add_watch()</code> is a simpler interface to this same functionality, for
  5884. the case where you want to add the source to the default main loop context
  5885. at the default priority.
  5886. </p>
  5887. <p>On Windows, polling a <span class="type">GSource</span> created to watch a channel for a socket
  5888. puts the socket in non-blocking mode. This is a side-effect of the
  5889. implementation and unavoidable.</p>
  5890. <div class="refsect3">
  5891. <a name="id-1.1.90.2.194.7"></a><h4>Parameters</h4>
  5892. <div class="informaltable"><table>
  5893. <tr>
  5894. <td class="parameter_name"><p>channel</p></td>
  5895. <td class="parameter_description">
  5896. <p>a <span class="type">GIOChannel</span> to watch</p>
  5897. <p>Passed as <code class="code">channel</code></p>
  5898. </td>
  5899. </tr>
  5900. <tr>
  5901. <td class="parameter_name"><p>condition</p></td>
  5902. <td class="parameter_description">
  5903. <p>conditions to watch for</p>
  5904. <p>Passed as <code class="code">condition</code></p>
  5905. </td>
  5906. </tr>
  5907. </table></div>
  5908. </div>
  5909. </div>
  5910. <div class="refsect2">
  5911. <a name="id-1.1.90.2.195"></a><h3>key-file-error-quark</h3>
  5912. <div class="informalexample"><pre class="programlisting">(define-values (%return) (key-file-error-quark))
  5913. </pre></div>
  5914. <p>Undocumented</p>
  5915. </div>
  5916. <div class="refsect2">
  5917. <a name="id-1.1.90.2.196"></a><h3>listenv</h3>
  5918. <div class="informalexample"><pre class="programlisting">(define-values (%return) (listenv))
  5919. </pre></div>
  5920. <p>Gets the names of all variables set in the environment.
  5921. </p>
  5922. <p>Programs that want to be portable to Windows should typically use
  5923. this function and <code class="function">g_getenv()</code> instead of using the environ array
  5924. from the C library directly. On Windows, the strings in the environ
  5925. array are in system codepage encoding, while in most of the typical
  5926. use cases for environment variables in GLib-using programs you want
  5927. the UTF-8 encoding that this function and <code class="function">g_getenv()</code> provide.</p>
  5928. </div>
  5929. <div class="refsect2">
  5930. <a name="id-1.1.90.2.197"></a><h3>locale-from-utf8</h3>
  5931. <div class="informalexample"><pre class="programlisting">(define-values
  5932. (%return bytes-read bytes-written)
  5933. (locale-from-utf8 utf8string len))
  5934. </pre></div>
  5935. <p>Converts a string from UTF-8 to the encoding used for strings by
  5936. the C runtime (usually the same as that used by the operating
  5937. system) in the [current locale][setlocale]. On Windows this means
  5938. the system codepage.
  5939. </p>
  5940. <p>The input string shall not contain nul characters even if the <em class="parameter"><code>len</code></em>
  5941. argument is positive. A nul character found inside the string will result
  5942. in error <code class="constant">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</code>. Use <code class="function">g_convert()</code> to convert
  5943. input that may contain embedded nul characters.</p>
  5944. <div class="refsect3">
  5945. <a name="id-1.1.90.2.197.5"></a><h4>Parameters</h4>
  5946. <div class="informaltable"><table>
  5947. <tr>
  5948. <td class="parameter_name"><p>utf8string</p></td>
  5949. <td class="parameter_description">
  5950. <p>a UTF-8 encoded string</p>
  5951. <p>Passed as <code class="code">utf8string</code></p>
  5952. </td>
  5953. </tr>
  5954. <tr>
  5955. <td class="parameter_name"><p>len</p></td>
  5956. <td class="parameter_description">
  5957. <p>the length of the string, or -1 if the string is
  5958. nul-terminated.</p>
  5959. <p>Passed as <code class="code">len</code></p>
  5960. </td>
  5961. </tr>
  5962. <tr>
  5963. <td class="parameter_name"><p>bytes_read</p></td>
  5964. <td class="parameter_description">
  5965. <p>location to store the number of bytes in the
  5966. input string that were successfully converted, or <code class="constant">NULL</code>.
  5967. Even if the conversion was successful, this may be
  5968. less than <em class="parameter"><code>len</code></em> if there were partial characters
  5969. at the end of the input. If the error
  5970. <code class="constant">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</code> occurs, the value
  5971. stored will be the byte offset after the last valid
  5972. input sequence.</p>
  5973. <p>Passed as <code class="code">bytes-read</code></p>
  5974. </td>
  5975. </tr>
  5976. <tr>
  5977. <td class="parameter_name"><p>bytes_written</p></td>
  5978. <td class="parameter_description">
  5979. <p>the number of bytes stored in the output
  5980. buffer (not including the terminating nul).</p>
  5981. <p>Inferred from <code class="code">%return</code></p>
  5982. </td>
  5983. </tr>
  5984. </table></div>
  5985. </div>
  5986. </div>
  5987. <div class="refsect2">
  5988. <a name="id-1.1.90.2.198"></a><h3>locale-to-utf8</h3>
  5989. <div class="informalexample"><pre class="programlisting">(define-values
  5990. (%return bytes-read bytes-written)
  5991. (locale-to-utf8 opsysstring))
  5992. </pre></div>
  5993. <p>Converts a string which is in the encoding used for strings by
  5994. the C runtime (usually the same as that used by the operating
  5995. system) in the [current locale][setlocale] into a UTF-8 string.
  5996. </p>
  5997. <p>If the source encoding is not UTF-8 and the conversion output contains a
  5998. nul character, the error <code class="constant">G_CONVERT_ERROR_EMBEDDED_NUL</code> is set and the
  5999. function returns <code class="constant">NULL</code>.
  6000. If the source encoding is UTF-8, an embedded nul character is treated with
  6001. the <code class="constant">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</code> error for backward compatibility with
  6002. earlier versions of this library. Use <code class="function">g_convert()</code> to produce output that
  6003. may contain embedded nul characters.</p>
  6004. <div class="refsect3">
  6005. <a name="id-1.1.90.2.198.5"></a><h4>Parameters</h4>
  6006. <div class="informaltable"><table>
  6007. <tr>
  6008. <td class="parameter_name"><p>opsysstring</p></td>
  6009. <td class="parameter_description">
  6010. <p>a string in the
  6011. encoding of the current locale. On Windows
  6012. this means the system codepage.</p>
  6013. <p>Passed as <code class="code">opsysstring</code></p>
  6014. </td>
  6015. </tr>
  6016. <tr>
  6017. <td class="parameter_name"><p>len</p></td>
  6018. <td class="parameter_description">
  6019. <p>the length of the string, or -1 if the string is
  6020. nul-terminated (Note that some encodings may allow nul
  6021. bytes to occur inside strings. In that case, using -1
  6022. for the <em class="parameter"><code>len</code></em> parameter is unsafe)</p>
  6023. <p>Inferred from <code class="code">opsysstring</code></p>
  6024. </td>
  6025. </tr>
  6026. <tr>
  6027. <td class="parameter_name"><p>bytes_read</p></td>
  6028. <td class="parameter_description">
  6029. <p>location to store the number of bytes in the
  6030. input string that were successfully converted, or <code class="constant">NULL</code>.
  6031. Even if the conversion was successful, this may be
  6032. less than <em class="parameter"><code>len</code></em> if there were partial characters
  6033. at the end of the input. If the error
  6034. <code class="constant">G_CONVERT_ERROR_ILLEGAL_SEQUENCE</code> occurs, the value
  6035. stored will be the byte offset after the last valid
  6036. input sequence.</p>
  6037. <p>Passed as <code class="code">bytes-read</code></p>
  6038. </td>
  6039. </tr>
  6040. <tr>
  6041. <td class="parameter_name"><p>bytes_written</p></td>
  6042. <td class="parameter_description">
  6043. <p>the number of bytes stored in the output
  6044. buffer (not including the terminating nul).</p>
  6045. <p>Passed as <code class="code">bytes-written</code></p>
  6046. </td>
  6047. </tr>
  6048. </table></div>
  6049. </div>
  6050. </div>
  6051. <div class="refsect2">
  6052. <a name="id-1.1.90.2.199"></a><h3>log-default-handler</h3>
  6053. <div class="informalexample"><pre class="programlisting">(define-values
  6054. ()
  6055. (log-default-handler log-domain log-level message unused-data))
  6056. </pre></div>
  6057. <p>The default log handler set up by GLib; <code class="function">g_log_set_default_handler()</code>
  6058. allows to install an alternate default log handler.
  6059. This is used if no log handler has been set for the particular log
  6060. domain and log level combination. It outputs the message to stderr
  6061. or stdout and if the log level is fatal it calls <code class="function">G_BREAKPOINT()</code>. It automatically
  6062. prints a new-line character after the message, so one does not need to be
  6063. manually included in <em class="parameter"><code>message</code></em>.
  6064. </p>
  6065. <p>The behavior of this log handler can be influenced by a number of
  6066. environment variables:
  6067. </p>
  6068. <p>- <code class="code">G_MESSAGES_PREFIXED</code>: A :-separated list of log levels for which
  6069. messages should be prefixed by the program name and PID of the
  6070. application.
  6071. </p>
  6072. <p>- <code class="code">G_MESSAGES_DEBUG</code>: A space-separated list of log domains for
  6073. which debug and informational messages are printed. By default
  6074. these messages are not printed.
  6075. </p>
  6076. <p>stderr is used for levels <code class="constant">G_LOG_LEVEL_ERROR</code>, <code class="constant">G_LOG_LEVEL_CRITICAL</code>,
  6077. <code class="constant">G_LOG_LEVEL_WARNING</code> and <code class="constant">G_LOG_LEVEL_MESSAGE</code>. stdout is used for
  6078. the rest.
  6079. </p>
  6080. <p>This has no effect if structured logging is enabled; see
  6081. [Using Structured Logging][using-structured-logging].</p>
  6082. <div class="refsect3">
  6083. <a name="id-1.1.90.2.199.9"></a><h4>Parameters</h4>
  6084. <div class="informaltable"><table>
  6085. <tr>
  6086. <td class="parameter_name"><p>log_domain</p></td>
  6087. <td class="parameter_description">
  6088. <p>the log domain of the message, or <code class="constant">NULL</code> for the
  6089. default "" application domain</p>
  6090. <p>Passed as <code class="code">log-domain</code></p>
  6091. </td>
  6092. </tr>
  6093. <tr>
  6094. <td class="parameter_name"><p>log_level</p></td>
  6095. <td class="parameter_description">
  6096. <p>the level of the message</p>
  6097. <p>Passed as <code class="code">log-level</code></p>
  6098. </td>
  6099. </tr>
  6100. <tr>
  6101. <td class="parameter_name"><p>message</p></td>
  6102. <td class="parameter_description">
  6103. <p>the message</p>
  6104. <p>Passed as <code class="code">message</code></p>
  6105. </td>
  6106. </tr>
  6107. <tr>
  6108. <td class="parameter_name"><p>unused_data</p></td>
  6109. <td class="parameter_description">
  6110. <p>data passed from <code class="function">g_log()</code> which is unused</p>
  6111. <p>Passed as <code class="code">unused-data</code></p>
  6112. </td>
  6113. </tr>
  6114. </table></div>
  6115. </div>
  6116. </div>
  6117. <div class="refsect2">
  6118. <a name="id-1.1.90.2.200"></a><h3>log-remove-handler</h3>
  6119. <div class="informalexample"><pre class="programlisting">(define-values () (log-remove-handler log-domain handler-id))
  6120. </pre></div>
  6121. <p>Removes the log handler.
  6122. </p>
  6123. <p>This has no effect if structured logging is enabled; see
  6124. [Using Structured Logging][using-structured-logging].</p>
  6125. <div class="refsect3">
  6126. <a name="id-1.1.90.2.200.5"></a><h4>Parameters</h4>
  6127. <div class="informaltable"><table>
  6128. <tr>
  6129. <td class="parameter_name"><p>log_domain</p></td>
  6130. <td class="parameter_description">
  6131. <p>the log domain</p>
  6132. <p>Passed as <code class="code">log-domain</code></p>
  6133. </td>
  6134. </tr>
  6135. <tr>
  6136. <td class="parameter_name"><p>handler_id</p></td>
  6137. <td class="parameter_description">
  6138. <p>the id of the handler, which was returned
  6139. in <code class="function">g_log_set_handler()</code></p>
  6140. <p>Passed as <code class="code">handler-id</code></p>
  6141. </td>
  6142. </tr>
  6143. </table></div>
  6144. </div>
  6145. </div>
  6146. <div class="refsect2">
  6147. <a name="id-1.1.90.2.201"></a><h3>log-set-always-fatal</h3>
  6148. <div class="informalexample"><pre class="programlisting">(define-values (%return) (log-set-always-fatal fatal-mask))
  6149. </pre></div>
  6150. <p>Sets the message levels which are always fatal, in any log domain.
  6151. When a message with any of these levels is logged the program terminates.
  6152. You can only set the levels defined by GLib to be fatal.
  6153. <code class="constant">G_LOG_LEVEL_ERROR</code> is always fatal.
  6154. </p>
  6155. <p>You can also make some message levels fatal at runtime by setting
  6156. the <code class="code">G_DEBUG</code> environment variable (see
  6157. [Running GLib Applications](glib-running.html)).
  6158. </p>
  6159. <p>Libraries should not call this function, as it affects all messages logged
  6160. by a process, including those from other libraries.
  6161. </p>
  6162. <p>Structured log messages (using <code class="function">g_log_structured()</code> and
  6163. <code class="function">g_log_structured_array()</code>) are fatal only if the default log writer is used;
  6164. otherwise it is up to the writer function to determine which log messages
  6165. are fatal. See [Using Structured Logging][using-structured-logging].</p>
  6166. <div class="refsect3">
  6167. <a name="id-1.1.90.2.201.7"></a><h4>Parameters</h4>
  6168. <div class="informaltable"><table><tr>
  6169. <td class="parameter_name"><p>fatal_mask</p></td>
  6170. <td class="parameter_description">
  6171. <p>the mask containing bits set for each level
  6172. of error which is to be fatal</p>
  6173. <p>Passed as <code class="code">fatal-mask</code></p>
  6174. </td>
  6175. </tr></table></div>
  6176. </div>
  6177. </div>
  6178. <div class="refsect2">
  6179. <a name="id-1.1.90.2.202"></a><h3>log-set-fatal-mask</h3>
  6180. <div class="informalexample"><pre class="programlisting">(define-values (%return) (log-set-fatal-mask log-domain fatal-mask))
  6181. </pre></div>
  6182. <p>Sets the log levels which are fatal in the given domain.
  6183. <code class="constant">G_LOG_LEVEL_ERROR</code> is always fatal.
  6184. </p>
  6185. <p>This has no effect on structured log messages (using <code class="function">g_log_structured()</code> or
  6186. <code class="function">g_log_structured_array()</code>). To change the fatal behaviour for specific log
  6187. messages, programs must install a custom log writer function using
  6188. <code class="function">g_log_set_writer_func()</code>. See
  6189. [Using Structured Logging][using-structured-logging].
  6190. </p>
  6191. <p>This function is mostly intended to be used with
  6192. <code class="constant">G_LOG_LEVEL_CRITICAL</code>. You should typically not set
  6193. <code class="constant">G_LOG_LEVEL_WARNING</code>, <code class="constant">G_LOG_LEVEL_MESSAGE</code>, <code class="constant">G_LOG_LEVEL_INFO</code> or
  6194. <code class="constant">G_LOG_LEVEL_DEBUG</code> as fatal except inside of test programs.</p>
  6195. <div class="refsect3">
  6196. <a name="id-1.1.90.2.202.6"></a><h4>Parameters</h4>
  6197. <div class="informaltable"><table>
  6198. <tr>
  6199. <td class="parameter_name"><p>log_domain</p></td>
  6200. <td class="parameter_description">
  6201. <p>the log domain</p>
  6202. <p>Passed as <code class="code">log-domain</code></p>
  6203. </td>
  6204. </tr>
  6205. <tr>
  6206. <td class="parameter_name"><p>fatal_mask</p></td>
  6207. <td class="parameter_description">
  6208. <p>the new fatal mask</p>
  6209. <p>Passed as <code class="code">fatal-mask</code></p>
  6210. </td>
  6211. </tr>
  6212. </table></div>
  6213. </div>
  6214. </div>
  6215. <div class="refsect2">
  6216. <a name="id-1.1.90.2.203"></a><h3>log-set-handler</h3>
  6217. <div class="informalexample"><pre class="programlisting">(define-values
  6218. (%return)
  6219. (log-set-handler log-domain log-levels log-func user-data destroy))
  6220. </pre></div>
  6221. <p>Sets the log handler for a domain and a set of log levels.
  6222. To handle fatal and recursive messages the <em class="parameter"><code>log_levels</code></em> parameter
  6223. must be combined with the <span class="type">G_LOG_FLAG_FATAL</span> and <span class="type">G_LOG_FLAG_RECURSION</span>
  6224. bit flags.
  6225. </p>
  6226. <p>Note that since the <span class="type">G_LOG_LEVEL_ERROR</span> log level is always fatal, if
  6227. you want to set a handler for this log level you must combine it with
  6228. <span class="type">G_LOG_FLAG_FATAL</span>.
  6229. </p>
  6230. <p>This has no effect if structured logging is enabled; see
  6231. [Using Structured Logging][using-structured-logging].
  6232. </p>
  6233. <p>Here is an example for adding a log handler for all warning messages
  6234. in the default domain:
  6235. </p>
  6236. <div class="informalexample"><pre class="programlisting">
  6237. g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
  6238. | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
  6239. </pre></div>
  6240. <p>This example adds a log handler for all critical messages from GTK+:
  6241. </p>
  6242. <div class="informalexample"><pre class="programlisting">
  6243. g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
  6244. | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
  6245. </pre></div>
  6246. <p>This example adds a log handler for all messages from GLib:
  6247. </p>
  6248. <div class="informalexample"><pre class="programlisting">
  6249. g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
  6250. | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
  6251. </pre></div>
  6252. <div class="refsect3">
  6253. <a name="id-1.1.90.2.203.9"></a><h4>Parameters</h4>
  6254. <div class="informaltable"><table>
  6255. <tr>
  6256. <td class="parameter_name"><p>destroy</p></td>
  6257. <td class="parameter_description">
  6258. <p></p>
  6259. <p>Passed as <code class="code">destroy</code></p>
  6260. </td>
  6261. </tr>
  6262. <tr>
  6263. <td class="parameter_name"><p>log_domain</p></td>
  6264. <td class="parameter_description">
  6265. <p>the log domain, or <code class="constant">NULL</code> for the default ""
  6266. application domain</p>
  6267. <p>Passed as <code class="code">log-domain</code></p>
  6268. </td>
  6269. </tr>
  6270. <tr>
  6271. <td class="parameter_name"><p>log_levels</p></td>
  6272. <td class="parameter_description">
  6273. <p>the log levels to apply the log handler for.
  6274. To handle fatal and recursive messages as well, combine
  6275. the log levels with the <span class="type">G_LOG_FLAG_FATAL</span> and
  6276. <span class="type">G_LOG_FLAG_RECURSION</span> bit flags.</p>
  6277. <p>Passed as <code class="code">log-levels</code></p>
  6278. </td>
  6279. </tr>
  6280. <tr>
  6281. <td class="parameter_name"><p>log_func</p></td>
  6282. <td class="parameter_description">
  6283. <p>the log handler function</p>
  6284. <p>Passed as <code class="code">log-func</code></p>
  6285. </td>
  6286. </tr>
  6287. <tr>
  6288. <td class="parameter_name"><p>user_data</p></td>
  6289. <td class="parameter_description">
  6290. <p>data passed to the log handler</p>
  6291. <p>Passed as <code class="code">user-data</code></p>
  6292. </td>
  6293. </tr>
  6294. </table></div>
  6295. </div>
  6296. </div>
  6297. <div class="refsect2">
  6298. <a name="id-1.1.90.2.204"></a><h3>log-variant</h3>
  6299. <div class="informalexample"><pre class="programlisting">(define-values () (log-variant log-domain log-level fields))
  6300. </pre></div>
  6301. <p>Log a message with structured data, accepting the data within a <span class="type">GVariant</span>. This
  6302. version is especially useful for use in other languages, via introspection.
  6303. </p>
  6304. <p>The only mandatory item in the <em class="parameter"><code>fields</code></em> dictionary is the "MESSAGE" which must
  6305. contain the text shown to the user.
  6306. </p>
  6307. <p>The values in the <em class="parameter"><code>fields</code></em> dictionary are likely to be of type String
  6308. (<span class="type">G_VARIANT_TYPE_STRING</span>). Array of bytes (<span class="type">G_VARIANT_TYPE_BYTESTRING</span>) is also
  6309. supported. In this case the message is handled as binary and will be forwarded
  6310. to the log writer as such. The size of the array should not be higher than
  6311. <code class="constant">G_MAXSSIZE</code>. Otherwise it will be truncated to this size. For other types
  6312. <code class="function">g_variant_print()</code> will be used to convert the value into a string.
  6313. </p>
  6314. <p>For more details on its usage and about the parameters, see <code class="function">g_log_structured()</code>.</p>
  6315. <div class="refsect3">
  6316. <a name="id-1.1.90.2.204.7"></a><h4>Parameters</h4>
  6317. <div class="informaltable"><table>
  6318. <tr>
  6319. <td class="parameter_name"><p>log_domain</p></td>
  6320. <td class="parameter_description">
  6321. <p>log domain, usually <code class="constant">G_LOG_DOMAIN</code></p>
  6322. <p>Passed as <code class="code">log-domain</code></p>
  6323. </td>
  6324. </tr>
  6325. <tr>
  6326. <td class="parameter_name"><p>log_level</p></td>
  6327. <td class="parameter_description">
  6328. <p>log level, either from <span class="type">GLogLevelFlags</span>, or a user-defined
  6329. level</p>
  6330. <p>Passed as <code class="code">log-level</code></p>
  6331. </td>
  6332. </tr>
  6333. <tr>
  6334. <td class="parameter_name"><p>fields</p></td>
  6335. <td class="parameter_description">
  6336. <p>a dictionary (<span class="type">GVariant</span> of the type <code class="constant">G_VARIANT_TYPE_VARDICT</code>)
  6337. containing the key-value pairs of message data.</p>
  6338. <p>Passed as <code class="code">fields</code></p>
  6339. </td>
  6340. </tr>
  6341. </table></div>
  6342. </div>
  6343. </div>
  6344. <div class="refsect2">
  6345. <a name="id-1.1.90.2.205"></a><h3>log-writer-default-set-use-stderr</h3>
  6346. <div class="informalexample"><pre class="programlisting">(define-values () (log-writer-default-set-use-stderr use-stderr))
  6347. </pre></div>
  6348. <p>Undocumented</p>
  6349. <div class="refsect3">
  6350. <a name="id-1.1.90.2.205.4"></a><h4>Parameters</h4>
  6351. <div class="informaltable"><table><tr>
  6352. <td class="parameter_name"><p>use_stderr</p></td>
  6353. <td class="parameter_description">
  6354. <p></p>
  6355. <p>Passed as <code class="code">use-stderr</code></p>
  6356. </td>
  6357. </tr></table></div>
  6358. </div>
  6359. </div>
  6360. <div class="refsect2">
  6361. <a name="id-1.1.90.2.206"></a><h3>log-writer-default-would-drop?</h3>
  6362. <div class="informalexample"><pre class="programlisting">(define-values
  6363. (%return)
  6364. (log-writer-default-would-drop? log-level log-domain))
  6365. </pre></div>
  6366. <p>Undocumented</p>
  6367. <div class="refsect3">
  6368. <a name="id-1.1.90.2.206.4"></a><h4>Parameters</h4>
  6369. <div class="informaltable"><table>
  6370. <tr>
  6371. <td class="parameter_name"><p>log_level</p></td>
  6372. <td class="parameter_description">
  6373. <p></p>
  6374. <p>Passed as <code class="code">log-level</code></p>
  6375. </td>
  6376. </tr>
  6377. <tr>
  6378. <td class="parameter_name"><p>log_domain</p></td>
  6379. <td class="parameter_description">
  6380. <p></p>
  6381. <p>Passed as <code class="code">log-domain</code></p>
  6382. </td>
  6383. </tr>
  6384. </table></div>
  6385. </div>
  6386. </div>
  6387. <div class="refsect2">
  6388. <a name="id-1.1.90.2.207"></a><h3>log-writer-is-journald?</h3>
  6389. <div class="informalexample"><pre class="programlisting">(define-values (%return) (log-writer-is-journald? output-fd))
  6390. </pre></div>
  6391. <p>Check whether the given <em class="parameter"><code>output_fd</code></em> file descriptor is a connection to the
  6392. systemd journal, or something else (like a log file or <code class="code">stdout</code> or
  6393. <code class="code">stderr</code>).
  6394. </p>
  6395. <p>Invalid file descriptors are accepted and return <code class="constant">FALSE</code>, which allows for
  6396. the following construct without needing any additional error handling:
  6397. </p>
  6398. <div class="informalexample"><pre class="programlisting">
  6399. is_journald = g_log_writer_is_journald (fileno (stderr));
  6400. </pre></div>
  6401. <div class="refsect3">
  6402. <a name="id-1.1.90.2.207.5"></a><h4>Parameters</h4>
  6403. <div class="informaltable"><table><tr>
  6404. <td class="parameter_name"><p>output_fd</p></td>
  6405. <td class="parameter_description">
  6406. <p>output file descriptor to check</p>
  6407. <p>Passed as <code class="code">output-fd</code></p>
  6408. </td>
  6409. </tr></table></div>
  6410. </div>
  6411. </div>
  6412. <div class="refsect2">
  6413. <a name="id-1.1.90.2.208"></a><h3>log-writer-supports-color?</h3>
  6414. <div class="informalexample"><pre class="programlisting">(define-values (%return) (log-writer-supports-color? output-fd))
  6415. </pre></div>
  6416. <p>Check whether the given <em class="parameter"><code>output_fd</code></em> file descriptor supports ANSI color
  6417. escape sequences. If so, they can safely be used when formatting log
  6418. messages.</p>
  6419. <div class="refsect3">
  6420. <a name="id-1.1.90.2.208.4"></a><h4>Parameters</h4>
  6421. <div class="informaltable"><table><tr>
  6422. <td class="parameter_name"><p>output_fd</p></td>
  6423. <td class="parameter_description">
  6424. <p>output file descriptor to check</p>
  6425. <p>Passed as <code class="code">output-fd</code></p>
  6426. </td>
  6427. </tr></table></div>
  6428. </div>
  6429. </div>
  6430. <div class="refsect2">
  6431. <a name="id-1.1.90.2.209"></a><h3>main-context-default</h3>
  6432. <div class="informalexample"><pre class="programlisting">(define-values (%return) (main-context-default))
  6433. </pre></div>
  6434. <p>Returns the global default main context. This is the main context
  6435. used for main loop functions when a main loop is not explicitly
  6436. specified, and corresponds to the "main" main loop. See also
  6437. <code class="function">g_main_context_get_thread_default()</code>.</p>
  6438. </div>
  6439. <div class="refsect2">
  6440. <a name="id-1.1.90.2.210"></a><h3>main-context-get-thread-default</h3>
  6441. <div class="informalexample"><pre class="programlisting">(define-values (%return) (main-context-get-thread-default))
  6442. </pre></div>
  6443. <p>Gets the thread-default <span class="type">GMainContext</span> for this thread. Asynchronous
  6444. operations that want to be able to be run in contexts other than
  6445. the default one should call this method or
  6446. <code class="function">g_main_context_ref_thread_default()</code> to get a <span class="type">GMainContext</span> to add
  6447. their <span class="type">GSources</span> to. (Note that even in single-threaded
  6448. programs applications may sometimes want to temporarily push a
  6449. non-default context, so it is not safe to assume that this will
  6450. always return <code class="constant">NULL</code> if you are running in the default thread.)
  6451. </p>
  6452. <p>If you need to hold a reference on the context, use
  6453. <code class="function">g_main_context_ref_thread_default()</code> instead.</p>
  6454. </div>
  6455. <div class="refsect2">
  6456. <a name="id-1.1.90.2.211"></a><h3>main-context-ref-thread-default</h3>
  6457. <div class="informalexample"><pre class="programlisting">(define-values (%return) (main-context-ref-thread-default))
  6458. </pre></div>
  6459. <p>Gets the thread-default <span class="type">GMainContext</span> for this thread, as with
  6460. <code class="function">g_main_context_get_thread_default()</code>, but also adds a reference to
  6461. it with <code class="function">g_main_context_ref()</code>. In addition, unlike
  6462. <code class="function">g_main_context_get_thread_default()</code>, if the thread-default context
  6463. is the global default context, this will return that <span class="type">GMainContext</span>
  6464. (with a ref added to it) rather than returning <code class="constant">NULL</code>.</p>
  6465. </div>
  6466. <div class="refsect2">
  6467. <a name="id-1.1.90.2.212"></a><h3>main-current-source</h3>
  6468. <div class="informalexample"><pre class="programlisting">(define-values (%return) (main-current-source))
  6469. </pre></div>
  6470. <p>Returns the currently firing source for this thread.</p>
  6471. </div>
  6472. <div class="refsect2">
  6473. <a name="id-1.1.90.2.213"></a><h3>main-depth</h3>
  6474. <div class="informalexample"><pre class="programlisting">(define-values (%return) (main-depth))
  6475. </pre></div>
  6476. <p>Returns the depth of the stack of calls to
  6477. <code class="function">g_main_context_dispatch()</code> on any <span class="type">GMainContext</span> in the current thread.
  6478. That is, when called from the toplevel, it gives 0. When
  6479. called from within a callback from <code class="function">g_main_context_iteration()</code>
  6480. (or <code class="function">g_main_loop_run()</code>, etc.) it returns 1. When called from within
  6481. a callback to a recursive call to <code class="function">g_main_context_iteration()</code>,
  6482. it returns 2. And so forth.
  6483. </p>
  6484. <p>This function is useful in a situation like the following:
  6485. Imagine an extremely simple "garbage collected" system.
  6486. </p>
  6487. <div class="informalexample"><pre class="programlisting">
  6488. static GList *free_list;
  6489. gpointer
  6490. allocate_memory (gsize size)
  6491. {
  6492. gpointer result = g_malloc (size);
  6493. free_list = g_list_prepend (free_list, result);
  6494. return result;
  6495. }
  6496. void
  6497. free_allocated_memory (void)
  6498. {
  6499. GList *l;
  6500. for (l = free_list; l; l = l-&gt;next);
  6501. g_free (l-&gt;data);
  6502. g_list_free (free_list);
  6503. free_list = NULL;
  6504. }
  6505. [...]
  6506. while (TRUE);
  6507. {
  6508. g_main_context_iteration (NULL, TRUE);
  6509. free_allocated_memory();
  6510. }
  6511. </pre></div>
  6512. <p>This works from an application, however, if you want to do the same
  6513. thing from a library, it gets more difficult, since you no longer
  6514. control the main loop. You might think you can simply use an idle
  6515. function to make the call to <code class="function">free_allocated_memory()</code>, but that
  6516. doesn't work, since the idle function could be called from a
  6517. recursive callback. This can be fixed by using <code class="function">g_main_depth()</code>
  6518. </p>
  6519. <div class="informalexample"><pre class="programlisting">
  6520. gpointer
  6521. allocate_memory (gsize size)
  6522. {
  6523. FreeListBlock *block = g_new (FreeListBlock, 1);
  6524. block-&gt;mem = g_malloc (size);
  6525. block-&gt;depth = g_main_depth ();
  6526. free_list = g_list_prepend (free_list, block);
  6527. return block-&gt;mem;
  6528. }
  6529. void
  6530. free_allocated_memory (void)
  6531. {
  6532. GList *l;
  6533. int depth = g_main_depth ();
  6534. for (l = free_list; l; );
  6535. {
  6536. GList *next = l-&gt;next;
  6537. FreeListBlock *block = l-&gt;data;
  6538. if (block-&gt;depth &gt; depth)
  6539. {
  6540. g_free (block-&gt;mem);
  6541. g_free (block);
  6542. free_list = g_list_delete_link (free_list, l);
  6543. }
  6544. l = next;
  6545. }
  6546. }
  6547. </pre></div>
  6548. <p>There is a temptation to use <code class="function">g_main_depth()</code> to solve
  6549. problems with reentrancy. For instance, while waiting for data
  6550. to be received from the network in response to a menu item,
  6551. the menu item might be selected again. It might seem that
  6552. one could make the menu item's callback return immediately
  6553. and do nothing if <code class="function">g_main_depth()</code> returns a value greater than 1.
  6554. However, this should be avoided since the user then sees selecting
  6555. the menu item do nothing. Furthermore, you'll find yourself adding
  6556. these checks all over your code, since there are doubtless many,
  6557. many things that the user could do. Instead, you can use the
  6558. following techniques:
  6559. </p>
  6560. <p>1. Use <code class="function">gtk_widget_set_sensitive()</code> or modal dialogs to prevent
  6561. the user from interacting with elements while the main
  6562. loop is recursing.
  6563. </p>
  6564. <p>2. Avoid main loop recursion in situations where you can't handle
  6565. arbitrary callbacks. Instead, structure your code so that you
  6566. simply return to the main loop and then get called again when
  6567. there is more work to do.</p>
  6568. </div>
  6569. <div class="refsect2">
  6570. <a name="id-1.1.90.2.214"></a><h3>malloc</h3>
  6571. <div class="informalexample"><pre class="programlisting">(define-values (%return) (malloc n-bytes))
  6572. </pre></div>
  6573. <p>Allocates <em class="parameter"><code>n_bytes</code></em> bytes of memory.
  6574. If <em class="parameter"><code>n_bytes</code></em> is 0 it returns <code class="constant">NULL</code>.</p>
  6575. <div class="refsect3">
  6576. <a name="id-1.1.90.2.214.4"></a><h4>Parameters</h4>
  6577. <div class="informaltable"><table><tr>
  6578. <td class="parameter_name"><p>n_bytes</p></td>
  6579. <td class="parameter_description">
  6580. <p>the number of bytes to allocate</p>
  6581. <p>Passed as <code class="code">n-bytes</code></p>
  6582. </td>
  6583. </tr></table></div>
  6584. </div>
  6585. </div>
  6586. <div class="refsect2">
  6587. <a name="id-1.1.90.2.215"></a><h3>malloc0</h3>
  6588. <div class="informalexample"><pre class="programlisting">(define-values (%return) (malloc0 n-bytes))
  6589. </pre></div>
  6590. <p>Allocates <em class="parameter"><code>n_bytes</code></em> bytes of memory, initialized to 0's.
  6591. If <em class="parameter"><code>n_bytes</code></em> is 0 it returns <code class="constant">NULL</code>.</p>
  6592. <div class="refsect3">
  6593. <a name="id-1.1.90.2.215.4"></a><h4>Parameters</h4>
  6594. <div class="informaltable"><table><tr>
  6595. <td class="parameter_name"><p>n_bytes</p></td>
  6596. <td class="parameter_description">
  6597. <p>the number of bytes to allocate</p>
  6598. <p>Passed as <code class="code">n-bytes</code></p>
  6599. </td>
  6600. </tr></table></div>
  6601. </div>
  6602. </div>
  6603. <div class="refsect2">
  6604. <a name="id-1.1.90.2.216"></a><h3>malloc0-n</h3>
  6605. <div class="informalexample"><pre class="programlisting">(define-values (%return) (malloc0-n n-blocks n-block-bytes))
  6606. </pre></div>
  6607. <p>This function is similar to <code class="function">g_malloc0()</code>, allocating (<em class="parameter"><code>n_blocks</code></em> * <em class="parameter"><code>n_block_bytes</code></em>) bytes,
  6608. but care is taken to detect possible overflow during multiplication.</p>
  6609. <div class="refsect3">
  6610. <a name="id-1.1.90.2.216.4"></a><h4>Parameters</h4>
  6611. <div class="informaltable"><table>
  6612. <tr>
  6613. <td class="parameter_name"><p>n_blocks</p></td>
  6614. <td class="parameter_description">
  6615. <p>the number of blocks to allocate</p>
  6616. <p>Passed as <code class="code">n-blocks</code></p>
  6617. </td>
  6618. </tr>
  6619. <tr>
  6620. <td class="parameter_name"><p>n_block_bytes</p></td>
  6621. <td class="parameter_description">
  6622. <p>the size of each block in bytes</p>
  6623. <p>Passed as <code class="code">n-block-bytes</code></p>
  6624. </td>
  6625. </tr>
  6626. </table></div>
  6627. </div>
  6628. </div>
  6629. <div class="refsect2">
  6630. <a name="id-1.1.90.2.217"></a><h3>malloc-n</h3>
  6631. <div class="informalexample"><pre class="programlisting">(define-values (%return) (malloc-n n-blocks n-block-bytes))
  6632. </pre></div>
  6633. <p>This function is similar to <code class="function">g_malloc()</code>, allocating (<em class="parameter"><code>n_blocks</code></em> * <em class="parameter"><code>n_block_bytes</code></em>) bytes,
  6634. but care is taken to detect possible overflow during multiplication.</p>
  6635. <div class="refsect3">
  6636. <a name="id-1.1.90.2.217.4"></a><h4>Parameters</h4>
  6637. <div class="informaltable"><table>
  6638. <tr>
  6639. <td class="parameter_name"><p>n_blocks</p></td>
  6640. <td class="parameter_description">
  6641. <p>the number of blocks to allocate</p>
  6642. <p>Passed as <code class="code">n-blocks</code></p>
  6643. </td>
  6644. </tr>
  6645. <tr>
  6646. <td class="parameter_name"><p>n_block_bytes</p></td>
  6647. <td class="parameter_description">
  6648. <p>the size of each block in bytes</p>
  6649. <p>Passed as <code class="code">n-block-bytes</code></p>
  6650. </td>
  6651. </tr>
  6652. </table></div>
  6653. </div>
  6654. </div>
  6655. <div class="refsect2">
  6656. <a name="id-1.1.90.2.218"></a><h3>markup-error-quark</h3>
  6657. <div class="informalexample"><pre class="programlisting">(define-values (%return) (markup-error-quark))
  6658. </pre></div>
  6659. <p>Undocumented</p>
  6660. </div>
  6661. <div class="refsect2">
  6662. <a name="id-1.1.90.2.219"></a><h3>markup-escape-text</h3>
  6663. <div class="informalexample"><pre class="programlisting">(define-values (%return) (markup-escape-text text length))
  6664. </pre></div>
  6665. <p>Escapes text so that the markup parser will parse it verbatim.
  6666. Less than, greater than, ampersand, etc. are replaced with the
  6667. corresponding entities. This function would typically be used
  6668. when writing out a file to be parsed with the markup parser.
  6669. </p>
  6670. <p>Note that this function doesn't protect whitespace and line endings
  6671. from being processed according to the XML rules for normalization
  6672. of line endings and attribute values.
  6673. </p>
  6674. <p>Note also that this function will produce character references in
  6675. the range of &amp;#x1; ... &amp;#x1f; for all control sequences
  6676. except for tabstop, newline and carriage return. The character
  6677. references in this range are not valid XML 1.0, but they are
  6678. valid XML 1.1 and will be accepted by the GMarkup parser.</p>
  6679. <div class="refsect3">
  6680. <a name="id-1.1.90.2.219.6"></a><h4>Parameters</h4>
  6681. <div class="informaltable"><table>
  6682. <tr>
  6683. <td class="parameter_name"><p>text</p></td>
  6684. <td class="parameter_description">
  6685. <p>some valid UTF-8 text</p>
  6686. <p>Passed as <code class="code">text</code></p>
  6687. </td>
  6688. </tr>
  6689. <tr>
  6690. <td class="parameter_name"><p>length</p></td>
  6691. <td class="parameter_description">
  6692. <p>length of <em class="parameter"><code>text</code></em> in bytes, or -1 if the text is nul-terminated</p>
  6693. <p>Passed as <code class="code">length</code></p>
  6694. </td>
  6695. </tr>
  6696. </table></div>
  6697. </div>
  6698. </div>
  6699. <div class="refsect2">
  6700. <a name="id-1.1.90.2.220"></a><h3>memdup</h3>
  6701. <div class="informalexample"><pre class="programlisting">(define-values (%return) (memdup mem byte-size))
  6702. </pre></div>
  6703. <p>Allocates <em class="parameter"><code>byte_size</code></em> bytes of memory, and copies <em class="parameter"><code>byte_size</code></em> bytes into it
  6704. from <em class="parameter"><code>mem</code></em>. If <em class="parameter"><code>mem</code></em> is <code class="constant">NULL</code> it returns <code class="constant">NULL</code>.</p>
  6705. <div class="refsect3">
  6706. <a name="id-1.1.90.2.220.4"></a><h4>Parameters</h4>
  6707. <div class="informaltable"><table>
  6708. <tr>
  6709. <td class="parameter_name"><p>mem</p></td>
  6710. <td class="parameter_description">
  6711. <p>the memory to copy.</p>
  6712. <p>Passed as <code class="code">mem</code></p>
  6713. </td>
  6714. </tr>
  6715. <tr>
  6716. <td class="parameter_name"><p>byte_size</p></td>
  6717. <td class="parameter_description">
  6718. <p>the number of bytes to copy.</p>
  6719. <p>Passed as <code class="code">byte-size</code></p>
  6720. </td>
  6721. </tr>
  6722. </table></div>
  6723. </div>
  6724. </div>
  6725. <div class="refsect2">
  6726. <a name="id-1.1.90.2.221"></a><h3>memdup2</h3>
  6727. <div class="informalexample"><pre class="programlisting">(define-values (%return) (memdup2 mem byte-size))
  6728. </pre></div>
  6729. <p>Undocumented</p>
  6730. <div class="refsect3">
  6731. <a name="id-1.1.90.2.221.4"></a><h4>Parameters</h4>
  6732. <div class="informaltable"><table>
  6733. <tr>
  6734. <td class="parameter_name"><p>mem</p></td>
  6735. <td class="parameter_description">
  6736. <p></p>
  6737. <p>Passed as <code class="code">mem</code></p>
  6738. </td>
  6739. </tr>
  6740. <tr>
  6741. <td class="parameter_name"><p>byte_size</p></td>
  6742. <td class="parameter_description">
  6743. <p></p>
  6744. <p>Passed as <code class="code">byte-size</code></p>
  6745. </td>
  6746. </tr>
  6747. </table></div>
  6748. </div>
  6749. </div>
  6750. <div class="refsect2">
  6751. <a name="id-1.1.90.2.222"></a><h3>mkdir-with-parents</h3>
  6752. <div class="informalexample"><pre class="programlisting">(define-values (%return) (mkdir-with-parents pathname mode))
  6753. </pre></div>
  6754. <p>Create a directory if it doesn't already exist. Create intermediate
  6755. parent directories as needed, too.</p>
  6756. <div class="refsect3">
  6757. <a name="id-1.1.90.2.222.4"></a><h4>Parameters</h4>
  6758. <div class="informaltable"><table>
  6759. <tr>
  6760. <td class="parameter_name"><p>pathname</p></td>
  6761. <td class="parameter_description">
  6762. <p>a pathname in the GLib file name encoding</p>
  6763. <p>Passed as <code class="code">pathname</code></p>
  6764. </td>
  6765. </tr>
  6766. <tr>
  6767. <td class="parameter_name"><p>mode</p></td>
  6768. <td class="parameter_description">
  6769. <p>permissions to use for newly created directories</p>
  6770. <p>Passed as <code class="code">mode</code></p>
  6771. </td>
  6772. </tr>
  6773. </table></div>
  6774. </div>
  6775. </div>
  6776. <div class="refsect2">
  6777. <a name="id-1.1.90.2.223"></a><h3>nullify-pointer</h3>
  6778. <div class="informalexample"><pre class="programlisting">(define-values () (nullify-pointer nullify-location))
  6779. </pre></div>
  6780. <p>Set the pointer at the specified location to <code class="constant">NULL</code>.</p>
  6781. <div class="refsect3">
  6782. <a name="id-1.1.90.2.223.4"></a><h4>Parameters</h4>
  6783. <div class="informaltable"><table><tr>
  6784. <td class="parameter_name"><p>nullify_location</p></td>
  6785. <td class="parameter_description">
  6786. <p>the memory address of the pointer.</p>
  6787. <p>Passed as <code class="code">nullify-location</code></p>
  6788. </td>
  6789. </tr></table></div>
  6790. </div>
  6791. </div>
  6792. <div class="refsect2">
  6793. <a name="id-1.1.90.2.224"></a><h3>number-parser-error-quark</h3>
  6794. <div class="informalexample"><pre class="programlisting">(define-values (%return) (number-parser-error-quark))
  6795. </pre></div>
  6796. <p>Undocumented</p>
  6797. </div>
  6798. <div class="refsect2">
  6799. <a name="id-1.1.90.2.225"></a><h3>on-error-query</h3>
  6800. <div class="informalexample"><pre class="programlisting">(define-values () (on-error-query prg-name))
  6801. </pre></div>
  6802. <p>Prompts the user with
  6803. <code class="code">[E]xit, [H]alt, show [S]tack trace or [P]roceed</code>.
  6804. This function is intended to be used for debugging use only.
  6805. The following example shows how it can be used together with
  6806. the <code class="function">g_log()</code> functions.
  6807. </p>
  6808. <div class="informalexample"><pre class="programlisting">
  6809. #include &lt;glib.h&gt;
  6810. static void
  6811. log_handler (const gchar *log_domain,
  6812. GLogLevelFlags log_level,
  6813. const gchar *message,
  6814. gpointer user_data)
  6815. {
  6816. g_log_default_handler (log_domain, log_level, message, user_data);
  6817. g_on_error_query (MY_PROGRAM_NAME);
  6818. }
  6819. int
  6820. main (int argc, char *argv[])
  6821. {
  6822. g_log_set_handler (MY_LOG_DOMAIN,
  6823. G_LOG_LEVEL_WARNING |
  6824. G_LOG_LEVEL_ERROR |
  6825. G_LOG_LEVEL_CRITICAL,
  6826. log_handler,
  6827. NULL);
  6828. ...
  6829. </pre></div>
  6830. <p>If "[E]xit" is selected, the application terminates with a call
  6831. to _exit(0).
  6832. </p>
  6833. <p>If "[S]tack" trace is selected, <code class="function">g_on_error_stack_trace()</code> is called.
  6834. This invokes gdb, which attaches to the current process and shows
  6835. a stack trace. The prompt is then shown again.
  6836. </p>
  6837. <p>If "[P]roceed" is selected, the function returns.
  6838. </p>
  6839. <p>This function may cause different actions on non-UNIX platforms.
  6840. </p>
  6841. <p>On Windows consider using the <code class="code">G_DEBUGGER</code> environment
  6842. variable (see [Running GLib Applications](glib-running.html)) and
  6843. calling <code class="function">g_on_error_stack_trace()</code> instead.</p>
  6844. <div class="refsect3">
  6845. <a name="id-1.1.90.2.225.10"></a><h4>Parameters</h4>
  6846. <div class="informaltable"><table><tr>
  6847. <td class="parameter_name"><p>prg_name</p></td>
  6848. <td class="parameter_description">
  6849. <p>the program name, needed by gdb for the "[S]tack trace"
  6850. option. If <em class="parameter"><code>prg_name</code></em> is <code class="constant">NULL</code>, <code class="function">g_get_prgname()</code> is called to get
  6851. the program name (which will work correctly if <code class="function">gdk_init()</code> or
  6852. <code class="function">gtk_init()</code> has been called)</p>
  6853. <p>Passed as <code class="code">prg-name</code></p>
  6854. </td>
  6855. </tr></table></div>
  6856. </div>
  6857. </div>
  6858. <div class="refsect2">
  6859. <a name="id-1.1.90.2.226"></a><h3>on-error-stack-trace</h3>
  6860. <div class="informalexample"><pre class="programlisting">(define-values () (on-error-stack-trace prg-name))
  6861. </pre></div>
  6862. <p>Invokes gdb, which attaches to the current process and shows a
  6863. stack trace. Called by <code class="function">g_on_error_query()</code> when the "[S]tack trace"
  6864. option is selected. You can get the current process's program name
  6865. with <code class="function">g_get_prgname()</code>, assuming that you have called <code class="function">gtk_init()</code> or
  6866. <code class="function">gdk_init()</code>.
  6867. </p>
  6868. <p>This function may cause different actions on non-UNIX platforms.
  6869. </p>
  6870. <p>When running on Windows, this function is *not* called by
  6871. <code class="function">g_on_error_query()</code>. If called directly, it will raise an
  6872. exception, which will crash the program. If the <code class="code">G_DEBUGGER</code> environment
  6873. variable is set, a debugger will be invoked to attach and
  6874. handle that exception (see [Running GLib Applications](glib-running.html)).</p>
  6875. <div class="refsect3">
  6876. <a name="id-1.1.90.2.226.6"></a><h4>Parameters</h4>
  6877. <div class="informaltable"><table><tr>
  6878. <td class="parameter_name"><p>prg_name</p></td>
  6879. <td class="parameter_description">
  6880. <p>the program name, needed by gdb for the "[S]tack trace"
  6881. option</p>
  6882. <p>Passed as <code class="code">prg-name</code></p>
  6883. </td>
  6884. </tr></table></div>
  6885. </div>
  6886. </div>
  6887. <div class="refsect2">
  6888. <a name="id-1.1.90.2.227"></a><h3>once-init-enter?</h3>
  6889. <div class="informalexample"><pre class="programlisting">(define-values (%return) (once-init-enter? location))
  6890. </pre></div>
  6891. <p>Function to be called when starting a critical initialization
  6892. section. The argument <em class="parameter"><code>location</code></em> must point to a static
  6893. 0-initialized variable that will be set to a value other than 0 at
  6894. the end of the initialization section. In combination with
  6895. <code class="function">g_once_init_leave()</code> and the unique address <em class="parameter"><code>value_location</code></em>, it can
  6896. be ensured that an initialization section will be executed only once
  6897. during a program's life time, and that concurrent threads are
  6898. blocked until initialization completed. To be used in constructs
  6899. like this:
  6900. </p>
  6901. <div class="informalexample"><pre class="programlisting">
  6902. static gsize initialization_value = 0;
  6903. if (g_once_init_enter (&amp;initialization_value))
  6904. {
  6905. gsize setup_value = 42; // initialization code here
  6906. g_once_init_leave (&amp;initialization_value, setup_value);
  6907. }
  6908. // use initialization_value here
  6909. </pre></div>
  6910. <div class="refsect3">
  6911. <a name="id-1.1.90.2.227.5"></a><h4>Parameters</h4>
  6912. <div class="informaltable"><table><tr>
  6913. <td class="parameter_name"><p>location</p></td>
  6914. <td class="parameter_description">
  6915. <p>location of a static initializable variable
  6916. containing 0</p>
  6917. <p>Passed as <code class="code">location</code></p>
  6918. </td>
  6919. </tr></table></div>
  6920. </div>
  6921. </div>
  6922. <div class="refsect2">
  6923. <a name="id-1.1.90.2.228"></a><h3>once-init-leave</h3>
  6924. <div class="informalexample"><pre class="programlisting">(define-values () (once-init-leave location result))
  6925. </pre></div>
  6926. <p>Counterpart to <code class="function">g_once_init_enter()</code>. Expects a location of a static
  6927. 0-initialized initialization variable, and an initialization value
  6928. other than 0. Sets the variable to the initialization value, and
  6929. releases concurrent threads blocking in <code class="function">g_once_init_enter()</code> on this
  6930. initialization variable.</p>
  6931. <div class="refsect3">
  6932. <a name="id-1.1.90.2.228.4"></a><h4>Parameters</h4>
  6933. <div class="informaltable"><table>
  6934. <tr>
  6935. <td class="parameter_name"><p>location</p></td>
  6936. <td class="parameter_description">
  6937. <p>location of a static initializable variable
  6938. containing 0</p>
  6939. <p>Passed as <code class="code">location</code></p>
  6940. </td>
  6941. </tr>
  6942. <tr>
  6943. <td class="parameter_name"><p>result</p></td>
  6944. <td class="parameter_description">
  6945. <p>new non-0 value for *<em class="parameter"><code>value_location</code></em></p>
  6946. <p>Passed as <code class="code">result</code></p>
  6947. </td>
  6948. </tr>
  6949. </table></div>
  6950. </div>
  6951. </div>
  6952. <div class="refsect2">
  6953. <a name="id-1.1.90.2.229"></a><h3>option-error-quark</h3>
  6954. <div class="informalexample"><pre class="programlisting">(define-values (%return) (option-error-quark))
  6955. </pre></div>
  6956. <p>Undocumented</p>
  6957. </div>
  6958. <div class="refsect2">
  6959. <a name="id-1.1.90.2.230"></a><h3>path-get-basename</h3>
  6960. <div class="informalexample"><pre class="programlisting">(define-values (%return) (path-get-basename file-name))
  6961. </pre></div>
  6962. <p>Gets the last component of the filename.
  6963. </p>
  6964. <p>If <em class="parameter"><code>file_name</code></em> ends with a directory separator it gets the component
  6965. before the last slash. If <em class="parameter"><code>file_name</code></em> consists only of directory
  6966. separators (and on Windows, possibly a drive letter), a single
  6967. separator is returned. If <em class="parameter"><code>file_name</code></em> is empty, it gets ".".</p>
  6968. <div class="refsect3">
  6969. <a name="id-1.1.90.2.230.5"></a><h4>Parameters</h4>
  6970. <div class="informaltable"><table><tr>
  6971. <td class="parameter_name"><p>file_name</p></td>
  6972. <td class="parameter_description">
  6973. <p>the name of the file</p>
  6974. <p>Passed as <code class="code">file-name</code></p>
  6975. </td>
  6976. </tr></table></div>
  6977. </div>
  6978. </div>
  6979. <div class="refsect2">
  6980. <a name="id-1.1.90.2.231"></a><h3>path-get-dirname</h3>
  6981. <div class="informalexample"><pre class="programlisting">(define-values (%return) (path-get-dirname file-name))
  6982. </pre></div>
  6983. <p>Gets the directory components of a file name. For example, the directory
  6984. component of <code class="code">/usr/bin/test</code> is <code class="code">/usr/bin</code>. The directory component of <code class="code">/</code>
  6985. is <code class="code">/</code>.
  6986. </p>
  6987. <p>If the file name has no directory components "." is returned.
  6988. The returned string should be freed when no longer needed.</p>
  6989. <div class="refsect3">
  6990. <a name="id-1.1.90.2.231.5"></a><h4>Parameters</h4>
  6991. <div class="informaltable"><table><tr>
  6992. <td class="parameter_name"><p>file_name</p></td>
  6993. <td class="parameter_description">
  6994. <p>the name of the file</p>
  6995. <p>Passed as <code class="code">file-name</code></p>
  6996. </td>
  6997. </tr></table></div>
  6998. </div>
  6999. </div>
  7000. <div class="refsect2">
  7001. <a name="id-1.1.90.2.232"></a><h3>path-is-absolute?</h3>
  7002. <div class="informalexample"><pre class="programlisting">(define-values (%return) (path-is-absolute? file-name))
  7003. </pre></div>
  7004. <p>Returns <code class="constant">TRUE</code> if the given <em class="parameter"><code>file_name</code></em> is an absolute file name.
  7005. Note that this is a somewhat vague concept on Windows.
  7006. </p>
  7007. <p>On POSIX systems, an absolute file name is well-defined. It always
  7008. starts from the single root directory. For example "/usr/local".
  7009. </p>
  7010. <p>On Windows, the concepts of current drive and drive-specific
  7011. current directory introduce vagueness. This function interprets as
  7012. an absolute file name one that either begins with a directory
  7013. separator such as "\Users\tml" or begins with the root on a drive,
  7014. for example "C:\Windows". The first case also includes UNC paths
  7015. such as "\\\\myserver\docs\foo". In all cases, either slashes or
  7016. backslashes are accepted.
  7017. </p>
  7018. <p>Note that a file name relative to the current drive root does not
  7019. truly specify a file uniquely over time and across processes, as
  7020. the current drive is a per-process value and can be changed.
  7021. </p>
  7022. <p>File names relative the current directory on some specific drive,
  7023. such as "D:foo/bar", are not interpreted as absolute by this
  7024. function, but they obviously are not relative to the normal current
  7025. directory as returned by <code class="function">getcwd()</code> or <code class="function">g_get_current_dir()</code>
  7026. either. Such paths should be avoided, or need to be handled using
  7027. Windows-specific code.</p>
  7028. <div class="refsect3">
  7029. <a name="id-1.1.90.2.232.8"></a><h4>Parameters</h4>
  7030. <div class="informaltable"><table><tr>
  7031. <td class="parameter_name"><p>file_name</p></td>
  7032. <td class="parameter_description">
  7033. <p>a file name</p>
  7034. <p>Passed as <code class="code">file-name</code></p>
  7035. </td>
  7036. </tr></table></div>
  7037. </div>
  7038. </div>
  7039. <div class="refsect2">
  7040. <a name="id-1.1.90.2.233"></a><h3>path-skip-root</h3>
  7041. <div class="informalexample"><pre class="programlisting">(define-values (%return) (path-skip-root file-name))
  7042. </pre></div>
  7043. <p>Returns a pointer into <em class="parameter"><code>file_name</code></em> after the root component,
  7044. i.e. after the "/" in UNIX or "C:\" under Windows. If <em class="parameter"><code>file_name</code></em>
  7045. is not an absolute path it returns <code class="constant">NULL</code>.</p>
  7046. <div class="refsect3">
  7047. <a name="id-1.1.90.2.233.4"></a><h4>Parameters</h4>
  7048. <div class="informaltable"><table><tr>
  7049. <td class="parameter_name"><p>file_name</p></td>
  7050. <td class="parameter_description">
  7051. <p>a file name</p>
  7052. <p>Passed as <code class="code">file-name</code></p>
  7053. </td>
  7054. </tr></table></div>
  7055. </div>
  7056. </div>
  7057. <div class="refsect2">
  7058. <a name="id-1.1.90.2.234"></a><h3>pattern-match?</h3>
  7059. <div class="informalexample"><pre class="programlisting">(define-values
  7060. (%return)
  7061. (pattern-match? pspec string-length string string-reversed))
  7062. </pre></div>
  7063. <p>Matches a string against a compiled pattern. Passing the correct
  7064. length of the string given is mandatory. The reversed string can be
  7065. omitted by passing <code class="constant">NULL</code>, this is more efficient if the reversed
  7066. version of the string to be matched is not at hand, as
  7067. <code class="function">g_pattern_match()</code> will only construct it if the compiled pattern
  7068. requires reverse matches.
  7069. </p>
  7070. <p>Note that, if the user code will (possibly) match a string against a
  7071. multitude of patterns containing wildcards, chances are high that
  7072. some patterns will require a reversed string. In this case, it's
  7073. more efficient to provide the reversed string to avoid multiple
  7074. constructions thereof in the various calls to <code class="function">g_pattern_match()</code>.
  7075. </p>
  7076. <p>Note also that the reverse of a UTF-8 encoded string can in general
  7077. not be obtained by <code class="function">g_strreverse()</code>. This works only if the string
  7078. does not contain any multibyte characters. GLib offers the
  7079. <code class="function">g_utf8_strreverse()</code> function to reverse UTF-8 encoded strings.</p>
  7080. <div class="refsect3">
  7081. <a name="id-1.1.90.2.234.6"></a><h4>Parameters</h4>
  7082. <div class="informaltable"><table>
  7083. <tr>
  7084. <td class="parameter_name"><p>pspec</p></td>
  7085. <td class="parameter_description">
  7086. <p>a <span class="type">GPatternSpec</span></p>
  7087. <p>Passed as <code class="code">pspec</code></p>
  7088. </td>
  7089. </tr>
  7090. <tr>
  7091. <td class="parameter_name"><p>string_length</p></td>
  7092. <td class="parameter_description">
  7093. <p>the length of <em class="parameter"><code>string</code></em> (in bytes, i.e. <code class="function">strlen()</code>,
  7094. not <code class="function">g_utf8_strlen()</code>)</p>
  7095. <p>Passed as <code class="code">string-length</code></p>
  7096. </td>
  7097. </tr>
  7098. <tr>
  7099. <td class="parameter_name"><p>string</p></td>
  7100. <td class="parameter_description">
  7101. <p>the UTF-8 encoded string to match</p>
  7102. <p>Passed as <code class="code">string</code></p>
  7103. </td>
  7104. </tr>
  7105. <tr>
  7106. <td class="parameter_name"><p>string_reversed</p></td>
  7107. <td class="parameter_description">
  7108. <p>the reverse of <em class="parameter"><code>string</code></em> or <code class="constant">NULL</code></p>
  7109. <p>Passed as <code class="code">string-reversed</code></p>
  7110. </td>
  7111. </tr>
  7112. </table></div>
  7113. </div>
  7114. </div>
  7115. <div class="refsect2">
  7116. <a name="id-1.1.90.2.235"></a><h3>pattern-match-simple?</h3>
  7117. <div class="informalexample"><pre class="programlisting">(define-values (%return) (pattern-match-simple? pattern string))
  7118. </pre></div>
  7119. <p>Matches a string against a pattern given as a string. If this
  7120. function is to be called in a loop, it's more efficient to compile
  7121. the pattern once with <code class="function">g_pattern_spec_new()</code> and call
  7122. <code class="function">g_pattern_match_string()</code> repeatedly.</p>
  7123. <div class="refsect3">
  7124. <a name="id-1.1.90.2.235.4"></a><h4>Parameters</h4>
  7125. <div class="informaltable"><table>
  7126. <tr>
  7127. <td class="parameter_name"><p>pattern</p></td>
  7128. <td class="parameter_description">
  7129. <p>the UTF-8 encoded pattern</p>
  7130. <p>Passed as <code class="code">pattern</code></p>
  7131. </td>
  7132. </tr>
  7133. <tr>
  7134. <td class="parameter_name"><p>string</p></td>
  7135. <td class="parameter_description">
  7136. <p>the UTF-8 encoded string to match</p>
  7137. <p>Passed as <code class="code">string</code></p>
  7138. </td>
  7139. </tr>
  7140. </table></div>
  7141. </div>
  7142. </div>
  7143. <div class="refsect2">
  7144. <a name="id-1.1.90.2.236"></a><h3>pattern-match-string?</h3>
  7145. <div class="informalexample"><pre class="programlisting">(define-values (%return) (pattern-match-string? pspec string))
  7146. </pre></div>
  7147. <p>Matches a string against a compiled pattern. If the string is to be
  7148. matched against more than one pattern, consider using
  7149. <code class="function">g_pattern_match()</code> instead while supplying the reversed string.</p>
  7150. <div class="refsect3">
  7151. <a name="id-1.1.90.2.236.4"></a><h4>Parameters</h4>
  7152. <div class="informaltable"><table>
  7153. <tr>
  7154. <td class="parameter_name"><p>pspec</p></td>
  7155. <td class="parameter_description">
  7156. <p>a <span class="type">GPatternSpec</span></p>
  7157. <p>Passed as <code class="code">pspec</code></p>
  7158. </td>
  7159. </tr>
  7160. <tr>
  7161. <td class="parameter_name"><p>string</p></td>
  7162. <td class="parameter_description">
  7163. <p>the UTF-8 encoded string to match</p>
  7164. <p>Passed as <code class="code">string</code></p>
  7165. </td>
  7166. </tr>
  7167. </table></div>
  7168. </div>
  7169. </div>
  7170. <div class="refsect2">
  7171. <a name="id-1.1.90.2.237"></a><h3>pointer-bit-lock</h3>
  7172. <div class="informalexample"><pre class="programlisting">(define-values () (pointer-bit-lock address lock-bit))
  7173. </pre></div>
  7174. <p>This is equivalent to g_bit_lock, but working on pointers (or other
  7175. pointer-sized values).
  7176. </p>
  7177. <p>For portability reasons, you may only lock on the bottom 32 bits of
  7178. the pointer.</p>
  7179. <div class="refsect3">
  7180. <a name="id-1.1.90.2.237.5"></a><h4>Parameters</h4>
  7181. <div class="informaltable"><table>
  7182. <tr>
  7183. <td class="parameter_name"><p>address</p></td>
  7184. <td class="parameter_description">
  7185. <p>a pointer to a <span class="type">gpointer</span>-sized value</p>
  7186. <p>Passed as <code class="code">address</code></p>
  7187. </td>
  7188. </tr>
  7189. <tr>
  7190. <td class="parameter_name"><p>lock_bit</p></td>
  7191. <td class="parameter_description">
  7192. <p>a bit value between 0 and 31</p>
  7193. <p>Passed as <code class="code">lock-bit</code></p>
  7194. </td>
  7195. </tr>
  7196. </table></div>
  7197. </div>
  7198. </div>
  7199. <div class="refsect2">
  7200. <a name="id-1.1.90.2.238"></a><h3>pointer-bit-trylock?</h3>
  7201. <div class="informalexample"><pre class="programlisting">(define-values (%return) (pointer-bit-trylock? address lock-bit))
  7202. </pre></div>
  7203. <p>This is equivalent to g_bit_trylock, but working on pointers (or
  7204. other pointer-sized values).
  7205. </p>
  7206. <p>For portability reasons, you may only lock on the bottom 32 bits of
  7207. the pointer.</p>
  7208. <div class="refsect3">
  7209. <a name="id-1.1.90.2.238.5"></a><h4>Parameters</h4>
  7210. <div class="informaltable"><table>
  7211. <tr>
  7212. <td class="parameter_name"><p>address</p></td>
  7213. <td class="parameter_description">
  7214. <p>a pointer to a <span class="type">gpointer</span>-sized value</p>
  7215. <p>Passed as <code class="code">address</code></p>
  7216. </td>
  7217. </tr>
  7218. <tr>
  7219. <td class="parameter_name"><p>lock_bit</p></td>
  7220. <td class="parameter_description">
  7221. <p>a bit value between 0 and 31</p>
  7222. <p>Passed as <code class="code">lock-bit</code></p>
  7223. </td>
  7224. </tr>
  7225. </table></div>
  7226. </div>
  7227. </div>
  7228. <div class="refsect2">
  7229. <a name="id-1.1.90.2.239"></a><h3>pointer-bit-unlock</h3>
  7230. <div class="informalexample"><pre class="programlisting">(define-values () (pointer-bit-unlock address lock-bit))
  7231. </pre></div>
  7232. <p>This is equivalent to g_bit_unlock, but working on pointers (or other
  7233. pointer-sized values).
  7234. </p>
  7235. <p>For portability reasons, you may only lock on the bottom 32 bits of
  7236. the pointer.</p>
  7237. <div class="refsect3">
  7238. <a name="id-1.1.90.2.239.5"></a><h4>Parameters</h4>
  7239. <div class="informaltable"><table>
  7240. <tr>
  7241. <td class="parameter_name"><p>address</p></td>
  7242. <td class="parameter_description">
  7243. <p>a pointer to a <span class="type">gpointer</span>-sized value</p>
  7244. <p>Passed as <code class="code">address</code></p>
  7245. </td>
  7246. </tr>
  7247. <tr>
  7248. <td class="parameter_name"><p>lock_bit</p></td>
  7249. <td class="parameter_description">
  7250. <p>a bit value between 0 and 31</p>
  7251. <p>Passed as <code class="code">lock-bit</code></p>
  7252. </td>
  7253. </tr>
  7254. </table></div>
  7255. </div>
  7256. </div>
  7257. <div class="refsect2">
  7258. <a name="id-1.1.90.2.240"></a><h3>poll</h3>
  7259. <div class="informalexample"><pre class="programlisting">(define-values (%return) (poll fds nfds timeout))
  7260. </pre></div>
  7261. <p>Polls <em class="parameter"><code>fds</code></em>, as with the <code class="function">poll()</code> system call, but portably. (On
  7262. systems that don't have <code class="function">poll()</code>, it is emulated using <code class="function">select()</code>.)
  7263. This is used internally by <span class="type">GMainContext</span>, but it can be called
  7264. directly if you need to block until a file descriptor is ready, but
  7265. don't want to run the full main loop.
  7266. </p>
  7267. <p>Each element of <em class="parameter"><code>fds</code></em> is a <span class="type">GPollFD</span> describing a single file
  7268. descriptor to poll. The <em class="parameter"><code>fd</code></em> field indicates the file descriptor,
  7269. and the <em class="parameter"><code>events</code></em> field indicates the events to poll for. On return,
  7270. the <em class="parameter"><code>revents</code></em> fields will be filled with the events that actually
  7271. occurred.
  7272. </p>
  7273. <p>On POSIX systems, the file descriptors in <em class="parameter"><code>fds</code></em> can be any sort of
  7274. file descriptor, but the situation is much more complicated on
  7275. Windows. If you need to use <code class="function">g_poll()</code> in code that has to run on
  7276. Windows, the easiest solution is to construct all of your
  7277. <span class="type">GPollFDs</span> with <code class="function">g_io_channel_win32_make_pollfd()</code>.</p>
  7278. <div class="refsect3">
  7279. <a name="id-1.1.90.2.240.6"></a><h4>Parameters</h4>
  7280. <div class="informaltable"><table>
  7281. <tr>
  7282. <td class="parameter_name"><p>fds</p></td>
  7283. <td class="parameter_description">
  7284. <p>file descriptors to poll</p>
  7285. <p>Passed as <code class="code">fds</code></p>
  7286. </td>
  7287. </tr>
  7288. <tr>
  7289. <td class="parameter_name"><p>nfds</p></td>
  7290. <td class="parameter_description">
  7291. <p>the number of file descriptors in <em class="parameter"><code>fds</code></em></p>
  7292. <p>Passed as <code class="code">nfds</code></p>
  7293. </td>
  7294. </tr>
  7295. <tr>
  7296. <td class="parameter_name"><p>timeout</p></td>
  7297. <td class="parameter_description">
  7298. <p>amount of time to wait, in milliseconds, or -1 to wait forever</p>
  7299. <p>Passed as <code class="code">timeout</code></p>
  7300. </td>
  7301. </tr>
  7302. </table></div>
  7303. </div>
  7304. </div>
  7305. <div class="refsect2">
  7306. <a name="id-1.1.90.2.241"></a><h3>prefix-error-literal</h3>
  7307. <div class="informalexample"><pre class="programlisting">(define-values () (prefix-error-literal err prefix))
  7308. </pre></div>
  7309. <p>Undocumented</p>
  7310. <div class="refsect3">
  7311. <a name="id-1.1.90.2.241.4"></a><h4>Parameters</h4>
  7312. <div class="informaltable"><table>
  7313. <tr>
  7314. <td class="parameter_name"><p>err</p></td>
  7315. <td class="parameter_description">
  7316. <p></p>
  7317. <p>Passed as <code class="code">err</code></p>
  7318. </td>
  7319. </tr>
  7320. <tr>
  7321. <td class="parameter_name"><p>prefix</p></td>
  7322. <td class="parameter_description">
  7323. <p></p>
  7324. <p>Passed as <code class="code">prefix</code></p>
  7325. </td>
  7326. </tr>
  7327. </table></div>
  7328. </div>
  7329. </div>
  7330. <div class="refsect2">
  7331. <a name="id-1.1.90.2.242"></a><h3>propagate-error</h3>
  7332. <div class="informalexample"><pre class="programlisting">(define-values (dest) (propagate-error src))
  7333. </pre></div>
  7334. <p>If <em class="parameter"><code>dest</code></em> is <code class="constant">NULL</code>, free <em class="parameter"><code>src</code></em>; otherwise, moves <em class="parameter"><code>src</code></em> into *<em class="parameter"><code>dest</code></em>.
  7335. The error variable <em class="parameter"><code>dest</code></em> points to must be <code class="constant">NULL</code>.
  7336. </p>
  7337. <p><em class="parameter"><code>src</code></em> must be non-<code class="constant">NULL</code>.
  7338. </p>
  7339. <p>Note that <em class="parameter"><code>src</code></em> is no longer valid after this call. If you want
  7340. to keep using the same GError*, you need to set it to <code class="constant">NULL</code>
  7341. after calling this function on it.</p>
  7342. <div class="refsect3">
  7343. <a name="id-1.1.90.2.242.6"></a><h4>Parameters</h4>
  7344. <div class="informaltable"><table>
  7345. <tr>
  7346. <td class="parameter_name"><p>dest</p></td>
  7347. <td class="parameter_description">
  7348. <p>error return location</p>
  7349. <p>Passed as <code class="code">dest</code></p>
  7350. </td>
  7351. </tr>
  7352. <tr>
  7353. <td class="parameter_name"><p>src</p></td>
  7354. <td class="parameter_description">
  7355. <p>error to move into the return location</p>
  7356. <p>Passed as <code class="code">src</code></p>
  7357. </td>
  7358. </tr>
  7359. </table></div>
  7360. </div>
  7361. </div>
  7362. <div class="refsect2">
  7363. <a name="id-1.1.90.2.243"></a><h3>quark-from-static-string</h3>
  7364. <div class="informalexample"><pre class="programlisting">(define-values (%return) (quark-from-static-string string))
  7365. </pre></div>
  7366. <p>Gets the <span class="type">GQuark</span> identifying the given (static) string. If the
  7367. string does not currently have an associated <span class="type">GQuark</span>, a new <span class="type">GQuark</span>
  7368. is created, linked to the given string.
  7369. </p>
  7370. <p>Note that this function is identical to <code class="function">g_quark_from_string()</code> except
  7371. that if a new <span class="type">GQuark</span> is created the string itself is used rather
  7372. than a copy. This saves memory, but can only be used if the string
  7373. will continue to exist until the program terminates. It can be used
  7374. with statically allocated strings in the main program, but not with
  7375. statically allocated memory in dynamically loaded modules, if you
  7376. expect to ever unload the module again (e.g. do not use this
  7377. function in GTK+ theme engines).
  7378. </p>
  7379. <p>This function must not be used before library constructors have finished
  7380. running. In particular, this means it cannot be used to initialize global
  7381. variables in C++.</p>
  7382. <div class="refsect3">
  7383. <a name="id-1.1.90.2.243.6"></a><h4>Parameters</h4>
  7384. <div class="informaltable"><table><tr>
  7385. <td class="parameter_name"><p>string</p></td>
  7386. <td class="parameter_description">
  7387. <p>a string</p>
  7388. <p>Passed as <code class="code">string</code></p>
  7389. </td>
  7390. </tr></table></div>
  7391. </div>
  7392. </div>
  7393. <div class="refsect2">
  7394. <a name="id-1.1.90.2.244"></a><h3>quark-from-string</h3>
  7395. <div class="informalexample"><pre class="programlisting">(define-values (%return) (quark-from-string string))
  7396. </pre></div>
  7397. <p>Gets the <span class="type">GQuark</span> identifying the given string. If the string does
  7398. not currently have an associated <span class="type">GQuark</span>, a new <span class="type">GQuark</span> is created,
  7399. using a copy of the string.
  7400. </p>
  7401. <p>This function must not be used before library constructors have finished
  7402. running. In particular, this means it cannot be used to initialize global
  7403. variables in C++.</p>
  7404. <div class="refsect3">
  7405. <a name="id-1.1.90.2.244.5"></a><h4>Parameters</h4>
  7406. <div class="informaltable"><table><tr>
  7407. <td class="parameter_name"><p>string</p></td>
  7408. <td class="parameter_description">
  7409. <p>a string</p>
  7410. <p>Passed as <code class="code">string</code></p>
  7411. </td>
  7412. </tr></table></div>
  7413. </div>
  7414. </div>
  7415. <div class="refsect2">
  7416. <a name="id-1.1.90.2.245"></a><h3>quark-to-string</h3>
  7417. <div class="informalexample"><pre class="programlisting">(define-values (%return) (quark-to-string quark))
  7418. </pre></div>
  7419. <p>Gets the string associated with the given <span class="type">GQuark</span>.</p>
  7420. <div class="refsect3">
  7421. <a name="id-1.1.90.2.245.4"></a><h4>Parameters</h4>
  7422. <div class="informaltable"><table><tr>
  7423. <td class="parameter_name"><p>quark</p></td>
  7424. <td class="parameter_description">
  7425. <p>a <span class="type">GQuark</span>.</p>
  7426. <p>Passed as <code class="code">quark</code></p>
  7427. </td>
  7428. </tr></table></div>
  7429. </div>
  7430. </div>
  7431. <div class="refsect2">
  7432. <a name="id-1.1.90.2.246"></a><h3>quark-try-string</h3>
  7433. <div class="informalexample"><pre class="programlisting">(define-values (%return) (quark-try-string string))
  7434. </pre></div>
  7435. <p>Gets the <span class="type">GQuark</span> associated with the given string, or 0 if string is
  7436. <code class="constant">NULL</code> or it has no associated <span class="type">GQuark</span>.
  7437. </p>
  7438. <p>If you want the GQuark to be created if it doesn't already exist,
  7439. use <code class="function">g_quark_from_string()</code> or <code class="function">g_quark_from_static_string()</code>.
  7440. </p>
  7441. <p>This function must not be used before library constructors have finished
  7442. running.</p>
  7443. <div class="refsect3">
  7444. <a name="id-1.1.90.2.246.6"></a><h4>Parameters</h4>
  7445. <div class="informaltable"><table><tr>
  7446. <td class="parameter_name"><p>string</p></td>
  7447. <td class="parameter_description">
  7448. <p>a string</p>
  7449. <p>Passed as <code class="code">string</code></p>
  7450. </td>
  7451. </tr></table></div>
  7452. </div>
  7453. </div>
  7454. <div class="refsect2">
  7455. <a name="id-1.1.90.2.247"></a><h3>random-double</h3>
  7456. <div class="informalexample"><pre class="programlisting">(define-values (%return) (random-double))
  7457. </pre></div>
  7458. <p>Returns a random <span class="type">gdouble</span> equally distributed over the range [0..1).</p>
  7459. </div>
  7460. <div class="refsect2">
  7461. <a name="id-1.1.90.2.248"></a><h3>random-double-range</h3>
  7462. <div class="informalexample"><pre class="programlisting">(define-values (%return) (random-double-range begin end))
  7463. </pre></div>
  7464. <p>Returns a random <span class="type">gdouble</span> equally distributed over the range
  7465. [<em class="parameter"><code>begin</code></em>..<em class="parameter"><code>end</code></em>).</p>
  7466. <div class="refsect3">
  7467. <a name="id-1.1.90.2.248.4"></a><h4>Parameters</h4>
  7468. <div class="informaltable"><table>
  7469. <tr>
  7470. <td class="parameter_name"><p>begin</p></td>
  7471. <td class="parameter_description">
  7472. <p>lower closed bound of the interval</p>
  7473. <p>Passed as <code class="code">begin</code></p>
  7474. </td>
  7475. </tr>
  7476. <tr>
  7477. <td class="parameter_name"><p>end</p></td>
  7478. <td class="parameter_description">
  7479. <p>upper open bound of the interval</p>
  7480. <p>Passed as <code class="code">end</code></p>
  7481. </td>
  7482. </tr>
  7483. </table></div>
  7484. </div>
  7485. </div>
  7486. <div class="refsect2">
  7487. <a name="id-1.1.90.2.249"></a><h3>random-int</h3>
  7488. <div class="informalexample"><pre class="programlisting">(define-values (%return) (random-int))
  7489. </pre></div>
  7490. <p>Return a random <span class="type">guint32</span> equally distributed over the range
  7491. [0..2^32-1].</p>
  7492. </div>
  7493. <div class="refsect2">
  7494. <a name="id-1.1.90.2.250"></a><h3>random-int-range</h3>
  7495. <div class="informalexample"><pre class="programlisting">(define-values (%return) (random-int-range begin end))
  7496. </pre></div>
  7497. <p>Returns a random <span class="type">gint32</span> equally distributed over the range
  7498. [<em class="parameter"><code>begin</code></em>..<em class="parameter"><code>end</code></em>-1].</p>
  7499. <div class="refsect3">
  7500. <a name="id-1.1.90.2.250.4"></a><h4>Parameters</h4>
  7501. <div class="informaltable"><table>
  7502. <tr>
  7503. <td class="parameter_name"><p>begin</p></td>
  7504. <td class="parameter_description">
  7505. <p>lower closed bound of the interval</p>
  7506. <p>Passed as <code class="code">begin</code></p>
  7507. </td>
  7508. </tr>
  7509. <tr>
  7510. <td class="parameter_name"><p>end</p></td>
  7511. <td class="parameter_description">
  7512. <p>upper open bound of the interval</p>
  7513. <p>Passed as <code class="code">end</code></p>
  7514. </td>
  7515. </tr>
  7516. </table></div>
  7517. </div>
  7518. </div>
  7519. <div class="refsect2">
  7520. <a name="id-1.1.90.2.251"></a><h3>random-set-seed</h3>
  7521. <div class="informalexample"><pre class="programlisting">(define-values () (random-set-seed seed))
  7522. </pre></div>
  7523. <p>Sets the seed for the global random number generator, which is used
  7524. by the g_random_* functions, to <em class="parameter"><code>seed</code></em>.</p>
  7525. <div class="refsect3">
  7526. <a name="id-1.1.90.2.251.4"></a><h4>Parameters</h4>
  7527. <div class="informaltable"><table><tr>
  7528. <td class="parameter_name"><p>seed</p></td>
  7529. <td class="parameter_description">
  7530. <p>a value to reinitialize the global random number generator</p>
  7531. <p>Passed as <code class="code">seed</code></p>
  7532. </td>
  7533. </tr></table></div>
  7534. </div>
  7535. </div>
  7536. <div class="refsect2">
  7537. <a name="id-1.1.90.2.252"></a><h3>rc-box-acquire</h3>
  7538. <div class="informalexample"><pre class="programlisting">(define-values (%return) (rc-box-acquire mem-block))
  7539. </pre></div>
  7540. <p>Acquires a reference on the data pointed by <em class="parameter"><code>mem_block</code></em>.</p>
  7541. <div class="refsect3">
  7542. <a name="id-1.1.90.2.252.4"></a><h4>Parameters</h4>
  7543. <div class="informaltable"><table><tr>
  7544. <td class="parameter_name"><p>mem_block</p></td>
  7545. <td class="parameter_description">
  7546. <p>a pointer to reference counted data</p>
  7547. <p>Passed as <code class="code">mem-block</code></p>
  7548. </td>
  7549. </tr></table></div>
  7550. </div>
  7551. </div>
  7552. <div class="refsect2">
  7553. <a name="id-1.1.90.2.253"></a><h3>rc-box-alloc</h3>
  7554. <div class="informalexample"><pre class="programlisting">(define-values (%return) (rc-box-alloc block-size))
  7555. </pre></div>
  7556. <p>Allocates <em class="parameter"><code>block_size</code></em> bytes of memory, and adds reference
  7557. counting semantics to it.
  7558. </p>
  7559. <p>The data will be freed when its reference count drops to
  7560. zero.
  7561. </p>
  7562. <p>The allocated data is guaranteed to be suitably aligned for any
  7563. built-in type.</p>
  7564. <div class="refsect3">
  7565. <a name="id-1.1.90.2.253.6"></a><h4>Parameters</h4>
  7566. <div class="informaltable"><table><tr>
  7567. <td class="parameter_name"><p>block_size</p></td>
  7568. <td class="parameter_description">
  7569. <p>the size of the allocation, must be greater than 0</p>
  7570. <p>Passed as <code class="code">block-size</code></p>
  7571. </td>
  7572. </tr></table></div>
  7573. </div>
  7574. </div>
  7575. <div class="refsect2">
  7576. <a name="id-1.1.90.2.254"></a><h3>rc-box-alloc0</h3>
  7577. <div class="informalexample"><pre class="programlisting">(define-values (%return) (rc-box-alloc0 block-size))
  7578. </pre></div>
  7579. <p>Allocates <em class="parameter"><code>block_size</code></em> bytes of memory, and adds reference
  7580. counting semantics to it.
  7581. </p>
  7582. <p>The contents of the returned data is set to zero.
  7583. </p>
  7584. <p>The data will be freed when its reference count drops to
  7585. zero.
  7586. </p>
  7587. <p>The allocated data is guaranteed to be suitably aligned for any
  7588. built-in type.</p>
  7589. <div class="refsect3">
  7590. <a name="id-1.1.90.2.254.7"></a><h4>Parameters</h4>
  7591. <div class="informaltable"><table><tr>
  7592. <td class="parameter_name"><p>block_size</p></td>
  7593. <td class="parameter_description">
  7594. <p>the size of the allocation, must be greater than 0</p>
  7595. <p>Passed as <code class="code">block-size</code></p>
  7596. </td>
  7597. </tr></table></div>
  7598. </div>
  7599. </div>
  7600. <div class="refsect2">
  7601. <a name="id-1.1.90.2.255"></a><h3>rc-box-dup</h3>
  7602. <div class="informalexample"><pre class="programlisting">(define-values (%return) (rc-box-dup block-size mem-block))
  7603. </pre></div>
  7604. <p>Allocates a new block of data with reference counting
  7605. semantics, and copies <em class="parameter"><code>block_size</code></em> bytes of <em class="parameter"><code>mem_block</code></em>
  7606. into it.</p>
  7607. <div class="refsect3">
  7608. <a name="id-1.1.90.2.255.4"></a><h4>Parameters</h4>
  7609. <div class="informaltable"><table>
  7610. <tr>
  7611. <td class="parameter_name"><p>block_size</p></td>
  7612. <td class="parameter_description">
  7613. <p>the number of bytes to copy, must be greater than 0</p>
  7614. <p>Passed as <code class="code">block-size</code></p>
  7615. </td>
  7616. </tr>
  7617. <tr>
  7618. <td class="parameter_name"><p>mem_block</p></td>
  7619. <td class="parameter_description">
  7620. <p>the memory to copy</p>
  7621. <p>Passed as <code class="code">mem-block</code></p>
  7622. </td>
  7623. </tr>
  7624. </table></div>
  7625. </div>
  7626. </div>
  7627. <div class="refsect2">
  7628. <a name="id-1.1.90.2.256"></a><h3>rc-box-get-size</h3>
  7629. <div class="informalexample"><pre class="programlisting">(define-values (%return) (rc-box-get-size mem-block))
  7630. </pre></div>
  7631. <p>Retrieves the size of the reference counted data pointed by <em class="parameter"><code>mem_block</code></em>.</p>
  7632. <div class="refsect3">
  7633. <a name="id-1.1.90.2.256.4"></a><h4>Parameters</h4>
  7634. <div class="informaltable"><table><tr>
  7635. <td class="parameter_name"><p>mem_block</p></td>
  7636. <td class="parameter_description">
  7637. <p>a pointer to reference counted data</p>
  7638. <p>Passed as <code class="code">mem-block</code></p>
  7639. </td>
  7640. </tr></table></div>
  7641. </div>
  7642. </div>
  7643. <div class="refsect2">
  7644. <a name="id-1.1.90.2.257"></a><h3>rc-box-release</h3>
  7645. <div class="informalexample"><pre class="programlisting">(define-values () (rc-box-release mem-block))
  7646. </pre></div>
  7647. <p>Releases a reference on the data pointed by <em class="parameter"><code>mem_block</code></em>.
  7648. </p>
  7649. <p>If the reference was the last one, it will free the
  7650. resources allocated for <em class="parameter"><code>mem_block</code></em>.</p>
  7651. <div class="refsect3">
  7652. <a name="id-1.1.90.2.257.5"></a><h4>Parameters</h4>
  7653. <div class="informaltable"><table><tr>
  7654. <td class="parameter_name"><p>mem_block</p></td>
  7655. <td class="parameter_description">
  7656. <p>a pointer to reference counted data</p>
  7657. <p>Passed as <code class="code">mem-block</code></p>
  7658. </td>
  7659. </tr></table></div>
  7660. </div>
  7661. </div>
  7662. <div class="refsect2">
  7663. <a name="id-1.1.90.2.258"></a><h3>rc-box-release-full</h3>
  7664. <div class="informalexample"><pre class="programlisting">(define-values () (rc-box-release-full mem-block clear-func))
  7665. </pre></div>
  7666. <p>Releases a reference on the data pointed by <em class="parameter"><code>mem_block</code></em>.
  7667. </p>
  7668. <p>If the reference was the last one, it will call <em class="parameter"><code>clear_func</code></em>
  7669. to clear the contents of <em class="parameter"><code>mem_block</code></em>, and then will free the
  7670. resources allocated for <em class="parameter"><code>mem_block</code></em>.</p>
  7671. <div class="refsect3">
  7672. <a name="id-1.1.90.2.258.5"></a><h4>Parameters</h4>
  7673. <div class="informaltable"><table>
  7674. <tr>
  7675. <td class="parameter_name"><p>mem_block</p></td>
  7676. <td class="parameter_description">
  7677. <p>a pointer to reference counted data</p>
  7678. <p>Passed as <code class="code">mem-block</code></p>
  7679. </td>
  7680. </tr>
  7681. <tr>
  7682. <td class="parameter_name"><p>clear_func</p></td>
  7683. <td class="parameter_description">
  7684. <p>a function to call when clearing the data</p>
  7685. <p>Passed as <code class="code">clear-func</code></p>
  7686. </td>
  7687. </tr>
  7688. </table></div>
  7689. </div>
  7690. </div>
  7691. <div class="refsect2">
  7692. <a name="id-1.1.90.2.259"></a><h3>realloc</h3>
  7693. <div class="informalexample"><pre class="programlisting">(define-values (%return) (realloc mem n-bytes))
  7694. </pre></div>
  7695. <p>Reallocates the memory pointed to by <em class="parameter"><code>mem</code></em>, so that it now has space for
  7696. <em class="parameter"><code>n_bytes</code></em> bytes of memory. It returns the new address of the memory, which may
  7697. have been moved. <em class="parameter"><code>mem</code></em> may be <code class="constant">NULL</code>, in which case it's considered to
  7698. have zero-length. <em class="parameter"><code>n_bytes</code></em> may be 0, in which case <code class="constant">NULL</code> will be returned
  7699. and <em class="parameter"><code>mem</code></em> will be freed unless it is <code class="constant">NULL</code>.</p>
  7700. <div class="refsect3">
  7701. <a name="id-1.1.90.2.259.4"></a><h4>Parameters</h4>
  7702. <div class="informaltable"><table>
  7703. <tr>
  7704. <td class="parameter_name"><p>mem</p></td>
  7705. <td class="parameter_description">
  7706. <p>the memory to reallocate</p>
  7707. <p>Passed as <code class="code">mem</code></p>
  7708. </td>
  7709. </tr>
  7710. <tr>
  7711. <td class="parameter_name"><p>n_bytes</p></td>
  7712. <td class="parameter_description">
  7713. <p>new size of the memory in bytes</p>
  7714. <p>Passed as <code class="code">n-bytes</code></p>
  7715. </td>
  7716. </tr>
  7717. </table></div>
  7718. </div>
  7719. </div>
  7720. <div class="refsect2">
  7721. <a name="id-1.1.90.2.260"></a><h3>realloc-n</h3>
  7722. <div class="informalexample"><pre class="programlisting">(define-values (%return) (realloc-n mem n-blocks n-block-bytes))
  7723. </pre></div>
  7724. <p>This function is similar to <code class="function">g_realloc()</code>, allocating (<em class="parameter"><code>n_blocks</code></em> * <em class="parameter"><code>n_block_bytes</code></em>) bytes,
  7725. but care is taken to detect possible overflow during multiplication.</p>
  7726. <div class="refsect3">
  7727. <a name="id-1.1.90.2.260.4"></a><h4>Parameters</h4>
  7728. <div class="informaltable"><table>
  7729. <tr>
  7730. <td class="parameter_name"><p>mem</p></td>
  7731. <td class="parameter_description">
  7732. <p>the memory to reallocate</p>
  7733. <p>Passed as <code class="code">mem</code></p>
  7734. </td>
  7735. </tr>
  7736. <tr>
  7737. <td class="parameter_name"><p>n_blocks</p></td>
  7738. <td class="parameter_description">
  7739. <p>the number of blocks to allocate</p>
  7740. <p>Passed as <code class="code">n-blocks</code></p>
  7741. </td>
  7742. </tr>
  7743. <tr>
  7744. <td class="parameter_name"><p>n_block_bytes</p></td>
  7745. <td class="parameter_description">
  7746. <p>the size of each block in bytes</p>
  7747. <p>Passed as <code class="code">n-block-bytes</code></p>
  7748. </td>
  7749. </tr>
  7750. </table></div>
  7751. </div>
  7752. </div>
  7753. <div class="refsect2">
  7754. <a name="id-1.1.90.2.261"></a><h3>ref-count-compare?</h3>
  7755. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ref-count-compare? rc val))
  7756. </pre></div>
  7757. <p>Compares the current value of <em class="parameter"><code>rc</code></em> with <em class="parameter"><code>val</code></em>.</p>
  7758. <div class="refsect3">
  7759. <a name="id-1.1.90.2.261.4"></a><h4>Parameters</h4>
  7760. <div class="informaltable"><table>
  7761. <tr>
  7762. <td class="parameter_name"><p>rc</p></td>
  7763. <td class="parameter_description">
  7764. <p>the address of a reference count variable</p>
  7765. <p>Passed as <code class="code">rc</code></p>
  7766. </td>
  7767. </tr>
  7768. <tr>
  7769. <td class="parameter_name"><p>val</p></td>
  7770. <td class="parameter_description">
  7771. <p>the value to compare</p>
  7772. <p>Passed as <code class="code">val</code></p>
  7773. </td>
  7774. </tr>
  7775. </table></div>
  7776. </div>
  7777. </div>
  7778. <div class="refsect2">
  7779. <a name="id-1.1.90.2.262"></a><h3>ref-count-dec?</h3>
  7780. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ref-count-dec? rc))
  7781. </pre></div>
  7782. <p>Decreases the reference count.</p>
  7783. <div class="refsect3">
  7784. <a name="id-1.1.90.2.262.4"></a><h4>Parameters</h4>
  7785. <div class="informaltable"><table><tr>
  7786. <td class="parameter_name"><p>rc</p></td>
  7787. <td class="parameter_description">
  7788. <p>the address of a reference count variable</p>
  7789. <p>Passed as <code class="code">rc</code></p>
  7790. </td>
  7791. </tr></table></div>
  7792. </div>
  7793. </div>
  7794. <div class="refsect2">
  7795. <a name="id-1.1.90.2.263"></a><h3>ref-count-inc</h3>
  7796. <div class="informalexample"><pre class="programlisting">(define-values () (ref-count-inc rc))
  7797. </pre></div>
  7798. <p>Increases the reference count.</p>
  7799. <div class="refsect3">
  7800. <a name="id-1.1.90.2.263.4"></a><h4>Parameters</h4>
  7801. <div class="informaltable"><table><tr>
  7802. <td class="parameter_name"><p>rc</p></td>
  7803. <td class="parameter_description">
  7804. <p>the address of a reference count variable</p>
  7805. <p>Passed as <code class="code">rc</code></p>
  7806. </td>
  7807. </tr></table></div>
  7808. </div>
  7809. </div>
  7810. <div class="refsect2">
  7811. <a name="id-1.1.90.2.264"></a><h3>ref-count-init</h3>
  7812. <div class="informalexample"><pre class="programlisting">(define-values () (ref-count-init rc))
  7813. </pre></div>
  7814. <p>Initializes a reference count variable.</p>
  7815. <div class="refsect3">
  7816. <a name="id-1.1.90.2.264.4"></a><h4>Parameters</h4>
  7817. <div class="informaltable"><table><tr>
  7818. <td class="parameter_name"><p>rc</p></td>
  7819. <td class="parameter_description">
  7820. <p>the address of a reference count variable</p>
  7821. <p>Passed as <code class="code">rc</code></p>
  7822. </td>
  7823. </tr></table></div>
  7824. </div>
  7825. </div>
  7826. <div class="refsect2">
  7827. <a name="id-1.1.90.2.265"></a><h3>ref-string-acquire</h3>
  7828. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ref-string-acquire str))
  7829. </pre></div>
  7830. <p>Acquires a reference on a string.</p>
  7831. <div class="refsect3">
  7832. <a name="id-1.1.90.2.265.4"></a><h4>Parameters</h4>
  7833. <div class="informaltable"><table><tr>
  7834. <td class="parameter_name"><p>str</p></td>
  7835. <td class="parameter_description">
  7836. <p>a reference counted string</p>
  7837. <p>Passed as <code class="code">str</code></p>
  7838. </td>
  7839. </tr></table></div>
  7840. </div>
  7841. </div>
  7842. <div class="refsect2">
  7843. <a name="id-1.1.90.2.266"></a><h3>ref-string-length</h3>
  7844. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ref-string-length str))
  7845. </pre></div>
  7846. <p>Retrieves the length of <em class="parameter"><code>str</code></em>.</p>
  7847. <div class="refsect3">
  7848. <a name="id-1.1.90.2.266.4"></a><h4>Parameters</h4>
  7849. <div class="informaltable"><table><tr>
  7850. <td class="parameter_name"><p>str</p></td>
  7851. <td class="parameter_description">
  7852. <p>a reference counted string</p>
  7853. <p>Passed as <code class="code">str</code></p>
  7854. </td>
  7855. </tr></table></div>
  7856. </div>
  7857. </div>
  7858. <div class="refsect2">
  7859. <a name="id-1.1.90.2.267"></a><h3>ref-string-new</h3>
  7860. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ref-string-new str))
  7861. </pre></div>
  7862. <p>Creates a new reference counted string and copies the contents of <em class="parameter"><code>str</code></em>
  7863. into it.</p>
  7864. <div class="refsect3">
  7865. <a name="id-1.1.90.2.267.4"></a><h4>Parameters</h4>
  7866. <div class="informaltable"><table><tr>
  7867. <td class="parameter_name"><p>str</p></td>
  7868. <td class="parameter_description">
  7869. <p>a NUL-terminated string</p>
  7870. <p>Passed as <code class="code">str</code></p>
  7871. </td>
  7872. </tr></table></div>
  7873. </div>
  7874. </div>
  7875. <div class="refsect2">
  7876. <a name="id-1.1.90.2.268"></a><h3>ref-string-new-intern</h3>
  7877. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ref-string-new-intern str))
  7878. </pre></div>
  7879. <p>Creates a new reference counted string and copies the content of <em class="parameter"><code>str</code></em>
  7880. into it.
  7881. </p>
  7882. <p>If you call this function multiple times with the same <em class="parameter"><code>str</code></em>, or with
  7883. the same contents of <em class="parameter"><code>str</code></em>, it will return a new reference, instead of
  7884. creating a new string.</p>
  7885. <div class="refsect3">
  7886. <a name="id-1.1.90.2.268.5"></a><h4>Parameters</h4>
  7887. <div class="informaltable"><table><tr>
  7888. <td class="parameter_name"><p>str</p></td>
  7889. <td class="parameter_description">
  7890. <p>a NUL-terminated string</p>
  7891. <p>Passed as <code class="code">str</code></p>
  7892. </td>
  7893. </tr></table></div>
  7894. </div>
  7895. </div>
  7896. <div class="refsect2">
  7897. <a name="id-1.1.90.2.269"></a><h3>ref-string-new-len</h3>
  7898. <div class="informalexample"><pre class="programlisting">(define-values (%return) (ref-string-new-len str len))
  7899. </pre></div>
  7900. <p>Creates a new reference counted string and copies the contents of <em class="parameter"><code>str</code></em>
  7901. into it, up to <em class="parameter"><code>len</code></em> bytes.
  7902. </p>
  7903. <p>Since this function does not stop at nul bytes, it is the caller's
  7904. responsibility to ensure that <em class="parameter"><code>str</code></em> has at least <em class="parameter"><code>len</code></em> addressable bytes.</p>
  7905. <div class="refsect3">
  7906. <a name="id-1.1.90.2.269.5"></a><h4>Parameters</h4>
  7907. <div class="informaltable"><table>
  7908. <tr>
  7909. <td class="parameter_name"><p>str</p></td>
  7910. <td class="parameter_description">
  7911. <p>a string</p>
  7912. <p>Passed as <code class="code">str</code></p>
  7913. </td>
  7914. </tr>
  7915. <tr>
  7916. <td class="parameter_name"><p>len</p></td>
  7917. <td class="parameter_description">
  7918. <p>length of <em class="parameter"><code>str</code></em> to use, or -1 if <em class="parameter"><code>str</code></em> is nul-terminated</p>
  7919. <p>Passed as <code class="code">len</code></p>
  7920. </td>
  7921. </tr>
  7922. </table></div>
  7923. </div>
  7924. </div>
  7925. <div class="refsect2">
  7926. <a name="id-1.1.90.2.270"></a><h3>ref-string-release</h3>
  7927. <div class="informalexample"><pre class="programlisting">(define-values () (ref-string-release str))
  7928. </pre></div>
  7929. <p>Releases a reference on a string; if it was the last reference, the
  7930. resources allocated by the string are freed as well.</p>
  7931. <div class="refsect3">
  7932. <a name="id-1.1.90.2.270.4"></a><h4>Parameters</h4>
  7933. <div class="informaltable"><table><tr>
  7934. <td class="parameter_name"><p>str</p></td>
  7935. <td class="parameter_description">
  7936. <p>a reference counted string</p>
  7937. <p>Passed as <code class="code">str</code></p>
  7938. </td>
  7939. </tr></table></div>
  7940. </div>
  7941. </div>
  7942. <div class="refsect2">
  7943. <a name="id-1.1.90.2.271"></a><h3>regex-check-replacement</h3>
  7944. <div class="informalexample"><pre class="programlisting">(define-values (%return has-references) (regex-check-replacement replacement))
  7945. </pre></div>
  7946. <p>Checks whether <em class="parameter"><code>replacement</code></em> is a valid replacement string
  7947. (see <code class="function">g_regex_replace()</code>), i.e. that all escape sequences in
  7948. it are valid.
  7949. </p>
  7950. <p>If <em class="parameter"><code>has_references</code></em> is not <code class="constant">NULL</code> then <em class="parameter"><code>replacement</code></em> is checked
  7951. for pattern references. For instance, replacement text 'foo\n'
  7952. does not contain references and may be evaluated without information
  7953. about actual match, but '\0\1' (whole match followed by first
  7954. subpattern) requires valid <span class="type">GMatchInfo</span> object.</p>
  7955. <div class="refsect3">
  7956. <a name="id-1.1.90.2.271.5"></a><h4>Parameters</h4>
  7957. <div class="informaltable"><table>
  7958. <tr>
  7959. <td class="parameter_name"><p>replacement</p></td>
  7960. <td class="parameter_description">
  7961. <p>the replacement string</p>
  7962. <p>Passed as <code class="code">replacement</code></p>
  7963. </td>
  7964. </tr>
  7965. <tr>
  7966. <td class="parameter_name"><p>has_references</p></td>
  7967. <td class="parameter_description">
  7968. <p>location to store information about
  7969. references in <em class="parameter"><code>replacement</code></em> or <code class="constant">NULL</code></p>
  7970. <p>Passed as <code class="code">has-references</code></p>
  7971. </td>
  7972. </tr>
  7973. </table></div>
  7974. </div>
  7975. </div>
  7976. <div class="refsect2">
  7977. <a name="id-1.1.90.2.272"></a><h3>regex-error-quark</h3>
  7978. <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex-error-quark))
  7979. </pre></div>
  7980. <p>Undocumented</p>
  7981. </div>
  7982. <div class="refsect2">
  7983. <a name="id-1.1.90.2.273"></a><h3>regex-escape-nul</h3>
  7984. <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex-escape-nul string length))
  7985. </pre></div>
  7986. <p>Escapes the nul characters in <em class="parameter"><code>string</code></em> to "\x00". It can be used
  7987. to compile a regex with embedded nul characters.
  7988. </p>
  7989. <p>For completeness, <em class="parameter"><code>length</code></em> can be -1 for a nul-terminated string.
  7990. In this case the output string will be of course equal to <em class="parameter"><code>string</code></em>.</p>
  7991. <div class="refsect3">
  7992. <a name="id-1.1.90.2.273.5"></a><h4>Parameters</h4>
  7993. <div class="informaltable"><table>
  7994. <tr>
  7995. <td class="parameter_name"><p>string</p></td>
  7996. <td class="parameter_description">
  7997. <p>the string to escape</p>
  7998. <p>Passed as <code class="code">string</code></p>
  7999. </td>
  8000. </tr>
  8001. <tr>
  8002. <td class="parameter_name"><p>length</p></td>
  8003. <td class="parameter_description">
  8004. <p>the length of <em class="parameter"><code>string</code></em></p>
  8005. <p>Passed as <code class="code">length</code></p>
  8006. </td>
  8007. </tr>
  8008. </table></div>
  8009. </div>
  8010. </div>
  8011. <div class="refsect2">
  8012. <a name="id-1.1.90.2.274"></a><h3>regex-escape-string</h3>
  8013. <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex-escape-string string))
  8014. </pre></div>
  8015. <p>Escapes the special characters used for regular expressions
  8016. in <em class="parameter"><code>string</code></em>, for instance "a.b*c" becomes "a\.b\*c". This
  8017. function is useful to dynamically generate regular expressions.
  8018. </p>
  8019. <p><em class="parameter"><code>string</code></em> can contain nul characters that are replaced with "\0",
  8020. in this case remember to specify the correct length of <em class="parameter"><code>string</code></em>
  8021. in <em class="parameter"><code>length</code></em>.</p>
  8022. <div class="refsect3">
  8023. <a name="id-1.1.90.2.274.5"></a><h4>Parameters</h4>
  8024. <div class="informaltable"><table>
  8025. <tr>
  8026. <td class="parameter_name"><p>string</p></td>
  8027. <td class="parameter_description">
  8028. <p>the string to escape</p>
  8029. <p>Passed as <code class="code">string</code></p>
  8030. </td>
  8031. </tr>
  8032. <tr>
  8033. <td class="parameter_name"><p>length</p></td>
  8034. <td class="parameter_description">
  8035. <p>the length of <em class="parameter"><code>string</code></em>, in bytes, or -1 if <em class="parameter"><code>string</code></em> is nul-terminated</p>
  8036. <p>Inferred from <code class="code">string</code></p>
  8037. </td>
  8038. </tr>
  8039. </table></div>
  8040. </div>
  8041. </div>
  8042. <div class="refsect2">
  8043. <a name="id-1.1.90.2.275"></a><h3>regex-match-simple?</h3>
  8044. <div class="informalexample"><pre class="programlisting">(define-values
  8045. (%return)
  8046. (regex-match-simple? pattern string compile-options match-options))
  8047. </pre></div>
  8048. <p>Scans for a match in <em class="parameter"><code>string</code></em> for <em class="parameter"><code>pattern</code></em>.
  8049. </p>
  8050. <p>This function is equivalent to <code class="function">g_regex_match()</code> but it does not
  8051. require to compile the pattern with <code class="function">g_regex_new()</code>, avoiding some
  8052. lines of code when you need just to do a match without extracting
  8053. substrings, capture counts, and so on.
  8054. </p>
  8055. <p>If this function is to be called on the same <em class="parameter"><code>pattern</code></em> more than
  8056. once, it's more efficient to compile the pattern once with
  8057. <code class="function">g_regex_new()</code> and then use <code class="function">g_regex_match()</code>.</p>
  8058. <div class="refsect3">
  8059. <a name="id-1.1.90.2.275.6"></a><h4>Parameters</h4>
  8060. <div class="informaltable"><table>
  8061. <tr>
  8062. <td class="parameter_name"><p>pattern</p></td>
  8063. <td class="parameter_description">
  8064. <p>the regular expression</p>
  8065. <p>Passed as <code class="code">pattern</code></p>
  8066. </td>
  8067. </tr>
  8068. <tr>
  8069. <td class="parameter_name"><p>string</p></td>
  8070. <td class="parameter_description">
  8071. <p>the string to scan for matches</p>
  8072. <p>Passed as <code class="code">string</code></p>
  8073. </td>
  8074. </tr>
  8075. <tr>
  8076. <td class="parameter_name"><p>compile_options</p></td>
  8077. <td class="parameter_description">
  8078. <p>compile options for the regular expression, or 0</p>
  8079. <p>Passed as <code class="code">compile-options</code></p>
  8080. </td>
  8081. </tr>
  8082. <tr>
  8083. <td class="parameter_name"><p>match_options</p></td>
  8084. <td class="parameter_description">
  8085. <p>match options, or 0</p>
  8086. <p>Passed as <code class="code">match-options</code></p>
  8087. </td>
  8088. </tr>
  8089. </table></div>
  8090. </div>
  8091. </div>
  8092. <div class="refsect2">
  8093. <a name="id-1.1.90.2.276"></a><h3>regex-split-simple</h3>
  8094. <div class="informalexample"><pre class="programlisting">(define-values
  8095. (%return)
  8096. (regex-split-simple pattern string compile-options match-options))
  8097. </pre></div>
  8098. <p>Breaks the string on the pattern, and returns an array of
  8099. the tokens. If the pattern contains capturing parentheses,
  8100. then the text for each of the substrings will also be returned.
  8101. If the pattern does not match anywhere in the string, then the
  8102. whole string is returned as the first token.
  8103. </p>
  8104. <p>This function is equivalent to <code class="function">g_regex_split()</code> but it does
  8105. not require to compile the pattern with <code class="function">g_regex_new()</code>, avoiding
  8106. some lines of code when you need just to do a split without
  8107. extracting substrings, capture counts, and so on.
  8108. </p>
  8109. <p>If this function is to be called on the same <em class="parameter"><code>pattern</code></em> more than
  8110. once, it's more efficient to compile the pattern once with
  8111. <code class="function">g_regex_new()</code> and then use <code class="function">g_regex_split()</code>.
  8112. </p>
  8113. <p>As a special case, the result of splitting the empty string ""
  8114. is an empty vector, not a vector containing a single string.
  8115. The reason for this special case is that being able to represent
  8116. an empty vector is typically more useful than consistent handling
  8117. of empty elements. If you do need to represent empty elements,
  8118. you'll need to check for the empty string before calling this
  8119. function.
  8120. </p>
  8121. <p>A pattern that can match empty strings splits <em class="parameter"><code>string</code></em> into
  8122. separate characters wherever it matches the empty string between
  8123. characters. For example splitting "ab c" using as a separator
  8124. "\s*", you will get "a", "b" and "c".</p>
  8125. <div class="refsect3">
  8126. <a name="id-1.1.90.2.276.8"></a><h4>Parameters</h4>
  8127. <div class="informaltable"><table>
  8128. <tr>
  8129. <td class="parameter_name"><p>pattern</p></td>
  8130. <td class="parameter_description">
  8131. <p>the regular expression</p>
  8132. <p>Passed as <code class="code">pattern</code></p>
  8133. </td>
  8134. </tr>
  8135. <tr>
  8136. <td class="parameter_name"><p>string</p></td>
  8137. <td class="parameter_description">
  8138. <p>the string to scan for matches</p>
  8139. <p>Passed as <code class="code">string</code></p>
  8140. </td>
  8141. </tr>
  8142. <tr>
  8143. <td class="parameter_name"><p>compile_options</p></td>
  8144. <td class="parameter_description">
  8145. <p>compile options for the regular expression, or 0</p>
  8146. <p>Passed as <code class="code">compile-options</code></p>
  8147. </td>
  8148. </tr>
  8149. <tr>
  8150. <td class="parameter_name"><p>match_options</p></td>
  8151. <td class="parameter_description">
  8152. <p>match options, or 0</p>
  8153. <p>Passed as <code class="code">match-options</code></p>
  8154. </td>
  8155. </tr>
  8156. </table></div>
  8157. </div>
  8158. </div>
  8159. <div class="refsect2">
  8160. <a name="id-1.1.90.2.277"></a><h3>reload-user-special-dirs-cache</h3>
  8161. <div class="informalexample"><pre class="programlisting">(define-values () (reload-user-special-dirs-cache))
  8162. </pre></div>
  8163. <p>Resets the cache used for <code class="function">g_get_user_special_dir()</code>, so
  8164. that the latest on-disk version is used. Call this only
  8165. if you just changed the data on disk yourself.
  8166. </p>
  8167. <p>Due to thread safety issues this may cause leaking of strings
  8168. that were previously returned from <code class="function">g_get_user_special_dir()</code>
  8169. that can't be freed. We ensure to only leak the data for
  8170. the directories that actually changed value though.</p>
  8171. </div>
  8172. <div class="refsect2">
  8173. <a name="id-1.1.90.2.278"></a><h3>rmdir</h3>
  8174. <div class="informalexample"><pre class="programlisting">(define-values (%return) (rmdir filename))
  8175. </pre></div>
  8176. <p>A wrapper for the POSIX <code class="function">rmdir()</code> function. The <code class="function">rmdir()</code> function
  8177. deletes a directory from the filesystem.
  8178. </p>
  8179. <p>See your C library manual for more details about how <code class="function">rmdir()</code> works
  8180. on your system.</p>
  8181. <div class="refsect3">
  8182. <a name="id-1.1.90.2.278.5"></a><h4>Parameters</h4>
  8183. <div class="informaltable"><table><tr>
  8184. <td class="parameter_name"><p>filename</p></td>
  8185. <td class="parameter_description">
  8186. <p>a pathname in the GLib file name encoding
  8187. (UTF-8 on Windows)</p>
  8188. <p>Passed as <code class="code">filename</code></p>
  8189. </td>
  8190. </tr></table></div>
  8191. </div>
  8192. </div>
  8193. <div class="refsect2">
  8194. <a name="id-1.1.90.2.279"></a><h3>set-application-name</h3>
  8195. <div class="informalexample"><pre class="programlisting">(define-values () (set-application-name application-name))
  8196. </pre></div>
  8197. <p>Sets a human-readable name for the application. This name should be
  8198. localized if possible, and is intended for display to the user.
  8199. Contrast with <code class="function">g_set_prgname()</code>, which sets a non-localized name.
  8200. <code class="function">g_set_prgname()</code> will be called automatically by <code class="function">gtk_init()</code>,
  8201. but <code class="function">g_set_application_name()</code> will not.
  8202. </p>
  8203. <p>Note that for thread safety reasons, this function can only
  8204. be called once.
  8205. </p>
  8206. <p>The application name will be used in contexts such as error messages,
  8207. or when displaying an application's name in the task list.</p>
  8208. <div class="refsect3">
  8209. <a name="id-1.1.90.2.279.6"></a><h4>Parameters</h4>
  8210. <div class="informaltable"><table><tr>
  8211. <td class="parameter_name"><p>application_name</p></td>
  8212. <td class="parameter_description">
  8213. <p>localized name of the application</p>
  8214. <p>Passed as <code class="code">application-name</code></p>
  8215. </td>
  8216. </tr></table></div>
  8217. </div>
  8218. </div>
  8219. <div class="refsect2">
  8220. <a name="id-1.1.90.2.280"></a><h3>set-error-literal</h3>
  8221. <div class="informalexample"><pre class="programlisting">(define-values (err) (set-error-literal domain code message))
  8222. </pre></div>
  8223. <p>Does nothing if <em class="parameter"><code>err</code></em> is <code class="constant">NULL</code>; if <em class="parameter"><code>err</code></em> is non-<code class="constant">NULL</code>, then *<em class="parameter"><code>err</code></em>
  8224. must be <code class="constant">NULL</code>. A new <span class="type">GError</span> is created and assigned to *<em class="parameter"><code>err</code></em>.
  8225. Unlike <code class="function">g_set_error()</code>, <em class="parameter"><code>message</code></em> is not a <code class="function">printf()</code>-style format string.
  8226. Use this function if <em class="parameter"><code>message</code></em> contains text you don't have control over,
  8227. that could include <code class="function">printf()</code> escape sequences.</p>
  8228. <div class="refsect3">
  8229. <a name="id-1.1.90.2.280.4"></a><h4>Parameters</h4>
  8230. <div class="informaltable"><table>
  8231. <tr>
  8232. <td class="parameter_name"><p>err</p></td>
  8233. <td class="parameter_description">
  8234. <p>a return location for a <span class="type">GError</span></p>
  8235. <p>Passed as <code class="code">err</code></p>
  8236. </td>
  8237. </tr>
  8238. <tr>
  8239. <td class="parameter_name"><p>domain</p></td>
  8240. <td class="parameter_description">
  8241. <p>error domain</p>
  8242. <p>Passed as <code class="code">domain</code></p>
  8243. </td>
  8244. </tr>
  8245. <tr>
  8246. <td class="parameter_name"><p>code</p></td>
  8247. <td class="parameter_description">
  8248. <p>error code</p>
  8249. <p>Passed as <code class="code">code</code></p>
  8250. </td>
  8251. </tr>
  8252. <tr>
  8253. <td class="parameter_name"><p>message</p></td>
  8254. <td class="parameter_description">
  8255. <p>error message</p>
  8256. <p>Passed as <code class="code">message</code></p>
  8257. </td>
  8258. </tr>
  8259. </table></div>
  8260. </div>
  8261. </div>
  8262. <div class="refsect2">
  8263. <a name="id-1.1.90.2.281"></a><h3>set-prgname</h3>
  8264. <div class="informalexample"><pre class="programlisting">(define-values () (set-prgname prgname))
  8265. </pre></div>
  8266. <p>Sets the name of the program. This name should not be localized,
  8267. in contrast to <code class="function">g_set_application_name()</code>.
  8268. </p>
  8269. <p>If you are using <span class="type">GApplication</span> the program name is set in
  8270. <code class="function">g_application_run()</code>. In case of GDK or GTK+ it is set in
  8271. <code class="function">gdk_init()</code>, which is called by <code class="function">gtk_init()</code> and the
  8272. <span class="type">“startup”</span> handler. The program name is found by
  8273. taking the last component of <em class="parameter"><code>argv</code></em>[0].
  8274. </p>
  8275. <p>Note that for thread-safety reasons this function can only be called once.</p>
  8276. <div class="refsect3">
  8277. <a name="id-1.1.90.2.281.6"></a><h4>Parameters</h4>
  8278. <div class="informaltable"><table><tr>
  8279. <td class="parameter_name"><p>prgname</p></td>
  8280. <td class="parameter_description">
  8281. <p>the name of the program.</p>
  8282. <p>Passed as <code class="code">prgname</code></p>
  8283. </td>
  8284. </tr></table></div>
  8285. </div>
  8286. </div>
  8287. <div class="refsect2">
  8288. <a name="id-1.1.90.2.282"></a><h3>setenv?</h3>
  8289. <div class="informalexample"><pre class="programlisting">(define-values (%return) (setenv? variable value overwrite))
  8290. </pre></div>
  8291. <p>Sets an environment variable. On UNIX, both the variable's name and
  8292. value can be arbitrary byte strings, except that the variable's name
  8293. cannot contain '='. On Windows, they should be in UTF-8.
  8294. </p>
  8295. <p>Note that on some systems, when variables are overwritten, the memory
  8296. used for the previous variables and its value isn't reclaimed.
  8297. </p>
  8298. <p>You should be mindful of the fact that environment variable handling
  8299. in UNIX is not thread-safe, and your program may crash if one thread
  8300. calls <code class="function">g_setenv()</code> while another thread is calling <code class="function">getenv()</code>. (And note
  8301. that many functions, such as <code class="function">gettext()</code>, call <code class="function">getenv()</code> internally.)
  8302. This function is only safe to use at the very start of your program,
  8303. before creating any other threads (or creating objects that create
  8304. worker threads of their own).
  8305. </p>
  8306. <p>If you need to set up the environment for a child process, you can
  8307. use <code class="function">g_get_environ()</code> to get an environment array, modify that with
  8308. <code class="function">g_environ_setenv()</code> and <code class="function">g_environ_unsetenv()</code>, and then pass that
  8309. array directly to <code class="function">execvpe()</code>, <code class="function">g_spawn_async()</code>, or the like.</p>
  8310. <div class="refsect3">
  8311. <a name="id-1.1.90.2.282.7"></a><h4>Parameters</h4>
  8312. <div class="informaltable"><table>
  8313. <tr>
  8314. <td class="parameter_name"><p>variable</p></td>
  8315. <td class="parameter_description">
  8316. <p>the environment variable to set, must not
  8317. contain '='.</p>
  8318. <p>Passed as <code class="code">variable</code></p>
  8319. </td>
  8320. </tr>
  8321. <tr>
  8322. <td class="parameter_name"><p>value</p></td>
  8323. <td class="parameter_description">
  8324. <p>the value for to set the variable to.</p>
  8325. <p>Passed as <code class="code">value</code></p>
  8326. </td>
  8327. </tr>
  8328. <tr>
  8329. <td class="parameter_name"><p>overwrite</p></td>
  8330. <td class="parameter_description">
  8331. <p>whether to change the variable if it already exists.</p>
  8332. <p>Passed as <code class="code">overwrite</code></p>
  8333. </td>
  8334. </tr>
  8335. </table></div>
  8336. </div>
  8337. </div>
  8338. <div class="refsect2">
  8339. <a name="id-1.1.90.2.283"></a><h3>shell-error-quark</h3>
  8340. <div class="informalexample"><pre class="programlisting">(define-values (%return) (shell-error-quark))
  8341. </pre></div>
  8342. <p>Undocumented</p>
  8343. </div>
  8344. <div class="refsect2">
  8345. <a name="id-1.1.90.2.284"></a><h3>shell-parse-argv</h3>
  8346. <div class="informalexample"><pre class="programlisting">(define-values (%return argcp argvp) (shell-parse-argv command-line))
  8347. </pre></div>
  8348. <p>Parses a command line into an argument vector, in much the same way
  8349. the shell would, but without many of the expansions the shell would
  8350. perform (variable expansion, globs, operators, filename expansion,
  8351. etc. are not supported). The results are defined to be the same as
  8352. those you would get from a UNIX98 /bin/sh, as long as the input
  8353. contains none of the unsupported shell expansions. If the input
  8354. does contain such expansions, they are passed through
  8355. literally. Possible errors are those from the <span class="type">G_SHELL_ERROR</span>
  8356. domain. Free the returned vector with <code class="function">g_strfreev()</code>.</p>
  8357. <div class="refsect3">
  8358. <a name="id-1.1.90.2.284.4"></a><h4>Parameters</h4>
  8359. <div class="informaltable"><table>
  8360. <tr>
  8361. <td class="parameter_name"><p>command_line</p></td>
  8362. <td class="parameter_description">
  8363. <p>command line to parse</p>
  8364. <p>Passed as <code class="code">command-line</code></p>
  8365. </td>
  8366. </tr>
  8367. <tr>
  8368. <td class="parameter_name"><p>argcp</p></td>
  8369. <td class="parameter_description">
  8370. <p>return location for number of args</p>
  8371. <p>Inferred from <code class="code">argvp</code></p>
  8372. </td>
  8373. </tr>
  8374. <tr>
  8375. <td class="parameter_name"><p>argvp</p></td>
  8376. <td class="parameter_description">
  8377. <p>
  8378. </p>
  8379. <p>return location for array of args</p>
  8380. <p>Passed as <code class="code">argvp</code></p>
  8381. </td>
  8382. </tr>
  8383. </table></div>
  8384. </div>
  8385. </div>
  8386. <div class="refsect2">
  8387. <a name="id-1.1.90.2.285"></a><h3>shell-quote</h3>
  8388. <div class="informalexample"><pre class="programlisting">(define-values (%return) (shell-quote unquoted-string))
  8389. </pre></div>
  8390. <p>Quotes a string so that the shell (/bin/sh) will interpret the
  8391. quoted string to mean <em class="parameter"><code>unquoted_string</code></em>. If you pass a filename to
  8392. the shell, for example, you should first quote it with this
  8393. function. The return value must be freed with <code class="function">g_free()</code>. The
  8394. quoting style used is undefined (single or double quotes may be
  8395. used).</p>
  8396. <div class="refsect3">
  8397. <a name="id-1.1.90.2.285.4"></a><h4>Parameters</h4>
  8398. <div class="informaltable"><table><tr>
  8399. <td class="parameter_name"><p>unquoted_string</p></td>
  8400. <td class="parameter_description">
  8401. <p>a literal string</p>
  8402. <p>Passed as <code class="code">unquoted-string</code></p>
  8403. </td>
  8404. </tr></table></div>
  8405. </div>
  8406. </div>
  8407. <div class="refsect2">
  8408. <a name="id-1.1.90.2.286"></a><h3>shell-unquote</h3>
  8409. <div class="informalexample"><pre class="programlisting">(define-values (%return) (shell-unquote quoted-string))
  8410. </pre></div>
  8411. <p>Unquotes a string as the shell (/bin/sh) would. Only handles
  8412. quotes; if a string contains file globs, arithmetic operators,
  8413. variables, backticks, redirections, or other special-to-the-shell
  8414. features, the result will be different from the result a real shell
  8415. would produce (the variables, backticks, etc. will be passed
  8416. through literally instead of being expanded). This function is
  8417. guaranteed to succeed if applied to the result of
  8418. <code class="function">g_shell_quote()</code>. If it fails, it returns <code class="constant">NULL</code> and sets the
  8419. error. The <em class="parameter"><code>quoted_string</code></em> need not actually contain quoted or
  8420. escaped text; <code class="function">g_shell_unquote()</code> simply goes through the string and
  8421. unquotes/unescapes anything that the shell would. Both single and
  8422. double quotes are handled, as are escapes including escaped
  8423. newlines. The return value must be freed with <code class="function">g_free()</code>. Possible
  8424. errors are in the <span class="type">G_SHELL_ERROR</span> domain.
  8425. </p>
  8426. <p>Shell quoting rules are a bit strange. Single quotes preserve the
  8427. literal string exactly. escape sequences are not allowed; not even
  8428. \' - if you want a ' in the quoted text, you have to do something
  8429. like 'foo'\''bar'. Double quotes allow $, `, ", \, and newline to
  8430. be escaped with backslash. Otherwise double quotes preserve things
  8431. literally.</p>
  8432. <div class="refsect3">
  8433. <a name="id-1.1.90.2.286.5"></a><h4>Parameters</h4>
  8434. <div class="informaltable"><table><tr>
  8435. <td class="parameter_name"><p>quoted_string</p></td>
  8436. <td class="parameter_description">
  8437. <p>shell-quoted string</p>
  8438. <p>Passed as <code class="code">quoted-string</code></p>
  8439. </td>
  8440. </tr></table></div>
  8441. </div>
  8442. </div>
  8443. <div class="refsect2">
  8444. <a name="id-1.1.90.2.287"></a><h3>slice-alloc</h3>
  8445. <div class="informalexample"><pre class="programlisting">(define-values (%return) (slice-alloc block-size))
  8446. </pre></div>
  8447. <p>Allocates a block of memory from the slice allocator.
  8448. The block address handed out can be expected to be aligned
  8449. to at least 1 * sizeof (void*),
  8450. though in general slices are 2 * sizeof (void*) bytes aligned,
  8451. if a <code class="function">malloc()</code> fallback implementation is used instead,
  8452. the alignment may be reduced in a libc dependent fashion.
  8453. Note that the underlying slice allocation mechanism can
  8454. be changed with the [<code class="code">G_SLICE=always-malloc</code>][G_SLICE]
  8455. environment variable.</p>
  8456. <div class="refsect3">
  8457. <a name="id-1.1.90.2.287.4"></a><h4>Parameters</h4>
  8458. <div class="informaltable"><table><tr>
  8459. <td class="parameter_name"><p>block_size</p></td>
  8460. <td class="parameter_description">
  8461. <p>the number of bytes to allocate</p>
  8462. <p>Passed as <code class="code">block-size</code></p>
  8463. </td>
  8464. </tr></table></div>
  8465. </div>
  8466. </div>
  8467. <div class="refsect2">
  8468. <a name="id-1.1.90.2.288"></a><h3>slice-alloc0</h3>
  8469. <div class="informalexample"><pre class="programlisting">(define-values (%return) (slice-alloc0 block-size))
  8470. </pre></div>
  8471. <p>Allocates a block of memory via <code class="function">g_slice_alloc()</code> and initializes
  8472. the returned memory to 0. Note that the underlying slice allocation
  8473. mechanism can be changed with the [<code class="code">G_SLICE=always-malloc</code>][G_SLICE]
  8474. environment variable.</p>
  8475. <div class="refsect3">
  8476. <a name="id-1.1.90.2.288.4"></a><h4>Parameters</h4>
  8477. <div class="informaltable"><table><tr>
  8478. <td class="parameter_name"><p>block_size</p></td>
  8479. <td class="parameter_description">
  8480. <p>the number of bytes to allocate</p>
  8481. <p>Passed as <code class="code">block-size</code></p>
  8482. </td>
  8483. </tr></table></div>
  8484. </div>
  8485. </div>
  8486. <div class="refsect2">
  8487. <a name="id-1.1.90.2.289"></a><h3>slice-copy</h3>
  8488. <div class="informalexample"><pre class="programlisting">(define-values (%return) (slice-copy block-size mem-block))
  8489. </pre></div>
  8490. <p>Allocates a block of memory from the slice allocator
  8491. and copies <em class="parameter"><code>block_size</code></em> bytes into it from <em class="parameter"><code>mem_block</code></em>.
  8492. </p>
  8493. <p><em class="parameter"><code>mem_block</code></em> must be non-<code class="constant">NULL</code> if <em class="parameter"><code>block_size</code></em> is non-zero.</p>
  8494. <div class="refsect3">
  8495. <a name="id-1.1.90.2.289.5"></a><h4>Parameters</h4>
  8496. <div class="informaltable"><table>
  8497. <tr>
  8498. <td class="parameter_name"><p>block_size</p></td>
  8499. <td class="parameter_description">
  8500. <p>the number of bytes to allocate</p>
  8501. <p>Passed as <code class="code">block-size</code></p>
  8502. </td>
  8503. </tr>
  8504. <tr>
  8505. <td class="parameter_name"><p>mem_block</p></td>
  8506. <td class="parameter_description">
  8507. <p>the memory to copy</p>
  8508. <p>Passed as <code class="code">mem-block</code></p>
  8509. </td>
  8510. </tr>
  8511. </table></div>
  8512. </div>
  8513. </div>
  8514. <div class="refsect2">
  8515. <a name="id-1.1.90.2.290"></a><h3>slice-free1</h3>
  8516. <div class="informalexample"><pre class="programlisting">(define-values () (slice-free1 block-size mem-block))
  8517. </pre></div>
  8518. <p>Frees a block of memory.
  8519. </p>
  8520. <p>The memory must have been allocated via <code class="function">g_slice_alloc()</code> or
  8521. <code class="function">g_slice_alloc0()</code> and the <em class="parameter"><code>block_size</code></em> has to match the size
  8522. specified upon allocation. Note that the exact release behaviour
  8523. can be changed with the [<code class="code">G_DEBUG=gc-friendly</code>][G_DEBUG] environment
  8524. variable, also see [<code class="code">G_SLICE</code>][G_SLICE] for related debugging options.
  8525. </p>
  8526. <p>If <em class="parameter"><code>mem_block</code></em> is <code class="constant">NULL</code>, this function does nothing.</p>
  8527. <div class="refsect3">
  8528. <a name="id-1.1.90.2.290.6"></a><h4>Parameters</h4>
  8529. <div class="informaltable"><table>
  8530. <tr>
  8531. <td class="parameter_name"><p>block_size</p></td>
  8532. <td class="parameter_description">
  8533. <p>the size of the block</p>
  8534. <p>Passed as <code class="code">block-size</code></p>
  8535. </td>
  8536. </tr>
  8537. <tr>
  8538. <td class="parameter_name"><p>mem_block</p></td>
  8539. <td class="parameter_description">
  8540. <p>a pointer to the block to free</p>
  8541. <p>Passed as <code class="code">mem-block</code></p>
  8542. </td>
  8543. </tr>
  8544. </table></div>
  8545. </div>
  8546. </div>
  8547. <div class="refsect2">
  8548. <a name="id-1.1.90.2.291"></a><h3>slice-free-chain-with-offset</h3>
  8549. <div class="informalexample"><pre class="programlisting">(define-values
  8550. ()
  8551. (slice-free-chain-with-offset block-size mem-chain next-offset))
  8552. </pre></div>
  8553. <p>Frees a linked list of memory blocks of structure type <em class="parameter"><code>type</code></em>.
  8554. </p>
  8555. <p>The memory blocks must be equal-sized, allocated via
  8556. <code class="function">g_slice_alloc()</code> or <code class="function">g_slice_alloc0()</code> and linked together by a
  8557. <em class="parameter"><code>next</code></em> pointer (similar to <span class="type">GSList</span>). The offset of the <em class="parameter"><code>next</code></em>
  8558. field in each block is passed as third argument.
  8559. Note that the exact release behaviour can be changed with the
  8560. [<code class="code">G_DEBUG=gc-friendly</code>][G_DEBUG] environment variable, also see
  8561. [<code class="code">G_SLICE</code>][G_SLICE] for related debugging options.
  8562. </p>
  8563. <p>If <em class="parameter"><code>mem_chain</code></em> is <code class="constant">NULL</code>, this function does nothing.</p>
  8564. <div class="refsect3">
  8565. <a name="id-1.1.90.2.291.6"></a><h4>Parameters</h4>
  8566. <div class="informaltable"><table>
  8567. <tr>
  8568. <td class="parameter_name"><p>block_size</p></td>
  8569. <td class="parameter_description">
  8570. <p>the size of the blocks</p>
  8571. <p>Passed as <code class="code">block-size</code></p>
  8572. </td>
  8573. </tr>
  8574. <tr>
  8575. <td class="parameter_name"><p>mem_chain</p></td>
  8576. <td class="parameter_description">
  8577. <p>a pointer to the first block of the chain</p>
  8578. <p>Passed as <code class="code">mem-chain</code></p>
  8579. </td>
  8580. </tr>
  8581. <tr>
  8582. <td class="parameter_name"><p>next_offset</p></td>
  8583. <td class="parameter_description">
  8584. <p>the offset of the <em class="parameter"><code>next</code></em> field in the blocks</p>
  8585. <p>Passed as <code class="code">next-offset</code></p>
  8586. </td>
  8587. </tr>
  8588. </table></div>
  8589. </div>
  8590. </div>
  8591. <div class="refsect2">
  8592. <a name="id-1.1.90.2.292"></a><h3>slice-get-config</h3>
  8593. <div class="informalexample"><pre class="programlisting">(define-values (%return) (slice-get-config ckey))
  8594. </pre></div>
  8595. <p>Undocumented</p>
  8596. <div class="refsect3">
  8597. <a name="id-1.1.90.2.292.4"></a><h4>Parameters</h4>
  8598. <div class="informaltable"><table><tr>
  8599. <td class="parameter_name"><p>ckey</p></td>
  8600. <td class="parameter_description">
  8601. <p></p>
  8602. <p>Passed as <code class="code">ckey</code></p>
  8603. </td>
  8604. </tr></table></div>
  8605. </div>
  8606. </div>
  8607. <div class="refsect2">
  8608. <a name="id-1.1.90.2.293"></a><h3>slice-get-config-state</h3>
  8609. <div class="informalexample"><pre class="programlisting">(define-values (%return) (slice-get-config-state ckey address n-values))
  8610. </pre></div>
  8611. <p>Undocumented</p>
  8612. <div class="refsect3">
  8613. <a name="id-1.1.90.2.293.4"></a><h4>Parameters</h4>
  8614. <div class="informaltable"><table>
  8615. <tr>
  8616. <td class="parameter_name"><p>ckey</p></td>
  8617. <td class="parameter_description">
  8618. <p></p>
  8619. <p>Passed as <code class="code">ckey</code></p>
  8620. </td>
  8621. </tr>
  8622. <tr>
  8623. <td class="parameter_name"><p>address</p></td>
  8624. <td class="parameter_description">
  8625. <p></p>
  8626. <p>Passed as <code class="code">address</code></p>
  8627. </td>
  8628. </tr>
  8629. <tr>
  8630. <td class="parameter_name"><p>n_values</p></td>
  8631. <td class="parameter_description">
  8632. <p></p>
  8633. <p>Passed as <code class="code">n-values</code></p>
  8634. </td>
  8635. </tr>
  8636. </table></div>
  8637. </div>
  8638. </div>
  8639. <div class="refsect2">
  8640. <a name="id-1.1.90.2.294"></a><h3>slice-set-config</h3>
  8641. <div class="informalexample"><pre class="programlisting">(define-values () (slice-set-config ckey value))
  8642. </pre></div>
  8643. <p>Undocumented</p>
  8644. <div class="refsect3">
  8645. <a name="id-1.1.90.2.294.4"></a><h4>Parameters</h4>
  8646. <div class="informaltable"><table>
  8647. <tr>
  8648. <td class="parameter_name"><p>ckey</p></td>
  8649. <td class="parameter_description">
  8650. <p></p>
  8651. <p>Passed as <code class="code">ckey</code></p>
  8652. </td>
  8653. </tr>
  8654. <tr>
  8655. <td class="parameter_name"><p>value</p></td>
  8656. <td class="parameter_description">
  8657. <p></p>
  8658. <p>Passed as <code class="code">value</code></p>
  8659. </td>
  8660. </tr>
  8661. </table></div>
  8662. </div>
  8663. </div>
  8664. <div class="refsect2">
  8665. <a name="id-1.1.90.2.295"></a><h3>source-remove?</h3>
  8666. <div class="informalexample"><pre class="programlisting">(define-values (%return) (source-remove? tag))
  8667. </pre></div>
  8668. <p>Removes the source with the given ID from the default main context. You must
  8669. use <code class="function">g_source_destroy()</code> for sources added to a non-default main context.
  8670. </p>
  8671. <p>The ID of a <span class="type">GSource</span> is given by <code class="function">g_source_get_id()</code>, or will be
  8672. returned by the functions <code class="function">g_source_attach()</code>, <code class="function">g_idle_add()</code>,
  8673. <code class="function">g_idle_add_full()</code>, <code class="function">g_timeout_add()</code>, <code class="function">g_timeout_add_full()</code>,
  8674. <code class="function">g_child_watch_add()</code>, <code class="function">g_child_watch_add_full()</code>, <code class="function">g_io_add_watch()</code>, and
  8675. <code class="function">g_io_add_watch_full()</code>.
  8676. </p>
  8677. <p>It is a programmer error to attempt to remove a non-existent source.
  8678. </p>
  8679. <p>More specifically: source IDs can be reissued after a source has been
  8680. destroyed and therefore it is never valid to use this function with a
  8681. source ID which may have already been removed. An example is when
  8682. scheduling an idle to run in another thread with <code class="function">g_idle_add()</code>: the
  8683. idle may already have run and been removed by the time this function
  8684. is called on its (now invalid) source ID. This source ID may have
  8685. been reissued, leading to the operation being performed against the
  8686. wrong source.</p>
  8687. <div class="refsect3">
  8688. <a name="id-1.1.90.2.295.7"></a><h4>Parameters</h4>
  8689. <div class="informaltable"><table><tr>
  8690. <td class="parameter_name"><p>tag</p></td>
  8691. <td class="parameter_description">
  8692. <p>the ID of the source to remove.</p>
  8693. <p>Passed as <code class="code">tag</code></p>
  8694. </td>
  8695. </tr></table></div>
  8696. </div>
  8697. </div>
  8698. <div class="refsect2">
  8699. <a name="id-1.1.90.2.296"></a><h3>source-remove-by-user-data?</h3>
  8700. <div class="informalexample"><pre class="programlisting">(define-values (%return) (source-remove-by-user-data? user-data))
  8701. </pre></div>
  8702. <p>Removes a source from the default main loop context given the user
  8703. data for the callback. If multiple sources exist with the same user
  8704. data, only one will be destroyed.</p>
  8705. <div class="refsect3">
  8706. <a name="id-1.1.90.2.296.4"></a><h4>Parameters</h4>
  8707. <div class="informaltable"><table><tr>
  8708. <td class="parameter_name"><p>user_data</p></td>
  8709. <td class="parameter_description">
  8710. <p>the user_data for the callback.</p>
  8711. <p>Passed as <code class="code">user-data</code></p>
  8712. </td>
  8713. </tr></table></div>
  8714. </div>
  8715. </div>
  8716. <div class="refsect2">
  8717. <a name="id-1.1.90.2.297"></a><h3>source-set-name-by-id</h3>
  8718. <div class="informalexample"><pre class="programlisting">(define-values () (source-set-name-by-id tag name))
  8719. </pre></div>
  8720. <p>Sets the name of a source using its ID.
  8721. </p>
  8722. <p>This is a convenience utility to set source names from the return
  8723. value of <code class="function">g_idle_add()</code>, <code class="function">g_timeout_add()</code>, etc.
  8724. </p>
  8725. <p>It is a programmer error to attempt to set the name of a non-existent
  8726. source.
  8727. </p>
  8728. <p>More specifically: source IDs can be reissued after a source has been
  8729. destroyed and therefore it is never valid to use this function with a
  8730. source ID which may have already been removed. An example is when
  8731. scheduling an idle to run in another thread with <code class="function">g_idle_add()</code>: the
  8732. idle may already have run and been removed by the time this function
  8733. is called on its (now invalid) source ID. This source ID may have
  8734. been reissued, leading to the operation being performed against the
  8735. wrong source.</p>
  8736. <div class="refsect3">
  8737. <a name="id-1.1.90.2.297.7"></a><h4>Parameters</h4>
  8738. <div class="informaltable"><table>
  8739. <tr>
  8740. <td class="parameter_name"><p>tag</p></td>
  8741. <td class="parameter_description">
  8742. <p>a <span class="type">GSource</span> ID</p>
  8743. <p>Passed as <code class="code">tag</code></p>
  8744. </td>
  8745. </tr>
  8746. <tr>
  8747. <td class="parameter_name"><p>name</p></td>
  8748. <td class="parameter_description">
  8749. <p>debug name for the source</p>
  8750. <p>Passed as <code class="code">name</code></p>
  8751. </td>
  8752. </tr>
  8753. </table></div>
  8754. </div>
  8755. </div>
  8756. <div class="refsect2">
  8757. <a name="id-1.1.90.2.298"></a><h3>spaced-primes-closest</h3>
  8758. <div class="informalexample"><pre class="programlisting">(define-values (%return) (spaced-primes-closest num))
  8759. </pre></div>
  8760. <p>Gets the smallest prime number from a built-in array of primes which
  8761. is larger than <em class="parameter"><code>num</code></em>. This is used within GLib to calculate the optimum
  8762. size of a <span class="type">GHashTable</span>.
  8763. </p>
  8764. <p>The built-in array of primes ranges from 11 to 13845163 such that
  8765. each prime is approximately 1.5-2 times the previous prime.</p>
  8766. <div class="refsect3">
  8767. <a name="id-1.1.90.2.298.5"></a><h4>Parameters</h4>
  8768. <div class="informaltable"><table><tr>
  8769. <td class="parameter_name"><p>num</p></td>
  8770. <td class="parameter_description">
  8771. <p>a <span class="type">guint</span></p>
  8772. <p>Passed as <code class="code">num</code></p>
  8773. </td>
  8774. </tr></table></div>
  8775. </div>
  8776. </div>
  8777. <div class="refsect2">
  8778. <a name="id-1.1.90.2.299"></a><h3>spawn-async</h3>
  8779. <div class="informalexample"><pre class="programlisting">(define-values
  8780. (%return child-pid)
  8781. (spawn-async working-directory argv envp flags child-setup user-data))
  8782. </pre></div>
  8783. <p>See <code class="function">g_spawn_async_with_pipes()</code> for a full description; this function
  8784. simply calls the <code class="function">g_spawn_async_with_pipes()</code> without any pipes.
  8785. </p>
  8786. <p>You should call <code class="function">g_spawn_close_pid()</code> on the returned child process
  8787. reference when you don't need it any more.
  8788. </p>
  8789. <p>If you are writing a GTK+ application, and the program you are spawning is a
  8790. graphical application too, then to ensure that the spawned program opens its
  8791. windows on the right screen, you may want to use <span class="type">GdkAppLaunchContext</span>,
  8792. <span class="type">GAppLaunchContext</span>, or set the <code class="constant">DISPLAY</code> environment variable.
  8793. </p>
  8794. <p>Note that the returned <em class="parameter"><code>child_pid</code></em> on Windows is a handle to the child
  8795. process and not its identifier. Process handles and process identifiers
  8796. are different concepts on Windows.</p>
  8797. <div class="refsect3">
  8798. <a name="id-1.1.90.2.299.7"></a><h4>Parameters</h4>
  8799. <div class="informaltable"><table>
  8800. <tr>
  8801. <td class="parameter_name"><p>working_directory</p></td>
  8802. <td class="parameter_description">
  8803. <p>child's current working
  8804. directory, or <code class="constant">NULL</code> to inherit parent's</p>
  8805. <p>Passed as <code class="code">working-directory</code></p>
  8806. </td>
  8807. </tr>
  8808. <tr>
  8809. <td class="parameter_name"><p>argv</p></td>
  8810. <td class="parameter_description">
  8811. <p>
  8812. </p>
  8813. <p>child's argument vector</p>
  8814. <p>Passed as <code class="code">argv</code></p>
  8815. </td>
  8816. </tr>
  8817. <tr>
  8818. <td class="parameter_name"><p>envp</p></td>
  8819. <td class="parameter_description">
  8820. <p>
  8821. </p>
  8822. <p>child's environment, or <code class="constant">NULL</code> to inherit parent's</p>
  8823. <p>Passed as <code class="code">envp</code></p>
  8824. </td>
  8825. </tr>
  8826. <tr>
  8827. <td class="parameter_name"><p>flags</p></td>
  8828. <td class="parameter_description">
  8829. <p>flags from <span class="type">GSpawnFlags</span></p>
  8830. <p>Passed as <code class="code">flags</code></p>
  8831. </td>
  8832. </tr>
  8833. <tr>
  8834. <td class="parameter_name"><p>child_setup</p></td>
  8835. <td class="parameter_description">
  8836. <p>function to run in the child just before <code class="function">exec()</code></p>
  8837. <p>Passed as <code class="code">child-setup</code></p>
  8838. </td>
  8839. </tr>
  8840. <tr>
  8841. <td class="parameter_name"><p>user_data</p></td>
  8842. <td class="parameter_description">
  8843. <p>user data for <em class="parameter"><code>child_setup</code></em></p>
  8844. <p>Passed as <code class="code">user-data</code></p>
  8845. </td>
  8846. </tr>
  8847. <tr>
  8848. <td class="parameter_name"><p>child_pid</p></td>
  8849. <td class="parameter_description">
  8850. <p>return location for child process reference, or <code class="constant">NULL</code></p>
  8851. <p>Passed as <code class="code">child-pid</code></p>
  8852. </td>
  8853. </tr>
  8854. </table></div>
  8855. </div>
  8856. </div>
  8857. <div class="refsect2">
  8858. <a name="id-1.1.90.2.300"></a><h3>spawn-async-with-fds</h3>
  8859. <div class="informalexample"><pre class="programlisting">(define-values
  8860. (%return child-pid)
  8861. (spawn-async-with-fds
  8862. working-directory
  8863. argv
  8864. envp
  8865. flags
  8866. child-setup
  8867. user-data
  8868. stdin-fd
  8869. stdout-fd
  8870. stderr-fd))
  8871. </pre></div>
  8872. <p>Identical to <code class="function">g_spawn_async_with_pipes()</code> but instead of
  8873. creating pipes for the stdin/stdout/stderr, you can pass existing
  8874. file descriptors into this function through the <em class="parameter"><code>stdin_fd</code></em>,
  8875. <em class="parameter"><code>stdout_fd</code></em> and <em class="parameter"><code>stderr_fd</code></em> parameters. The following <em class="parameter"><code>flags</code></em>
  8876. also have their behaviour slightly tweaked as a result:
  8877. </p>
  8878. <p><code class="constant">G_SPAWN_STDOUT_TO_DEV_NULL</code> means that the child's standard output
  8879. will be discarded, instead of going to the same location as the parent's
  8880. standard output. If you use this flag, <em class="parameter"><code>standard_output</code></em> must be -1.
  8881. <code class="constant">G_SPAWN_STDERR_TO_DEV_NULL</code> means that the child's standard error
  8882. will be discarded, instead of going to the same location as the parent's
  8883. standard error. If you use this flag, <em class="parameter"><code>standard_error</code></em> must be -1.
  8884. <code class="constant">G_SPAWN_CHILD_INHERITS_STDIN</code> means that the child will inherit the parent's
  8885. standard input (by default, the child's standard input is attached to
  8886. /dev/null). If you use this flag, <em class="parameter"><code>standard_input</code></em> must be -1.
  8887. </p>
  8888. <p>It is valid to pass the same fd in multiple parameters (e.g. you can pass
  8889. a single fd for both stdout and stderr).</p>
  8890. <div class="refsect3">
  8891. <a name="id-1.1.90.2.300.6"></a><h4>Parameters</h4>
  8892. <div class="informaltable"><table>
  8893. <tr>
  8894. <td class="parameter_name"><p>working_directory</p></td>
  8895. <td class="parameter_description">
  8896. <p>child's current working directory, or <code class="constant">NULL</code> to inherit parent's, in the GLib file name encoding</p>
  8897. <p>Passed as <code class="code">working-directory</code></p>
  8898. </td>
  8899. </tr>
  8900. <tr>
  8901. <td class="parameter_name"><p>argv</p></td>
  8902. <td class="parameter_description">
  8903. <p>child's argument vector, in the GLib file name encoding</p>
  8904. <p>Passed as <code class="code">argv</code></p>
  8905. </td>
  8906. </tr>
  8907. <tr>
  8908. <td class="parameter_name"><p>envp</p></td>
  8909. <td class="parameter_description">
  8910. <p>child's environment, or <code class="constant">NULL</code> to inherit parent's, in the GLib file name encoding</p>
  8911. <p>Passed as <code class="code">envp</code></p>
  8912. </td>
  8913. </tr>
  8914. <tr>
  8915. <td class="parameter_name"><p>flags</p></td>
  8916. <td class="parameter_description">
  8917. <p>flags from <span class="type">GSpawnFlags</span></p>
  8918. <p>Passed as <code class="code">flags</code></p>
  8919. </td>
  8920. </tr>
  8921. <tr>
  8922. <td class="parameter_name"><p>child_setup</p></td>
  8923. <td class="parameter_description">
  8924. <p>function to run in the child just before <code class="function">exec()</code></p>
  8925. <p>Passed as <code class="code">child-setup</code></p>
  8926. </td>
  8927. </tr>
  8928. <tr>
  8929. <td class="parameter_name"><p>user_data</p></td>
  8930. <td class="parameter_description">
  8931. <p>user data for <em class="parameter"><code>child_setup</code></em></p>
  8932. <p>Passed as <code class="code">user-data</code></p>
  8933. </td>
  8934. </tr>
  8935. <tr>
  8936. <td class="parameter_name"><p>child_pid</p></td>
  8937. <td class="parameter_description">
  8938. <p>return location for child process ID, or <code class="constant">NULL</code></p>
  8939. <p>Passed as <code class="code">child-pid</code></p>
  8940. </td>
  8941. </tr>
  8942. <tr>
  8943. <td class="parameter_name"><p>stdin_fd</p></td>
  8944. <td class="parameter_description">
  8945. <p>file descriptor to use for child's stdin, or -1</p>
  8946. <p>Passed as <code class="code">stdin-fd</code></p>
  8947. </td>
  8948. </tr>
  8949. <tr>
  8950. <td class="parameter_name"><p>stdout_fd</p></td>
  8951. <td class="parameter_description">
  8952. <p>file descriptor to use for child's stdout, or -1</p>
  8953. <p>Passed as <code class="code">stdout-fd</code></p>
  8954. </td>
  8955. </tr>
  8956. <tr>
  8957. <td class="parameter_name"><p>stderr_fd</p></td>
  8958. <td class="parameter_description">
  8959. <p>file descriptor to use for child's stderr, or -1</p>
  8960. <p>Passed as <code class="code">stderr-fd</code></p>
  8961. </td>
  8962. </tr>
  8963. </table></div>
  8964. </div>
  8965. </div>
  8966. <div class="refsect2">
  8967. <a name="id-1.1.90.2.301"></a><h3>spawn-async-with-pipes</h3>
  8968. <div class="informalexample"><pre class="programlisting">(define-values
  8969. (%return child-pid standard-input standard-output standard-error)
  8970. (spawn-async-with-pipes
  8971. working-directory
  8972. argv
  8973. envp
  8974. flags
  8975. child-setup
  8976. user-data))
  8977. </pre></div>
  8978. <p>Executes a child program asynchronously (your program will not
  8979. block waiting for the child to exit). The child program is
  8980. specified by the only argument that must be provided, <em class="parameter"><code>argv</code></em>.
  8981. <em class="parameter"><code>argv</code></em> should be a <code class="constant">NULL</code>-terminated array of strings, to be passed
  8982. as the argument vector for the child. The first string in <em class="parameter"><code>argv</code></em>
  8983. is of course the name of the program to execute. By default, the
  8984. name of the program must be a full path. If <em class="parameter"><code>flags</code></em> contains the
  8985. <code class="constant">G_SPAWN_SEARCH_PATH</code> flag, the <code class="code">PATH</code> environment variable is
  8986. used to search for the executable. If <em class="parameter"><code>flags</code></em> contains the
  8987. <code class="constant">G_SPAWN_SEARCH_PATH_FROM_ENVP</code> flag, the <code class="code">PATH</code> variable from
  8988. <em class="parameter"><code>envp</code></em> is used to search for the executable. If both the
  8989. <code class="constant">G_SPAWN_SEARCH_PATH</code> and <code class="constant">G_SPAWN_SEARCH_PATH_FROM_ENVP</code> flags
  8990. are set, the <code class="code">PATH</code> variable from <em class="parameter"><code>envp</code></em> takes precedence over
  8991. the environment variable.
  8992. </p>
  8993. <p>If the program name is not a full path and <code class="constant">G_SPAWN_SEARCH_PATH</code> flag is not
  8994. used, then the program will be run from the current directory (or
  8995. <em class="parameter"><code>working_directory</code></em>, if specified); this might be unexpected or even
  8996. dangerous in some cases when the current directory is world-writable.
  8997. </p>
  8998. <p>On Windows, note that all the string or string vector arguments to
  8999. this function and the other g_spawn*() functions are in UTF-8, the
  9000. GLib file name encoding. Unicode characters that are not part of
  9001. the system codepage passed in these arguments will be correctly
  9002. available in the spawned program only if it uses wide character API
  9003. to retrieve its command line. For C programs built with Microsoft's
  9004. tools it is enough to make the program have a <code class="function">wmain()</code> instead of
  9005. <code class="function">main()</code>. <code class="function">wmain()</code> has a wide character argument vector as parameter.
  9006. </p>
  9007. <p>At least currently, mingw doesn't support <code class="function">wmain()</code>, so if you use
  9008. mingw to develop the spawned program, it should call
  9009. <code class="function">g_win32_get_command_line()</code> to get arguments in UTF-8.
  9010. </p>
  9011. <p>On Windows the low-level child process creation API <code class="function">CreateProcess()</code>
  9012. doesn't use argument vectors, but a command line. The C runtime
  9013. library's spawn*() family of functions (which <code class="function">g_spawn_async_with_pipes()</code>
  9014. eventually calls) paste the argument vector elements together into
  9015. a command line, and the C runtime startup code does a corresponding
  9016. reconstruction of an argument vector from the command line, to be
  9017. passed to <code class="function">main()</code>. Complications arise when you have argument vector
  9018. elements that contain spaces or double quotes. The <code class="code">spawn*()</code> functions
  9019. don't do any quoting or escaping, but on the other hand the startup
  9020. code does do unquoting and unescaping in order to enable receiving
  9021. arguments with embedded spaces or double quotes. To work around this
  9022. asymmetry, <code class="function">g_spawn_async_with_pipes()</code> will do quoting and escaping on
  9023. argument vector elements that need it before calling the C runtime
  9024. <code class="function">spawn()</code> function.
  9025. </p>
  9026. <p>The returned <em class="parameter"><code>child_pid</code></em> on Windows is a handle to the child
  9027. process, not its identifier. Process handles and process
  9028. identifiers are different concepts on Windows.
  9029. </p>
  9030. <p><em class="parameter"><code>envp</code></em> is a <code class="constant">NULL</code>-terminated array of strings, where each string
  9031. has the form <code class="code">KEY=VALUE</code>. This will become the child's environment.
  9032. If <em class="parameter"><code>envp</code></em> is <code class="constant">NULL</code>, the child inherits its parent's environment.
  9033. </p>
  9034. <p><em class="parameter"><code>flags</code></em> should be the bitwise OR of any flags you want to affect the
  9035. function's behaviour. The <code class="constant">G_SPAWN_DO_NOT_REAP_CHILD</code> means that the
  9036. child will not automatically be reaped; you must use a child watch
  9037. (<code class="function">g_child_watch_add()</code>) to be notified about the death of the child process,
  9038. otherwise it will stay around as a zombie process until this process exits.
  9039. Eventually you must call <code class="function">g_spawn_close_pid()</code> on the <em class="parameter"><code>child_pid</code></em>, in order to
  9040. free resources which may be associated with the child process. (On Unix,
  9041. using a child watch is equivalent to calling <code class="function">waitpid()</code> or handling
  9042. the <code class="constant">SIGCHLD</code> signal manually. On Windows, calling <code class="function">g_spawn_close_pid()</code>
  9043. is equivalent to calling <code class="function">CloseHandle()</code> on the process handle returned
  9044. in <em class="parameter"><code>child_pid</code></em>). See <code class="function">g_child_watch_add()</code>.
  9045. </p>
  9046. <p>Open UNIX file descriptors marked as <code class="code">FD_CLOEXEC</code> will be automatically
  9047. closed in the child process. <code class="constant">G_SPAWN_LEAVE_DESCRIPTORS_OPEN</code> means that
  9048. other open file descriptors will be inherited by the child; otherwise all
  9049. descriptors except stdin/stdout/stderr will be closed before calling <code class="function">exec()</code>
  9050. in the child. <code class="constant">G_SPAWN_SEARCH_PATH</code> means that <em class="parameter"><code>argv</code></em>[0] need not be an
  9051. absolute path, it will be looked for in the <code class="code">PATH</code> environment
  9052. variable. <code class="constant">G_SPAWN_SEARCH_PATH_FROM_ENVP</code> means need not be an
  9053. absolute path, it will be looked for in the <code class="code">PATH</code> variable from
  9054. <em class="parameter"><code>envp</code></em>. If both <code class="constant">G_SPAWN_SEARCH_PATH</code> and <code class="constant">G_SPAWN_SEARCH_PATH_FROM_ENVP</code>
  9055. are used, the value from <em class="parameter"><code>envp</code></em> takes precedence over the environment.
  9056. <code class="constant">G_SPAWN_STDOUT_TO_DEV_NULL</code> means that the child's standard output
  9057. will be discarded, instead of going to the same location as the parent's
  9058. standard output. If you use this flag, <em class="parameter"><code>standard_output</code></em> must be <code class="constant">NULL</code>.
  9059. <code class="constant">G_SPAWN_STDERR_TO_DEV_NULL</code> means that the child's standard error
  9060. will be discarded, instead of going to the same location as the parent's
  9061. standard error. If you use this flag, <em class="parameter"><code>standard_error</code></em> must be <code class="constant">NULL</code>.
  9062. <code class="constant">G_SPAWN_CHILD_INHERITS_STDIN</code> means that the child will inherit the parent's
  9063. standard input (by default, the child's standard input is attached to
  9064. <code class="code">/dev/null</code>). If you use this flag, <em class="parameter"><code>standard_input</code></em> must be <code class="constant">NULL</code>.
  9065. <code class="constant">G_SPAWN_FILE_AND_ARGV_ZERO</code> means that the first element of <em class="parameter"><code>argv</code></em> is
  9066. the file to execute, while the remaining elements are the actual
  9067. argument vector to pass to the file. Normally <code class="function">g_spawn_async_with_pipes()</code>
  9068. uses <em class="parameter"><code>argv</code></em>[0] as the file to execute, and passes all of <em class="parameter"><code>argv</code></em> to the child.
  9069. </p>
  9070. <p><em class="parameter"><code>child_setup</code></em> and <em class="parameter"><code>user_data</code></em> are a function and user data. On POSIX
  9071. platforms, the function is called in the child after GLib has
  9072. performed all the setup it plans to perform (including creating
  9073. pipes, closing file descriptors, etc.) but before calling <code class="function">exec()</code>.
  9074. That is, <em class="parameter"><code>child_setup</code></em> is called just before calling <code class="function">exec()</code> in the
  9075. child. Obviously actions taken in this function will only affect
  9076. the child, not the parent.
  9077. </p>
  9078. <p>On Windows, there is no separate <code class="function">fork()</code> and <code class="function">exec()</code> functionality.
  9079. Child processes are created and run with a single API call,
  9080. <code class="function">CreateProcess()</code>. There is no sensible thing <em class="parameter"><code>child_setup</code></em>
  9081. could be used for on Windows so it is ignored and not called.
  9082. </p>
  9083. <p>If non-<code class="constant">NULL</code>, <em class="parameter"><code>child_pid</code></em> will on Unix be filled with the child's
  9084. process ID. You can use the process ID to send signals to the child,
  9085. or to use <code class="function">g_child_watch_add()</code> (or <code class="function">waitpid()</code>) if you specified the
  9086. <code class="constant">G_SPAWN_DO_NOT_REAP_CHILD</code> flag. On Windows, <em class="parameter"><code>child_pid</code></em> will be
  9087. filled with a handle to the child process only if you specified the
  9088. <code class="constant">G_SPAWN_DO_NOT_REAP_CHILD</code> flag. You can then access the child
  9089. process using the Win32 API, for example wait for its termination
  9090. with the WaitFor*() functions, or examine its exit code with
  9091. <code class="function">GetExitCodeProcess()</code>. You should close the handle with <code class="function">CloseHandle()</code>
  9092. or <code class="function">g_spawn_close_pid()</code> when you no longer need it.
  9093. </p>
  9094. <p>If non-<code class="constant">NULL</code>, the <em class="parameter"><code>standard_input</code></em>, <em class="parameter"><code>standard_output</code></em>, <em class="parameter"><code>standard_error</code></em>
  9095. locations will be filled with file descriptors for writing to the child's
  9096. standard input or reading from its standard output or standard error.
  9097. The caller of <code class="function">g_spawn_async_with_pipes()</code> must close these file descriptors
  9098. when they are no longer in use. If these parameters are <code class="constant">NULL</code>, the
  9099. corresponding pipe won't be created.
  9100. </p>
  9101. <p>If <em class="parameter"><code>standard_input</code></em> is <code class="constant">NULL</code>, the child's standard input is attached to
  9102. <code class="code">/dev/null</code> unless <code class="constant">G_SPAWN_CHILD_INHERITS_STDIN</code> is set.
  9103. </p>
  9104. <p>If <em class="parameter"><code>standard_error</code></em> is NULL, the child's standard error goes to the same
  9105. location as the parent's standard error unless <code class="constant">G_SPAWN_STDERR_TO_DEV_NULL</code>
  9106. is set.
  9107. </p>
  9108. <p>If <em class="parameter"><code>standard_output</code></em> is NULL, the child's standard output goes to the same
  9109. location as the parent's standard output unless <code class="constant">G_SPAWN_STDOUT_TO_DEV_NULL</code>
  9110. is set.
  9111. </p>
  9112. <p><em class="parameter"><code>error</code></em> can be <code class="constant">NULL</code> to ignore errors, or non-<code class="constant">NULL</code> to report errors.
  9113. If an error is set, the function returns <code class="constant">FALSE</code>. Errors are reported
  9114. even if they occur in the child (for example if the executable in
  9115. <em class="parameter"><code>argv</code></em>[0] is not found). Typically the <code class="code">message</code> field of returned
  9116. errors should be displayed to users. Possible errors are those from
  9117. the <span class="type">G_SPAWN_ERROR</span> domain.
  9118. </p>
  9119. <p>If an error occurs, <em class="parameter"><code>child_pid</code></em>, <em class="parameter"><code>standard_input</code></em>, <em class="parameter"><code>standard_output</code></em>,
  9120. and <em class="parameter"><code>standard_error</code></em> will not be filled with valid values.
  9121. </p>
  9122. <p>If <em class="parameter"><code>child_pid</code></em> is not <code class="constant">NULL</code> and an error does not occur then the returned
  9123. process reference must be closed using <code class="function">g_spawn_close_pid()</code>.
  9124. </p>
  9125. <p>On modern UNIX platforms, GLib can use an efficient process launching
  9126. codepath driven internally by <code class="function">posix_spawn()</code>. This has the advantage of
  9127. avoiding the fork-time performance costs of cloning the parent process
  9128. address space, and avoiding associated memory overcommit checks that are
  9129. not relevant in the context of immediately executing a distinct process.
  9130. This optimized codepath will be used provided that the following conditions
  9131. are met:
  9132. </p>
  9133. <p>1. <code class="constant">G_SPAWN_DO_NOT_REAP_CHILD</code> is set
  9134. 2. <code class="constant">G_SPAWN_LEAVE_DESCRIPTORS_OPEN</code> is set
  9135. 3. <code class="constant">G_SPAWN_SEARCH_PATH_FROM_ENVP</code> is not set
  9136. 4. <em class="parameter"><code>working_directory</code></em> is <code class="constant">NULL</code>
  9137. 5. <em class="parameter"><code>child_setup</code></em> is <code class="constant">NULL</code>
  9138. 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.
  9139. </p>
  9140. <p>If you are writing a GTK+ application, and the program you are spawning is a
  9141. graphical application too, then to ensure that the spawned program opens its
  9142. windows on the right screen, you may want to use <span class="type">GdkAppLaunchContext</span>,
  9143. <span class="type">GAppLaunchContext</span>, or set the <code class="constant">DISPLAY</code> environment variable.</p>
  9144. <div class="refsect3">
  9145. <a name="id-1.1.90.2.301.25"></a><h4>Parameters</h4>
  9146. <div class="informaltable"><table>
  9147. <tr>
  9148. <td class="parameter_name"><p>working_directory</p></td>
  9149. <td class="parameter_description">
  9150. <p>child's current working
  9151. directory, or <code class="constant">NULL</code> to inherit parent's, in the GLib file name encoding</p>
  9152. <p>Passed as <code class="code">working-directory</code></p>
  9153. </td>
  9154. </tr>
  9155. <tr>
  9156. <td class="parameter_name"><p>argv</p></td>
  9157. <td class="parameter_description">
  9158. <p>child's argument
  9159. vector, in the GLib file name encoding</p>
  9160. <p>Passed as <code class="code">argv</code></p>
  9161. </td>
  9162. </tr>
  9163. <tr>
  9164. <td class="parameter_name"><p>envp</p></td>
  9165. <td class="parameter_description">
  9166. <p>
  9167. </p>
  9168. <p>child's environment, or <code class="constant">NULL</code> to inherit parent's, in the GLib file
  9169. name encoding</p>
  9170. <p>Passed as <code class="code">envp</code></p>
  9171. </td>
  9172. </tr>
  9173. <tr>
  9174. <td class="parameter_name"><p>flags</p></td>
  9175. <td class="parameter_description">
  9176. <p>flags from <span class="type">GSpawnFlags</span></p>
  9177. <p>Passed as <code class="code">flags</code></p>
  9178. </td>
  9179. </tr>
  9180. <tr>
  9181. <td class="parameter_name"><p>child_setup</p></td>
  9182. <td class="parameter_description">
  9183. <p>function to run in the child just before <code class="function">exec()</code></p>
  9184. <p>Passed as <code class="code">child-setup</code></p>
  9185. </td>
  9186. </tr>
  9187. <tr>
  9188. <td class="parameter_name"><p>user_data</p></td>
  9189. <td class="parameter_description">
  9190. <p>user data for <em class="parameter"><code>child_setup</code></em></p>
  9191. <p>Passed as <code class="code">user-data</code></p>
  9192. </td>
  9193. </tr>
  9194. <tr>
  9195. <td class="parameter_name"><p>child_pid</p></td>
  9196. <td class="parameter_description">
  9197. <p>return location for child process ID, or <code class="constant">NULL</code></p>
  9198. <p>Passed as <code class="code">child-pid</code></p>
  9199. </td>
  9200. </tr>
  9201. <tr>
  9202. <td class="parameter_name"><p>standard_input</p></td>
  9203. <td class="parameter_description">
  9204. <p>return location for file descriptor to write to child's stdin, or <code class="constant">NULL</code></p>
  9205. <p>Passed as <code class="code">standard-input</code></p>
  9206. </td>
  9207. </tr>
  9208. <tr>
  9209. <td class="parameter_name"><p>standard_output</p></td>
  9210. <td class="parameter_description">
  9211. <p>return location for file descriptor to read child's stdout, or <code class="constant">NULL</code></p>
  9212. <p>Passed as <code class="code">standard-output</code></p>
  9213. </td>
  9214. </tr>
  9215. <tr>
  9216. <td class="parameter_name"><p>standard_error</p></td>
  9217. <td class="parameter_description">
  9218. <p>return location for file descriptor to read child's stderr, or <code class="constant">NULL</code></p>
  9219. <p>Passed as <code class="code">standard-error</code></p>
  9220. </td>
  9221. </tr>
  9222. </table></div>
  9223. </div>
  9224. </div>
  9225. <div class="refsect2">
  9226. <a name="id-1.1.90.2.302"></a><h3>spawn-check-exit-status?</h3>
  9227. <div class="informalexample"><pre class="programlisting">(define-values (%return) (spawn-check-exit-status? wait-status))
  9228. </pre></div>
  9229. <p>Set <em class="parameter"><code>error</code></em> if <em class="parameter"><code>exit_status</code></em> indicates the child exited abnormally
  9230. (e.g. with a nonzero exit code, or via a fatal signal).
  9231. </p>
  9232. <p>The <code class="function">g_spawn_sync()</code> and <code class="function">g_child_watch_add()</code> family of APIs return an
  9233. exit status for subprocesses encoded in a platform-specific way.
  9234. On Unix, this is guaranteed to be in the same format <code class="function">waitpid()</code> returns,
  9235. and on Windows it is guaranteed to be the result of <code class="function">GetExitCodeProcess()</code>.
  9236. </p>
  9237. <p>Prior to the introduction of this function in GLib 2.34, interpreting
  9238. <em class="parameter"><code>exit_status</code></em> required use of platform-specific APIs, which is problematic
  9239. for software using GLib as a cross-platform layer.
  9240. </p>
  9241. <p>Additionally, many programs simply want to determine whether or not
  9242. the child exited successfully, and either propagate a <span class="type">GError</span> or
  9243. print a message to standard error. In that common case, this function
  9244. can be used. Note that the error message in <em class="parameter"><code>error</code></em> will contain
  9245. human-readable information about the exit status.
  9246. </p>
  9247. <p>The <em class="parameter"><code>domain</code></em> and <em class="parameter"><code>code</code></em> of <em class="parameter"><code>error</code></em> have special semantics in the case
  9248. where the process has an "exit code", as opposed to being killed by
  9249. a signal. On Unix, this happens if <code class="function">WIFEXITED()</code> would be true of
  9250. <em class="parameter"><code>exit_status</code></em>. On Windows, it is always the case.
  9251. </p>
  9252. <p>The special semantics are that the actual exit code will be the
  9253. code set in <em class="parameter"><code>error</code></em>, and the domain will be <code class="constant">G_SPAWN_EXIT_ERROR</code>.
  9254. This allows you to differentiate between different exit codes.
  9255. </p>
  9256. <p>If the process was terminated by some means other than an exit
  9257. status, the domain will be <code class="constant">G_SPAWN_ERROR</code>, and the code will be
  9258. <code class="constant">G_SPAWN_ERROR_FAILED</code>.
  9259. </p>
  9260. <p>This function just offers convenience; you can of course also check
  9261. the available platform via a macro such as <code class="constant">G_OS_UNIX</code>, and use
  9262. <code class="function">WIFEXITED()</code> and <code class="function">WEXITSTATUS()</code> on <em class="parameter"><code>exit_status</code></em> directly. Do not attempt
  9263. to scan or parse the error message string; it may be translated and/or
  9264. change in future versions of GLib.</p>
  9265. <div class="refsect3">
  9266. <a name="id-1.1.90.2.302.11"></a><h4>Parameters</h4>
  9267. <div class="informaltable"><table><tr>
  9268. <td class="parameter_name"><p>wait_status</p></td>
  9269. <td class="parameter_description">
  9270. <p></p>
  9271. <p>Passed as <code class="code">wait-status</code></p>
  9272. </td>
  9273. </tr></table></div>
  9274. </div>
  9275. </div>
  9276. <div class="refsect2">
  9277. <a name="id-1.1.90.2.303"></a><h3>spawn-check-wait-status?</h3>
  9278. <div class="informalexample"><pre class="programlisting">(define-values (%return) (spawn-check-wait-status? wait-status))
  9279. </pre></div>
  9280. <p>Undocumented</p>
  9281. <div class="refsect3">
  9282. <a name="id-1.1.90.2.303.4"></a><h4>Parameters</h4>
  9283. <div class="informaltable"><table><tr>
  9284. <td class="parameter_name"><p>wait_status</p></td>
  9285. <td class="parameter_description">
  9286. <p></p>
  9287. <p>Passed as <code class="code">wait-status</code></p>
  9288. </td>
  9289. </tr></table></div>
  9290. </div>
  9291. </div>
  9292. <div class="refsect2">
  9293. <a name="id-1.1.90.2.304"></a><h3>spawn-close-pid</h3>
  9294. <div class="informalexample"><pre class="programlisting">(define-values () (spawn-close-pid pid))
  9295. </pre></div>
  9296. <p>On some platforms, notably Windows, the <span class="type">GPid</span> type represents a resource
  9297. which must be closed to prevent resource leaking. <code class="function">g_spawn_close_pid()</code>
  9298. is provided for this purpose. It should be used on all platforms, even
  9299. though it doesn't do anything under UNIX.</p>
  9300. <div class="refsect3">
  9301. <a name="id-1.1.90.2.304.4"></a><h4>Parameters</h4>
  9302. <div class="informaltable"><table><tr>
  9303. <td class="parameter_name"><p>pid</p></td>
  9304. <td class="parameter_description">
  9305. <p>The process reference to close</p>
  9306. <p>Passed as <code class="code">pid</code></p>
  9307. </td>
  9308. </tr></table></div>
  9309. </div>
  9310. </div>
  9311. <div class="refsect2">
  9312. <a name="id-1.1.90.2.305"></a><h3>spawn-command-line-async?</h3>
  9313. <div class="informalexample"><pre class="programlisting">(define-values (%return) (spawn-command-line-async? command-line))
  9314. </pre></div>
  9315. <p>A simple version of <code class="function">g_spawn_async()</code> that parses a command line with
  9316. <code class="function">g_shell_parse_argv()</code> and passes it to <code class="function">g_spawn_async()</code>. Runs a
  9317. command line in the background. Unlike <code class="function">g_spawn_async()</code>, the
  9318. <code class="constant">G_SPAWN_SEARCH_PATH</code> flag is enabled, other flags are not. Note
  9319. that <code class="constant">G_SPAWN_SEARCH_PATH</code> can have security implications, so
  9320. consider using <code class="function">g_spawn_async()</code> directly if appropriate. Possible
  9321. errors are those from <code class="function">g_shell_parse_argv()</code> and <code class="function">g_spawn_async()</code>.
  9322. </p>
  9323. <p>The same concerns on Windows apply as for <code class="function">g_spawn_command_line_sync()</code>.</p>
  9324. <div class="refsect3">
  9325. <a name="id-1.1.90.2.305.5"></a><h4>Parameters</h4>
  9326. <div class="informaltable"><table><tr>
  9327. <td class="parameter_name"><p>command_line</p></td>
  9328. <td class="parameter_description">
  9329. <p>a command line</p>
  9330. <p>Passed as <code class="code">command-line</code></p>
  9331. </td>
  9332. </tr></table></div>
  9333. </div>
  9334. </div>
  9335. <div class="refsect2">
  9336. <a name="id-1.1.90.2.306"></a><h3>spawn-command-line-sync</h3>
  9337. <div class="informalexample"><pre class="programlisting">(define-values
  9338. (%return standard-output standard-error)
  9339. (spawn-command-line-sync command-line wait-status))
  9340. </pre></div>
  9341. <p>A simple version of <code class="function">g_spawn_sync()</code> with little-used parameters
  9342. removed, taking a command line instead of an argument vector. See
  9343. <code class="function">g_spawn_sync()</code> for full details. <em class="parameter"><code>command_line</code></em> will be parsed by
  9344. <code class="function">g_shell_parse_argv()</code>. Unlike <code class="function">g_spawn_sync()</code>, the <code class="constant">G_SPAWN_SEARCH_PATH</code> flag
  9345. is enabled. Note that <code class="constant">G_SPAWN_SEARCH_PATH</code> can have security
  9346. implications, so consider using <code class="function">g_spawn_sync()</code> directly if
  9347. appropriate. Possible errors are those from <code class="function">g_spawn_sync()</code> and those
  9348. from <code class="function">g_shell_parse_argv()</code>.
  9349. </p>
  9350. <p>If <em class="parameter"><code>exit_status</code></em> is non-<code class="constant">NULL</code>, the platform-specific exit status of
  9351. the child is stored there; see the documentation of
  9352. <code class="function">g_spawn_check_exit_status()</code> for how to use and interpret this.
  9353. </p>
  9354. <p>On Windows, please note the implications of <code class="function">g_shell_parse_argv()</code>
  9355. parsing <em class="parameter"><code>command_line</code></em>. Parsing is done according to Unix shell rules, not
  9356. Windows command interpreter rules.
  9357. Space is a separator, and backslashes are
  9358. special. Thus you cannot simply pass a <em class="parameter"><code>command_line</code></em> containing
  9359. canonical Windows paths, like "c:\\program files\\app\\app.exe", as
  9360. the backslashes will be eaten, and the space will act as a
  9361. separator. You need to enclose such paths with single quotes, like
  9362. "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'".</p>
  9363. <div class="refsect3">
  9364. <a name="id-1.1.90.2.306.6"></a><h4>Parameters</h4>
  9365. <div class="informaltable"><table>
  9366. <tr>
  9367. <td class="parameter_name"><p>command_line</p></td>
  9368. <td class="parameter_description">
  9369. <p>a command line</p>
  9370. <p>Passed as <code class="code">command-line</code></p>
  9371. </td>
  9372. </tr>
  9373. <tr>
  9374. <td class="parameter_name"><p>standard_output</p></td>
  9375. <td class="parameter_description">
  9376. <p>return location for child output</p>
  9377. <p>Passed as <code class="code">standard-output</code></p>
  9378. </td>
  9379. </tr>
  9380. <tr>
  9381. <td class="parameter_name"><p>standard_error</p></td>
  9382. <td class="parameter_description">
  9383. <p>return location for child errors</p>
  9384. <p>Passed as <code class="code">standard-error</code></p>
  9385. </td>
  9386. </tr>
  9387. <tr>
  9388. <td class="parameter_name"><p>wait_status</p></td>
  9389. <td class="parameter_description">
  9390. <p></p>
  9391. <p>Passed as <code class="code">wait-status</code></p>
  9392. </td>
  9393. </tr>
  9394. </table></div>
  9395. </div>
  9396. </div>
  9397. <div class="refsect2">
  9398. <a name="id-1.1.90.2.307"></a><h3>spawn-error-quark</h3>
  9399. <div class="informalexample"><pre class="programlisting">(define-values (%return) (spawn-error-quark))
  9400. </pre></div>
  9401. <p>Undocumented</p>
  9402. </div>
  9403. <div class="refsect2">
  9404. <a name="id-1.1.90.2.308"></a><h3>spawn-exit-error-quark</h3>
  9405. <div class="informalexample"><pre class="programlisting">(define-values (%return) (spawn-exit-error-quark))
  9406. </pre></div>
  9407. <p>Undocumented</p>
  9408. </div>
  9409. <div class="refsect2">
  9410. <a name="id-1.1.90.2.309"></a><h3>spawn-sync</h3>
  9411. <div class="informalexample"><pre class="programlisting">(define-values
  9412. (%return standard-output standard-error)
  9413. (spawn-sync
  9414. working-directory
  9415. argv
  9416. envp
  9417. flags
  9418. child-setup
  9419. user-data
  9420. wait-status))
  9421. </pre></div>
  9422. <p>Executes a child synchronously (waits for the child to exit before returning).
  9423. All output from the child is stored in <em class="parameter"><code>standard_output</code></em> and <em class="parameter"><code>standard_error</code></em>,
  9424. if those parameters are non-<code class="constant">NULL</code>. Note that you must set the
  9425. <code class="constant">G_SPAWN_STDOUT_TO_DEV_NULL</code> and <code class="constant">G_SPAWN_STDERR_TO_DEV_NULL</code> flags when
  9426. passing <code class="constant">NULL</code> for <em class="parameter"><code>standard_output</code></em> and <em class="parameter"><code>standard_error</code></em>.
  9427. </p>
  9428. <p>If <em class="parameter"><code>exit_status</code></em> is non-<code class="constant">NULL</code>, the platform-specific exit status of
  9429. the child is stored there; see the documentation of
  9430. <code class="function">g_spawn_check_exit_status()</code> for how to use and interpret this.
  9431. Note that it is invalid to pass <code class="constant">G_SPAWN_DO_NOT_REAP_CHILD</code> in
  9432. <em class="parameter"><code>flags</code></em>, and on POSIX platforms, the same restrictions as for
  9433. <code class="function">g_child_watch_source_new()</code> apply.
  9434. </p>
  9435. <p>If an error occurs, no data is returned in <em class="parameter"><code>standard_output</code></em>,
  9436. <em class="parameter"><code>standard_error</code></em>, or <em class="parameter"><code>exit_status</code></em>.
  9437. </p>
  9438. <p>This function calls <code class="function">g_spawn_async_with_pipes()</code> internally; see that
  9439. function for full details on the other parameters and details on
  9440. how these functions work on Windows.</p>
  9441. <div class="refsect3">
  9442. <a name="id-1.1.90.2.309.7"></a><h4>Parameters</h4>
  9443. <div class="informaltable"><table>
  9444. <tr>
  9445. <td class="parameter_name"><p>working_directory</p></td>
  9446. <td class="parameter_description">
  9447. <p>child's current working
  9448. directory, or <code class="constant">NULL</code> to inherit parent's</p>
  9449. <p>Passed as <code class="code">working-directory</code></p>
  9450. </td>
  9451. </tr>
  9452. <tr>
  9453. <td class="parameter_name"><p>argv</p></td>
  9454. <td class="parameter_description">
  9455. <p>
  9456. </p>
  9457. <p>child's argument vector</p>
  9458. <p>Passed as <code class="code">argv</code></p>
  9459. </td>
  9460. </tr>
  9461. <tr>
  9462. <td class="parameter_name"><p>envp</p></td>
  9463. <td class="parameter_description">
  9464. <p>
  9465. </p>
  9466. <p>child's environment, or <code class="constant">NULL</code> to inherit parent's</p>
  9467. <p>Passed as <code class="code">envp</code></p>
  9468. </td>
  9469. </tr>
  9470. <tr>
  9471. <td class="parameter_name"><p>flags</p></td>
  9472. <td class="parameter_description">
  9473. <p>flags from <span class="type">GSpawnFlags</span></p>
  9474. <p>Passed as <code class="code">flags</code></p>
  9475. </td>
  9476. </tr>
  9477. <tr>
  9478. <td class="parameter_name"><p>child_setup</p></td>
  9479. <td class="parameter_description">
  9480. <p>function to run in the child just before <code class="function">exec()</code></p>
  9481. <p>Passed as <code class="code">child-setup</code></p>
  9482. </td>
  9483. </tr>
  9484. <tr>
  9485. <td class="parameter_name"><p>user_data</p></td>
  9486. <td class="parameter_description">
  9487. <p>user data for <em class="parameter"><code>child_setup</code></em></p>
  9488. <p>Passed as <code class="code">user-data</code></p>
  9489. </td>
  9490. </tr>
  9491. <tr>
  9492. <td class="parameter_name"><p>standard_output</p></td>
  9493. <td class="parameter_description">
  9494. <p>return location for child output, or <code class="constant">NULL</code></p>
  9495. <p>Passed as <code class="code">standard-output</code></p>
  9496. </td>
  9497. </tr>
  9498. <tr>
  9499. <td class="parameter_name"><p>standard_error</p></td>
  9500. <td class="parameter_description">
  9501. <p>return location for child error messages, or <code class="constant">NULL</code></p>
  9502. <p>Passed as <code class="code">standard-error</code></p>
  9503. </td>
  9504. </tr>
  9505. <tr>
  9506. <td class="parameter_name"><p>wait_status</p></td>
  9507. <td class="parameter_description">
  9508. <p></p>
  9509. <p>Passed as <code class="code">wait-status</code></p>
  9510. </td>
  9511. </tr>
  9512. </table></div>
  9513. </div>
  9514. </div>
  9515. <div class="refsect2">
  9516. <a name="id-1.1.90.2.310"></a><h3>stpcpy</h3>
  9517. <div class="informalexample"><pre class="programlisting">(define-values (%return) (stpcpy dest src))
  9518. </pre></div>
  9519. <p>Copies a nul-terminated string into the dest buffer, include the
  9520. trailing nul, and return a pointer to the trailing nul byte.
  9521. This is useful for concatenating multiple strings together
  9522. without having to repeatedly scan for the end.</p>
  9523. <div class="refsect3">
  9524. <a name="id-1.1.90.2.310.4"></a><h4>Parameters</h4>
  9525. <div class="informaltable"><table>
  9526. <tr>
  9527. <td class="parameter_name"><p>dest</p></td>
  9528. <td class="parameter_description">
  9529. <p>destination buffer.</p>
  9530. <p>Passed as <code class="code">dest</code></p>
  9531. </td>
  9532. </tr>
  9533. <tr>
  9534. <td class="parameter_name"><p>src</p></td>
  9535. <td class="parameter_description">
  9536. <p>source string.</p>
  9537. <p>Passed as <code class="code">src</code></p>
  9538. </td>
  9539. </tr>
  9540. </table></div>
  9541. </div>
  9542. </div>
  9543. <div class="refsect2">
  9544. <a name="id-1.1.90.2.311"></a><h3>str-equal?</h3>
  9545. <div class="informalexample"><pre class="programlisting">(define-values (%return) (str-equal? v1 v2))
  9546. </pre></div>
  9547. <p>Compares two strings for byte-by-byte equality and returns <code class="constant">TRUE</code>
  9548. if they are equal. It can be passed to <code class="function">g_hash_table_new()</code> as the
  9549. <em class="parameter"><code>key_equal_func</code></em> parameter, when using non-<code class="constant">NULL</code> strings as keys in a
  9550. <span class="type">GHashTable</span>.
  9551. </p>
  9552. <p>This function is typically used for hash table comparisons, but can be used
  9553. for general purpose comparisons of non-<code class="constant">NULL</code> strings. For a <code class="constant">NULL</code>-safe string
  9554. comparison function, see <code class="function">g_strcmp0()</code>.</p>
  9555. <div class="refsect3">
  9556. <a name="id-1.1.90.2.311.5"></a><h4>Parameters</h4>
  9557. <div class="informaltable"><table>
  9558. <tr>
  9559. <td class="parameter_name"><p>v1</p></td>
  9560. <td class="parameter_description">
  9561. <p>a key</p>
  9562. <p>Passed as <code class="code">v1</code></p>
  9563. </td>
  9564. </tr>
  9565. <tr>
  9566. <td class="parameter_name"><p>v2</p></td>
  9567. <td class="parameter_description">
  9568. <p>a key to compare with <em class="parameter"><code>v1</code></em></p>
  9569. <p>Passed as <code class="code">v2</code></p>
  9570. </td>
  9571. </tr>
  9572. </table></div>
  9573. </div>
  9574. </div>
  9575. <div class="refsect2">
  9576. <a name="id-1.1.90.2.312"></a><h3>str-has-prefix?</h3>
  9577. <div class="informalexample"><pre class="programlisting">(define-values (%return) (str-has-prefix? str prefix))
  9578. </pre></div>
  9579. <p>Looks whether the string <em class="parameter"><code>str</code></em> begins with <em class="parameter"><code>prefix</code></em>.</p>
  9580. <div class="refsect3">
  9581. <a name="id-1.1.90.2.312.4"></a><h4>Parameters</h4>
  9582. <div class="informaltable"><table>
  9583. <tr>
  9584. <td class="parameter_name"><p>str</p></td>
  9585. <td class="parameter_description">
  9586. <p>a nul-terminated string</p>
  9587. <p>Passed as <code class="code">str</code></p>
  9588. </td>
  9589. </tr>
  9590. <tr>
  9591. <td class="parameter_name"><p>prefix</p></td>
  9592. <td class="parameter_description">
  9593. <p>the nul-terminated prefix to look for</p>
  9594. <p>Passed as <code class="code">prefix</code></p>
  9595. </td>
  9596. </tr>
  9597. </table></div>
  9598. </div>
  9599. </div>
  9600. <div class="refsect2">
  9601. <a name="id-1.1.90.2.313"></a><h3>str-has-suffix?</h3>
  9602. <div class="informalexample"><pre class="programlisting">(define-values (%return) (str-has-suffix? str suffix))
  9603. </pre></div>
  9604. <p>Looks whether the string <em class="parameter"><code>str</code></em> ends with <em class="parameter"><code>suffix</code></em>.</p>
  9605. <div class="refsect3">
  9606. <a name="id-1.1.90.2.313.4"></a><h4>Parameters</h4>
  9607. <div class="informaltable"><table>
  9608. <tr>
  9609. <td class="parameter_name"><p>str</p></td>
  9610. <td class="parameter_description">
  9611. <p>a nul-terminated string</p>
  9612. <p>Passed as <code class="code">str</code></p>
  9613. </td>
  9614. </tr>
  9615. <tr>
  9616. <td class="parameter_name"><p>suffix</p></td>
  9617. <td class="parameter_description">
  9618. <p>the nul-terminated suffix to look for</p>
  9619. <p>Passed as <code class="code">suffix</code></p>
  9620. </td>
  9621. </tr>
  9622. </table></div>
  9623. </div>
  9624. </div>
  9625. <div class="refsect2">
  9626. <a name="id-1.1.90.2.314"></a><h3>str-hash</h3>
  9627. <div class="informalexample"><pre class="programlisting">(define-values (%return) (str-hash v))
  9628. </pre></div>
  9629. <p>Converts a string to a hash value.
  9630. </p>
  9631. <p>This function implements the widely used "djb" hash apparently
  9632. posted by Daniel Bernstein to comp.lang.c some time ago. The 32
  9633. bit unsigned hash value starts at 5381 and for each byte 'c' in
  9634. the string, is updated: <code class="code">hash = hash * 33 + c</code>. This function
  9635. uses the signed value of each byte.
  9636. </p>
  9637. <p>It can be passed to <code class="function">g_hash_table_new()</code> as the <em class="parameter"><code>hash_func</code></em> parameter,
  9638. when using non-<code class="constant">NULL</code> strings as keys in a <span class="type">GHashTable</span>.
  9639. </p>
  9640. <p>Note that this function may not be a perfect fit for all use cases.
  9641. For example, it produces some hash collisions with strings as short
  9642. as 2.</p>
  9643. <div class="refsect3">
  9644. <a name="id-1.1.90.2.314.7"></a><h4>Parameters</h4>
  9645. <div class="informaltable"><table><tr>
  9646. <td class="parameter_name"><p>v</p></td>
  9647. <td class="parameter_description">
  9648. <p>a string key</p>
  9649. <p>Passed as <code class="code">v</code></p>
  9650. </td>
  9651. </tr></table></div>
  9652. </div>
  9653. </div>
  9654. <div class="refsect2">
  9655. <a name="id-1.1.90.2.315"></a><h3>str-is-ascii?</h3>
  9656. <div class="informalexample"><pre class="programlisting">(define-values (%return) (str-is-ascii? str))
  9657. </pre></div>
  9658. <p>Determines if a string is pure ASCII. A string is pure ASCII if it
  9659. contains no bytes with the high bit set.</p>
  9660. <div class="refsect3">
  9661. <a name="id-1.1.90.2.315.4"></a><h4>Parameters</h4>
  9662. <div class="informaltable"><table><tr>
  9663. <td class="parameter_name"><p>str</p></td>
  9664. <td class="parameter_description">
  9665. <p>a string</p>
  9666. <p>Passed as <code class="code">str</code></p>
  9667. </td>
  9668. </tr></table></div>
  9669. </div>
  9670. </div>
  9671. <div class="refsect2">
  9672. <a name="id-1.1.90.2.316"></a><h3>str-match-string?</h3>
  9673. <div class="informalexample"><pre class="programlisting">(define-values
  9674. (%return)
  9675. (str-match-string? search-term potential-hit accept-alternates))
  9676. </pre></div>
  9677. <p>Checks if a search conducted for <em class="parameter"><code>search_term</code></em> should match
  9678. <em class="parameter"><code>potential_hit</code></em>.
  9679. </p>
  9680. <p>This function calls <code class="function">g_str_tokenize_and_fold()</code> on both
  9681. <em class="parameter"><code>search_term</code></em> and <em class="parameter"><code>potential_hit</code></em>. ASCII alternates are never taken
  9682. for <em class="parameter"><code>search_term</code></em> but will be taken for <em class="parameter"><code>potential_hit</code></em> according to
  9683. the value of <em class="parameter"><code>accept_alternates</code></em>.
  9684. </p>
  9685. <p>A hit occurs when each folded token in <em class="parameter"><code>search_term</code></em> is a prefix of a
  9686. folded token from <em class="parameter"><code>potential_hit</code></em>.
  9687. </p>
  9688. <p>Depending on how you're performing the search, it will typically be
  9689. faster to call <code class="function">g_str_tokenize_and_fold()</code> on each string in
  9690. your corpus and build an index on the returned folded tokens, then
  9691. call <code class="function">g_str_tokenize_and_fold()</code> on the search term and
  9692. perform lookups into that index.
  9693. </p>
  9694. <p>As some examples, searching for ‘fred’ would match the potential hit
  9695. ‘Smith, Fred’ and also ‘Frédéric’. Searching for ‘Fréd’ would match
  9696. ‘Frédéric’ but not ‘Frederic’ (due to the one-directional nature of
  9697. accent matching). Searching ‘fo’ would match ‘Foo’ and ‘Bar Foo
  9698. Baz’, but not ‘SFO’ (because no word has ‘fo’ as a prefix).</p>
  9699. <div class="refsect3">
  9700. <a name="id-1.1.90.2.316.8"></a><h4>Parameters</h4>
  9701. <div class="informaltable"><table>
  9702. <tr>
  9703. <td class="parameter_name"><p>search_term</p></td>
  9704. <td class="parameter_description">
  9705. <p>the search term from the user</p>
  9706. <p>Passed as <code class="code">search-term</code></p>
  9707. </td>
  9708. </tr>
  9709. <tr>
  9710. <td class="parameter_name"><p>potential_hit</p></td>
  9711. <td class="parameter_description">
  9712. <p>the text that may be a hit</p>
  9713. <p>Passed as <code class="code">potential-hit</code></p>
  9714. </td>
  9715. </tr>
  9716. <tr>
  9717. <td class="parameter_name"><p>accept_alternates</p></td>
  9718. <td class="parameter_description">
  9719. <p><code class="constant">TRUE</code> to accept ASCII alternates</p>
  9720. <p>Passed as <code class="code">accept-alternates</code></p>
  9721. </td>
  9722. </tr>
  9723. </table></div>
  9724. </div>
  9725. </div>
  9726. <div class="refsect2">
  9727. <a name="id-1.1.90.2.317"></a><h3>str-to-ascii</h3>
  9728. <div class="informalexample"><pre class="programlisting">(define-values (%return) (str-to-ascii str from-locale))
  9729. </pre></div>
  9730. <p>Transliterate <em class="parameter"><code>str</code></em> to plain ASCII.
  9731. </p>
  9732. <p>For best results, <em class="parameter"><code>str</code></em> should be in composed normalised form.
  9733. </p>
  9734. <p>This function performs a reasonably good set of character
  9735. replacements. The particular set of replacements that is done may
  9736. change by version or even by runtime environment.
  9737. </p>
  9738. <p>If the source language of <em class="parameter"><code>str</code></em> is known, it can used to improve the
  9739. accuracy of the translation by passing it as <em class="parameter"><code>from_locale</code></em>. It should
  9740. be a valid POSIX locale string (of the form
  9741. <code class="code">language[_territory][.codeset][@modifier]</code>).
  9742. </p>
  9743. <p>If <em class="parameter"><code>from_locale</code></em> is <code class="constant">NULL</code> then the current locale is used.
  9744. </p>
  9745. <p>If you want to do translation for no specific locale, and you want it
  9746. to be done independently of the currently locale, specify <code class="code">"C"</code> for
  9747. <em class="parameter"><code>from_locale</code></em>.</p>
  9748. <div class="refsect3">
  9749. <a name="id-1.1.90.2.317.9"></a><h4>Parameters</h4>
  9750. <div class="informaltable"><table>
  9751. <tr>
  9752. <td class="parameter_name"><p>str</p></td>
  9753. <td class="parameter_description">
  9754. <p>a string, in UTF-8</p>
  9755. <p>Passed as <code class="code">str</code></p>
  9756. </td>
  9757. </tr>
  9758. <tr>
  9759. <td class="parameter_name"><p>from_locale</p></td>
  9760. <td class="parameter_description">
  9761. <p>the source locale, if known</p>
  9762. <p>Passed as <code class="code">from-locale</code></p>
  9763. </td>
  9764. </tr>
  9765. </table></div>
  9766. </div>
  9767. </div>
  9768. <div class="refsect2">
  9769. <a name="id-1.1.90.2.318"></a><h3>str-tokenize-and-fold</h3>
  9770. <div class="informalexample"><pre class="programlisting">(define-values
  9771. (%return ascii-alternates)
  9772. (str-tokenize-and-fold string translit-locale))
  9773. </pre></div>
  9774. <p>Tokenises <em class="parameter"><code>string</code></em> and performs folding on each token.
  9775. </p>
  9776. <p>A token is a non-empty sequence of alphanumeric characters in the
  9777. source string, separated by non-alphanumeric characters. An
  9778. "alphanumeric" character for this purpose is one that matches
  9779. <code class="function">g_unichar_isalnum()</code> or <code class="function">g_unichar_ismark()</code>.
  9780. </p>
  9781. <p>Each token is then (Unicode) normalised and case-folded. If
  9782. <em class="parameter"><code>ascii_alternates</code></em> is non-<code class="constant">NULL</code> and some of the returned tokens
  9783. contain non-ASCII characters, ASCII alternatives will be generated.
  9784. </p>
  9785. <p>The number of ASCII alternatives that are generated and the method
  9786. for doing so is unspecified, but <em class="parameter"><code>translit_locale</code></em> (if specified) may
  9787. improve the transliteration if the language of the source string is
  9788. known.</p>
  9789. <div class="refsect3">
  9790. <a name="id-1.1.90.2.318.7"></a><h4>Parameters</h4>
  9791. <div class="informaltable"><table>
  9792. <tr>
  9793. <td class="parameter_name"><p>string</p></td>
  9794. <td class="parameter_description">
  9795. <p>a string</p>
  9796. <p>Passed as <code class="code">string</code></p>
  9797. </td>
  9798. </tr>
  9799. <tr>
  9800. <td class="parameter_name"><p>translit_locale</p></td>
  9801. <td class="parameter_description">
  9802. <p>the language code (like 'de' or
  9803. 'en_GB') from which <em class="parameter"><code>string</code></em> originates</p>
  9804. <p>Passed as <code class="code">translit-locale</code></p>
  9805. </td>
  9806. </tr>
  9807. <tr>
  9808. <td class="parameter_name"><p>ascii_alternates</p></td>
  9809. <td class="parameter_description">
  9810. <p>a
  9811. return location for ASCII alternates</p>
  9812. <p>Passed as <code class="code">ascii-alternates</code></p>
  9813. </td>
  9814. </tr>
  9815. </table></div>
  9816. </div>
  9817. </div>
  9818. <div class="refsect2">
  9819. <a name="id-1.1.90.2.319"></a><h3>strcanon</h3>
  9820. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strcanon string valid-chars substitutor))
  9821. </pre></div>
  9822. <p>For each character in <em class="parameter"><code>string</code></em>, if the character is not in <em class="parameter"><code>valid_chars</code></em>,
  9823. replaces the character with <em class="parameter"><code>substitutor</code></em>. Modifies <em class="parameter"><code>string</code></em> in place,
  9824. and return <em class="parameter"><code>string</code></em> itself, not a copy. The return value is to allow
  9825. nesting such as
  9826. </p>
  9827. <div class="informalexample"><pre class="programlisting">
  9828. g_ascii_strup (g_strcanon (str, "abc", '?'))
  9829. </pre></div>
  9830. <p>In order to modify a copy, you may use <code class="code">g_strdup()</code>:
  9831. </p>
  9832. <div class="informalexample"><pre class="programlisting">
  9833. reformatted = g_strcanon (g_strdup (const_str), "abc", '?');
  9834. ...
  9835. g_free (reformatted);
  9836. </pre></div>
  9837. <div class="refsect3">
  9838. <a name="id-1.1.90.2.319.5"></a><h4>Parameters</h4>
  9839. <div class="informaltable"><table>
  9840. <tr>
  9841. <td class="parameter_name"><p>string</p></td>
  9842. <td class="parameter_description">
  9843. <p>a nul-terminated array of bytes</p>
  9844. <p>Passed as <code class="code">string</code></p>
  9845. </td>
  9846. </tr>
  9847. <tr>
  9848. <td class="parameter_name"><p>valid_chars</p></td>
  9849. <td class="parameter_description">
  9850. <p>bytes permitted in <em class="parameter"><code>string</code></em></p>
  9851. <p>Passed as <code class="code">valid-chars</code></p>
  9852. </td>
  9853. </tr>
  9854. <tr>
  9855. <td class="parameter_name"><p>substitutor</p></td>
  9856. <td class="parameter_description">
  9857. <p>replacement character for disallowed bytes</p>
  9858. <p>Passed as <code class="code">substitutor</code></p>
  9859. </td>
  9860. </tr>
  9861. </table></div>
  9862. </div>
  9863. </div>
  9864. <div class="refsect2">
  9865. <a name="id-1.1.90.2.320"></a><h3>strchomp</h3>
  9866. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strchomp string))
  9867. </pre></div>
  9868. <p>Removes trailing whitespace from a string.
  9869. </p>
  9870. <p>This function doesn't allocate or reallocate any memory;
  9871. it modifies <em class="parameter"><code>string</code></em> in place. Therefore, it cannot be used
  9872. on statically allocated strings.
  9873. </p>
  9874. <p>The pointer to <em class="parameter"><code>string</code></em> is returned to allow the nesting of functions.
  9875. </p>
  9876. <p>Also see <code class="function">g_strchug()</code> and <code class="function">g_strstrip()</code>.</p>
  9877. <div class="refsect3">
  9878. <a name="id-1.1.90.2.320.7"></a><h4>Parameters</h4>
  9879. <div class="informaltable"><table><tr>
  9880. <td class="parameter_name"><p>string</p></td>
  9881. <td class="parameter_description">
  9882. <p>a string to remove the trailing whitespace from</p>
  9883. <p>Passed as <code class="code">string</code></p>
  9884. </td>
  9885. </tr></table></div>
  9886. </div>
  9887. </div>
  9888. <div class="refsect2">
  9889. <a name="id-1.1.90.2.321"></a><h3>strchug</h3>
  9890. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strchug string))
  9891. </pre></div>
  9892. <p>Removes leading whitespace from a string, by moving the rest
  9893. of the characters forward.
  9894. </p>
  9895. <p>This function doesn't allocate or reallocate any memory;
  9896. it modifies <em class="parameter"><code>string</code></em> in place. Therefore, it cannot be used on
  9897. statically allocated strings.
  9898. </p>
  9899. <p>The pointer to <em class="parameter"><code>string</code></em> is returned to allow the nesting of functions.
  9900. </p>
  9901. <p>Also see <code class="function">g_strchomp()</code> and <code class="function">g_strstrip()</code>.</p>
  9902. <div class="refsect3">
  9903. <a name="id-1.1.90.2.321.7"></a><h4>Parameters</h4>
  9904. <div class="informaltable"><table><tr>
  9905. <td class="parameter_name"><p>string</p></td>
  9906. <td class="parameter_description">
  9907. <p>a string to remove the leading whitespace from</p>
  9908. <p>Passed as <code class="code">string</code></p>
  9909. </td>
  9910. </tr></table></div>
  9911. </div>
  9912. </div>
  9913. <div class="refsect2">
  9914. <a name="id-1.1.90.2.322"></a><h3>strcmp0</h3>
  9915. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strcmp0 str1 str2))
  9916. </pre></div>
  9917. <p>Compares <em class="parameter"><code>str1</code></em> and <em class="parameter"><code>str2</code></em> like <code class="function">strcmp()</code>. Handles <code class="constant">NULL</code>
  9918. gracefully by sorting it before non-<code class="constant">NULL</code> strings.
  9919. Comparing two <code class="constant">NULL</code> pointers returns 0.</p>
  9920. <div class="refsect3">
  9921. <a name="id-1.1.90.2.322.4"></a><h4>Parameters</h4>
  9922. <div class="informaltable"><table>
  9923. <tr>
  9924. <td class="parameter_name"><p>str1</p></td>
  9925. <td class="parameter_description">
  9926. <p>a C string or <code class="constant">NULL</code></p>
  9927. <p>Passed as <code class="code">str1</code></p>
  9928. </td>
  9929. </tr>
  9930. <tr>
  9931. <td class="parameter_name"><p>str2</p></td>
  9932. <td class="parameter_description">
  9933. <p>another C string or <code class="constant">NULL</code></p>
  9934. <p>Passed as <code class="code">str2</code></p>
  9935. </td>
  9936. </tr>
  9937. </table></div>
  9938. </div>
  9939. </div>
  9940. <div class="refsect2">
  9941. <a name="id-1.1.90.2.323"></a><h3>strcompress</h3>
  9942. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strcompress source))
  9943. </pre></div>
  9944. <p>Replaces all escaped characters with their one byte equivalent.
  9945. </p>
  9946. <p>This function does the reverse conversion of <code class="function">g_strescape()</code>.</p>
  9947. <div class="refsect3">
  9948. <a name="id-1.1.90.2.323.5"></a><h4>Parameters</h4>
  9949. <div class="informaltable"><table><tr>
  9950. <td class="parameter_name"><p>source</p></td>
  9951. <td class="parameter_description">
  9952. <p>a string to compress</p>
  9953. <p>Passed as <code class="code">source</code></p>
  9954. </td>
  9955. </tr></table></div>
  9956. </div>
  9957. </div>
  9958. <div class="refsect2">
  9959. <a name="id-1.1.90.2.324"></a><h3>strdelimit</h3>
  9960. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strdelimit string delimiters new-delimiter))
  9961. </pre></div>
  9962. <p>Converts any delimiter characters in <em class="parameter"><code>string</code></em> to <em class="parameter"><code>new_delimiter</code></em>.
  9963. Any characters in <em class="parameter"><code>string</code></em> which are found in <em class="parameter"><code>delimiters</code></em> are
  9964. changed to the <em class="parameter"><code>new_delimiter</code></em> character. Modifies <em class="parameter"><code>string</code></em> in place,
  9965. and returns <em class="parameter"><code>string</code></em> itself, not a copy. The return value is to
  9966. allow nesting such as
  9967. </p>
  9968. <div class="informalexample"><pre class="programlisting">
  9969. g_ascii_strup (g_strdelimit (str, "abc", '?'))
  9970. </pre></div>
  9971. <p>In order to modify a copy, you may use <code class="code">g_strdup()</code>:
  9972. </p>
  9973. <div class="informalexample"><pre class="programlisting">
  9974. reformatted = g_strdelimit (g_strdup (const_str), "abc", '?');
  9975. ...
  9976. g_free (reformatted);
  9977. </pre></div>
  9978. <div class="refsect3">
  9979. <a name="id-1.1.90.2.324.5"></a><h4>Parameters</h4>
  9980. <div class="informaltable"><table>
  9981. <tr>
  9982. <td class="parameter_name"><p>string</p></td>
  9983. <td class="parameter_description">
  9984. <p>the string to convert</p>
  9985. <p>Passed as <code class="code">string</code></p>
  9986. </td>
  9987. </tr>
  9988. <tr>
  9989. <td class="parameter_name"><p>delimiters</p></td>
  9990. <td class="parameter_description">
  9991. <p>a string containing the current delimiters,
  9992. or <code class="constant">NULL</code> to use the standard delimiters defined in <span class="type">G_STR_DELIMITERS</span></p>
  9993. <p>Passed as <code class="code">delimiters</code></p>
  9994. </td>
  9995. </tr>
  9996. <tr>
  9997. <td class="parameter_name"><p>new_delimiter</p></td>
  9998. <td class="parameter_description">
  9999. <p>the new delimiter character</p>
  10000. <p>Passed as <code class="code">new-delimiter</code></p>
  10001. </td>
  10002. </tr>
  10003. </table></div>
  10004. </div>
  10005. </div>
  10006. <div class="refsect2">
  10007. <a name="id-1.1.90.2.325"></a><h3>strdup</h3>
  10008. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strdup str))
  10009. </pre></div>
  10010. <p>Duplicates a string. If <em class="parameter"><code>str</code></em> is <code class="constant">NULL</code> it returns <code class="constant">NULL</code>.
  10011. The returned string should be freed with <code class="function">g_free()</code>
  10012. when no longer needed.</p>
  10013. <div class="refsect3">
  10014. <a name="id-1.1.90.2.325.4"></a><h4>Parameters</h4>
  10015. <div class="informaltable"><table><tr>
  10016. <td class="parameter_name"><p>str</p></td>
  10017. <td class="parameter_description">
  10018. <p>the string to duplicate</p>
  10019. <p>Passed as <code class="code">str</code></p>
  10020. </td>
  10021. </tr></table></div>
  10022. </div>
  10023. </div>
  10024. <div class="refsect2">
  10025. <a name="id-1.1.90.2.326"></a><h3>strerror</h3>
  10026. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strerror errnum))
  10027. </pre></div>
  10028. <p>Returns a string corresponding to the given error code, e.g. "no
  10029. such process". Unlike <code class="function">strerror()</code>, this always returns a string in
  10030. UTF-8 encoding, and the pointer is guaranteed to remain valid for
  10031. the lifetime of the process.
  10032. </p>
  10033. <p>Note that the string may be translated according to the current locale.
  10034. </p>
  10035. <p>The value of <code class="constant">errno</code> will not be changed by this function. However, it may
  10036. be changed by intermediate function calls, so you should save its value
  10037. as soon as the call returns:
  10038. </p>
  10039. <div class="informalexample"><pre class="programlisting">
  10040. int saved_errno;
  10041. ret = read (blah);
  10042. saved_errno = errno;
  10043. g_strerror (saved_errno);
  10044. </pre></div>
  10045. <div class="refsect3">
  10046. <a name="id-1.1.90.2.326.6"></a><h4>Parameters</h4>
  10047. <div class="informaltable"><table><tr>
  10048. <td class="parameter_name"><p>errnum</p></td>
  10049. <td class="parameter_description">
  10050. <p>the system error number. See the standard C <code class="constant">errno</code>
  10051. documentation</p>
  10052. <p>Passed as <code class="code">errnum</code></p>
  10053. </td>
  10054. </tr></table></div>
  10055. </div>
  10056. </div>
  10057. <div class="refsect2">
  10058. <a name="id-1.1.90.2.327"></a><h3>strescape</h3>
  10059. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strescape source exceptions))
  10060. </pre></div>
  10061. <p>Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\'
  10062. and '"' in the string <em class="parameter"><code>source</code></em> by inserting a '\' before
  10063. them. Additionally all characters in the range 0x01-0x1F (everything
  10064. below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are
  10065. replaced with a '\' followed by their octal representation.
  10066. Characters supplied in <em class="parameter"><code>exceptions</code></em> are not escaped.
  10067. </p>
  10068. <p><code class="function">g_strcompress()</code> does the reverse conversion.</p>
  10069. <div class="refsect3">
  10070. <a name="id-1.1.90.2.327.5"></a><h4>Parameters</h4>
  10071. <div class="informaltable"><table>
  10072. <tr>
  10073. <td class="parameter_name"><p>source</p></td>
  10074. <td class="parameter_description">
  10075. <p>a string to escape</p>
  10076. <p>Passed as <code class="code">source</code></p>
  10077. </td>
  10078. </tr>
  10079. <tr>
  10080. <td class="parameter_name"><p>exceptions</p></td>
  10081. <td class="parameter_description">
  10082. <p>a string of characters not to escape in <em class="parameter"><code>source</code></em></p>
  10083. <p>Passed as <code class="code">exceptions</code></p>
  10084. </td>
  10085. </tr>
  10086. </table></div>
  10087. </div>
  10088. </div>
  10089. <div class="refsect2">
  10090. <a name="id-1.1.90.2.328"></a><h3>strfreev</h3>
  10091. <div class="informalexample"><pre class="programlisting">(define-values () (strfreev str-array))
  10092. </pre></div>
  10093. <p>Frees a <code class="constant">NULL</code>-terminated array of strings, as well as each
  10094. string it contains.
  10095. </p>
  10096. <p>If <em class="parameter"><code>str_array</code></em> is <code class="constant">NULL</code>, this function simply returns.</p>
  10097. <div class="refsect3">
  10098. <a name="id-1.1.90.2.328.5"></a><h4>Parameters</h4>
  10099. <div class="informaltable"><table><tr>
  10100. <td class="parameter_name"><p>str_array</p></td>
  10101. <td class="parameter_description">
  10102. <p>a <code class="constant">NULL</code>-terminated array of strings to free</p>
  10103. <p>Passed as <code class="code">str-array</code></p>
  10104. </td>
  10105. </tr></table></div>
  10106. </div>
  10107. </div>
  10108. <div class="refsect2">
  10109. <a name="id-1.1.90.2.329"></a><h3>string-new</h3>
  10110. <div class="informalexample"><pre class="programlisting">(define-values (%return) (string-new init))
  10111. </pre></div>
  10112. <p>Creates a new <span class="type">GString</span>, initialized with the given string.</p>
  10113. <div class="refsect3">
  10114. <a name="id-1.1.90.2.329.4"></a><h4>Parameters</h4>
  10115. <div class="informaltable"><table><tr>
  10116. <td class="parameter_name"><p>init</p></td>
  10117. <td class="parameter_description">
  10118. <p>the initial text to copy into the string, or <code class="constant">NULL</code> to
  10119. start with an empty string</p>
  10120. <p>Passed as <code class="code">init</code></p>
  10121. </td>
  10122. </tr></table></div>
  10123. </div>
  10124. </div>
  10125. <div class="refsect2">
  10126. <a name="id-1.1.90.2.330"></a><h3>string-new-len</h3>
  10127. <div class="informalexample"><pre class="programlisting">(define-values (%return) (string-new-len init len))
  10128. </pre></div>
  10129. <p>Creates a new <span class="type">GString</span> with <em class="parameter"><code>len</code></em> bytes of the <em class="parameter"><code>init</code></em> buffer.
  10130. Because a length is provided, <em class="parameter"><code>init</code></em> need not be nul-terminated,
  10131. and can contain embedded nul bytes.
  10132. </p>
  10133. <p>Since this function does not stop at nul bytes, it is the caller's
  10134. responsibility to ensure that <em class="parameter"><code>init</code></em> has at least <em class="parameter"><code>len</code></em> addressable
  10135. bytes.</p>
  10136. <div class="refsect3">
  10137. <a name="id-1.1.90.2.330.5"></a><h4>Parameters</h4>
  10138. <div class="informaltable"><table>
  10139. <tr>
  10140. <td class="parameter_name"><p>init</p></td>
  10141. <td class="parameter_description">
  10142. <p>initial contents of the string</p>
  10143. <p>Passed as <code class="code">init</code></p>
  10144. </td>
  10145. </tr>
  10146. <tr>
  10147. <td class="parameter_name"><p>len</p></td>
  10148. <td class="parameter_description">
  10149. <p>length of <em class="parameter"><code>init</code></em> to use</p>
  10150. <p>Passed as <code class="code">len</code></p>
  10151. </td>
  10152. </tr>
  10153. </table></div>
  10154. </div>
  10155. </div>
  10156. <div class="refsect2">
  10157. <a name="id-1.1.90.2.331"></a><h3>string-sized-new</h3>
  10158. <div class="informalexample"><pre class="programlisting">(define-values (%return) (string-sized-new dfl-size))
  10159. </pre></div>
  10160. <p>Creates a new <span class="type">GString</span>, with enough space for <em class="parameter"><code>dfl_size</code></em>
  10161. bytes. This is useful if you are going to add a lot of
  10162. text to the string and don't want it to be reallocated
  10163. too often.</p>
  10164. <div class="refsect3">
  10165. <a name="id-1.1.90.2.331.4"></a><h4>Parameters</h4>
  10166. <div class="informaltable"><table><tr>
  10167. <td class="parameter_name"><p>dfl_size</p></td>
  10168. <td class="parameter_description">
  10169. <p>the default size of the space allocated to
  10170. hold the string</p>
  10171. <p>Passed as <code class="code">dfl-size</code></p>
  10172. </td>
  10173. </tr></table></div>
  10174. </div>
  10175. </div>
  10176. <div class="refsect2">
  10177. <a name="id-1.1.90.2.332"></a><h3>strip-context</h3>
  10178. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strip-context msgid msgval))
  10179. </pre></div>
  10180. <p>An auxiliary function for <code class="function">gettext()</code> support (see <code class="function">Q_()</code>).</p>
  10181. <div class="refsect3">
  10182. <a name="id-1.1.90.2.332.4"></a><h4>Parameters</h4>
  10183. <div class="informaltable"><table>
  10184. <tr>
  10185. <td class="parameter_name"><p>msgid</p></td>
  10186. <td class="parameter_description">
  10187. <p>a string</p>
  10188. <p>Passed as <code class="code">msgid</code></p>
  10189. </td>
  10190. </tr>
  10191. <tr>
  10192. <td class="parameter_name"><p>msgval</p></td>
  10193. <td class="parameter_description">
  10194. <p>another string</p>
  10195. <p>Passed as <code class="code">msgval</code></p>
  10196. </td>
  10197. </tr>
  10198. </table></div>
  10199. </div>
  10200. </div>
  10201. <div class="refsect2">
  10202. <a name="id-1.1.90.2.333"></a><h3>strjoinv</h3>
  10203. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strjoinv separator str-array))
  10204. </pre></div>
  10205. <p>Joins a number of strings together to form one long string, with the
  10206. optional <em class="parameter"><code>separator</code></em> inserted between each of them. The returned string
  10207. should be freed with <code class="function">g_free()</code>.
  10208. </p>
  10209. <p>If <em class="parameter"><code>str_array</code></em> has no items, the return value will be an
  10210. empty string. If <em class="parameter"><code>str_array</code></em> contains a single item, <em class="parameter"><code>separator</code></em> will not
  10211. appear in the resulting string.</p>
  10212. <div class="refsect3">
  10213. <a name="id-1.1.90.2.333.5"></a><h4>Parameters</h4>
  10214. <div class="informaltable"><table>
  10215. <tr>
  10216. <td class="parameter_name"><p>separator</p></td>
  10217. <td class="parameter_description">
  10218. <p>a string to insert between each of the
  10219. strings, or <code class="constant">NULL</code></p>
  10220. <p>Passed as <code class="code">separator</code></p>
  10221. </td>
  10222. </tr>
  10223. <tr>
  10224. <td class="parameter_name"><p>str_array</p></td>
  10225. <td class="parameter_description">
  10226. <p>a <code class="constant">NULL</code>-terminated array of strings to join</p>
  10227. <p>Passed as <code class="code">str-array</code></p>
  10228. </td>
  10229. </tr>
  10230. </table></div>
  10231. </div>
  10232. </div>
  10233. <div class="refsect2">
  10234. <a name="id-1.1.90.2.334"></a><h3>strlcat</h3>
  10235. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strlcat dest src dest-size))
  10236. </pre></div>
  10237. <p>Portability wrapper that calls <code class="function">strlcat()</code> on systems which have it,
  10238. and emulates it otherwise. Appends nul-terminated <em class="parameter"><code>src</code></em> string to <em class="parameter"><code>dest</code></em>,
  10239. guaranteeing nul-termination for <em class="parameter"><code>dest</code></em>. The total size of <em class="parameter"><code>dest</code></em> won't
  10240. exceed <em class="parameter"><code>dest_size</code></em>.
  10241. </p>
  10242. <p>At most <em class="parameter"><code>dest_size</code></em> - 1 characters will be copied. Unlike <code class="function">strncat()</code>,
  10243. <em class="parameter"><code>dest_size</code></em> is the full size of dest, not the space left over. This
  10244. function does not allocate memory. It always nul-terminates (unless
  10245. <em class="parameter"><code>dest_size</code></em> == 0 or there were no nul characters in the <em class="parameter"><code>dest_size</code></em>
  10246. characters of dest to start with).
  10247. </p>
  10248. <p>Caveat: this is supposedly a more secure alternative to <code class="function">strcat()</code> or
  10249. <code class="function">strncat()</code>, but for real security <code class="function">g_strconcat()</code> is harder to mess up.</p>
  10250. <div class="refsect3">
  10251. <a name="id-1.1.90.2.334.6"></a><h4>Parameters</h4>
  10252. <div class="informaltable"><table>
  10253. <tr>
  10254. <td class="parameter_name"><p>dest</p></td>
  10255. <td class="parameter_description">
  10256. <p>destination buffer, already containing one nul-terminated string</p>
  10257. <p>Passed as <code class="code">dest</code></p>
  10258. </td>
  10259. </tr>
  10260. <tr>
  10261. <td class="parameter_name"><p>src</p></td>
  10262. <td class="parameter_description">
  10263. <p>source buffer</p>
  10264. <p>Passed as <code class="code">src</code></p>
  10265. </td>
  10266. </tr>
  10267. <tr>
  10268. <td class="parameter_name"><p>dest_size</p></td>
  10269. <td class="parameter_description">
  10270. <p>length of <em class="parameter"><code>dest</code></em> buffer in bytes (not length of existing string
  10271. inside <em class="parameter"><code>dest</code></em>)</p>
  10272. <p>Passed as <code class="code">dest-size</code></p>
  10273. </td>
  10274. </tr>
  10275. </table></div>
  10276. </div>
  10277. </div>
  10278. <div class="refsect2">
  10279. <a name="id-1.1.90.2.335"></a><h3>strlcpy</h3>
  10280. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strlcpy dest src dest-size))
  10281. </pre></div>
  10282. <p>Portability wrapper that calls <code class="function">strlcpy()</code> on systems which have it,
  10283. and emulates <code class="function">strlcpy()</code> otherwise. Copies <em class="parameter"><code>src</code></em> to <em class="parameter"><code>dest</code></em>; <em class="parameter"><code>dest</code></em> is
  10284. guaranteed to be nul-terminated; <em class="parameter"><code>src</code></em> must be nul-terminated;
  10285. <em class="parameter"><code>dest_size</code></em> is the buffer size, not the number of bytes to copy.
  10286. </p>
  10287. <p>At most <em class="parameter"><code>dest_size</code></em> - 1 characters will be copied. Always nul-terminates
  10288. (unless <em class="parameter"><code>dest_size</code></em> is 0). This function does not allocate memory. Unlike
  10289. <code class="function">strncpy()</code>, this function doesn't pad <em class="parameter"><code>dest</code></em> (so it's often faster). It
  10290. returns the size of the attempted result, strlen (src), so if
  10291. <em class="parameter"><code>retval</code></em> &gt;= <em class="parameter"><code>dest_size</code></em>, truncation occurred.
  10292. </p>
  10293. <p>Caveat: <code class="function">strlcpy()</code> is supposedly more secure than <code class="function">strcpy()</code> or <code class="function">strncpy()</code>,
  10294. but if you really want to avoid screwups, <code class="function">g_strdup()</code> is an even better
  10295. idea.</p>
  10296. <div class="refsect3">
  10297. <a name="id-1.1.90.2.335.6"></a><h4>Parameters</h4>
  10298. <div class="informaltable"><table>
  10299. <tr>
  10300. <td class="parameter_name"><p>dest</p></td>
  10301. <td class="parameter_description">
  10302. <p>destination buffer</p>
  10303. <p>Passed as <code class="code">dest</code></p>
  10304. </td>
  10305. </tr>
  10306. <tr>
  10307. <td class="parameter_name"><p>src</p></td>
  10308. <td class="parameter_description">
  10309. <p>source buffer</p>
  10310. <p>Passed as <code class="code">src</code></p>
  10311. </td>
  10312. </tr>
  10313. <tr>
  10314. <td class="parameter_name"><p>dest_size</p></td>
  10315. <td class="parameter_description">
  10316. <p>length of <em class="parameter"><code>dest</code></em> in bytes</p>
  10317. <p>Passed as <code class="code">dest-size</code></p>
  10318. </td>
  10319. </tr>
  10320. </table></div>
  10321. </div>
  10322. </div>
  10323. <div class="refsect2">
  10324. <a name="id-1.1.90.2.336"></a><h3>strndup</h3>
  10325. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strndup str n))
  10326. </pre></div>
  10327. <p>Duplicates the first <em class="parameter"><code>n</code></em> bytes of a string, returning a newly-allocated
  10328. buffer <em class="parameter"><code>n</code></em> + 1 bytes long which will always be nul-terminated. If <em class="parameter"><code>str</code></em>
  10329. is less than <em class="parameter"><code>n</code></em> bytes long the buffer is padded with nuls. If <em class="parameter"><code>str</code></em> is
  10330. <code class="constant">NULL</code> it returns <code class="constant">NULL</code>. The returned value should be freed when no longer
  10331. needed.
  10332. </p>
  10333. <p>To copy a number of characters from a UTF-8 encoded string,
  10334. use <code class="function">g_utf8_strncpy()</code> instead.</p>
  10335. <div class="refsect3">
  10336. <a name="id-1.1.90.2.336.5"></a><h4>Parameters</h4>
  10337. <div class="informaltable"><table>
  10338. <tr>
  10339. <td class="parameter_name"><p>str</p></td>
  10340. <td class="parameter_description">
  10341. <p>the string to duplicate</p>
  10342. <p>Passed as <code class="code">str</code></p>
  10343. </td>
  10344. </tr>
  10345. <tr>
  10346. <td class="parameter_name"><p>n</p></td>
  10347. <td class="parameter_description">
  10348. <p>the maximum number of bytes to copy from <em class="parameter"><code>str</code></em></p>
  10349. <p>Passed as <code class="code">n</code></p>
  10350. </td>
  10351. </tr>
  10352. </table></div>
  10353. </div>
  10354. </div>
  10355. <div class="refsect2">
  10356. <a name="id-1.1.90.2.337"></a><h3>strnfill</h3>
  10357. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strnfill length fill-char))
  10358. </pre></div>
  10359. <p>Creates a new string <em class="parameter"><code>length</code></em> bytes long filled with <em class="parameter"><code>fill_char</code></em>.
  10360. The returned string should be freed when no longer needed.</p>
  10361. <div class="refsect3">
  10362. <a name="id-1.1.90.2.337.4"></a><h4>Parameters</h4>
  10363. <div class="informaltable"><table>
  10364. <tr>
  10365. <td class="parameter_name"><p>length</p></td>
  10366. <td class="parameter_description">
  10367. <p>the length of the new string</p>
  10368. <p>Passed as <code class="code">length</code></p>
  10369. </td>
  10370. </tr>
  10371. <tr>
  10372. <td class="parameter_name"><p>fill_char</p></td>
  10373. <td class="parameter_description">
  10374. <p>the byte to fill the string with</p>
  10375. <p>Passed as <code class="code">fill-char</code></p>
  10376. </td>
  10377. </tr>
  10378. </table></div>
  10379. </div>
  10380. </div>
  10381. <div class="refsect2">
  10382. <a name="id-1.1.90.2.338"></a><h3>strreverse</h3>
  10383. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strreverse string))
  10384. </pre></div>
  10385. <p>Reverses all of the bytes in a string. For example,
  10386. <code class="code">g_strreverse ("abcdef")</code> will result in "fedcba".
  10387. </p>
  10388. <p>Note that <code class="function">g_strreverse()</code> doesn't work on UTF-8 strings
  10389. containing multibyte characters. For that purpose, use
  10390. <code class="function">g_utf8_strreverse()</code>.</p>
  10391. <div class="refsect3">
  10392. <a name="id-1.1.90.2.338.5"></a><h4>Parameters</h4>
  10393. <div class="informaltable"><table><tr>
  10394. <td class="parameter_name"><p>string</p></td>
  10395. <td class="parameter_description">
  10396. <p>the string to reverse</p>
  10397. <p>Passed as <code class="code">string</code></p>
  10398. </td>
  10399. </tr></table></div>
  10400. </div>
  10401. </div>
  10402. <div class="refsect2">
  10403. <a name="id-1.1.90.2.339"></a><h3>strrstr</h3>
  10404. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strrstr haystack needle))
  10405. </pre></div>
  10406. <p>Searches the string <em class="parameter"><code>haystack</code></em> for the last occurrence
  10407. of the string <em class="parameter"><code>needle</code></em>.</p>
  10408. <div class="refsect3">
  10409. <a name="id-1.1.90.2.339.4"></a><h4>Parameters</h4>
  10410. <div class="informaltable"><table>
  10411. <tr>
  10412. <td class="parameter_name"><p>haystack</p></td>
  10413. <td class="parameter_description">
  10414. <p>a nul-terminated string</p>
  10415. <p>Passed as <code class="code">haystack</code></p>
  10416. </td>
  10417. </tr>
  10418. <tr>
  10419. <td class="parameter_name"><p>needle</p></td>
  10420. <td class="parameter_description">
  10421. <p>the nul-terminated string to search for</p>
  10422. <p>Passed as <code class="code">needle</code></p>
  10423. </td>
  10424. </tr>
  10425. </table></div>
  10426. </div>
  10427. </div>
  10428. <div class="refsect2">
  10429. <a name="id-1.1.90.2.340"></a><h3>strrstr-len</h3>
  10430. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strrstr-len haystack haystack-len needle))
  10431. </pre></div>
  10432. <p>Searches the string <em class="parameter"><code>haystack</code></em> for the last occurrence
  10433. of the string <em class="parameter"><code>needle</code></em>, limiting the length of the search
  10434. to <em class="parameter"><code>haystack_len</code></em>.</p>
  10435. <div class="refsect3">
  10436. <a name="id-1.1.90.2.340.4"></a><h4>Parameters</h4>
  10437. <div class="informaltable"><table>
  10438. <tr>
  10439. <td class="parameter_name"><p>haystack</p></td>
  10440. <td class="parameter_description">
  10441. <p>a nul-terminated string</p>
  10442. <p>Passed as <code class="code">haystack</code></p>
  10443. </td>
  10444. </tr>
  10445. <tr>
  10446. <td class="parameter_name"><p>haystack_len</p></td>
  10447. <td class="parameter_description">
  10448. <p>the maximum length of <em class="parameter"><code>haystack</code></em></p>
  10449. <p>Passed as <code class="code">haystack-len</code></p>
  10450. </td>
  10451. </tr>
  10452. <tr>
  10453. <td class="parameter_name"><p>needle</p></td>
  10454. <td class="parameter_description">
  10455. <p>the nul-terminated string to search for</p>
  10456. <p>Passed as <code class="code">needle</code></p>
  10457. </td>
  10458. </tr>
  10459. </table></div>
  10460. </div>
  10461. </div>
  10462. <div class="refsect2">
  10463. <a name="id-1.1.90.2.341"></a><h3>strsignal</h3>
  10464. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strsignal signum))
  10465. </pre></div>
  10466. <p>Returns a string describing the given signal, e.g. "Segmentation fault".
  10467. You should use this function in preference to <code class="function">strsignal()</code>, because it
  10468. returns a string in UTF-8 encoding, and since not all platforms support
  10469. the <code class="function">strsignal()</code> function.</p>
  10470. <div class="refsect3">
  10471. <a name="id-1.1.90.2.341.4"></a><h4>Parameters</h4>
  10472. <div class="informaltable"><table><tr>
  10473. <td class="parameter_name"><p>signum</p></td>
  10474. <td class="parameter_description">
  10475. <p>the signal number. See the <code class="code">signal</code> documentation</p>
  10476. <p>Passed as <code class="code">signum</code></p>
  10477. </td>
  10478. </tr></table></div>
  10479. </div>
  10480. </div>
  10481. <div class="refsect2">
  10482. <a name="id-1.1.90.2.342"></a><h3>strstr-len</h3>
  10483. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strstr-len haystack haystack-len needle))
  10484. </pre></div>
  10485. <p>Searches the string <em class="parameter"><code>haystack</code></em> for the first occurrence
  10486. of the string <em class="parameter"><code>needle</code></em>, limiting the length of the search
  10487. to <em class="parameter"><code>haystack_len</code></em>.</p>
  10488. <div class="refsect3">
  10489. <a name="id-1.1.90.2.342.4"></a><h4>Parameters</h4>
  10490. <div class="informaltable"><table>
  10491. <tr>
  10492. <td class="parameter_name"><p>haystack</p></td>
  10493. <td class="parameter_description">
  10494. <p>a string</p>
  10495. <p>Passed as <code class="code">haystack</code></p>
  10496. </td>
  10497. </tr>
  10498. <tr>
  10499. <td class="parameter_name"><p>haystack_len</p></td>
  10500. <td class="parameter_description">
  10501. <p>the maximum length of <em class="parameter"><code>haystack</code></em>. Note that -1 is
  10502. a valid length, if <em class="parameter"><code>haystack</code></em> is nul-terminated, meaning it will
  10503. search through the whole string.</p>
  10504. <p>Passed as <code class="code">haystack-len</code></p>
  10505. </td>
  10506. </tr>
  10507. <tr>
  10508. <td class="parameter_name"><p>needle</p></td>
  10509. <td class="parameter_description">
  10510. <p>the string to search for</p>
  10511. <p>Passed as <code class="code">needle</code></p>
  10512. </td>
  10513. </tr>
  10514. </table></div>
  10515. </div>
  10516. </div>
  10517. <div class="refsect2">
  10518. <a name="id-1.1.90.2.343"></a><h3>strtod</h3>
  10519. <div class="informalexample"><pre class="programlisting">(define-values (%return endptr) (strtod nptr))
  10520. </pre></div>
  10521. <p>Converts a string to a <span class="type">gdouble</span> value.
  10522. It calls the standard <code class="function">strtod()</code> function to handle the conversion, but
  10523. if the string is not completely converted it attempts the conversion
  10524. again with <code class="function">g_ascii_strtod()</code>, and returns the best match.
  10525. </p>
  10526. <p>This function should seldom be used. The normal situation when reading
  10527. numbers not for human consumption is to use <code class="function">g_ascii_strtod()</code>. Only when
  10528. you know that you must expect both locale formatted and C formatted numbers
  10529. should you use this. Make sure that you don't pass strings such as comma
  10530. separated lists of values, since the commas may be interpreted as a decimal
  10531. point in some locales, causing unexpected results.</p>
  10532. <div class="refsect3">
  10533. <a name="id-1.1.90.2.343.5"></a><h4>Parameters</h4>
  10534. <div class="informaltable"><table>
  10535. <tr>
  10536. <td class="parameter_name"><p>nptr</p></td>
  10537. <td class="parameter_description">
  10538. <p>the string to convert to a numeric value.</p>
  10539. <p>Passed as <code class="code">nptr</code></p>
  10540. </td>
  10541. </tr>
  10542. <tr>
  10543. <td class="parameter_name"><p>endptr</p></td>
  10544. <td class="parameter_description">
  10545. <p>if non-<code class="constant">NULL</code>, it returns the
  10546. character after the last character used in the conversion.</p>
  10547. <p>Passed as <code class="code">endptr</code></p>
  10548. </td>
  10549. </tr>
  10550. </table></div>
  10551. </div>
  10552. </div>
  10553. <div class="refsect2">
  10554. <a name="id-1.1.90.2.344"></a><h3>strv-contains?</h3>
  10555. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strv-contains? strv str))
  10556. </pre></div>
  10557. <p>Checks if <em class="parameter"><code>strv</code></em> contains <em class="parameter"><code>str</code></em>. <em class="parameter"><code>strv</code></em> must not be <code class="constant">NULL</code>.</p>
  10558. <div class="refsect3">
  10559. <a name="id-1.1.90.2.344.4"></a><h4>Parameters</h4>
  10560. <div class="informaltable"><table>
  10561. <tr>
  10562. <td class="parameter_name"><p>strv</p></td>
  10563. <td class="parameter_description">
  10564. <p>a <code class="constant">NULL</code>-terminated array of strings</p>
  10565. <p>Passed as <code class="code">strv</code></p>
  10566. </td>
  10567. </tr>
  10568. <tr>
  10569. <td class="parameter_name"><p>str</p></td>
  10570. <td class="parameter_description">
  10571. <p>a string</p>
  10572. <p>Passed as <code class="code">str</code></p>
  10573. </td>
  10574. </tr>
  10575. </table></div>
  10576. </div>
  10577. </div>
  10578. <div class="refsect2">
  10579. <a name="id-1.1.90.2.345"></a><h3>strv-equal?</h3>
  10580. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strv-equal? strv1 strv2))
  10581. </pre></div>
  10582. <p>Checks if <em class="parameter"><code>strv1</code></em> and <em class="parameter"><code>strv2</code></em> contain exactly the same elements in exactly the
  10583. same order. Elements are compared using <code class="function">g_str_equal()</code>. To match independently
  10584. of order, sort the arrays first (using <code class="function">g_qsort_with_data()</code> or similar).
  10585. </p>
  10586. <p>Two empty arrays are considered equal. Neither <em class="parameter"><code>strv1</code></em> not <em class="parameter"><code>strv2</code></em> may be
  10587. <code class="constant">NULL</code>.</p>
  10588. <div class="refsect3">
  10589. <a name="id-1.1.90.2.345.5"></a><h4>Parameters</h4>
  10590. <div class="informaltable"><table>
  10591. <tr>
  10592. <td class="parameter_name"><p>strv1</p></td>
  10593. <td class="parameter_description">
  10594. <p>a <code class="constant">NULL</code>-terminated array of strings</p>
  10595. <p>Passed as <code class="code">strv1</code></p>
  10596. </td>
  10597. </tr>
  10598. <tr>
  10599. <td class="parameter_name"><p>strv2</p></td>
  10600. <td class="parameter_description">
  10601. <p>another <code class="constant">NULL</code>-terminated array of strings</p>
  10602. <p>Passed as <code class="code">strv2</code></p>
  10603. </td>
  10604. </tr>
  10605. </table></div>
  10606. </div>
  10607. </div>
  10608. <div class="refsect2">
  10609. <a name="id-1.1.90.2.346"></a><h3>strv-get-type</h3>
  10610. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strv-get-type))
  10611. </pre></div>
  10612. <p>Undocumented</p>
  10613. </div>
  10614. <div class="refsect2">
  10615. <a name="id-1.1.90.2.347"></a><h3>strv-length</h3>
  10616. <div class="informalexample"><pre class="programlisting">(define-values (%return) (strv-length str-array))
  10617. </pre></div>
  10618. <p>Returns the length of the given <code class="constant">NULL</code>-terminated
  10619. string array <em class="parameter"><code>str_array</code></em>. <em class="parameter"><code>str_array</code></em> must not be <code class="constant">NULL</code>.</p>
  10620. <div class="refsect3">
  10621. <a name="id-1.1.90.2.347.4"></a><h4>Parameters</h4>
  10622. <div class="informaltable"><table><tr>
  10623. <td class="parameter_name"><p>str_array</p></td>
  10624. <td class="parameter_description">
  10625. <p>a <code class="constant">NULL</code>-terminated array of strings</p>
  10626. <p>Passed as <code class="code">str-array</code></p>
  10627. </td>
  10628. </tr></table></div>
  10629. </div>
  10630. </div>
  10631. <div class="refsect2">
  10632. <a name="id-1.1.90.2.348"></a><h3>test-add-data-func</h3>
  10633. <div class="informalexample"><pre class="programlisting">(define-values () (test-add-data-func testpath test-data test-func))
  10634. </pre></div>
  10635. <p>Create a new test case, similar to <code class="function">g_test_create_case()</code>. However
  10636. the test is assumed to use no fixture, and test suites are automatically
  10637. created on the fly and added to the root fixture, based on the
  10638. slash-separated portions of <em class="parameter"><code>testpath</code></em>. The <em class="parameter"><code>test_data</code></em> argument
  10639. will be passed as first argument to <em class="parameter"><code>test_func</code></em>.
  10640. </p>
  10641. <p>If <em class="parameter"><code>testpath</code></em> includes the component "subprocess" anywhere in it,
  10642. the test will be skipped by default, and only run if explicitly
  10643. required via the <code class="code">-p</code> command-line option or <code class="function">g_test_trap_subprocess()</code>.
  10644. </p>
  10645. <p>No component of <em class="parameter"><code>testpath</code></em> may start with a dot (<code class="code">.</code>) if the
  10646. <code class="constant">G_TEST_OPTION_ISOLATE_DIRS</code> option is being used; and it is recommended to
  10647. do so even if it isn’t.</p>
  10648. <div class="refsect3">
  10649. <a name="id-1.1.90.2.348.6"></a><h4>Parameters</h4>
  10650. <div class="informaltable"><table>
  10651. <tr>
  10652. <td class="parameter_name"><p>testpath</p></td>
  10653. <td class="parameter_description">
  10654. <p>/-separated test case path name for the test.</p>
  10655. <p>Passed as <code class="code">testpath</code></p>
  10656. </td>
  10657. </tr>
  10658. <tr>
  10659. <td class="parameter_name"><p>test_data</p></td>
  10660. <td class="parameter_description">
  10661. <p>Test data argument for the test function.</p>
  10662. <p>Passed as <code class="code">test-data</code></p>
  10663. </td>
  10664. </tr>
  10665. <tr>
  10666. <td class="parameter_name"><p>test_func</p></td>
  10667. <td class="parameter_description">
  10668. <p>The test function to invoke for this test.</p>
  10669. <p>Passed as <code class="code">test-func</code></p>
  10670. </td>
  10671. </tr>
  10672. </table></div>
  10673. </div>
  10674. </div>
  10675. <div class="refsect2">
  10676. <a name="id-1.1.90.2.349"></a><h3>test-add-data-func-full</h3>
  10677. <div class="informalexample"><pre class="programlisting">(define-values
  10678. ()
  10679. (test-add-data-func-full testpath test-data test-func data-free-func))
  10680. </pre></div>
  10681. <p>Create a new test case, as with <code class="function">g_test_add_data_func()</code>, but freeing
  10682. <em class="parameter"><code>test_data</code></em> after the test run is complete.</p>
  10683. <div class="refsect3">
  10684. <a name="id-1.1.90.2.349.4"></a><h4>Parameters</h4>
  10685. <div class="informaltable"><table>
  10686. <tr>
  10687. <td class="parameter_name"><p>testpath</p></td>
  10688. <td class="parameter_description">
  10689. <p>/-separated test case path name for the test.</p>
  10690. <p>Passed as <code class="code">testpath</code></p>
  10691. </td>
  10692. </tr>
  10693. <tr>
  10694. <td class="parameter_name"><p>test_data</p></td>
  10695. <td class="parameter_description">
  10696. <p>Test data argument for the test function.</p>
  10697. <p>Passed as <code class="code">test-data</code></p>
  10698. </td>
  10699. </tr>
  10700. <tr>
  10701. <td class="parameter_name"><p>test_func</p></td>
  10702. <td class="parameter_description">
  10703. <p>The test function to invoke for this test.</p>
  10704. <p>Passed as <code class="code">test-func</code></p>
  10705. </td>
  10706. </tr>
  10707. <tr>
  10708. <td class="parameter_name"><p>data_free_func</p></td>
  10709. <td class="parameter_description">
  10710. <p><span class="type">GDestroyNotify</span> for <em class="parameter"><code>test_data</code></em>.</p>
  10711. <p>Passed as <code class="code">data-free-func</code></p>
  10712. </td>
  10713. </tr>
  10714. </table></div>
  10715. </div>
  10716. </div>
  10717. <div class="refsect2">
  10718. <a name="id-1.1.90.2.350"></a><h3>test-add-func</h3>
  10719. <div class="informalexample"><pre class="programlisting">(define-values () (test-add-func testpath test-func))
  10720. </pre></div>
  10721. <p>Create a new test case, similar to <code class="function">g_test_create_case()</code>. However
  10722. the test is assumed to use no fixture, and test suites are automatically
  10723. created on the fly and added to the root fixture, based on the
  10724. slash-separated portions of <em class="parameter"><code>testpath</code></em>.
  10725. </p>
  10726. <p>If <em class="parameter"><code>testpath</code></em> includes the component "subprocess" anywhere in it,
  10727. the test will be skipped by default, and only run if explicitly
  10728. required via the <code class="code">-p</code> command-line option or <code class="function">g_test_trap_subprocess()</code>.
  10729. </p>
  10730. <p>No component of <em class="parameter"><code>testpath</code></em> may start with a dot (<code class="code">.</code>) if the
  10731. <code class="constant">G_TEST_OPTION_ISOLATE_DIRS</code> option is being used; and it is recommended to
  10732. do so even if it isn’t.</p>
  10733. <div class="refsect3">
  10734. <a name="id-1.1.90.2.350.6"></a><h4>Parameters</h4>
  10735. <div class="informaltable"><table>
  10736. <tr>
  10737. <td class="parameter_name"><p>testpath</p></td>
  10738. <td class="parameter_description">
  10739. <p>/-separated test case path name for the test.</p>
  10740. <p>Passed as <code class="code">testpath</code></p>
  10741. </td>
  10742. </tr>
  10743. <tr>
  10744. <td class="parameter_name"><p>test_func</p></td>
  10745. <td class="parameter_description">
  10746. <p>The test function to invoke for this test.</p>
  10747. <p>Passed as <code class="code">test-func</code></p>
  10748. </td>
  10749. </tr>
  10750. </table></div>
  10751. </div>
  10752. </div>
  10753. <div class="refsect2">
  10754. <a name="id-1.1.90.2.351"></a><h3>test-assert-expected-messages-internal</h3>
  10755. <div class="informalexample"><pre class="programlisting">(define-values
  10756. ()
  10757. (test-assert-expected-messages-internal domain file line func))
  10758. </pre></div>
  10759. <p>Undocumented</p>
  10760. <div class="refsect3">
  10761. <a name="id-1.1.90.2.351.4"></a><h4>Parameters</h4>
  10762. <div class="informaltable"><table>
  10763. <tr>
  10764. <td class="parameter_name"><p>domain</p></td>
  10765. <td class="parameter_description">
  10766. <p></p>
  10767. <p>Passed as <code class="code">domain</code></p>
  10768. </td>
  10769. </tr>
  10770. <tr>
  10771. <td class="parameter_name"><p>file</p></td>
  10772. <td class="parameter_description">
  10773. <p></p>
  10774. <p>Passed as <code class="code">file</code></p>
  10775. </td>
  10776. </tr>
  10777. <tr>
  10778. <td class="parameter_name"><p>line</p></td>
  10779. <td class="parameter_description">
  10780. <p></p>
  10781. <p>Passed as <code class="code">line</code></p>
  10782. </td>
  10783. </tr>
  10784. <tr>
  10785. <td class="parameter_name"><p>func</p></td>
  10786. <td class="parameter_description">
  10787. <p></p>
  10788. <p>Passed as <code class="code">func</code></p>
  10789. </td>
  10790. </tr>
  10791. </table></div>
  10792. </div>
  10793. </div>
  10794. <div class="refsect2">
  10795. <a name="id-1.1.90.2.352"></a><h3>test-bug</h3>
  10796. <div class="informalexample"><pre class="programlisting">(define-values () (test-bug bug-uri-snippet))
  10797. </pre></div>
  10798. <p>This function adds a message to test reports that
  10799. associates a bug URI with a test case.
  10800. Bug URIs are constructed from a base URI set with <code class="function">g_test_bug_base()</code>
  10801. and <em class="parameter"><code>bug_uri_snippet</code></em>. If <code class="function">g_test_bug_base()</code> has not been called, it is
  10802. assumed to be the empty string, so a full URI can be provided to
  10803. <code class="function">g_test_bug()</code> instead.</p>
  10804. <div class="refsect3">
  10805. <a name="id-1.1.90.2.352.4"></a><h4>Parameters</h4>
  10806. <div class="informaltable"><table><tr>
  10807. <td class="parameter_name"><p>bug_uri_snippet</p></td>
  10808. <td class="parameter_description">
  10809. <p>Bug specific bug tracker URI portion.</p>
  10810. <p>Passed as <code class="code">bug-uri-snippet</code></p>
  10811. </td>
  10812. </tr></table></div>
  10813. </div>
  10814. </div>
  10815. <div class="refsect2">
  10816. <a name="id-1.1.90.2.353"></a><h3>test-bug-base</h3>
  10817. <div class="informalexample"><pre class="programlisting">(define-values () (test-bug-base uri-pattern))
  10818. </pre></div>
  10819. <p>Specify the base URI for bug reports.
  10820. </p>
  10821. <p>The base URI is used to construct bug report messages for
  10822. <code class="function">g_test_message()</code> when <code class="function">g_test_bug()</code> is called.
  10823. Calling this function outside of a test case sets the
  10824. default base URI for all test cases. Calling it from within
  10825. a test case changes the base URI for the scope of the test
  10826. case only.
  10827. Bug URIs are constructed by appending a bug specific URI
  10828. portion to <em class="parameter"><code>uri_pattern</code></em>, or by replacing the special string
  10829. '\%s' within <em class="parameter"><code>uri_pattern</code></em> if that is present.
  10830. </p>
  10831. <p>If <code class="function">g_test_bug_base()</code> is not called, bug URIs are formed solely
  10832. from the value provided by <code class="function">g_test_bug()</code>.</p>
  10833. <div class="refsect3">
  10834. <a name="id-1.1.90.2.353.6"></a><h4>Parameters</h4>
  10835. <div class="informaltable"><table><tr>
  10836. <td class="parameter_name"><p>uri_pattern</p></td>
  10837. <td class="parameter_description">
  10838. <p>the base pattern for bug URIs</p>
  10839. <p>Passed as <code class="code">uri-pattern</code></p>
  10840. </td>
  10841. </tr></table></div>
  10842. </div>
  10843. </div>
  10844. <div class="refsect2">
  10845. <a name="id-1.1.90.2.354"></a><h3>test-expect-message</h3>
  10846. <div class="informalexample"><pre class="programlisting">(define-values () (test-expect-message log-domain log-level pattern))
  10847. </pre></div>
  10848. <p>Indicates that a message with the given <em class="parameter"><code>log_domain</code></em> and <em class="parameter"><code>log_level</code></em>,
  10849. with text matching <em class="parameter"><code>pattern</code></em>, is expected to be logged. When this
  10850. message is logged, it will not be printed, and the test case will
  10851. not abort.
  10852. </p>
  10853. <p>This API may only be used with the old logging API (<code class="function">g_log()</code> without
  10854. <code class="constant">G_LOG_USE_STRUCTURED</code> defined). It will not work with the structured logging
  10855. API. See [Testing for Messages][testing-for-messages].
  10856. </p>
  10857. <p>Use <code class="function">g_test_assert_expected_messages()</code> to assert that all
  10858. previously-expected messages have been seen and suppressed.
  10859. </p>
  10860. <p>You can call this multiple times in a row, if multiple messages are
  10861. expected as a result of a single call. (The messages must appear in
  10862. the same order as the calls to <code class="function">g_test_expect_message()</code>.)
  10863. </p>
  10864. <p>For example:
  10865. </p>
  10866. <div class="informalexample"><pre class="programlisting">
  10867. // g_main_context_push_thread_default() should fail if the
  10868. // context is already owned by another thread.
  10869. g_test_expect_message (G_LOG_DOMAIN,
  10870. G_LOG_LEVEL_CRITICAL,
  10871. "assertion*acquired_context*failed");
  10872. g_main_context_push_thread_default (bad_context);
  10873. g_test_assert_expected_messages ();
  10874. </pre></div>
  10875. <p>Note that you cannot use this to test <code class="function">g_error()</code> messages, since
  10876. <code class="function">g_error()</code> intentionally never returns even if the program doesn't
  10877. abort; use <code class="function">g_test_trap_subprocess()</code> in this case.
  10878. </p>
  10879. <p>If messages at <code class="constant">G_LOG_LEVEL_DEBUG</code> are emitted, but not explicitly
  10880. expected via <code class="function">g_test_expect_message()</code> then they will be ignored.</p>
  10881. <div class="refsect3">
  10882. <a name="id-1.1.90.2.354.11"></a><h4>Parameters</h4>
  10883. <div class="informaltable"><table>
  10884. <tr>
  10885. <td class="parameter_name"><p>log_domain</p></td>
  10886. <td class="parameter_description">
  10887. <p>the log domain of the message</p>
  10888. <p>Passed as <code class="code">log-domain</code></p>
  10889. </td>
  10890. </tr>
  10891. <tr>
  10892. <td class="parameter_name"><p>log_level</p></td>
  10893. <td class="parameter_description">
  10894. <p>the log level of the message</p>
  10895. <p>Passed as <code class="code">log-level</code></p>
  10896. </td>
  10897. </tr>
  10898. <tr>
  10899. <td class="parameter_name"><p>pattern</p></td>
  10900. <td class="parameter_description">
  10901. <p>a glob-style [pattern][glib-Glob-style-pattern-matching]</p>
  10902. <p>Passed as <code class="code">pattern</code></p>
  10903. </td>
  10904. </tr>
  10905. </table></div>
  10906. </div>
  10907. </div>
  10908. <div class="refsect2">
  10909. <a name="id-1.1.90.2.355"></a><h3>test-fail</h3>
  10910. <div class="informalexample"><pre class="programlisting">(define-values () (test-fail))
  10911. </pre></div>
  10912. <p>Indicates that a test failed. This function can be called
  10913. multiple times from the same test. You can use this function
  10914. if your test failed in a recoverable way.
  10915. </p>
  10916. <p>Do not use this function if the failure of a test could cause
  10917. other tests to malfunction.
  10918. </p>
  10919. <p>Calling this function will not stop the test from running, you
  10920. need to return from the test function yourself. So you can
  10921. produce additional diagnostic messages or even continue running
  10922. the test.
  10923. </p>
  10924. <p>If not called from inside a test, this function does nothing.</p>
  10925. </div>
  10926. <div class="refsect2">
  10927. <a name="id-1.1.90.2.356"></a><h3>test-failed?</h3>
  10928. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-failed?))
  10929. </pre></div>
  10930. <p>Returns whether a test has already failed. This will
  10931. be the case when <code class="function">g_test_fail()</code>, <code class="function">g_test_incomplete()</code>
  10932. or <code class="function">g_test_skip()</code> have been called, but also if an
  10933. assertion has failed.
  10934. </p>
  10935. <p>This can be useful to return early from a test if
  10936. continuing after a failed assertion might be harmful.
  10937. </p>
  10938. <p>The return value of this function is only meaningful
  10939. if it is called from inside a test function.</p>
  10940. </div>
  10941. <div class="refsect2">
  10942. <a name="id-1.1.90.2.357"></a><h3>test-get-dir</h3>
  10943. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-get-dir file-type))
  10944. </pre></div>
  10945. <p>Gets the pathname of the directory containing test files of the type
  10946. specified by <em class="parameter"><code>file_type</code></em>.
  10947. </p>
  10948. <p>This is approximately the same as calling g_test_build_filename("."),
  10949. but you don't need to free the return value.</p>
  10950. <div class="refsect3">
  10951. <a name="id-1.1.90.2.357.5"></a><h4>Parameters</h4>
  10952. <div class="informaltable"><table><tr>
  10953. <td class="parameter_name"><p>file_type</p></td>
  10954. <td class="parameter_description">
  10955. <p>the type of file (built vs. distributed)</p>
  10956. <p>Passed as <code class="code">file-type</code></p>
  10957. </td>
  10958. </tr></table></div>
  10959. </div>
  10960. </div>
  10961. <div class="refsect2">
  10962. <a name="id-1.1.90.2.358"></a><h3>test-get-path</h3>
  10963. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-get-path))
  10964. </pre></div>
  10965. <p>Undocumented</p>
  10966. </div>
  10967. <div class="refsect2">
  10968. <a name="id-1.1.90.2.359"></a><h3>test-incomplete</h3>
  10969. <div class="informalexample"><pre class="programlisting">(define-values () (test-incomplete msg))
  10970. </pre></div>
  10971. <p>Indicates that a test failed because of some incomplete
  10972. functionality. This function can be called multiple times
  10973. from the same test.
  10974. </p>
  10975. <p>Calling this function will not stop the test from running, you
  10976. need to return from the test function yourself. So you can
  10977. produce additional diagnostic messages or even continue running
  10978. the test.
  10979. </p>
  10980. <p>If not called from inside a test, this function does nothing.</p>
  10981. <div class="refsect3">
  10982. <a name="id-1.1.90.2.359.6"></a><h4>Parameters</h4>
  10983. <div class="informaltable"><table><tr>
  10984. <td class="parameter_name"><p>msg</p></td>
  10985. <td class="parameter_description">
  10986. <p>explanation</p>
  10987. <p>Passed as <code class="code">msg</code></p>
  10988. </td>
  10989. </tr></table></div>
  10990. </div>
  10991. </div>
  10992. <div class="refsect2">
  10993. <a name="id-1.1.90.2.360"></a><h3>test-log-type-name</h3>
  10994. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-log-type-name log-type))
  10995. </pre></div>
  10996. <p>Undocumented</p>
  10997. <div class="refsect3">
  10998. <a name="id-1.1.90.2.360.4"></a><h4>Parameters</h4>
  10999. <div class="informaltable"><table><tr>
  11000. <td class="parameter_name"><p>log_type</p></td>
  11001. <td class="parameter_description">
  11002. <p></p>
  11003. <p>Passed as <code class="code">log-type</code></p>
  11004. </td>
  11005. </tr></table></div>
  11006. </div>
  11007. </div>
  11008. <div class="refsect2">
  11009. <a name="id-1.1.90.2.361"></a><h3>test-queue-destroy</h3>
  11010. <div class="informalexample"><pre class="programlisting">(define-values () (test-queue-destroy destroy-func destroy-data))
  11011. </pre></div>
  11012. <p>This function enqueus a callback <em class="parameter"><code>destroy_func</code></em> to be executed
  11013. during the next test case teardown phase. This is most useful
  11014. to auto destruct allocated test resources at the end of a test run.
  11015. Resources are released in reverse queue order, that means enqueueing
  11016. callback A before callback B will cause <code class="function">B()</code> to be called before
  11017. <code class="function">A()</code> during teardown.</p>
  11018. <div class="refsect3">
  11019. <a name="id-1.1.90.2.361.4"></a><h4>Parameters</h4>
  11020. <div class="informaltable"><table>
  11021. <tr>
  11022. <td class="parameter_name"><p>destroy_func</p></td>
  11023. <td class="parameter_description">
  11024. <p>Destroy callback for teardown phase.</p>
  11025. <p>Passed as <code class="code">destroy-func</code></p>
  11026. </td>
  11027. </tr>
  11028. <tr>
  11029. <td class="parameter_name"><p>destroy_data</p></td>
  11030. <td class="parameter_description">
  11031. <p>Destroy callback data.</p>
  11032. <p>Passed as <code class="code">destroy-data</code></p>
  11033. </td>
  11034. </tr>
  11035. </table></div>
  11036. </div>
  11037. </div>
  11038. <div class="refsect2">
  11039. <a name="id-1.1.90.2.362"></a><h3>test-queue-free</h3>
  11040. <div class="informalexample"><pre class="programlisting">(define-values () (test-queue-free gfree-pointer))
  11041. </pre></div>
  11042. <p>Enqueue a pointer to be released with <code class="function">g_free()</code> during the next
  11043. teardown phase. This is equivalent to calling <code class="function">g_test_queue_destroy()</code>
  11044. with a destroy callback of <code class="function">g_free()</code>.</p>
  11045. <div class="refsect3">
  11046. <a name="id-1.1.90.2.362.4"></a><h4>Parameters</h4>
  11047. <div class="informaltable"><table><tr>
  11048. <td class="parameter_name"><p>gfree_pointer</p></td>
  11049. <td class="parameter_description">
  11050. <p>the pointer to be stored.</p>
  11051. <p>Passed as <code class="code">gfree-pointer</code></p>
  11052. </td>
  11053. </tr></table></div>
  11054. </div>
  11055. </div>
  11056. <div class="refsect2">
  11057. <a name="id-1.1.90.2.363"></a><h3>test-rand-double</h3>
  11058. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-rand-double))
  11059. </pre></div>
  11060. <p>Get a reproducible random floating point number,
  11061. see <code class="function">g_test_rand_int()</code> for details on test case random numbers.</p>
  11062. </div>
  11063. <div class="refsect2">
  11064. <a name="id-1.1.90.2.364"></a><h3>test-rand-double-range</h3>
  11065. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-rand-double-range range-start range-end))
  11066. </pre></div>
  11067. <p>Get a reproducible random floating pointer number out of a specified range,
  11068. see <code class="function">g_test_rand_int()</code> for details on test case random numbers.</p>
  11069. <div class="refsect3">
  11070. <a name="id-1.1.90.2.364.4"></a><h4>Parameters</h4>
  11071. <div class="informaltable"><table>
  11072. <tr>
  11073. <td class="parameter_name"><p>range_start</p></td>
  11074. <td class="parameter_description">
  11075. <p>the minimum value returned by this function</p>
  11076. <p>Passed as <code class="code">range-start</code></p>
  11077. </td>
  11078. </tr>
  11079. <tr>
  11080. <td class="parameter_name"><p>range_end</p></td>
  11081. <td class="parameter_description">
  11082. <p>the minimum value not returned by this function</p>
  11083. <p>Passed as <code class="code">range-end</code></p>
  11084. </td>
  11085. </tr>
  11086. </table></div>
  11087. </div>
  11088. </div>
  11089. <div class="refsect2">
  11090. <a name="id-1.1.90.2.365"></a><h3>test-rand-int</h3>
  11091. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-rand-int))
  11092. </pre></div>
  11093. <p>Get a reproducible random integer number.
  11094. </p>
  11095. <p>The random numbers generated by the g_test_rand_*() family of functions
  11096. change with every new test program start, unless the --seed option is
  11097. given when starting test programs.
  11098. </p>
  11099. <p>For individual test cases however, the random number generator is
  11100. reseeded, to avoid dependencies between tests and to make --seed
  11101. effective for all test cases.</p>
  11102. </div>
  11103. <div class="refsect2">
  11104. <a name="id-1.1.90.2.366"></a><h3>test-rand-int-range</h3>
  11105. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-rand-int-range begin end))
  11106. </pre></div>
  11107. <p>Get a reproducible random integer number out of a specified range,
  11108. see <code class="function">g_test_rand_int()</code> for details on test case random numbers.</p>
  11109. <div class="refsect3">
  11110. <a name="id-1.1.90.2.366.4"></a><h4>Parameters</h4>
  11111. <div class="informaltable"><table>
  11112. <tr>
  11113. <td class="parameter_name"><p>begin</p></td>
  11114. <td class="parameter_description">
  11115. <p>the minimum value returned by this function</p>
  11116. <p>Passed as <code class="code">begin</code></p>
  11117. </td>
  11118. </tr>
  11119. <tr>
  11120. <td class="parameter_name"><p>end</p></td>
  11121. <td class="parameter_description">
  11122. <p>the smallest value not to be returned by this function</p>
  11123. <p>Passed as <code class="code">end</code></p>
  11124. </td>
  11125. </tr>
  11126. </table></div>
  11127. </div>
  11128. </div>
  11129. <div class="refsect2">
  11130. <a name="id-1.1.90.2.367"></a><h3>test-run</h3>
  11131. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-run))
  11132. </pre></div>
  11133. <p>Runs all tests under the toplevel suite which can be retrieved
  11134. with <code class="function">g_test_get_root()</code>. Similar to <code class="function">g_test_run_suite()</code>, the test
  11135. cases to be run are filtered according to test path arguments
  11136. (<code class="code">-p testpath</code> and <code class="code">-s testpath</code>) as parsed by <code class="function">g_test_init()</code>.
  11137. <code class="function">g_test_run_suite()</code> or <code class="function">g_test_run()</code> may only be called once in a
  11138. program.
  11139. </p>
  11140. <p>In general, the tests and sub-suites within each suite are run in
  11141. the order in which they are defined. However, note that prior to
  11142. GLib 2.36, there was a bug in the <code class="code">g_test_add_*</code>
  11143. functions which caused them to create multiple suites with the same
  11144. name, meaning that if you created tests "/foo/simple",
  11145. "/bar/simple", and "/foo/using-bar" in that order, they would get
  11146. run in that order (since <code class="function">g_test_run()</code> would run the first "/foo"
  11147. suite, then the "/bar" suite, then the second "/foo" suite). As of
  11148. 2.36, this bug is fixed, and adding the tests in that order would
  11149. result in a running order of "/foo/simple", "/foo/using-bar",
  11150. "/bar/simple". If this new ordering is sub-optimal (because it puts
  11151. more-complicated tests before simpler ones, making it harder to
  11152. figure out exactly what has failed), you can fix it by changing the
  11153. test paths to group tests by suite in a way that will result in the
  11154. desired running order. Eg, "/simple/foo", "/simple/bar",
  11155. "/complex/foo-using-bar".
  11156. </p>
  11157. <p>However, you should never make the actual result of a test depend
  11158. on the order that tests are run in. If you need to ensure that some
  11159. particular code runs before or after a given test case, use
  11160. <code class="function">g_test_add()</code>, which lets you specify setup and teardown functions.
  11161. </p>
  11162. <p>If all tests are skipped or marked as incomplete (expected failures),
  11163. this function will return 0 if producing TAP output, or 77 (treated
  11164. as "skip test" by Automake) otherwise.</p>
  11165. </div>
  11166. <div class="refsect2">
  11167. <a name="id-1.1.90.2.368"></a><h3>test-set-nonfatal-assertions</h3>
  11168. <div class="informalexample"><pre class="programlisting">(define-values () (test-set-nonfatal-assertions))
  11169. </pre></div>
  11170. <p>Changes the behaviour of the various <code class="code">g_assert_*()</code> macros,
  11171. <code class="function">g_test_assert_expected_messages()</code> and the various
  11172. <code class="code">g_test_trap_assert_*()</code> macros to not abort to program, but instead
  11173. call <code class="function">g_test_fail()</code> and continue. (This also changes the behavior of
  11174. <code class="function">g_test_fail()</code> so that it will not cause the test program to abort
  11175. after completing the failed test.)
  11176. </p>
  11177. <p>Note that the <code class="function">g_assert_not_reached()</code> and <code class="function">g_assert()</code> macros are not
  11178. affected by this.
  11179. </p>
  11180. <p>This function can only be called after <code class="function">g_test_init()</code>.</p>
  11181. </div>
  11182. <div class="refsect2">
  11183. <a name="id-1.1.90.2.369"></a><h3>test-skip</h3>
  11184. <div class="informalexample"><pre class="programlisting">(define-values () (test-skip msg))
  11185. </pre></div>
  11186. <p>Indicates that a test was skipped.
  11187. </p>
  11188. <p>Calling this function will not stop the test from running, you
  11189. need to return from the test function yourself. So you can
  11190. produce additional diagnostic messages or even continue running
  11191. the test.
  11192. </p>
  11193. <p>If not called from inside a test, this function does nothing.</p>
  11194. <div class="refsect3">
  11195. <a name="id-1.1.90.2.369.6"></a><h4>Parameters</h4>
  11196. <div class="informaltable"><table><tr>
  11197. <td class="parameter_name"><p>msg</p></td>
  11198. <td class="parameter_description">
  11199. <p>explanation</p>
  11200. <p>Passed as <code class="code">msg</code></p>
  11201. </td>
  11202. </tr></table></div>
  11203. </div>
  11204. </div>
  11205. <div class="refsect2">
  11206. <a name="id-1.1.90.2.370"></a><h3>test-subprocess?</h3>
  11207. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-subprocess?))
  11208. </pre></div>
  11209. <p>Returns <code class="constant">TRUE</code> (after <code class="function">g_test_init()</code> has been called) if the test
  11210. program is running under <code class="function">g_test_trap_subprocess()</code>.</p>
  11211. </div>
  11212. <div class="refsect2">
  11213. <a name="id-1.1.90.2.371"></a><h3>test-summary</h3>
  11214. <div class="informalexample"><pre class="programlisting">(define-values () (test-summary summary))
  11215. </pre></div>
  11216. <p>Set the summary for a test, which describes what the test checks, and how it
  11217. goes about checking it. This may be included in test report output, and is
  11218. useful documentation for anyone reading the source code or modifying a test
  11219. in future. It must be a single line.
  11220. </p>
  11221. <p>This should be called at the top of a test function.
  11222. </p>
  11223. <p>For example:
  11224. </p>
  11225. <div class="informalexample"><pre class="programlisting">
  11226. static void
  11227. test_array_sort (void)
  11228. {
  11229. g_test_summary ("Test my_array_sort() sorts the array correctly and stably, "
  11230. "including testing zero length and one-element arrays.");
  11231. }
  11232. </pre></div>
  11233. <div class="refsect3">
  11234. <a name="id-1.1.90.2.371.6"></a><h4>Parameters</h4>
  11235. <div class="informaltable"><table><tr>
  11236. <td class="parameter_name"><p>summary</p></td>
  11237. <td class="parameter_description">
  11238. <p>One or two sentences summarising what the test checks, and how it
  11239. checks it.</p>
  11240. <p>Passed as <code class="code">summary</code></p>
  11241. </td>
  11242. </tr></table></div>
  11243. </div>
  11244. </div>
  11245. <div class="refsect2">
  11246. <a name="id-1.1.90.2.372"></a><h3>test-timer-elapsed</h3>
  11247. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-timer-elapsed))
  11248. </pre></div>
  11249. <p>Get the time since the last start of the timer with <code class="function">g_test_timer_start()</code>.</p>
  11250. </div>
  11251. <div class="refsect2">
  11252. <a name="id-1.1.90.2.373"></a><h3>test-timer-last</h3>
  11253. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-timer-last))
  11254. </pre></div>
  11255. <p>Report the last result of <code class="function">g_test_timer_elapsed()</code>.</p>
  11256. </div>
  11257. <div class="refsect2">
  11258. <a name="id-1.1.90.2.374"></a><h3>test-timer-start</h3>
  11259. <div class="informalexample"><pre class="programlisting">(define-values () (test-timer-start))
  11260. </pre></div>
  11261. <p>Start a timing test. Call <code class="function">g_test_timer_elapsed()</code> when the task is supposed
  11262. to be done. Call this function again to restart the timer.</p>
  11263. </div>
  11264. <div class="refsect2">
  11265. <a name="id-1.1.90.2.375"></a><h3>test-trap-assertions</h3>
  11266. <div class="informalexample"><pre class="programlisting">(define-values
  11267. ()
  11268. (test-trap-assertions domain file line func assertion-flags pattern))
  11269. </pre></div>
  11270. <p>Undocumented</p>
  11271. <div class="refsect3">
  11272. <a name="id-1.1.90.2.375.4"></a><h4>Parameters</h4>
  11273. <div class="informaltable"><table>
  11274. <tr>
  11275. <td class="parameter_name"><p>domain</p></td>
  11276. <td class="parameter_description">
  11277. <p></p>
  11278. <p>Passed as <code class="code">domain</code></p>
  11279. </td>
  11280. </tr>
  11281. <tr>
  11282. <td class="parameter_name"><p>file</p></td>
  11283. <td class="parameter_description">
  11284. <p></p>
  11285. <p>Passed as <code class="code">file</code></p>
  11286. </td>
  11287. </tr>
  11288. <tr>
  11289. <td class="parameter_name"><p>line</p></td>
  11290. <td class="parameter_description">
  11291. <p></p>
  11292. <p>Passed as <code class="code">line</code></p>
  11293. </td>
  11294. </tr>
  11295. <tr>
  11296. <td class="parameter_name"><p>func</p></td>
  11297. <td class="parameter_description">
  11298. <p></p>
  11299. <p>Passed as <code class="code">func</code></p>
  11300. </td>
  11301. </tr>
  11302. <tr>
  11303. <td class="parameter_name"><p>assertion_flags</p></td>
  11304. <td class="parameter_description">
  11305. <p></p>
  11306. <p>Passed as <code class="code">assertion-flags</code></p>
  11307. </td>
  11308. </tr>
  11309. <tr>
  11310. <td class="parameter_name"><p>pattern</p></td>
  11311. <td class="parameter_description">
  11312. <p></p>
  11313. <p>Passed as <code class="code">pattern</code></p>
  11314. </td>
  11315. </tr>
  11316. </table></div>
  11317. </div>
  11318. </div>
  11319. <div class="refsect2">
  11320. <a name="id-1.1.90.2.376"></a><h3>test-trap-has-passed?</h3>
  11321. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-trap-has-passed?))
  11322. </pre></div>
  11323. <p>Check the result of the last <code class="function">g_test_trap_subprocess()</code> call.</p>
  11324. </div>
  11325. <div class="refsect2">
  11326. <a name="id-1.1.90.2.377"></a><h3>test-trap-reached-timeout?</h3>
  11327. <div class="informalexample"><pre class="programlisting">(define-values (%return) (test-trap-reached-timeout?))
  11328. </pre></div>
  11329. <p>Check the result of the last <code class="function">g_test_trap_subprocess()</code> call.</p>
  11330. </div>
  11331. <div class="refsect2">
  11332. <a name="id-1.1.90.2.378"></a><h3>test-trap-subprocess</h3>
  11333. <div class="informalexample"><pre class="programlisting">(define-values () (test-trap-subprocess test-path usec-timeout test-flags))
  11334. </pre></div>
  11335. <p>Respawns the test program to run only <em class="parameter"><code>test_path</code></em> in a subprocess.
  11336. This can be used for a test case that might not return, or that
  11337. might abort.
  11338. </p>
  11339. <p>If <em class="parameter"><code>test_path</code></em> is <code class="constant">NULL</code> then the same test is re-run in a subprocess.
  11340. You can use <code class="function">g_test_subprocess()</code> to determine whether the test is in
  11341. a subprocess or not.
  11342. </p>
  11343. <p><em class="parameter"><code>test_path</code></em> can also be the name of the parent test, followed by
  11344. "`/subprocess/<code class="code">" and then a name for the specific subtest (or just
  11345. ending with "</code>/subprocess`" if the test only has one child test);
  11346. tests with names of this form will automatically be skipped in the
  11347. parent process.
  11348. </p>
  11349. <p>If <em class="parameter"><code>usec_timeout</code></em> is non-0, the test subprocess is aborted and
  11350. considered failing if its run time exceeds it.
  11351. </p>
  11352. <p>The subprocess behavior can be configured with the
  11353. <span class="type">GTestSubprocessFlags</span> flags.
  11354. </p>
  11355. <p>You can use methods such as <code class="function">g_test_trap_assert_passed()</code>,
  11356. <code class="function">g_test_trap_assert_failed()</code>, and <code class="function">g_test_trap_assert_stderr()</code> to
  11357. check the results of the subprocess. (But note that
  11358. <code class="function">g_test_trap_assert_stdout()</code> and <code class="function">g_test_trap_assert_stderr()</code>
  11359. cannot be used if <em class="parameter"><code>test_flags</code></em> specifies that the child should
  11360. inherit the parent stdout/stderr.)
  11361. </p>
  11362. <p>If your <code class="code">main ()</code> needs to behave differently in
  11363. the subprocess, you can call <code class="function">g_test_subprocess()</code> (after calling
  11364. <code class="function">g_test_init()</code>) to see whether you are in a subprocess.
  11365. </p>
  11366. <p>The following example tests that calling
  11367. <code class="code">my_object_new(1000000)</code> will abort with an error
  11368. message.
  11369. </p>
  11370. <div class="informalexample"><pre class="programlisting">
  11371. static void
  11372. test_create_large_object (void)
  11373. {
  11374. if (g_test_subprocess ())
  11375. {
  11376. my_object_new (1000000);
  11377. return;
  11378. }
  11379. // Reruns this same test in a subprocess
  11380. g_test_trap_subprocess (NULL, 0, 0);
  11381. g_test_trap_assert_failed ();
  11382. g_test_trap_assert_stderr ("*ERROR*too large*");
  11383. }
  11384. int
  11385. main (int argc, char **argv)
  11386. {
  11387. g_test_init (&amp;argc, &amp;argv, NULL);
  11388. g_test_add_func ("/myobject/create_large_object",
  11389. test_create_large_object);
  11390. return g_test_run ();
  11391. }
  11392. </pre></div>
  11393. <div class="refsect3">
  11394. <a name="id-1.1.90.2.378.12"></a><h4>Parameters</h4>
  11395. <div class="informaltable"><table>
  11396. <tr>
  11397. <td class="parameter_name"><p>test_path</p></td>
  11398. <td class="parameter_description">
  11399. <p>Test to run in a subprocess</p>
  11400. <p>Passed as <code class="code">test-path</code></p>
  11401. </td>
  11402. </tr>
  11403. <tr>
  11404. <td class="parameter_name"><p>usec_timeout</p></td>
  11405. <td class="parameter_description">
  11406. <p>Timeout for the subprocess test in micro seconds.</p>
  11407. <p>Passed as <code class="code">usec-timeout</code></p>
  11408. </td>
  11409. </tr>
  11410. <tr>
  11411. <td class="parameter_name"><p>test_flags</p></td>
  11412. <td class="parameter_description">
  11413. <p>Flags to modify subprocess behaviour.</p>
  11414. <p>Passed as <code class="code">test-flags</code></p>
  11415. </td>
  11416. </tr>
  11417. </table></div>
  11418. </div>
  11419. </div>
  11420. <div class="refsect2">
  11421. <a name="id-1.1.90.2.379"></a><h3>thread-error-quark</h3>
  11422. <div class="informalexample"><pre class="programlisting">(define-values (%return) (thread-error-quark))
  11423. </pre></div>
  11424. <p>Undocumented</p>
  11425. </div>
  11426. <div class="refsect2">
  11427. <a name="id-1.1.90.2.380"></a><h3>thread-exit</h3>
  11428. <div class="informalexample"><pre class="programlisting">(define-values () (thread-exit retval))
  11429. </pre></div>
  11430. <p>Terminates the current thread.
  11431. </p>
  11432. <p>If another thread is waiting for us using <code class="function">g_thread_join()</code> then the
  11433. waiting thread will be woken up and get <em class="parameter"><code>retval</code></em> as the return value
  11434. of <code class="function">g_thread_join()</code>.
  11435. </p>
  11436. <p>Calling <code class="function">g_thread_exit()</code> with a parameter <em class="parameter"><code>retval</code></em> is equivalent to
  11437. returning <em class="parameter"><code>retval</code></em> from the function <em class="parameter"><code>func</code></em>, as given to <code class="function">g_thread_new()</code>.
  11438. </p>
  11439. <p>You must only call <code class="function">g_thread_exit()</code> from a thread that you created
  11440. yourself with <code class="function">g_thread_new()</code> or related APIs. You must not call
  11441. this function from a thread created with another threading library
  11442. or or from within a <span class="type">GThreadPool</span>.</p>
  11443. <div class="refsect3">
  11444. <a name="id-1.1.90.2.380.7"></a><h4>Parameters</h4>
  11445. <div class="informaltable"><table><tr>
  11446. <td class="parameter_name"><p>retval</p></td>
  11447. <td class="parameter_description">
  11448. <p>the return value of this thread</p>
  11449. <p>Passed as <code class="code">retval</code></p>
  11450. </td>
  11451. </tr></table></div>
  11452. </div>
  11453. </div>
  11454. <div class="refsect2">
  11455. <a name="id-1.1.90.2.381"></a><h3>thread-pool-get-max-idle-time</h3>
  11456. <div class="informalexample"><pre class="programlisting">(define-values (%return) (thread-pool-get-max-idle-time))
  11457. </pre></div>
  11458. <p>This function will return the maximum <em class="parameter"><code>interval</code></em> that a
  11459. thread will wait in the thread pool for new tasks before
  11460. being stopped.
  11461. </p>
  11462. <p>If this function returns 0, threads waiting in the thread
  11463. pool for new work are not stopped.</p>
  11464. </div>
  11465. <div class="refsect2">
  11466. <a name="id-1.1.90.2.382"></a><h3>thread-pool-get-max-unused-threads</h3>
  11467. <div class="informalexample"><pre class="programlisting">(define-values (%return) (thread-pool-get-max-unused-threads))
  11468. </pre></div>
  11469. <p>Returns the maximal allowed number of unused threads.</p>
  11470. </div>
  11471. <div class="refsect2">
  11472. <a name="id-1.1.90.2.383"></a><h3>thread-pool-get-num-unused-threads</h3>
  11473. <div class="informalexample"><pre class="programlisting">(define-values (%return) (thread-pool-get-num-unused-threads))
  11474. </pre></div>
  11475. <p>Returns the number of currently unused threads.</p>
  11476. </div>
  11477. <div class="refsect2">
  11478. <a name="id-1.1.90.2.384"></a><h3>thread-pool-set-max-idle-time</h3>
  11479. <div class="informalexample"><pre class="programlisting">(define-values () (thread-pool-set-max-idle-time interval))
  11480. </pre></div>
  11481. <p>This function will set the maximum <em class="parameter"><code>interval</code></em> that a thread
  11482. waiting in the pool for new tasks can be idle for before
  11483. being stopped. This function is similar to calling
  11484. <code class="function">g_thread_pool_stop_unused_threads()</code> on a regular timeout,
  11485. except this is done on a per thread basis.
  11486. </p>
  11487. <p>By setting <em class="parameter"><code>interval</code></em> to 0, idle threads will not be stopped.
  11488. </p>
  11489. <p>The default value is 15000 (15 seconds).</p>
  11490. <div class="refsect3">
  11491. <a name="id-1.1.90.2.384.6"></a><h4>Parameters</h4>
  11492. <div class="informaltable"><table><tr>
  11493. <td class="parameter_name"><p>interval</p></td>
  11494. <td class="parameter_description">
  11495. <p>the maximum <em class="parameter"><code>interval</code></em> (in milliseconds)
  11496. a thread can be idle</p>
  11497. <p>Passed as <code class="code">interval</code></p>
  11498. </td>
  11499. </tr></table></div>
  11500. </div>
  11501. </div>
  11502. <div class="refsect2">
  11503. <a name="id-1.1.90.2.385"></a><h3>thread-pool-set-max-unused-threads</h3>
  11504. <div class="informalexample"><pre class="programlisting">(define-values () (thread-pool-set-max-unused-threads max-threads))
  11505. </pre></div>
  11506. <p>Sets the maximal number of unused threads to <em class="parameter"><code>max_threads</code></em>.
  11507. If <em class="parameter"><code>max_threads</code></em> is -1, no limit is imposed on the number
  11508. of unused threads.
  11509. </p>
  11510. <p>The default value is 2.</p>
  11511. <div class="refsect3">
  11512. <a name="id-1.1.90.2.385.5"></a><h4>Parameters</h4>
  11513. <div class="informaltable"><table><tr>
  11514. <td class="parameter_name"><p>max_threads</p></td>
  11515. <td class="parameter_description">
  11516. <p>maximal number of unused threads</p>
  11517. <p>Passed as <code class="code">max-threads</code></p>
  11518. </td>
  11519. </tr></table></div>
  11520. </div>
  11521. </div>
  11522. <div class="refsect2">
  11523. <a name="id-1.1.90.2.386"></a><h3>thread-pool-stop-unused-threads</h3>
  11524. <div class="informalexample"><pre class="programlisting">(define-values () (thread-pool-stop-unused-threads))
  11525. </pre></div>
  11526. <p>Stops all currently unused threads. This does not change the
  11527. maximal number of unused threads. This function can be used to
  11528. regularly stop all unused threads e.g. from <code class="function">g_timeout_add()</code>.</p>
  11529. </div>
  11530. <div class="refsect2">
  11531. <a name="id-1.1.90.2.387"></a><h3>thread-self</h3>
  11532. <div class="informalexample"><pre class="programlisting">(define-values (%return) (thread-self))
  11533. </pre></div>
  11534. <p>This function returns the <span class="type">GThread</span> corresponding to the
  11535. current thread. Note that this function does not increase
  11536. the reference count of the returned struct.
  11537. </p>
  11538. <p>This function will return a <span class="type">GThread</span> even for threads that
  11539. were not created by GLib (i.e. those created by other threading
  11540. APIs). This may be useful for thread identification purposes
  11541. (i.e. comparisons) but you must not use GLib functions (such
  11542. as <code class="function">g_thread_join()</code>) on these threads.</p>
  11543. </div>
  11544. <div class="refsect2">
  11545. <a name="id-1.1.90.2.388"></a><h3>thread-yield</h3>
  11546. <div class="informalexample"><pre class="programlisting">(define-values () (thread-yield))
  11547. </pre></div>
  11548. <p>Causes the calling thread to voluntarily relinquish the CPU, so
  11549. that other threads can run.
  11550. </p>
  11551. <p>This function is often used as a method to make busy wait less evil.</p>
  11552. </div>
  11553. <div class="refsect2">
  11554. <a name="id-1.1.90.2.389"></a><h3>timeout-add</h3>
  11555. <div class="informalexample"><pre class="programlisting">(define-values (%return) (timeout-add priority interval function data notify))
  11556. </pre></div>
  11557. <p>Sets a function to be called at regular intervals, with the default
  11558. priority, <span class="type">G_PRIORITY_DEFAULT</span>. The function is called repeatedly
  11559. until it returns <code class="constant">FALSE</code>, at which point the timeout is automatically
  11560. destroyed and the function will not be called again. The first call
  11561. to the function will be at the end of the first <em class="parameter"><code>interval</code></em>.
  11562. </p>
  11563. <p>Note that timeout functions may be delayed, due to the processing of other
  11564. event sources. Thus they should not be relied on for precise timing.
  11565. After each call to the timeout function, the time of the next
  11566. timeout is recalculated based on the current time and the given interval
  11567. (it does not try to 'catch up' time lost in delays).
  11568. </p>
  11569. <p>See [memory management of sources][mainloop-memory-management] for details
  11570. on how to handle the return value and memory management of <em class="parameter"><code>data</code></em>.
  11571. </p>
  11572. <p>If you want to have a timer in the "seconds" range and do not care
  11573. about the exact time of the first call of the timer, use the
  11574. <code class="function">g_timeout_add_seconds()</code> function; this function allows for more
  11575. optimizations and more efficient system power usage.
  11576. </p>
  11577. <p>This internally creates a main loop source using <code class="function">g_timeout_source_new()</code>
  11578. and attaches it to the global <span class="type">GMainContext</span> using <code class="function">g_source_attach()</code>, so
  11579. the callback will be invoked in whichever thread is running that main
  11580. context. You can do these steps manually if you need greater control or to
  11581. use a custom main context.
  11582. </p>
  11583. <p>It is safe to call this function from any thread.
  11584. </p>
  11585. <p>The interval given is in terms of monotonic time, not wall clock
  11586. time. See <code class="function">g_get_monotonic_time()</code>.</p>
  11587. <div class="refsect3">
  11588. <a name="id-1.1.90.2.389.10"></a><h4>Parameters</h4>
  11589. <div class="informaltable"><table>
  11590. <tr>
  11591. <td class="parameter_name"><p>notify</p></td>
  11592. <td class="parameter_description">
  11593. <p></p>
  11594. <p>Passed as <code class="code">notify</code></p>
  11595. </td>
  11596. </tr>
  11597. <tr>
  11598. <td class="parameter_name"><p>priority</p></td>
  11599. <td class="parameter_description">
  11600. <p></p>
  11601. <p>Passed as <code class="code">priority</code></p>
  11602. </td>
  11603. </tr>
  11604. <tr>
  11605. <td class="parameter_name"><p>interval</p></td>
  11606. <td class="parameter_description">
  11607. <p>the time between calls to the function, in milliseconds
  11608. (1/1000ths of a second)</p>
  11609. <p>Passed as <code class="code">interval</code></p>
  11610. </td>
  11611. </tr>
  11612. <tr>
  11613. <td class="parameter_name"><p>function</p></td>
  11614. <td class="parameter_description">
  11615. <p>function to call</p>
  11616. <p>Passed as <code class="code">function</code></p>
  11617. </td>
  11618. </tr>
  11619. <tr>
  11620. <td class="parameter_name"><p>data</p></td>
  11621. <td class="parameter_description">
  11622. <p>data to pass to <em class="parameter"><code>function</code></em></p>
  11623. <p>Passed as <code class="code">data</code></p>
  11624. </td>
  11625. </tr>
  11626. </table></div>
  11627. </div>
  11628. </div>
  11629. <div class="refsect2">
  11630. <a name="id-1.1.90.2.390"></a><h3>timeout-add-seconds</h3>
  11631. <div class="informalexample"><pre class="programlisting">(define-values
  11632. (%return)
  11633. (timeout-add-seconds priority interval function data notify))
  11634. </pre></div>
  11635. <p>Sets a function to be called at regular intervals with the default
  11636. priority, <span class="type">G_PRIORITY_DEFAULT</span>. The function is called repeatedly until
  11637. it returns <code class="constant">FALSE</code>, at which point the timeout is automatically destroyed
  11638. and the function will not be called again.
  11639. </p>
  11640. <p>This internally creates a main loop source using
  11641. <code class="function">g_timeout_source_new_seconds()</code> and attaches it to the main loop context
  11642. using <code class="function">g_source_attach()</code>. You can do these steps manually if you need
  11643. greater control. Also see <code class="function">g_timeout_add_seconds_full()</code>.
  11644. </p>
  11645. <p>It is safe to call this function from any thread.
  11646. </p>
  11647. <p>Note that the first call of the timer may not be precise for timeouts
  11648. of one second. If you need finer precision and have such a timeout,
  11649. you may want to use <code class="function">g_timeout_add()</code> instead.
  11650. </p>
  11651. <p>See [memory management of sources][mainloop-memory-management] for details
  11652. on how to handle the return value and memory management of <em class="parameter"><code>data</code></em>.
  11653. </p>
  11654. <p>The interval given is in terms of monotonic time, not wall clock
  11655. time. See <code class="function">g_get_monotonic_time()</code>.</p>
  11656. <div class="refsect3">
  11657. <a name="id-1.1.90.2.390.9"></a><h4>Parameters</h4>
  11658. <div class="informaltable"><table>
  11659. <tr>
  11660. <td class="parameter_name"><p>notify</p></td>
  11661. <td class="parameter_description">
  11662. <p></p>
  11663. <p>Passed as <code class="code">notify</code></p>
  11664. </td>
  11665. </tr>
  11666. <tr>
  11667. <td class="parameter_name"><p>priority</p></td>
  11668. <td class="parameter_description">
  11669. <p></p>
  11670. <p>Passed as <code class="code">priority</code></p>
  11671. </td>
  11672. </tr>
  11673. <tr>
  11674. <td class="parameter_name"><p>interval</p></td>
  11675. <td class="parameter_description">
  11676. <p>the time between calls to the function, in seconds</p>
  11677. <p>Passed as <code class="code">interval</code></p>
  11678. </td>
  11679. </tr>
  11680. <tr>
  11681. <td class="parameter_name"><p>function</p></td>
  11682. <td class="parameter_description">
  11683. <p>function to call</p>
  11684. <p>Passed as <code class="code">function</code></p>
  11685. </td>
  11686. </tr>
  11687. <tr>
  11688. <td class="parameter_name"><p>data</p></td>
  11689. <td class="parameter_description">
  11690. <p>data to pass to <em class="parameter"><code>function</code></em></p>
  11691. <p>Passed as <code class="code">data</code></p>
  11692. </td>
  11693. </tr>
  11694. </table></div>
  11695. </div>
  11696. </div>
  11697. <div class="refsect2">
  11698. <a name="id-1.1.90.2.391"></a><h3>timeout-source-new</h3>
  11699. <div class="informalexample"><pre class="programlisting">(define-values (%return) (timeout-source-new interval))
  11700. </pre></div>
  11701. <p>Creates a new timeout source.
  11702. </p>
  11703. <p>The source will not initially be associated with any <span class="type">GMainContext</span>
  11704. and must be added to one with <code class="function">g_source_attach()</code> before it will be
  11705. executed.
  11706. </p>
  11707. <p>The interval given is in terms of monotonic time, not wall clock
  11708. time. See <code class="function">g_get_monotonic_time()</code>.</p>
  11709. <div class="refsect3">
  11710. <a name="id-1.1.90.2.391.6"></a><h4>Parameters</h4>
  11711. <div class="informaltable"><table><tr>
  11712. <td class="parameter_name"><p>interval</p></td>
  11713. <td class="parameter_description">
  11714. <p>the timeout interval in milliseconds.</p>
  11715. <p>Passed as <code class="code">interval</code></p>
  11716. </td>
  11717. </tr></table></div>
  11718. </div>
  11719. </div>
  11720. <div class="refsect2">
  11721. <a name="id-1.1.90.2.392"></a><h3>timeout-source-new-seconds</h3>
  11722. <div class="informalexample"><pre class="programlisting">(define-values (%return) (timeout-source-new-seconds interval))
  11723. </pre></div>
  11724. <p>Creates a new timeout source.
  11725. </p>
  11726. <p>The source will not initially be associated with any <span class="type">GMainContext</span>
  11727. and must be added to one with <code class="function">g_source_attach()</code> before it will be
  11728. executed.
  11729. </p>
  11730. <p>The scheduling granularity/accuracy of this timeout source will be
  11731. in seconds.
  11732. </p>
  11733. <p>The interval given is in terms of monotonic time, not wall clock time.
  11734. See <code class="function">g_get_monotonic_time()</code>.</p>
  11735. <div class="refsect3">
  11736. <a name="id-1.1.90.2.392.7"></a><h4>Parameters</h4>
  11737. <div class="informaltable"><table><tr>
  11738. <td class="parameter_name"><p>interval</p></td>
  11739. <td class="parameter_description">
  11740. <p>the timeout interval in seconds</p>
  11741. <p>Passed as <code class="code">interval</code></p>
  11742. </td>
  11743. </tr></table></div>
  11744. </div>
  11745. </div>
  11746. <div class="refsect2">
  11747. <a name="id-1.1.90.2.393"></a><h3>try-malloc</h3>
  11748. <div class="informalexample"><pre class="programlisting">(define-values (%return) (try-malloc n-bytes))
  11749. </pre></div>
  11750. <p>Attempts to allocate <em class="parameter"><code>n_bytes</code></em>, and returns <code class="constant">NULL</code> on failure.
  11751. Contrast with <code class="function">g_malloc()</code>, which aborts the program on failure.</p>
  11752. <div class="refsect3">
  11753. <a name="id-1.1.90.2.393.4"></a><h4>Parameters</h4>
  11754. <div class="informaltable"><table><tr>
  11755. <td class="parameter_name"><p>n_bytes</p></td>
  11756. <td class="parameter_description">
  11757. <p>number of bytes to allocate.</p>
  11758. <p>Passed as <code class="code">n-bytes</code></p>
  11759. </td>
  11760. </tr></table></div>
  11761. </div>
  11762. </div>
  11763. <div class="refsect2">
  11764. <a name="id-1.1.90.2.394"></a><h3>try-malloc0</h3>
  11765. <div class="informalexample"><pre class="programlisting">(define-values (%return) (try-malloc0 n-bytes))
  11766. </pre></div>
  11767. <p>Attempts to allocate <em class="parameter"><code>n_bytes</code></em>, initialized to 0's, and returns <code class="constant">NULL</code> on
  11768. failure. Contrast with <code class="function">g_malloc0()</code>, which aborts the program on failure.</p>
  11769. <div class="refsect3">
  11770. <a name="id-1.1.90.2.394.4"></a><h4>Parameters</h4>
  11771. <div class="informaltable"><table><tr>
  11772. <td class="parameter_name"><p>n_bytes</p></td>
  11773. <td class="parameter_description">
  11774. <p>number of bytes to allocate</p>
  11775. <p>Passed as <code class="code">n-bytes</code></p>
  11776. </td>
  11777. </tr></table></div>
  11778. </div>
  11779. </div>
  11780. <div class="refsect2">
  11781. <a name="id-1.1.90.2.395"></a><h3>try-malloc0-n</h3>
  11782. <div class="informalexample"><pre class="programlisting">(define-values (%return) (try-malloc0-n n-blocks n-block-bytes))
  11783. </pre></div>
  11784. <p>This function is similar to <code class="function">g_try_malloc0()</code>, allocating (<em class="parameter"><code>n_blocks</code></em> * <em class="parameter"><code>n_block_bytes</code></em>) bytes,
  11785. but care is taken to detect possible overflow during multiplication.</p>
  11786. <div class="refsect3">
  11787. <a name="id-1.1.90.2.395.4"></a><h4>Parameters</h4>
  11788. <div class="informaltable"><table>
  11789. <tr>
  11790. <td class="parameter_name"><p>n_blocks</p></td>
  11791. <td class="parameter_description">
  11792. <p>the number of blocks to allocate</p>
  11793. <p>Passed as <code class="code">n-blocks</code></p>
  11794. </td>
  11795. </tr>
  11796. <tr>
  11797. <td class="parameter_name"><p>n_block_bytes</p></td>
  11798. <td class="parameter_description">
  11799. <p>the size of each block in bytes</p>
  11800. <p>Passed as <code class="code">n-block-bytes</code></p>
  11801. </td>
  11802. </tr>
  11803. </table></div>
  11804. </div>
  11805. </div>
  11806. <div class="refsect2">
  11807. <a name="id-1.1.90.2.396"></a><h3>try-malloc-n</h3>
  11808. <div class="informalexample"><pre class="programlisting">(define-values (%return) (try-malloc-n n-blocks n-block-bytes))
  11809. </pre></div>
  11810. <p>This function is similar to <code class="function">g_try_malloc()</code>, allocating (<em class="parameter"><code>n_blocks</code></em> * <em class="parameter"><code>n_block_bytes</code></em>) bytes,
  11811. but care is taken to detect possible overflow during multiplication.</p>
  11812. <div class="refsect3">
  11813. <a name="id-1.1.90.2.396.4"></a><h4>Parameters</h4>
  11814. <div class="informaltable"><table>
  11815. <tr>
  11816. <td class="parameter_name"><p>n_blocks</p></td>
  11817. <td class="parameter_description">
  11818. <p>the number of blocks to allocate</p>
  11819. <p>Passed as <code class="code">n-blocks</code></p>
  11820. </td>
  11821. </tr>
  11822. <tr>
  11823. <td class="parameter_name"><p>n_block_bytes</p></td>
  11824. <td class="parameter_description">
  11825. <p>the size of each block in bytes</p>
  11826. <p>Passed as <code class="code">n-block-bytes</code></p>
  11827. </td>
  11828. </tr>
  11829. </table></div>
  11830. </div>
  11831. </div>
  11832. <div class="refsect2">
  11833. <a name="id-1.1.90.2.397"></a><h3>try-realloc</h3>
  11834. <div class="informalexample"><pre class="programlisting">(define-values (%return) (try-realloc mem n-bytes))
  11835. </pre></div>
  11836. <p>Attempts to realloc <em class="parameter"><code>mem</code></em> to a new size, <em class="parameter"><code>n_bytes</code></em>, and returns <code class="constant">NULL</code>
  11837. on failure. Contrast with <code class="function">g_realloc()</code>, which aborts the program
  11838. on failure.
  11839. </p>
  11840. <p>If <em class="parameter"><code>mem</code></em> is <code class="constant">NULL</code>, behaves the same as <code class="function">g_try_malloc()</code>.</p>
  11841. <div class="refsect3">
  11842. <a name="id-1.1.90.2.397.5"></a><h4>Parameters</h4>
  11843. <div class="informaltable"><table>
  11844. <tr>
  11845. <td class="parameter_name"><p>mem</p></td>
  11846. <td class="parameter_description">
  11847. <p>previously-allocated memory, or <code class="constant">NULL</code>.</p>
  11848. <p>Passed as <code class="code">mem</code></p>
  11849. </td>
  11850. </tr>
  11851. <tr>
  11852. <td class="parameter_name"><p>n_bytes</p></td>
  11853. <td class="parameter_description">
  11854. <p>number of bytes to allocate.</p>
  11855. <p>Passed as <code class="code">n-bytes</code></p>
  11856. </td>
  11857. </tr>
  11858. </table></div>
  11859. </div>
  11860. </div>
  11861. <div class="refsect2">
  11862. <a name="id-1.1.90.2.398"></a><h3>try-realloc-n</h3>
  11863. <div class="informalexample"><pre class="programlisting">(define-values (%return) (try-realloc-n mem n-blocks n-block-bytes))
  11864. </pre></div>
  11865. <p>This function is similar to <code class="function">g_try_realloc()</code>, allocating (<em class="parameter"><code>n_blocks</code></em> * <em class="parameter"><code>n_block_bytes</code></em>) bytes,
  11866. but care is taken to detect possible overflow during multiplication.</p>
  11867. <div class="refsect3">
  11868. <a name="id-1.1.90.2.398.4"></a><h4>Parameters</h4>
  11869. <div class="informaltable"><table>
  11870. <tr>
  11871. <td class="parameter_name"><p>mem</p></td>
  11872. <td class="parameter_description">
  11873. <p>previously-allocated memory, or <code class="constant">NULL</code>.</p>
  11874. <p>Passed as <code class="code">mem</code></p>
  11875. </td>
  11876. </tr>
  11877. <tr>
  11878. <td class="parameter_name"><p>n_blocks</p></td>
  11879. <td class="parameter_description">
  11880. <p>the number of blocks to allocate</p>
  11881. <p>Passed as <code class="code">n-blocks</code></p>
  11882. </td>
  11883. </tr>
  11884. <tr>
  11885. <td class="parameter_name"><p>n_block_bytes</p></td>
  11886. <td class="parameter_description">
  11887. <p>the size of each block in bytes</p>
  11888. <p>Passed as <code class="code">n-block-bytes</code></p>
  11889. </td>
  11890. </tr>
  11891. </table></div>
  11892. </div>
  11893. </div>
  11894. <div class="refsect2">
  11895. <a name="id-1.1.90.2.399"></a><h3>ucs4-to-utf16</h3>
  11896. <div class="informalexample"><pre class="programlisting">(define-values
  11897. (%return items-read items-written)
  11898. (ucs4-to-utf16 str len items-read items-written))
  11899. </pre></div>
  11900. <p>Convert a string from UCS-4 to UTF-16. A 0 character will be
  11901. added to the result after the converted text.</p>
  11902. <div class="refsect3">
  11903. <a name="id-1.1.90.2.399.4"></a><h4>Parameters</h4>
  11904. <div class="informaltable"><table>
  11905. <tr>
  11906. <td class="parameter_name"><p>str</p></td>
  11907. <td class="parameter_description">
  11908. <p>a UCS-4 encoded string</p>
  11909. <p>Passed as <code class="code">str</code></p>
  11910. </td>
  11911. </tr>
  11912. <tr>
  11913. <td class="parameter_name"><p>len</p></td>
  11914. <td class="parameter_description">
  11915. <p>the maximum length (number of characters) of <em class="parameter"><code>str</code></em> to use.
  11916. If <em class="parameter"><code>len</code></em> &lt; 0, then the string is nul-terminated.</p>
  11917. <p>Passed as <code class="code">len</code></p>
  11918. </td>
  11919. </tr>
  11920. <tr>
  11921. <td class="parameter_name"><p>items_read</p></td>
  11922. <td class="parameter_description">
  11923. <p>location to store number of
  11924. bytes read, or <code class="constant">NULL</code>. If an error occurs then the index of the invalid
  11925. input is stored here.</p>
  11926. <p>Passed as <code class="code">items-read</code></p>
  11927. </td>
  11928. </tr>
  11929. <tr>
  11930. <td class="parameter_name"><p>items_written</p></td>
  11931. <td class="parameter_description">
  11932. <p>location to store number
  11933. of <span class="type">gunichar2</span> written, or <code class="constant">NULL</code>. The value stored here does not include
  11934. the trailing 0.</p>
  11935. <p>Passed as <code class="code">items-written</code></p>
  11936. </td>
  11937. </tr>
  11938. </table></div>
  11939. </div>
  11940. </div>
  11941. <div class="refsect2">
  11942. <a name="id-1.1.90.2.400"></a><h3>ucs4-to-utf8</h3>
  11943. <div class="informalexample"><pre class="programlisting">(define-values
  11944. (%return items-read items-written)
  11945. (ucs4-to-utf8 str len items-read items-written))
  11946. </pre></div>
  11947. <p>Convert a string from a 32-bit fixed width representation as UCS-4.
  11948. to UTF-8. The result will be terminated with a 0 byte.</p>
  11949. <div class="refsect3">
  11950. <a name="id-1.1.90.2.400.4"></a><h4>Parameters</h4>
  11951. <div class="informaltable"><table>
  11952. <tr>
  11953. <td class="parameter_name"><p>str</p></td>
  11954. <td class="parameter_description">
  11955. <p>a UCS-4 encoded string</p>
  11956. <p>Passed as <code class="code">str</code></p>
  11957. </td>
  11958. </tr>
  11959. <tr>
  11960. <td class="parameter_name"><p>len</p></td>
  11961. <td class="parameter_description">
  11962. <p>the maximum length (number of characters) of <em class="parameter"><code>str</code></em> to use.
  11963. If <em class="parameter"><code>len</code></em> &lt; 0, then the string is nul-terminated.</p>
  11964. <p>Passed as <code class="code">len</code></p>
  11965. </td>
  11966. </tr>
  11967. <tr>
  11968. <td class="parameter_name"><p>items_read</p></td>
  11969. <td class="parameter_description">
  11970. <p>location to store number of
  11971. characters read, or <code class="constant">NULL</code>.</p>
  11972. <p>Passed as <code class="code">items-read</code></p>
  11973. </td>
  11974. </tr>
  11975. <tr>
  11976. <td class="parameter_name"><p>items_written</p></td>
  11977. <td class="parameter_description">
  11978. <p>location to store number
  11979. of bytes written or <code class="constant">NULL</code>. The value here stored does not include the
  11980. trailing 0 byte.</p>
  11981. <p>Passed as <code class="code">items-written</code></p>
  11982. </td>
  11983. </tr>
  11984. </table></div>
  11985. </div>
  11986. </div>
  11987. <div class="refsect2">
  11988. <a name="id-1.1.90.2.401"></a><h3>unichar-break-type</h3>
  11989. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-break-type c))
  11990. </pre></div>
  11991. <p>Determines the break type of <em class="parameter"><code>c</code></em>. <em class="parameter"><code>c</code></em> should be a Unicode character
  11992. (to derive a character from UTF-8 encoded text, use
  11993. <code class="function">g_utf8_get_char()</code>). The break type is used to find word and line
  11994. breaks ("text boundaries"), Pango implements the Unicode boundary
  11995. resolution algorithms and normally you would use a function such
  11996. as <code class="function">pango_break()</code> instead of caring about break types yourself.</p>
  11997. <div class="refsect3">
  11998. <a name="id-1.1.90.2.401.4"></a><h4>Parameters</h4>
  11999. <div class="informaltable"><table><tr>
  12000. <td class="parameter_name"><p>c</p></td>
  12001. <td class="parameter_description">
  12002. <p>a Unicode character</p>
  12003. <p>Passed as <code class="code">c</code></p>
  12004. </td>
  12005. </tr></table></div>
  12006. </div>
  12007. </div>
  12008. <div class="refsect2">
  12009. <a name="id-1.1.90.2.402"></a><h3>unichar-combining-class</h3>
  12010. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-combining-class uc))
  12011. </pre></div>
  12012. <p>Determines the canonical combining class of a Unicode character.</p>
  12013. <div class="refsect3">
  12014. <a name="id-1.1.90.2.402.4"></a><h4>Parameters</h4>
  12015. <div class="informaltable"><table><tr>
  12016. <td class="parameter_name"><p>uc</p></td>
  12017. <td class="parameter_description">
  12018. <p>a Unicode character</p>
  12019. <p>Passed as <code class="code">uc</code></p>
  12020. </td>
  12021. </tr></table></div>
  12022. </div>
  12023. </div>
  12024. <div class="refsect2">
  12025. <a name="id-1.1.90.2.403"></a><h3>unichar-compose</h3>
  12026. <div class="informalexample"><pre class="programlisting">(define-values (%return ch) (unichar-compose a b))
  12027. </pre></div>
  12028. <p>Performs a single composition step of the
  12029. Unicode canonical composition algorithm.
  12030. </p>
  12031. <p>This function includes algorithmic Hangul Jamo composition,
  12032. but it is not exactly the inverse of <code class="function">g_unichar_decompose()</code>.
  12033. No composition can have either of <em class="parameter"><code>a</code></em> or <em class="parameter"><code>b</code></em> equal to zero.
  12034. To be precise, this function composes if and only if
  12035. there exists a Primary Composite P which is canonically
  12036. equivalent to the sequence &lt;<em class="parameter"><code>a</code></em>,<em class="parameter"><code>b</code></em>&gt;. See the Unicode
  12037. Standard for the definition of Primary Composite.
  12038. </p>
  12039. <p>If <em class="parameter"><code>a</code></em> and <em class="parameter"><code>b</code></em> do not compose a new character, <em class="parameter"><code>ch</code></em> is set to zero.
  12040. </p>
  12041. <p>See
  12042. [UAX#15](http://unicode.org/reports/tr15/)
  12043. for details.</p>
  12044. <div class="refsect3">
  12045. <a name="id-1.1.90.2.403.7"></a><h4>Parameters</h4>
  12046. <div class="informaltable"><table>
  12047. <tr>
  12048. <td class="parameter_name"><p>a</p></td>
  12049. <td class="parameter_description">
  12050. <p>a Unicode character</p>
  12051. <p>Passed as <code class="code">a</code></p>
  12052. </td>
  12053. </tr>
  12054. <tr>
  12055. <td class="parameter_name"><p>b</p></td>
  12056. <td class="parameter_description">
  12057. <p>a Unicode character</p>
  12058. <p>Passed as <code class="code">b</code></p>
  12059. </td>
  12060. </tr>
  12061. <tr>
  12062. <td class="parameter_name"><p>ch</p></td>
  12063. <td class="parameter_description">
  12064. <p>return location for the composed character</p>
  12065. <p>Passed as <code class="code">ch</code></p>
  12066. </td>
  12067. </tr>
  12068. </table></div>
  12069. </div>
  12070. </div>
  12071. <div class="refsect2">
  12072. <a name="id-1.1.90.2.404"></a><h3>unichar-decompose</h3>
  12073. <div class="informalexample"><pre class="programlisting">(define-values (%return a b) (unichar-decompose ch))
  12074. </pre></div>
  12075. <p>Performs a single decomposition step of the
  12076. Unicode canonical decomposition algorithm.
  12077. </p>
  12078. <p>This function does not include compatibility
  12079. decompositions. It does, however, include algorithmic
  12080. Hangul Jamo decomposition, as well as 'singleton'
  12081. decompositions which replace a character by a single
  12082. other character. In the case of singletons *<em class="parameter"><code>b</code></em> will
  12083. be set to zero.
  12084. </p>
  12085. <p>If <em class="parameter"><code>ch</code></em> is not decomposable, *<em class="parameter"><code>a</code></em> is set to <em class="parameter"><code>ch</code></em> and *<em class="parameter"><code>b</code></em>
  12086. is set to zero.
  12087. </p>
  12088. <p>Note that the way Unicode decomposition pairs are
  12089. defined, it is guaranteed that <em class="parameter"><code>b</code></em> would not decompose
  12090. further, but <em class="parameter"><code>a</code></em> may itself decompose. To get the full
  12091. canonical decomposition for <em class="parameter"><code>ch</code></em>, one would need to
  12092. recursively call this function on <em class="parameter"><code>a</code></em>. Or use
  12093. <code class="function">g_unichar_fully_decompose()</code>.
  12094. </p>
  12095. <p>See
  12096. [UAX#15](http://unicode.org/reports/tr15/)
  12097. for details.</p>
  12098. <div class="refsect3">
  12099. <a name="id-1.1.90.2.404.8"></a><h4>Parameters</h4>
  12100. <div class="informaltable"><table>
  12101. <tr>
  12102. <td class="parameter_name"><p>ch</p></td>
  12103. <td class="parameter_description">
  12104. <p>a Unicode character</p>
  12105. <p>Passed as <code class="code">ch</code></p>
  12106. </td>
  12107. </tr>
  12108. <tr>
  12109. <td class="parameter_name"><p>a</p></td>
  12110. <td class="parameter_description">
  12111. <p>return location for the first component of <em class="parameter"><code>ch</code></em></p>
  12112. <p>Passed as <code class="code">a</code></p>
  12113. </td>
  12114. </tr>
  12115. <tr>
  12116. <td class="parameter_name"><p>b</p></td>
  12117. <td class="parameter_description">
  12118. <p>return location for the second component of <em class="parameter"><code>ch</code></em></p>
  12119. <p>Passed as <code class="code">b</code></p>
  12120. </td>
  12121. </tr>
  12122. </table></div>
  12123. </div>
  12124. </div>
  12125. <div class="refsect2">
  12126. <a name="id-1.1.90.2.405"></a><h3>unichar-digit-value</h3>
  12127. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-digit-value c))
  12128. </pre></div>
  12129. <p>Determines the numeric value of a character as a decimal
  12130. digit.</p>
  12131. <div class="refsect3">
  12132. <a name="id-1.1.90.2.405.4"></a><h4>Parameters</h4>
  12133. <div class="informaltable"><table><tr>
  12134. <td class="parameter_name"><p>c</p></td>
  12135. <td class="parameter_description">
  12136. <p>a Unicode character</p>
  12137. <p>Passed as <code class="code">c</code></p>
  12138. </td>
  12139. </tr></table></div>
  12140. </div>
  12141. </div>
  12142. <div class="refsect2">
  12143. <a name="id-1.1.90.2.406"></a><h3>unichar-fully-decompose</h3>
  12144. <div class="informalexample"><pre class="programlisting">(define-values
  12145. (%return result)
  12146. (unichar-fully-decompose ch compat result result-len))
  12147. </pre></div>
  12148. <p>Computes the canonical or compatibility decomposition of a
  12149. Unicode character. For compatibility decomposition,
  12150. pass <code class="constant">TRUE</code> for <em class="parameter"><code>compat</code></em>; for canonical decomposition
  12151. pass <code class="constant">FALSE</code> for <em class="parameter"><code>compat</code></em>.
  12152. </p>
  12153. <p>The decomposed sequence is placed in <em class="parameter"><code>result</code></em>. Only up to
  12154. <em class="parameter"><code>result_len</code></em> characters are written into <em class="parameter"><code>result</code></em>. The length
  12155. of the full decomposition (irrespective of <em class="parameter"><code>result_len</code></em>) is
  12156. returned by the function. For canonical decomposition,
  12157. currently all decompositions are of length at most 4, but
  12158. this may change in the future (very unlikely though).
  12159. At any rate, Unicode does guarantee that a buffer of length
  12160. 18 is always enough for both compatibility and canonical
  12161. decompositions, so that is the size recommended. This is provided
  12162. as <code class="constant">G_UNICHAR_MAX_DECOMPOSITION_LENGTH</code>.
  12163. </p>
  12164. <p>See
  12165. [UAX#15](http://unicode.org/reports/tr15/)
  12166. for details.</p>
  12167. <div class="refsect3">
  12168. <a name="id-1.1.90.2.406.6"></a><h4>Parameters</h4>
  12169. <div class="informaltable"><table>
  12170. <tr>
  12171. <td class="parameter_name"><p>ch</p></td>
  12172. <td class="parameter_description">
  12173. <p>a Unicode character.</p>
  12174. <p>Passed as <code class="code">ch</code></p>
  12175. </td>
  12176. </tr>
  12177. <tr>
  12178. <td class="parameter_name"><p>compat</p></td>
  12179. <td class="parameter_description">
  12180. <p>whether perform canonical or compatibility decomposition</p>
  12181. <p>Passed as <code class="code">compat</code></p>
  12182. </td>
  12183. </tr>
  12184. <tr>
  12185. <td class="parameter_name"><p>result</p></td>
  12186. <td class="parameter_description">
  12187. <p>location to store decomposed result, or <code class="constant">NULL</code></p>
  12188. <p>Passed as <code class="code">result</code></p>
  12189. </td>
  12190. </tr>
  12191. <tr>
  12192. <td class="parameter_name"><p>result_len</p></td>
  12193. <td class="parameter_description">
  12194. <p>length of <em class="parameter"><code>result</code></em></p>
  12195. <p>Passed as <code class="code">result-len</code></p>
  12196. </td>
  12197. </tr>
  12198. </table></div>
  12199. </div>
  12200. </div>
  12201. <div class="refsect2">
  12202. <a name="id-1.1.90.2.407"></a><h3>unichar-get-mirror-char?</h3>
  12203. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-get-mirror-char? ch mirrored-ch))
  12204. </pre></div>
  12205. <p>In Unicode, some characters are "mirrored". This means that their
  12206. images are mirrored horizontally in text that is laid out from right
  12207. to left. For instance, "(" would become its mirror image, ")", in
  12208. right-to-left text.
  12209. </p>
  12210. <p>If <em class="parameter"><code>ch</code></em> has the Unicode mirrored property and there is another unicode
  12211. character that typically has a glyph that is the mirror image of <em class="parameter"><code>ch</code></em>'s
  12212. glyph and <em class="parameter"><code>mirrored_ch</code></em> is set, it puts that character in the address
  12213. pointed to by <em class="parameter"><code>mirrored_ch</code></em>. Otherwise the original character is put.</p>
  12214. <div class="refsect3">
  12215. <a name="id-1.1.90.2.407.5"></a><h4>Parameters</h4>
  12216. <div class="informaltable"><table>
  12217. <tr>
  12218. <td class="parameter_name"><p>ch</p></td>
  12219. <td class="parameter_description">
  12220. <p>a Unicode character</p>
  12221. <p>Passed as <code class="code">ch</code></p>
  12222. </td>
  12223. </tr>
  12224. <tr>
  12225. <td class="parameter_name"><p>mirrored_ch</p></td>
  12226. <td class="parameter_description">
  12227. <p>location to store the mirrored character</p>
  12228. <p>Passed as <code class="code">mirrored-ch</code></p>
  12229. </td>
  12230. </tr>
  12231. </table></div>
  12232. </div>
  12233. </div>
  12234. <div class="refsect2">
  12235. <a name="id-1.1.90.2.408"></a><h3>unichar-get-script</h3>
  12236. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-get-script ch))
  12237. </pre></div>
  12238. <p>Looks up the <span class="type">GUnicodeScript</span> for a particular character (as defined
  12239. by Unicode Standard Annex \#24). No check is made for <em class="parameter"><code>ch</code></em> being a
  12240. valid Unicode character; if you pass in invalid character, the
  12241. result is undefined.
  12242. </p>
  12243. <p>This function is equivalent to <code class="function">pango_script_for_unichar()</code> and the
  12244. two are interchangeable.</p>
  12245. <div class="refsect3">
  12246. <a name="id-1.1.90.2.408.5"></a><h4>Parameters</h4>
  12247. <div class="informaltable"><table><tr>
  12248. <td class="parameter_name"><p>ch</p></td>
  12249. <td class="parameter_description">
  12250. <p>a Unicode character</p>
  12251. <p>Passed as <code class="code">ch</code></p>
  12252. </td>
  12253. </tr></table></div>
  12254. </div>
  12255. </div>
  12256. <div class="refsect2">
  12257. <a name="id-1.1.90.2.409"></a><h3>unichar-isalnum?</h3>
  12258. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-isalnum? c))
  12259. </pre></div>
  12260. <p>Determines whether a character is alphanumeric.
  12261. Given some UTF-8 text, obtain a character value
  12262. with <code class="function">g_utf8_get_char()</code>.</p>
  12263. <div class="refsect3">
  12264. <a name="id-1.1.90.2.409.4"></a><h4>Parameters</h4>
  12265. <div class="informaltable"><table><tr>
  12266. <td class="parameter_name"><p>c</p></td>
  12267. <td class="parameter_description">
  12268. <p>a Unicode character</p>
  12269. <p>Passed as <code class="code">c</code></p>
  12270. </td>
  12271. </tr></table></div>
  12272. </div>
  12273. </div>
  12274. <div class="refsect2">
  12275. <a name="id-1.1.90.2.410"></a><h3>unichar-isalpha?</h3>
  12276. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-isalpha? c))
  12277. </pre></div>
  12278. <p>Determines whether a character is alphabetic (i.e. a letter).
  12279. Given some UTF-8 text, obtain a character value with
  12280. <code class="function">g_utf8_get_char()</code>.</p>
  12281. <div class="refsect3">
  12282. <a name="id-1.1.90.2.410.4"></a><h4>Parameters</h4>
  12283. <div class="informaltable"><table><tr>
  12284. <td class="parameter_name"><p>c</p></td>
  12285. <td class="parameter_description">
  12286. <p>a Unicode character</p>
  12287. <p>Passed as <code class="code">c</code></p>
  12288. </td>
  12289. </tr></table></div>
  12290. </div>
  12291. </div>
  12292. <div class="refsect2">
  12293. <a name="id-1.1.90.2.411"></a><h3>unichar-iscntrl?</h3>
  12294. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-iscntrl? c))
  12295. </pre></div>
  12296. <p>Determines whether a character is a control character.
  12297. Given some UTF-8 text, obtain a character value with
  12298. <code class="function">g_utf8_get_char()</code>.</p>
  12299. <div class="refsect3">
  12300. <a name="id-1.1.90.2.411.4"></a><h4>Parameters</h4>
  12301. <div class="informaltable"><table><tr>
  12302. <td class="parameter_name"><p>c</p></td>
  12303. <td class="parameter_description">
  12304. <p>a Unicode character</p>
  12305. <p>Passed as <code class="code">c</code></p>
  12306. </td>
  12307. </tr></table></div>
  12308. </div>
  12309. </div>
  12310. <div class="refsect2">
  12311. <a name="id-1.1.90.2.412"></a><h3>unichar-isdefined?</h3>
  12312. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-isdefined? c))
  12313. </pre></div>
  12314. <p>Determines if a given character is assigned in the Unicode
  12315. standard.</p>
  12316. <div class="refsect3">
  12317. <a name="id-1.1.90.2.412.4"></a><h4>Parameters</h4>
  12318. <div class="informaltable"><table><tr>
  12319. <td class="parameter_name"><p>c</p></td>
  12320. <td class="parameter_description">
  12321. <p>a Unicode character</p>
  12322. <p>Passed as <code class="code">c</code></p>
  12323. </td>
  12324. </tr></table></div>
  12325. </div>
  12326. </div>
  12327. <div class="refsect2">
  12328. <a name="id-1.1.90.2.413"></a><h3>unichar-isdigit?</h3>
  12329. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-isdigit? c))
  12330. </pre></div>
  12331. <p>Determines whether a character is numeric (i.e. a digit). This
  12332. covers ASCII 0-9 and also digits in other languages/scripts. Given
  12333. some UTF-8 text, obtain a character value with <code class="function">g_utf8_get_char()</code>.</p>
  12334. <div class="refsect3">
  12335. <a name="id-1.1.90.2.413.4"></a><h4>Parameters</h4>
  12336. <div class="informaltable"><table><tr>
  12337. <td class="parameter_name"><p>c</p></td>
  12338. <td class="parameter_description">
  12339. <p>a Unicode character</p>
  12340. <p>Passed as <code class="code">c</code></p>
  12341. </td>
  12342. </tr></table></div>
  12343. </div>
  12344. </div>
  12345. <div class="refsect2">
  12346. <a name="id-1.1.90.2.414"></a><h3>unichar-isgraph?</h3>
  12347. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-isgraph? c))
  12348. </pre></div>
  12349. <p>Determines whether a character is printable and not a space
  12350. (returns <code class="constant">FALSE</code> for control characters, format characters, and
  12351. spaces). <code class="function">g_unichar_isprint()</code> is similar, but returns <code class="constant">TRUE</code> for
  12352. spaces. Given some UTF-8 text, obtain a character value with
  12353. <code class="function">g_utf8_get_char()</code>.</p>
  12354. <div class="refsect3">
  12355. <a name="id-1.1.90.2.414.4"></a><h4>Parameters</h4>
  12356. <div class="informaltable"><table><tr>
  12357. <td class="parameter_name"><p>c</p></td>
  12358. <td class="parameter_description">
  12359. <p>a Unicode character</p>
  12360. <p>Passed as <code class="code">c</code></p>
  12361. </td>
  12362. </tr></table></div>
  12363. </div>
  12364. </div>
  12365. <div class="refsect2">
  12366. <a name="id-1.1.90.2.415"></a><h3>unichar-islower?</h3>
  12367. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-islower? c))
  12368. </pre></div>
  12369. <p>Determines whether a character is a lowercase letter.
  12370. Given some UTF-8 text, obtain a character value with
  12371. <code class="function">g_utf8_get_char()</code>.</p>
  12372. <div class="refsect3">
  12373. <a name="id-1.1.90.2.415.4"></a><h4>Parameters</h4>
  12374. <div class="informaltable"><table><tr>
  12375. <td class="parameter_name"><p>c</p></td>
  12376. <td class="parameter_description">
  12377. <p>a Unicode character</p>
  12378. <p>Passed as <code class="code">c</code></p>
  12379. </td>
  12380. </tr></table></div>
  12381. </div>
  12382. </div>
  12383. <div class="refsect2">
  12384. <a name="id-1.1.90.2.416"></a><h3>unichar-ismark?</h3>
  12385. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-ismark? c))
  12386. </pre></div>
  12387. <p>Determines whether a character is a mark (non-spacing mark,
  12388. combining mark, or enclosing mark in Unicode speak).
  12389. Given some UTF-8 text, obtain a character value
  12390. with <code class="function">g_utf8_get_char()</code>.
  12391. </p>
  12392. <p>Note: in most cases where isalpha characters are allowed,
  12393. ismark characters should be allowed to as they are essential
  12394. for writing most European languages as well as many non-Latin
  12395. scripts.</p>
  12396. <div class="refsect3">
  12397. <a name="id-1.1.90.2.416.5"></a><h4>Parameters</h4>
  12398. <div class="informaltable"><table><tr>
  12399. <td class="parameter_name"><p>c</p></td>
  12400. <td class="parameter_description">
  12401. <p>a Unicode character</p>
  12402. <p>Passed as <code class="code">c</code></p>
  12403. </td>
  12404. </tr></table></div>
  12405. </div>
  12406. </div>
  12407. <div class="refsect2">
  12408. <a name="id-1.1.90.2.417"></a><h3>unichar-isprint?</h3>
  12409. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-isprint? c))
  12410. </pre></div>
  12411. <p>Determines whether a character is printable.
  12412. Unlike <code class="function">g_unichar_isgraph()</code>, returns <code class="constant">TRUE</code> for spaces.
  12413. Given some UTF-8 text, obtain a character value with
  12414. <code class="function">g_utf8_get_char()</code>.</p>
  12415. <div class="refsect3">
  12416. <a name="id-1.1.90.2.417.4"></a><h4>Parameters</h4>
  12417. <div class="informaltable"><table><tr>
  12418. <td class="parameter_name"><p>c</p></td>
  12419. <td class="parameter_description">
  12420. <p>a Unicode character</p>
  12421. <p>Passed as <code class="code">c</code></p>
  12422. </td>
  12423. </tr></table></div>
  12424. </div>
  12425. </div>
  12426. <div class="refsect2">
  12427. <a name="id-1.1.90.2.418"></a><h3>unichar-ispunct?</h3>
  12428. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-ispunct? c))
  12429. </pre></div>
  12430. <p>Determines whether a character is punctuation or a symbol.
  12431. Given some UTF-8 text, obtain a character value with
  12432. <code class="function">g_utf8_get_char()</code>.</p>
  12433. <div class="refsect3">
  12434. <a name="id-1.1.90.2.418.4"></a><h4>Parameters</h4>
  12435. <div class="informaltable"><table><tr>
  12436. <td class="parameter_name"><p>c</p></td>
  12437. <td class="parameter_description">
  12438. <p>a Unicode character</p>
  12439. <p>Passed as <code class="code">c</code></p>
  12440. </td>
  12441. </tr></table></div>
  12442. </div>
  12443. </div>
  12444. <div class="refsect2">
  12445. <a name="id-1.1.90.2.419"></a><h3>unichar-isspace?</h3>
  12446. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-isspace? c))
  12447. </pre></div>
  12448. <p>Determines whether a character is a space, tab, or line separator
  12449. (newline, carriage return, etc.). Given some UTF-8 text, obtain a
  12450. character value with <code class="function">g_utf8_get_char()</code>.
  12451. </p>
  12452. <p>(Note: don't use this to do word breaking; you have to use
  12453. Pango or equivalent to get word breaking right, the algorithm
  12454. is fairly complex.)</p>
  12455. <div class="refsect3">
  12456. <a name="id-1.1.90.2.419.5"></a><h4>Parameters</h4>
  12457. <div class="informaltable"><table><tr>
  12458. <td class="parameter_name"><p>c</p></td>
  12459. <td class="parameter_description">
  12460. <p>a Unicode character</p>
  12461. <p>Passed as <code class="code">c</code></p>
  12462. </td>
  12463. </tr></table></div>
  12464. </div>
  12465. </div>
  12466. <div class="refsect2">
  12467. <a name="id-1.1.90.2.420"></a><h3>unichar-istitle?</h3>
  12468. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-istitle? c))
  12469. </pre></div>
  12470. <p>Determines if a character is titlecase. Some characters in
  12471. Unicode which are composites, such as the DZ digraph
  12472. have three case variants instead of just two. The titlecase
  12473. form is used at the beginning of a word where only the
  12474. first letter is capitalized. The titlecase form of the DZ
  12475. digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z.</p>
  12476. <div class="refsect3">
  12477. <a name="id-1.1.90.2.420.4"></a><h4>Parameters</h4>
  12478. <div class="informaltable"><table><tr>
  12479. <td class="parameter_name"><p>c</p></td>
  12480. <td class="parameter_description">
  12481. <p>a Unicode character</p>
  12482. <p>Passed as <code class="code">c</code></p>
  12483. </td>
  12484. </tr></table></div>
  12485. </div>
  12486. </div>
  12487. <div class="refsect2">
  12488. <a name="id-1.1.90.2.421"></a><h3>unichar-isupper?</h3>
  12489. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-isupper? c))
  12490. </pre></div>
  12491. <p>Determines if a character is uppercase.</p>
  12492. <div class="refsect3">
  12493. <a name="id-1.1.90.2.421.4"></a><h4>Parameters</h4>
  12494. <div class="informaltable"><table><tr>
  12495. <td class="parameter_name"><p>c</p></td>
  12496. <td class="parameter_description">
  12497. <p>a Unicode character</p>
  12498. <p>Passed as <code class="code">c</code></p>
  12499. </td>
  12500. </tr></table></div>
  12501. </div>
  12502. </div>
  12503. <div class="refsect2">
  12504. <a name="id-1.1.90.2.422"></a><h3>unichar-iswide?</h3>
  12505. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-iswide? c))
  12506. </pre></div>
  12507. <p>Determines if a character is typically rendered in a double-width
  12508. cell.</p>
  12509. <div class="refsect3">
  12510. <a name="id-1.1.90.2.422.4"></a><h4>Parameters</h4>
  12511. <div class="informaltable"><table><tr>
  12512. <td class="parameter_name"><p>c</p></td>
  12513. <td class="parameter_description">
  12514. <p>a Unicode character</p>
  12515. <p>Passed as <code class="code">c</code></p>
  12516. </td>
  12517. </tr></table></div>
  12518. </div>
  12519. </div>
  12520. <div class="refsect2">
  12521. <a name="id-1.1.90.2.423"></a><h3>unichar-iswide-cjk?</h3>
  12522. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-iswide-cjk? c))
  12523. </pre></div>
  12524. <p>Determines if a character is typically rendered in a double-width
  12525. cell under legacy East Asian locales. If a character is wide according to
  12526. <code class="function">g_unichar_iswide()</code>, then it is also reported wide with this function, but
  12527. the converse is not necessarily true. See the
  12528. [Unicode Standard Annex <span class="type">11</span>](http://www.unicode.org/reports/tr11/)
  12529. for details.
  12530. </p>
  12531. <p>If a character passes the <code class="function">g_unichar_iswide()</code> test then it will also pass
  12532. this test, but not the other way around. Note that some characters may
  12533. pass both this test and <code class="function">g_unichar_iszerowidth()</code>.</p>
  12534. <div class="refsect3">
  12535. <a name="id-1.1.90.2.423.5"></a><h4>Parameters</h4>
  12536. <div class="informaltable"><table><tr>
  12537. <td class="parameter_name"><p>c</p></td>
  12538. <td class="parameter_description">
  12539. <p>a Unicode character</p>
  12540. <p>Passed as <code class="code">c</code></p>
  12541. </td>
  12542. </tr></table></div>
  12543. </div>
  12544. </div>
  12545. <div class="refsect2">
  12546. <a name="id-1.1.90.2.424"></a><h3>unichar-isxdigit?</h3>
  12547. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-isxdigit? c))
  12548. </pre></div>
  12549. <p>Determines if a character is a hexadecimal digit.</p>
  12550. <div class="refsect3">
  12551. <a name="id-1.1.90.2.424.4"></a><h4>Parameters</h4>
  12552. <div class="informaltable"><table><tr>
  12553. <td class="parameter_name"><p>c</p></td>
  12554. <td class="parameter_description">
  12555. <p>a Unicode character.</p>
  12556. <p>Passed as <code class="code">c</code></p>
  12557. </td>
  12558. </tr></table></div>
  12559. </div>
  12560. </div>
  12561. <div class="refsect2">
  12562. <a name="id-1.1.90.2.425"></a><h3>unichar-iszerowidth?</h3>
  12563. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-iszerowidth? c))
  12564. </pre></div>
  12565. <p>Determines if a given character typically takes zero width when rendered.
  12566. The return value is <code class="constant">TRUE</code> for all non-spacing and enclosing marks
  12567. (e.g., combining accents), format characters, zero-width
  12568. space, but not U+00AD SOFT HYPHEN.
  12569. </p>
  12570. <p>A typical use of this function is with one of <code class="function">g_unichar_iswide()</code> or
  12571. <code class="function">g_unichar_iswide_cjk()</code> to determine the number of cells a string occupies
  12572. when displayed on a grid display (terminals). However, note that not all
  12573. terminals support zero-width rendering of zero-width marks.</p>
  12574. <div class="refsect3">
  12575. <a name="id-1.1.90.2.425.5"></a><h4>Parameters</h4>
  12576. <div class="informaltable"><table><tr>
  12577. <td class="parameter_name"><p>c</p></td>
  12578. <td class="parameter_description">
  12579. <p>a Unicode character</p>
  12580. <p>Passed as <code class="code">c</code></p>
  12581. </td>
  12582. </tr></table></div>
  12583. </div>
  12584. </div>
  12585. <div class="refsect2">
  12586. <a name="id-1.1.90.2.426"></a><h3>unichar-to-utf8!</h3>
  12587. <div class="informalexample"><pre class="programlisting">(define-values (%return outbuf) (unichar-to-utf8! c outbuf))
  12588. </pre></div>
  12589. <p>Converts a single character to UTF-8.</p>
  12590. <div class="refsect3">
  12591. <a name="id-1.1.90.2.426.4"></a><h4>Parameters</h4>
  12592. <div class="informaltable"><table>
  12593. <tr>
  12594. <td class="parameter_name"><p>c</p></td>
  12595. <td class="parameter_description">
  12596. <p>a Unicode character code</p>
  12597. <p>Passed as <code class="code">c</code></p>
  12598. </td>
  12599. </tr>
  12600. <tr>
  12601. <td class="parameter_name"><p>outbuf</p></td>
  12602. <td class="parameter_description">
  12603. <p>output buffer, must have at
  12604. least 6 bytes of space. If <code class="constant">NULL</code>, the length will be computed and
  12605. returned and nothing will be written to <em class="parameter"><code>outbuf</code></em>.</p>
  12606. <p>Passed as <code class="code">outbuf</code></p>
  12607. </td>
  12608. </tr>
  12609. </table></div>
  12610. </div>
  12611. </div>
  12612. <div class="refsect2">
  12613. <a name="id-1.1.90.2.427"></a><h3>unichar-tolower</h3>
  12614. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-tolower c))
  12615. </pre></div>
  12616. <p>Converts a character to lower case.</p>
  12617. <div class="refsect3">
  12618. <a name="id-1.1.90.2.427.4"></a><h4>Parameters</h4>
  12619. <div class="informaltable"><table><tr>
  12620. <td class="parameter_name"><p>c</p></td>
  12621. <td class="parameter_description">
  12622. <p>a Unicode character.</p>
  12623. <p>Passed as <code class="code">c</code></p>
  12624. </td>
  12625. </tr></table></div>
  12626. </div>
  12627. </div>
  12628. <div class="refsect2">
  12629. <a name="id-1.1.90.2.428"></a><h3>unichar-totitle</h3>
  12630. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-totitle c))
  12631. </pre></div>
  12632. <p>Converts a character to the titlecase.</p>
  12633. <div class="refsect3">
  12634. <a name="id-1.1.90.2.428.4"></a><h4>Parameters</h4>
  12635. <div class="informaltable"><table><tr>
  12636. <td class="parameter_name"><p>c</p></td>
  12637. <td class="parameter_description">
  12638. <p>a Unicode character</p>
  12639. <p>Passed as <code class="code">c</code></p>
  12640. </td>
  12641. </tr></table></div>
  12642. </div>
  12643. </div>
  12644. <div class="refsect2">
  12645. <a name="id-1.1.90.2.429"></a><h3>unichar-toupper</h3>
  12646. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-toupper c))
  12647. </pre></div>
  12648. <p>Converts a character to uppercase.</p>
  12649. <div class="refsect3">
  12650. <a name="id-1.1.90.2.429.4"></a><h4>Parameters</h4>
  12651. <div class="informaltable"><table><tr>
  12652. <td class="parameter_name"><p>c</p></td>
  12653. <td class="parameter_description">
  12654. <p>a Unicode character</p>
  12655. <p>Passed as <code class="code">c</code></p>
  12656. </td>
  12657. </tr></table></div>
  12658. </div>
  12659. </div>
  12660. <div class="refsect2">
  12661. <a name="id-1.1.90.2.430"></a><h3>unichar-type</h3>
  12662. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-type c))
  12663. </pre></div>
  12664. <p>Classifies a Unicode character by type.</p>
  12665. <div class="refsect3">
  12666. <a name="id-1.1.90.2.430.4"></a><h4>Parameters</h4>
  12667. <div class="informaltable"><table><tr>
  12668. <td class="parameter_name"><p>c</p></td>
  12669. <td class="parameter_description">
  12670. <p>a Unicode character</p>
  12671. <p>Passed as <code class="code">c</code></p>
  12672. </td>
  12673. </tr></table></div>
  12674. </div>
  12675. </div>
  12676. <div class="refsect2">
  12677. <a name="id-1.1.90.2.431"></a><h3>unichar-validate?</h3>
  12678. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-validate? ch))
  12679. </pre></div>
  12680. <p>Checks whether <em class="parameter"><code>ch</code></em> is a valid Unicode character. Some possible
  12681. integer values of <em class="parameter"><code>ch</code></em> will not be valid. 0 is considered a valid
  12682. character, though it's normally a string terminator.</p>
  12683. <div class="refsect3">
  12684. <a name="id-1.1.90.2.431.4"></a><h4>Parameters</h4>
  12685. <div class="informaltable"><table><tr>
  12686. <td class="parameter_name"><p>ch</p></td>
  12687. <td class="parameter_description">
  12688. <p>a Unicode character</p>
  12689. <p>Passed as <code class="code">ch</code></p>
  12690. </td>
  12691. </tr></table></div>
  12692. </div>
  12693. </div>
  12694. <div class="refsect2">
  12695. <a name="id-1.1.90.2.432"></a><h3>unichar-xdigit-value</h3>
  12696. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unichar-xdigit-value c))
  12697. </pre></div>
  12698. <p>Determines the numeric value of a character as a hexadecimal
  12699. digit.</p>
  12700. <div class="refsect3">
  12701. <a name="id-1.1.90.2.432.4"></a><h4>Parameters</h4>
  12702. <div class="informaltable"><table><tr>
  12703. <td class="parameter_name"><p>c</p></td>
  12704. <td class="parameter_description">
  12705. <p>a Unicode character</p>
  12706. <p>Passed as <code class="code">c</code></p>
  12707. </td>
  12708. </tr></table></div>
  12709. </div>
  12710. </div>
  12711. <div class="refsect2">
  12712. <a name="id-1.1.90.2.433"></a><h3>unicode-canonical-ordering</h3>
  12713. <div class="informalexample"><pre class="programlisting">(define-values () (unicode-canonical-ordering string len))
  12714. </pre></div>
  12715. <p>Computes the canonical ordering of a string in-place.
  12716. This rearranges decomposed characters in the string
  12717. according to their combining classes. See the Unicode
  12718. manual for more information.</p>
  12719. <div class="refsect3">
  12720. <a name="id-1.1.90.2.433.4"></a><h4>Parameters</h4>
  12721. <div class="informaltable"><table>
  12722. <tr>
  12723. <td class="parameter_name"><p>string</p></td>
  12724. <td class="parameter_description">
  12725. <p>a UCS-4 encoded string.</p>
  12726. <p>Passed as <code class="code">string</code></p>
  12727. </td>
  12728. </tr>
  12729. <tr>
  12730. <td class="parameter_name"><p>len</p></td>
  12731. <td class="parameter_description">
  12732. <p>the maximum length of <em class="parameter"><code>string</code></em> to use.</p>
  12733. <p>Passed as <code class="code">len</code></p>
  12734. </td>
  12735. </tr>
  12736. </table></div>
  12737. </div>
  12738. </div>
  12739. <div class="refsect2">
  12740. <a name="id-1.1.90.2.434"></a><h3>unicode-script-from-iso15924</h3>
  12741. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unicode-script-from-iso15924 iso15924))
  12742. </pre></div>
  12743. <p>Looks up the Unicode script for <em class="parameter"><code>iso15924</code></em>. ISO 15924 assigns four-letter
  12744. codes to scripts. For example, the code for Arabic is 'Arab'.
  12745. This function accepts four letter codes encoded as a <em class="parameter"><code>guint32</code></em> in a
  12746. big-endian fashion. That is, the code expected for Arabic is
  12747. 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
  12748. </p>
  12749. <p>See
  12750. [Codes for the representation of names of scripts](http://unicode.org/iso15924/codelists.html)
  12751. for details.</p>
  12752. <div class="refsect3">
  12753. <a name="id-1.1.90.2.434.5"></a><h4>Parameters</h4>
  12754. <div class="informaltable"><table><tr>
  12755. <td class="parameter_name"><p>iso15924</p></td>
  12756. <td class="parameter_description">
  12757. <p>a Unicode script</p>
  12758. <p>Passed as <code class="code">iso15924</code></p>
  12759. </td>
  12760. </tr></table></div>
  12761. </div>
  12762. </div>
  12763. <div class="refsect2">
  12764. <a name="id-1.1.90.2.435"></a><h3>unicode-script-to-iso15924</h3>
  12765. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unicode-script-to-iso15924 script))
  12766. </pre></div>
  12767. <p>Looks up the ISO 15924 code for <em class="parameter"><code>script</code></em>. ISO 15924 assigns four-letter
  12768. codes to scripts. For example, the code for Arabic is 'Arab'. The
  12769. four letter codes are encoded as a <em class="parameter"><code>guint32</code></em> by this function in a
  12770. big-endian fashion. That is, the code returned for Arabic is
  12771. 0x41726162 (0x41 is ASCII code for 'A', 0x72 is ASCII code for 'r', etc).
  12772. </p>
  12773. <p>See
  12774. [Codes for the representation of names of scripts](http://unicode.org/iso15924/codelists.html)
  12775. for details.</p>
  12776. <div class="refsect3">
  12777. <a name="id-1.1.90.2.435.5"></a><h4>Parameters</h4>
  12778. <div class="informaltable"><table><tr>
  12779. <td class="parameter_name"><p>script</p></td>
  12780. <td class="parameter_description">
  12781. <p>a Unicode script</p>
  12782. <p>Passed as <code class="code">script</code></p>
  12783. </td>
  12784. </tr></table></div>
  12785. </div>
  12786. </div>
  12787. <div class="refsect2">
  12788. <a name="id-1.1.90.2.436"></a><h3>unix-error-quark</h3>
  12789. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unix-error-quark))
  12790. </pre></div>
  12791. <p>Undocumented</p>
  12792. </div>
  12793. <div class="refsect2">
  12794. <a name="id-1.1.90.2.437"></a><h3>unix-fd-add-full</h3>
  12795. <div class="informalexample"><pre class="programlisting">(define-values
  12796. (%return)
  12797. (unix-fd-add-full priority fd condition function user-data notify))
  12798. </pre></div>
  12799. <p>Sets a function to be called when the IO condition, as specified by
  12800. <em class="parameter"><code>condition</code></em> becomes true for <em class="parameter"><code>fd</code></em>.
  12801. </p>
  12802. <p>This is the same as <code class="function">g_unix_fd_add()</code>, except that it allows you to
  12803. specify a non-default priority and a provide a <span class="type">GDestroyNotify</span> for
  12804. <em class="parameter"><code>user_data</code></em>.</p>
  12805. <div class="refsect3">
  12806. <a name="id-1.1.90.2.437.5"></a><h4>Parameters</h4>
  12807. <div class="informaltable"><table>
  12808. <tr>
  12809. <td class="parameter_name"><p>priority</p></td>
  12810. <td class="parameter_description">
  12811. <p>the priority of the source</p>
  12812. <p>Passed as <code class="code">priority</code></p>
  12813. </td>
  12814. </tr>
  12815. <tr>
  12816. <td class="parameter_name"><p>fd</p></td>
  12817. <td class="parameter_description">
  12818. <p>a file descriptor</p>
  12819. <p>Passed as <code class="code">fd</code></p>
  12820. </td>
  12821. </tr>
  12822. <tr>
  12823. <td class="parameter_name"><p>condition</p></td>
  12824. <td class="parameter_description">
  12825. <p>IO conditions to watch for on <em class="parameter"><code>fd</code></em></p>
  12826. <p>Passed as <code class="code">condition</code></p>
  12827. </td>
  12828. </tr>
  12829. <tr>
  12830. <td class="parameter_name"><p>function</p></td>
  12831. <td class="parameter_description">
  12832. <p>a <span class="type">GUnixFDSourceFunc</span></p>
  12833. <p>Passed as <code class="code">function</code></p>
  12834. </td>
  12835. </tr>
  12836. <tr>
  12837. <td class="parameter_name"><p>user_data</p></td>
  12838. <td class="parameter_description">
  12839. <p>data to pass to <em class="parameter"><code>function</code></em></p>
  12840. <p>Passed as <code class="code">user-data</code></p>
  12841. </td>
  12842. </tr>
  12843. <tr>
  12844. <td class="parameter_name"><p>notify</p></td>
  12845. <td class="parameter_description">
  12846. <p>function to call when the idle is removed, or <code class="constant">NULL</code></p>
  12847. <p>Passed as <code class="code">notify</code></p>
  12848. </td>
  12849. </tr>
  12850. </table></div>
  12851. </div>
  12852. </div>
  12853. <div class="refsect2">
  12854. <a name="id-1.1.90.2.438"></a><h3>unix-fd-source-new</h3>
  12855. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unix-fd-source-new fd condition))
  12856. </pre></div>
  12857. <p>Creates a <span class="type">GSource</span> to watch for a particular IO condition on a file
  12858. descriptor.
  12859. </p>
  12860. <p>The source will never close the fd -- you must do it yourself.</p>
  12861. <div class="refsect3">
  12862. <a name="id-1.1.90.2.438.5"></a><h4>Parameters</h4>
  12863. <div class="informaltable"><table>
  12864. <tr>
  12865. <td class="parameter_name"><p>fd</p></td>
  12866. <td class="parameter_description">
  12867. <p>a file descriptor</p>
  12868. <p>Passed as <code class="code">fd</code></p>
  12869. </td>
  12870. </tr>
  12871. <tr>
  12872. <td class="parameter_name"><p>condition</p></td>
  12873. <td class="parameter_description">
  12874. <p>IO conditions to watch for on <em class="parameter"><code>fd</code></em></p>
  12875. <p>Passed as <code class="code">condition</code></p>
  12876. </td>
  12877. </tr>
  12878. </table></div>
  12879. </div>
  12880. </div>
  12881. <div class="refsect2">
  12882. <a name="id-1.1.90.2.439"></a><h3>unix-get-passwd-entry</h3>
  12883. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unix-get-passwd-entry user-name))
  12884. </pre></div>
  12885. <p>Get the <code class="code">passwd</code> file entry for the given <em class="parameter"><code>user_name</code></em> using <code class="code">getpwnam_r()</code>.
  12886. This can fail if the given <em class="parameter"><code>user_name</code></em> doesn’t exist.
  12887. </p>
  12888. <p>The returned <code class="code">struct passwd</code> has been allocated using <code class="function">g_malloc()</code> and should
  12889. be freed using <code class="function">g_free()</code>. The strings referenced by the returned struct are
  12890. included in the same allocation, so are valid until the <code class="code">struct passwd</code> is
  12891. freed.
  12892. </p>
  12893. <p>This function is safe to call from multiple threads concurrently.
  12894. </p>
  12895. <p>You will need to include <code class="code">pwd.h</code> to get the definition of <code class="code">struct passwd</code>.</p>
  12896. <div class="refsect3">
  12897. <a name="id-1.1.90.2.439.7"></a><h4>Parameters</h4>
  12898. <div class="informaltable"><table><tr>
  12899. <td class="parameter_name"><p>user_name</p></td>
  12900. <td class="parameter_description">
  12901. <p>the username to get the passwd file entry for</p>
  12902. <p>Passed as <code class="code">user-name</code></p>
  12903. </td>
  12904. </tr></table></div>
  12905. </div>
  12906. </div>
  12907. <div class="refsect2">
  12908. <a name="id-1.1.90.2.440"></a><h3>unix-open-pipe?</h3>
  12909. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unix-open-pipe? fds flags))
  12910. </pre></div>
  12911. <p>Similar to the UNIX <code class="function">pipe()</code> call, but on modern systems like Linux
  12912. uses the <code class="function">pipe2()</code> system call, which atomically creates a pipe with
  12913. the configured flags. The only supported flag currently is
  12914. <code class="constant">FD_CLOEXEC</code>. If for example you want to configure <code class="constant">O_NONBLOCK</code>, that
  12915. must still be done separately with <code class="function">fcntl()</code>.
  12916. </p>
  12917. <p>This function does not take <code class="constant">O_CLOEXEC</code>, it takes <code class="constant">FD_CLOEXEC</code> as if
  12918. for <code class="function">fcntl()</code>; these are different on Linux/glibc.</p>
  12919. <div class="refsect3">
  12920. <a name="id-1.1.90.2.440.5"></a><h4>Parameters</h4>
  12921. <div class="informaltable"><table>
  12922. <tr>
  12923. <td class="parameter_name"><p>fds</p></td>
  12924. <td class="parameter_description">
  12925. <p>Array of two integers</p>
  12926. <p>Passed as <code class="code">fds</code></p>
  12927. </td>
  12928. </tr>
  12929. <tr>
  12930. <td class="parameter_name"><p>flags</p></td>
  12931. <td class="parameter_description">
  12932. <p>Bitfield of file descriptor flags, as for <code class="function">fcntl()</code></p>
  12933. <p>Passed as <code class="code">flags</code></p>
  12934. </td>
  12935. </tr>
  12936. </table></div>
  12937. </div>
  12938. </div>
  12939. <div class="refsect2">
  12940. <a name="id-1.1.90.2.441"></a><h3>unix-set-fd-nonblocking?</h3>
  12941. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unix-set-fd-nonblocking? fd nonblock))
  12942. </pre></div>
  12943. <p>Control the non-blocking state of the given file descriptor,
  12944. according to <em class="parameter"><code>nonblock</code></em>. On most systems this uses <code class="constant">O_NONBLOCK</code>, but
  12945. on some older ones may use <code class="constant">O_NDELAY</code>.</p>
  12946. <div class="refsect3">
  12947. <a name="id-1.1.90.2.441.4"></a><h4>Parameters</h4>
  12948. <div class="informaltable"><table>
  12949. <tr>
  12950. <td class="parameter_name"><p>fd</p></td>
  12951. <td class="parameter_description">
  12952. <p>A file descriptor</p>
  12953. <p>Passed as <code class="code">fd</code></p>
  12954. </td>
  12955. </tr>
  12956. <tr>
  12957. <td class="parameter_name"><p>nonblock</p></td>
  12958. <td class="parameter_description">
  12959. <p>If <code class="constant">TRUE</code>, set the descriptor to be non-blocking</p>
  12960. <p>Passed as <code class="code">nonblock</code></p>
  12961. </td>
  12962. </tr>
  12963. </table></div>
  12964. </div>
  12965. </div>
  12966. <div class="refsect2">
  12967. <a name="id-1.1.90.2.442"></a><h3>unix-signal-add</h3>
  12968. <div class="informalexample"><pre class="programlisting">(define-values
  12969. (%return)
  12970. (unix-signal-add priority signum handler user-data notify))
  12971. </pre></div>
  12972. <p>A convenience function for <code class="function">g_unix_signal_source_new()</code>, which
  12973. attaches to the default <span class="type">GMainContext</span>. You can remove the watch
  12974. using <code class="function">g_source_remove()</code>.</p>
  12975. <div class="refsect3">
  12976. <a name="id-1.1.90.2.442.4"></a><h4>Parameters</h4>
  12977. <div class="informaltable"><table>
  12978. <tr>
  12979. <td class="parameter_name"><p>notify</p></td>
  12980. <td class="parameter_description">
  12981. <p></p>
  12982. <p>Passed as <code class="code">notify</code></p>
  12983. </td>
  12984. </tr>
  12985. <tr>
  12986. <td class="parameter_name"><p>priority</p></td>
  12987. <td class="parameter_description">
  12988. <p></p>
  12989. <p>Passed as <code class="code">priority</code></p>
  12990. </td>
  12991. </tr>
  12992. <tr>
  12993. <td class="parameter_name"><p>signum</p></td>
  12994. <td class="parameter_description">
  12995. <p>Signal number</p>
  12996. <p>Passed as <code class="code">signum</code></p>
  12997. </td>
  12998. </tr>
  12999. <tr>
  13000. <td class="parameter_name"><p>handler</p></td>
  13001. <td class="parameter_description">
  13002. <p>Callback</p>
  13003. <p>Passed as <code class="code">handler</code></p>
  13004. </td>
  13005. </tr>
  13006. <tr>
  13007. <td class="parameter_name"><p>user_data</p></td>
  13008. <td class="parameter_description">
  13009. <p>Data for <em class="parameter"><code>handler</code></em></p>
  13010. <p>Passed as <code class="code">user-data</code></p>
  13011. </td>
  13012. </tr>
  13013. </table></div>
  13014. </div>
  13015. </div>
  13016. <div class="refsect2">
  13017. <a name="id-1.1.90.2.443"></a><h3>unix-signal-source-new</h3>
  13018. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unix-signal-source-new signum))
  13019. </pre></div>
  13020. <p>Create a <span class="type">GSource</span> that will be dispatched upon delivery of the UNIX
  13021. signal <em class="parameter"><code>signum</code></em>. In GLib versions before 2.36, only <code class="code">SIGHUP</code>, <code class="code">SIGINT</code>,
  13022. <code class="code">SIGTERM</code> can be monitored. In GLib 2.36, <code class="code">SIGUSR1</code> and <code class="code">SIGUSR2</code>
  13023. were added. In GLib 2.54, <code class="code">SIGWINCH</code> was added.
  13024. </p>
  13025. <p>Note that unlike the UNIX default, all sources which have created a
  13026. watch will be dispatched, regardless of which underlying thread
  13027. invoked <code class="function">g_unix_signal_source_new()</code>.
  13028. </p>
  13029. <p>For example, an effective use of this function is to handle <code class="code">SIGTERM</code>
  13030. cleanly; flushing any outstanding files, and then calling
  13031. g_main_loop_quit (). It is not safe to do any of this a regular
  13032. UNIX signal handler; your handler may be invoked while <code class="function">malloc()</code> or
  13033. another library function is running, causing reentrancy if you
  13034. attempt to use it from the handler. None of the GLib/GObject API
  13035. is safe against this kind of reentrancy.
  13036. </p>
  13037. <p>The interaction of this source when combined with native UNIX
  13038. functions like <code class="function">sigprocmask()</code> is not defined.
  13039. </p>
  13040. <p>The source will not initially be associated with any <span class="type">GMainContext</span>
  13041. and must be added to one with <code class="function">g_source_attach()</code> before it will be
  13042. executed.</p>
  13043. <div class="refsect3">
  13044. <a name="id-1.1.90.2.443.8"></a><h4>Parameters</h4>
  13045. <div class="informaltable"><table><tr>
  13046. <td class="parameter_name"><p>signum</p></td>
  13047. <td class="parameter_description">
  13048. <p>A signal number</p>
  13049. <p>Passed as <code class="code">signum</code></p>
  13050. </td>
  13051. </tr></table></div>
  13052. </div>
  13053. </div>
  13054. <div class="refsect2">
  13055. <a name="id-1.1.90.2.444"></a><h3>unlink</h3>
  13056. <div class="informalexample"><pre class="programlisting">(define-values (%return) (unlink filename))
  13057. </pre></div>
  13058. <p>A wrapper for the POSIX <code class="function">unlink()</code> function. The <code class="function">unlink()</code> function
  13059. deletes a name from the filesystem. If this was the last link to the
  13060. file and no processes have it opened, the diskspace occupied by the
  13061. file is freed.
  13062. </p>
  13063. <p>See your C library manual for more details about <code class="function">unlink()</code>. Note
  13064. that on Windows, it is in general not possible to delete files that
  13065. are open to some process, or mapped into memory.</p>
  13066. <div class="refsect3">
  13067. <a name="id-1.1.90.2.444.5"></a><h4>Parameters</h4>
  13068. <div class="informaltable"><table><tr>
  13069. <td class="parameter_name"><p>filename</p></td>
  13070. <td class="parameter_description">
  13071. <p>a pathname in the GLib file name encoding
  13072. (UTF-8 on Windows)</p>
  13073. <p>Passed as <code class="code">filename</code></p>
  13074. </td>
  13075. </tr></table></div>
  13076. </div>
  13077. </div>
  13078. <div class="refsect2">
  13079. <a name="id-1.1.90.2.445"></a><h3>unsetenv</h3>
  13080. <div class="informalexample"><pre class="programlisting">(define-values () (unsetenv variable))
  13081. </pre></div>
  13082. <p>Removes an environment variable from the environment.
  13083. </p>
  13084. <p>Note that on some systems, when variables are overwritten, the
  13085. memory used for the previous variables and its value isn't reclaimed.
  13086. </p>
  13087. <p>You should be mindful of the fact that environment variable handling
  13088. in UNIX is not thread-safe, and your program may crash if one thread
  13089. calls <code class="function">g_unsetenv()</code> while another thread is calling <code class="function">getenv()</code>. (And note
  13090. that many functions, such as <code class="function">gettext()</code>, call <code class="function">getenv()</code> internally.) This
  13091. function is only safe to use at the very start of your program, before
  13092. creating any other threads (or creating objects that create worker
  13093. threads of their own).
  13094. </p>
  13095. <p>If you need to set up the environment for a child process, you can
  13096. use <code class="function">g_get_environ()</code> to get an environment array, modify that with
  13097. <code class="function">g_environ_setenv()</code> and <code class="function">g_environ_unsetenv()</code>, and then pass that
  13098. array directly to <code class="function">execvpe()</code>, <code class="function">g_spawn_async()</code>, or the like.</p>
  13099. <div class="refsect3">
  13100. <a name="id-1.1.90.2.445.7"></a><h4>Parameters</h4>
  13101. <div class="informaltable"><table><tr>
  13102. <td class="parameter_name"><p>variable</p></td>
  13103. <td class="parameter_description">
  13104. <p>the environment variable to remove, must
  13105. not contain '='</p>
  13106. <p>Passed as <code class="code">variable</code></p>
  13107. </td>
  13108. </tr></table></div>
  13109. </div>
  13110. </div>
  13111. <div class="refsect2">
  13112. <a name="id-1.1.90.2.446"></a><h3>uri-build</h3>
  13113. <div class="informalexample"><pre class="programlisting">(define-values
  13114. (%return)
  13115. (uri-build flags scheme userinfo host port path query fragment))
  13116. </pre></div>
  13117. <p>Creates a new <span class="type">GUri</span> from the given components according to <em class="parameter"><code>flags</code></em>.
  13118. </p>
  13119. <p>See also <code class="function">g_uri_build_with_user()</code>, which allows specifying the
  13120. components of the "userinfo" separately.</p>
  13121. <div class="refsect3">
  13122. <a name="id-1.1.90.2.446.5"></a><h4>Parameters</h4>
  13123. <div class="informaltable"><table>
  13124. <tr>
  13125. <td class="parameter_name"><p>flags</p></td>
  13126. <td class="parameter_description">
  13127. <p>flags describing how to build the <span class="type">GUri</span></p>
  13128. <p>Passed as <code class="code">flags</code></p>
  13129. </td>
  13130. </tr>
  13131. <tr>
  13132. <td class="parameter_name"><p>scheme</p></td>
  13133. <td class="parameter_description">
  13134. <p>the URI scheme</p>
  13135. <p>Passed as <code class="code">scheme</code></p>
  13136. </td>
  13137. </tr>
  13138. <tr>
  13139. <td class="parameter_name"><p>userinfo</p></td>
  13140. <td class="parameter_description">
  13141. <p>the userinfo component, or <code class="constant">NULL</code></p>
  13142. <p>Passed as <code class="code">userinfo</code></p>
  13143. </td>
  13144. </tr>
  13145. <tr>
  13146. <td class="parameter_name"><p>host</p></td>
  13147. <td class="parameter_description">
  13148. <p>the host component, or <code class="constant">NULL</code></p>
  13149. <p>Passed as <code class="code">host</code></p>
  13150. </td>
  13151. </tr>
  13152. <tr>
  13153. <td class="parameter_name"><p>port</p></td>
  13154. <td class="parameter_description">
  13155. <p>the port, or <code class="code">-1</code></p>
  13156. <p>Passed as <code class="code">port</code></p>
  13157. </td>
  13158. </tr>
  13159. <tr>
  13160. <td class="parameter_name"><p>path</p></td>
  13161. <td class="parameter_description">
  13162. <p>the path component</p>
  13163. <p>Passed as <code class="code">path</code></p>
  13164. </td>
  13165. </tr>
  13166. <tr>
  13167. <td class="parameter_name"><p>query</p></td>
  13168. <td class="parameter_description">
  13169. <p>the query component, or <code class="constant">NULL</code></p>
  13170. <p>Passed as <code class="code">query</code></p>
  13171. </td>
  13172. </tr>
  13173. <tr>
  13174. <td class="parameter_name"><p>fragment</p></td>
  13175. <td class="parameter_description">
  13176. <p>the fragment, or <code class="constant">NULL</code></p>
  13177. <p>Passed as <code class="code">fragment</code></p>
  13178. </td>
  13179. </tr>
  13180. </table></div>
  13181. </div>
  13182. </div>
  13183. <div class="refsect2">
  13184. <a name="id-1.1.90.2.447"></a><h3>uri-build-with-user</h3>
  13185. <div class="informalexample"><pre class="programlisting">(define-values
  13186. (%return)
  13187. (uri-build-with-user
  13188. flags
  13189. scheme
  13190. user
  13191. password
  13192. auth-params
  13193. host
  13194. port
  13195. path
  13196. query
  13197. fragment))
  13198. </pre></div>
  13199. <p>Creates a new <span class="type">GUri</span> from the given components according to <em class="parameter"><code>flags</code></em>
  13200. (<code class="constant">G_URI_FLAGS_HAS_PASSWORD</code> is added unconditionally). The <em class="parameter"><code>flags</code></em> must be
  13201. coherent with the passed values, in particular use <code class="code">%</code>-encoded values with
  13202. <code class="constant">G_URI_FLAGS_ENCODED</code>.
  13203. </p>
  13204. <p>In contrast to <code class="function">g_uri_build()</code>, this allows specifying the components
  13205. of the ‘userinfo’ field separately. Note that <em class="parameter"><code>user</code></em> must be non-<code class="constant">NULL</code>
  13206. if either <em class="parameter"><code>password</code></em> or <em class="parameter"><code>auth_params</code></em> is non-<code class="constant">NULL</code>.</p>
  13207. <div class="refsect3">
  13208. <a name="id-1.1.90.2.447.5"></a><h4>Parameters</h4>
  13209. <div class="informaltable"><table>
  13210. <tr>
  13211. <td class="parameter_name"><p>flags</p></td>
  13212. <td class="parameter_description">
  13213. <p>flags describing how to build the <span class="type">GUri</span></p>
  13214. <p>Passed as <code class="code">flags</code></p>
  13215. </td>
  13216. </tr>
  13217. <tr>
  13218. <td class="parameter_name"><p>scheme</p></td>
  13219. <td class="parameter_description">
  13220. <p>the URI scheme</p>
  13221. <p>Passed as <code class="code">scheme</code></p>
  13222. </td>
  13223. </tr>
  13224. <tr>
  13225. <td class="parameter_name"><p>user</p></td>
  13226. <td class="parameter_description">
  13227. <p>the user component of the userinfo, or <code class="constant">NULL</code></p>
  13228. <p>Passed as <code class="code">user</code></p>
  13229. </td>
  13230. </tr>
  13231. <tr>
  13232. <td class="parameter_name"><p>password</p></td>
  13233. <td class="parameter_description">
  13234. <p>the password component of the userinfo, or <code class="constant">NULL</code></p>
  13235. <p>Passed as <code class="code">password</code></p>
  13236. </td>
  13237. </tr>
  13238. <tr>
  13239. <td class="parameter_name"><p>auth_params</p></td>
  13240. <td class="parameter_description">
  13241. <p>the auth params of the userinfo, or <code class="constant">NULL</code></p>
  13242. <p>Passed as <code class="code">auth-params</code></p>
  13243. </td>
  13244. </tr>
  13245. <tr>
  13246. <td class="parameter_name"><p>host</p></td>
  13247. <td class="parameter_description">
  13248. <p>the host component, or <code class="constant">NULL</code></p>
  13249. <p>Passed as <code class="code">host</code></p>
  13250. </td>
  13251. </tr>
  13252. <tr>
  13253. <td class="parameter_name"><p>port</p></td>
  13254. <td class="parameter_description">
  13255. <p>the port, or <code class="code">-1</code></p>
  13256. <p>Passed as <code class="code">port</code></p>
  13257. </td>
  13258. </tr>
  13259. <tr>
  13260. <td class="parameter_name"><p>path</p></td>
  13261. <td class="parameter_description">
  13262. <p>the path component</p>
  13263. <p>Passed as <code class="code">path</code></p>
  13264. </td>
  13265. </tr>
  13266. <tr>
  13267. <td class="parameter_name"><p>query</p></td>
  13268. <td class="parameter_description">
  13269. <p>the query component, or <code class="constant">NULL</code></p>
  13270. <p>Passed as <code class="code">query</code></p>
  13271. </td>
  13272. </tr>
  13273. <tr>
  13274. <td class="parameter_name"><p>fragment</p></td>
  13275. <td class="parameter_description">
  13276. <p>the fragment, or <code class="constant">NULL</code></p>
  13277. <p>Passed as <code class="code">fragment</code></p>
  13278. </td>
  13279. </tr>
  13280. </table></div>
  13281. </div>
  13282. </div>
  13283. <div class="refsect2">
  13284. <a name="id-1.1.90.2.448"></a><h3>uri-error-quark</h3>
  13285. <div class="informalexample"><pre class="programlisting">(define-values (%return) (uri-error-quark))
  13286. </pre></div>
  13287. <p>Undocumented</p>
  13288. </div>
  13289. <div class="refsect2">
  13290. <a name="id-1.1.90.2.449"></a><h3>uri-escape-bytes</h3>
  13291. <div class="informalexample"><pre class="programlisting">(define-values (%return) (uri-escape-bytes unescaped reserved-chars-allowed))
  13292. </pre></div>
  13293. <p>Escapes arbitrary data for use in a URI.
  13294. </p>
  13295. <p>Normally all characters that are not ‘unreserved’ (i.e. ASCII
  13296. alphanumerical characters plus dash, dot, underscore and tilde) are
  13297. escaped. But if you specify characters in <em class="parameter"><code>reserved_chars_allowed</code></em>
  13298. they are not escaped. This is useful for the ‘reserved’ characters
  13299. in the URI specification, since those are allowed unescaped in some
  13300. portions of a URI.
  13301. </p>
  13302. <p>Though technically incorrect, this will also allow escaping nul
  13303. bytes as <code class="code">%</code><code class="code">00</code>.</p>
  13304. <div class="refsect3">
  13305. <a name="id-1.1.90.2.449.6"></a><h4>Parameters</h4>
  13306. <div class="informaltable"><table>
  13307. <tr>
  13308. <td class="parameter_name"><p>unescaped</p></td>
  13309. <td class="parameter_description">
  13310. <p>the unescaped input data.</p>
  13311. <p>Passed as <code class="code">unescaped</code></p>
  13312. </td>
  13313. </tr>
  13314. <tr>
  13315. <td class="parameter_name"><p>length</p></td>
  13316. <td class="parameter_description">
  13317. <p>the length of <em class="parameter"><code>unescaped</code></em></p>
  13318. <p>Inferred from <code class="code">unescaped</code></p>
  13319. </td>
  13320. </tr>
  13321. <tr>
  13322. <td class="parameter_name"><p>reserved_chars_allowed</p></td>
  13323. <td class="parameter_description">
  13324. <p>a string of reserved
  13325. characters that are allowed to be used, or <code class="constant">NULL</code>.</p>
  13326. <p>Passed as <code class="code">reserved-chars-allowed</code></p>
  13327. </td>
  13328. </tr>
  13329. </table></div>
  13330. </div>
  13331. </div>
  13332. <div class="refsect2">
  13333. <a name="id-1.1.90.2.450"></a><h3>uri-escape-string</h3>
  13334. <div class="informalexample"><pre class="programlisting">(define-values
  13335. (%return)
  13336. (uri-escape-string unescaped reserved-chars-allowed allow-utf8))
  13337. </pre></div>
  13338. <p>Escapes a string for use in a URI.
  13339. </p>
  13340. <p>Normally all characters that are not "unreserved" (i.e. ASCII
  13341. alphanumerical characters plus dash, dot, underscore and tilde) are
  13342. escaped. But if you specify characters in <em class="parameter"><code>reserved_chars_allowed</code></em>
  13343. they are not escaped. This is useful for the "reserved" characters
  13344. in the URI specification, since those are allowed unescaped in some
  13345. portions of a URI.</p>
  13346. <div class="refsect3">
  13347. <a name="id-1.1.90.2.450.5"></a><h4>Parameters</h4>
  13348. <div class="informaltable"><table>
  13349. <tr>
  13350. <td class="parameter_name"><p>unescaped</p></td>
  13351. <td class="parameter_description">
  13352. <p>the unescaped input string.</p>
  13353. <p>Passed as <code class="code">unescaped</code></p>
  13354. </td>
  13355. </tr>
  13356. <tr>
  13357. <td class="parameter_name"><p>reserved_chars_allowed</p></td>
  13358. <td class="parameter_description">
  13359. <p>a string of reserved
  13360. characters that are allowed to be used, or <code class="constant">NULL</code>.</p>
  13361. <p>Passed as <code class="code">reserved-chars-allowed</code></p>
  13362. </td>
  13363. </tr>
  13364. <tr>
  13365. <td class="parameter_name"><p>allow_utf8</p></td>
  13366. <td class="parameter_description">
  13367. <p><code class="constant">TRUE</code> if the result can include UTF-8 characters.</p>
  13368. <p>Passed as <code class="code">allow-utf8</code></p>
  13369. </td>
  13370. </tr>
  13371. </table></div>
  13372. </div>
  13373. </div>
  13374. <div class="refsect2">
  13375. <a name="id-1.1.90.2.451"></a><h3>uri-is-valid?</h3>
  13376. <div class="informalexample"><pre class="programlisting">(define-values (%return) (uri-is-valid? uri-string flags))
  13377. </pre></div>
  13378. <p>Parses <em class="parameter"><code>uri_string</code></em> according to <em class="parameter"><code>flags</code></em>, to determine whether it is a valid
  13379. [absolute URI][relative-absolute-uris], i.e. it does not need to be resolved
  13380. relative to another URI using <code class="function">g_uri_parse_relative()</code>.
  13381. </p>
  13382. <p>If it’s not a valid URI, an error is returned explaining how it’s invalid.
  13383. </p>
  13384. <p>See <code class="function">g_uri_split()</code>, and the definition of <span class="type">GUriFlags</span>, for more
  13385. information on the effect of <em class="parameter"><code>flags</code></em>.</p>
  13386. <div class="refsect3">
  13387. <a name="id-1.1.90.2.451.6"></a><h4>Parameters</h4>
  13388. <div class="informaltable"><table>
  13389. <tr>
  13390. <td class="parameter_name"><p>uri_string</p></td>
  13391. <td class="parameter_description">
  13392. <p>a string containing an absolute URI</p>
  13393. <p>Passed as <code class="code">uri-string</code></p>
  13394. </td>
  13395. </tr>
  13396. <tr>
  13397. <td class="parameter_name"><p>flags</p></td>
  13398. <td class="parameter_description">
  13399. <p>flags for parsing <em class="parameter"><code>uri_string</code></em></p>
  13400. <p>Passed as <code class="code">flags</code></p>
  13401. </td>
  13402. </tr>
  13403. </table></div>
  13404. </div>
  13405. </div>
  13406. <div class="refsect2">
  13407. <a name="id-1.1.90.2.452"></a><h3>uri-join</h3>
  13408. <div class="informalexample"><pre class="programlisting">(define-values
  13409. (%return)
  13410. (uri-join flags scheme userinfo host port path query fragment))
  13411. </pre></div>
  13412. <p>Joins the given components together according to <em class="parameter"><code>flags</code></em> to create
  13413. an absolute URI string. <em class="parameter"><code>path</code></em> may not be <code class="constant">NULL</code> (though it may be the empty
  13414. string).
  13415. </p>
  13416. <p>When <em class="parameter"><code>host</code></em> is present, <em class="parameter"><code>path</code></em> must either be empty or begin with a slash (<code class="code">/</code>)
  13417. character. When <em class="parameter"><code>host</code></em> is not present, <em class="parameter"><code>path</code></em> cannot begin with two slash
  13418. characters (<code class="code">//</code>). See
  13419. [RFC 3986, section 3](https://tools.ietf.org/html/rfc3986#section-3).
  13420. </p>
  13421. <p>See also <code class="function">g_uri_join_with_user()</code>, which allows specifying the
  13422. components of the ‘userinfo’ separately.
  13423. </p>
  13424. <p><code class="constant">G_URI_FLAGS_HAS_PASSWORD</code> and <code class="constant">G_URI_FLAGS_HAS_AUTH_PARAMS</code> are ignored if set
  13425. in <em class="parameter"><code>flags</code></em>.</p>
  13426. <div class="refsect3">
  13427. <a name="id-1.1.90.2.452.7"></a><h4>Parameters</h4>
  13428. <div class="informaltable"><table>
  13429. <tr>
  13430. <td class="parameter_name"><p>flags</p></td>
  13431. <td class="parameter_description">
  13432. <p>flags describing how to build the URI string</p>
  13433. <p>Passed as <code class="code">flags</code></p>
  13434. </td>
  13435. </tr>
  13436. <tr>
  13437. <td class="parameter_name"><p>scheme</p></td>
  13438. <td class="parameter_description">
  13439. <p>the URI scheme, or <code class="constant">NULL</code></p>
  13440. <p>Passed as <code class="code">scheme</code></p>
  13441. </td>
  13442. </tr>
  13443. <tr>
  13444. <td class="parameter_name"><p>userinfo</p></td>
  13445. <td class="parameter_description">
  13446. <p>the userinfo component, or <code class="constant">NULL</code></p>
  13447. <p>Passed as <code class="code">userinfo</code></p>
  13448. </td>
  13449. </tr>
  13450. <tr>
  13451. <td class="parameter_name"><p>host</p></td>
  13452. <td class="parameter_description">
  13453. <p>the host component, or <code class="constant">NULL</code></p>
  13454. <p>Passed as <code class="code">host</code></p>
  13455. </td>
  13456. </tr>
  13457. <tr>
  13458. <td class="parameter_name"><p>port</p></td>
  13459. <td class="parameter_description">
  13460. <p>the port, or <code class="code">-1</code></p>
  13461. <p>Passed as <code class="code">port</code></p>
  13462. </td>
  13463. </tr>
  13464. <tr>
  13465. <td class="parameter_name"><p>path</p></td>
  13466. <td class="parameter_description">
  13467. <p>the path component</p>
  13468. <p>Passed as <code class="code">path</code></p>
  13469. </td>
  13470. </tr>
  13471. <tr>
  13472. <td class="parameter_name"><p>query</p></td>
  13473. <td class="parameter_description">
  13474. <p>the query component, or <code class="constant">NULL</code></p>
  13475. <p>Passed as <code class="code">query</code></p>
  13476. </td>
  13477. </tr>
  13478. <tr>
  13479. <td class="parameter_name"><p>fragment</p></td>
  13480. <td class="parameter_description">
  13481. <p>the fragment, or <code class="constant">NULL</code></p>
  13482. <p>Passed as <code class="code">fragment</code></p>
  13483. </td>
  13484. </tr>
  13485. </table></div>
  13486. </div>
  13487. </div>
  13488. <div class="refsect2">
  13489. <a name="id-1.1.90.2.453"></a><h3>uri-join-with-user</h3>
  13490. <div class="informalexample"><pre class="programlisting">(define-values
  13491. (%return)
  13492. (uri-join-with-user
  13493. flags
  13494. scheme
  13495. user
  13496. password
  13497. auth-params
  13498. host
  13499. port
  13500. path
  13501. query
  13502. fragment))
  13503. </pre></div>
  13504. <p>Joins the given components together according to <em class="parameter"><code>flags</code></em> to create
  13505. an absolute URI string. <em class="parameter"><code>path</code></em> may not be <code class="constant">NULL</code> (though it may be the empty
  13506. string).
  13507. </p>
  13508. <p>In contrast to <code class="function">g_uri_join()</code>, this allows specifying the components
  13509. of the ‘userinfo’ separately. It otherwise behaves the same.
  13510. </p>
  13511. <p><code class="constant">G_URI_FLAGS_HAS_PASSWORD</code> and <code class="constant">G_URI_FLAGS_HAS_AUTH_PARAMS</code> are ignored if set
  13512. in <em class="parameter"><code>flags</code></em>.</p>
  13513. <div class="refsect3">
  13514. <a name="id-1.1.90.2.453.6"></a><h4>Parameters</h4>
  13515. <div class="informaltable"><table>
  13516. <tr>
  13517. <td class="parameter_name"><p>flags</p></td>
  13518. <td class="parameter_description">
  13519. <p>flags describing how to build the URI string</p>
  13520. <p>Passed as <code class="code">flags</code></p>
  13521. </td>
  13522. </tr>
  13523. <tr>
  13524. <td class="parameter_name"><p>scheme</p></td>
  13525. <td class="parameter_description">
  13526. <p>the URI scheme, or <code class="constant">NULL</code></p>
  13527. <p>Passed as <code class="code">scheme</code></p>
  13528. </td>
  13529. </tr>
  13530. <tr>
  13531. <td class="parameter_name"><p>user</p></td>
  13532. <td class="parameter_description">
  13533. <p>the user component of the userinfo, or <code class="constant">NULL</code></p>
  13534. <p>Passed as <code class="code">user</code></p>
  13535. </td>
  13536. </tr>
  13537. <tr>
  13538. <td class="parameter_name"><p>password</p></td>
  13539. <td class="parameter_description">
  13540. <p>the password component of the userinfo, or
  13541. <code class="constant">NULL</code></p>
  13542. <p>Passed as <code class="code">password</code></p>
  13543. </td>
  13544. </tr>
  13545. <tr>
  13546. <td class="parameter_name"><p>auth_params</p></td>
  13547. <td class="parameter_description">
  13548. <p>the auth params of the userinfo, or
  13549. <code class="constant">NULL</code></p>
  13550. <p>Passed as <code class="code">auth-params</code></p>
  13551. </td>
  13552. </tr>
  13553. <tr>
  13554. <td class="parameter_name"><p>host</p></td>
  13555. <td class="parameter_description">
  13556. <p>the host component, or <code class="constant">NULL</code></p>
  13557. <p>Passed as <code class="code">host</code></p>
  13558. </td>
  13559. </tr>
  13560. <tr>
  13561. <td class="parameter_name"><p>port</p></td>
  13562. <td class="parameter_description">
  13563. <p>the port, or <code class="code">-1</code></p>
  13564. <p>Passed as <code class="code">port</code></p>
  13565. </td>
  13566. </tr>
  13567. <tr>
  13568. <td class="parameter_name"><p>path</p></td>
  13569. <td class="parameter_description">
  13570. <p>the path component</p>
  13571. <p>Passed as <code class="code">path</code></p>
  13572. </td>
  13573. </tr>
  13574. <tr>
  13575. <td class="parameter_name"><p>query</p></td>
  13576. <td class="parameter_description">
  13577. <p>the query component, or <code class="constant">NULL</code></p>
  13578. <p>Passed as <code class="code">query</code></p>
  13579. </td>
  13580. </tr>
  13581. <tr>
  13582. <td class="parameter_name"><p>fragment</p></td>
  13583. <td class="parameter_description">
  13584. <p>the fragment, or <code class="constant">NULL</code></p>
  13585. <p>Passed as <code class="code">fragment</code></p>
  13586. </td>
  13587. </tr>
  13588. </table></div>
  13589. </div>
  13590. </div>
  13591. <div class="refsect2">
  13592. <a name="id-1.1.90.2.454"></a><h3>uri-list-extract-uris</h3>
  13593. <div class="informalexample"><pre class="programlisting">(define-values (%return) (uri-list-extract-uris uri-list))
  13594. </pre></div>
  13595. <p>Splits an URI list conforming to the text/uri-list
  13596. mime type defined in RFC 2483 into individual URIs,
  13597. discarding any comments. The URIs are not validated.</p>
  13598. <div class="refsect3">
  13599. <a name="id-1.1.90.2.454.4"></a><h4>Parameters</h4>
  13600. <div class="informaltable"><table><tr>
  13601. <td class="parameter_name"><p>uri_list</p></td>
  13602. <td class="parameter_description">
  13603. <p>an URI list</p>
  13604. <p>Passed as <code class="code">uri-list</code></p>
  13605. </td>
  13606. </tr></table></div>
  13607. </div>
  13608. </div>
  13609. <div class="refsect2">
  13610. <a name="id-1.1.90.2.455"></a><h3>uri-parse</h3>
  13611. <div class="informalexample"><pre class="programlisting">(define-values (%return) (uri-parse uri-string flags))
  13612. </pre></div>
  13613. <p>Parses <em class="parameter"><code>uri_string</code></em> according to <em class="parameter"><code>flags</code></em>. If the result is not a
  13614. valid [absolute URI][relative-absolute-uris], it will be discarded, and an
  13615. error returned.</p>
  13616. <div class="refsect3">
  13617. <a name="id-1.1.90.2.455.4"></a><h4>Parameters</h4>
  13618. <div class="informaltable"><table>
  13619. <tr>
  13620. <td class="parameter_name"><p>uri_string</p></td>
  13621. <td class="parameter_description">
  13622. <p>a string representing an absolute URI</p>
  13623. <p>Passed as <code class="code">uri-string</code></p>
  13624. </td>
  13625. </tr>
  13626. <tr>
  13627. <td class="parameter_name"><p>flags</p></td>
  13628. <td class="parameter_description">
  13629. <p>flags describing how to parse <em class="parameter"><code>uri_string</code></em></p>
  13630. <p>Passed as <code class="code">flags</code></p>
  13631. </td>
  13632. </tr>
  13633. </table></div>
  13634. </div>
  13635. </div>
  13636. <div class="refsect2">
  13637. <a name="id-1.1.90.2.456"></a><h3>uri-parse-params</h3>
  13638. <div class="informalexample"><pre class="programlisting">(define-values (%return) (uri-parse-params params length separators flags))
  13639. </pre></div>
  13640. <p>Many URI schemes include one or more attribute/value pairs as part of the URI
  13641. value. This method can be used to parse them into a hash table. When an
  13642. attribute has multiple occurrences, the last value is the final returned
  13643. value. If you need to handle repeated attributes differently, use
  13644. <span class="type">GUriParamsIter</span>.
  13645. </p>
  13646. <p>The <em class="parameter"><code>params</code></em> string is assumed to still be <code class="code">%</code>-encoded, but the returned
  13647. values will be fully decoded. (Thus it is possible that the returned values
  13648. may contain <code class="code">=</code> or <em class="parameter"><code>separators</code></em>, if the value was encoded in the input.)
  13649. Invalid <code class="code">%</code>-encoding is treated as with the <code class="constant">G_URI_FLAGS_PARSE_RELAXED</code>
  13650. rules for <code class="function">g_uri_parse()</code>. (However, if <em class="parameter"><code>params</code></em> is the path or query string
  13651. from a <span class="type">GUri</span> that was parsed without <code class="constant">G_URI_FLAGS_PARSE_RELAXED</code> and
  13652. <code class="constant">G_URI_FLAGS_ENCODED</code>, then you already know that it does not contain any
  13653. invalid encoding.)
  13654. </p>
  13655. <p><code class="constant">G_URI_PARAMS_WWW_FORM</code> is handled as documented for <code class="function">g_uri_params_iter_init()</code>.
  13656. </p>
  13657. <p>If <code class="constant">G_URI_PARAMS_CASE_INSENSITIVE</code> is passed to <em class="parameter"><code>flags</code></em>, attributes will be
  13658. compared case-insensitively, so a params string <code class="code">attr=123&amp;Attr=456</code> will only
  13659. return a single attribute–value pair, <code class="code">Attr=456</code>. Case will be preserved in
  13660. the returned attributes.
  13661. </p>
  13662. <p>If <em class="parameter"><code>params</code></em> cannot be parsed (for example, it contains two <em class="parameter"><code>separators</code></em>
  13663. characters in a row), then <em class="parameter"><code>error</code></em> is set and <code class="constant">NULL</code> is returned.</p>
  13664. <div class="refsect3">
  13665. <a name="id-1.1.90.2.456.8"></a><h4>Parameters</h4>
  13666. <div class="informaltable"><table>
  13667. <tr>
  13668. <td class="parameter_name"><p>params</p></td>
  13669. <td class="parameter_description">
  13670. <p>a <code class="code">%</code>-encoded string containing <code class="code">attribute=value</code>
  13671. parameters</p>
  13672. <p>Passed as <code class="code">params</code></p>
  13673. </td>
  13674. </tr>
  13675. <tr>
  13676. <td class="parameter_name"><p>length</p></td>
  13677. <td class="parameter_description">
  13678. <p>the length of <em class="parameter"><code>params</code></em>, or <code class="code">-1</code> if it is nul-terminated</p>
  13679. <p>Passed as <code class="code">length</code></p>
  13680. </td>
  13681. </tr>
  13682. <tr>
  13683. <td class="parameter_name"><p>separators</p></td>
  13684. <td class="parameter_description">
  13685. <p>the separator byte character set between parameters. (usually
  13686. <code class="code">&amp;</code>, but sometimes <code class="code">;</code> or both <code class="code">&amp;;</code>). Note that this function works on
  13687. bytes not characters, so it can't be used to delimit UTF-8 strings for
  13688. anything but ASCII characters. You may pass an empty set, in which case
  13689. no splitting will occur.</p>
  13690. <p>Passed as <code class="code">separators</code></p>
  13691. </td>
  13692. </tr>
  13693. <tr>
  13694. <td class="parameter_name"><p>flags</p></td>
  13695. <td class="parameter_description">
  13696. <p>flags to modify the way the parameters are handled.</p>
  13697. <p>Passed as <code class="code">flags</code></p>
  13698. </td>
  13699. </tr>
  13700. </table></div>
  13701. </div>
  13702. </div>
  13703. <div class="refsect2">
  13704. <a name="id-1.1.90.2.457"></a><h3>uri-parse-scheme</h3>
  13705. <div class="informalexample"><pre class="programlisting">(define-values (%return) (uri-parse-scheme uri))
  13706. </pre></div>
  13707. <p>Gets the scheme portion of a URI string.
  13708. [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3) decodes the scheme
  13709. as:
  13710. </p>
  13711. <div class="informalexample"><pre class="programlisting">
  13712. URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
  13713. </pre></div>
  13714. <p>Common schemes include <code class="code">file</code>, <code class="code">https</code>, <code class="code">svn+ssh</code>, etc.</p>
  13715. <div class="refsect3">
  13716. <a name="id-1.1.90.2.457.5"></a><h4>Parameters</h4>
  13717. <div class="informaltable"><table><tr>
  13718. <td class="parameter_name"><p>uri</p></td>
  13719. <td class="parameter_description">
  13720. <p>a valid URI.</p>
  13721. <p>Passed as <code class="code">uri</code></p>
  13722. </td>
  13723. </tr></table></div>
  13724. </div>
  13725. </div>
  13726. <div class="refsect2">
  13727. <a name="id-1.1.90.2.458"></a><h3>uri-peek-scheme</h3>
  13728. <div class="informalexample"><pre class="programlisting">(define-values (%return) (uri-peek-scheme uri))
  13729. </pre></div>
  13730. <p>Gets the scheme portion of a URI string.
  13731. [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3) decodes the scheme
  13732. as:
  13733. </p>
  13734. <div class="informalexample"><pre class="programlisting">
  13735. URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
  13736. </pre></div>
  13737. <p>Common schemes include <code class="code">file</code>, <code class="code">https</code>, <code class="code">svn+ssh</code>, etc.
  13738. </p>
  13739. <p>Unlike <code class="function">g_uri_parse_scheme()</code>, the returned scheme is normalized to
  13740. all-lowercase and does not need to be freed.</p>
  13741. <div class="refsect3">
  13742. <a name="id-1.1.90.2.458.6"></a><h4>Parameters</h4>
  13743. <div class="informaltable"><table><tr>
  13744. <td class="parameter_name"><p>uri</p></td>
  13745. <td class="parameter_description">
  13746. <p>a valid URI.</p>
  13747. <p>Passed as <code class="code">uri</code></p>
  13748. </td>
  13749. </tr></table></div>
  13750. </div>
  13751. </div>
  13752. <div class="refsect2">
  13753. <a name="id-1.1.90.2.459"></a><h3>uri-resolve-relative</h3>
  13754. <div class="informalexample"><pre class="programlisting">(define-values (%return) (uri-resolve-relative base-uri-string uri-ref flags))
  13755. </pre></div>
  13756. <p>Parses <em class="parameter"><code>uri_ref</code></em> according to <em class="parameter"><code>flags</code></em> and, if it is a
  13757. [relative URI][relative-absolute-uris], resolves it relative to
  13758. <em class="parameter"><code>base_uri_string</code></em>. If the result is not a valid absolute URI, it will be
  13759. discarded, and an error returned.
  13760. </p>
  13761. <p>(If <em class="parameter"><code>base_uri_string</code></em> is <code class="constant">NULL</code>, this just returns <em class="parameter"><code>uri_ref</code></em>, or
  13762. <code class="constant">NULL</code> if <em class="parameter"><code>uri_ref</code></em> is invalid or not absolute.)</p>
  13763. <div class="refsect3">
  13764. <a name="id-1.1.90.2.459.5"></a><h4>Parameters</h4>
  13765. <div class="informaltable"><table>
  13766. <tr>
  13767. <td class="parameter_name"><p>base_uri_string</p></td>
  13768. <td class="parameter_description">
  13769. <p>a string representing a base URI</p>
  13770. <p>Passed as <code class="code">base-uri-string</code></p>
  13771. </td>
  13772. </tr>
  13773. <tr>
  13774. <td class="parameter_name"><p>uri_ref</p></td>
  13775. <td class="parameter_description">
  13776. <p>a string representing a relative or absolute URI</p>
  13777. <p>Passed as <code class="code">uri-ref</code></p>
  13778. </td>
  13779. </tr>
  13780. <tr>
  13781. <td class="parameter_name"><p>flags</p></td>
  13782. <td class="parameter_description">
  13783. <p>flags describing how to parse <em class="parameter"><code>uri_ref</code></em></p>
  13784. <p>Passed as <code class="code">flags</code></p>
  13785. </td>
  13786. </tr>
  13787. </table></div>
  13788. </div>
  13789. </div>
  13790. <div class="refsect2">
  13791. <a name="id-1.1.90.2.460"></a><h3>uri-split</h3>
  13792. <div class="informalexample"><pre class="programlisting">(define-values
  13793. (%return scheme userinfo host port path query fragment)
  13794. (uri-split uri-ref flags))
  13795. </pre></div>
  13796. <p>Parses <em class="parameter"><code>uri_ref</code></em> (which can be an
  13797. [absolute or relative URI][relative-absolute-uris]) according to <em class="parameter"><code>flags</code></em>, and
  13798. returns the pieces. Any component that doesn't appear in <em class="parameter"><code>uri_ref</code></em> will be
  13799. returned as <code class="constant">NULL</code> (but note that all URIs always have a path component,
  13800. though it may be the empty string).
  13801. </p>
  13802. <p>If <em class="parameter"><code>flags</code></em> contains <code class="constant">G_URI_FLAGS_ENCODED</code>, then <code class="code">%</code>-encoded characters in
  13803. <em class="parameter"><code>uri_ref</code></em> will remain encoded in the output strings. (If not,
  13804. then all such characters will be decoded.) Note that decoding will
  13805. only work if the URI components are ASCII or UTF-8, so you will
  13806. need to use <code class="constant">G_URI_FLAGS_ENCODED</code> if they are not.
  13807. </p>
  13808. <p>Note that the <code class="constant">G_URI_FLAGS_HAS_PASSWORD</code> and
  13809. <code class="constant">G_URI_FLAGS_HAS_AUTH_PARAMS</code> <em class="parameter"><code>flags</code></em> are ignored by <code class="function">g_uri_split()</code>,
  13810. since it always returns only the full userinfo; use
  13811. <code class="function">g_uri_split_with_user()</code> if you want it split up.</p>
  13812. <div class="refsect3">
  13813. <a name="id-1.1.90.2.460.6"></a><h4>Parameters</h4>
  13814. <div class="informaltable"><table>
  13815. <tr>
  13816. <td class="parameter_name"><p>uri_ref</p></td>
  13817. <td class="parameter_description">
  13818. <p>a string containing a relative or absolute URI</p>
  13819. <p>Passed as <code class="code">uri-ref</code></p>
  13820. </td>
  13821. </tr>
  13822. <tr>
  13823. <td class="parameter_name"><p>flags</p></td>
  13824. <td class="parameter_description">
  13825. <p>flags for parsing <em class="parameter"><code>uri_ref</code></em></p>
  13826. <p>Passed as <code class="code">flags</code></p>
  13827. </td>
  13828. </tr>
  13829. <tr>
  13830. <td class="parameter_name"><p>scheme</p></td>
  13831. <td class="parameter_description">
  13832. <p>on return, contains
  13833. the scheme (converted to lowercase), or <code class="constant">NULL</code></p>
  13834. <p>Passed as <code class="code">scheme</code></p>
  13835. </td>
  13836. </tr>
  13837. <tr>
  13838. <td class="parameter_name"><p>userinfo</p></td>
  13839. <td class="parameter_description">
  13840. <p>on return, contains
  13841. the userinfo, or <code class="constant">NULL</code></p>
  13842. <p>Passed as <code class="code">userinfo</code></p>
  13843. </td>
  13844. </tr>
  13845. <tr>
  13846. <td class="parameter_name"><p>host</p></td>
  13847. <td class="parameter_description">
  13848. <p>on return, contains the
  13849. host, or <code class="constant">NULL</code></p>
  13850. <p>Passed as <code class="code">host</code></p>
  13851. </td>
  13852. </tr>
  13853. <tr>
  13854. <td class="parameter_name"><p>port</p></td>
  13855. <td class="parameter_description">
  13856. <p>on return, contains the
  13857. port, or <code class="code">-1</code></p>
  13858. <p>Passed as <code class="code">port</code></p>
  13859. </td>
  13860. </tr>
  13861. <tr>
  13862. <td class="parameter_name"><p>path</p></td>
  13863. <td class="parameter_description">
  13864. <p>on return, contains the
  13865. path</p>
  13866. <p>Passed as <code class="code">path</code></p>
  13867. </td>
  13868. </tr>
  13869. <tr>
  13870. <td class="parameter_name"><p>query</p></td>
  13871. <td class="parameter_description">
  13872. <p>on return, contains the
  13873. query, or <code class="constant">NULL</code></p>
  13874. <p>Passed as <code class="code">query</code></p>
  13875. </td>
  13876. </tr>
  13877. <tr>
  13878. <td class="parameter_name"><p>fragment</p></td>
  13879. <td class="parameter_description">
  13880. <p>on return, contains
  13881. the fragment, or <code class="constant">NULL</code></p>
  13882. <p>Passed as <code class="code">fragment</code></p>
  13883. </td>
  13884. </tr>
  13885. </table></div>
  13886. </div>
  13887. </div>
  13888. <div class="refsect2">
  13889. <a name="id-1.1.90.2.461"></a><h3>uri-split-network</h3>
  13890. <div class="informalexample"><pre class="programlisting">(define-values
  13891. (%return scheme host port)
  13892. (uri-split-network uri-string flags))
  13893. </pre></div>
  13894. <p>Parses <em class="parameter"><code>uri_string</code></em> (which must be an [absolute URI][relative-absolute-uris])
  13895. according to <em class="parameter"><code>flags</code></em>, and returns the pieces relevant to connecting to a host.
  13896. See the documentation for <code class="function">g_uri_split()</code> for more details; this is
  13897. mostly a wrapper around that function with simpler arguments.
  13898. However, it will return an error if <em class="parameter"><code>uri_string</code></em> is a relative URI,
  13899. or does not contain a hostname component.</p>
  13900. <div class="refsect3">
  13901. <a name="id-1.1.90.2.461.4"></a><h4>Parameters</h4>
  13902. <div class="informaltable"><table>
  13903. <tr>
  13904. <td class="parameter_name"><p>uri_string</p></td>
  13905. <td class="parameter_description">
  13906. <p>a string containing an absolute URI</p>
  13907. <p>Passed as <code class="code">uri-string</code></p>
  13908. </td>
  13909. </tr>
  13910. <tr>
  13911. <td class="parameter_name"><p>flags</p></td>
  13912. <td class="parameter_description">
  13913. <p>flags for parsing <em class="parameter"><code>uri_string</code></em></p>
  13914. <p>Passed as <code class="code">flags</code></p>
  13915. </td>
  13916. </tr>
  13917. <tr>
  13918. <td class="parameter_name"><p>scheme</p></td>
  13919. <td class="parameter_description">
  13920. <p>on return, contains
  13921. the scheme (converted to lowercase), or <code class="constant">NULL</code></p>
  13922. <p>Passed as <code class="code">scheme</code></p>
  13923. </td>
  13924. </tr>
  13925. <tr>
  13926. <td class="parameter_name"><p>host</p></td>
  13927. <td class="parameter_description">
  13928. <p>on return, contains the
  13929. host, or <code class="constant">NULL</code></p>
  13930. <p>Passed as <code class="code">host</code></p>
  13931. </td>
  13932. </tr>
  13933. <tr>
  13934. <td class="parameter_name"><p>port</p></td>
  13935. <td class="parameter_description">
  13936. <p>on return, contains the
  13937. port, or <code class="code">-1</code></p>
  13938. <p>Passed as <code class="code">port</code></p>
  13939. </td>
  13940. </tr>
  13941. </table></div>
  13942. </div>
  13943. </div>
  13944. <div class="refsect2">
  13945. <a name="id-1.1.90.2.462"></a><h3>uri-split-with-user</h3>
  13946. <div class="informalexample"><pre class="programlisting">(define-values
  13947. (%return scheme user password auth-params host port path query fragment)
  13948. (uri-split-with-user uri-ref flags))
  13949. </pre></div>
  13950. <p>Parses <em class="parameter"><code>uri_ref</code></em> (which can be an
  13951. [absolute or relative URI][relative-absolute-uris]) according to <em class="parameter"><code>flags</code></em>, and
  13952. returns the pieces. Any component that doesn't appear in <em class="parameter"><code>uri_ref</code></em> will be
  13953. returned as <code class="constant">NULL</code> (but note that all URIs always have a path component,
  13954. though it may be the empty string).
  13955. </p>
  13956. <p>See <code class="function">g_uri_split()</code>, and the definition of <span class="type">GUriFlags</span>, for more
  13957. information on the effect of <em class="parameter"><code>flags</code></em>. Note that <em class="parameter"><code>password</code></em> will only
  13958. be parsed out if <em class="parameter"><code>flags</code></em> contains <code class="constant">G_URI_FLAGS_HAS_PASSWORD</code>, and
  13959. <em class="parameter"><code>auth_params</code></em> will only be parsed out if <em class="parameter"><code>flags</code></em> contains
  13960. <code class="constant">G_URI_FLAGS_HAS_AUTH_PARAMS</code>.</p>
  13961. <div class="refsect3">
  13962. <a name="id-1.1.90.2.462.5"></a><h4>Parameters</h4>
  13963. <div class="informaltable"><table>
  13964. <tr>
  13965. <td class="parameter_name"><p>uri_ref</p></td>
  13966. <td class="parameter_description">
  13967. <p>a string containing a relative or absolute URI</p>
  13968. <p>Passed as <code class="code">uri-ref</code></p>
  13969. </td>
  13970. </tr>
  13971. <tr>
  13972. <td class="parameter_name"><p>flags</p></td>
  13973. <td class="parameter_description">
  13974. <p>flags for parsing <em class="parameter"><code>uri_ref</code></em></p>
  13975. <p>Passed as <code class="code">flags</code></p>
  13976. </td>
  13977. </tr>
  13978. <tr>
  13979. <td class="parameter_name"><p>scheme</p></td>
  13980. <td class="parameter_description">
  13981. <p>on return, contains
  13982. the scheme (converted to lowercase), or <code class="constant">NULL</code></p>
  13983. <p>Passed as <code class="code">scheme</code></p>
  13984. </td>
  13985. </tr>
  13986. <tr>
  13987. <td class="parameter_name"><p>user</p></td>
  13988. <td class="parameter_description">
  13989. <p>on return, contains
  13990. the user, or <code class="constant">NULL</code></p>
  13991. <p>Passed as <code class="code">user</code></p>
  13992. </td>
  13993. </tr>
  13994. <tr>
  13995. <td class="parameter_name"><p>password</p></td>
  13996. <td class="parameter_description">
  13997. <p>on return, contains
  13998. the password, or <code class="constant">NULL</code></p>
  13999. <p>Passed as <code class="code">password</code></p>
  14000. </td>
  14001. </tr>
  14002. <tr>
  14003. <td class="parameter_name"><p>auth_params</p></td>
  14004. <td class="parameter_description">
  14005. <p>on return, contains
  14006. the auth_params, or <code class="constant">NULL</code></p>
  14007. <p>Passed as <code class="code">auth-params</code></p>
  14008. </td>
  14009. </tr>
  14010. <tr>
  14011. <td class="parameter_name"><p>host</p></td>
  14012. <td class="parameter_description">
  14013. <p>on return, contains the
  14014. host, or <code class="constant">NULL</code></p>
  14015. <p>Passed as <code class="code">host</code></p>
  14016. </td>
  14017. </tr>
  14018. <tr>
  14019. <td class="parameter_name"><p>port</p></td>
  14020. <td class="parameter_description">
  14021. <p>on return, contains the
  14022. port, or <code class="code">-1</code></p>
  14023. <p>Passed as <code class="code">port</code></p>
  14024. </td>
  14025. </tr>
  14026. <tr>
  14027. <td class="parameter_name"><p>path</p></td>
  14028. <td class="parameter_description">
  14029. <p>on return, contains the
  14030. path</p>
  14031. <p>Passed as <code class="code">path</code></p>
  14032. </td>
  14033. </tr>
  14034. <tr>
  14035. <td class="parameter_name"><p>query</p></td>
  14036. <td class="parameter_description">
  14037. <p>on return, contains the
  14038. query, or <code class="constant">NULL</code></p>
  14039. <p>Passed as <code class="code">query</code></p>
  14040. </td>
  14041. </tr>
  14042. <tr>
  14043. <td class="parameter_name"><p>fragment</p></td>
  14044. <td class="parameter_description">
  14045. <p>on return, contains
  14046. the fragment, or <code class="constant">NULL</code></p>
  14047. <p>Passed as <code class="code">fragment</code></p>
  14048. </td>
  14049. </tr>
  14050. </table></div>
  14051. </div>
  14052. </div>
  14053. <div class="refsect2">
  14054. <a name="id-1.1.90.2.463"></a><h3>uri-unescape-bytes</h3>
  14055. <div class="informalexample"><pre class="programlisting">(define-values
  14056. (%return)
  14057. (uri-unescape-bytes escaped-string length illegal-characters))
  14058. </pre></div>
  14059. <p>Unescapes a segment of an escaped string as binary data.
  14060. </p>
  14061. <p>Note that in contrast to <code class="function">g_uri_unescape_string()</code>, this does allow
  14062. nul bytes to appear in the output.
  14063. </p>
  14064. <p>If any of the characters in <em class="parameter"><code>illegal_characters</code></em> appears as an escaped
  14065. character in <em class="parameter"><code>escaped_string</code></em>, then that is an error and <code class="constant">NULL</code> will be
  14066. returned. This is useful if you want to avoid for instance having a slash
  14067. being expanded in an escaped path element, which might confuse pathname
  14068. handling.</p>
  14069. <div class="refsect3">
  14070. <a name="id-1.1.90.2.463.6"></a><h4>Parameters</h4>
  14071. <div class="informaltable"><table>
  14072. <tr>
  14073. <td class="parameter_name"><p>escaped_string</p></td>
  14074. <td class="parameter_description">
  14075. <p>A URI-escaped string</p>
  14076. <p>Passed as <code class="code">escaped-string</code></p>
  14077. </td>
  14078. </tr>
  14079. <tr>
  14080. <td class="parameter_name"><p>length</p></td>
  14081. <td class="parameter_description">
  14082. <p>the length (in bytes) of <em class="parameter"><code>escaped_string</code></em> to escape, or <code class="code">-1</code> if it
  14083. is nul-terminated.</p>
  14084. <p>Passed as <code class="code">length</code></p>
  14085. </td>
  14086. </tr>
  14087. <tr>
  14088. <td class="parameter_name"><p>illegal_characters</p></td>
  14089. <td class="parameter_description">
  14090. <p>a string of illegal characters
  14091. not to be allowed, or <code class="constant">NULL</code>.</p>
  14092. <p>Passed as <code class="code">illegal-characters</code></p>
  14093. </td>
  14094. </tr>
  14095. </table></div>
  14096. </div>
  14097. </div>
  14098. <div class="refsect2">
  14099. <a name="id-1.1.90.2.464"></a><h3>uri-unescape-segment</h3>
  14100. <div class="informalexample"><pre class="programlisting">(define-values
  14101. (%return)
  14102. (uri-unescape-segment escaped-string escaped-string-end illegal-characters))
  14103. </pre></div>
  14104. <p>Unescapes a segment of an escaped string.
  14105. </p>
  14106. <p>If any of the characters in <em class="parameter"><code>illegal_characters</code></em> or the NUL
  14107. character appears as an escaped character in <em class="parameter"><code>escaped_string</code></em>, then
  14108. that is an error and <code class="constant">NULL</code> will be returned. This is useful if you
  14109. want to avoid for instance having a slash being expanded in an
  14110. escaped path element, which might confuse pathname handling.
  14111. </p>
  14112. <p>Note: <code class="code">NUL</code> byte is not accepted in the output, in contrast to
  14113. <code class="function">g_uri_unescape_bytes()</code>.</p>
  14114. <div class="refsect3">
  14115. <a name="id-1.1.90.2.464.6"></a><h4>Parameters</h4>
  14116. <div class="informaltable"><table>
  14117. <tr>
  14118. <td class="parameter_name"><p>escaped_string</p></td>
  14119. <td class="parameter_description">
  14120. <p>A string, may be <code class="constant">NULL</code></p>
  14121. <p>Passed as <code class="code">escaped-string</code></p>
  14122. </td>
  14123. </tr>
  14124. <tr>
  14125. <td class="parameter_name"><p>escaped_string_end</p></td>
  14126. <td class="parameter_description">
  14127. <p>Pointer to end of <em class="parameter"><code>escaped_string</code></em>,
  14128. may be <code class="constant">NULL</code></p>
  14129. <p>Passed as <code class="code">escaped-string-end</code></p>
  14130. </td>
  14131. </tr>
  14132. <tr>
  14133. <td class="parameter_name"><p>illegal_characters</p></td>
  14134. <td class="parameter_description">
  14135. <p>An optional string of illegal
  14136. characters not to be allowed, may be <code class="constant">NULL</code></p>
  14137. <p>Passed as <code class="code">illegal-characters</code></p>
  14138. </td>
  14139. </tr>
  14140. </table></div>
  14141. </div>
  14142. </div>
  14143. <div class="refsect2">
  14144. <a name="id-1.1.90.2.465"></a><h3>uri-unescape-string</h3>
  14145. <div class="informalexample"><pre class="programlisting">(define-values
  14146. (%return)
  14147. (uri-unescape-string escaped-string illegal-characters))
  14148. </pre></div>
  14149. <p>Unescapes a whole escaped string.
  14150. </p>
  14151. <p>If any of the characters in <em class="parameter"><code>illegal_characters</code></em> or the NUL
  14152. character appears as an escaped character in <em class="parameter"><code>escaped_string</code></em>, then
  14153. that is an error and <code class="constant">NULL</code> will be returned. This is useful if you
  14154. want to avoid for instance having a slash being expanded in an
  14155. escaped path element, which might confuse pathname handling.</p>
  14156. <div class="refsect3">
  14157. <a name="id-1.1.90.2.465.5"></a><h4>Parameters</h4>
  14158. <div class="informaltable"><table>
  14159. <tr>
  14160. <td class="parameter_name"><p>escaped_string</p></td>
  14161. <td class="parameter_description">
  14162. <p>an escaped string to be unescaped.</p>
  14163. <p>Passed as <code class="code">escaped-string</code></p>
  14164. </td>
  14165. </tr>
  14166. <tr>
  14167. <td class="parameter_name"><p>illegal_characters</p></td>
  14168. <td class="parameter_description">
  14169. <p>a string of illegal characters
  14170. not to be allowed, or <code class="constant">NULL</code>.</p>
  14171. <p>Passed as <code class="code">illegal-characters</code></p>
  14172. </td>
  14173. </tr>
  14174. </table></div>
  14175. </div>
  14176. </div>
  14177. <div class="refsect2">
  14178. <a name="id-1.1.90.2.466"></a><h3>usleep</h3>
  14179. <div class="informalexample"><pre class="programlisting">(define-values () (usleep microseconds))
  14180. </pre></div>
  14181. <p>Pauses the current thread for the given number of microseconds.
  14182. </p>
  14183. <p>There are 1 million microseconds per second (represented by the
  14184. <span class="type">G_USEC_PER_SEC</span> macro). <code class="function">g_usleep()</code> may have limited precision,
  14185. depending on hardware and operating system; don't rely on the exact
  14186. length of the sleep.</p>
  14187. <div class="refsect3">
  14188. <a name="id-1.1.90.2.466.5"></a><h4>Parameters</h4>
  14189. <div class="informaltable"><table><tr>
  14190. <td class="parameter_name"><p>microseconds</p></td>
  14191. <td class="parameter_description">
  14192. <p>number of microseconds to pause</p>
  14193. <p>Passed as <code class="code">microseconds</code></p>
  14194. </td>
  14195. </tr></table></div>
  14196. </div>
  14197. </div>
  14198. <div class="refsect2">
  14199. <a name="id-1.1.90.2.467"></a><h3>utf16-to-ucs4</h3>
  14200. <div class="informalexample"><pre class="programlisting">(define-values
  14201. (%return items-read items-written)
  14202. (utf16-to-ucs4 str len items-read items-written))
  14203. </pre></div>
  14204. <p>Convert a string from UTF-16 to UCS-4. The result will be
  14205. nul-terminated.</p>
  14206. <div class="refsect3">
  14207. <a name="id-1.1.90.2.467.4"></a><h4>Parameters</h4>
  14208. <div class="informaltable"><table>
  14209. <tr>
  14210. <td class="parameter_name"><p>str</p></td>
  14211. <td class="parameter_description">
  14212. <p>a UTF-16 encoded string</p>
  14213. <p>Passed as <code class="code">str</code></p>
  14214. </td>
  14215. </tr>
  14216. <tr>
  14217. <td class="parameter_name"><p>len</p></td>
  14218. <td class="parameter_description">
  14219. <p>the maximum length (number of <span class="type">gunichar2</span>) of <em class="parameter"><code>str</code></em> to use.
  14220. If <em class="parameter"><code>len</code></em> &lt; 0, then the string is nul-terminated.</p>
  14221. <p>Passed as <code class="code">len</code></p>
  14222. </td>
  14223. </tr>
  14224. <tr>
  14225. <td class="parameter_name"><p>items_read</p></td>
  14226. <td class="parameter_description">
  14227. <p>location to store number of
  14228. words read, or <code class="constant">NULL</code>. If <code class="constant">NULL</code>, then <code class="constant">G_CONVERT_ERROR_PARTIAL_INPUT</code> will
  14229. be returned in case <em class="parameter"><code>str</code></em> contains a trailing partial character. If
  14230. an error occurs then the index of the invalid input is stored here.</p>
  14231. <p>Passed as <code class="code">items-read</code></p>
  14232. </td>
  14233. </tr>
  14234. <tr>
  14235. <td class="parameter_name"><p>items_written</p></td>
  14236. <td class="parameter_description">
  14237. <p>location to store number
  14238. of characters written, or <code class="constant">NULL</code>. The value stored here does not include
  14239. the trailing 0 character.</p>
  14240. <p>Passed as <code class="code">items-written</code></p>
  14241. </td>
  14242. </tr>
  14243. </table></div>
  14244. </div>
  14245. </div>
  14246. <div class="refsect2">
  14247. <a name="id-1.1.90.2.468"></a><h3>utf16-to-utf8</h3>
  14248. <div class="informalexample"><pre class="programlisting">(define-values
  14249. (%return items-read items-written)
  14250. (utf16-to-utf8 str len items-read items-written))
  14251. </pre></div>
  14252. <p>Convert a string from UTF-16 to UTF-8. The result will be
  14253. terminated with a 0 byte.
  14254. </p>
  14255. <p>Note that the input is expected to be already in native endianness,
  14256. an initial byte-order-mark character is not handled specially.
  14257. <code class="function">g_convert()</code> can be used to convert a byte buffer of UTF-16 data of
  14258. ambiguous endianness.
  14259. </p>
  14260. <p>Further note that this function does not validate the result
  14261. string; it may e.g. include embedded NUL characters. The only
  14262. validation done by this function is to ensure that the input can
  14263. be correctly interpreted as UTF-16, i.e. it doesn't contain
  14264. unpaired surrogates or partial character sequences.</p>
  14265. <div class="refsect3">
  14266. <a name="id-1.1.90.2.468.6"></a><h4>Parameters</h4>
  14267. <div class="informaltable"><table>
  14268. <tr>
  14269. <td class="parameter_name"><p>str</p></td>
  14270. <td class="parameter_description">
  14271. <p>a UTF-16 encoded string</p>
  14272. <p>Passed as <code class="code">str</code></p>
  14273. </td>
  14274. </tr>
  14275. <tr>
  14276. <td class="parameter_name"><p>len</p></td>
  14277. <td class="parameter_description">
  14278. <p>the maximum length (number of <span class="type">gunichar2</span>) of <em class="parameter"><code>str</code></em> to use.
  14279. If <em class="parameter"><code>len</code></em> &lt; 0, then the string is nul-terminated.</p>
  14280. <p>Passed as <code class="code">len</code></p>
  14281. </td>
  14282. </tr>
  14283. <tr>
  14284. <td class="parameter_name"><p>items_read</p></td>
  14285. <td class="parameter_description">
  14286. <p>location to store number of
  14287. words read, or <code class="constant">NULL</code>. If <code class="constant">NULL</code>, then <code class="constant">G_CONVERT_ERROR_PARTIAL_INPUT</code> will
  14288. be returned in case <em class="parameter"><code>str</code></em> contains a trailing partial character. If
  14289. an error occurs then the index of the invalid input is stored here.</p>
  14290. <p>Passed as <code class="code">items-read</code></p>
  14291. </td>
  14292. </tr>
  14293. <tr>
  14294. <td class="parameter_name"><p>items_written</p></td>
  14295. <td class="parameter_description">
  14296. <p>location to store number
  14297. of bytes written, or <code class="constant">NULL</code>. The value stored here does not include the
  14298. trailing 0 byte.</p>
  14299. <p>Passed as <code class="code">items-written</code></p>
  14300. </td>
  14301. </tr>
  14302. </table></div>
  14303. </div>
  14304. </div>
  14305. <div class="refsect2">
  14306. <a name="id-1.1.90.2.469"></a><h3>utf8-casefold</h3>
  14307. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-casefold str len))
  14308. </pre></div>
  14309. <p>Converts a string into a form that is independent of case. The
  14310. result will not correspond to any particular case, but can be
  14311. compared for equality or ordered with the results of calling
  14312. <code class="function">g_utf8_casefold()</code> on other strings.
  14313. </p>
  14314. <p>Note that calling <code class="function">g_utf8_casefold()</code> followed by <code class="function">g_utf8_collate()</code> is
  14315. only an approximation to the correct linguistic case insensitive
  14316. ordering, though it is a fairly good one. Getting this exactly
  14317. right would require a more sophisticated collation function that
  14318. takes case sensitivity into account. GLib does not currently
  14319. provide such a function.</p>
  14320. <div class="refsect3">
  14321. <a name="id-1.1.90.2.469.5"></a><h4>Parameters</h4>
  14322. <div class="informaltable"><table>
  14323. <tr>
  14324. <td class="parameter_name"><p>str</p></td>
  14325. <td class="parameter_description">
  14326. <p>a UTF-8 encoded string</p>
  14327. <p>Passed as <code class="code">str</code></p>
  14328. </td>
  14329. </tr>
  14330. <tr>
  14331. <td class="parameter_name"><p>len</p></td>
  14332. <td class="parameter_description">
  14333. <p>length of <em class="parameter"><code>str</code></em>, in bytes, or -1 if <em class="parameter"><code>str</code></em> is nul-terminated.</p>
  14334. <p>Passed as <code class="code">len</code></p>
  14335. </td>
  14336. </tr>
  14337. </table></div>
  14338. </div>
  14339. </div>
  14340. <div class="refsect2">
  14341. <a name="id-1.1.90.2.470"></a><h3>utf8-collate</h3>
  14342. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-collate str1 str2))
  14343. </pre></div>
  14344. <p>Compares two strings for ordering using the linguistically
  14345. correct rules for the [current locale][setlocale].
  14346. When sorting a large number of strings, it will be significantly
  14347. faster to obtain collation keys with <code class="function">g_utf8_collate_key()</code> and
  14348. compare the keys with <code class="function">strcmp()</code> when sorting instead of sorting
  14349. the original strings.</p>
  14350. <div class="refsect3">
  14351. <a name="id-1.1.90.2.470.4"></a><h4>Parameters</h4>
  14352. <div class="informaltable"><table>
  14353. <tr>
  14354. <td class="parameter_name"><p>str1</p></td>
  14355. <td class="parameter_description">
  14356. <p>a UTF-8 encoded string</p>
  14357. <p>Passed as <code class="code">str1</code></p>
  14358. </td>
  14359. </tr>
  14360. <tr>
  14361. <td class="parameter_name"><p>str2</p></td>
  14362. <td class="parameter_description">
  14363. <p>a UTF-8 encoded string</p>
  14364. <p>Passed as <code class="code">str2</code></p>
  14365. </td>
  14366. </tr>
  14367. </table></div>
  14368. </div>
  14369. </div>
  14370. <div class="refsect2">
  14371. <a name="id-1.1.90.2.471"></a><h3>utf8-collate-key</h3>
  14372. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-collate-key str len))
  14373. </pre></div>
  14374. <p>Converts a string into a collation key that can be compared
  14375. with other collation keys produced by the same function using
  14376. <code class="function">strcmp()</code>.
  14377. </p>
  14378. <p>The results of comparing the collation keys of two strings
  14379. with <code class="function">strcmp()</code> will always be the same as comparing the two
  14380. original keys with <code class="function">g_utf8_collate()</code>.
  14381. </p>
  14382. <p>Note that this function depends on the [current locale][setlocale].</p>
  14383. <div class="refsect3">
  14384. <a name="id-1.1.90.2.471.6"></a><h4>Parameters</h4>
  14385. <div class="informaltable"><table>
  14386. <tr>
  14387. <td class="parameter_name"><p>str</p></td>
  14388. <td class="parameter_description">
  14389. <p>a UTF-8 encoded string.</p>
  14390. <p>Passed as <code class="code">str</code></p>
  14391. </td>
  14392. </tr>
  14393. <tr>
  14394. <td class="parameter_name"><p>len</p></td>
  14395. <td class="parameter_description">
  14396. <p>length of <em class="parameter"><code>str</code></em>, in bytes, or -1 if <em class="parameter"><code>str</code></em> is nul-terminated.</p>
  14397. <p>Passed as <code class="code">len</code></p>
  14398. </td>
  14399. </tr>
  14400. </table></div>
  14401. </div>
  14402. </div>
  14403. <div class="refsect2">
  14404. <a name="id-1.1.90.2.472"></a><h3>utf8-collate-key-for-filename</h3>
  14405. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-collate-key-for-filename str len))
  14406. </pre></div>
  14407. <p>Converts a string into a collation key that can be compared
  14408. with other collation keys produced by the same function using <code class="function">strcmp()</code>.
  14409. </p>
  14410. <p>In order to sort filenames correctly, this function treats the dot '.'
  14411. as a special case. Most dictionary orderings seem to consider it
  14412. insignificant, thus producing the ordering "event.c" "eventgenerator.c"
  14413. "event.h" instead of "event.c" "event.h" "eventgenerator.c". Also, we
  14414. would like to treat numbers intelligently so that "file1" "file10" "file5"
  14415. is sorted as "file1" "file5" "file10".
  14416. </p>
  14417. <p>Note that this function depends on the [current locale][setlocale].</p>
  14418. <div class="refsect3">
  14419. <a name="id-1.1.90.2.472.6"></a><h4>Parameters</h4>
  14420. <div class="informaltable"><table>
  14421. <tr>
  14422. <td class="parameter_name"><p>str</p></td>
  14423. <td class="parameter_description">
  14424. <p>a UTF-8 encoded string.</p>
  14425. <p>Passed as <code class="code">str</code></p>
  14426. </td>
  14427. </tr>
  14428. <tr>
  14429. <td class="parameter_name"><p>len</p></td>
  14430. <td class="parameter_description">
  14431. <p>length of <em class="parameter"><code>str</code></em>, in bytes, or -1 if <em class="parameter"><code>str</code></em> is nul-terminated.</p>
  14432. <p>Passed as <code class="code">len</code></p>
  14433. </td>
  14434. </tr>
  14435. </table></div>
  14436. </div>
  14437. </div>
  14438. <div class="refsect2">
  14439. <a name="id-1.1.90.2.473"></a><h3>utf8-find-next-char</h3>
  14440. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-find-next-char p end))
  14441. </pre></div>
  14442. <p>Finds the start of the next UTF-8 character in the string after <em class="parameter"><code>p</code></em>.
  14443. </p>
  14444. <p><em class="parameter"><code>p</code></em> does not have to be at the beginning of a UTF-8 character. No check
  14445. is made to see if the character found is actually valid other than
  14446. it starts with an appropriate byte.
  14447. </p>
  14448. <p>If <em class="parameter"><code>end</code></em> is <code class="constant">NULL</code>, the return value will never be <code class="constant">NULL</code>: if the end of the
  14449. string is reached, a pointer to the terminating nul byte is returned. If
  14450. <em class="parameter"><code>end</code></em> is non-<code class="constant">NULL</code>, the return value will be <code class="constant">NULL</code> if the end of the string
  14451. is reached.</p>
  14452. <div class="refsect3">
  14453. <a name="id-1.1.90.2.473.6"></a><h4>Parameters</h4>
  14454. <div class="informaltable"><table>
  14455. <tr>
  14456. <td class="parameter_name"><p>p</p></td>
  14457. <td class="parameter_description">
  14458. <p>a pointer to a position within a UTF-8 encoded string</p>
  14459. <p>Passed as <code class="code">p</code></p>
  14460. </td>
  14461. </tr>
  14462. <tr>
  14463. <td class="parameter_name"><p>end</p></td>
  14464. <td class="parameter_description">
  14465. <p>a pointer to the byte following the end of the string,
  14466. or <code class="constant">NULL</code> to indicate that the string is nul-terminated</p>
  14467. <p>Passed as <code class="code">end</code></p>
  14468. </td>
  14469. </tr>
  14470. </table></div>
  14471. </div>
  14472. </div>
  14473. <div class="refsect2">
  14474. <a name="id-1.1.90.2.474"></a><h3>utf8-find-prev-char</h3>
  14475. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-find-prev-char str p))
  14476. </pre></div>
  14477. <p>Given a position <em class="parameter"><code>p</code></em> with a UTF-8 encoded string <em class="parameter"><code>str</code></em>, find the start
  14478. of the previous UTF-8 character starting before <em class="parameter"><code>p</code></em>. Returns <code class="constant">NULL</code> if no
  14479. UTF-8 characters are present in <em class="parameter"><code>str</code></em> before <em class="parameter"><code>p</code></em>.
  14480. </p>
  14481. <p><em class="parameter"><code>p</code></em> does not have to be at the beginning of a UTF-8 character. No check
  14482. is made to see if the character found is actually valid other than
  14483. it starts with an appropriate byte.</p>
  14484. <div class="refsect3">
  14485. <a name="id-1.1.90.2.474.5"></a><h4>Parameters</h4>
  14486. <div class="informaltable"><table>
  14487. <tr>
  14488. <td class="parameter_name"><p>str</p></td>
  14489. <td class="parameter_description">
  14490. <p>pointer to the beginning of a UTF-8 encoded string</p>
  14491. <p>Passed as <code class="code">str</code></p>
  14492. </td>
  14493. </tr>
  14494. <tr>
  14495. <td class="parameter_name"><p>p</p></td>
  14496. <td class="parameter_description">
  14497. <p>pointer to some position within <em class="parameter"><code>str</code></em></p>
  14498. <p>Passed as <code class="code">p</code></p>
  14499. </td>
  14500. </tr>
  14501. </table></div>
  14502. </div>
  14503. </div>
  14504. <div class="refsect2">
  14505. <a name="id-1.1.90.2.475"></a><h3>utf8-get-char</h3>
  14506. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-get-char p))
  14507. </pre></div>
  14508. <p>Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
  14509. </p>
  14510. <p>If <em class="parameter"><code>p</code></em> does not point to a valid UTF-8 encoded character, results
  14511. are undefined. If you are not sure that the bytes are complete
  14512. valid Unicode characters, you should use <code class="function">g_utf8_get_char_validated()</code>
  14513. instead.</p>
  14514. <div class="refsect3">
  14515. <a name="id-1.1.90.2.475.5"></a><h4>Parameters</h4>
  14516. <div class="informaltable"><table><tr>
  14517. <td class="parameter_name"><p>p</p></td>
  14518. <td class="parameter_description">
  14519. <p>a pointer to Unicode character encoded as UTF-8</p>
  14520. <p>Passed as <code class="code">p</code></p>
  14521. </td>
  14522. </tr></table></div>
  14523. </div>
  14524. </div>
  14525. <div class="refsect2">
  14526. <a name="id-1.1.90.2.476"></a><h3>utf8-get-char-validated</h3>
  14527. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-get-char-validated p max-len))
  14528. </pre></div>
  14529. <p>Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
  14530. This function checks for incomplete characters, for invalid characters
  14531. such as characters that are out of the range of Unicode, and for
  14532. overlong encodings of valid characters.
  14533. </p>
  14534. <p>Note that <code class="function">g_utf8_get_char_validated()</code> returns (gunichar)-2 if
  14535. <em class="parameter"><code>max_len</code></em> is positive and any of the bytes in the first UTF-8 character
  14536. sequence are nul.</p>
  14537. <div class="refsect3">
  14538. <a name="id-1.1.90.2.476.5"></a><h4>Parameters</h4>
  14539. <div class="informaltable"><table>
  14540. <tr>
  14541. <td class="parameter_name"><p>p</p></td>
  14542. <td class="parameter_description">
  14543. <p>a pointer to Unicode character encoded as UTF-8</p>
  14544. <p>Passed as <code class="code">p</code></p>
  14545. </td>
  14546. </tr>
  14547. <tr>
  14548. <td class="parameter_name"><p>max_len</p></td>
  14549. <td class="parameter_description">
  14550. <p>the maximum number of bytes to read, or -1 if <em class="parameter"><code>p</code></em> is nul-terminated</p>
  14551. <p>Passed as <code class="code">max-len</code></p>
  14552. </td>
  14553. </tr>
  14554. </table></div>
  14555. </div>
  14556. </div>
  14557. <div class="refsect2">
  14558. <a name="id-1.1.90.2.477"></a><h3>utf8-make-valid</h3>
  14559. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-make-valid str len))
  14560. </pre></div>
  14561. <p>If the provided string is valid UTF-8, return a copy of it. If not,
  14562. return a copy in which bytes that could not be interpreted as valid Unicode
  14563. are replaced with the Unicode replacement character (U+FFFD).
  14564. </p>
  14565. <p>For example, this is an appropriate function to use if you have received
  14566. a string that was incorrectly declared to be UTF-8, and you need a valid
  14567. UTF-8 version of it that can be logged or displayed to the user, with the
  14568. assumption that it is close enough to ASCII or UTF-8 to be mostly
  14569. readable as-is.</p>
  14570. <div class="refsect3">
  14571. <a name="id-1.1.90.2.477.5"></a><h4>Parameters</h4>
  14572. <div class="informaltable"><table>
  14573. <tr>
  14574. <td class="parameter_name"><p>str</p></td>
  14575. <td class="parameter_description">
  14576. <p>string to coerce into UTF-8</p>
  14577. <p>Passed as <code class="code">str</code></p>
  14578. </td>
  14579. </tr>
  14580. <tr>
  14581. <td class="parameter_name"><p>len</p></td>
  14582. <td class="parameter_description">
  14583. <p>the maximum length of <em class="parameter"><code>str</code></em> to use, in bytes. If <em class="parameter"><code>len</code></em> &lt; 0,
  14584. then the string is nul-terminated.</p>
  14585. <p>Passed as <code class="code">len</code></p>
  14586. </td>
  14587. </tr>
  14588. </table></div>
  14589. </div>
  14590. </div>
  14591. <div class="refsect2">
  14592. <a name="id-1.1.90.2.478"></a><h3>utf8-normalize</h3>
  14593. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-normalize str len mode))
  14594. </pre></div>
  14595. <p>Converts a string into canonical form, standardizing
  14596. such issues as whether a character with an accent
  14597. is represented as a base character and combining
  14598. accent or as a single precomposed character. The
  14599. string has to be valid UTF-8, otherwise <code class="constant">NULL</code> is
  14600. returned. You should generally call <code class="function">g_utf8_normalize()</code>
  14601. before comparing two Unicode strings.
  14602. </p>
  14603. <p>The normalization mode <code class="constant">G_NORMALIZE_DEFAULT</code> only
  14604. standardizes differences that do not affect the
  14605. text content, such as the above-mentioned accent
  14606. representation. <code class="constant">G_NORMALIZE_ALL</code> also standardizes
  14607. the "compatibility" characters in Unicode, such
  14608. as SUPERSCRIPT THREE to the standard forms
  14609. (in this case DIGIT THREE). Formatting information
  14610. may be lost but for most text operations such
  14611. characters should be considered the same.
  14612. </p>
  14613. <p><code class="constant">G_NORMALIZE_DEFAULT_COMPOSE</code> and <code class="constant">G_NORMALIZE_ALL_COMPOSE</code>
  14614. are like <code class="constant">G_NORMALIZE_DEFAULT</code> and <code class="constant">G_NORMALIZE_ALL</code>,
  14615. but returned a result with composed forms rather
  14616. than a maximally decomposed form. This is often
  14617. useful if you intend to convert the string to
  14618. a legacy encoding or pass it to a system with
  14619. less capable Unicode handling.</p>
  14620. <div class="refsect3">
  14621. <a name="id-1.1.90.2.478.6"></a><h4>Parameters</h4>
  14622. <div class="informaltable"><table>
  14623. <tr>
  14624. <td class="parameter_name"><p>str</p></td>
  14625. <td class="parameter_description">
  14626. <p>a UTF-8 encoded string.</p>
  14627. <p>Passed as <code class="code">str</code></p>
  14628. </td>
  14629. </tr>
  14630. <tr>
  14631. <td class="parameter_name"><p>len</p></td>
  14632. <td class="parameter_description">
  14633. <p>length of <em class="parameter"><code>str</code></em>, in bytes, or -1 if <em class="parameter"><code>str</code></em> is nul-terminated.</p>
  14634. <p>Passed as <code class="code">len</code></p>
  14635. </td>
  14636. </tr>
  14637. <tr>
  14638. <td class="parameter_name"><p>mode</p></td>
  14639. <td class="parameter_description">
  14640. <p>the type of normalization to perform.</p>
  14641. <p>Passed as <code class="code">mode</code></p>
  14642. </td>
  14643. </tr>
  14644. </table></div>
  14645. </div>
  14646. </div>
  14647. <div class="refsect2">
  14648. <a name="id-1.1.90.2.479"></a><h3>utf8-offset-to-pointer</h3>
  14649. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-offset-to-pointer str offset))
  14650. </pre></div>
  14651. <p>Converts from an integer character offset to a pointer to a position
  14652. within the string.
  14653. </p>
  14654. <p>Since 2.10, this function allows to pass a negative <em class="parameter"><code>offset</code></em> to
  14655. step backwards. It is usually worth stepping backwards from the end
  14656. instead of forwards if <em class="parameter"><code>offset</code></em> is in the last fourth of the string,
  14657. since moving forward is about 3 times faster than moving backward.
  14658. </p>
  14659. <p>Note that this function doesn't abort when reaching the end of <em class="parameter"><code>str</code></em>.
  14660. Therefore you should be sure that <em class="parameter"><code>offset</code></em> is within string boundaries
  14661. before calling that function. Call <code class="function">g_utf8_strlen()</code> when unsure.
  14662. This limitation exists as this function is called frequently during
  14663. text rendering and therefore has to be as fast as possible.</p>
  14664. <div class="refsect3">
  14665. <a name="id-1.1.90.2.479.6"></a><h4>Parameters</h4>
  14666. <div class="informaltable"><table>
  14667. <tr>
  14668. <td class="parameter_name"><p>str</p></td>
  14669. <td class="parameter_description">
  14670. <p>a UTF-8 encoded string</p>
  14671. <p>Passed as <code class="code">str</code></p>
  14672. </td>
  14673. </tr>
  14674. <tr>
  14675. <td class="parameter_name"><p>offset</p></td>
  14676. <td class="parameter_description">
  14677. <p>a character offset within <em class="parameter"><code>str</code></em></p>
  14678. <p>Passed as <code class="code">offset</code></p>
  14679. </td>
  14680. </tr>
  14681. </table></div>
  14682. </div>
  14683. </div>
  14684. <div class="refsect2">
  14685. <a name="id-1.1.90.2.480"></a><h3>utf8-pointer-to-offset</h3>
  14686. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-pointer-to-offset str pos))
  14687. </pre></div>
  14688. <p>Converts from a pointer to position within a string to an integer
  14689. character offset.
  14690. </p>
  14691. <p>Since 2.10, this function allows <em class="parameter"><code>pos</code></em> to be before <em class="parameter"><code>str</code></em>, and returns
  14692. a negative offset in this case.</p>
  14693. <div class="refsect3">
  14694. <a name="id-1.1.90.2.480.5"></a><h4>Parameters</h4>
  14695. <div class="informaltable"><table>
  14696. <tr>
  14697. <td class="parameter_name"><p>str</p></td>
  14698. <td class="parameter_description">
  14699. <p>a UTF-8 encoded string</p>
  14700. <p>Passed as <code class="code">str</code></p>
  14701. </td>
  14702. </tr>
  14703. <tr>
  14704. <td class="parameter_name"><p>pos</p></td>
  14705. <td class="parameter_description">
  14706. <p>a pointer to a position within <em class="parameter"><code>str</code></em></p>
  14707. <p>Passed as <code class="code">pos</code></p>
  14708. </td>
  14709. </tr>
  14710. </table></div>
  14711. </div>
  14712. </div>
  14713. <div class="refsect2">
  14714. <a name="id-1.1.90.2.481"></a><h3>utf8-prev-char</h3>
  14715. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-prev-char p))
  14716. </pre></div>
  14717. <p>Finds the previous UTF-8 character in the string before <em class="parameter"><code>p</code></em>.
  14718. </p>
  14719. <p><em class="parameter"><code>p</code></em> does not have to be at the beginning of a UTF-8 character. No check
  14720. is made to see if the character found is actually valid other than
  14721. it starts with an appropriate byte. If <em class="parameter"><code>p</code></em> might be the first
  14722. character of the string, you must use <code class="function">g_utf8_find_prev_char()</code> instead.</p>
  14723. <div class="refsect3">
  14724. <a name="id-1.1.90.2.481.5"></a><h4>Parameters</h4>
  14725. <div class="informaltable"><table><tr>
  14726. <td class="parameter_name"><p>p</p></td>
  14727. <td class="parameter_description">
  14728. <p>a pointer to a position within a UTF-8 encoded string</p>
  14729. <p>Passed as <code class="code">p</code></p>
  14730. </td>
  14731. </tr></table></div>
  14732. </div>
  14733. </div>
  14734. <div class="refsect2">
  14735. <a name="id-1.1.90.2.482"></a><h3>utf8-strchr</h3>
  14736. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-strchr p len c))
  14737. </pre></div>
  14738. <p>Finds the leftmost occurrence of the given Unicode character
  14739. in a UTF-8 encoded string, while limiting the search to <em class="parameter"><code>len</code></em> bytes.
  14740. If <em class="parameter"><code>len</code></em> is -1, allow unbounded search.</p>
  14741. <div class="refsect3">
  14742. <a name="id-1.1.90.2.482.4"></a><h4>Parameters</h4>
  14743. <div class="informaltable"><table>
  14744. <tr>
  14745. <td class="parameter_name"><p>p</p></td>
  14746. <td class="parameter_description">
  14747. <p>a nul-terminated UTF-8 encoded string</p>
  14748. <p>Passed as <code class="code">p</code></p>
  14749. </td>
  14750. </tr>
  14751. <tr>
  14752. <td class="parameter_name"><p>len</p></td>
  14753. <td class="parameter_description">
  14754. <p>the maximum length of <em class="parameter"><code>p</code></em></p>
  14755. <p>Passed as <code class="code">len</code></p>
  14756. </td>
  14757. </tr>
  14758. <tr>
  14759. <td class="parameter_name"><p>c</p></td>
  14760. <td class="parameter_description">
  14761. <p>a Unicode character</p>
  14762. <p>Passed as <code class="code">c</code></p>
  14763. </td>
  14764. </tr>
  14765. </table></div>
  14766. </div>
  14767. </div>
  14768. <div class="refsect2">
  14769. <a name="id-1.1.90.2.483"></a><h3>utf8-strdown</h3>
  14770. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-strdown str len))
  14771. </pre></div>
  14772. <p>Converts all Unicode characters in the string that have a case
  14773. to lowercase. The exact manner that this is done depends
  14774. on the current locale, and may result in the number of
  14775. characters in the string changing.</p>
  14776. <div class="refsect3">
  14777. <a name="id-1.1.90.2.483.4"></a><h4>Parameters</h4>
  14778. <div class="informaltable"><table>
  14779. <tr>
  14780. <td class="parameter_name"><p>str</p></td>
  14781. <td class="parameter_description">
  14782. <p>a UTF-8 encoded string</p>
  14783. <p>Passed as <code class="code">str</code></p>
  14784. </td>
  14785. </tr>
  14786. <tr>
  14787. <td class="parameter_name"><p>len</p></td>
  14788. <td class="parameter_description">
  14789. <p>length of <em class="parameter"><code>str</code></em>, in bytes, or -1 if <em class="parameter"><code>str</code></em> is nul-terminated.</p>
  14790. <p>Passed as <code class="code">len</code></p>
  14791. </td>
  14792. </tr>
  14793. </table></div>
  14794. </div>
  14795. </div>
  14796. <div class="refsect2">
  14797. <a name="id-1.1.90.2.484"></a><h3>utf8-strlen</h3>
  14798. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-strlen p max))
  14799. </pre></div>
  14800. <p>Computes the length of the string in characters, not including
  14801. the terminating nul character. If the <em class="parameter"><code>max</code></em>'th byte falls in the
  14802. middle of a character, the last (partial) character is not counted.</p>
  14803. <div class="refsect3">
  14804. <a name="id-1.1.90.2.484.4"></a><h4>Parameters</h4>
  14805. <div class="informaltable"><table>
  14806. <tr>
  14807. <td class="parameter_name"><p>p</p></td>
  14808. <td class="parameter_description">
  14809. <p>pointer to the start of a UTF-8 encoded string</p>
  14810. <p>Passed as <code class="code">p</code></p>
  14811. </td>
  14812. </tr>
  14813. <tr>
  14814. <td class="parameter_name"><p>max</p></td>
  14815. <td class="parameter_description">
  14816. <p>the maximum number of bytes to examine. If <em class="parameter"><code>max</code></em>
  14817. is less than 0, then the string is assumed to be
  14818. nul-terminated. If <em class="parameter"><code>max</code></em> is 0, <em class="parameter"><code>p</code></em> will not be examined and
  14819. may be <code class="constant">NULL</code>. If <em class="parameter"><code>max</code></em> is greater than 0, up to <em class="parameter"><code>max</code></em>
  14820. bytes are examined</p>
  14821. <p>Passed as <code class="code">max</code></p>
  14822. </td>
  14823. </tr>
  14824. </table></div>
  14825. </div>
  14826. </div>
  14827. <div class="refsect2">
  14828. <a name="id-1.1.90.2.485"></a><h3>utf8-strncpy</h3>
  14829. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-strncpy dest src n))
  14830. </pre></div>
  14831. <p>Like the standard C <code class="function">strncpy()</code> function, but copies a given number
  14832. of characters instead of a given number of bytes. The <em class="parameter"><code>src</code></em> string
  14833. must be valid UTF-8 encoded text. (Use <code class="function">g_utf8_validate()</code> on all
  14834. text before trying to use UTF-8 utility functions with it.)
  14835. </p>
  14836. <p>Note you must ensure <em class="parameter"><code>dest</code></em> is at least 4 * <em class="parameter"><code>n</code></em> to fit the
  14837. largest possible UTF-8 characters</p>
  14838. <div class="refsect3">
  14839. <a name="id-1.1.90.2.485.5"></a><h4>Parameters</h4>
  14840. <div class="informaltable"><table>
  14841. <tr>
  14842. <td class="parameter_name"><p>dest</p></td>
  14843. <td class="parameter_description">
  14844. <p>buffer to fill with characters from <em class="parameter"><code>src</code></em></p>
  14845. <p>Passed as <code class="code">dest</code></p>
  14846. </td>
  14847. </tr>
  14848. <tr>
  14849. <td class="parameter_name"><p>src</p></td>
  14850. <td class="parameter_description">
  14851. <p>UTF-8 encoded string</p>
  14852. <p>Passed as <code class="code">src</code></p>
  14853. </td>
  14854. </tr>
  14855. <tr>
  14856. <td class="parameter_name"><p>n</p></td>
  14857. <td class="parameter_description">
  14858. <p>character count</p>
  14859. <p>Passed as <code class="code">n</code></p>
  14860. </td>
  14861. </tr>
  14862. </table></div>
  14863. </div>
  14864. </div>
  14865. <div class="refsect2">
  14866. <a name="id-1.1.90.2.486"></a><h3>utf8-strrchr</h3>
  14867. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-strrchr p len c))
  14868. </pre></div>
  14869. <p>Find the rightmost occurrence of the given Unicode character
  14870. in a UTF-8 encoded string, while limiting the search to <em class="parameter"><code>len</code></em> bytes.
  14871. If <em class="parameter"><code>len</code></em> is -1, allow unbounded search.</p>
  14872. <div class="refsect3">
  14873. <a name="id-1.1.90.2.486.4"></a><h4>Parameters</h4>
  14874. <div class="informaltable"><table>
  14875. <tr>
  14876. <td class="parameter_name"><p>p</p></td>
  14877. <td class="parameter_description">
  14878. <p>a nul-terminated UTF-8 encoded string</p>
  14879. <p>Passed as <code class="code">p</code></p>
  14880. </td>
  14881. </tr>
  14882. <tr>
  14883. <td class="parameter_name"><p>len</p></td>
  14884. <td class="parameter_description">
  14885. <p>the maximum length of <em class="parameter"><code>p</code></em></p>
  14886. <p>Passed as <code class="code">len</code></p>
  14887. </td>
  14888. </tr>
  14889. <tr>
  14890. <td class="parameter_name"><p>c</p></td>
  14891. <td class="parameter_description">
  14892. <p>a Unicode character</p>
  14893. <p>Passed as <code class="code">c</code></p>
  14894. </td>
  14895. </tr>
  14896. </table></div>
  14897. </div>
  14898. </div>
  14899. <div class="refsect2">
  14900. <a name="id-1.1.90.2.487"></a><h3>utf8-strreverse</h3>
  14901. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-strreverse str len))
  14902. </pre></div>
  14903. <p>Reverses a UTF-8 string. <em class="parameter"><code>str</code></em> must be valid UTF-8 encoded text.
  14904. (Use <code class="function">g_utf8_validate()</code> on all text before trying to use UTF-8
  14905. utility functions with it.)
  14906. </p>
  14907. <p>This function is intended for programmatic uses of reversed strings.
  14908. It pays no attention to decomposed characters, combining marks, byte
  14909. order marks, directional indicators (LRM, LRO, etc) and similar
  14910. characters which might need special handling when reversing a string
  14911. for display purposes.
  14912. </p>
  14913. <p>Note that unlike <code class="function">g_strreverse()</code>, this function returns
  14914. newly-allocated memory, which should be freed with <code class="function">g_free()</code> when
  14915. no longer needed.</p>
  14916. <div class="refsect3">
  14917. <a name="id-1.1.90.2.487.6"></a><h4>Parameters</h4>
  14918. <div class="informaltable"><table>
  14919. <tr>
  14920. <td class="parameter_name"><p>str</p></td>
  14921. <td class="parameter_description">
  14922. <p>a UTF-8 encoded string</p>
  14923. <p>Passed as <code class="code">str</code></p>
  14924. </td>
  14925. </tr>
  14926. <tr>
  14927. <td class="parameter_name"><p>len</p></td>
  14928. <td class="parameter_description">
  14929. <p>the maximum length of <em class="parameter"><code>str</code></em> to use, in bytes. If <em class="parameter"><code>len</code></em> &lt; 0,
  14930. then the string is nul-terminated.</p>
  14931. <p>Passed as <code class="code">len</code></p>
  14932. </td>
  14933. </tr>
  14934. </table></div>
  14935. </div>
  14936. </div>
  14937. <div class="refsect2">
  14938. <a name="id-1.1.90.2.488"></a><h3>utf8-strup</h3>
  14939. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-strup str len))
  14940. </pre></div>
  14941. <p>Converts all Unicode characters in the string that have a case
  14942. to uppercase. The exact manner that this is done depends
  14943. on the current locale, and may result in the number of
  14944. characters in the string increasing. (For instance, the
  14945. German ess-zet will be changed to SS.)</p>
  14946. <div class="refsect3">
  14947. <a name="id-1.1.90.2.488.4"></a><h4>Parameters</h4>
  14948. <div class="informaltable"><table>
  14949. <tr>
  14950. <td class="parameter_name"><p>str</p></td>
  14951. <td class="parameter_description">
  14952. <p>a UTF-8 encoded string</p>
  14953. <p>Passed as <code class="code">str</code></p>
  14954. </td>
  14955. </tr>
  14956. <tr>
  14957. <td class="parameter_name"><p>len</p></td>
  14958. <td class="parameter_description">
  14959. <p>length of <em class="parameter"><code>str</code></em>, in bytes, or -1 if <em class="parameter"><code>str</code></em> is nul-terminated.</p>
  14960. <p>Passed as <code class="code">len</code></p>
  14961. </td>
  14962. </tr>
  14963. </table></div>
  14964. </div>
  14965. </div>
  14966. <div class="refsect2">
  14967. <a name="id-1.1.90.2.489"></a><h3>utf8-substring</h3>
  14968. <div class="informalexample"><pre class="programlisting">(define-values (%return) (utf8-substring str start-pos end-pos))
  14969. </pre></div>
  14970. <p>Copies a substring out of a UTF-8 encoded string.
  14971. The substring will contain <em class="parameter"><code>end_pos</code></em> - <em class="parameter"><code>start_pos</code></em> characters.</p>
  14972. <div class="refsect3">
  14973. <a name="id-1.1.90.2.489.4"></a><h4>Parameters</h4>
  14974. <div class="informaltable"><table>
  14975. <tr>
  14976. <td class="parameter_name"><p>str</p></td>
  14977. <td class="parameter_description">
  14978. <p>a UTF-8 encoded string</p>
  14979. <p>Passed as <code class="code">str</code></p>
  14980. </td>
  14981. </tr>
  14982. <tr>
  14983. <td class="parameter_name"><p>start_pos</p></td>
  14984. <td class="parameter_description">
  14985. <p>a character offset within <em class="parameter"><code>str</code></em></p>
  14986. <p>Passed as <code class="code">start-pos</code></p>
  14987. </td>
  14988. </tr>
  14989. <tr>
  14990. <td class="parameter_name"><p>end_pos</p></td>
  14991. <td class="parameter_description">
  14992. <p>another character offset within <em class="parameter"><code>str</code></em></p>
  14993. <p>Passed as <code class="code">end-pos</code></p>
  14994. </td>
  14995. </tr>
  14996. </table></div>
  14997. </div>
  14998. </div>
  14999. <div class="refsect2">
  15000. <a name="id-1.1.90.2.490"></a><h3>utf8-to-ucs4</h3>
  15001. <div class="informalexample"><pre class="programlisting">(define-values
  15002. (%return items-read items-written)
  15003. (utf8-to-ucs4 str len items-read items-written))
  15004. </pre></div>
  15005. <p>Convert a string from UTF-8 to a 32-bit fixed width
  15006. representation as UCS-4. A trailing 0 character will be added to the
  15007. string after the converted text.</p>
  15008. <div class="refsect3">
  15009. <a name="id-1.1.90.2.490.4"></a><h4>Parameters</h4>
  15010. <div class="informaltable"><table>
  15011. <tr>
  15012. <td class="parameter_name"><p>str</p></td>
  15013. <td class="parameter_description">
  15014. <p>a UTF-8 encoded string</p>
  15015. <p>Passed as <code class="code">str</code></p>
  15016. </td>
  15017. </tr>
  15018. <tr>
  15019. <td class="parameter_name"><p>len</p></td>
  15020. <td class="parameter_description">
  15021. <p>the maximum length of <em class="parameter"><code>str</code></em> to use, in bytes. If <em class="parameter"><code>len</code></em> &lt; 0,
  15022. then the string is nul-terminated.</p>
  15023. <p>Passed as <code class="code">len</code></p>
  15024. </td>
  15025. </tr>
  15026. <tr>
  15027. <td class="parameter_name"><p>items_read</p></td>
  15028. <td class="parameter_description">
  15029. <p>location to store number of
  15030. bytes read, or <code class="constant">NULL</code>.
  15031. If <code class="constant">NULL</code>, then <code class="constant">G_CONVERT_ERROR_PARTIAL_INPUT</code> will be
  15032. returned in case <em class="parameter"><code>str</code></em> contains a trailing partial
  15033. character. If an error occurs then the index of the
  15034. invalid input is stored here.</p>
  15035. <p>Passed as <code class="code">items-read</code></p>
  15036. </td>
  15037. </tr>
  15038. <tr>
  15039. <td class="parameter_name"><p>items_written</p></td>
  15040. <td class="parameter_description">
  15041. <p>location to store number
  15042. of characters written or <code class="constant">NULL</code>. The value here stored does not include
  15043. the trailing 0 character.</p>
  15044. <p>Passed as <code class="code">items-written</code></p>
  15045. </td>
  15046. </tr>
  15047. </table></div>
  15048. </div>
  15049. </div>
  15050. <div class="refsect2">
  15051. <a name="id-1.1.90.2.491"></a><h3>utf8-to-ucs4-fast</h3>
  15052. <div class="informalexample"><pre class="programlisting">(define-values
  15053. (%return items-written)
  15054. (utf8-to-ucs4-fast str len items-written))
  15055. </pre></div>
  15056. <p>Convert a string from UTF-8 to a 32-bit fixed width
  15057. representation as UCS-4, assuming valid UTF-8 input.
  15058. This function is roughly twice as fast as <code class="function">g_utf8_to_ucs4()</code>
  15059. but does no error checking on the input. A trailing 0 character
  15060. will be added to the string after the converted text.</p>
  15061. <div class="refsect3">
  15062. <a name="id-1.1.90.2.491.4"></a><h4>Parameters</h4>
  15063. <div class="informaltable"><table>
  15064. <tr>
  15065. <td class="parameter_name"><p>str</p></td>
  15066. <td class="parameter_description">
  15067. <p>a UTF-8 encoded string</p>
  15068. <p>Passed as <code class="code">str</code></p>
  15069. </td>
  15070. </tr>
  15071. <tr>
  15072. <td class="parameter_name"><p>len</p></td>
  15073. <td class="parameter_description">
  15074. <p>the maximum length of <em class="parameter"><code>str</code></em> to use, in bytes. If <em class="parameter"><code>len</code></em> &lt; 0,
  15075. then the string is nul-terminated.</p>
  15076. <p>Passed as <code class="code">len</code></p>
  15077. </td>
  15078. </tr>
  15079. <tr>
  15080. <td class="parameter_name"><p>items_written</p></td>
  15081. <td class="parameter_description">
  15082. <p>location to store the
  15083. number of characters in the result, or <code class="constant">NULL</code>.</p>
  15084. <p>Passed as <code class="code">items-written</code></p>
  15085. </td>
  15086. </tr>
  15087. </table></div>
  15088. </div>
  15089. </div>
  15090. <div class="refsect2">
  15091. <a name="id-1.1.90.2.492"></a><h3>utf8-to-utf16</h3>
  15092. <div class="informalexample"><pre class="programlisting">(define-values
  15093. (%return items-read items-written)
  15094. (utf8-to-utf16 str len items-read items-written))
  15095. </pre></div>
  15096. <p>Convert a string from UTF-8 to UTF-16. A 0 character will be
  15097. added to the result after the converted text.</p>
  15098. <div class="refsect3">
  15099. <a name="id-1.1.90.2.492.4"></a><h4>Parameters</h4>
  15100. <div class="informaltable"><table>
  15101. <tr>
  15102. <td class="parameter_name"><p>str</p></td>
  15103. <td class="parameter_description">
  15104. <p>a UTF-8 encoded string</p>
  15105. <p>Passed as <code class="code">str</code></p>
  15106. </td>
  15107. </tr>
  15108. <tr>
  15109. <td class="parameter_name"><p>len</p></td>
  15110. <td class="parameter_description">
  15111. <p>the maximum length (number of bytes) of <em class="parameter"><code>str</code></em> to use.
  15112. If <em class="parameter"><code>len</code></em> &lt; 0, then the string is nul-terminated.</p>
  15113. <p>Passed as <code class="code">len</code></p>
  15114. </td>
  15115. </tr>
  15116. <tr>
  15117. <td class="parameter_name"><p>items_read</p></td>
  15118. <td class="parameter_description">
  15119. <p>location to store number of
  15120. bytes read, or <code class="constant">NULL</code>. If <code class="constant">NULL</code>, then <code class="constant">G_CONVERT_ERROR_PARTIAL_INPUT</code> will
  15121. be returned in case <em class="parameter"><code>str</code></em> contains a trailing partial character. If
  15122. an error occurs then the index of the invalid input is stored here.</p>
  15123. <p>Passed as <code class="code">items-read</code></p>
  15124. </td>
  15125. </tr>
  15126. <tr>
  15127. <td class="parameter_name"><p>items_written</p></td>
  15128. <td class="parameter_description">
  15129. <p>location to store number
  15130. of <span class="type">gunichar2</span> written, or <code class="constant">NULL</code>. The value stored here does not include
  15131. the trailing 0.</p>
  15132. <p>Passed as <code class="code">items-written</code></p>
  15133. </td>
  15134. </tr>
  15135. </table></div>
  15136. </div>
  15137. </div>
  15138. <div class="refsect2">
  15139. <a name="id-1.1.90.2.493"></a><h3>utf8-validate</h3>
  15140. <div class="informalexample"><pre class="programlisting">(define-values (%return end) (utf8-validate str))
  15141. </pre></div>
  15142. <p>Validates UTF-8 encoded text. <em class="parameter"><code>str</code></em> is the text to validate;
  15143. if <em class="parameter"><code>str</code></em> is nul-terminated, then <em class="parameter"><code>max_len</code></em> can be -1, otherwise
  15144. <em class="parameter"><code>max_len</code></em> should be the number of bytes to validate.
  15145. If <em class="parameter"><code>end</code></em> is non-<code class="constant">NULL</code>, then the end of the valid range
  15146. will be stored there (i.e. the start of the first invalid
  15147. character if some bytes were invalid, or the end of the text
  15148. being validated otherwise).
  15149. </p>
  15150. <p>Note that <code class="function">g_utf8_validate()</code> returns <code class="constant">FALSE</code> if <em class="parameter"><code>max_len</code></em> is
  15151. positive and any of the <em class="parameter"><code>max_len</code></em> bytes are nul.
  15152. </p>
  15153. <p>Returns <code class="constant">TRUE</code> if all of <em class="parameter"><code>str</code></em> was valid. Many GLib and GTK+
  15154. routines require valid UTF-8 as input; so data read from a file
  15155. or the network should be checked with <code class="function">g_utf8_validate()</code> before
  15156. doing anything else with it.</p>
  15157. <div class="refsect3">
  15158. <a name="id-1.1.90.2.493.6"></a><h4>Parameters</h4>
  15159. <div class="informaltable"><table>
  15160. <tr>
  15161. <td class="parameter_name"><p>str</p></td>
  15162. <td class="parameter_description">
  15163. <p>a pointer to character data</p>
  15164. <p>Passed as <code class="code">str</code></p>
  15165. </td>
  15166. </tr>
  15167. <tr>
  15168. <td class="parameter_name"><p>max_len</p></td>
  15169. <td class="parameter_description">
  15170. <p>max bytes to validate, or -1 to go until NUL</p>
  15171. <p>Inferred from <code class="code">str</code></p>
  15172. </td>
  15173. </tr>
  15174. <tr>
  15175. <td class="parameter_name"><p>end</p></td>
  15176. <td class="parameter_description">
  15177. <p>return location for end of valid data</p>
  15178. <p>Passed as <code class="code">end</code></p>
  15179. </td>
  15180. </tr>
  15181. </table></div>
  15182. </div>
  15183. </div>
  15184. <div class="refsect2">
  15185. <a name="id-1.1.90.2.494"></a><h3>utf8-validate-len</h3>
  15186. <div class="informalexample"><pre class="programlisting">(define-values (%return end) (utf8-validate-len str))
  15187. </pre></div>
  15188. <p>Validates UTF-8 encoded text.
  15189. </p>
  15190. <p>As with <code class="function">g_utf8_validate()</code>, but <em class="parameter"><code>max_len</code></em> must be set, and hence this function
  15191. will always return <code class="constant">FALSE</code> if any of the bytes of <em class="parameter"><code>str</code></em> are nul.</p>
  15192. <div class="refsect3">
  15193. <a name="id-1.1.90.2.494.5"></a><h4>Parameters</h4>
  15194. <div class="informaltable"><table>
  15195. <tr>
  15196. <td class="parameter_name"><p>str</p></td>
  15197. <td class="parameter_description">
  15198. <p>a pointer to character data</p>
  15199. <p>Passed as <code class="code">str</code></p>
  15200. </td>
  15201. </tr>
  15202. <tr>
  15203. <td class="parameter_name"><p>max_len</p></td>
  15204. <td class="parameter_description">
  15205. <p>max bytes to validate</p>
  15206. <p>Inferred from <code class="code">str</code></p>
  15207. </td>
  15208. </tr>
  15209. <tr>
  15210. <td class="parameter_name"><p>end</p></td>
  15211. <td class="parameter_description">
  15212. <p>return location for end of valid data</p>
  15213. <p>Passed as <code class="code">end</code></p>
  15214. </td>
  15215. </tr>
  15216. </table></div>
  15217. </div>
  15218. </div>
  15219. <div class="refsect2">
  15220. <a name="id-1.1.90.2.495"></a><h3>uuid-string-is-valid?</h3>
  15221. <div class="informalexample"><pre class="programlisting">(define-values (%return) (uuid-string-is-valid? str))
  15222. </pre></div>
  15223. <p>Parses the string <em class="parameter"><code>str</code></em> and verify if it is a UUID.
  15224. </p>
  15225. <p>The function accepts the following syntax:
  15226. </p>
  15227. <p>- simple forms (e.g. <code class="code">f81d4fae-7dec-11d0-a765-00a0c91e6bf6</code>)
  15228. </p>
  15229. <p>Note that hyphens are required within the UUID string itself,
  15230. as per the aforementioned RFC.</p>
  15231. <div class="refsect3">
  15232. <a name="id-1.1.90.2.495.7"></a><h4>Parameters</h4>
  15233. <div class="informaltable"><table><tr>
  15234. <td class="parameter_name"><p>str</p></td>
  15235. <td class="parameter_description">
  15236. <p>a string representing a UUID</p>
  15237. <p>Passed as <code class="code">str</code></p>
  15238. </td>
  15239. </tr></table></div>
  15240. </div>
  15241. </div>
  15242. <div class="refsect2">
  15243. <a name="id-1.1.90.2.496"></a><h3>uuid-string-random</h3>
  15244. <div class="informalexample"><pre class="programlisting">(define-values (%return) (uuid-string-random))
  15245. </pre></div>
  15246. <p>Generates a random UUID (RFC 4122 version 4) as a string. It has the same
  15247. randomness guarantees as <span class="type">GRand</span>, so must not be used for cryptographic
  15248. purposes such as key generation, nonces, salts or one-time pads.</p>
  15249. </div>
  15250. <div class="refsect2">
  15251. <a name="id-1.1.90.2.497"></a><h3>variant-get-gtype</h3>
  15252. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-get-gtype))
  15253. </pre></div>
  15254. <p>Undocumented</p>
  15255. </div>
  15256. <div class="refsect2">
  15257. <a name="id-1.1.90.2.498"></a><h3>variant-is-object-path?</h3>
  15258. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-is-object-path? string))
  15259. </pre></div>
  15260. <p>Determines if a given string is a valid D-Bus object path. You
  15261. should ensure that a string is a valid D-Bus object path before
  15262. passing it to <code class="function">g_variant_new_object_path()</code>.
  15263. </p>
  15264. <p>A valid object path starts with <code class="code">/</code> followed by zero or more
  15265. sequences of characters separated by <code class="code">/</code> characters. Each sequence
  15266. must contain only the characters <code class="code">[A-Z][a-z][0-9]_</code>. No sequence
  15267. (including the one following the final <code class="code">/</code> character) may be empty.</p>
  15268. <div class="refsect3">
  15269. <a name="id-1.1.90.2.498.5"></a><h4>Parameters</h4>
  15270. <div class="informaltable"><table><tr>
  15271. <td class="parameter_name"><p>string</p></td>
  15272. <td class="parameter_description">
  15273. <p>a normal C nul-terminated string</p>
  15274. <p>Passed as <code class="code">string</code></p>
  15275. </td>
  15276. </tr></table></div>
  15277. </div>
  15278. </div>
  15279. <div class="refsect2">
  15280. <a name="id-1.1.90.2.499"></a><h3>variant-is-signature?</h3>
  15281. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-is-signature? string))
  15282. </pre></div>
  15283. <p>Determines if a given string is a valid D-Bus type signature. You
  15284. should ensure that a string is a valid D-Bus type signature before
  15285. passing it to <code class="function">g_variant_new_signature()</code>.
  15286. </p>
  15287. <p>D-Bus type signatures consist of zero or more definite <span class="type">GVariantType</span>
  15288. strings in sequence.</p>
  15289. <div class="refsect3">
  15290. <a name="id-1.1.90.2.499.5"></a><h4>Parameters</h4>
  15291. <div class="informaltable"><table><tr>
  15292. <td class="parameter_name"><p>string</p></td>
  15293. <td class="parameter_description">
  15294. <p>a normal C nul-terminated string</p>
  15295. <p>Passed as <code class="code">string</code></p>
  15296. </td>
  15297. </tr></table></div>
  15298. </div>
  15299. </div>
  15300. <div class="refsect2">
  15301. <a name="id-1.1.90.2.500"></a><h3>variant-parse</h3>
  15302. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-parse type text limit endptr))
  15303. </pre></div>
  15304. <p>Parses a <span class="type">GVariant</span> from a text representation.
  15305. </p>
  15306. <p>A single <span class="type">GVariant</span> is parsed from the content of <em class="parameter"><code>text</code></em>.
  15307. </p>
  15308. <p>The format is described [here][gvariant-text].
  15309. </p>
  15310. <p>The memory at <em class="parameter"><code>limit</code></em> will never be accessed and the parser behaves as
  15311. if the character at <em class="parameter"><code>limit</code></em> is the nul terminator. This has the
  15312. effect of bounding <em class="parameter"><code>text</code></em>.
  15313. </p>
  15314. <p>If <em class="parameter"><code>endptr</code></em> is non-<code class="constant">NULL</code> then <em class="parameter"><code>text</code></em> is permitted to contain data
  15315. following the value that this function parses and <em class="parameter"><code>endptr</code></em> will be
  15316. updated to point to the first character past the end of the text
  15317. parsed by this function. If <em class="parameter"><code>endptr</code></em> is <code class="constant">NULL</code> and there is extra data
  15318. then an error is returned.
  15319. </p>
  15320. <p>If <em class="parameter"><code>type</code></em> is non-<code class="constant">NULL</code> then the value will be parsed to have that
  15321. type. This may result in additional parse errors (in the case that
  15322. the parsed value doesn't fit the type) but may also result in fewer
  15323. errors (in the case that the type would have been ambiguous, such as
  15324. with empty arrays).
  15325. </p>
  15326. <p>In the event that the parsing is successful, the resulting <span class="type">GVariant</span>
  15327. is returned. It is never floating, and must be freed with
  15328. <code class="function">g_variant_unref()</code>.
  15329. </p>
  15330. <p>In case of any error, <code class="constant">NULL</code> will be returned. If <em class="parameter"><code>error</code></em> is non-<code class="constant">NULL</code>
  15331. then it will be set to reflect the error that occurred.
  15332. </p>
  15333. <p>Officially, the language understood by the parser is "any string
  15334. produced by <code class="function">g_variant_print()</code>".
  15335. </p>
  15336. <p>There may be implementation specific restrictions on deeply nested values,
  15337. which would result in a <code class="constant">G_VARIANT_PARSE_ERROR_RECURSION</code> error. <span class="type">GVariant</span> is
  15338. guaranteed to handle nesting up to at least 64 levels.</p>
  15339. <div class="refsect3">
  15340. <a name="id-1.1.90.2.500.13"></a><h4>Parameters</h4>
  15341. <div class="informaltable"><table>
  15342. <tr>
  15343. <td class="parameter_name"><p>type</p></td>
  15344. <td class="parameter_description">
  15345. <p>a <span class="type">GVariantType</span>, or <code class="constant">NULL</code></p>
  15346. <p>Passed as <code class="code">type</code></p>
  15347. </td>
  15348. </tr>
  15349. <tr>
  15350. <td class="parameter_name"><p>text</p></td>
  15351. <td class="parameter_description">
  15352. <p>a string containing a GVariant in text form</p>
  15353. <p>Passed as <code class="code">text</code></p>
  15354. </td>
  15355. </tr>
  15356. <tr>
  15357. <td class="parameter_name"><p>limit</p></td>
  15358. <td class="parameter_description">
  15359. <p>a pointer to the end of <em class="parameter"><code>text</code></em>, or <code class="constant">NULL</code></p>
  15360. <p>Passed as <code class="code">limit</code></p>
  15361. </td>
  15362. </tr>
  15363. <tr>
  15364. <td class="parameter_name"><p>endptr</p></td>
  15365. <td class="parameter_description">
  15366. <p>a location to store the end pointer, or <code class="constant">NULL</code></p>
  15367. <p>Passed as <code class="code">endptr</code></p>
  15368. </td>
  15369. </tr>
  15370. </table></div>
  15371. </div>
  15372. </div>
  15373. <div class="refsect2">
  15374. <a name="id-1.1.90.2.501"></a><h3>variant-parse-error-print-context</h3>
  15375. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-parse-error-print-context error source-str))
  15376. </pre></div>
  15377. <p>Pretty-prints a message showing the context of a <span class="type">GVariant</span> parse
  15378. error within the string for which parsing was attempted.
  15379. </p>
  15380. <p>The resulting string is suitable for output to the console or other
  15381. monospace media where newlines are treated in the usual way.
  15382. </p>
  15383. <p>The message will typically look something like one of the following:
  15384. </p>
  15385. <div class="informalexample"><pre class="programlisting">
  15386. unterminated string constant:
  15387. (1, 2, 3, 'abc
  15388. ^^^^
  15389. </pre></div>
  15390. <p>or
  15391. </p>
  15392. <div class="informalexample"><pre class="programlisting">
  15393. unable to find a common type:
  15394. [1, 2, 3, 'str']
  15395. ^ ^^^^^
  15396. </pre></div>
  15397. <p>The format of the message may change in a future version.
  15398. </p>
  15399. <p><em class="parameter"><code>error</code></em> must have come from a failed attempt to <code class="function">g_variant_parse()</code> and
  15400. <em class="parameter"><code>source_str</code></em> must be exactly the same string that caused the error.
  15401. If <em class="parameter"><code>source_str</code></em> was not nul-terminated when you passed it to
  15402. <code class="function">g_variant_parse()</code> then you must add nul termination before using this
  15403. function.</p>
  15404. <div class="refsect3">
  15405. <a name="id-1.1.90.2.501.11"></a><h4>Parameters</h4>
  15406. <div class="informaltable"><table>
  15407. <tr>
  15408. <td class="parameter_name"><p>error</p></td>
  15409. <td class="parameter_description">
  15410. <p>a <span class="type">GError</span> from the <span class="type">GVariantParseError</span> domain</p>
  15411. <p>Passed as <code class="code">error</code></p>
  15412. </td>
  15413. </tr>
  15414. <tr>
  15415. <td class="parameter_name"><p>source_str</p></td>
  15416. <td class="parameter_description">
  15417. <p>the string that was given to the parser</p>
  15418. <p>Passed as <code class="code">source-str</code></p>
  15419. </td>
  15420. </tr>
  15421. </table></div>
  15422. </div>
  15423. </div>
  15424. <div class="refsect2">
  15425. <a name="id-1.1.90.2.502"></a><h3>variant-parse-error-quark</h3>
  15426. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-parse-error-quark))
  15427. </pre></div>
  15428. <p>Undocumented</p>
  15429. </div>
  15430. <div class="refsect2">
  15431. <a name="id-1.1.90.2.503"></a><h3>variant-type-checked-</h3>
  15432. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type-checked- arg0))
  15433. </pre></div>
  15434. <p>Undocumented</p>
  15435. <div class="refsect3">
  15436. <a name="id-1.1.90.2.503.4"></a><h4>Parameters</h4>
  15437. <div class="informaltable"><table><tr>
  15438. <td class="parameter_name"><p>arg0</p></td>
  15439. <td class="parameter_description">
  15440. <p></p>
  15441. <p>Passed as <code class="code">arg0</code></p>
  15442. </td>
  15443. </tr></table></div>
  15444. </div>
  15445. </div>
  15446. <div class="refsect2">
  15447. <a name="id-1.1.90.2.504"></a><h3>variant-type-string-get-depth-</h3>
  15448. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type-string-get-depth- type-string))
  15449. </pre></div>
  15450. <p>Undocumented</p>
  15451. <div class="refsect3">
  15452. <a name="id-1.1.90.2.504.4"></a><h4>Parameters</h4>
  15453. <div class="informaltable"><table><tr>
  15454. <td class="parameter_name"><p>type_string</p></td>
  15455. <td class="parameter_description">
  15456. <p></p>
  15457. <p>Passed as <code class="code">type-string</code></p>
  15458. </td>
  15459. </tr></table></div>
  15460. </div>
  15461. </div>
  15462. <div class="refsect2">
  15463. <a name="id-1.1.90.2.505"></a><h3>variant-type-string-is-valid?</h3>
  15464. <div class="informalexample"><pre class="programlisting">(define-values (%return) (variant-type-string-is-valid? type-string))
  15465. </pre></div>
  15466. <p>Checks if <em class="parameter"><code>type_string</code></em> is a valid GVariant type string. This call is
  15467. equivalent to calling <code class="function">g_variant_type_string_scan()</code> and confirming
  15468. that the following character is a nul terminator.</p>
  15469. <div class="refsect3">
  15470. <a name="id-1.1.90.2.505.4"></a><h4>Parameters</h4>
  15471. <div class="informaltable"><table><tr>
  15472. <td class="parameter_name"><p>type_string</p></td>
  15473. <td class="parameter_description">
  15474. <p>a pointer to any string</p>
  15475. <p>Passed as <code class="code">type-string</code></p>
  15476. </td>
  15477. </tr></table></div>
  15478. </div>
  15479. </div>
  15480. <div class="refsect2">
  15481. <a name="id-1.1.90.2.506"></a><h3>variant-type-string-scan</h3>
  15482. <div class="informalexample"><pre class="programlisting">(define-values (%return endptr) (variant-type-string-scan string limit))
  15483. </pre></div>
  15484. <p>Scan for a single complete and valid GVariant type string in <em class="parameter"><code>string</code></em>.
  15485. The memory pointed to by <em class="parameter"><code>limit</code></em> (or bytes beyond it) is never
  15486. accessed.
  15487. </p>
  15488. <p>If a valid type string is found, <em class="parameter"><code>endptr</code></em> is updated to point to the
  15489. first character past the end of the string that was found and <code class="constant">TRUE</code>
  15490. is returned.
  15491. </p>
  15492. <p>If there is no valid type string starting at <em class="parameter"><code>string</code></em>, or if the type
  15493. string does not end before <em class="parameter"><code>limit</code></em> then <code class="constant">FALSE</code> is returned.
  15494. </p>
  15495. <p>For the simple case of checking if a string is a valid type string,
  15496. see <code class="function">g_variant_type_string_is_valid()</code>.</p>
  15497. <div class="refsect3">
  15498. <a name="id-1.1.90.2.506.7"></a><h4>Parameters</h4>
  15499. <div class="informaltable"><table>
  15500. <tr>
  15501. <td class="parameter_name"><p>string</p></td>
  15502. <td class="parameter_description">
  15503. <p>a pointer to any string</p>
  15504. <p>Passed as <code class="code">string</code></p>
  15505. </td>
  15506. </tr>
  15507. <tr>
  15508. <td class="parameter_name"><p>limit</p></td>
  15509. <td class="parameter_description">
  15510. <p>the end of <em class="parameter"><code>string</code></em>, or <code class="constant">NULL</code></p>
  15511. <p>Passed as <code class="code">limit</code></p>
  15512. </td>
  15513. </tr>
  15514. <tr>
  15515. <td class="parameter_name"><p>endptr</p></td>
  15516. <td class="parameter_description">
  15517. <p>location to store the end pointer, or <code class="constant">NULL</code></p>
  15518. <p>Passed as <code class="code">endptr</code></p>
  15519. </td>
  15520. </tr>
  15521. </table></div>
  15522. </div>
  15523. </div>
  15524. </div>
  15525. </div>
  15526. <div class="footer">
  15527. <hr>Generated by GTK-Doc V1.33.1</div>
  15528. </body>
  15529. </html>