libc.info-4 292 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131
  1. This is libc.info, produced by makeinfo version 6.5 from libc.texinfo.
  2. This is ‘The GNU C Library Reference Manual’, for version 2.33 (GNU).
  3. Copyright © 1993–2021 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being “Free Software Needs Free Documentation” and
  8. “GNU Lesser General Public License”, the Front-Cover texts being “A GNU
  9. Manual”, and with the Back-Cover Texts as in (a) below. A copy of the
  10. license is included in the section entitled "GNU Free Documentation
  11. License".
  12. (a) The FSF’s Back-Cover Text is: “You have the freedom to copy and
  13. modify this GNU manual. Buying copies from the FSF supports it in
  14. developing GNU and promoting software freedom.”
  15. INFO-DIR-SECTION Software libraries
  16. START-INFO-DIR-ENTRY
  17. * Libc: (libc). C library.
  18. END-INFO-DIR-ENTRY
  19. INFO-DIR-SECTION GNU C library functions and macros
  20. START-INFO-DIR-ENTRY
  21. * ALTWERASE: (libc)Local Modes.
  22. * ARGP_ERR_UNKNOWN: (libc)Argp Parser Functions.
  23. * ARG_MAX: (libc)General Limits.
  24. * BC_BASE_MAX: (libc)Utility Limits.
  25. * BC_DIM_MAX: (libc)Utility Limits.
  26. * BC_SCALE_MAX: (libc)Utility Limits.
  27. * BC_STRING_MAX: (libc)Utility Limits.
  28. * BRKINT: (libc)Input Modes.
  29. * BUFSIZ: (libc)Controlling Buffering.
  30. * CCTS_OFLOW: (libc)Control Modes.
  31. * CHAR_BIT: (libc)Width of Type.
  32. * CHILD_MAX: (libc)General Limits.
  33. * CIGNORE: (libc)Control Modes.
  34. * CLK_TCK: (libc)Processor Time.
  35. * CLOCAL: (libc)Control Modes.
  36. * CLOCKS_PER_SEC: (libc)CPU Time.
  37. * CLOCK_MONOTONIC: (libc)Getting the Time.
  38. * CLOCK_REALTIME: (libc)Getting the Time.
  39. * COLL_WEIGHTS_MAX: (libc)Utility Limits.
  40. * CPU_CLR: (libc)CPU Affinity.
  41. * CPU_FEATURE_USABLE: (libc)X86.
  42. * CPU_ISSET: (libc)CPU Affinity.
  43. * CPU_SET: (libc)CPU Affinity.
  44. * CPU_SETSIZE: (libc)CPU Affinity.
  45. * CPU_ZERO: (libc)CPU Affinity.
  46. * CREAD: (libc)Control Modes.
  47. * CRTS_IFLOW: (libc)Control Modes.
  48. * CS5: (libc)Control Modes.
  49. * CS6: (libc)Control Modes.
  50. * CS7: (libc)Control Modes.
  51. * CS8: (libc)Control Modes.
  52. * CSIZE: (libc)Control Modes.
  53. * CSTOPB: (libc)Control Modes.
  54. * DTTOIF: (libc)Directory Entries.
  55. * E2BIG: (libc)Error Codes.
  56. * EACCES: (libc)Error Codes.
  57. * EADDRINUSE: (libc)Error Codes.
  58. * EADDRNOTAVAIL: (libc)Error Codes.
  59. * EADV: (libc)Error Codes.
  60. * EAFNOSUPPORT: (libc)Error Codes.
  61. * EAGAIN: (libc)Error Codes.
  62. * EALREADY: (libc)Error Codes.
  63. * EAUTH: (libc)Error Codes.
  64. * EBACKGROUND: (libc)Error Codes.
  65. * EBADE: (libc)Error Codes.
  66. * EBADF: (libc)Error Codes.
  67. * EBADFD: (libc)Error Codes.
  68. * EBADMSG: (libc)Error Codes.
  69. * EBADR: (libc)Error Codes.
  70. * EBADRPC: (libc)Error Codes.
  71. * EBADRQC: (libc)Error Codes.
  72. * EBADSLT: (libc)Error Codes.
  73. * EBFONT: (libc)Error Codes.
  74. * EBUSY: (libc)Error Codes.
  75. * ECANCELED: (libc)Error Codes.
  76. * ECHILD: (libc)Error Codes.
  77. * ECHO: (libc)Local Modes.
  78. * ECHOCTL: (libc)Local Modes.
  79. * ECHOE: (libc)Local Modes.
  80. * ECHOK: (libc)Local Modes.
  81. * ECHOKE: (libc)Local Modes.
  82. * ECHONL: (libc)Local Modes.
  83. * ECHOPRT: (libc)Local Modes.
  84. * ECHRNG: (libc)Error Codes.
  85. * ECOMM: (libc)Error Codes.
  86. * ECONNABORTED: (libc)Error Codes.
  87. * ECONNREFUSED: (libc)Error Codes.
  88. * ECONNRESET: (libc)Error Codes.
  89. * ED: (libc)Error Codes.
  90. * EDEADLK: (libc)Error Codes.
  91. * EDEADLOCK: (libc)Error Codes.
  92. * EDESTADDRREQ: (libc)Error Codes.
  93. * EDIED: (libc)Error Codes.
  94. * EDOM: (libc)Error Codes.
  95. * EDOTDOT: (libc)Error Codes.
  96. * EDQUOT: (libc)Error Codes.
  97. * EEXIST: (libc)Error Codes.
  98. * EFAULT: (libc)Error Codes.
  99. * EFBIG: (libc)Error Codes.
  100. * EFTYPE: (libc)Error Codes.
  101. * EGRATUITOUS: (libc)Error Codes.
  102. * EGREGIOUS: (libc)Error Codes.
  103. * EHOSTDOWN: (libc)Error Codes.
  104. * EHOSTUNREACH: (libc)Error Codes.
  105. * EHWPOISON: (libc)Error Codes.
  106. * EIDRM: (libc)Error Codes.
  107. * EIEIO: (libc)Error Codes.
  108. * EILSEQ: (libc)Error Codes.
  109. * EINPROGRESS: (libc)Error Codes.
  110. * EINTR: (libc)Error Codes.
  111. * EINVAL: (libc)Error Codes.
  112. * EIO: (libc)Error Codes.
  113. * EISCONN: (libc)Error Codes.
  114. * EISDIR: (libc)Error Codes.
  115. * EISNAM: (libc)Error Codes.
  116. * EKEYEXPIRED: (libc)Error Codes.
  117. * EKEYREJECTED: (libc)Error Codes.
  118. * EKEYREVOKED: (libc)Error Codes.
  119. * EL2HLT: (libc)Error Codes.
  120. * EL2NSYNC: (libc)Error Codes.
  121. * EL3HLT: (libc)Error Codes.
  122. * EL3RST: (libc)Error Codes.
  123. * ELIBACC: (libc)Error Codes.
  124. * ELIBBAD: (libc)Error Codes.
  125. * ELIBEXEC: (libc)Error Codes.
  126. * ELIBMAX: (libc)Error Codes.
  127. * ELIBSCN: (libc)Error Codes.
  128. * ELNRNG: (libc)Error Codes.
  129. * ELOOP: (libc)Error Codes.
  130. * EMEDIUMTYPE: (libc)Error Codes.
  131. * EMFILE: (libc)Error Codes.
  132. * EMLINK: (libc)Error Codes.
  133. * EMSGSIZE: (libc)Error Codes.
  134. * EMULTIHOP: (libc)Error Codes.
  135. * ENAMETOOLONG: (libc)Error Codes.
  136. * ENAVAIL: (libc)Error Codes.
  137. * ENEEDAUTH: (libc)Error Codes.
  138. * ENETDOWN: (libc)Error Codes.
  139. * ENETRESET: (libc)Error Codes.
  140. * ENETUNREACH: (libc)Error Codes.
  141. * ENFILE: (libc)Error Codes.
  142. * ENOANO: (libc)Error Codes.
  143. * ENOBUFS: (libc)Error Codes.
  144. * ENOCSI: (libc)Error Codes.
  145. * ENODATA: (libc)Error Codes.
  146. * ENODEV: (libc)Error Codes.
  147. * ENOENT: (libc)Error Codes.
  148. * ENOEXEC: (libc)Error Codes.
  149. * ENOKEY: (libc)Error Codes.
  150. * ENOLCK: (libc)Error Codes.
  151. * ENOLINK: (libc)Error Codes.
  152. * ENOMEDIUM: (libc)Error Codes.
  153. * ENOMEM: (libc)Error Codes.
  154. * ENOMSG: (libc)Error Codes.
  155. * ENONET: (libc)Error Codes.
  156. * ENOPKG: (libc)Error Codes.
  157. * ENOPROTOOPT: (libc)Error Codes.
  158. * ENOSPC: (libc)Error Codes.
  159. * ENOSR: (libc)Error Codes.
  160. * ENOSTR: (libc)Error Codes.
  161. * ENOSYS: (libc)Error Codes.
  162. * ENOTBLK: (libc)Error Codes.
  163. * ENOTCONN: (libc)Error Codes.
  164. * ENOTDIR: (libc)Error Codes.
  165. * ENOTEMPTY: (libc)Error Codes.
  166. * ENOTNAM: (libc)Error Codes.
  167. * ENOTRECOVERABLE: (libc)Error Codes.
  168. * ENOTSOCK: (libc)Error Codes.
  169. * ENOTSUP: (libc)Error Codes.
  170. * ENOTTY: (libc)Error Codes.
  171. * ENOTUNIQ: (libc)Error Codes.
  172. * ENXIO: (libc)Error Codes.
  173. * EOF: (libc)EOF and Errors.
  174. * EOPNOTSUPP: (libc)Error Codes.
  175. * EOVERFLOW: (libc)Error Codes.
  176. * EOWNERDEAD: (libc)Error Codes.
  177. * EPERM: (libc)Error Codes.
  178. * EPFNOSUPPORT: (libc)Error Codes.
  179. * EPIPE: (libc)Error Codes.
  180. * EPROCLIM: (libc)Error Codes.
  181. * EPROCUNAVAIL: (libc)Error Codes.
  182. * EPROGMISMATCH: (libc)Error Codes.
  183. * EPROGUNAVAIL: (libc)Error Codes.
  184. * EPROTO: (libc)Error Codes.
  185. * EPROTONOSUPPORT: (libc)Error Codes.
  186. * EPROTOTYPE: (libc)Error Codes.
  187. * EQUIV_CLASS_MAX: (libc)Utility Limits.
  188. * ERANGE: (libc)Error Codes.
  189. * EREMCHG: (libc)Error Codes.
  190. * EREMOTE: (libc)Error Codes.
  191. * EREMOTEIO: (libc)Error Codes.
  192. * ERESTART: (libc)Error Codes.
  193. * ERFKILL: (libc)Error Codes.
  194. * EROFS: (libc)Error Codes.
  195. * ERPCMISMATCH: (libc)Error Codes.
  196. * ESHUTDOWN: (libc)Error Codes.
  197. * ESOCKTNOSUPPORT: (libc)Error Codes.
  198. * ESPIPE: (libc)Error Codes.
  199. * ESRCH: (libc)Error Codes.
  200. * ESRMNT: (libc)Error Codes.
  201. * ESTALE: (libc)Error Codes.
  202. * ESTRPIPE: (libc)Error Codes.
  203. * ETIME: (libc)Error Codes.
  204. * ETIMEDOUT: (libc)Error Codes.
  205. * ETOOMANYREFS: (libc)Error Codes.
  206. * ETXTBSY: (libc)Error Codes.
  207. * EUCLEAN: (libc)Error Codes.
  208. * EUNATCH: (libc)Error Codes.
  209. * EUSERS: (libc)Error Codes.
  210. * EWOULDBLOCK: (libc)Error Codes.
  211. * EXDEV: (libc)Error Codes.
  212. * EXFULL: (libc)Error Codes.
  213. * EXIT_FAILURE: (libc)Exit Status.
  214. * EXIT_SUCCESS: (libc)Exit Status.
  215. * EXPR_NEST_MAX: (libc)Utility Limits.
  216. * FD_CLOEXEC: (libc)Descriptor Flags.
  217. * FD_CLR: (libc)Waiting for I/O.
  218. * FD_ISSET: (libc)Waiting for I/O.
  219. * FD_SET: (libc)Waiting for I/O.
  220. * FD_SETSIZE: (libc)Waiting for I/O.
  221. * FD_ZERO: (libc)Waiting for I/O.
  222. * FE_SNANS_ALWAYS_SIGNAL: (libc)Infinity and NaN.
  223. * FILENAME_MAX: (libc)Limits for Files.
  224. * FLUSHO: (libc)Local Modes.
  225. * FOPEN_MAX: (libc)Opening Streams.
  226. * FP_ILOGB0: (libc)Exponents and Logarithms.
  227. * FP_ILOGBNAN: (libc)Exponents and Logarithms.
  228. * FP_LLOGB0: (libc)Exponents and Logarithms.
  229. * FP_LLOGBNAN: (libc)Exponents and Logarithms.
  230. * F_DUPFD: (libc)Duplicating Descriptors.
  231. * F_GETFD: (libc)Descriptor Flags.
  232. * F_GETFL: (libc)Getting File Status Flags.
  233. * F_GETLK: (libc)File Locks.
  234. * F_GETOWN: (libc)Interrupt Input.
  235. * F_OFD_GETLK: (libc)Open File Description Locks.
  236. * F_OFD_SETLK: (libc)Open File Description Locks.
  237. * F_OFD_SETLKW: (libc)Open File Description Locks.
  238. * F_OK: (libc)Testing File Access.
  239. * F_SETFD: (libc)Descriptor Flags.
  240. * F_SETFL: (libc)Getting File Status Flags.
  241. * F_SETLK: (libc)File Locks.
  242. * F_SETLKW: (libc)File Locks.
  243. * F_SETOWN: (libc)Interrupt Input.
  244. * HAS_CPU_FEATURE: (libc)X86.
  245. * HUGE_VAL: (libc)Math Error Reporting.
  246. * HUGE_VALF: (libc)Math Error Reporting.
  247. * HUGE_VALL: (libc)Math Error Reporting.
  248. * HUGE_VAL_FN: (libc)Math Error Reporting.
  249. * HUGE_VAL_FNx: (libc)Math Error Reporting.
  250. * HUPCL: (libc)Control Modes.
  251. * I: (libc)Complex Numbers.
  252. * ICANON: (libc)Local Modes.
  253. * ICRNL: (libc)Input Modes.
  254. * IEXTEN: (libc)Local Modes.
  255. * IFNAMSIZ: (libc)Interface Naming.
  256. * IFTODT: (libc)Directory Entries.
  257. * IGNBRK: (libc)Input Modes.
  258. * IGNCR: (libc)Input Modes.
  259. * IGNPAR: (libc)Input Modes.
  260. * IMAXBEL: (libc)Input Modes.
  261. * INADDR_ANY: (libc)Host Address Data Type.
  262. * INADDR_BROADCAST: (libc)Host Address Data Type.
  263. * INADDR_LOOPBACK: (libc)Host Address Data Type.
  264. * INADDR_NONE: (libc)Host Address Data Type.
  265. * INFINITY: (libc)Infinity and NaN.
  266. * INLCR: (libc)Input Modes.
  267. * INPCK: (libc)Input Modes.
  268. * IPPORT_RESERVED: (libc)Ports.
  269. * IPPORT_USERRESERVED: (libc)Ports.
  270. * ISIG: (libc)Local Modes.
  271. * ISTRIP: (libc)Input Modes.
  272. * IXANY: (libc)Input Modes.
  273. * IXOFF: (libc)Input Modes.
  274. * IXON: (libc)Input Modes.
  275. * LINE_MAX: (libc)Utility Limits.
  276. * LINK_MAX: (libc)Limits for Files.
  277. * L_ctermid: (libc)Identifying the Terminal.
  278. * L_cuserid: (libc)Who Logged In.
  279. * L_tmpnam: (libc)Temporary Files.
  280. * MAXNAMLEN: (libc)Limits for Files.
  281. * MAXSYMLINKS: (libc)Symbolic Links.
  282. * MAX_CANON: (libc)Limits for Files.
  283. * MAX_INPUT: (libc)Limits for Files.
  284. * MB_CUR_MAX: (libc)Selecting the Conversion.
  285. * MB_LEN_MAX: (libc)Selecting the Conversion.
  286. * MDMBUF: (libc)Control Modes.
  287. * MSG_DONTROUTE: (libc)Socket Data Options.
  288. * MSG_OOB: (libc)Socket Data Options.
  289. * MSG_PEEK: (libc)Socket Data Options.
  290. * NAME_MAX: (libc)Limits for Files.
  291. * NAN: (libc)Infinity and NaN.
  292. * NCCS: (libc)Mode Data Types.
  293. * NGROUPS_MAX: (libc)General Limits.
  294. * NOFLSH: (libc)Local Modes.
  295. * NOKERNINFO: (libc)Local Modes.
  296. * NSIG: (libc)Standard Signals.
  297. * NULL: (libc)Null Pointer Constant.
  298. * ONLCR: (libc)Output Modes.
  299. * ONOEOT: (libc)Output Modes.
  300. * OPEN_MAX: (libc)General Limits.
  301. * OPOST: (libc)Output Modes.
  302. * OXTABS: (libc)Output Modes.
  303. * O_ACCMODE: (libc)Access Modes.
  304. * O_APPEND: (libc)Operating Modes.
  305. * O_ASYNC: (libc)Operating Modes.
  306. * O_CREAT: (libc)Open-time Flags.
  307. * O_DIRECTORY: (libc)Open-time Flags.
  308. * O_EXCL: (libc)Open-time Flags.
  309. * O_EXEC: (libc)Access Modes.
  310. * O_EXLOCK: (libc)Open-time Flags.
  311. * O_FSYNC: (libc)Operating Modes.
  312. * O_IGNORE_CTTY: (libc)Open-time Flags.
  313. * O_NDELAY: (libc)Operating Modes.
  314. * O_NOATIME: (libc)Operating Modes.
  315. * O_NOCTTY: (libc)Open-time Flags.
  316. * O_NOFOLLOW: (libc)Open-time Flags.
  317. * O_NOLINK: (libc)Open-time Flags.
  318. * O_NONBLOCK: (libc)Open-time Flags.
  319. * O_NONBLOCK: (libc)Operating Modes.
  320. * O_NOTRANS: (libc)Open-time Flags.
  321. * O_PATH: (libc)Access Modes.
  322. * O_RDONLY: (libc)Access Modes.
  323. * O_RDWR: (libc)Access Modes.
  324. * O_READ: (libc)Access Modes.
  325. * O_SHLOCK: (libc)Open-time Flags.
  326. * O_SYNC: (libc)Operating Modes.
  327. * O_TMPFILE: (libc)Open-time Flags.
  328. * O_TRUNC: (libc)Open-time Flags.
  329. * O_WRITE: (libc)Access Modes.
  330. * O_WRONLY: (libc)Access Modes.
  331. * PARENB: (libc)Control Modes.
  332. * PARMRK: (libc)Input Modes.
  333. * PARODD: (libc)Control Modes.
  334. * PATH_MAX: (libc)Limits for Files.
  335. * PA_FLAG_MASK: (libc)Parsing a Template String.
  336. * PENDIN: (libc)Local Modes.
  337. * PF_FILE: (libc)Local Namespace Details.
  338. * PF_INET6: (libc)Internet Namespace.
  339. * PF_INET: (libc)Internet Namespace.
  340. * PF_LOCAL: (libc)Local Namespace Details.
  341. * PF_UNIX: (libc)Local Namespace Details.
  342. * PIPE_BUF: (libc)Limits for Files.
  343. * PTHREAD_ATTR_NO_SIGMASK_NP: (libc)Initial Thread Signal Mask.
  344. * P_tmpdir: (libc)Temporary Files.
  345. * RAND_MAX: (libc)ISO Random.
  346. * RE_DUP_MAX: (libc)General Limits.
  347. * RLIM_INFINITY: (libc)Limits on Resources.
  348. * R_OK: (libc)Testing File Access.
  349. * SA_NOCLDSTOP: (libc)Flags for Sigaction.
  350. * SA_ONSTACK: (libc)Flags for Sigaction.
  351. * SA_RESTART: (libc)Flags for Sigaction.
  352. * SEEK_CUR: (libc)File Positioning.
  353. * SEEK_END: (libc)File Positioning.
  354. * SEEK_SET: (libc)File Positioning.
  355. * SIGABRT: (libc)Program Error Signals.
  356. * SIGALRM: (libc)Alarm Signals.
  357. * SIGBUS: (libc)Program Error Signals.
  358. * SIGCHLD: (libc)Job Control Signals.
  359. * SIGCLD: (libc)Job Control Signals.
  360. * SIGCONT: (libc)Job Control Signals.
  361. * SIGEMT: (libc)Program Error Signals.
  362. * SIGFPE: (libc)Program Error Signals.
  363. * SIGHUP: (libc)Termination Signals.
  364. * SIGILL: (libc)Program Error Signals.
  365. * SIGINFO: (libc)Miscellaneous Signals.
  366. * SIGINT: (libc)Termination Signals.
  367. * SIGIO: (libc)Asynchronous I/O Signals.
  368. * SIGIOT: (libc)Program Error Signals.
  369. * SIGKILL: (libc)Termination Signals.
  370. * SIGLOST: (libc)Operation Error Signals.
  371. * SIGPIPE: (libc)Operation Error Signals.
  372. * SIGPOLL: (libc)Asynchronous I/O Signals.
  373. * SIGPROF: (libc)Alarm Signals.
  374. * SIGQUIT: (libc)Termination Signals.
  375. * SIGSEGV: (libc)Program Error Signals.
  376. * SIGSTOP: (libc)Job Control Signals.
  377. * SIGSYS: (libc)Program Error Signals.
  378. * SIGTERM: (libc)Termination Signals.
  379. * SIGTRAP: (libc)Program Error Signals.
  380. * SIGTSTP: (libc)Job Control Signals.
  381. * SIGTTIN: (libc)Job Control Signals.
  382. * SIGTTOU: (libc)Job Control Signals.
  383. * SIGURG: (libc)Asynchronous I/O Signals.
  384. * SIGUSR1: (libc)Miscellaneous Signals.
  385. * SIGUSR2: (libc)Miscellaneous Signals.
  386. * SIGVTALRM: (libc)Alarm Signals.
  387. * SIGWINCH: (libc)Miscellaneous Signals.
  388. * SIGXCPU: (libc)Operation Error Signals.
  389. * SIGXFSZ: (libc)Operation Error Signals.
  390. * SIG_ERR: (libc)Basic Signal Handling.
  391. * SNAN: (libc)Infinity and NaN.
  392. * SNANF: (libc)Infinity and NaN.
  393. * SNANFN: (libc)Infinity and NaN.
  394. * SNANFNx: (libc)Infinity and NaN.
  395. * SNANL: (libc)Infinity and NaN.
  396. * SOCK_DGRAM: (libc)Communication Styles.
  397. * SOCK_RAW: (libc)Communication Styles.
  398. * SOCK_RDM: (libc)Communication Styles.
  399. * SOCK_SEQPACKET: (libc)Communication Styles.
  400. * SOCK_STREAM: (libc)Communication Styles.
  401. * SOL_SOCKET: (libc)Socket-Level Options.
  402. * SSIZE_MAX: (libc)General Limits.
  403. * STREAM_MAX: (libc)General Limits.
  404. * SUN_LEN: (libc)Local Namespace Details.
  405. * S_IFMT: (libc)Testing File Type.
  406. * S_ISBLK: (libc)Testing File Type.
  407. * S_ISCHR: (libc)Testing File Type.
  408. * S_ISDIR: (libc)Testing File Type.
  409. * S_ISFIFO: (libc)Testing File Type.
  410. * S_ISLNK: (libc)Testing File Type.
  411. * S_ISREG: (libc)Testing File Type.
  412. * S_ISSOCK: (libc)Testing File Type.
  413. * S_TYPEISMQ: (libc)Testing File Type.
  414. * S_TYPEISSEM: (libc)Testing File Type.
  415. * S_TYPEISSHM: (libc)Testing File Type.
  416. * TMP_MAX: (libc)Temporary Files.
  417. * TOSTOP: (libc)Local Modes.
  418. * TZNAME_MAX: (libc)General Limits.
  419. * VDISCARD: (libc)Other Special.
  420. * VDSUSP: (libc)Signal Characters.
  421. * VEOF: (libc)Editing Characters.
  422. * VEOL2: (libc)Editing Characters.
  423. * VEOL: (libc)Editing Characters.
  424. * VERASE: (libc)Editing Characters.
  425. * VINTR: (libc)Signal Characters.
  426. * VKILL: (libc)Editing Characters.
  427. * VLNEXT: (libc)Other Special.
  428. * VMIN: (libc)Noncanonical Input.
  429. * VQUIT: (libc)Signal Characters.
  430. * VREPRINT: (libc)Editing Characters.
  431. * VSTART: (libc)Start/Stop Characters.
  432. * VSTATUS: (libc)Other Special.
  433. * VSTOP: (libc)Start/Stop Characters.
  434. * VSUSP: (libc)Signal Characters.
  435. * VTIME: (libc)Noncanonical Input.
  436. * VWERASE: (libc)Editing Characters.
  437. * WCHAR_MAX: (libc)Extended Char Intro.
  438. * WCHAR_MIN: (libc)Extended Char Intro.
  439. * WCOREDUMP: (libc)Process Completion Status.
  440. * WEOF: (libc)EOF and Errors.
  441. * WEOF: (libc)Extended Char Intro.
  442. * WEXITSTATUS: (libc)Process Completion Status.
  443. * WIFEXITED: (libc)Process Completion Status.
  444. * WIFSIGNALED: (libc)Process Completion Status.
  445. * WIFSTOPPED: (libc)Process Completion Status.
  446. * WSTOPSIG: (libc)Process Completion Status.
  447. * WTERMSIG: (libc)Process Completion Status.
  448. * W_OK: (libc)Testing File Access.
  449. * X_OK: (libc)Testing File Access.
  450. * _Complex_I: (libc)Complex Numbers.
  451. * _Exit: (libc)Termination Internals.
  452. * _IOFBF: (libc)Controlling Buffering.
  453. * _IOLBF: (libc)Controlling Buffering.
  454. * _IONBF: (libc)Controlling Buffering.
  455. * _Imaginary_I: (libc)Complex Numbers.
  456. * _PATH_UTMP: (libc)Manipulating the Database.
  457. * _PATH_WTMP: (libc)Manipulating the Database.
  458. * _POSIX2_C_DEV: (libc)System Options.
  459. * _POSIX2_C_VERSION: (libc)Version Supported.
  460. * _POSIX2_FORT_DEV: (libc)System Options.
  461. * _POSIX2_FORT_RUN: (libc)System Options.
  462. * _POSIX2_LOCALEDEF: (libc)System Options.
  463. * _POSIX2_SW_DEV: (libc)System Options.
  464. * _POSIX_CHOWN_RESTRICTED: (libc)Options for Files.
  465. * _POSIX_JOB_CONTROL: (libc)System Options.
  466. * _POSIX_NO_TRUNC: (libc)Options for Files.
  467. * _POSIX_SAVED_IDS: (libc)System Options.
  468. * _POSIX_VDISABLE: (libc)Options for Files.
  469. * _POSIX_VERSION: (libc)Version Supported.
  470. * __fbufsize: (libc)Controlling Buffering.
  471. * __flbf: (libc)Controlling Buffering.
  472. * __fpending: (libc)Controlling Buffering.
  473. * __fpurge: (libc)Flushing Buffers.
  474. * __freadable: (libc)Opening Streams.
  475. * __freading: (libc)Opening Streams.
  476. * __fsetlocking: (libc)Streams and Threads.
  477. * __fwritable: (libc)Opening Streams.
  478. * __fwriting: (libc)Opening Streams.
  479. * __gconv_end_fct: (libc)glibc iconv Implementation.
  480. * __gconv_fct: (libc)glibc iconv Implementation.
  481. * __gconv_init_fct: (libc)glibc iconv Implementation.
  482. * __ppc_get_timebase: (libc)PowerPC.
  483. * __ppc_get_timebase_freq: (libc)PowerPC.
  484. * __ppc_mdoio: (libc)PowerPC.
  485. * __ppc_mdoom: (libc)PowerPC.
  486. * __ppc_set_ppr_low: (libc)PowerPC.
  487. * __ppc_set_ppr_med: (libc)PowerPC.
  488. * __ppc_set_ppr_med_high: (libc)PowerPC.
  489. * __ppc_set_ppr_med_low: (libc)PowerPC.
  490. * __ppc_set_ppr_very_low: (libc)PowerPC.
  491. * __ppc_yield: (libc)PowerPC.
  492. * __riscv_flush_icache: (libc)RISC-V.
  493. * __va_copy: (libc)Argument Macros.
  494. * __x86_get_cpuid_feature_leaf: (libc)X86.
  495. * _exit: (libc)Termination Internals.
  496. * _flushlbf: (libc)Flushing Buffers.
  497. * _tolower: (libc)Case Conversion.
  498. * _toupper: (libc)Case Conversion.
  499. * a64l: (libc)Encode Binary Data.
  500. * abort: (libc)Aborting a Program.
  501. * abs: (libc)Absolute Value.
  502. * accept: (libc)Accepting Connections.
  503. * access: (libc)Testing File Access.
  504. * acos: (libc)Inverse Trig Functions.
  505. * acosf: (libc)Inverse Trig Functions.
  506. * acosfN: (libc)Inverse Trig Functions.
  507. * acosfNx: (libc)Inverse Trig Functions.
  508. * acosh: (libc)Hyperbolic Functions.
  509. * acoshf: (libc)Hyperbolic Functions.
  510. * acoshfN: (libc)Hyperbolic Functions.
  511. * acoshfNx: (libc)Hyperbolic Functions.
  512. * acoshl: (libc)Hyperbolic Functions.
  513. * acosl: (libc)Inverse Trig Functions.
  514. * addmntent: (libc)mtab.
  515. * addseverity: (libc)Adding Severity Classes.
  516. * adjtime: (libc)Setting and Adjusting the Time.
  517. * adjtimex: (libc)Setting and Adjusting the Time.
  518. * aio_cancel64: (libc)Cancel AIO Operations.
  519. * aio_cancel: (libc)Cancel AIO Operations.
  520. * aio_error64: (libc)Status of AIO Operations.
  521. * aio_error: (libc)Status of AIO Operations.
  522. * aio_fsync64: (libc)Synchronizing AIO Operations.
  523. * aio_fsync: (libc)Synchronizing AIO Operations.
  524. * aio_init: (libc)Configuration of AIO.
  525. * aio_read64: (libc)Asynchronous Reads/Writes.
  526. * aio_read: (libc)Asynchronous Reads/Writes.
  527. * aio_return64: (libc)Status of AIO Operations.
  528. * aio_return: (libc)Status of AIO Operations.
  529. * aio_suspend64: (libc)Synchronizing AIO Operations.
  530. * aio_suspend: (libc)Synchronizing AIO Operations.
  531. * aio_write64: (libc)Asynchronous Reads/Writes.
  532. * aio_write: (libc)Asynchronous Reads/Writes.
  533. * alarm: (libc)Setting an Alarm.
  534. * aligned_alloc: (libc)Aligned Memory Blocks.
  535. * alloca: (libc)Variable Size Automatic.
  536. * alphasort64: (libc)Scanning Directory Content.
  537. * alphasort: (libc)Scanning Directory Content.
  538. * argp_error: (libc)Argp Helper Functions.
  539. * argp_failure: (libc)Argp Helper Functions.
  540. * argp_help: (libc)Argp Help.
  541. * argp_parse: (libc)Argp.
  542. * argp_state_help: (libc)Argp Helper Functions.
  543. * argp_usage: (libc)Argp Helper Functions.
  544. * argz_add: (libc)Argz Functions.
  545. * argz_add_sep: (libc)Argz Functions.
  546. * argz_append: (libc)Argz Functions.
  547. * argz_count: (libc)Argz Functions.
  548. * argz_create: (libc)Argz Functions.
  549. * argz_create_sep: (libc)Argz Functions.
  550. * argz_delete: (libc)Argz Functions.
  551. * argz_extract: (libc)Argz Functions.
  552. * argz_insert: (libc)Argz Functions.
  553. * argz_next: (libc)Argz Functions.
  554. * argz_replace: (libc)Argz Functions.
  555. * argz_stringify: (libc)Argz Functions.
  556. * asctime: (libc)Formatting Calendar Time.
  557. * asctime_r: (libc)Formatting Calendar Time.
  558. * asin: (libc)Inverse Trig Functions.
  559. * asinf: (libc)Inverse Trig Functions.
  560. * asinfN: (libc)Inverse Trig Functions.
  561. * asinfNx: (libc)Inverse Trig Functions.
  562. * asinh: (libc)Hyperbolic Functions.
  563. * asinhf: (libc)Hyperbolic Functions.
  564. * asinhfN: (libc)Hyperbolic Functions.
  565. * asinhfNx: (libc)Hyperbolic Functions.
  566. * asinhl: (libc)Hyperbolic Functions.
  567. * asinl: (libc)Inverse Trig Functions.
  568. * asprintf: (libc)Dynamic Output.
  569. * assert: (libc)Consistency Checking.
  570. * assert_perror: (libc)Consistency Checking.
  571. * atan2: (libc)Inverse Trig Functions.
  572. * atan2f: (libc)Inverse Trig Functions.
  573. * atan2fN: (libc)Inverse Trig Functions.
  574. * atan2fNx: (libc)Inverse Trig Functions.
  575. * atan2l: (libc)Inverse Trig Functions.
  576. * atan: (libc)Inverse Trig Functions.
  577. * atanf: (libc)Inverse Trig Functions.
  578. * atanfN: (libc)Inverse Trig Functions.
  579. * atanfNx: (libc)Inverse Trig Functions.
  580. * atanh: (libc)Hyperbolic Functions.
  581. * atanhf: (libc)Hyperbolic Functions.
  582. * atanhfN: (libc)Hyperbolic Functions.
  583. * atanhfNx: (libc)Hyperbolic Functions.
  584. * atanhl: (libc)Hyperbolic Functions.
  585. * atanl: (libc)Inverse Trig Functions.
  586. * atexit: (libc)Cleanups on Exit.
  587. * atof: (libc)Parsing of Floats.
  588. * atoi: (libc)Parsing of Integers.
  589. * atol: (libc)Parsing of Integers.
  590. * atoll: (libc)Parsing of Integers.
  591. * backtrace: (libc)Backtraces.
  592. * backtrace_symbols: (libc)Backtraces.
  593. * backtrace_symbols_fd: (libc)Backtraces.
  594. * basename: (libc)Finding Tokens in a String.
  595. * basename: (libc)Finding Tokens in a String.
  596. * bcmp: (libc)String/Array Comparison.
  597. * bcopy: (libc)Copying Strings and Arrays.
  598. * bind: (libc)Setting Address.
  599. * bind_textdomain_codeset: (libc)Charset conversion in gettext.
  600. * bindtextdomain: (libc)Locating gettext catalog.
  601. * brk: (libc)Resizing the Data Segment.
  602. * bsearch: (libc)Array Search Function.
  603. * btowc: (libc)Converting a Character.
  604. * bzero: (libc)Copying Strings and Arrays.
  605. * cabs: (libc)Absolute Value.
  606. * cabsf: (libc)Absolute Value.
  607. * cabsfN: (libc)Absolute Value.
  608. * cabsfNx: (libc)Absolute Value.
  609. * cabsl: (libc)Absolute Value.
  610. * cacos: (libc)Inverse Trig Functions.
  611. * cacosf: (libc)Inverse Trig Functions.
  612. * cacosfN: (libc)Inverse Trig Functions.
  613. * cacosfNx: (libc)Inverse Trig Functions.
  614. * cacosh: (libc)Hyperbolic Functions.
  615. * cacoshf: (libc)Hyperbolic Functions.
  616. * cacoshfN: (libc)Hyperbolic Functions.
  617. * cacoshfNx: (libc)Hyperbolic Functions.
  618. * cacoshl: (libc)Hyperbolic Functions.
  619. * cacosl: (libc)Inverse Trig Functions.
  620. * call_once: (libc)Call Once.
  621. * calloc: (libc)Allocating Cleared Space.
  622. * canonicalize: (libc)FP Bit Twiddling.
  623. * canonicalize_file_name: (libc)Symbolic Links.
  624. * canonicalizef: (libc)FP Bit Twiddling.
  625. * canonicalizefN: (libc)FP Bit Twiddling.
  626. * canonicalizefNx: (libc)FP Bit Twiddling.
  627. * canonicalizel: (libc)FP Bit Twiddling.
  628. * carg: (libc)Operations on Complex.
  629. * cargf: (libc)Operations on Complex.
  630. * cargfN: (libc)Operations on Complex.
  631. * cargfNx: (libc)Operations on Complex.
  632. * cargl: (libc)Operations on Complex.
  633. * casin: (libc)Inverse Trig Functions.
  634. * casinf: (libc)Inverse Trig Functions.
  635. * casinfN: (libc)Inverse Trig Functions.
  636. * casinfNx: (libc)Inverse Trig Functions.
  637. * casinh: (libc)Hyperbolic Functions.
  638. * casinhf: (libc)Hyperbolic Functions.
  639. * casinhfN: (libc)Hyperbolic Functions.
  640. * casinhfNx: (libc)Hyperbolic Functions.
  641. * casinhl: (libc)Hyperbolic Functions.
  642. * casinl: (libc)Inverse Trig Functions.
  643. * catan: (libc)Inverse Trig Functions.
  644. * catanf: (libc)Inverse Trig Functions.
  645. * catanfN: (libc)Inverse Trig Functions.
  646. * catanfNx: (libc)Inverse Trig Functions.
  647. * catanh: (libc)Hyperbolic Functions.
  648. * catanhf: (libc)Hyperbolic Functions.
  649. * catanhfN: (libc)Hyperbolic Functions.
  650. * catanhfNx: (libc)Hyperbolic Functions.
  651. * catanhl: (libc)Hyperbolic Functions.
  652. * catanl: (libc)Inverse Trig Functions.
  653. * catclose: (libc)The catgets Functions.
  654. * catgets: (libc)The catgets Functions.
  655. * catopen: (libc)The catgets Functions.
  656. * cbrt: (libc)Exponents and Logarithms.
  657. * cbrtf: (libc)Exponents and Logarithms.
  658. * cbrtfN: (libc)Exponents and Logarithms.
  659. * cbrtfNx: (libc)Exponents and Logarithms.
  660. * cbrtl: (libc)Exponents and Logarithms.
  661. * ccos: (libc)Trig Functions.
  662. * ccosf: (libc)Trig Functions.
  663. * ccosfN: (libc)Trig Functions.
  664. * ccosfNx: (libc)Trig Functions.
  665. * ccosh: (libc)Hyperbolic Functions.
  666. * ccoshf: (libc)Hyperbolic Functions.
  667. * ccoshfN: (libc)Hyperbolic Functions.
  668. * ccoshfNx: (libc)Hyperbolic Functions.
  669. * ccoshl: (libc)Hyperbolic Functions.
  670. * ccosl: (libc)Trig Functions.
  671. * ceil: (libc)Rounding Functions.
  672. * ceilf: (libc)Rounding Functions.
  673. * ceilfN: (libc)Rounding Functions.
  674. * ceilfNx: (libc)Rounding Functions.
  675. * ceill: (libc)Rounding Functions.
  676. * cexp: (libc)Exponents and Logarithms.
  677. * cexpf: (libc)Exponents and Logarithms.
  678. * cexpfN: (libc)Exponents and Logarithms.
  679. * cexpfNx: (libc)Exponents and Logarithms.
  680. * cexpl: (libc)Exponents and Logarithms.
  681. * cfgetispeed: (libc)Line Speed.
  682. * cfgetospeed: (libc)Line Speed.
  683. * cfmakeraw: (libc)Noncanonical Input.
  684. * cfsetispeed: (libc)Line Speed.
  685. * cfsetospeed: (libc)Line Speed.
  686. * cfsetspeed: (libc)Line Speed.
  687. * chdir: (libc)Working Directory.
  688. * chmod: (libc)Setting Permissions.
  689. * chown: (libc)File Owner.
  690. * cimag: (libc)Operations on Complex.
  691. * cimagf: (libc)Operations on Complex.
  692. * cimagfN: (libc)Operations on Complex.
  693. * cimagfNx: (libc)Operations on Complex.
  694. * cimagl: (libc)Operations on Complex.
  695. * clearenv: (libc)Environment Access.
  696. * clearerr: (libc)Error Recovery.
  697. * clearerr_unlocked: (libc)Error Recovery.
  698. * clock: (libc)CPU Time.
  699. * clock_getres: (libc)Getting the Time.
  700. * clock_gettime: (libc)Getting the Time.
  701. * clock_settime: (libc)Setting and Adjusting the Time.
  702. * clog10: (libc)Exponents and Logarithms.
  703. * clog10f: (libc)Exponents and Logarithms.
  704. * clog10fN: (libc)Exponents and Logarithms.
  705. * clog10fNx: (libc)Exponents and Logarithms.
  706. * clog10l: (libc)Exponents and Logarithms.
  707. * clog: (libc)Exponents and Logarithms.
  708. * clogf: (libc)Exponents and Logarithms.
  709. * clogfN: (libc)Exponents and Logarithms.
  710. * clogfNx: (libc)Exponents and Logarithms.
  711. * clogl: (libc)Exponents and Logarithms.
  712. * close: (libc)Opening and Closing Files.
  713. * closedir: (libc)Reading/Closing Directory.
  714. * closelog: (libc)closelog.
  715. * cnd_broadcast: (libc)ISO C Condition Variables.
  716. * cnd_destroy: (libc)ISO C Condition Variables.
  717. * cnd_init: (libc)ISO C Condition Variables.
  718. * cnd_signal: (libc)ISO C Condition Variables.
  719. * cnd_timedwait: (libc)ISO C Condition Variables.
  720. * cnd_wait: (libc)ISO C Condition Variables.
  721. * confstr: (libc)String Parameters.
  722. * conj: (libc)Operations on Complex.
  723. * conjf: (libc)Operations on Complex.
  724. * conjfN: (libc)Operations on Complex.
  725. * conjfNx: (libc)Operations on Complex.
  726. * conjl: (libc)Operations on Complex.
  727. * connect: (libc)Connecting.
  728. * copy_file_range: (libc)Copying File Data.
  729. * copysign: (libc)FP Bit Twiddling.
  730. * copysignf: (libc)FP Bit Twiddling.
  731. * copysignfN: (libc)FP Bit Twiddling.
  732. * copysignfNx: (libc)FP Bit Twiddling.
  733. * copysignl: (libc)FP Bit Twiddling.
  734. * cos: (libc)Trig Functions.
  735. * cosf: (libc)Trig Functions.
  736. * cosfN: (libc)Trig Functions.
  737. * cosfNx: (libc)Trig Functions.
  738. * cosh: (libc)Hyperbolic Functions.
  739. * coshf: (libc)Hyperbolic Functions.
  740. * coshfN: (libc)Hyperbolic Functions.
  741. * coshfNx: (libc)Hyperbolic Functions.
  742. * coshl: (libc)Hyperbolic Functions.
  743. * cosl: (libc)Trig Functions.
  744. * cpow: (libc)Exponents and Logarithms.
  745. * cpowf: (libc)Exponents and Logarithms.
  746. * cpowfN: (libc)Exponents and Logarithms.
  747. * cpowfNx: (libc)Exponents and Logarithms.
  748. * cpowl: (libc)Exponents and Logarithms.
  749. * cproj: (libc)Operations on Complex.
  750. * cprojf: (libc)Operations on Complex.
  751. * cprojfN: (libc)Operations on Complex.
  752. * cprojfNx: (libc)Operations on Complex.
  753. * cprojl: (libc)Operations on Complex.
  754. * creal: (libc)Operations on Complex.
  755. * crealf: (libc)Operations on Complex.
  756. * crealfN: (libc)Operations on Complex.
  757. * crealfNx: (libc)Operations on Complex.
  758. * creall: (libc)Operations on Complex.
  759. * creat64: (libc)Opening and Closing Files.
  760. * creat: (libc)Opening and Closing Files.
  761. * crypt: (libc)Passphrase Storage.
  762. * crypt_r: (libc)Passphrase Storage.
  763. * csin: (libc)Trig Functions.
  764. * csinf: (libc)Trig Functions.
  765. * csinfN: (libc)Trig Functions.
  766. * csinfNx: (libc)Trig Functions.
  767. * csinh: (libc)Hyperbolic Functions.
  768. * csinhf: (libc)Hyperbolic Functions.
  769. * csinhfN: (libc)Hyperbolic Functions.
  770. * csinhfNx: (libc)Hyperbolic Functions.
  771. * csinhl: (libc)Hyperbolic Functions.
  772. * csinl: (libc)Trig Functions.
  773. * csqrt: (libc)Exponents and Logarithms.
  774. * csqrtf: (libc)Exponents and Logarithms.
  775. * csqrtfN: (libc)Exponents and Logarithms.
  776. * csqrtfNx: (libc)Exponents and Logarithms.
  777. * csqrtl: (libc)Exponents and Logarithms.
  778. * ctan: (libc)Trig Functions.
  779. * ctanf: (libc)Trig Functions.
  780. * ctanfN: (libc)Trig Functions.
  781. * ctanfNx: (libc)Trig Functions.
  782. * ctanh: (libc)Hyperbolic Functions.
  783. * ctanhf: (libc)Hyperbolic Functions.
  784. * ctanhfN: (libc)Hyperbolic Functions.
  785. * ctanhfNx: (libc)Hyperbolic Functions.
  786. * ctanhl: (libc)Hyperbolic Functions.
  787. * ctanl: (libc)Trig Functions.
  788. * ctermid: (libc)Identifying the Terminal.
  789. * ctime: (libc)Formatting Calendar Time.
  790. * ctime_r: (libc)Formatting Calendar Time.
  791. * cuserid: (libc)Who Logged In.
  792. * daddl: (libc)Misc FP Arithmetic.
  793. * dcgettext: (libc)Translation with gettext.
  794. * dcngettext: (libc)Advanced gettext functions.
  795. * ddivl: (libc)Misc FP Arithmetic.
  796. * dgettext: (libc)Translation with gettext.
  797. * difftime: (libc)Calculating Elapsed Time.
  798. * dirfd: (libc)Opening a Directory.
  799. * dirname: (libc)Finding Tokens in a String.
  800. * div: (libc)Integer Division.
  801. * dmull: (libc)Misc FP Arithmetic.
  802. * dngettext: (libc)Advanced gettext functions.
  803. * drand48: (libc)SVID Random.
  804. * drand48_r: (libc)SVID Random.
  805. * drem: (libc)Remainder Functions.
  806. * dremf: (libc)Remainder Functions.
  807. * dreml: (libc)Remainder Functions.
  808. * dsubl: (libc)Misc FP Arithmetic.
  809. * dup2: (libc)Duplicating Descriptors.
  810. * dup: (libc)Duplicating Descriptors.
  811. * ecvt: (libc)System V Number Conversion.
  812. * ecvt_r: (libc)System V Number Conversion.
  813. * endfsent: (libc)fstab.
  814. * endgrent: (libc)Scanning All Groups.
  815. * endhostent: (libc)Host Names.
  816. * endmntent: (libc)mtab.
  817. * endnetent: (libc)Networks Database.
  818. * endnetgrent: (libc)Lookup Netgroup.
  819. * endprotoent: (libc)Protocols Database.
  820. * endpwent: (libc)Scanning All Users.
  821. * endservent: (libc)Services Database.
  822. * endutent: (libc)Manipulating the Database.
  823. * endutxent: (libc)XPG Functions.
  824. * envz_add: (libc)Envz Functions.
  825. * envz_entry: (libc)Envz Functions.
  826. * envz_get: (libc)Envz Functions.
  827. * envz_merge: (libc)Envz Functions.
  828. * envz_remove: (libc)Envz Functions.
  829. * envz_strip: (libc)Envz Functions.
  830. * erand48: (libc)SVID Random.
  831. * erand48_r: (libc)SVID Random.
  832. * erf: (libc)Special Functions.
  833. * erfc: (libc)Special Functions.
  834. * erfcf: (libc)Special Functions.
  835. * erfcfN: (libc)Special Functions.
  836. * erfcfNx: (libc)Special Functions.
  837. * erfcl: (libc)Special Functions.
  838. * erff: (libc)Special Functions.
  839. * erffN: (libc)Special Functions.
  840. * erffNx: (libc)Special Functions.
  841. * erfl: (libc)Special Functions.
  842. * err: (libc)Error Messages.
  843. * errno: (libc)Checking for Errors.
  844. * error: (libc)Error Messages.
  845. * error_at_line: (libc)Error Messages.
  846. * errx: (libc)Error Messages.
  847. * execl: (libc)Executing a File.
  848. * execle: (libc)Executing a File.
  849. * execlp: (libc)Executing a File.
  850. * execv: (libc)Executing a File.
  851. * execve: (libc)Executing a File.
  852. * execvp: (libc)Executing a File.
  853. * exit: (libc)Normal Termination.
  854. * exp10: (libc)Exponents and Logarithms.
  855. * exp10f: (libc)Exponents and Logarithms.
  856. * exp10fN: (libc)Exponents and Logarithms.
  857. * exp10fNx: (libc)Exponents and Logarithms.
  858. * exp10l: (libc)Exponents and Logarithms.
  859. * exp2: (libc)Exponents and Logarithms.
  860. * exp2f: (libc)Exponents and Logarithms.
  861. * exp2fN: (libc)Exponents and Logarithms.
  862. * exp2fNx: (libc)Exponents and Logarithms.
  863. * exp2l: (libc)Exponents and Logarithms.
  864. * exp: (libc)Exponents and Logarithms.
  865. * expf: (libc)Exponents and Logarithms.
  866. * expfN: (libc)Exponents and Logarithms.
  867. * expfNx: (libc)Exponents and Logarithms.
  868. * expl: (libc)Exponents and Logarithms.
  869. * explicit_bzero: (libc)Erasing Sensitive Data.
  870. * expm1: (libc)Exponents and Logarithms.
  871. * expm1f: (libc)Exponents and Logarithms.
  872. * expm1fN: (libc)Exponents and Logarithms.
  873. * expm1fNx: (libc)Exponents and Logarithms.
  874. * expm1l: (libc)Exponents and Logarithms.
  875. * fMaddfN: (libc)Misc FP Arithmetic.
  876. * fMaddfNx: (libc)Misc FP Arithmetic.
  877. * fMdivfN: (libc)Misc FP Arithmetic.
  878. * fMdivfNx: (libc)Misc FP Arithmetic.
  879. * fMmulfN: (libc)Misc FP Arithmetic.
  880. * fMmulfNx: (libc)Misc FP Arithmetic.
  881. * fMsubfN: (libc)Misc FP Arithmetic.
  882. * fMsubfNx: (libc)Misc FP Arithmetic.
  883. * fMxaddfN: (libc)Misc FP Arithmetic.
  884. * fMxaddfNx: (libc)Misc FP Arithmetic.
  885. * fMxdivfN: (libc)Misc FP Arithmetic.
  886. * fMxdivfNx: (libc)Misc FP Arithmetic.
  887. * fMxmulfN: (libc)Misc FP Arithmetic.
  888. * fMxmulfNx: (libc)Misc FP Arithmetic.
  889. * fMxsubfN: (libc)Misc FP Arithmetic.
  890. * fMxsubfNx: (libc)Misc FP Arithmetic.
  891. * fabs: (libc)Absolute Value.
  892. * fabsf: (libc)Absolute Value.
  893. * fabsfN: (libc)Absolute Value.
  894. * fabsfNx: (libc)Absolute Value.
  895. * fabsl: (libc)Absolute Value.
  896. * fadd: (libc)Misc FP Arithmetic.
  897. * faddl: (libc)Misc FP Arithmetic.
  898. * fchdir: (libc)Working Directory.
  899. * fchmod: (libc)Setting Permissions.
  900. * fchown: (libc)File Owner.
  901. * fclose: (libc)Closing Streams.
  902. * fcloseall: (libc)Closing Streams.
  903. * fcntl: (libc)Control Operations.
  904. * fcvt: (libc)System V Number Conversion.
  905. * fcvt_r: (libc)System V Number Conversion.
  906. * fdatasync: (libc)Synchronizing I/O.
  907. * fdim: (libc)Misc FP Arithmetic.
  908. * fdimf: (libc)Misc FP Arithmetic.
  909. * fdimfN: (libc)Misc FP Arithmetic.
  910. * fdimfNx: (libc)Misc FP Arithmetic.
  911. * fdiml: (libc)Misc FP Arithmetic.
  912. * fdiv: (libc)Misc FP Arithmetic.
  913. * fdivl: (libc)Misc FP Arithmetic.
  914. * fdopen: (libc)Descriptors and Streams.
  915. * fdopendir: (libc)Opening a Directory.
  916. * feclearexcept: (libc)Status bit operations.
  917. * fedisableexcept: (libc)Control Functions.
  918. * feenableexcept: (libc)Control Functions.
  919. * fegetenv: (libc)Control Functions.
  920. * fegetexcept: (libc)Control Functions.
  921. * fegetexceptflag: (libc)Status bit operations.
  922. * fegetmode: (libc)Control Functions.
  923. * fegetround: (libc)Rounding.
  924. * feholdexcept: (libc)Control Functions.
  925. * feof: (libc)EOF and Errors.
  926. * feof_unlocked: (libc)EOF and Errors.
  927. * feraiseexcept: (libc)Status bit operations.
  928. * ferror: (libc)EOF and Errors.
  929. * ferror_unlocked: (libc)EOF and Errors.
  930. * fesetenv: (libc)Control Functions.
  931. * fesetexcept: (libc)Status bit operations.
  932. * fesetexceptflag: (libc)Status bit operations.
  933. * fesetmode: (libc)Control Functions.
  934. * fesetround: (libc)Rounding.
  935. * fetestexcept: (libc)Status bit operations.
  936. * fetestexceptflag: (libc)Status bit operations.
  937. * feupdateenv: (libc)Control Functions.
  938. * fexecve: (libc)Executing a File.
  939. * fflush: (libc)Flushing Buffers.
  940. * fflush_unlocked: (libc)Flushing Buffers.
  941. * fgetc: (libc)Character Input.
  942. * fgetc_unlocked: (libc)Character Input.
  943. * fgetgrent: (libc)Scanning All Groups.
  944. * fgetgrent_r: (libc)Scanning All Groups.
  945. * fgetpos64: (libc)Portable Positioning.
  946. * fgetpos: (libc)Portable Positioning.
  947. * fgetpwent: (libc)Scanning All Users.
  948. * fgetpwent_r: (libc)Scanning All Users.
  949. * fgets: (libc)Line Input.
  950. * fgets_unlocked: (libc)Line Input.
  951. * fgetwc: (libc)Character Input.
  952. * fgetwc_unlocked: (libc)Character Input.
  953. * fgetws: (libc)Line Input.
  954. * fgetws_unlocked: (libc)Line Input.
  955. * fileno: (libc)Descriptors and Streams.
  956. * fileno_unlocked: (libc)Descriptors and Streams.
  957. * finite: (libc)Floating Point Classes.
  958. * finitef: (libc)Floating Point Classes.
  959. * finitel: (libc)Floating Point Classes.
  960. * flockfile: (libc)Streams and Threads.
  961. * floor: (libc)Rounding Functions.
  962. * floorf: (libc)Rounding Functions.
  963. * floorfN: (libc)Rounding Functions.
  964. * floorfNx: (libc)Rounding Functions.
  965. * floorl: (libc)Rounding Functions.
  966. * fma: (libc)Misc FP Arithmetic.
  967. * fmaf: (libc)Misc FP Arithmetic.
  968. * fmafN: (libc)Misc FP Arithmetic.
  969. * fmafNx: (libc)Misc FP Arithmetic.
  970. * fmal: (libc)Misc FP Arithmetic.
  971. * fmax: (libc)Misc FP Arithmetic.
  972. * fmaxf: (libc)Misc FP Arithmetic.
  973. * fmaxfN: (libc)Misc FP Arithmetic.
  974. * fmaxfNx: (libc)Misc FP Arithmetic.
  975. * fmaxl: (libc)Misc FP Arithmetic.
  976. * fmaxmag: (libc)Misc FP Arithmetic.
  977. * fmaxmagf: (libc)Misc FP Arithmetic.
  978. * fmaxmagfN: (libc)Misc FP Arithmetic.
  979. * fmaxmagfNx: (libc)Misc FP Arithmetic.
  980. * fmaxmagl: (libc)Misc FP Arithmetic.
  981. * fmemopen: (libc)String Streams.
  982. * fmin: (libc)Misc FP Arithmetic.
  983. * fminf: (libc)Misc FP Arithmetic.
  984. * fminfN: (libc)Misc FP Arithmetic.
  985. * fminfNx: (libc)Misc FP Arithmetic.
  986. * fminl: (libc)Misc FP Arithmetic.
  987. * fminmag: (libc)Misc FP Arithmetic.
  988. * fminmagf: (libc)Misc FP Arithmetic.
  989. * fminmagfN: (libc)Misc FP Arithmetic.
  990. * fminmagfNx: (libc)Misc FP Arithmetic.
  991. * fminmagl: (libc)Misc FP Arithmetic.
  992. * fmod: (libc)Remainder Functions.
  993. * fmodf: (libc)Remainder Functions.
  994. * fmodfN: (libc)Remainder Functions.
  995. * fmodfNx: (libc)Remainder Functions.
  996. * fmodl: (libc)Remainder Functions.
  997. * fmtmsg: (libc)Printing Formatted Messages.
  998. * fmul: (libc)Misc FP Arithmetic.
  999. * fmull: (libc)Misc FP Arithmetic.
  1000. * fnmatch: (libc)Wildcard Matching.
  1001. * fopen64: (libc)Opening Streams.
  1002. * fopen: (libc)Opening Streams.
  1003. * fopencookie: (libc)Streams and Cookies.
  1004. * fork: (libc)Creating a Process.
  1005. * forkpty: (libc)Pseudo-Terminal Pairs.
  1006. * fpathconf: (libc)Pathconf.
  1007. * fpclassify: (libc)Floating Point Classes.
  1008. * fprintf: (libc)Formatted Output Functions.
  1009. * fputc: (libc)Simple Output.
  1010. * fputc_unlocked: (libc)Simple Output.
  1011. * fputs: (libc)Simple Output.
  1012. * fputs_unlocked: (libc)Simple Output.
  1013. * fputwc: (libc)Simple Output.
  1014. * fputwc_unlocked: (libc)Simple Output.
  1015. * fputws: (libc)Simple Output.
  1016. * fputws_unlocked: (libc)Simple Output.
  1017. * fread: (libc)Block Input/Output.
  1018. * fread_unlocked: (libc)Block Input/Output.
  1019. * free: (libc)Freeing after Malloc.
  1020. * freopen64: (libc)Opening Streams.
  1021. * freopen: (libc)Opening Streams.
  1022. * frexp: (libc)Normalization Functions.
  1023. * frexpf: (libc)Normalization Functions.
  1024. * frexpfN: (libc)Normalization Functions.
  1025. * frexpfNx: (libc)Normalization Functions.
  1026. * frexpl: (libc)Normalization Functions.
  1027. * fromfp: (libc)Rounding Functions.
  1028. * fromfpf: (libc)Rounding Functions.
  1029. * fromfpfN: (libc)Rounding Functions.
  1030. * fromfpfNx: (libc)Rounding Functions.
  1031. * fromfpl: (libc)Rounding Functions.
  1032. * fromfpx: (libc)Rounding Functions.
  1033. * fromfpxf: (libc)Rounding Functions.
  1034. * fromfpxfN: (libc)Rounding Functions.
  1035. * fromfpxfNx: (libc)Rounding Functions.
  1036. * fromfpxl: (libc)Rounding Functions.
  1037. * fscanf: (libc)Formatted Input Functions.
  1038. * fseek: (libc)File Positioning.
  1039. * fseeko64: (libc)File Positioning.
  1040. * fseeko: (libc)File Positioning.
  1041. * fsetpos64: (libc)Portable Positioning.
  1042. * fsetpos: (libc)Portable Positioning.
  1043. * fstat64: (libc)Reading Attributes.
  1044. * fstat: (libc)Reading Attributes.
  1045. * fsub: (libc)Misc FP Arithmetic.
  1046. * fsubl: (libc)Misc FP Arithmetic.
  1047. * fsync: (libc)Synchronizing I/O.
  1048. * ftell: (libc)File Positioning.
  1049. * ftello64: (libc)File Positioning.
  1050. * ftello: (libc)File Positioning.
  1051. * ftruncate64: (libc)File Size.
  1052. * ftruncate: (libc)File Size.
  1053. * ftrylockfile: (libc)Streams and Threads.
  1054. * ftw64: (libc)Working with Directory Trees.
  1055. * ftw: (libc)Working with Directory Trees.
  1056. * funlockfile: (libc)Streams and Threads.
  1057. * futimes: (libc)File Times.
  1058. * fwide: (libc)Streams and I18N.
  1059. * fwprintf: (libc)Formatted Output Functions.
  1060. * fwrite: (libc)Block Input/Output.
  1061. * fwrite_unlocked: (libc)Block Input/Output.
  1062. * fwscanf: (libc)Formatted Input Functions.
  1063. * gamma: (libc)Special Functions.
  1064. * gammaf: (libc)Special Functions.
  1065. * gammal: (libc)Special Functions.
  1066. * gcvt: (libc)System V Number Conversion.
  1067. * get_avphys_pages: (libc)Query Memory Parameters.
  1068. * get_current_dir_name: (libc)Working Directory.
  1069. * get_nprocs: (libc)Processor Resources.
  1070. * get_nprocs_conf: (libc)Processor Resources.
  1071. * get_phys_pages: (libc)Query Memory Parameters.
  1072. * getauxval: (libc)Auxiliary Vector.
  1073. * getc: (libc)Character Input.
  1074. * getc_unlocked: (libc)Character Input.
  1075. * getchar: (libc)Character Input.
  1076. * getchar_unlocked: (libc)Character Input.
  1077. * getcontext: (libc)System V contexts.
  1078. * getcpu: (libc)CPU Affinity.
  1079. * getcwd: (libc)Working Directory.
  1080. * getdate: (libc)General Time String Parsing.
  1081. * getdate_r: (libc)General Time String Parsing.
  1082. * getdelim: (libc)Line Input.
  1083. * getdents64: (libc)Low-level Directory Access.
  1084. * getdomainnname: (libc)Host Identification.
  1085. * getegid: (libc)Reading Persona.
  1086. * getentropy: (libc)Unpredictable Bytes.
  1087. * getenv: (libc)Environment Access.
  1088. * geteuid: (libc)Reading Persona.
  1089. * getfsent: (libc)fstab.
  1090. * getfsfile: (libc)fstab.
  1091. * getfsspec: (libc)fstab.
  1092. * getgid: (libc)Reading Persona.
  1093. * getgrent: (libc)Scanning All Groups.
  1094. * getgrent_r: (libc)Scanning All Groups.
  1095. * getgrgid: (libc)Lookup Group.
  1096. * getgrgid_r: (libc)Lookup Group.
  1097. * getgrnam: (libc)Lookup Group.
  1098. * getgrnam_r: (libc)Lookup Group.
  1099. * getgrouplist: (libc)Setting Groups.
  1100. * getgroups: (libc)Reading Persona.
  1101. * gethostbyaddr: (libc)Host Names.
  1102. * gethostbyaddr_r: (libc)Host Names.
  1103. * gethostbyname2: (libc)Host Names.
  1104. * gethostbyname2_r: (libc)Host Names.
  1105. * gethostbyname: (libc)Host Names.
  1106. * gethostbyname_r: (libc)Host Names.
  1107. * gethostent: (libc)Host Names.
  1108. * gethostid: (libc)Host Identification.
  1109. * gethostname: (libc)Host Identification.
  1110. * getitimer: (libc)Setting an Alarm.
  1111. * getline: (libc)Line Input.
  1112. * getloadavg: (libc)Processor Resources.
  1113. * getlogin: (libc)Who Logged In.
  1114. * getmntent: (libc)mtab.
  1115. * getmntent_r: (libc)mtab.
  1116. * getnetbyaddr: (libc)Networks Database.
  1117. * getnetbyname: (libc)Networks Database.
  1118. * getnetent: (libc)Networks Database.
  1119. * getnetgrent: (libc)Lookup Netgroup.
  1120. * getnetgrent_r: (libc)Lookup Netgroup.
  1121. * getopt: (libc)Using Getopt.
  1122. * getopt_long: (libc)Getopt Long Options.
  1123. * getopt_long_only: (libc)Getopt Long Options.
  1124. * getpagesize: (libc)Query Memory Parameters.
  1125. * getpass: (libc)getpass.
  1126. * getpayload: (libc)FP Bit Twiddling.
  1127. * getpayloadf: (libc)FP Bit Twiddling.
  1128. * getpayloadfN: (libc)FP Bit Twiddling.
  1129. * getpayloadfNx: (libc)FP Bit Twiddling.
  1130. * getpayloadl: (libc)FP Bit Twiddling.
  1131. * getpeername: (libc)Who is Connected.
  1132. * getpgid: (libc)Process Group Functions.
  1133. * getpgrp: (libc)Process Group Functions.
  1134. * getpid: (libc)Process Identification.
  1135. * getppid: (libc)Process Identification.
  1136. * getpriority: (libc)Traditional Scheduling Functions.
  1137. * getprotobyname: (libc)Protocols Database.
  1138. * getprotobynumber: (libc)Protocols Database.
  1139. * getprotoent: (libc)Protocols Database.
  1140. * getpt: (libc)Allocation.
  1141. * getpwent: (libc)Scanning All Users.
  1142. * getpwent_r: (libc)Scanning All Users.
  1143. * getpwnam: (libc)Lookup User.
  1144. * getpwnam_r: (libc)Lookup User.
  1145. * getpwuid: (libc)Lookup User.
  1146. * getpwuid_r: (libc)Lookup User.
  1147. * getrandom: (libc)Unpredictable Bytes.
  1148. * getrlimit64: (libc)Limits on Resources.
  1149. * getrlimit: (libc)Limits on Resources.
  1150. * getrusage: (libc)Resource Usage.
  1151. * gets: (libc)Line Input.
  1152. * getservbyname: (libc)Services Database.
  1153. * getservbyport: (libc)Services Database.
  1154. * getservent: (libc)Services Database.
  1155. * getsid: (libc)Process Group Functions.
  1156. * getsockname: (libc)Reading Address.
  1157. * getsockopt: (libc)Socket Option Functions.
  1158. * getsubopt: (libc)Suboptions.
  1159. * gettext: (libc)Translation with gettext.
  1160. * gettid: (libc)Process Identification.
  1161. * gettimeofday: (libc)Getting the Time.
  1162. * getuid: (libc)Reading Persona.
  1163. * getumask: (libc)Setting Permissions.
  1164. * getutent: (libc)Manipulating the Database.
  1165. * getutent_r: (libc)Manipulating the Database.
  1166. * getutid: (libc)Manipulating the Database.
  1167. * getutid_r: (libc)Manipulating the Database.
  1168. * getutline: (libc)Manipulating the Database.
  1169. * getutline_r: (libc)Manipulating the Database.
  1170. * getutmp: (libc)XPG Functions.
  1171. * getutmpx: (libc)XPG Functions.
  1172. * getutxent: (libc)XPG Functions.
  1173. * getutxid: (libc)XPG Functions.
  1174. * getutxline: (libc)XPG Functions.
  1175. * getw: (libc)Character Input.
  1176. * getwc: (libc)Character Input.
  1177. * getwc_unlocked: (libc)Character Input.
  1178. * getwchar: (libc)Character Input.
  1179. * getwchar_unlocked: (libc)Character Input.
  1180. * getwd: (libc)Working Directory.
  1181. * glob64: (libc)Calling Glob.
  1182. * glob: (libc)Calling Glob.
  1183. * globfree64: (libc)More Flags for Globbing.
  1184. * globfree: (libc)More Flags for Globbing.
  1185. * gmtime: (libc)Broken-down Time.
  1186. * gmtime_r: (libc)Broken-down Time.
  1187. * grantpt: (libc)Allocation.
  1188. * gsignal: (libc)Signaling Yourself.
  1189. * gtty: (libc)BSD Terminal Modes.
  1190. * hasmntopt: (libc)mtab.
  1191. * hcreate: (libc)Hash Search Function.
  1192. * hcreate_r: (libc)Hash Search Function.
  1193. * hdestroy: (libc)Hash Search Function.
  1194. * hdestroy_r: (libc)Hash Search Function.
  1195. * hsearch: (libc)Hash Search Function.
  1196. * hsearch_r: (libc)Hash Search Function.
  1197. * htonl: (libc)Byte Order.
  1198. * htons: (libc)Byte Order.
  1199. * hypot: (libc)Exponents and Logarithms.
  1200. * hypotf: (libc)Exponents and Logarithms.
  1201. * hypotfN: (libc)Exponents and Logarithms.
  1202. * hypotfNx: (libc)Exponents and Logarithms.
  1203. * hypotl: (libc)Exponents and Logarithms.
  1204. * iconv: (libc)Generic Conversion Interface.
  1205. * iconv_close: (libc)Generic Conversion Interface.
  1206. * iconv_open: (libc)Generic Conversion Interface.
  1207. * if_freenameindex: (libc)Interface Naming.
  1208. * if_indextoname: (libc)Interface Naming.
  1209. * if_nameindex: (libc)Interface Naming.
  1210. * if_nametoindex: (libc)Interface Naming.
  1211. * ilogb: (libc)Exponents and Logarithms.
  1212. * ilogbf: (libc)Exponents and Logarithms.
  1213. * ilogbfN: (libc)Exponents and Logarithms.
  1214. * ilogbfNx: (libc)Exponents and Logarithms.
  1215. * ilogbl: (libc)Exponents and Logarithms.
  1216. * imaxabs: (libc)Absolute Value.
  1217. * imaxdiv: (libc)Integer Division.
  1218. * in6addr_any: (libc)Host Address Data Type.
  1219. * in6addr_loopback: (libc)Host Address Data Type.
  1220. * index: (libc)Search Functions.
  1221. * inet_addr: (libc)Host Address Functions.
  1222. * inet_aton: (libc)Host Address Functions.
  1223. * inet_lnaof: (libc)Host Address Functions.
  1224. * inet_makeaddr: (libc)Host Address Functions.
  1225. * inet_netof: (libc)Host Address Functions.
  1226. * inet_network: (libc)Host Address Functions.
  1227. * inet_ntoa: (libc)Host Address Functions.
  1228. * inet_ntop: (libc)Host Address Functions.
  1229. * inet_pton: (libc)Host Address Functions.
  1230. * initgroups: (libc)Setting Groups.
  1231. * initstate: (libc)BSD Random.
  1232. * initstate_r: (libc)BSD Random.
  1233. * innetgr: (libc)Netgroup Membership.
  1234. * ioctl: (libc)IOCTLs.
  1235. * isalnum: (libc)Classification of Characters.
  1236. * isalpha: (libc)Classification of Characters.
  1237. * isascii: (libc)Classification of Characters.
  1238. * isatty: (libc)Is It a Terminal.
  1239. * isblank: (libc)Classification of Characters.
  1240. * iscanonical: (libc)Floating Point Classes.
  1241. * iscntrl: (libc)Classification of Characters.
  1242. * isdigit: (libc)Classification of Characters.
  1243. * iseqsig: (libc)FP Comparison Functions.
  1244. * isfinite: (libc)Floating Point Classes.
  1245. * isgraph: (libc)Classification of Characters.
  1246. * isgreater: (libc)FP Comparison Functions.
  1247. * isgreaterequal: (libc)FP Comparison Functions.
  1248. * isinf: (libc)Floating Point Classes.
  1249. * isinff: (libc)Floating Point Classes.
  1250. * isinfl: (libc)Floating Point Classes.
  1251. * isless: (libc)FP Comparison Functions.
  1252. * islessequal: (libc)FP Comparison Functions.
  1253. * islessgreater: (libc)FP Comparison Functions.
  1254. * islower: (libc)Classification of Characters.
  1255. * isnan: (libc)Floating Point Classes.
  1256. * isnan: (libc)Floating Point Classes.
  1257. * isnanf: (libc)Floating Point Classes.
  1258. * isnanl: (libc)Floating Point Classes.
  1259. * isnormal: (libc)Floating Point Classes.
  1260. * isprint: (libc)Classification of Characters.
  1261. * ispunct: (libc)Classification of Characters.
  1262. * issignaling: (libc)Floating Point Classes.
  1263. * isspace: (libc)Classification of Characters.
  1264. * issubnormal: (libc)Floating Point Classes.
  1265. * isunordered: (libc)FP Comparison Functions.
  1266. * isupper: (libc)Classification of Characters.
  1267. * iswalnum: (libc)Classification of Wide Characters.
  1268. * iswalpha: (libc)Classification of Wide Characters.
  1269. * iswblank: (libc)Classification of Wide Characters.
  1270. * iswcntrl: (libc)Classification of Wide Characters.
  1271. * iswctype: (libc)Classification of Wide Characters.
  1272. * iswdigit: (libc)Classification of Wide Characters.
  1273. * iswgraph: (libc)Classification of Wide Characters.
  1274. * iswlower: (libc)Classification of Wide Characters.
  1275. * iswprint: (libc)Classification of Wide Characters.
  1276. * iswpunct: (libc)Classification of Wide Characters.
  1277. * iswspace: (libc)Classification of Wide Characters.
  1278. * iswupper: (libc)Classification of Wide Characters.
  1279. * iswxdigit: (libc)Classification of Wide Characters.
  1280. * isxdigit: (libc)Classification of Characters.
  1281. * iszero: (libc)Floating Point Classes.
  1282. * j0: (libc)Special Functions.
  1283. * j0f: (libc)Special Functions.
  1284. * j0fN: (libc)Special Functions.
  1285. * j0fNx: (libc)Special Functions.
  1286. * j0l: (libc)Special Functions.
  1287. * j1: (libc)Special Functions.
  1288. * j1f: (libc)Special Functions.
  1289. * j1fN: (libc)Special Functions.
  1290. * j1fNx: (libc)Special Functions.
  1291. * j1l: (libc)Special Functions.
  1292. * jn: (libc)Special Functions.
  1293. * jnf: (libc)Special Functions.
  1294. * jnfN: (libc)Special Functions.
  1295. * jnfNx: (libc)Special Functions.
  1296. * jnl: (libc)Special Functions.
  1297. * jrand48: (libc)SVID Random.
  1298. * jrand48_r: (libc)SVID Random.
  1299. * kill: (libc)Signaling Another Process.
  1300. * killpg: (libc)Signaling Another Process.
  1301. * l64a: (libc)Encode Binary Data.
  1302. * labs: (libc)Absolute Value.
  1303. * lcong48: (libc)SVID Random.
  1304. * lcong48_r: (libc)SVID Random.
  1305. * ldexp: (libc)Normalization Functions.
  1306. * ldexpf: (libc)Normalization Functions.
  1307. * ldexpfN: (libc)Normalization Functions.
  1308. * ldexpfNx: (libc)Normalization Functions.
  1309. * ldexpl: (libc)Normalization Functions.
  1310. * ldiv: (libc)Integer Division.
  1311. * lfind: (libc)Array Search Function.
  1312. * lgamma: (libc)Special Functions.
  1313. * lgamma_r: (libc)Special Functions.
  1314. * lgammaf: (libc)Special Functions.
  1315. * lgammafN: (libc)Special Functions.
  1316. * lgammafN_r: (libc)Special Functions.
  1317. * lgammafNx: (libc)Special Functions.
  1318. * lgammafNx_r: (libc)Special Functions.
  1319. * lgammaf_r: (libc)Special Functions.
  1320. * lgammal: (libc)Special Functions.
  1321. * lgammal_r: (libc)Special Functions.
  1322. * link: (libc)Hard Links.
  1323. * linkat: (libc)Hard Links.
  1324. * lio_listio64: (libc)Asynchronous Reads/Writes.
  1325. * lio_listio: (libc)Asynchronous Reads/Writes.
  1326. * listen: (libc)Listening.
  1327. * llabs: (libc)Absolute Value.
  1328. * lldiv: (libc)Integer Division.
  1329. * llogb: (libc)Exponents and Logarithms.
  1330. * llogbf: (libc)Exponents and Logarithms.
  1331. * llogbfN: (libc)Exponents and Logarithms.
  1332. * llogbfNx: (libc)Exponents and Logarithms.
  1333. * llogbl: (libc)Exponents and Logarithms.
  1334. * llrint: (libc)Rounding Functions.
  1335. * llrintf: (libc)Rounding Functions.
  1336. * llrintfN: (libc)Rounding Functions.
  1337. * llrintfNx: (libc)Rounding Functions.
  1338. * llrintl: (libc)Rounding Functions.
  1339. * llround: (libc)Rounding Functions.
  1340. * llroundf: (libc)Rounding Functions.
  1341. * llroundfN: (libc)Rounding Functions.
  1342. * llroundfNx: (libc)Rounding Functions.
  1343. * llroundl: (libc)Rounding Functions.
  1344. * localeconv: (libc)The Lame Way to Locale Data.
  1345. * localtime: (libc)Broken-down Time.
  1346. * localtime_r: (libc)Broken-down Time.
  1347. * log10: (libc)Exponents and Logarithms.
  1348. * log10f: (libc)Exponents and Logarithms.
  1349. * log10fN: (libc)Exponents and Logarithms.
  1350. * log10fNx: (libc)Exponents and Logarithms.
  1351. * log10l: (libc)Exponents and Logarithms.
  1352. * log1p: (libc)Exponents and Logarithms.
  1353. * log1pf: (libc)Exponents and Logarithms.
  1354. * log1pfN: (libc)Exponents and Logarithms.
  1355. * log1pfNx: (libc)Exponents and Logarithms.
  1356. * log1pl: (libc)Exponents and Logarithms.
  1357. * log2: (libc)Exponents and Logarithms.
  1358. * log2f: (libc)Exponents and Logarithms.
  1359. * log2fN: (libc)Exponents and Logarithms.
  1360. * log2fNx: (libc)Exponents and Logarithms.
  1361. * log2l: (libc)Exponents and Logarithms.
  1362. * log: (libc)Exponents and Logarithms.
  1363. * logb: (libc)Exponents and Logarithms.
  1364. * logbf: (libc)Exponents and Logarithms.
  1365. * logbfN: (libc)Exponents and Logarithms.
  1366. * logbfNx: (libc)Exponents and Logarithms.
  1367. * logbl: (libc)Exponents and Logarithms.
  1368. * logf: (libc)Exponents and Logarithms.
  1369. * logfN: (libc)Exponents and Logarithms.
  1370. * logfNx: (libc)Exponents and Logarithms.
  1371. * login: (libc)Logging In and Out.
  1372. * login_tty: (libc)Logging In and Out.
  1373. * logl: (libc)Exponents and Logarithms.
  1374. * logout: (libc)Logging In and Out.
  1375. * logwtmp: (libc)Logging In and Out.
  1376. * longjmp: (libc)Non-Local Details.
  1377. * lrand48: (libc)SVID Random.
  1378. * lrand48_r: (libc)SVID Random.
  1379. * lrint: (libc)Rounding Functions.
  1380. * lrintf: (libc)Rounding Functions.
  1381. * lrintfN: (libc)Rounding Functions.
  1382. * lrintfNx: (libc)Rounding Functions.
  1383. * lrintl: (libc)Rounding Functions.
  1384. * lround: (libc)Rounding Functions.
  1385. * lroundf: (libc)Rounding Functions.
  1386. * lroundfN: (libc)Rounding Functions.
  1387. * lroundfNx: (libc)Rounding Functions.
  1388. * lroundl: (libc)Rounding Functions.
  1389. * lsearch: (libc)Array Search Function.
  1390. * lseek64: (libc)File Position Primitive.
  1391. * lseek: (libc)File Position Primitive.
  1392. * lstat64: (libc)Reading Attributes.
  1393. * lstat: (libc)Reading Attributes.
  1394. * lutimes: (libc)File Times.
  1395. * madvise: (libc)Memory-mapped I/O.
  1396. * makecontext: (libc)System V contexts.
  1397. * mallinfo2: (libc)Statistics of Malloc.
  1398. * malloc: (libc)Basic Allocation.
  1399. * mallopt: (libc)Malloc Tunable Parameters.
  1400. * mblen: (libc)Non-reentrant Character Conversion.
  1401. * mbrlen: (libc)Converting a Character.
  1402. * mbrtowc: (libc)Converting a Character.
  1403. * mbsinit: (libc)Keeping the state.
  1404. * mbsnrtowcs: (libc)Converting Strings.
  1405. * mbsrtowcs: (libc)Converting Strings.
  1406. * mbstowcs: (libc)Non-reentrant String Conversion.
  1407. * mbtowc: (libc)Non-reentrant Character Conversion.
  1408. * mcheck: (libc)Heap Consistency Checking.
  1409. * memalign: (libc)Aligned Memory Blocks.
  1410. * memccpy: (libc)Copying Strings and Arrays.
  1411. * memchr: (libc)Search Functions.
  1412. * memcmp: (libc)String/Array Comparison.
  1413. * memcpy: (libc)Copying Strings and Arrays.
  1414. * memfd_create: (libc)Memory-mapped I/O.
  1415. * memfrob: (libc)Obfuscating Data.
  1416. * memmem: (libc)Search Functions.
  1417. * memmove: (libc)Copying Strings and Arrays.
  1418. * mempcpy: (libc)Copying Strings and Arrays.
  1419. * memrchr: (libc)Search Functions.
  1420. * memset: (libc)Copying Strings and Arrays.
  1421. * mkdir: (libc)Creating Directories.
  1422. * mkdtemp: (libc)Temporary Files.
  1423. * mkfifo: (libc)FIFO Special Files.
  1424. * mknod: (libc)Making Special Files.
  1425. * mkstemp: (libc)Temporary Files.
  1426. * mktemp: (libc)Temporary Files.
  1427. * mktime: (libc)Broken-down Time.
  1428. * mlock2: (libc)Page Lock Functions.
  1429. * mlock: (libc)Page Lock Functions.
  1430. * mlockall: (libc)Page Lock Functions.
  1431. * mmap64: (libc)Memory-mapped I/O.
  1432. * mmap: (libc)Memory-mapped I/O.
  1433. * modf: (libc)Rounding Functions.
  1434. * modff: (libc)Rounding Functions.
  1435. * modffN: (libc)Rounding Functions.
  1436. * modffNx: (libc)Rounding Functions.
  1437. * modfl: (libc)Rounding Functions.
  1438. * mount: (libc)Mount-Unmount-Remount.
  1439. * mprobe: (libc)Heap Consistency Checking.
  1440. * mprotect: (libc)Memory Protection.
  1441. * mrand48: (libc)SVID Random.
  1442. * mrand48_r: (libc)SVID Random.
  1443. * mremap: (libc)Memory-mapped I/O.
  1444. * msync: (libc)Memory-mapped I/O.
  1445. * mtrace: (libc)Tracing malloc.
  1446. * mtx_destroy: (libc)ISO C Mutexes.
  1447. * mtx_init: (libc)ISO C Mutexes.
  1448. * mtx_lock: (libc)ISO C Mutexes.
  1449. * mtx_timedlock: (libc)ISO C Mutexes.
  1450. * mtx_trylock: (libc)ISO C Mutexes.
  1451. * mtx_unlock: (libc)ISO C Mutexes.
  1452. * munlock: (libc)Page Lock Functions.
  1453. * munlockall: (libc)Page Lock Functions.
  1454. * munmap: (libc)Memory-mapped I/O.
  1455. * muntrace: (libc)Tracing malloc.
  1456. * nan: (libc)FP Bit Twiddling.
  1457. * nanf: (libc)FP Bit Twiddling.
  1458. * nanfN: (libc)FP Bit Twiddling.
  1459. * nanfNx: (libc)FP Bit Twiddling.
  1460. * nanl: (libc)FP Bit Twiddling.
  1461. * nanosleep: (libc)Sleeping.
  1462. * nearbyint: (libc)Rounding Functions.
  1463. * nearbyintf: (libc)Rounding Functions.
  1464. * nearbyintfN: (libc)Rounding Functions.
  1465. * nearbyintfNx: (libc)Rounding Functions.
  1466. * nearbyintl: (libc)Rounding Functions.
  1467. * nextafter: (libc)FP Bit Twiddling.
  1468. * nextafterf: (libc)FP Bit Twiddling.
  1469. * nextafterfN: (libc)FP Bit Twiddling.
  1470. * nextafterfNx: (libc)FP Bit Twiddling.
  1471. * nextafterl: (libc)FP Bit Twiddling.
  1472. * nextdown: (libc)FP Bit Twiddling.
  1473. * nextdownf: (libc)FP Bit Twiddling.
  1474. * nextdownfN: (libc)FP Bit Twiddling.
  1475. * nextdownfNx: (libc)FP Bit Twiddling.
  1476. * nextdownl: (libc)FP Bit Twiddling.
  1477. * nexttoward: (libc)FP Bit Twiddling.
  1478. * nexttowardf: (libc)FP Bit Twiddling.
  1479. * nexttowardl: (libc)FP Bit Twiddling.
  1480. * nextup: (libc)FP Bit Twiddling.
  1481. * nextupf: (libc)FP Bit Twiddling.
  1482. * nextupfN: (libc)FP Bit Twiddling.
  1483. * nextupfNx: (libc)FP Bit Twiddling.
  1484. * nextupl: (libc)FP Bit Twiddling.
  1485. * nftw64: (libc)Working with Directory Trees.
  1486. * nftw: (libc)Working with Directory Trees.
  1487. * ngettext: (libc)Advanced gettext functions.
  1488. * nice: (libc)Traditional Scheduling Functions.
  1489. * nl_langinfo: (libc)The Elegant and Fast Way.
  1490. * nrand48: (libc)SVID Random.
  1491. * nrand48_r: (libc)SVID Random.
  1492. * ntohl: (libc)Byte Order.
  1493. * ntohs: (libc)Byte Order.
  1494. * ntp_adjtime: (libc)Setting and Adjusting the Time.
  1495. * ntp_gettime: (libc)Setting and Adjusting the Time.
  1496. * obstack_1grow: (libc)Growing Objects.
  1497. * obstack_1grow_fast: (libc)Extra Fast Growing.
  1498. * obstack_alignment_mask: (libc)Obstacks Data Alignment.
  1499. * obstack_alloc: (libc)Allocation in an Obstack.
  1500. * obstack_base: (libc)Status of an Obstack.
  1501. * obstack_blank: (libc)Growing Objects.
  1502. * obstack_blank_fast: (libc)Extra Fast Growing.
  1503. * obstack_chunk_size: (libc)Obstack Chunks.
  1504. * obstack_copy0: (libc)Allocation in an Obstack.
  1505. * obstack_copy: (libc)Allocation in an Obstack.
  1506. * obstack_finish: (libc)Growing Objects.
  1507. * obstack_free: (libc)Freeing Obstack Objects.
  1508. * obstack_grow0: (libc)Growing Objects.
  1509. * obstack_grow: (libc)Growing Objects.
  1510. * obstack_init: (libc)Preparing for Obstacks.
  1511. * obstack_int_grow: (libc)Growing Objects.
  1512. * obstack_int_grow_fast: (libc)Extra Fast Growing.
  1513. * obstack_next_free: (libc)Status of an Obstack.
  1514. * obstack_object_size: (libc)Growing Objects.
  1515. * obstack_object_size: (libc)Status of an Obstack.
  1516. * obstack_printf: (libc)Dynamic Output.
  1517. * obstack_ptr_grow: (libc)Growing Objects.
  1518. * obstack_ptr_grow_fast: (libc)Extra Fast Growing.
  1519. * obstack_room: (libc)Extra Fast Growing.
  1520. * obstack_vprintf: (libc)Variable Arguments Output.
  1521. * offsetof: (libc)Structure Measurement.
  1522. * on_exit: (libc)Cleanups on Exit.
  1523. * open64: (libc)Opening and Closing Files.
  1524. * open: (libc)Opening and Closing Files.
  1525. * open_memstream: (libc)String Streams.
  1526. * opendir: (libc)Opening a Directory.
  1527. * openlog: (libc)openlog.
  1528. * openpty: (libc)Pseudo-Terminal Pairs.
  1529. * parse_printf_format: (libc)Parsing a Template String.
  1530. * pathconf: (libc)Pathconf.
  1531. * pause: (libc)Using Pause.
  1532. * pclose: (libc)Pipe to a Subprocess.
  1533. * perror: (libc)Error Messages.
  1534. * pipe: (libc)Creating a Pipe.
  1535. * pkey_alloc: (libc)Memory Protection.
  1536. * pkey_free: (libc)Memory Protection.
  1537. * pkey_get: (libc)Memory Protection.
  1538. * pkey_mprotect: (libc)Memory Protection.
  1539. * pkey_set: (libc)Memory Protection.
  1540. * popen: (libc)Pipe to a Subprocess.
  1541. * posix_fallocate64: (libc)Storage Allocation.
  1542. * posix_fallocate: (libc)Storage Allocation.
  1543. * posix_memalign: (libc)Aligned Memory Blocks.
  1544. * pow: (libc)Exponents and Logarithms.
  1545. * powf: (libc)Exponents and Logarithms.
  1546. * powfN: (libc)Exponents and Logarithms.
  1547. * powfNx: (libc)Exponents and Logarithms.
  1548. * powl: (libc)Exponents and Logarithms.
  1549. * pread64: (libc)I/O Primitives.
  1550. * pread: (libc)I/O Primitives.
  1551. * preadv2: (libc)Scatter-Gather.
  1552. * preadv64: (libc)Scatter-Gather.
  1553. * preadv64v2: (libc)Scatter-Gather.
  1554. * preadv: (libc)Scatter-Gather.
  1555. * printf: (libc)Formatted Output Functions.
  1556. * printf_size: (libc)Predefined Printf Handlers.
  1557. * printf_size_info: (libc)Predefined Printf Handlers.
  1558. * psignal: (libc)Signal Messages.
  1559. * pthread_attr_getsigmask_np: (libc)Initial Thread Signal Mask.
  1560. * pthread_attr_setsigmask_np: (libc)Initial Thread Signal Mask.
  1561. * pthread_clockjoin_np: (libc)Waiting with Explicit Clocks.
  1562. * pthread_cond_clockwait: (libc)Waiting with Explicit Clocks.
  1563. * pthread_getattr_default_np: (libc)Default Thread Attributes.
  1564. * pthread_getspecific: (libc)Thread-specific Data.
  1565. * pthread_key_create: (libc)Thread-specific Data.
  1566. * pthread_key_delete: (libc)Thread-specific Data.
  1567. * pthread_rwlock_clockrdlock: (libc)Waiting with Explicit Clocks.
  1568. * pthread_rwlock_clockwrlock: (libc)Waiting with Explicit Clocks.
  1569. * pthread_setattr_default_np: (libc)Default Thread Attributes.
  1570. * pthread_setspecific: (libc)Thread-specific Data.
  1571. * pthread_timedjoin_np: (libc)Waiting with Explicit Clocks.
  1572. * pthread_tryjoin_np: (libc)Waiting with Explicit Clocks.
  1573. * ptsname: (libc)Allocation.
  1574. * ptsname_r: (libc)Allocation.
  1575. * putc: (libc)Simple Output.
  1576. * putc_unlocked: (libc)Simple Output.
  1577. * putchar: (libc)Simple Output.
  1578. * putchar_unlocked: (libc)Simple Output.
  1579. * putenv: (libc)Environment Access.
  1580. * putpwent: (libc)Writing a User Entry.
  1581. * puts: (libc)Simple Output.
  1582. * pututline: (libc)Manipulating the Database.
  1583. * pututxline: (libc)XPG Functions.
  1584. * putw: (libc)Simple Output.
  1585. * putwc: (libc)Simple Output.
  1586. * putwc_unlocked: (libc)Simple Output.
  1587. * putwchar: (libc)Simple Output.
  1588. * putwchar_unlocked: (libc)Simple Output.
  1589. * pwrite64: (libc)I/O Primitives.
  1590. * pwrite: (libc)I/O Primitives.
  1591. * pwritev2: (libc)Scatter-Gather.
  1592. * pwritev64: (libc)Scatter-Gather.
  1593. * pwritev64v2: (libc)Scatter-Gather.
  1594. * pwritev: (libc)Scatter-Gather.
  1595. * qecvt: (libc)System V Number Conversion.
  1596. * qecvt_r: (libc)System V Number Conversion.
  1597. * qfcvt: (libc)System V Number Conversion.
  1598. * qfcvt_r: (libc)System V Number Conversion.
  1599. * qgcvt: (libc)System V Number Conversion.
  1600. * qsort: (libc)Array Sort Function.
  1601. * raise: (libc)Signaling Yourself.
  1602. * rand: (libc)ISO Random.
  1603. * rand_r: (libc)ISO Random.
  1604. * random: (libc)BSD Random.
  1605. * random_r: (libc)BSD Random.
  1606. * rawmemchr: (libc)Search Functions.
  1607. * read: (libc)I/O Primitives.
  1608. * readdir64: (libc)Reading/Closing Directory.
  1609. * readdir64_r: (libc)Reading/Closing Directory.
  1610. * readdir: (libc)Reading/Closing Directory.
  1611. * readdir_r: (libc)Reading/Closing Directory.
  1612. * readlink: (libc)Symbolic Links.
  1613. * readv: (libc)Scatter-Gather.
  1614. * realloc: (libc)Changing Block Size.
  1615. * reallocarray: (libc)Changing Block Size.
  1616. * realpath: (libc)Symbolic Links.
  1617. * recv: (libc)Receiving Data.
  1618. * recvfrom: (libc)Receiving Datagrams.
  1619. * recvmsg: (libc)Receiving Datagrams.
  1620. * regcomp: (libc)POSIX Regexp Compilation.
  1621. * regerror: (libc)Regexp Cleanup.
  1622. * regexec: (libc)Matching POSIX Regexps.
  1623. * regfree: (libc)Regexp Cleanup.
  1624. * register_printf_function: (libc)Registering New Conversions.
  1625. * remainder: (libc)Remainder Functions.
  1626. * remainderf: (libc)Remainder Functions.
  1627. * remainderfN: (libc)Remainder Functions.
  1628. * remainderfNx: (libc)Remainder Functions.
  1629. * remainderl: (libc)Remainder Functions.
  1630. * remove: (libc)Deleting Files.
  1631. * rename: (libc)Renaming Files.
  1632. * rewind: (libc)File Positioning.
  1633. * rewinddir: (libc)Random Access Directory.
  1634. * rindex: (libc)Search Functions.
  1635. * rint: (libc)Rounding Functions.
  1636. * rintf: (libc)Rounding Functions.
  1637. * rintfN: (libc)Rounding Functions.
  1638. * rintfNx: (libc)Rounding Functions.
  1639. * rintl: (libc)Rounding Functions.
  1640. * rmdir: (libc)Deleting Files.
  1641. * round: (libc)Rounding Functions.
  1642. * roundeven: (libc)Rounding Functions.
  1643. * roundevenf: (libc)Rounding Functions.
  1644. * roundevenfN: (libc)Rounding Functions.
  1645. * roundevenfNx: (libc)Rounding Functions.
  1646. * roundevenl: (libc)Rounding Functions.
  1647. * roundf: (libc)Rounding Functions.
  1648. * roundfN: (libc)Rounding Functions.
  1649. * roundfNx: (libc)Rounding Functions.
  1650. * roundl: (libc)Rounding Functions.
  1651. * rpmatch: (libc)Yes-or-No Questions.
  1652. * sbrk: (libc)Resizing the Data Segment.
  1653. * scalb: (libc)Normalization Functions.
  1654. * scalbf: (libc)Normalization Functions.
  1655. * scalbl: (libc)Normalization Functions.
  1656. * scalbln: (libc)Normalization Functions.
  1657. * scalblnf: (libc)Normalization Functions.
  1658. * scalblnfN: (libc)Normalization Functions.
  1659. * scalblnfNx: (libc)Normalization Functions.
  1660. * scalblnl: (libc)Normalization Functions.
  1661. * scalbn: (libc)Normalization Functions.
  1662. * scalbnf: (libc)Normalization Functions.
  1663. * scalbnfN: (libc)Normalization Functions.
  1664. * scalbnfNx: (libc)Normalization Functions.
  1665. * scalbnl: (libc)Normalization Functions.
  1666. * scandir64: (libc)Scanning Directory Content.
  1667. * scandir: (libc)Scanning Directory Content.
  1668. * scanf: (libc)Formatted Input Functions.
  1669. * sched_get_priority_max: (libc)Basic Scheduling Functions.
  1670. * sched_get_priority_min: (libc)Basic Scheduling Functions.
  1671. * sched_getaffinity: (libc)CPU Affinity.
  1672. * sched_getparam: (libc)Basic Scheduling Functions.
  1673. * sched_getscheduler: (libc)Basic Scheduling Functions.
  1674. * sched_rr_get_interval: (libc)Basic Scheduling Functions.
  1675. * sched_setaffinity: (libc)CPU Affinity.
  1676. * sched_setparam: (libc)Basic Scheduling Functions.
  1677. * sched_setscheduler: (libc)Basic Scheduling Functions.
  1678. * sched_yield: (libc)Basic Scheduling Functions.
  1679. * secure_getenv: (libc)Environment Access.
  1680. * seed48: (libc)SVID Random.
  1681. * seed48_r: (libc)SVID Random.
  1682. * seekdir: (libc)Random Access Directory.
  1683. * select: (libc)Waiting for I/O.
  1684. * sem_clockwait: (libc)Waiting with Explicit Clocks.
  1685. * sem_close: (libc)Semaphores.
  1686. * sem_destroy: (libc)Semaphores.
  1687. * sem_getvalue: (libc)Semaphores.
  1688. * sem_init: (libc)Semaphores.
  1689. * sem_open: (libc)Semaphores.
  1690. * sem_post: (libc)Semaphores.
  1691. * sem_timedwait: (libc)Semaphores.
  1692. * sem_trywait: (libc)Semaphores.
  1693. * sem_unlink: (libc)Semaphores.
  1694. * sem_wait: (libc)Semaphores.
  1695. * semctl: (libc)Semaphores.
  1696. * semget: (libc)Semaphores.
  1697. * semop: (libc)Semaphores.
  1698. * semtimedop: (libc)Semaphores.
  1699. * send: (libc)Sending Data.
  1700. * sendmsg: (libc)Receiving Datagrams.
  1701. * sendto: (libc)Sending Datagrams.
  1702. * setbuf: (libc)Controlling Buffering.
  1703. * setbuffer: (libc)Controlling Buffering.
  1704. * setcontext: (libc)System V contexts.
  1705. * setdomainname: (libc)Host Identification.
  1706. * setegid: (libc)Setting Groups.
  1707. * setenv: (libc)Environment Access.
  1708. * seteuid: (libc)Setting User ID.
  1709. * setfsent: (libc)fstab.
  1710. * setgid: (libc)Setting Groups.
  1711. * setgrent: (libc)Scanning All Groups.
  1712. * setgroups: (libc)Setting Groups.
  1713. * sethostent: (libc)Host Names.
  1714. * sethostid: (libc)Host Identification.
  1715. * sethostname: (libc)Host Identification.
  1716. * setitimer: (libc)Setting an Alarm.
  1717. * setjmp: (libc)Non-Local Details.
  1718. * setlinebuf: (libc)Controlling Buffering.
  1719. * setlocale: (libc)Setting the Locale.
  1720. * setlogmask: (libc)setlogmask.
  1721. * setmntent: (libc)mtab.
  1722. * setnetent: (libc)Networks Database.
  1723. * setnetgrent: (libc)Lookup Netgroup.
  1724. * setpayload: (libc)FP Bit Twiddling.
  1725. * setpayloadf: (libc)FP Bit Twiddling.
  1726. * setpayloadfN: (libc)FP Bit Twiddling.
  1727. * setpayloadfNx: (libc)FP Bit Twiddling.
  1728. * setpayloadl: (libc)FP Bit Twiddling.
  1729. * setpayloadsig: (libc)FP Bit Twiddling.
  1730. * setpayloadsigf: (libc)FP Bit Twiddling.
  1731. * setpayloadsigfN: (libc)FP Bit Twiddling.
  1732. * setpayloadsigfNx: (libc)FP Bit Twiddling.
  1733. * setpayloadsigl: (libc)FP Bit Twiddling.
  1734. * setpgid: (libc)Process Group Functions.
  1735. * setpgrp: (libc)Process Group Functions.
  1736. * setpriority: (libc)Traditional Scheduling Functions.
  1737. * setprotoent: (libc)Protocols Database.
  1738. * setpwent: (libc)Scanning All Users.
  1739. * setregid: (libc)Setting Groups.
  1740. * setreuid: (libc)Setting User ID.
  1741. * setrlimit64: (libc)Limits on Resources.
  1742. * setrlimit: (libc)Limits on Resources.
  1743. * setservent: (libc)Services Database.
  1744. * setsid: (libc)Process Group Functions.
  1745. * setsockopt: (libc)Socket Option Functions.
  1746. * setstate: (libc)BSD Random.
  1747. * setstate_r: (libc)BSD Random.
  1748. * settimeofday: (libc)Setting and Adjusting the Time.
  1749. * setuid: (libc)Setting User ID.
  1750. * setutent: (libc)Manipulating the Database.
  1751. * setutxent: (libc)XPG Functions.
  1752. * setvbuf: (libc)Controlling Buffering.
  1753. * shm_open: (libc)Memory-mapped I/O.
  1754. * shm_unlink: (libc)Memory-mapped I/O.
  1755. * shutdown: (libc)Closing a Socket.
  1756. * sigabbrev_np: (libc)Signal Messages.
  1757. * sigaction: (libc)Advanced Signal Handling.
  1758. * sigaddset: (libc)Signal Sets.
  1759. * sigaltstack: (libc)Signal Stack.
  1760. * sigblock: (libc)BSD Signal Handling.
  1761. * sigdelset: (libc)Signal Sets.
  1762. * sigdescr_np: (libc)Signal Messages.
  1763. * sigemptyset: (libc)Signal Sets.
  1764. * sigfillset: (libc)Signal Sets.
  1765. * siginterrupt: (libc)BSD Signal Handling.
  1766. * sigismember: (libc)Signal Sets.
  1767. * siglongjmp: (libc)Non-Local Exits and Signals.
  1768. * sigmask: (libc)BSD Signal Handling.
  1769. * signal: (libc)Basic Signal Handling.
  1770. * signbit: (libc)FP Bit Twiddling.
  1771. * significand: (libc)Normalization Functions.
  1772. * significandf: (libc)Normalization Functions.
  1773. * significandl: (libc)Normalization Functions.
  1774. * sigpause: (libc)BSD Signal Handling.
  1775. * sigpending: (libc)Checking for Pending Signals.
  1776. * sigprocmask: (libc)Process Signal Mask.
  1777. * sigsetjmp: (libc)Non-Local Exits and Signals.
  1778. * sigsetmask: (libc)BSD Signal Handling.
  1779. * sigstack: (libc)Signal Stack.
  1780. * sigsuspend: (libc)Sigsuspend.
  1781. * sin: (libc)Trig Functions.
  1782. * sincos: (libc)Trig Functions.
  1783. * sincosf: (libc)Trig Functions.
  1784. * sincosfN: (libc)Trig Functions.
  1785. * sincosfNx: (libc)Trig Functions.
  1786. * sincosl: (libc)Trig Functions.
  1787. * sinf: (libc)Trig Functions.
  1788. * sinfN: (libc)Trig Functions.
  1789. * sinfNx: (libc)Trig Functions.
  1790. * sinh: (libc)Hyperbolic Functions.
  1791. * sinhf: (libc)Hyperbolic Functions.
  1792. * sinhfN: (libc)Hyperbolic Functions.
  1793. * sinhfNx: (libc)Hyperbolic Functions.
  1794. * sinhl: (libc)Hyperbolic Functions.
  1795. * sinl: (libc)Trig Functions.
  1796. * sleep: (libc)Sleeping.
  1797. * snprintf: (libc)Formatted Output Functions.
  1798. * socket: (libc)Creating a Socket.
  1799. * socketpair: (libc)Socket Pairs.
  1800. * sprintf: (libc)Formatted Output Functions.
  1801. * sqrt: (libc)Exponents and Logarithms.
  1802. * sqrtf: (libc)Exponents and Logarithms.
  1803. * sqrtfN: (libc)Exponents and Logarithms.
  1804. * sqrtfNx: (libc)Exponents and Logarithms.
  1805. * sqrtl: (libc)Exponents and Logarithms.
  1806. * srand48: (libc)SVID Random.
  1807. * srand48_r: (libc)SVID Random.
  1808. * srand: (libc)ISO Random.
  1809. * srandom: (libc)BSD Random.
  1810. * srandom_r: (libc)BSD Random.
  1811. * sscanf: (libc)Formatted Input Functions.
  1812. * ssignal: (libc)Basic Signal Handling.
  1813. * stat64: (libc)Reading Attributes.
  1814. * stat: (libc)Reading Attributes.
  1815. * stime: (libc)Setting and Adjusting the Time.
  1816. * stpcpy: (libc)Copying Strings and Arrays.
  1817. * stpncpy: (libc)Truncating Strings.
  1818. * strcasecmp: (libc)String/Array Comparison.
  1819. * strcasestr: (libc)Search Functions.
  1820. * strcat: (libc)Concatenating Strings.
  1821. * strchr: (libc)Search Functions.
  1822. * strchrnul: (libc)Search Functions.
  1823. * strcmp: (libc)String/Array Comparison.
  1824. * strcoll: (libc)Collation Functions.
  1825. * strcpy: (libc)Copying Strings and Arrays.
  1826. * strcspn: (libc)Search Functions.
  1827. * strdup: (libc)Copying Strings and Arrays.
  1828. * strdupa: (libc)Copying Strings and Arrays.
  1829. * strerror: (libc)Error Messages.
  1830. * strerror_r: (libc)Error Messages.
  1831. * strerrordesc_np: (libc)Error Messages.
  1832. * strerrorname_np: (libc)Error Messages.
  1833. * strfmon: (libc)Formatting Numbers.
  1834. * strfromd: (libc)Printing of Floats.
  1835. * strfromf: (libc)Printing of Floats.
  1836. * strfromfN: (libc)Printing of Floats.
  1837. * strfromfNx: (libc)Printing of Floats.
  1838. * strfroml: (libc)Printing of Floats.
  1839. * strfry: (libc)Shuffling Bytes.
  1840. * strftime: (libc)Formatting Calendar Time.
  1841. * strlen: (libc)String Length.
  1842. * strncasecmp: (libc)String/Array Comparison.
  1843. * strncat: (libc)Truncating Strings.
  1844. * strncmp: (libc)String/Array Comparison.
  1845. * strncpy: (libc)Truncating Strings.
  1846. * strndup: (libc)Truncating Strings.
  1847. * strndupa: (libc)Truncating Strings.
  1848. * strnlen: (libc)String Length.
  1849. * strpbrk: (libc)Search Functions.
  1850. * strptime: (libc)Low-Level Time String Parsing.
  1851. * strrchr: (libc)Search Functions.
  1852. * strsep: (libc)Finding Tokens in a String.
  1853. * strsignal: (libc)Signal Messages.
  1854. * strspn: (libc)Search Functions.
  1855. * strstr: (libc)Search Functions.
  1856. * strtod: (libc)Parsing of Floats.
  1857. * strtof: (libc)Parsing of Floats.
  1858. * strtofN: (libc)Parsing of Floats.
  1859. * strtofNx: (libc)Parsing of Floats.
  1860. * strtoimax: (libc)Parsing of Integers.
  1861. * strtok: (libc)Finding Tokens in a String.
  1862. * strtok_r: (libc)Finding Tokens in a String.
  1863. * strtol: (libc)Parsing of Integers.
  1864. * strtold: (libc)Parsing of Floats.
  1865. * strtoll: (libc)Parsing of Integers.
  1866. * strtoq: (libc)Parsing of Integers.
  1867. * strtoul: (libc)Parsing of Integers.
  1868. * strtoull: (libc)Parsing of Integers.
  1869. * strtoumax: (libc)Parsing of Integers.
  1870. * strtouq: (libc)Parsing of Integers.
  1871. * strverscmp: (libc)String/Array Comparison.
  1872. * strxfrm: (libc)Collation Functions.
  1873. * stty: (libc)BSD Terminal Modes.
  1874. * swapcontext: (libc)System V contexts.
  1875. * swprintf: (libc)Formatted Output Functions.
  1876. * swscanf: (libc)Formatted Input Functions.
  1877. * symlink: (libc)Symbolic Links.
  1878. * sync: (libc)Synchronizing I/O.
  1879. * syscall: (libc)System Calls.
  1880. * sysconf: (libc)Sysconf Definition.
  1881. * syslog: (libc)syslog; vsyslog.
  1882. * system: (libc)Running a Command.
  1883. * sysv_signal: (libc)Basic Signal Handling.
  1884. * tan: (libc)Trig Functions.
  1885. * tanf: (libc)Trig Functions.
  1886. * tanfN: (libc)Trig Functions.
  1887. * tanfNx: (libc)Trig Functions.
  1888. * tanh: (libc)Hyperbolic Functions.
  1889. * tanhf: (libc)Hyperbolic Functions.
  1890. * tanhfN: (libc)Hyperbolic Functions.
  1891. * tanhfNx: (libc)Hyperbolic Functions.
  1892. * tanhl: (libc)Hyperbolic Functions.
  1893. * tanl: (libc)Trig Functions.
  1894. * tcdrain: (libc)Line Control.
  1895. * tcflow: (libc)Line Control.
  1896. * tcflush: (libc)Line Control.
  1897. * tcgetattr: (libc)Mode Functions.
  1898. * tcgetpgrp: (libc)Terminal Access Functions.
  1899. * tcgetsid: (libc)Terminal Access Functions.
  1900. * tcsendbreak: (libc)Line Control.
  1901. * tcsetattr: (libc)Mode Functions.
  1902. * tcsetpgrp: (libc)Terminal Access Functions.
  1903. * tdelete: (libc)Tree Search Function.
  1904. * tdestroy: (libc)Tree Search Function.
  1905. * telldir: (libc)Random Access Directory.
  1906. * tempnam: (libc)Temporary Files.
  1907. * textdomain: (libc)Locating gettext catalog.
  1908. * tfind: (libc)Tree Search Function.
  1909. * tgamma: (libc)Special Functions.
  1910. * tgammaf: (libc)Special Functions.
  1911. * tgammafN: (libc)Special Functions.
  1912. * tgammafNx: (libc)Special Functions.
  1913. * tgammal: (libc)Special Functions.
  1914. * tgkill: (libc)Signaling Another Process.
  1915. * thrd_create: (libc)ISO C Thread Management.
  1916. * thrd_current: (libc)ISO C Thread Management.
  1917. * thrd_detach: (libc)ISO C Thread Management.
  1918. * thrd_equal: (libc)ISO C Thread Management.
  1919. * thrd_exit: (libc)ISO C Thread Management.
  1920. * thrd_join: (libc)ISO C Thread Management.
  1921. * thrd_sleep: (libc)ISO C Thread Management.
  1922. * thrd_yield: (libc)ISO C Thread Management.
  1923. * time: (libc)Getting the Time.
  1924. * timegm: (libc)Broken-down Time.
  1925. * timelocal: (libc)Broken-down Time.
  1926. * times: (libc)Processor Time.
  1927. * tmpfile64: (libc)Temporary Files.
  1928. * tmpfile: (libc)Temporary Files.
  1929. * tmpnam: (libc)Temporary Files.
  1930. * tmpnam_r: (libc)Temporary Files.
  1931. * toascii: (libc)Case Conversion.
  1932. * tolower: (libc)Case Conversion.
  1933. * totalorder: (libc)FP Comparison Functions.
  1934. * totalorderf: (libc)FP Comparison Functions.
  1935. * totalorderfN: (libc)FP Comparison Functions.
  1936. * totalorderfNx: (libc)FP Comparison Functions.
  1937. * totalorderl: (libc)FP Comparison Functions.
  1938. * totalordermag: (libc)FP Comparison Functions.
  1939. * totalordermagf: (libc)FP Comparison Functions.
  1940. * totalordermagfN: (libc)FP Comparison Functions.
  1941. * totalordermagfNx: (libc)FP Comparison Functions.
  1942. * totalordermagl: (libc)FP Comparison Functions.
  1943. * toupper: (libc)Case Conversion.
  1944. * towctrans: (libc)Wide Character Case Conversion.
  1945. * towlower: (libc)Wide Character Case Conversion.
  1946. * towupper: (libc)Wide Character Case Conversion.
  1947. * trunc: (libc)Rounding Functions.
  1948. * truncate64: (libc)File Size.
  1949. * truncate: (libc)File Size.
  1950. * truncf: (libc)Rounding Functions.
  1951. * truncfN: (libc)Rounding Functions.
  1952. * truncfNx: (libc)Rounding Functions.
  1953. * truncl: (libc)Rounding Functions.
  1954. * tsearch: (libc)Tree Search Function.
  1955. * tss_create: (libc)ISO C Thread-local Storage.
  1956. * tss_delete: (libc)ISO C Thread-local Storage.
  1957. * tss_get: (libc)ISO C Thread-local Storage.
  1958. * tss_set: (libc)ISO C Thread-local Storage.
  1959. * ttyname: (libc)Is It a Terminal.
  1960. * ttyname_r: (libc)Is It a Terminal.
  1961. * twalk: (libc)Tree Search Function.
  1962. * twalk_r: (libc)Tree Search Function.
  1963. * tzset: (libc)Time Zone Functions.
  1964. * ufromfp: (libc)Rounding Functions.
  1965. * ufromfpf: (libc)Rounding Functions.
  1966. * ufromfpfN: (libc)Rounding Functions.
  1967. * ufromfpfNx: (libc)Rounding Functions.
  1968. * ufromfpl: (libc)Rounding Functions.
  1969. * ufromfpx: (libc)Rounding Functions.
  1970. * ufromfpxf: (libc)Rounding Functions.
  1971. * ufromfpxfN: (libc)Rounding Functions.
  1972. * ufromfpxfNx: (libc)Rounding Functions.
  1973. * ufromfpxl: (libc)Rounding Functions.
  1974. * ulimit: (libc)Limits on Resources.
  1975. * umask: (libc)Setting Permissions.
  1976. * umount2: (libc)Mount-Unmount-Remount.
  1977. * umount: (libc)Mount-Unmount-Remount.
  1978. * uname: (libc)Platform Type.
  1979. * ungetc: (libc)How Unread.
  1980. * ungetwc: (libc)How Unread.
  1981. * unlink: (libc)Deleting Files.
  1982. * unlockpt: (libc)Allocation.
  1983. * unsetenv: (libc)Environment Access.
  1984. * updwtmp: (libc)Manipulating the Database.
  1985. * utime: (libc)File Times.
  1986. * utimes: (libc)File Times.
  1987. * utmpname: (libc)Manipulating the Database.
  1988. * utmpxname: (libc)XPG Functions.
  1989. * va_arg: (libc)Argument Macros.
  1990. * va_copy: (libc)Argument Macros.
  1991. * va_end: (libc)Argument Macros.
  1992. * va_start: (libc)Argument Macros.
  1993. * valloc: (libc)Aligned Memory Blocks.
  1994. * vasprintf: (libc)Variable Arguments Output.
  1995. * verr: (libc)Error Messages.
  1996. * verrx: (libc)Error Messages.
  1997. * versionsort64: (libc)Scanning Directory Content.
  1998. * versionsort: (libc)Scanning Directory Content.
  1999. * vfork: (libc)Creating a Process.
  2000. * vfprintf: (libc)Variable Arguments Output.
  2001. * vfscanf: (libc)Variable Arguments Input.
  2002. * vfwprintf: (libc)Variable Arguments Output.
  2003. * vfwscanf: (libc)Variable Arguments Input.
  2004. * vlimit: (libc)Limits on Resources.
  2005. * vprintf: (libc)Variable Arguments Output.
  2006. * vscanf: (libc)Variable Arguments Input.
  2007. * vsnprintf: (libc)Variable Arguments Output.
  2008. * vsprintf: (libc)Variable Arguments Output.
  2009. * vsscanf: (libc)Variable Arguments Input.
  2010. * vswprintf: (libc)Variable Arguments Output.
  2011. * vswscanf: (libc)Variable Arguments Input.
  2012. * vsyslog: (libc)syslog; vsyslog.
  2013. * vwarn: (libc)Error Messages.
  2014. * vwarnx: (libc)Error Messages.
  2015. * vwprintf: (libc)Variable Arguments Output.
  2016. * vwscanf: (libc)Variable Arguments Input.
  2017. * wait3: (libc)BSD Wait Functions.
  2018. * wait4: (libc)Process Completion.
  2019. * wait: (libc)Process Completion.
  2020. * waitpid: (libc)Process Completion.
  2021. * warn: (libc)Error Messages.
  2022. * warnx: (libc)Error Messages.
  2023. * wcpcpy: (libc)Copying Strings and Arrays.
  2024. * wcpncpy: (libc)Truncating Strings.
  2025. * wcrtomb: (libc)Converting a Character.
  2026. * wcscasecmp: (libc)String/Array Comparison.
  2027. * wcscat: (libc)Concatenating Strings.
  2028. * wcschr: (libc)Search Functions.
  2029. * wcschrnul: (libc)Search Functions.
  2030. * wcscmp: (libc)String/Array Comparison.
  2031. * wcscoll: (libc)Collation Functions.
  2032. * wcscpy: (libc)Copying Strings and Arrays.
  2033. * wcscspn: (libc)Search Functions.
  2034. * wcsdup: (libc)Copying Strings and Arrays.
  2035. * wcsftime: (libc)Formatting Calendar Time.
  2036. * wcslen: (libc)String Length.
  2037. * wcsncasecmp: (libc)String/Array Comparison.
  2038. * wcsncat: (libc)Truncating Strings.
  2039. * wcsncmp: (libc)String/Array Comparison.
  2040. * wcsncpy: (libc)Truncating Strings.
  2041. * wcsnlen: (libc)String Length.
  2042. * wcsnrtombs: (libc)Converting Strings.
  2043. * wcspbrk: (libc)Search Functions.
  2044. * wcsrchr: (libc)Search Functions.
  2045. * wcsrtombs: (libc)Converting Strings.
  2046. * wcsspn: (libc)Search Functions.
  2047. * wcsstr: (libc)Search Functions.
  2048. * wcstod: (libc)Parsing of Floats.
  2049. * wcstof: (libc)Parsing of Floats.
  2050. * wcstofN: (libc)Parsing of Floats.
  2051. * wcstofNx: (libc)Parsing of Floats.
  2052. * wcstoimax: (libc)Parsing of Integers.
  2053. * wcstok: (libc)Finding Tokens in a String.
  2054. * wcstol: (libc)Parsing of Integers.
  2055. * wcstold: (libc)Parsing of Floats.
  2056. * wcstoll: (libc)Parsing of Integers.
  2057. * wcstombs: (libc)Non-reentrant String Conversion.
  2058. * wcstoq: (libc)Parsing of Integers.
  2059. * wcstoul: (libc)Parsing of Integers.
  2060. * wcstoull: (libc)Parsing of Integers.
  2061. * wcstoumax: (libc)Parsing of Integers.
  2062. * wcstouq: (libc)Parsing of Integers.
  2063. * wcswcs: (libc)Search Functions.
  2064. * wcsxfrm: (libc)Collation Functions.
  2065. * wctob: (libc)Converting a Character.
  2066. * wctomb: (libc)Non-reentrant Character Conversion.
  2067. * wctrans: (libc)Wide Character Case Conversion.
  2068. * wctype: (libc)Classification of Wide Characters.
  2069. * wmemchr: (libc)Search Functions.
  2070. * wmemcmp: (libc)String/Array Comparison.
  2071. * wmemcpy: (libc)Copying Strings and Arrays.
  2072. * wmemmove: (libc)Copying Strings and Arrays.
  2073. * wmempcpy: (libc)Copying Strings and Arrays.
  2074. * wmemset: (libc)Copying Strings and Arrays.
  2075. * wordexp: (libc)Calling Wordexp.
  2076. * wordfree: (libc)Calling Wordexp.
  2077. * wprintf: (libc)Formatted Output Functions.
  2078. * write: (libc)I/O Primitives.
  2079. * writev: (libc)Scatter-Gather.
  2080. * wscanf: (libc)Formatted Input Functions.
  2081. * y0: (libc)Special Functions.
  2082. * y0f: (libc)Special Functions.
  2083. * y0fN: (libc)Special Functions.
  2084. * y0fNx: (libc)Special Functions.
  2085. * y0l: (libc)Special Functions.
  2086. * y1: (libc)Special Functions.
  2087. * y1f: (libc)Special Functions.
  2088. * y1fN: (libc)Special Functions.
  2089. * y1fNx: (libc)Special Functions.
  2090. * y1l: (libc)Special Functions.
  2091. * yn: (libc)Special Functions.
  2092. * ynf: (libc)Special Functions.
  2093. * ynfN: (libc)Special Functions.
  2094. * ynfNx: (libc)Special Functions.
  2095. * ynl: (libc)Special Functions.
  2096. END-INFO-DIR-ENTRY
  2097. 
  2098. File: libc.info, Node: The message catalog files, Next: The gencat program, Prev: The catgets Functions, Up: Message catalogs a la X/Open
  2099. 8.1.2 Format of the message catalog files
  2100. -----------------------------------------
  2101. The only reasonable way to translate all the messages of a function and
  2102. store the result in a message catalog file which can be read by the
  2103. ‘catopen’ function is to write all the message text to the translator
  2104. and let her/him translate them all. I.e., we must have a file with
  2105. entries which associate the set/message tuple with a specific
  2106. translation. This file format is specified in the X/Open standard and
  2107. is as follows:
  2108. • Lines containing only whitespace characters or empty lines are
  2109. ignored.
  2110. • Lines which contain as the first non-whitespace character a ‘$’
  2111. followed by a whitespace character are comment and are also
  2112. ignored.
  2113. • If a line contains as the first non-whitespace characters the
  2114. sequence ‘$set’ followed by a whitespace character an additional
  2115. argument is required to follow. This argument can either be:
  2116. − a number. In this case the value of this number determines
  2117. the set to which the following messages are added.
  2118. − an identifier consisting of alphanumeric characters plus the
  2119. underscore character. In this case the set get automatically
  2120. a number assigned. This value is one added to the largest set
  2121. number which so far appeared.
  2122. How to use the symbolic names is explained in section *note
  2123. Common Usage::.
  2124. It is an error if a symbol name appears more than once. All
  2125. following messages are placed in a set with this number.
  2126. • If a line contains as the first non-whitespace characters the
  2127. sequence ‘$delset’ followed by a whitespace character an additional
  2128. argument is required to follow. This argument can either be:
  2129. − a number. In this case the value of this number determines
  2130. the set which will be deleted.
  2131. − an identifier consisting of alphanumeric characters plus the
  2132. underscore character. This symbolic identifier must match a
  2133. name for a set which previously was defined. It is an error
  2134. if the name is unknown.
  2135. In both cases all messages in the specified set will be removed.
  2136. They will not appear in the output. But if this set is later again
  2137. selected with a ‘$set’ command again messages could be added and
  2138. these messages will appear in the output.
  2139. • If a line contains after leading whitespaces the sequence ‘$quote’,
  2140. the quoting character used for this input file is changed to the
  2141. first non-whitespace character following ‘$quote’. If no
  2142. non-whitespace character is present before the line ends quoting is
  2143. disabled.
  2144. By default no quoting character is used. In this mode strings are
  2145. terminated with the first unescaped line break. If there is a
  2146. ‘$quote’ sequence present newline need not be escaped. Instead a
  2147. string is terminated with the first unescaped appearance of the
  2148. quote character.
  2149. A common usage of this feature would be to set the quote character
  2150. to ‘"’. Then any appearance of the ‘"’ in the strings must be
  2151. escaped using the backslash (i.e., ‘\"’ must be written).
  2152. • Any other line must start with a number or an alphanumeric
  2153. identifier (with the underscore character included). The following
  2154. characters (starting after the first whitespace character) will
  2155. form the string which gets associated with the currently selected
  2156. set and the message number represented by the number and identifier
  2157. respectively.
  2158. If the start of the line is a number the message number is obvious.
  2159. It is an error if the same message number already appeared for this
  2160. set.
  2161. If the leading token was an identifier the message number gets
  2162. automatically assigned. The value is the current maximum message
  2163. number for this set plus one. It is an error if the identifier was
  2164. already used for a message in this set. It is OK to reuse the
  2165. identifier for a message in another thread. How to use the
  2166. symbolic identifiers will be explained below (*note Common
  2167. Usage::). There is one limitation with the identifier: it must not
  2168. be ‘Set’. The reason will be explained below.
  2169. The text of the messages can contain escape characters. The usual
  2170. bunch of characters known from the ISO C language are recognized
  2171. (‘\n’, ‘\t’, ‘\v’, ‘\b’, ‘\r’, ‘\f’, ‘\\’, and ‘\NNN’, where NNN is
  2172. the octal coding of a character code).
  2173. *Important:* The handling of identifiers instead of numbers for the
  2174. set and messages is a GNU extension. Systems strictly following the
  2175. X/Open specification do not have this feature. An example for a message
  2176. catalog file is this:
  2177. $ This is a leading comment.
  2178. $quote "
  2179. $set SetOne
  2180. 1 Message with ID 1.
  2181. two " Message with ID \"two\", which gets the value 2 assigned"
  2182. $set SetTwo
  2183. $ Since the last set got the number 1 assigned this set has number 2.
  2184. 4000 "The numbers can be arbitrary, they need not start at one."
  2185. This small example shows various aspects:
  2186. • Lines 1 and 9 are comments since they start with ‘$’ followed by a
  2187. whitespace.
  2188. • The quoting character is set to ‘"’. Otherwise the quotes in the
  2189. message definition would have to be omitted and in this case the
  2190. message with the identifier ‘two’ would lose its leading
  2191. whitespace.
  2192. • Mixing numbered messages with messages having symbolic names is no
  2193. problem and the numbering happens automatically.
  2194. While this file format is pretty easy it is not the best possible for
  2195. use in a running program. The ‘catopen’ function would have to parse
  2196. the file and handle syntactic errors gracefully. This is not so easy
  2197. and the whole process is pretty slow. Therefore the ‘catgets’ functions
  2198. expect the data in another more compact and ready-to-use file format.
  2199. There is a special program ‘gencat’ which is explained in detail in the
  2200. next section.
  2201. Files in this other format are not human readable. To be easy to use
  2202. by programs it is a binary file. But the format is byte order
  2203. independent so translation files can be shared by systems of arbitrary
  2204. architecture (as long as they use the GNU C Library).
  2205. Details about the binary file format are not important to know since
  2206. these files are always created by the ‘gencat’ program. The sources of
  2207. the GNU C Library also provide the sources for the ‘gencat’ program and
  2208. so the interested reader can look through these source files to learn
  2209. about the file format.
  2210. 
  2211. File: libc.info, Node: The gencat program, Next: Common Usage, Prev: The message catalog files, Up: Message catalogs a la X/Open
  2212. 8.1.3 Generate Message Catalogs files
  2213. -------------------------------------
  2214. The ‘gencat’ program is specified in the X/Open standard and the GNU
  2215. implementation follows this specification and so processes all correctly
  2216. formed input files. Additionally some extension are implemented which
  2217. help to work in a more reasonable way with the ‘catgets’ functions.
  2218. The ‘gencat’ program can be invoked in two ways:
  2219. `gencat [OPTION ...] [OUTPUT-FILE [INPUT-FILE ...]]`
  2220. This is the interface defined in the X/Open standard. If no
  2221. INPUT-FILE parameter is given, input will be read from standard input.
  2222. Multiple input files will be read as if they were concatenated. If
  2223. OUTPUT-FILE is also missing, the output will be written to standard
  2224. output. To provide the interface one is used to from other programs a
  2225. second interface is provided.
  2226. `gencat [OPTION ...] -o OUTPUT-FILE [INPUT-FILE ...]`
  2227. The option ‘-o’ is used to specify the output file and all file
  2228. arguments are used as input files.
  2229. Beside this one can use ‘-’ or ‘/dev/stdin’ for INPUT-FILE to denote
  2230. the standard input. Corresponding one can use ‘-’ and ‘/dev/stdout’ for
  2231. OUTPUT-FILE to denote standard output. Using ‘-’ as a file name is
  2232. allowed in X/Open while using the device names is a GNU extension.
  2233. The ‘gencat’ program works by concatenating all input files and then
  2234. *merging* the resulting collection of message sets with a possibly
  2235. existing output file. This is done by removing all messages with
  2236. set/message number tuples matching any of the generated messages from
  2237. the output file and then adding all the new messages. To regenerate a
  2238. catalog file while ignoring the old contents therefore requires removing
  2239. the output file if it exists. If the output is written to standard
  2240. output no merging takes place.
  2241. The following table shows the options understood by the ‘gencat’
  2242. program. The X/Open standard does not specify any options for the
  2243. program so all of these are GNU extensions.
  2244. ‘-V’
  2245. ‘--version’
  2246. Print the version information and exit.
  2247. ‘-h’
  2248. ‘--help’
  2249. Print a usage message listing all available options, then exit
  2250. successfully.
  2251. ‘--new’
  2252. Do not merge the new messages from the input files with the old
  2253. content of the output file. The old content of the output file is
  2254. discarded.
  2255. ‘-H’
  2256. ‘--header=name’
  2257. This option is used to emit the symbolic names given to sets and
  2258. messages in the input files for use in the program. Details about
  2259. how to use this are given in the next section. The NAME parameter
  2260. to this option specifies the name of the output file. It will
  2261. contain a number of C preprocessor ‘#define’s to associate a name
  2262. with a number.
  2263. Please note that the generated file only contains the symbols from
  2264. the input files. If the output is merged with the previous content
  2265. of the output file the possibly existing symbols from the file(s)
  2266. which generated the old output files are not in the generated
  2267. header file.
  2268. 
  2269. File: libc.info, Node: Common Usage, Prev: The gencat program, Up: Message catalogs a la X/Open
  2270. 8.1.4 How to use the ‘catgets’ interface
  2271. ----------------------------------------
  2272. The ‘catgets’ functions can be used in two different ways. By following
  2273. slavishly the X/Open specs and not relying on the extension and by using
  2274. the GNU extensions. We will take a look at the former method first to
  2275. understand the benefits of extensions.
  2276. 8.1.4.1 Not using symbolic names
  2277. ................................
  2278. Since the X/Open format of the message catalog files does not allow
  2279. symbol names we have to work with numbers all the time. When we start
  2280. writing a program we have to replace all appearances of translatable
  2281. strings with something like
  2282. catgets (catdesc, set, msg, "string")
  2283. CATGETS is retrieved from a call to ‘catopen’ which is normally done
  2284. once at the program start. The ‘"string"’ is the string we want to
  2285. translate. The problems start with the set and message numbers.
  2286. In a bigger program several programmers usually work at the same time
  2287. on the program and so coordinating the number allocation is crucial.
  2288. Though no two different strings must be indexed by the same tuple of
  2289. numbers it is highly desirable to reuse the numbers for equal strings
  2290. with equal translations (please note that there might be strings which
  2291. are equal in one language but have different translations due to
  2292. difference contexts).
  2293. The allocation process can be relaxed a bit by different set numbers
  2294. for different parts of the program. So the number of developers who
  2295. have to coordinate the allocation can be reduced. But still lists must
  2296. be keep track of the allocation and errors can easily happen. These
  2297. errors cannot be discovered by the compiler or the ‘catgets’ functions.
  2298. Only the user of the program might see wrong messages printed. In the
  2299. worst cases the messages are so irritating that they cannot be
  2300. recognized as wrong. Think about the translations for ‘"true"’ and
  2301. ‘"false"’ being exchanged. This could result in a disaster.
  2302. 8.1.4.2 Using symbolic names
  2303. ............................
  2304. The problems mentioned in the last section derive from the fact that:
  2305. 1. the numbers are allocated once and due to the possibly frequent use
  2306. of them it is difficult to change a number later.
  2307. 2. the numbers do not allow guessing anything about the string and
  2308. therefore collisions can easily happen.
  2309. By constantly using symbolic names and by providing a method which
  2310. maps the string content to a symbolic name (however this will happen)
  2311. one can prevent both problems above. The cost of this is that the
  2312. programmer has to write a complete message catalog file while s/he is
  2313. writing the program itself.
  2314. This is necessary since the symbolic names must be mapped to numbers
  2315. before the program sources can be compiled. In the last section it was
  2316. described how to generate a header containing the mapping of the names.
  2317. E.g., for the example message file given in the last section we could
  2318. call the ‘gencat’ program as follows (assume ‘ex.msg’ contains the
  2319. sources).
  2320. gencat -H ex.h -o ex.cat ex.msg
  2321. This generates a header file with the following content:
  2322. #define SetTwoSet 0x2 /* ex.msg:8 */
  2323. #define SetOneSet 0x1 /* ex.msg:4 */
  2324. #define SetOnetwo 0x2 /* ex.msg:6 */
  2325. As can be seen the various symbols given in the source file are
  2326. mangled to generate unique identifiers and these identifiers get numbers
  2327. assigned. Reading the source file and knowing about the rules will
  2328. allow to predict the content of the header file (it is deterministic)
  2329. but this is not necessary. The ‘gencat’ program can take care for
  2330. everything. All the programmer has to do is to put the generated header
  2331. file in the dependency list of the source files of her/his project and
  2332. add a rule to regenerate the header if any of the input files change.
  2333. One word about the symbol mangling. Every symbol consists of two
  2334. parts: the name of the message set plus the name of the message or the
  2335. special string ‘Set’. So ‘SetOnetwo’ means this macro can be used to
  2336. access the translation with identifier ‘two’ in the message set
  2337. ‘SetOne’.
  2338. The other names denote the names of the message sets. The special
  2339. string ‘Set’ is used in the place of the message identifier.
  2340. If in the code the second string of the set ‘SetOne’ is used the C
  2341. code should look like this:
  2342. catgets (catdesc, SetOneSet, SetOnetwo,
  2343. " Message with ID \"two\", which gets the value 2 assigned")
  2344. Writing the function this way will allow to change the message number
  2345. and even the set number without requiring any change in the C source
  2346. code. (The text of the string is normally not the same; this is only
  2347. for this example.)
  2348. 8.1.4.3 How does to this allow to develop
  2349. .........................................
  2350. To illustrate the usual way to work with the symbolic version numbers
  2351. here is a little example. Assume we want to write the very complex and
  2352. famous greeting program. We start by writing the code as usual:
  2353. #include <stdio.h>
  2354. int
  2355. main (void)
  2356. {
  2357. printf ("Hello, world!\n");
  2358. return 0;
  2359. }
  2360. Now we want to internationalize the message and therefore replace the
  2361. message with whatever the user wants.
  2362. #include <nl_types.h>
  2363. #include <stdio.h>
  2364. #include "msgnrs.h"
  2365. int
  2366. main (void)
  2367. {
  2368. nl_catd catdesc = catopen ("hello.cat", NL_CAT_LOCALE);
  2369. printf (catgets (catdesc, SetMainSet, SetMainHello,
  2370. "Hello, world!\n"));
  2371. catclose (catdesc);
  2372. return 0;
  2373. }
  2374. We see how the catalog object is opened and the returned descriptor
  2375. used in the other function calls. It is not really necessary to check
  2376. for failure of any of the functions since even in these situations the
  2377. functions will behave reasonable. They simply will be return a
  2378. translation.
  2379. What remains unspecified here are the constants ‘SetMainSet’ and
  2380. ‘SetMainHello’. These are the symbolic names describing the message.
  2381. To get the actual definitions which match the information in the catalog
  2382. file we have to create the message catalog source file and process it
  2383. using the ‘gencat’ program.
  2384. $ Messages for the famous greeting program.
  2385. $quote "
  2386. $set Main
  2387. Hello "Hallo, Welt!\n"
  2388. Now we can start building the program (assume the message catalog
  2389. source file is named ‘hello.msg’ and the program source file ‘hello.c’):
  2390. % gencat -H msgnrs.h -o hello.cat hello.msg
  2391. % cat msgnrs.h
  2392. #define MainSet 0x1 /* hello.msg:4 */
  2393. #define MainHello 0x1 /* hello.msg:5 */
  2394. % gcc -o hello hello.c -I.
  2395. % cp hello.cat /usr/share/locale/de/LC_MESSAGES
  2396. % echo $LC_ALL
  2397. de
  2398. % ./hello
  2399. Hallo, Welt!
  2400. %
  2401. The call of the ‘gencat’ program creates the missing header file
  2402. ‘msgnrs.h’ as well as the message catalog binary. The former is used in
  2403. the compilation of ‘hello.c’ while the later is placed in a directory in
  2404. which the ‘catopen’ function will try to locate it. Please check the
  2405. ‘LC_ALL’ environment variable and the default path for ‘catopen’
  2406. presented in the description above.
  2407. 
  2408. File: libc.info, Node: The Uniforum approach, Prev: Message catalogs a la X/Open, Up: Message Translation
  2409. 8.2 The Uniforum approach to Message Translation
  2410. ================================================
  2411. Sun Microsystems tried to standardize a different approach to message
  2412. translation in the Uniforum group. There never was a real standard
  2413. defined but still the interface was used in Sun’s operating systems.
  2414. Since this approach fits better in the development process of free
  2415. software it is also used throughout the GNU project and the GNU
  2416. ‘gettext’ package provides support for this outside the GNU C Library.
  2417. The code of the ‘libintl’ from GNU ‘gettext’ is the same as the code
  2418. in the GNU C Library. So the documentation in the GNU ‘gettext’ manual
  2419. is also valid for the functionality here. The following text will
  2420. describe the library functions in detail. But the numerous helper
  2421. programs are not described in this manual. Instead people should read
  2422. the GNU ‘gettext’ manual (*note GNU gettext utilities: (gettext)Top.).
  2423. We will only give a short overview.
  2424. Though the ‘catgets’ functions are available by default on more
  2425. systems the ‘gettext’ interface is at least as portable as the former.
  2426. The GNU ‘gettext’ package can be used wherever the functions are not
  2427. available.
  2428. * Menu:
  2429. * Message catalogs with gettext:: The ‘gettext’ family of functions.
  2430. * Helper programs for gettext:: Programs to handle message catalogs
  2431. for ‘gettext’.
  2432. 
  2433. File: libc.info, Node: Message catalogs with gettext, Next: Helper programs for gettext, Up: The Uniforum approach
  2434. 8.2.1 The ‘gettext’ family of functions
  2435. ---------------------------------------
  2436. The paradigms underlying the ‘gettext’ approach to message translations
  2437. is different from that of the ‘catgets’ functions the basic functionally
  2438. is equivalent. There are functions of the following categories:
  2439. * Menu:
  2440. * Translation with gettext:: What has to be done to translate a message.
  2441. * Locating gettext catalog:: How to determine which catalog to be used.
  2442. * Advanced gettext functions:: Additional functions for more complicated
  2443. situations.
  2444. * Charset conversion in gettext:: How to specify the output character set
  2445. ‘gettext’ uses.
  2446. * GUI program problems:: How to use ‘gettext’ in GUI programs.
  2447. * Using gettextized software:: The possibilities of the user to influence
  2448. the way ‘gettext’ works.
  2449. 
  2450. File: libc.info, Node: Translation with gettext, Next: Locating gettext catalog, Up: Message catalogs with gettext
  2451. 8.2.1.1 What has to be done to translate a message?
  2452. ...................................................
  2453. The ‘gettext’ functions have a very simple interface. The most basic
  2454. function just takes the string which shall be translated as the argument
  2455. and it returns the translation. This is fundamentally different from
  2456. the ‘catgets’ approach where an extra key is necessary and the original
  2457. string is only used for the error case.
  2458. If the string which has to be translated is the only argument this of
  2459. course means the string itself is the key. I.e., the translation will
  2460. be selected based on the original string. The message catalogs must
  2461. therefore contain the original strings plus one translation for any such
  2462. string. The task of the ‘gettext’ function is to compare the argument
  2463. string with the available strings in the catalog and return the
  2464. appropriate translation. Of course this process is optimized so that
  2465. this process is not more expensive than an access using an atomic key
  2466. like in ‘catgets’.
  2467. The ‘gettext’ approach has some advantages but also some
  2468. disadvantages. Please see the GNU ‘gettext’ manual for a detailed
  2469. discussion of the pros and cons.
  2470. All the definitions and declarations for ‘gettext’ can be found in
  2471. the ‘libintl.h’ header file. On systems where these functions are not
  2472. part of the C library they can be found in a separate library named
  2473. ‘libintl.a’ (or accordingly different for shared libraries).
  2474. -- Function: char * gettext (const char *MSGID)
  2475. Preliminary: | MT-Safe env | AS-Unsafe corrupt heap lock dlopen |
  2476. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  2477. The ‘gettext’ function searches the currently selected message
  2478. catalogs for a string which is equal to MSGID. If there is such a
  2479. string available it is returned. Otherwise the argument string
  2480. MSGID is returned.
  2481. Please note that although the return value is ‘char *’ the returned
  2482. string must not be changed. This broken type results from the
  2483. history of the function and does not reflect the way the function
  2484. should be used.
  2485. Please note that above we wrote “message catalogs” (plural). This
  2486. is a specialty of the GNU implementation of these functions and we
  2487. will say more about this when we talk about the ways message
  2488. catalogs are selected (*note Locating gettext catalog::).
  2489. The ‘gettext’ function does not modify the value of the global
  2490. ‘errno’ variable. This is necessary to make it possible to write
  2491. something like
  2492. printf (gettext ("Operation failed: %m\n"));
  2493. Here the ‘errno’ value is used in the ‘printf’ function while
  2494. processing the ‘%m’ format element and if the ‘gettext’ function
  2495. would change this value (it is called before ‘printf’ is called) we
  2496. would get a wrong message.
  2497. So there is no easy way to detect a missing message catalog besides
  2498. comparing the argument string with the result. But it is normally
  2499. the task of the user to react on missing catalogs. The program
  2500. cannot guess when a message catalog is really necessary since for a
  2501. user who speaks the language the program was developed in, the
  2502. message does not need any translation.
  2503. The remaining two functions to access the message catalog add some
  2504. functionality to select a message catalog which is not the default one.
  2505. This is important if parts of the program are developed independently.
  2506. Every part can have its own message catalog and all of them can be used
  2507. at the same time. The C library itself is an example: internally it
  2508. uses the ‘gettext’ functions but since it must not depend on a currently
  2509. selected default message catalog it must specify all ambiguous
  2510. information.
  2511. -- Function: char * dgettext (const char *DOMAINNAME, const char
  2512. *MSGID)
  2513. Preliminary: | MT-Safe env | AS-Unsafe corrupt heap lock dlopen |
  2514. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  2515. The ‘dgettext’ function acts just like the ‘gettext’ function. It
  2516. only takes an additional first argument DOMAINNAME which guides the
  2517. selection of the message catalogs which are searched for the
  2518. translation. If the DOMAINNAME parameter is the null pointer the
  2519. ‘dgettext’ function is exactly equivalent to ‘gettext’ since the
  2520. default value for the domain name is used.
  2521. As for ‘gettext’ the return value type is ‘char *’ which is an
  2522. anachronism. The returned string must never be modified.
  2523. -- Function: char * dcgettext (const char *DOMAINNAME, const char
  2524. *MSGID, int CATEGORY)
  2525. Preliminary: | MT-Safe env | AS-Unsafe corrupt heap lock dlopen |
  2526. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  2527. The ‘dcgettext’ adds another argument to those which ‘dgettext’
  2528. takes. This argument CATEGORY specifies the last piece of
  2529. information needed to localize the message catalog. I.e., the
  2530. domain name and the locale category exactly specify which message
  2531. catalog has to be used (relative to a given directory, see below).
  2532. The ‘dgettext’ function can be expressed in terms of ‘dcgettext’ by
  2533. using
  2534. dcgettext (domain, string, LC_MESSAGES)
  2535. instead of
  2536. dgettext (domain, string)
  2537. This also shows which values are expected for the third parameter.
  2538. One has to use the available selectors for the categories available
  2539. in ‘locale.h’. Normally the available values are ‘LC_CTYPE’,
  2540. ‘LC_COLLATE’, ‘LC_MESSAGES’, ‘LC_MONETARY’, ‘LC_NUMERIC’, and
  2541. ‘LC_TIME’. Please note that ‘LC_ALL’ must not be used and even
  2542. though the names might suggest this, there is no relation to the
  2543. environment variable of this name.
  2544. The ‘dcgettext’ function is only implemented for compatibility with
  2545. other systems which have ‘gettext’ functions. There is not really
  2546. any situation where it is necessary (or useful) to use a different
  2547. value than ‘LC_MESSAGES’ for the CATEGORY parameter. We are
  2548. dealing with messages here and any other choice can only be
  2549. irritating.
  2550. As for ‘gettext’ the return value type is ‘char *’ which is an
  2551. anachronism. The returned string must never be modified.
  2552. When using the three functions above in a program it is a frequent
  2553. case that the MSGID argument is a constant string. So it is worthwhile
  2554. to optimize this case. Thinking shortly about this one will realize
  2555. that as long as no new message catalog is loaded the translation of a
  2556. message will not change. This optimization is actually implemented by
  2557. the ‘gettext’, ‘dgettext’ and ‘dcgettext’ functions.
  2558. 
  2559. File: libc.info, Node: Locating gettext catalog, Next: Advanced gettext functions, Prev: Translation with gettext, Up: Message catalogs with gettext
  2560. 8.2.1.2 How to determine which catalog to be used
  2561. .................................................
  2562. The functions to retrieve the translations for a given message have a
  2563. remarkable simple interface. But to provide the user of the program
  2564. still the opportunity to select exactly the translation s/he wants and
  2565. also to provide the programmer the possibility to influence the way to
  2566. locate the search for catalogs files there is a quite complicated
  2567. underlying mechanism which controls all this. The code is complicated
  2568. the use is easy.
  2569. Basically we have two different tasks to perform which can also be
  2570. performed by the ‘catgets’ functions:
  2571. 1. Locate the set of message catalogs. There are a number of files
  2572. for different languages which all belong to the package. Usually
  2573. they are all stored in the filesystem below a certain directory.
  2574. There can be arbitrarily many packages installed and they can
  2575. follow different guidelines for the placement of their files.
  2576. 2. Relative to the location specified by the package the actual
  2577. translation files must be searched, based on the wishes of the
  2578. user. I.e., for each language the user selects the program should
  2579. be able to locate the appropriate file.
  2580. This is the functionality required by the specifications for
  2581. ‘gettext’ and this is also what the ‘catgets’ functions are able to do.
  2582. But there are some problems unresolved:
  2583. • The language to be used can be specified in several different ways.
  2584. There is no generally accepted standard for this and the user
  2585. always expects the program to understand what s/he means. E.g., to
  2586. select the German translation one could write ‘de’, ‘german’, or
  2587. ‘deutsch’ and the program should always react the same.
  2588. • Sometimes the specification of the user is too detailed. If s/he,
  2589. e.g., specifies ‘de_DE.ISO-8859-1’ which means German, spoken in
  2590. Germany, coded using the ISO 8859-1 character set there is the
  2591. possibility that a message catalog matching this exactly is not
  2592. available. But there could be a catalog matching ‘de’ and if the
  2593. character set used on the machine is always ISO 8859-1 there is no
  2594. reason why this later message catalog should not be used. (We call
  2595. this “message inheritance”.)
  2596. • If a catalog for a wanted language is not available it is not
  2597. always the second best choice to fall back on the language of the
  2598. developer and simply not translate any message. Instead a user
  2599. might be better able to read the messages in another language and
  2600. so the user of the program should be able to define a precedence
  2601. order of languages.
  2602. We can divide the configuration actions in two parts: the one is
  2603. performed by the programmer, the other by the user. We will start with
  2604. the functions the programmer can use since the user configuration will
  2605. be based on this.
  2606. As the functions described in the last sections already mention
  2607. separate sets of messages can be selected by a “domain name”. This is a
  2608. simple string which should be unique for each program part that uses a
  2609. separate domain. It is possible to use in one program arbitrarily many
  2610. domains at the same time. E.g., the GNU C Library itself uses a domain
  2611. named ‘libc’ while the program using the C Library could use a domain
  2612. named ‘foo’. The important point is that at any time exactly one domain
  2613. is active. This is controlled with the following function.
  2614. -- Function: char * textdomain (const char *DOMAINNAME)
  2615. Preliminary: | MT-Safe | AS-Unsafe lock heap | AC-Unsafe lock mem |
  2616. *Note POSIX Safety Concepts::.
  2617. The ‘textdomain’ function sets the default domain, which is used in
  2618. all future ‘gettext’ calls, to DOMAINNAME. Please note that
  2619. ‘dgettext’ and ‘dcgettext’ calls are not influenced if the
  2620. DOMAINNAME parameter of these functions is not the null pointer.
  2621. Before the first call to ‘textdomain’ the default domain is
  2622. ‘messages’. This is the name specified in the specification of the
  2623. ‘gettext’ API. This name is as good as any other name. No program
  2624. should ever really use a domain with this name since this can only
  2625. lead to problems.
  2626. The function returns the value which is from now on taken as the
  2627. default domain. If the system went out of memory the returned
  2628. value is ‘NULL’ and the global variable ‘errno’ is set to ‘ENOMEM’.
  2629. Despite the return value type being ‘char *’ the return string must
  2630. not be changed. It is allocated internally by the ‘textdomain’
  2631. function.
  2632. If the DOMAINNAME parameter is the null pointer no new default
  2633. domain is set. Instead the currently selected default domain is
  2634. returned.
  2635. If the DOMAINNAME parameter is the empty string the default domain
  2636. is reset to its initial value, the domain with the name ‘messages’.
  2637. This possibility is questionable to use since the domain ‘messages’
  2638. really never should be used.
  2639. -- Function: char * bindtextdomain (const char *DOMAINNAME, const char
  2640. *DIRNAME)
  2641. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  2642. POSIX Safety Concepts::.
  2643. The ‘bindtextdomain’ function can be used to specify the directory
  2644. which contains the message catalogs for domain DOMAINNAME for the
  2645. different languages. To be correct, this is the directory where
  2646. the hierarchy of directories is expected. Details are explained
  2647. below.
  2648. For the programmer it is important to note that the translations
  2649. which come with the program have to be placed in a directory
  2650. hierarchy starting at, say, ‘/foo/bar’. Then the program should
  2651. make a ‘bindtextdomain’ call to bind the domain for the current
  2652. program to this directory. So it is made sure the catalogs are
  2653. found. A correctly running program does not depend on the user
  2654. setting an environment variable.
  2655. The ‘bindtextdomain’ function can be used several times and if the
  2656. DOMAINNAME argument is different the previously bound domains will
  2657. not be overwritten.
  2658. If the program which wish to use ‘bindtextdomain’ at some point of
  2659. time use the ‘chdir’ function to change the current working
  2660. directory it is important that the DIRNAME strings ought to be an
  2661. absolute pathname. Otherwise the addressed directory might vary
  2662. with the time.
  2663. If the DIRNAME parameter is the null pointer ‘bindtextdomain’
  2664. returns the currently selected directory for the domain with the
  2665. name DOMAINNAME.
  2666. The ‘bindtextdomain’ function returns a pointer to a string
  2667. containing the name of the selected directory name. The string is
  2668. allocated internally in the function and must not be changed by the
  2669. user. If the system went out of core during the execution of
  2670. ‘bindtextdomain’ the return value is ‘NULL’ and the global variable
  2671. ‘errno’ is set accordingly.
  2672. 
  2673. File: libc.info, Node: Advanced gettext functions, Next: Charset conversion in gettext, Prev: Locating gettext catalog, Up: Message catalogs with gettext
  2674. 8.2.1.3 Additional functions for more complicated situations
  2675. ............................................................
  2676. The functions of the ‘gettext’ family described so far (and all the
  2677. ‘catgets’ functions as well) have one problem in the real world which
  2678. has been neglected completely in all existing approaches. What is meant
  2679. here is the handling of plural forms.
  2680. Looking through Unix source code before the time anybody thought
  2681. about internationalization (and, sadly, even afterwards) one can often
  2682. find code similar to the following:
  2683. printf ("%d file%s deleted", n, n == 1 ? "" : "s");
  2684. After the first complaints from people internationalizing the code
  2685. people either completely avoided formulations like this or used strings
  2686. like ‘"file(s)"’. Both look unnatural and should be avoided. First
  2687. tries to solve the problem correctly looked like this:
  2688. if (n == 1)
  2689. printf ("%d file deleted", n);
  2690. else
  2691. printf ("%d files deleted", n);
  2692. But this does not solve the problem. It helps languages where the
  2693. plural form of a noun is not simply constructed by adding an ‘s’ but
  2694. that is all. Once again people fell into the trap of believing the
  2695. rules their language uses are universal. But the handling of plural
  2696. forms differs widely between the language families. There are two
  2697. things we can differ between (and even inside language families);
  2698. • The form how plural forms are build differs. This is a problem
  2699. with language which have many irregularities. German, for
  2700. instance, is a drastic case. Though English and German are part of
  2701. the same language family (Germanic), the almost regular forming of
  2702. plural noun forms (appending an ‘s’) is hardly found in German.
  2703. • The number of plural forms differ. This is somewhat surprising for
  2704. those who only have experiences with Romanic and Germanic languages
  2705. since here the number is the same (there are two).
  2706. But other language families have only one form or many forms. More
  2707. information on this in an extra section.
  2708. The consequence of this is that application writers should not try to
  2709. solve the problem in their code. This would be localization since it is
  2710. only usable for certain, hardcoded language environments. Instead the
  2711. extended ‘gettext’ interface should be used.
  2712. These extra functions are taking instead of the one key string two
  2713. strings and a numerical argument. The idea behind this is that using
  2714. the numerical argument and the first string as a key, the implementation
  2715. can select using rules specified by the translator the right plural
  2716. form. The two string arguments then will be used to provide a return
  2717. value in case no message catalog is found (similar to the normal
  2718. ‘gettext’ behavior). In this case the rules for Germanic language are
  2719. used and it is assumed that the first string argument is the singular
  2720. form, the second the plural form.
  2721. This has the consequence that programs without language catalogs can
  2722. display the correct strings only if the program itself is written using
  2723. a Germanic language. This is a limitation but since the GNU C Library
  2724. (as well as the GNU ‘gettext’ package) is written as part of the GNU
  2725. package and the coding standards for the GNU project require programs to
  2726. be written in English, this solution nevertheless fulfills its purpose.
  2727. -- Function: char * ngettext (const char *MSGID1, const char *MSGID2,
  2728. unsigned long int N)
  2729. Preliminary: | MT-Safe env | AS-Unsafe corrupt heap lock dlopen |
  2730. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  2731. The ‘ngettext’ function is similar to the ‘gettext’ function as it
  2732. finds the message catalogs in the same way. But it takes two extra
  2733. arguments. The MSGID1 parameter must contain the singular form of
  2734. the string to be converted. It is also used as the key for the
  2735. search in the catalog. The MSGID2 parameter is the plural form.
  2736. The parameter N is used to determine the plural form. If no
  2737. message catalog is found MSGID1 is returned if ‘n == 1’, otherwise
  2738. ‘msgid2’.
  2739. An example for the use of this function is:
  2740. printf (ngettext ("%d file removed", "%d files removed", n), n);
  2741. Please note that the numeric value N has to be passed to the
  2742. ‘printf’ function as well. It is not sufficient to pass it only to
  2743. ‘ngettext’.
  2744. -- Function: char * dngettext (const char *DOMAIN, const char *MSGID1,
  2745. const char *MSGID2, unsigned long int N)
  2746. Preliminary: | MT-Safe env | AS-Unsafe corrupt heap lock dlopen |
  2747. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  2748. The ‘dngettext’ is similar to the ‘dgettext’ function in the way
  2749. the message catalog is selected. The difference is that it takes
  2750. two extra parameters to provide the correct plural form. These two
  2751. parameters are handled in the same way ‘ngettext’ handles them.
  2752. -- Function: char * dcngettext (const char *DOMAIN, const char *MSGID1,
  2753. const char *MSGID2, unsigned long int N, int CATEGORY)
  2754. Preliminary: | MT-Safe env | AS-Unsafe corrupt heap lock dlopen |
  2755. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  2756. The ‘dcngettext’ is similar to the ‘dcgettext’ function in the way
  2757. the message catalog is selected. The difference is that it takes
  2758. two extra parameters to provide the correct plural form. These two
  2759. parameters are handled in the same way ‘ngettext’ handles them.
  2760. The problem of plural forms
  2761. ...........................
  2762. A description of the problem can be found at the beginning of the last
  2763. section. Now there is the question how to solve it. Without the input
  2764. of linguists (which was not available) it was not possible to determine
  2765. whether there are only a few different forms in which plural forms are
  2766. formed or whether the number can increase with every new supported
  2767. language.
  2768. Therefore the solution implemented is to allow the translator to
  2769. specify the rules of how to select the plural form. Since the formula
  2770. varies with every language this is the only viable solution except for
  2771. hardcoding the information in the code (which still would require the
  2772. possibility of extensions to not prevent the use of new languages). The
  2773. details are explained in the GNU ‘gettext’ manual. Here only a bit of
  2774. information is provided.
  2775. The information about the plural form selection has to be stored in
  2776. the header entry (the one with the empty ‘msgid’ string). It looks like
  2777. this:
  2778. Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1;
  2779. The ‘nplurals’ value must be a decimal number which specifies how
  2780. many different plural forms exist for this language. The string
  2781. following ‘plural’ is an expression using the C language syntax.
  2782. Exceptions are that no negative numbers are allowed, numbers must be
  2783. decimal, and the only variable allowed is ‘n’. This expression will be
  2784. evaluated whenever one of the functions ‘ngettext’, ‘dngettext’, or
  2785. ‘dcngettext’ is called. The numeric value passed to these functions is
  2786. then substituted for all uses of the variable ‘n’ in the expression.
  2787. The resulting value then must be greater or equal to zero and smaller
  2788. than the value given as the value of ‘nplurals’.
  2789. The following rules are known at this point. The language with families
  2790. are listed. But this does not necessarily mean the information can be
  2791. generalized for the whole family (as can be easily seen in the table
  2792. below).(1)
  2793. Only one form:
  2794. Some languages only require one single form. There is no
  2795. distinction between the singular and plural form. An appropriate
  2796. header entry would look like this:
  2797. Plural-Forms: nplurals=1; plural=0;
  2798. Languages with this property include:
  2799. Finno-Ugric family
  2800. Hungarian
  2801. Asian family
  2802. Japanese, Korean
  2803. Turkic/Altaic family
  2804. Turkish
  2805. Two forms, singular used for one only
  2806. This is the form used in most existing programs since it is what
  2807. English uses. A header entry would look like this:
  2808. Plural-Forms: nplurals=2; plural=n != 1;
  2809. (Note: this uses the feature of C expressions that boolean
  2810. expressions have to value zero or one.)
  2811. Languages with this property include:
  2812. Germanic family
  2813. Danish, Dutch, English, German, Norwegian, Swedish
  2814. Finno-Ugric family
  2815. Estonian, Finnish
  2816. Latin/Greek family
  2817. Greek
  2818. Semitic family
  2819. Hebrew
  2820. Romance family
  2821. Italian, Portuguese, Spanish
  2822. Artificial
  2823. Esperanto
  2824. Two forms, singular used for zero and one
  2825. Exceptional case in the language family. The header entry would
  2826. be:
  2827. Plural-Forms: nplurals=2; plural=n>1;
  2828. Languages with this property include:
  2829. Romanic family
  2830. French, Brazilian Portuguese
  2831. Three forms, special case for zero
  2832. The header entry would be:
  2833. Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2;
  2834. Languages with this property include:
  2835. Baltic family
  2836. Latvian
  2837. Three forms, special cases for one and two
  2838. The header entry would be:
  2839. Plural-Forms: nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;
  2840. Languages with this property include:
  2841. Celtic
  2842. Gaeilge (Irish)
  2843. Three forms, special case for numbers ending in 1[2-9]
  2844. The header entry would look like this:
  2845. Plural-Forms: nplurals=3; \
  2846. plural=n%10==1 && n%100!=11 ? 0 : \
  2847. n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2;
  2848. Languages with this property include:
  2849. Baltic family
  2850. Lithuanian
  2851. Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]
  2852. The header entry would look like this:
  2853. Plural-Forms: nplurals=3; \
  2854. plural=n%100/10==1 ? 2 : n%10==1 ? 0 : (n+9)%10>3 ? 2 : 1;
  2855. Languages with this property include:
  2856. Slavic family
  2857. Croatian, Czech, Russian, Ukrainian
  2858. Three forms, special cases for 1 and 2, 3, 4
  2859. The header entry would look like this:
  2860. Plural-Forms: nplurals=3; \
  2861. plural=(n==1) ? 1 : (n>=2 && n<=4) ? 2 : 0;
  2862. Languages with this property include:
  2863. Slavic family
  2864. Slovak
  2865. Three forms, special case for one and some numbers ending in 2, 3, or 4
  2866. The header entry would look like this:
  2867. Plural-Forms: nplurals=3; \
  2868. plural=n==1 ? 0 : \
  2869. n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
  2870. Languages with this property include:
  2871. Slavic family
  2872. Polish
  2873. Four forms, special case for one and all numbers ending in 02, 03, or 04
  2874. The header entry would look like this:
  2875. Plural-Forms: nplurals=4; \
  2876. plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3;
  2877. Languages with this property include:
  2878. Slavic family
  2879. Slovenian
  2880. ---------- Footnotes ----------
  2881. (1) Additions are welcome. Send appropriate information to
  2882. <bug-glibc-manual@gnu.org>.
  2883. 
  2884. File: libc.info, Node: Charset conversion in gettext, Next: GUI program problems, Prev: Advanced gettext functions, Up: Message catalogs with gettext
  2885. 8.2.1.4 How to specify the output character set ‘gettext’ uses
  2886. ..............................................................
  2887. ‘gettext’ not only looks up a translation in a message catalog, it also
  2888. converts the translation on the fly to the desired output character set.
  2889. This is useful if the user is working in a different character set than
  2890. the translator who created the message catalog, because it avoids
  2891. distributing variants of message catalogs which differ only in the
  2892. character set.
  2893. The output character set is, by default, the value of ‘nl_langinfo
  2894. (CODESET)’, which depends on the ‘LC_CTYPE’ part of the current locale.
  2895. But programs which store strings in a locale independent way (e.g.
  2896. UTF-8) can request that ‘gettext’ and related functions return the
  2897. translations in that encoding, by use of the ‘bind_textdomain_codeset’
  2898. function.
  2899. Note that the MSGID argument to ‘gettext’ is not subject to character
  2900. set conversion. Also, when ‘gettext’ does not find a translation for
  2901. MSGID, it returns MSGID unchanged – independently of the current output
  2902. character set. It is therefore recommended that all MSGIDs be US-ASCII
  2903. strings.
  2904. -- Function: char * bind_textdomain_codeset (const char *DOMAINNAME,
  2905. const char *CODESET)
  2906. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  2907. POSIX Safety Concepts::.
  2908. The ‘bind_textdomain_codeset’ function can be used to specify the
  2909. output character set for message catalogs for domain DOMAINNAME.
  2910. The CODESET argument must be a valid codeset name which can be used
  2911. for the ‘iconv_open’ function, or a null pointer.
  2912. If the CODESET parameter is the null pointer,
  2913. ‘bind_textdomain_codeset’ returns the currently selected codeset
  2914. for the domain with the name DOMAINNAME. It returns ‘NULL’ if no
  2915. codeset has yet been selected.
  2916. The ‘bind_textdomain_codeset’ function can be used several times.
  2917. If used multiple times with the same DOMAINNAME argument, the later
  2918. call overrides the settings made by the earlier one.
  2919. The ‘bind_textdomain_codeset’ function returns a pointer to a
  2920. string containing the name of the selected codeset. The string is
  2921. allocated internally in the function and must not be changed by the
  2922. user. If the system went out of core during the execution of
  2923. ‘bind_textdomain_codeset’, the return value is ‘NULL’ and the
  2924. global variable ‘errno’ is set accordingly.
  2925. 
  2926. File: libc.info, Node: GUI program problems, Next: Using gettextized software, Prev: Charset conversion in gettext, Up: Message catalogs with gettext
  2927. 8.2.1.5 How to use ‘gettext’ in GUI programs
  2928. ............................................
  2929. One place where the ‘gettext’ functions, if used normally, have big
  2930. problems is within programs with graphical user interfaces (GUIs). The
  2931. problem is that many of the strings which have to be translated are very
  2932. short. They have to appear in pull-down menus which restricts the
  2933. length. But strings which are not containing entire sentences or at
  2934. least large fragments of a sentence may appear in more than one
  2935. situation in the program but might have different translations. This is
  2936. especially true for the one-word strings which are frequently used in
  2937. GUI programs.
  2938. As a consequence many people say that the ‘gettext’ approach is wrong
  2939. and instead ‘catgets’ should be used which indeed does not have this
  2940. problem. But there is a very simple and powerful method to handle these
  2941. kind of problems with the ‘gettext’ functions.
  2942. As an example consider the following fictional situation. A GUI program
  2943. has a menu bar with the following entries:
  2944. +------------+------------+--------------------------------------+
  2945. | File | Printer | |
  2946. +------------+------------+--------------------------------------+
  2947. | Open | | Select |
  2948. | New | | Open |
  2949. +----------+ | Connect |
  2950. +----------+
  2951. To have the strings ‘File’, ‘Printer’, ‘Open’, ‘New’, ‘Select’, and
  2952. ‘Connect’ translated there has to be at some point in the code a call to
  2953. a function of the ‘gettext’ family. But in two places the string passed
  2954. into the function would be ‘Open’. The translations might not be the
  2955. same and therefore we are in the dilemma described above.
  2956. One solution to this problem is to artificially extend the strings to
  2957. make them unambiguous. But what would the program do if no translation
  2958. is available? The extended string is not what should be printed. So we
  2959. should use a slightly modified version of the functions.
  2960. To extend the strings a uniform method should be used. E.g., in the
  2961. example above, the strings could be chosen as
  2962. Menu|File
  2963. Menu|Printer
  2964. Menu|File|Open
  2965. Menu|File|New
  2966. Menu|Printer|Select
  2967. Menu|Printer|Open
  2968. Menu|Printer|Connect
  2969. Now all the strings are different and if now instead of ‘gettext’ the
  2970. following little wrapper function is used, everything works just fine:
  2971. char *
  2972. sgettext (const char *msgid)
  2973. {
  2974. char *msgval = gettext (msgid);
  2975. if (msgval == msgid)
  2976. msgval = strrchr (msgid, '|') + 1;
  2977. return msgval;
  2978. }
  2979. What this little function does is to recognize the case when no
  2980. translation is available. This can be done very efficiently by a
  2981. pointer comparison since the return value is the input value. If there
  2982. is no translation we know that the input string is in the format we used
  2983. for the Menu entries and therefore contains a ‘|’ character. We simply
  2984. search for the last occurrence of this character and return a pointer to
  2985. the character following it. That’s it!
  2986. If one now consistently uses the extended string form and replaces
  2987. the ‘gettext’ calls with calls to ‘sgettext’ (this is normally limited
  2988. to very few places in the GUI implementation) then it is possible to
  2989. produce a program which can be internationalized.
  2990. With advanced compilers (such as GNU C) one can write the ‘sgettext’
  2991. functions as an inline function or as a macro like this:
  2992. #define sgettext(msgid) \
  2993. ({ const char *__msgid = (msgid); \
  2994. char *__msgstr = gettext (__msgid); \
  2995. if (__msgval == __msgid) \
  2996. __msgval = strrchr (__msgid, '|') + 1; \
  2997. __msgval; })
  2998. The other ‘gettext’ functions (‘dgettext’, ‘dcgettext’ and the
  2999. ‘ngettext’ equivalents) can and should have corresponding functions as
  3000. well which look almost identical, except for the parameters and the call
  3001. to the underlying function.
  3002. Now there is of course the question why such functions do not exist
  3003. in the GNU C Library? There are two parts of the answer to this
  3004. question.
  3005. • They are easy to write and therefore can be provided by the project
  3006. they are used in. This is not an answer by itself and must be seen
  3007. together with the second part which is:
  3008. • There is no way the C library can contain a version which can work
  3009. everywhere. The problem is the selection of the character to
  3010. separate the prefix from the actual string in the extended string.
  3011. The examples above used ‘|’ which is a quite good choice because it
  3012. resembles a notation frequently used in this context and it also is
  3013. a character not often used in message strings.
  3014. But what if the character is used in message strings. Or if the
  3015. chose character is not available in the character set on the
  3016. machine one compiles (e.g., ‘|’ is not required to exist for ISO C;
  3017. this is why the ‘iso646.h’ file exists in ISO C programming
  3018. environments).
  3019. There is only one more comment to make left. The wrapper function
  3020. above requires that the translations strings are not extended
  3021. themselves. This is only logical. There is no need to disambiguate the
  3022. strings (since they are never used as keys for a search) and one also
  3023. saves quite some memory and disk space by doing this.
  3024. 
  3025. File: libc.info, Node: Using gettextized software, Prev: GUI program problems, Up: Message catalogs with gettext
  3026. 8.2.1.6 User influence on ‘gettext’
  3027. ...................................
  3028. The last sections described what the programmer can do to
  3029. internationalize the messages of the program. But it is finally up to
  3030. the user to select the message s/he wants to see. S/He must understand
  3031. them.
  3032. The POSIX locale model uses the environment variables ‘LC_COLLATE’,
  3033. ‘LC_CTYPE’, ‘LC_MESSAGES’, ‘LC_MONETARY’, ‘LC_NUMERIC’, and ‘LC_TIME’ to
  3034. select the locale which is to be used. This way the user can influence
  3035. lots of functions. As we mentioned above, the ‘gettext’ functions also
  3036. take advantage of this.
  3037. To understand how this happens it is necessary to take a look at the
  3038. various components of the filename which gets computed to locate a
  3039. message catalog. It is composed as follows:
  3040. DIR_NAME/LOCALE/LC_CATEGORY/DOMAIN_NAME.mo
  3041. The default value for DIR_NAME is system specific. It is computed
  3042. from the value given as the prefix while configuring the C library.
  3043. This value normally is ‘/usr’ or ‘/’. For the former the complete
  3044. DIR_NAME is:
  3045. /usr/share/locale
  3046. We can use ‘/usr/share’ since the ‘.mo’ files containing the message
  3047. catalogs are system independent, so all systems can use the same files.
  3048. If the program executed the ‘bindtextdomain’ function for the message
  3049. domain that is currently handled, the ‘dir_name’ component is exactly
  3050. the value which was given to the function as the second parameter.
  3051. I.e., ‘bindtextdomain’ allows overwriting the only system dependent and
  3052. fixed value to make it possible to address files anywhere in the
  3053. filesystem.
  3054. The CATEGORY is the name of the locale category which was selected in
  3055. the program code. For ‘gettext’ and ‘dgettext’ this is always
  3056. ‘LC_MESSAGES’, for ‘dcgettext’ this is selected by the value of the
  3057. third parameter. As said above it should be avoided to ever use a
  3058. category other than ‘LC_MESSAGES’.
  3059. The LOCALE component is computed based on the category used. Just
  3060. like for the ‘setlocale’ function here comes the user selection into the
  3061. play. Some environment variables are examined in a fixed order and the
  3062. first environment variable set determines the return value of the lookup
  3063. process. In detail, for the category ‘LC_xxx’ the following variables
  3064. in this order are examined:
  3065. ‘LANGUAGE’
  3066. ‘LC_ALL’
  3067. ‘LC_xxx’
  3068. ‘LANG’
  3069. This looks very familiar. With the exception of the ‘LANGUAGE’
  3070. environment variable this is exactly the lookup order the ‘setlocale’
  3071. function uses. But why introduce the ‘LANGUAGE’ variable?
  3072. The reason is that the syntax of the values these variables can have
  3073. is different to what is expected by the ‘setlocale’ function. If we
  3074. would set ‘LC_ALL’ to a value following the extended syntax that would
  3075. mean the ‘setlocale’ function will never be able to use the value of
  3076. this variable as well. An additional variable removes this problem plus
  3077. we can select the language independently of the locale setting which
  3078. sometimes is useful.
  3079. While for the ‘LC_xxx’ variables the value should consist of exactly
  3080. one specification of a locale the ‘LANGUAGE’ variable’s value can
  3081. consist of a colon separated list of locale names. The attentive reader
  3082. will realize that this is the way we manage to implement one of our
  3083. additional demands above: we want to be able to specify an ordered list
  3084. of languages.
  3085. Back to the constructed filename we have only one component missing.
  3086. The DOMAIN_NAME part is the name which was either registered using the
  3087. ‘textdomain’ function or which was given to ‘dgettext’ or ‘dcgettext’ as
  3088. the first parameter. Now it becomes obvious that a good choice for the
  3089. domain name in the program code is a string which is closely related to
  3090. the program/package name. E.g., for the GNU C Library the domain name
  3091. is ‘libc’.
  3092. A limited piece of example code should show how the program is supposed
  3093. to work:
  3094. {
  3095. setlocale (LC_ALL, "");
  3096. textdomain ("test-package");
  3097. bindtextdomain ("test-package", "/usr/local/share/locale");
  3098. puts (gettext ("Hello, world!"));
  3099. }
  3100. At the program start the default domain is ‘messages’, and the
  3101. default locale is "C". The ‘setlocale’ call sets the locale according to
  3102. the user’s environment variables; remember that correct functioning of
  3103. ‘gettext’ relies on the correct setting of the ‘LC_MESSAGES’ locale (for
  3104. looking up the message catalog) and of the ‘LC_CTYPE’ locale (for the
  3105. character set conversion). The ‘textdomain’ call changes the default
  3106. domain to ‘test-package’. The ‘bindtextdomain’ call specifies that the
  3107. message catalogs for the domain ‘test-package’ can be found below the
  3108. directory ‘/usr/local/share/locale’.
  3109. If the user sets in her/his environment the variable ‘LANGUAGE’ to
  3110. ‘de’ the ‘gettext’ function will try to use the translations from the
  3111. file
  3112. /usr/local/share/locale/de/LC_MESSAGES/test-package.mo
  3113. From the above descriptions it should be clear which component of
  3114. this filename is determined by which source.
  3115. In the above example we assumed the ‘LANGUAGE’ environment variable
  3116. to be ‘de’. This might be an appropriate selection but what happens if
  3117. the user wants to use ‘LC_ALL’ because of the wider usability and here
  3118. the required value is ‘de_DE.ISO-8859-1’? We already mentioned above
  3119. that a situation like this is not infrequent. E.g., a person might
  3120. prefer reading a dialect and if this is not available fall back on the
  3121. standard language.
  3122. The ‘gettext’ functions know about situations like this and can
  3123. handle them gracefully. The functions recognize the format of the value
  3124. of the environment variable. It can split the value is different pieces
  3125. and by leaving out the only or the other part it can construct new
  3126. values. This happens of course in a predictable way. To understand
  3127. this one must know the format of the environment variable value. There
  3128. is one more or less standardized form, originally from the X/Open
  3129. specification:
  3130. ‘language[_territory[.codeset]][@modifier]’
  3131. Less specific locale names will be stripped in the order of the
  3132. following list:
  3133. 1. ‘codeset’
  3134. 2. ‘normalized codeset’
  3135. 3. ‘territory’
  3136. 4. ‘modifier’
  3137. The ‘language’ field will never be dropped for obvious reasons.
  3138. The only new thing is the ‘normalized codeset’ entry. This is
  3139. another goodie which is introduced to help reduce the chaos which
  3140. derives from the inability of people to standardize the names of
  3141. character sets. Instead of ISO-8859-1 one can often see 8859-1, 88591,
  3142. iso8859-1, or iso_8859-1. The ‘normalized codeset’ value is generated
  3143. from the user-provided character set name by applying the following
  3144. rules:
  3145. 1. Remove all characters besides numbers and letters.
  3146. 2. Fold letters to lowercase.
  3147. 3. If the same only contains digits prepend the string ‘"iso"’.
  3148. So all of the above names will be normalized to ‘iso88591’. This allows
  3149. the program user much more freedom in choosing the locale name.
  3150. Even this extended functionality still does not help to solve the
  3151. problem that completely different names can be used to denote the same
  3152. locale (e.g., ‘de’ and ‘german’). To be of help in this situation the
  3153. locale implementation and also the ‘gettext’ functions know about
  3154. aliases.
  3155. The file ‘/usr/share/locale/locale.alias’ (replace ‘/usr’ with
  3156. whatever prefix you used for configuring the C library) contains a
  3157. mapping of alternative names to more regular names. The system manager
  3158. is free to add new entries to fill her/his own needs. The selected
  3159. locale from the environment is compared with the entries in the first
  3160. column of this file ignoring the case. If they match, the value of the
  3161. second column is used instead for the further handling.
  3162. In the description of the format of the environment variables we
  3163. already mentioned the character set as a factor in the selection of the
  3164. message catalog. In fact, only catalogs which contain text written
  3165. using the character set of the system/program can be used (directly;
  3166. there will come a solution for this some day). This means for the user
  3167. that s/he will always have to take care of this. If in the collection
  3168. of the message catalogs there are files for the same language but coded
  3169. using different character sets the user has to be careful.
  3170. 
  3171. File: libc.info, Node: Helper programs for gettext, Prev: Message catalogs with gettext, Up: The Uniforum approach
  3172. 8.2.2 Programs to handle message catalogs for ‘gettext’
  3173. -------------------------------------------------------
  3174. The GNU C Library does not contain the source code for the programs to
  3175. handle message catalogs for the ‘gettext’ functions. As part of the GNU
  3176. project the GNU gettext package contains everything the developer needs.
  3177. The functionality provided by the tools in this package by far exceeds
  3178. the abilities of the ‘gencat’ program described above for the ‘catgets’
  3179. functions.
  3180. There is a program ‘msgfmt’ which is the equivalent program to the
  3181. ‘gencat’ program. It generates from the human-readable and -editable
  3182. form of the message catalog a binary file which can be used by the
  3183. ‘gettext’ functions. But there are several more programs available.
  3184. The ‘xgettext’ program can be used to automatically extract the
  3185. translatable messages from a source file. I.e., the programmer need not
  3186. take care of the translations and the list of messages which have to be
  3187. translated. S/He will simply wrap the translatable string in calls to
  3188. ‘gettext’ et.al and the rest will be done by ‘xgettext’. This program
  3189. has a lot of options which help to customize the output or help to
  3190. understand the input better.
  3191. Other programs help to manage the development cycle when new messages
  3192. appear in the source files or when a new translation of the messages
  3193. appears. Here it should only be noted that using all the tools in GNU
  3194. gettext it is possible to _completely_ automate the handling of message
  3195. catalogs. Besides marking the translatable strings in the source code
  3196. and generating the translations the developers do not have anything to
  3197. do themselves.
  3198. 
  3199. File: libc.info, Node: Searching and Sorting, Next: Pattern Matching, Prev: Message Translation, Up: Top
  3200. 9 Searching and Sorting
  3201. ***********************
  3202. This chapter describes functions for searching and sorting arrays of
  3203. arbitrary objects. You pass the appropriate comparison function to be
  3204. applied as an argument, along with the size of the objects in the array
  3205. and the total number of elements.
  3206. * Menu:
  3207. * Comparison Functions:: Defining how to compare two objects.
  3208. Since the sort and search facilities
  3209. are general, you have to specify the
  3210. ordering.
  3211. * Array Search Function:: The ‘bsearch’ function.
  3212. * Array Sort Function:: The ‘qsort’ function.
  3213. * Search/Sort Example:: An example program.
  3214. * Hash Search Function:: The ‘hsearch’ function.
  3215. * Tree Search Function:: The ‘tsearch’ function.
  3216. 
  3217. File: libc.info, Node: Comparison Functions, Next: Array Search Function, Up: Searching and Sorting
  3218. 9.1 Defining the Comparison Function
  3219. ====================================
  3220. In order to use the sorted array library functions, you have to describe
  3221. how to compare the elements of the array.
  3222. To do this, you supply a comparison function to compare two elements
  3223. of the array. The library will call this function, passing as arguments
  3224. pointers to two array elements to be compared. Your comparison function
  3225. should return a value the way ‘strcmp’ (*note String/Array Comparison::)
  3226. does: negative if the first argument is “less” than the second, zero if
  3227. they are “equal”, and positive if the first argument is “greater”.
  3228. Here is an example of a comparison function which works with an array
  3229. of numbers of type ‘double’:
  3230. int
  3231. compare_doubles (const void *a, const void *b)
  3232. {
  3233. const double *da = (const double *) a;
  3234. const double *db = (const double *) b;
  3235. return (*da > *db) - (*da < *db);
  3236. }
  3237. The header file ‘stdlib.h’ defines a name for the data type of
  3238. comparison functions. This type is a GNU extension.
  3239. int comparison_fn_t (const void *, const void *);
  3240. 
  3241. File: libc.info, Node: Array Search Function, Next: Array Sort Function, Prev: Comparison Functions, Up: Searching and Sorting
  3242. 9.2 Array Search Function
  3243. =========================
  3244. Generally searching for a specific element in an array means that
  3245. potentially all elements must be checked. The GNU C Library contains
  3246. functions to perform linear search. The prototypes for the following
  3247. two functions can be found in ‘search.h’.
  3248. -- Function: void * lfind (const void *KEY, const void *BASE, size_t
  3249. *NMEMB, size_t SIZE, comparison_fn_t COMPAR)
  3250. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3251. Concepts::.
  3252. The ‘lfind’ function searches in the array with ‘*NMEMB’ elements
  3253. of SIZE bytes pointed to by BASE for an element which matches the
  3254. one pointed to by KEY. The function pointed to by COMPAR is used
  3255. to decide whether two elements match.
  3256. The return value is a pointer to the matching element in the array
  3257. starting at BASE if it is found. If no matching element is
  3258. available ‘NULL’ is returned.
  3259. The mean runtime of this function is ‘*NMEMB’/2. This function
  3260. should only be used if elements often get added to or deleted from
  3261. the array in which case it might not be useful to sort the array
  3262. before searching.
  3263. -- Function: void * lsearch (const void *KEY, void *BASE, size_t
  3264. *NMEMB, size_t SIZE, comparison_fn_t COMPAR)
  3265. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3266. Concepts::.
  3267. The ‘lsearch’ function is similar to the ‘lfind’ function. It
  3268. searches the given array for an element and returns it if found.
  3269. The difference is that if no matching element is found the
  3270. ‘lsearch’ function adds the object pointed to by KEY (with a size
  3271. of SIZE bytes) at the end of the array and it increments the value
  3272. of ‘*NMEMB’ to reflect this addition.
  3273. This means for the caller that if it is not sure that the array
  3274. contains the element one is searching for the memory allocated for
  3275. the array starting at BASE must have room for at least SIZE more
  3276. bytes. If one is sure the element is in the array it is better to
  3277. use ‘lfind’ so having more room in the array is always necessary
  3278. when calling ‘lsearch’.
  3279. To search a sorted array for an element matching the key, use the
  3280. ‘bsearch’ function. The prototype for this function is in the header
  3281. file ‘stdlib.h’.
  3282. -- Function: void * bsearch (const void *KEY, const void *ARRAY, size_t
  3283. COUNT, size_t SIZE, comparison_fn_t COMPARE)
  3284. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3285. Concepts::.
  3286. The ‘bsearch’ function searches the sorted array ARRAY for an
  3287. object that is equivalent to KEY. The array contains COUNT
  3288. elements, each of which is of size SIZE bytes.
  3289. The COMPARE function is used to perform the comparison. This
  3290. function is called with two pointer arguments and should return an
  3291. integer less than, equal to, or greater than zero corresponding to
  3292. whether its first argument is considered less than, equal to, or
  3293. greater than its second argument. The elements of the ARRAY must
  3294. already be sorted in ascending order according to this comparison
  3295. function.
  3296. The return value is a pointer to the matching array element, or a
  3297. null pointer if no match is found. If the array contains more than
  3298. one element that matches, the one that is returned is unspecified.
  3299. This function derives its name from the fact that it is implemented
  3300. using the binary search algorithm.
  3301. 
  3302. File: libc.info, Node: Array Sort Function, Next: Search/Sort Example, Prev: Array Search Function, Up: Searching and Sorting
  3303. 9.3 Array Sort Function
  3304. =======================
  3305. To sort an array using an arbitrary comparison function, use the ‘qsort’
  3306. function. The prototype for this function is in ‘stdlib.h’.
  3307. -- Function: void qsort (void *ARRAY, size_t COUNT, size_t SIZE,
  3308. comparison_fn_t COMPARE)
  3309. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt | *Note POSIX
  3310. Safety Concepts::.
  3311. The ‘qsort’ function sorts the array ARRAY. The array contains
  3312. COUNT elements, each of which is of size SIZE.
  3313. The COMPARE function is used to perform the comparison on the array
  3314. elements. This function is called with two pointer arguments and
  3315. should return an integer less than, equal to, or greater than zero
  3316. corresponding to whether its first argument is considered less
  3317. than, equal to, or greater than its second argument.
  3318. *Warning:* If two objects compare as equal, their order after
  3319. sorting is unpredictable. That is to say, the sorting is not
  3320. stable. This can make a difference when the comparison considers
  3321. only part of the elements. Two elements with the same sort key may
  3322. differ in other respects.
  3323. Although the object addresses passed to the comparison function lie
  3324. within the array, they need not correspond with the original
  3325. locations of those objects because the sorting algorithm may swap
  3326. around objects in the array before making some comparisons. The
  3327. only way to perform a stable sort with ‘qsort’ is to first augment
  3328. the objects with a monotonic counter of some kind.
  3329. Here is a simple example of sorting an array of doubles in
  3330. numerical order, using the comparison function defined above (*note
  3331. Comparison Functions::):
  3332. {
  3333. double *array;
  3334. int size;
  3335. ...
  3336. qsort (array, size, sizeof (double), compare_doubles);
  3337. }
  3338. The ‘qsort’ function derives its name from the fact that it was
  3339. originally implemented using the “quick sort” algorithm.
  3340. The implementation of ‘qsort’ in this library might not be an
  3341. in-place sort and might thereby use an extra amount of memory to
  3342. store the array.
  3343. 
  3344. File: libc.info, Node: Search/Sort Example, Next: Hash Search Function, Prev: Array Sort Function, Up: Searching and Sorting
  3345. 9.4 Searching and Sorting Example
  3346. =================================
  3347. Here is an example showing the use of ‘qsort’ and ‘bsearch’ with an
  3348. array of structures. The objects in the array are sorted by comparing
  3349. their ‘name’ fields with the ‘strcmp’ function. Then, we can look up
  3350. individual objects based on their names.
  3351. #include <stdlib.h>
  3352. #include <stdio.h>
  3353. #include <string.h>
  3354. /* Define an array of critters to sort. */
  3355. struct critter
  3356. {
  3357. const char *name;
  3358. const char *species;
  3359. };
  3360. struct critter muppets[] =
  3361. {
  3362. {"Kermit", "frog"},
  3363. {"Piggy", "pig"},
  3364. {"Gonzo", "whatever"},
  3365. {"Fozzie", "bear"},
  3366. {"Sam", "eagle"},
  3367. {"Robin", "frog"},
  3368. {"Animal", "animal"},
  3369. {"Camilla", "chicken"},
  3370. {"Sweetums", "monster"},
  3371. {"Dr. Strangepork", "pig"},
  3372. {"Link Hogthrob", "pig"},
  3373. {"Zoot", "human"},
  3374. {"Dr. Bunsen Honeydew", "human"},
  3375. {"Beaker", "human"},
  3376. {"Swedish Chef", "human"}
  3377. };
  3378. int count = sizeof (muppets) / sizeof (struct critter);
  3379. /* This is the comparison function used for sorting and searching. */
  3380. int
  3381. critter_cmp (const void *v1, const void *v2)
  3382. {
  3383. const struct critter *c1 = v1;
  3384. const struct critter *c2 = v2;
  3385. return strcmp (c1->name, c2->name);
  3386. }
  3387. /* Print information about a critter. */
  3388. void
  3389. print_critter (const struct critter *c)
  3390. {
  3391. printf ("%s, the %s\n", c->name, c->species);
  3392. }
  3393. /* Do the lookup into the sorted array. */
  3394. void
  3395. find_critter (const char *name)
  3396. {
  3397. struct critter target, *result;
  3398. target.name = name;
  3399. result = bsearch (&target, muppets, count, sizeof (struct critter),
  3400. critter_cmp);
  3401. if (result)
  3402. print_critter (result);
  3403. else
  3404. printf ("Couldn't find %s.\n", name);
  3405. }
  3406. /* Main program. */
  3407. int
  3408. main (void)
  3409. {
  3410. int i;
  3411. for (i = 0; i < count; i++)
  3412. print_critter (&muppets[i]);
  3413. printf ("\n");
  3414. qsort (muppets, count, sizeof (struct critter), critter_cmp);
  3415. for (i = 0; i < count; i++)
  3416. print_critter (&muppets[i]);
  3417. printf ("\n");
  3418. find_critter ("Kermit");
  3419. find_critter ("Gonzo");
  3420. find_critter ("Janice");
  3421. return 0;
  3422. }
  3423. The output from this program looks like:
  3424. Kermit, the frog
  3425. Piggy, the pig
  3426. Gonzo, the whatever
  3427. Fozzie, the bear
  3428. Sam, the eagle
  3429. Robin, the frog
  3430. Animal, the animal
  3431. Camilla, the chicken
  3432. Sweetums, the monster
  3433. Dr. Strangepork, the pig
  3434. Link Hogthrob, the pig
  3435. Zoot, the human
  3436. Dr. Bunsen Honeydew, the human
  3437. Beaker, the human
  3438. Swedish Chef, the human
  3439. Animal, the animal
  3440. Beaker, the human
  3441. Camilla, the chicken
  3442. Dr. Bunsen Honeydew, the human
  3443. Dr. Strangepork, the pig
  3444. Fozzie, the bear
  3445. Gonzo, the whatever
  3446. Kermit, the frog
  3447. Link Hogthrob, the pig
  3448. Piggy, the pig
  3449. Robin, the frog
  3450. Sam, the eagle
  3451. Swedish Chef, the human
  3452. Sweetums, the monster
  3453. Zoot, the human
  3454. Kermit, the frog
  3455. Gonzo, the whatever
  3456. Couldn't find Janice.
  3457. 
  3458. File: libc.info, Node: Hash Search Function, Next: Tree Search Function, Prev: Search/Sort Example, Up: Searching and Sorting
  3459. 9.5 The ‘hsearch’ function.
  3460. ===========================
  3461. The functions mentioned so far in this chapter are for searching in a
  3462. sorted or unsorted array. There are other methods to organize
  3463. information which later should be searched. The costs of insert, delete
  3464. and search differ. One possible implementation is using hashing tables.
  3465. The following functions are declared in the header file ‘search.h’.
  3466. -- Function: int hcreate (size_t NEL)
  3467. Preliminary: | MT-Unsafe race:hsearch | AS-Unsafe heap | AC-Unsafe
  3468. corrupt mem | *Note POSIX Safety Concepts::.
  3469. The ‘hcreate’ function creates a hashing table which can contain at
  3470. least NEL elements. There is no possibility to grow this table so
  3471. it is necessary to choose the value for NEL wisely. The method
  3472. used to implement this function might make it necessary to make the
  3473. number of elements in the hashing table larger than the expected
  3474. maximal number of elements. Hashing tables usually work
  3475. inefficiently if they are filled 80% or more. The constant access
  3476. time guaranteed by hashing can only be achieved if few collisions
  3477. exist. See Knuth’s “The Art of Computer Programming, Part 3:
  3478. Searching and Sorting” for more information.
  3479. The weakest aspect of this function is that there can be at most
  3480. one hashing table used through the whole program. The table is
  3481. allocated in local memory out of control of the programmer. As an
  3482. extension the GNU C Library provides an additional set of functions
  3483. with a reentrant interface which provides a similar interface but
  3484. which allows keeping arbitrarily many hashing tables.
  3485. It is possible to use more than one hashing table in the program
  3486. run if the former table is first destroyed by a call to ‘hdestroy’.
  3487. The function returns a non-zero value if successful. If it returns
  3488. zero, something went wrong. This could either mean there is
  3489. already a hashing table in use or the program ran out of memory.
  3490. -- Function: void hdestroy (void)
  3491. Preliminary: | MT-Unsafe race:hsearch | AS-Unsafe heap | AC-Unsafe
  3492. corrupt mem | *Note POSIX Safety Concepts::.
  3493. The ‘hdestroy’ function can be used to free all the resources
  3494. allocated in a previous call of ‘hcreate’. After a call to this
  3495. function it is again possible to call ‘hcreate’ and allocate a new
  3496. table with possibly different size.
  3497. It is important to remember that the elements contained in the
  3498. hashing table at the time ‘hdestroy’ is called are _not_ freed by
  3499. this function. It is the responsibility of the program code to
  3500. free those strings (if necessary at all). Freeing all the element
  3501. memory is not possible without extra, separately kept information
  3502. since there is no function to iterate through all available
  3503. elements in the hashing table. If it is really necessary to free a
  3504. table and all elements the programmer has to keep a list of all
  3505. table elements and before calling ‘hdestroy’ s/he has to free all
  3506. element’s data using this list. This is a very unpleasant
  3507. mechanism and it also shows that this kind of hashing table is
  3508. mainly meant for tables which are created once and used until the
  3509. end of the program run.
  3510. Entries of the hashing table and keys for the search are defined
  3511. using this type:
  3512. -- Data type: struct ENTRY
  3513. Both elements of this structure are pointers to zero-terminated
  3514. strings. This is a limiting restriction of the functionality of
  3515. the ‘hsearch’ functions. They can only be used for data sets which
  3516. use the NUL character always and solely to terminate the records.
  3517. It is not possible to handle general binary data.
  3518. ‘char *key’
  3519. Pointer to a zero-terminated string of characters describing
  3520. the key for the search or the element in the hashing table.
  3521. ‘char *data’
  3522. Pointer to a zero-terminated string of characters describing
  3523. the data. If the functions will be called only for searching
  3524. an existing entry this element might stay undefined since it
  3525. is not used.
  3526. -- Function: ENTRY * hsearch (ENTRY ITEM, ACTION ACTION)
  3527. Preliminary: | MT-Unsafe race:hsearch | AS-Unsafe | AC-Unsafe
  3528. corrupt/action==ENTER | *Note POSIX Safety Concepts::.
  3529. To search in a hashing table created using ‘hcreate’ the ‘hsearch’
  3530. function must be used. This function can perform a simple search
  3531. for an element (if ACTION has the value ‘FIND’) or it can
  3532. alternatively insert the key element into the hashing table.
  3533. Entries are never replaced.
  3534. The key is denoted by a pointer to an object of type ‘ENTRY’. For
  3535. locating the corresponding position in the hashing table only the
  3536. ‘key’ element of the structure is used.
  3537. If an entry with a matching key is found the ACTION parameter is
  3538. irrelevant. The found entry is returned. If no matching entry is
  3539. found and the ACTION parameter has the value ‘FIND’ the function
  3540. returns a ‘NULL’ pointer. If no entry is found and the ACTION
  3541. parameter has the value ‘ENTER’ a new entry is added to the hashing
  3542. table which is initialized with the parameter ITEM. A pointer to
  3543. the newly added entry is returned.
  3544. As mentioned before, the hashing table used by the functions
  3545. described so far is global and there can be at any time at most one
  3546. hashing table in the program. A solution is to use the following
  3547. functions which are a GNU extension. All have in common that they
  3548. operate on a hashing table which is described by the content of an
  3549. object of the type ‘struct hsearch_data’. This type should be treated
  3550. as opaque, none of its members should be changed directly.
  3551. -- Function: int hcreate_r (size_t NEL, struct hsearch_data *HTAB)
  3552. Preliminary: | MT-Safe race:htab | AS-Unsafe heap | AC-Unsafe
  3553. corrupt mem | *Note POSIX Safety Concepts::.
  3554. The ‘hcreate_r’ function initializes the object pointed to by HTAB
  3555. to contain a hashing table with at least NEL elements. So this
  3556. function is equivalent to the ‘hcreate’ function except that the
  3557. initialized data structure is controlled by the user.
  3558. This allows having more than one hashing table at one time. The
  3559. memory necessary for the ‘struct hsearch_data’ object can be
  3560. allocated dynamically. It must be initialized with zero before
  3561. calling this function.
  3562. The return value is non-zero if the operation was successful. If
  3563. the return value is zero, something went wrong, which probably
  3564. means the program ran out of memory.
  3565. -- Function: void hdestroy_r (struct hsearch_data *HTAB)
  3566. Preliminary: | MT-Safe race:htab | AS-Unsafe heap | AC-Unsafe
  3567. corrupt mem | *Note POSIX Safety Concepts::.
  3568. The ‘hdestroy_r’ function frees all resources allocated by the
  3569. ‘hcreate_r’ function for this very same object HTAB. As for
  3570. ‘hdestroy’ it is the program’s responsibility to free the strings
  3571. for the elements of the table.
  3572. -- Function: int hsearch_r (ENTRY ITEM, ACTION ACTION, ENTRY **RETVAL,
  3573. struct hsearch_data *HTAB)
  3574. Preliminary: | MT-Safe race:htab | AS-Safe | AC-Unsafe
  3575. corrupt/action==ENTER | *Note POSIX Safety Concepts::.
  3576. The ‘hsearch_r’ function is equivalent to ‘hsearch’. The meaning
  3577. of the first two arguments is identical. But instead of operating
  3578. on a single global hashing table the function works on the table
  3579. described by the object pointed to by HTAB (which is initialized by
  3580. a call to ‘hcreate_r’).
  3581. Another difference to ‘hcreate’ is that the pointer to the found
  3582. entry in the table is not the return value of the function. It is
  3583. returned by storing it in a pointer variable pointed to by the
  3584. RETVAL parameter. The return value of the function is an integer
  3585. value indicating success if it is non-zero and failure if it is
  3586. zero. In the latter case the global variable ‘errno’ signals the
  3587. reason for the failure.
  3588. ‘ENOMEM’
  3589. The table is filled and ‘hsearch_r’ was called with a so far
  3590. unknown key and ACTION set to ‘ENTER’.
  3591. ‘ESRCH’
  3592. The ACTION parameter is ‘FIND’ and no corresponding element is
  3593. found in the table.
  3594. 
  3595. File: libc.info, Node: Tree Search Function, Prev: Hash Search Function, Up: Searching and Sorting
  3596. 9.6 The ‘tsearch’ function.
  3597. ===========================
  3598. Another common form to organize data for efficient search is to use
  3599. trees. The ‘tsearch’ function family provides a nice interface to
  3600. functions to organize possibly large amounts of data by providing a mean
  3601. access time proportional to the logarithm of the number of elements.
  3602. The GNU C Library implementation even guarantees that this bound is
  3603. never exceeded even for input data which cause problems for simple
  3604. binary tree implementations.
  3605. The functions described in the chapter are all described in the
  3606. System V and X/Open specifications and are therefore quite portable.
  3607. In contrast to the ‘hsearch’ functions the ‘tsearch’ functions can be
  3608. used with arbitrary data and not only zero-terminated strings.
  3609. The ‘tsearch’ functions have the advantage that no function to
  3610. initialize data structures is necessary. A simple pointer of type ‘void
  3611. *’ initialized to ‘NULL’ is a valid tree and can be extended or
  3612. searched. The prototypes for these functions can be found in the header
  3613. file ‘search.h’.
  3614. -- Function: void * tsearch (const void *KEY, void **ROOTP,
  3615. comparison_fn_t COMPAR)
  3616. Preliminary: | MT-Safe race:rootp | AS-Unsafe heap | AC-Unsafe
  3617. corrupt mem | *Note POSIX Safety Concepts::.
  3618. The ‘tsearch’ function searches in the tree pointed to by ‘*ROOTP’
  3619. for an element matching KEY. The function pointed to by COMPAR is
  3620. used to determine whether two elements match. *Note Comparison
  3621. Functions::, for a specification of the functions which can be used
  3622. for the COMPAR parameter.
  3623. If the tree does not contain a matching entry the KEY value will be
  3624. added to the tree. ‘tsearch’ does not make a copy of the object
  3625. pointed to by KEY (how could it since the size is unknown).
  3626. Instead it adds a reference to this object which means the object
  3627. must be available as long as the tree data structure is used.
  3628. The tree is represented by a pointer to a pointer since it is
  3629. sometimes necessary to change the root node of the tree. So it
  3630. must not be assumed that the variable pointed to by ROOTP has the
  3631. same value after the call. This also shows that it is not safe to
  3632. call the ‘tsearch’ function more than once at the same time using
  3633. the same tree. It is no problem to run it more than once at a time
  3634. on different trees.
  3635. The return value is a pointer to the matching element in the tree.
  3636. If a new element was created the pointer points to the new data
  3637. (which is in fact KEY). If an entry had to be created and the
  3638. program ran out of space ‘NULL’ is returned.
  3639. -- Function: void * tfind (const void *KEY, void *const *ROOTP,
  3640. comparison_fn_t COMPAR)
  3641. Preliminary: | MT-Safe race:rootp | AS-Safe | AC-Safe | *Note POSIX
  3642. Safety Concepts::.
  3643. The ‘tfind’ function is similar to the ‘tsearch’ function. It
  3644. locates an element matching the one pointed to by KEY and returns a
  3645. pointer to this element. But if no matching element is available
  3646. no new element is entered (note that the ROOTP parameter points to
  3647. a constant pointer). Instead the function returns ‘NULL’.
  3648. Another advantage of the ‘tsearch’ functions in contrast to the
  3649. ‘hsearch’ functions is that there is an easy way to remove elements.
  3650. -- Function: void * tdelete (const void *KEY, void **ROOTP,
  3651. comparison_fn_t COMPAR)
  3652. Preliminary: | MT-Safe race:rootp | AS-Unsafe heap | AC-Unsafe
  3653. corrupt mem | *Note POSIX Safety Concepts::.
  3654. To remove a specific element matching KEY from the tree ‘tdelete’
  3655. can be used. It locates the matching element using the same method
  3656. as ‘tfind’. The corresponding element is then removed and a
  3657. pointer to the parent of the deleted node is returned by the
  3658. function. If there is no matching entry in the tree nothing can be
  3659. deleted and the function returns ‘NULL’. If the root of the tree
  3660. is deleted ‘tdelete’ returns some unspecified value not equal to
  3661. ‘NULL’.
  3662. -- Function: void tdestroy (void *VROOT, __free_fn_t FREEFCT)
  3663. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3664. POSIX Safety Concepts::.
  3665. If the complete search tree has to be removed one can use
  3666. ‘tdestroy’. It frees all resources allocated by the ‘tsearch’
  3667. functions to generate the tree pointed to by VROOT.
  3668. For the data in each tree node the function FREEFCT is called. The
  3669. pointer to the data is passed as the argument to the function. If
  3670. no such work is necessary FREEFCT must point to a function doing
  3671. nothing. It is called in any case.
  3672. This function is a GNU extension and not covered by the System V or
  3673. X/Open specifications.
  3674. In addition to the functions to create and destroy the tree data
  3675. structure, there is another function which allows you to apply a
  3676. function to all elements of the tree. The function must have this type:
  3677. void __action_fn_t (const void *nodep, VISIT value, int level);
  3678. The NODEP is the data value of the current node (once given as the
  3679. KEY argument to ‘tsearch’). LEVEL is a numeric value which corresponds
  3680. to the depth of the current node in the tree. The root node has the
  3681. depth 0 and its children have a depth of 1 and so on. The ‘VISIT’ type
  3682. is an enumeration type.
  3683. -- Data Type: VISIT
  3684. The ‘VISIT’ value indicates the status of the current node in the
  3685. tree and how the function is called. The status of a node is
  3686. either ‘leaf’ or ‘internal node’. For each leaf node the function
  3687. is called exactly once, for each internal node it is called three
  3688. times: before the first child is processed, after the first child
  3689. is processed and after both children are processed. This makes it
  3690. possible to handle all three methods of tree traversal (or even a
  3691. combination of them).
  3692. ‘preorder’
  3693. The current node is an internal node and the function is
  3694. called before the first child was processed.
  3695. ‘postorder’
  3696. The current node is an internal node and the function is
  3697. called after the first child was processed.
  3698. ‘endorder’
  3699. The current node is an internal node and the function is
  3700. called after the second child was processed.
  3701. ‘leaf’
  3702. The current node is a leaf.
  3703. -- Function: void twalk (const void *ROOT, __action_fn_t ACTION)
  3704. Preliminary: | MT-Safe race:root | AS-Safe | AC-Safe | *Note POSIX
  3705. Safety Concepts::.
  3706. For each node in the tree with a node pointed to by ROOT, the
  3707. ‘twalk’ function calls the function provided by the parameter
  3708. ACTION. For leaf nodes the function is called exactly once with
  3709. VALUE set to ‘leaf’. For internal nodes the function is called
  3710. three times, setting the VALUE parameter or ACTION to the
  3711. appropriate value. The LEVEL argument for the ACTION function is
  3712. computed while descending the tree by increasing the value by one
  3713. for each descent to a child, starting with the value 0 for the root
  3714. node.
  3715. Since the functions used for the ACTION parameter to ‘twalk’ must
  3716. not modify the tree data, it is safe to run ‘twalk’ in more than
  3717. one thread at the same time, working on the same tree. It is also
  3718. safe to call ‘tfind’ in parallel. Functions which modify the tree
  3719. must not be used, otherwise the behavior is undefined. However, it
  3720. is difficult to pass data external to the tree to the callback
  3721. function without resorting to global variables (and thread safety
  3722. issues), so see the ‘twalk_r’ function below.
  3723. -- Function: void twalk_r (const void *ROOT, void (*ACTION) (const void
  3724. *KEY, VISIT WHICH, void *CLOSURE), void *CLOSURE)
  3725. Preliminary: | MT-Safe race:root | AS-Safe | AC-Safe | *Note POSIX
  3726. Safety Concepts::.
  3727. For each node in the tree with a node pointed to by ROOT, the
  3728. ‘twalk_r’ function calls the function provided by the parameter
  3729. ACTION. For leaf nodes the function is called exactly once with
  3730. WHICH set to ‘leaf’. For internal nodes the function is called
  3731. three times, setting the WHICH parameter of ACTION to the
  3732. appropriate value. The CLOSURE parameter is passed down to each
  3733. call of the ACTION function, unmodified.
  3734. It is possible to implement the ‘twalk’ function on top of the
  3735. ‘twalk_r’ function, which is why there is no separate level
  3736. parameter.
  3737. #include <search.h>
  3738. struct twalk_with_twalk_r_closure
  3739. {
  3740. void (*action) (const void *, VISIT, int);
  3741. int depth;
  3742. };
  3743. static void
  3744. twalk_with_twalk_r_action (const void *nodep, VISIT which, void *closure0)
  3745. {
  3746. struct twalk_with_twalk_r_closure *closure = closure0;
  3747. switch (which)
  3748. {
  3749. case leaf:
  3750. closure->action (nodep, which, closure->depth);
  3751. break;
  3752. case preorder:
  3753. closure->action (nodep, which, closure->depth);
  3754. ++closure->depth;
  3755. break;
  3756. case postorder:
  3757. /* The preorder action incremented the depth. */
  3758. closure->action (nodep, which, closure->depth - 1);
  3759. break;
  3760. case endorder:
  3761. --closure->depth;
  3762. closure->action (nodep, which, closure->depth);
  3763. break;
  3764. }
  3765. }
  3766. void
  3767. twalk (const void *root, void (*action) (const void *, VISIT, int))
  3768. {
  3769. struct twalk_with_twalk_r_closure closure = { action, 0 };
  3770. twalk_r (root, twalk_with_twalk_r_action, &closure);
  3771. }
  3772. 
  3773. File: libc.info, Node: Pattern Matching, Next: I/O Overview, Prev: Searching and Sorting, Up: Top
  3774. 10 Pattern Matching
  3775. *******************
  3776. The GNU C Library provides pattern matching facilities for two kinds of
  3777. patterns: regular expressions and file-name wildcards. The library also
  3778. provides a facility for expanding variable and command references and
  3779. parsing text into words in the way the shell does.
  3780. * Menu:
  3781. * Wildcard Matching:: Matching a wildcard pattern against a single string.
  3782. * Globbing:: Finding the files that match a wildcard pattern.
  3783. * Regular Expressions:: Matching regular expressions against strings.
  3784. * Word Expansion:: Expanding shell variables, nested commands,
  3785. arithmetic, and wildcards.
  3786. This is what the shell does with shell commands.
  3787. 
  3788. File: libc.info, Node: Wildcard Matching, Next: Globbing, Up: Pattern Matching
  3789. 10.1 Wildcard Matching
  3790. ======================
  3791. This section describes how to match a wildcard pattern against a
  3792. particular string. The result is a yes or no answer: does the string
  3793. fit the pattern or not. The symbols described here are all declared in
  3794. ‘fnmatch.h’.
  3795. -- Function: int fnmatch (const char *PATTERN, const char *STRING, int
  3796. FLAGS)
  3797. Preliminary: | MT-Safe env locale | AS-Unsafe heap | AC-Unsafe mem
  3798. | *Note POSIX Safety Concepts::.
  3799. This function tests whether the string STRING matches the pattern
  3800. PATTERN. It returns ‘0’ if they do match; otherwise, it returns
  3801. the nonzero value ‘FNM_NOMATCH’. The arguments PATTERN and STRING
  3802. are both strings.
  3803. The argument FLAGS is a combination of flag bits that alter the
  3804. details of matching. See below for a list of the defined flags.
  3805. In the GNU C Library, ‘fnmatch’ might sometimes report “errors” by
  3806. returning nonzero values that are not equal to ‘FNM_NOMATCH’.
  3807. These are the available flags for the FLAGS argument:
  3808. ‘FNM_FILE_NAME’
  3809. Treat the ‘/’ character specially, for matching file names. If
  3810. this flag is set, wildcard constructs in PATTERN cannot match ‘/’
  3811. in STRING. Thus, the only way to match ‘/’ is with an explicit ‘/’
  3812. in PATTERN.
  3813. ‘FNM_PATHNAME’
  3814. This is an alias for ‘FNM_FILE_NAME’; it comes from POSIX.2. We
  3815. don’t recommend this name because we don’t use the term “pathname”
  3816. for file names.
  3817. ‘FNM_PERIOD’
  3818. Treat the ‘.’ character specially if it appears at the beginning of
  3819. STRING. If this flag is set, wildcard constructs in PATTERN cannot
  3820. match ‘.’ as the first character of STRING.
  3821. If you set both ‘FNM_PERIOD’ and ‘FNM_FILE_NAME’, then the special
  3822. treatment applies to ‘.’ following ‘/’ as well as to ‘.’ at the
  3823. beginning of STRING. (The shell uses the ‘FNM_PERIOD’ and
  3824. ‘FNM_FILE_NAME’ flags together for matching file names.)
  3825. ‘FNM_NOESCAPE’
  3826. Don’t treat the ‘\’ character specially in patterns. Normally, ‘\’
  3827. quotes the following character, turning off its special meaning (if
  3828. any) so that it matches only itself. When quoting is enabled, the
  3829. pattern ‘\?’ matches only the string ‘?’, because the question mark
  3830. in the pattern acts like an ordinary character.
  3831. If you use ‘FNM_NOESCAPE’, then ‘\’ is an ordinary character.
  3832. ‘FNM_LEADING_DIR’
  3833. Ignore a trailing sequence of characters starting with a ‘/’ in
  3834. STRING; that is to say, test whether STRING starts with a directory
  3835. name that PATTERN matches.
  3836. If this flag is set, either ‘foo*’ or ‘foobar’ as a pattern would
  3837. match the string ‘foobar/frobozz’.
  3838. ‘FNM_CASEFOLD’
  3839. Ignore case in comparing STRING to PATTERN.
  3840. ‘FNM_EXTMATCH’
  3841. Besides the normal patterns, also recognize the extended patterns
  3842. introduced in ‘ksh’. The patterns are written in the form
  3843. explained in the following table where PATTERN-LIST is a ‘|’
  3844. separated list of patterns.
  3845. ‘?(PATTERN-LIST)’
  3846. The pattern matches if zero or one occurrences of any of the
  3847. patterns in the PATTERN-LIST allow matching the input string.
  3848. ‘*(PATTERN-LIST)’
  3849. The pattern matches if zero or more occurrences of any of the
  3850. patterns in the PATTERN-LIST allow matching the input string.
  3851. ‘+(PATTERN-LIST)’
  3852. The pattern matches if one or more occurrences of any of the
  3853. patterns in the PATTERN-LIST allow matching the input string.
  3854. ‘@(PATTERN-LIST)’
  3855. The pattern matches if exactly one occurrence of any of the
  3856. patterns in the PATTERN-LIST allows matching the input string.
  3857. ‘!(PATTERN-LIST)’
  3858. The pattern matches if the input string cannot be matched with
  3859. any of the patterns in the PATTERN-LIST.
  3860. 
  3861. File: libc.info, Node: Globbing, Next: Regular Expressions, Prev: Wildcard Matching, Up: Pattern Matching
  3862. 10.2 Globbing
  3863. =============
  3864. The archetypal use of wildcards is for matching against the files in a
  3865. directory, and making a list of all the matches. This is called
  3866. “globbing”.
  3867. You could do this using ‘fnmatch’, by reading the directory entries
  3868. one by one and testing each one with ‘fnmatch’. But that would be slow
  3869. (and complex, since you would have to handle subdirectories by hand).
  3870. The library provides a function ‘glob’ to make this particular use of
  3871. wildcards convenient. ‘glob’ and the other symbols in this section are
  3872. declared in ‘glob.h’.
  3873. * Menu:
  3874. * Calling Glob:: Basic use of ‘glob’.
  3875. * Flags for Globbing:: Flags that enable various options in ‘glob’.
  3876. * More Flags for Globbing:: GNU specific extensions to ‘glob’.
  3877. 
  3878. File: libc.info, Node: Calling Glob, Next: Flags for Globbing, Up: Globbing
  3879. 10.2.1 Calling ‘glob’
  3880. ---------------------
  3881. The result of globbing is a vector of file names (strings). To return
  3882. this vector, ‘glob’ uses a special data type, ‘glob_t’, which is a
  3883. structure. You pass ‘glob’ the address of the structure, and it fills
  3884. in the structure’s fields to tell you about the results.
  3885. -- Data Type: glob_t
  3886. This data type holds a pointer to a word vector. More precisely,
  3887. it records both the address of the word vector and its size. The
  3888. GNU implementation contains some more fields which are non-standard
  3889. extensions.
  3890. ‘gl_pathc’
  3891. The number of elements in the vector, excluding the initial
  3892. null entries if the GLOB_DOOFFS flag is used (see gl_offs
  3893. below).
  3894. ‘gl_pathv’
  3895. The address of the vector. This field has type ‘char **’.
  3896. ‘gl_offs’
  3897. The offset of the first real element of the vector, from its
  3898. nominal address in the ‘gl_pathv’ field. Unlike the other
  3899. fields, this is always an input to ‘glob’, rather than an
  3900. output from it.
  3901. If you use a nonzero offset, then that many elements at the
  3902. beginning of the vector are left empty. (The ‘glob’ function
  3903. fills them with null pointers.)
  3904. The ‘gl_offs’ field is meaningful only if you use the
  3905. ‘GLOB_DOOFFS’ flag. Otherwise, the offset is always zero
  3906. regardless of what is in this field, and the first real
  3907. element comes at the beginning of the vector.
  3908. ‘gl_closedir’
  3909. The address of an alternative implementation of the ‘closedir’
  3910. function. It is used if the ‘GLOB_ALTDIRFUNC’ bit is set in
  3911. the flag parameter. The type of this field is
  3912. ‘void (*) (void *)’.
  3913. This is a GNU extension.
  3914. ‘gl_readdir’
  3915. The address of an alternative implementation of the ‘readdir’
  3916. function used to read the contents of a directory. It is used
  3917. if the ‘GLOB_ALTDIRFUNC’ bit is set in the flag parameter.
  3918. The type of this field is ‘struct dirent *(*) (void *)’.
  3919. An implementation of ‘gl_readdir’ needs to initialize the
  3920. following members of the ‘struct dirent’ object:
  3921. ‘d_type’
  3922. This member should be set to the file type of the entry
  3923. if it is known. Otherwise, the value ‘DT_UNKNOWN’ can be
  3924. used. The ‘glob’ function may use the specified file
  3925. type to avoid callbacks in cases where the file type
  3926. indicates that the data is not required.
  3927. ‘d_ino’
  3928. This member needs to be non-zero, otherwise ‘glob’ may
  3929. skip the current entry and call the ‘gl_readdir’ callback
  3930. function again to retrieve another entry.
  3931. ‘d_name’
  3932. This member must be set to the name of the entry. It
  3933. must be null-terminated.
  3934. The example below shows how to allocate a ‘struct dirent’
  3935. object containing a given name.
  3936. #include <dirent.h>
  3937. #include <errno.h>
  3938. #include <stddef.h>
  3939. #include <stdlib.h>
  3940. #include <string.h>
  3941. struct dirent *
  3942. mkdirent (const char *name)
  3943. {
  3944. size_t dirent_size = offsetof (struct dirent, d_name) + 1;
  3945. size_t name_length = strlen (name);
  3946. size_t total_size = dirent_size + name_length;
  3947. if (total_size < dirent_size)
  3948. {
  3949. errno = ENOMEM;
  3950. return NULL;
  3951. }
  3952. struct dirent *result = malloc (total_size);
  3953. if (result == NULL)
  3954. return NULL;
  3955. result->d_type = DT_UNKNOWN;
  3956. result->d_ino = 1; /* Do not skip this entry. */
  3957. memcpy (result->d_name, name, name_length + 1);
  3958. return result;
  3959. }
  3960. The ‘glob’ function reads the ‘struct dirent’ members listed
  3961. above and makes a copy of the file name in the ‘d_name’ member
  3962. immediately after the ‘gl_readdir’ callback function returns.
  3963. Future invocations of any of the callback functions may
  3964. dealloacte or reuse the buffer. It is the responsibility of
  3965. the caller of the ‘glob’ function to allocate and deallocate
  3966. the buffer, around the call to ‘glob’ or using the callback
  3967. functions. For example, an application could allocate the
  3968. buffer in the ‘gl_readdir’ callback function, and deallocate
  3969. it in the ‘gl_closedir’ callback function.
  3970. The ‘gl_readdir’ member is a GNU extension.
  3971. ‘gl_opendir’
  3972. The address of an alternative implementation of the ‘opendir’
  3973. function. It is used if the ‘GLOB_ALTDIRFUNC’ bit is set in
  3974. the flag parameter. The type of this field is
  3975. ‘void *(*) (const char *)’.
  3976. This is a GNU extension.
  3977. ‘gl_stat’
  3978. The address of an alternative implementation of the ‘stat’
  3979. function to get information about an object in the filesystem.
  3980. It is used if the ‘GLOB_ALTDIRFUNC’ bit is set in the flag
  3981. parameter. The type of this field is
  3982. ‘int (*) (const char *, struct stat *)’.
  3983. This is a GNU extension.
  3984. ‘gl_lstat’
  3985. The address of an alternative implementation of the ‘lstat’
  3986. function to get information about an object in the
  3987. filesystems, not following symbolic links. It is used if the
  3988. ‘GLOB_ALTDIRFUNC’ bit is set in the flag parameter. The type
  3989. of this field is ‘int (*) (const char *, struct stat *)’.
  3990. This is a GNU extension.
  3991. ‘gl_flags’
  3992. The flags used when ‘glob’ was called. In addition,
  3993. ‘GLOB_MAGCHAR’ might be set. See *note Flags for Globbing::
  3994. for more details.
  3995. This is a GNU extension.
  3996. For use in the ‘glob64’ function ‘glob.h’ contains another definition
  3997. for a very similar type. ‘glob64_t’ differs from ‘glob_t’ only in the
  3998. types of the members ‘gl_readdir’, ‘gl_stat’, and ‘gl_lstat’.
  3999. -- Data Type: glob64_t
  4000. This data type holds a pointer to a word vector. More precisely,
  4001. it records both the address of the word vector and its size. The
  4002. GNU implementation contains some more fields which are non-standard
  4003. extensions.
  4004. ‘gl_pathc’
  4005. The number of elements in the vector, excluding the initial
  4006. null entries if the GLOB_DOOFFS flag is used (see gl_offs
  4007. below).
  4008. ‘gl_pathv’
  4009. The address of the vector. This field has type ‘char **’.
  4010. ‘gl_offs’
  4011. The offset of the first real element of the vector, from its
  4012. nominal address in the ‘gl_pathv’ field. Unlike the other
  4013. fields, this is always an input to ‘glob’, rather than an
  4014. output from it.
  4015. If you use a nonzero offset, then that many elements at the
  4016. beginning of the vector are left empty. (The ‘glob’ function
  4017. fills them with null pointers.)
  4018. The ‘gl_offs’ field is meaningful only if you use the
  4019. ‘GLOB_DOOFFS’ flag. Otherwise, the offset is always zero
  4020. regardless of what is in this field, and the first real
  4021. element comes at the beginning of the vector.
  4022. ‘gl_closedir’
  4023. The address of an alternative implementation of the ‘closedir’
  4024. function. It is used if the ‘GLOB_ALTDIRFUNC’ bit is set in
  4025. the flag parameter. The type of this field is
  4026. ‘void (*) (void *)’.
  4027. This is a GNU extension.
  4028. ‘gl_readdir’
  4029. The address of an alternative implementation of the
  4030. ‘readdir64’ function used to read the contents of a directory.
  4031. It is used if the ‘GLOB_ALTDIRFUNC’ bit is set in the flag
  4032. parameter. The type of this field is
  4033. ‘struct dirent64 *(*) (void *)’.
  4034. This is a GNU extension.
  4035. ‘gl_opendir’
  4036. The address of an alternative implementation of the ‘opendir’
  4037. function. It is used if the ‘GLOB_ALTDIRFUNC’ bit is set in
  4038. the flag parameter. The type of this field is
  4039. ‘void *(*) (const char *)’.
  4040. This is a GNU extension.
  4041. ‘gl_stat’
  4042. The address of an alternative implementation of the ‘stat64’
  4043. function to get information about an object in the filesystem.
  4044. It is used if the ‘GLOB_ALTDIRFUNC’ bit is set in the flag
  4045. parameter. The type of this field is
  4046. ‘int (*) (const char *, struct stat64 *)’.
  4047. This is a GNU extension.
  4048. ‘gl_lstat’
  4049. The address of an alternative implementation of the ‘lstat64’
  4050. function to get information about an object in the
  4051. filesystems, not following symbolic links. It is used if the
  4052. ‘GLOB_ALTDIRFUNC’ bit is set in the flag parameter. The type
  4053. of this field is ‘int (*) (const char *, struct stat64 *)’.
  4054. This is a GNU extension.
  4055. ‘gl_flags’
  4056. The flags used when ‘glob’ was called. In addition,
  4057. ‘GLOB_MAGCHAR’ might be set. See *note Flags for Globbing::
  4058. for more details.
  4059. This is a GNU extension.
  4060. -- Function: int glob (const char *PATTERN, int FLAGS, int (*ERRFUNC)
  4061. (const char *FILENAME, int ERROR-CODE), glob_t *VECTOR-PTR)
  4062. Preliminary: | MT-Unsafe race:utent env sig:ALRM timer locale |
  4063. AS-Unsafe dlopen plugin corrupt heap lock | AC-Unsafe corrupt lock
  4064. fd mem | *Note POSIX Safety Concepts::.
  4065. The function ‘glob’ does globbing using the pattern PATTERN in the
  4066. current directory. It puts the result in a newly allocated vector,
  4067. and stores the size and address of this vector into ‘*VECTOR-PTR’.
  4068. The argument FLAGS is a combination of bit flags; see *note Flags
  4069. for Globbing::, for details of the flags.
  4070. The result of globbing is a sequence of file names. The function
  4071. ‘glob’ allocates a string for each resulting word, then allocates a
  4072. vector of type ‘char **’ to store the addresses of these strings.
  4073. The last element of the vector is a null pointer. This vector is
  4074. called the “word vector”.
  4075. To return this vector, ‘glob’ stores both its address and its
  4076. length (number of elements, not counting the terminating null
  4077. pointer) into ‘*VECTOR-PTR’.
  4078. Normally, ‘glob’ sorts the file names alphabetically before
  4079. returning them. You can turn this off with the flag ‘GLOB_NOSORT’
  4080. if you want to get the information as fast as possible. Usually
  4081. it’s a good idea to let ‘glob’ sort them—if you process the files
  4082. in alphabetical order, the users will have a feel for the rate of
  4083. progress that your application is making.
  4084. If ‘glob’ succeeds, it returns 0. Otherwise, it returns one of
  4085. these error codes:
  4086. ‘GLOB_ABORTED’
  4087. There was an error opening a directory, and you used the flag
  4088. ‘GLOB_ERR’ or your specified ERRFUNC returned a nonzero value.
  4089. *Note Flags for Globbing::, for an explanation of the
  4090. ‘GLOB_ERR’ flag and ERRFUNC.
  4091. ‘GLOB_NOMATCH’
  4092. The pattern didn’t match any existing files. If you use the
  4093. ‘GLOB_NOCHECK’ flag, then you never get this error code,
  4094. because that flag tells ‘glob’ to _pretend_ that the pattern
  4095. matched at least one file.
  4096. ‘GLOB_NOSPACE’
  4097. It was impossible to allocate memory to hold the result.
  4098. In the event of an error, ‘glob’ stores information in
  4099. ‘*VECTOR-PTR’ about all the matches it has found so far.
  4100. It is important to notice that the ‘glob’ function will not fail if
  4101. it encounters directories or files which cannot be handled without
  4102. the LFS interfaces. The implementation of ‘glob’ is supposed to
  4103. use these functions internally. This at least is the assumption
  4104. made by the Unix standard. The GNU extension of allowing the user
  4105. to provide their own directory handling and ‘stat’ functions
  4106. complicates things a bit. If these callback functions are used and
  4107. a large file or directory is encountered ‘glob’ _can_ fail.
  4108. -- Function: int glob64 (const char *PATTERN, int FLAGS, int (*ERRFUNC)
  4109. (const char *FILENAME, int ERROR-CODE), glob64_t *VECTOR-PTR)
  4110. Preliminary: | MT-Unsafe race:utent env sig:ALRM timer locale |
  4111. AS-Unsafe dlopen corrupt heap lock | AC-Unsafe corrupt lock fd mem
  4112. | *Note POSIX Safety Concepts::.
  4113. The ‘glob64’ function was added as part of the Large File Summit
  4114. extensions but is not part of the original LFS proposal. The
  4115. reason for this is simple: it is not necessary. The necessity for
  4116. a ‘glob64’ function is added by the extensions of the GNU ‘glob’
  4117. implementation which allows the user to provide their own directory
  4118. handling and ‘stat’ functions. The ‘readdir’ and ‘stat’ functions
  4119. do depend on the choice of ‘_FILE_OFFSET_BITS’ since the definition
  4120. of the types ‘struct dirent’ and ‘struct stat’ will change
  4121. depending on the choice.
  4122. Besides this difference, ‘glob64’ works just like ‘glob’ in all
  4123. aspects.
  4124. This function is a GNU extension.
  4125. 
  4126. File: libc.info, Node: Flags for Globbing, Next: More Flags for Globbing, Prev: Calling Glob, Up: Globbing
  4127. 10.2.2 Flags for Globbing
  4128. -------------------------
  4129. This section describes the standard flags that you can specify in the
  4130. FLAGS argument to ‘glob’. Choose the flags you want, and combine them
  4131. with the C bitwise OR operator ‘|’.
  4132. Note that there are *note More Flags for Globbing:: available as GNU
  4133. extensions.
  4134. ‘GLOB_APPEND’
  4135. Append the words from this expansion to the vector of words
  4136. produced by previous calls to ‘glob’. This way you can effectively
  4137. expand several words as if they were concatenated with spaces
  4138. between them.
  4139. In order for appending to work, you must not modify the contents of
  4140. the word vector structure between calls to ‘glob’. And, if you set
  4141. ‘GLOB_DOOFFS’ in the first call to ‘glob’, you must also set it
  4142. when you append to the results.
  4143. Note that the pointer stored in ‘gl_pathv’ may no longer be valid
  4144. after you call ‘glob’ the second time, because ‘glob’ might have
  4145. relocated the vector. So always fetch ‘gl_pathv’ from the ‘glob_t’
  4146. structure after each ‘glob’ call; *never* save the pointer across
  4147. calls.
  4148. ‘GLOB_DOOFFS’
  4149. Leave blank slots at the beginning of the vector of words. The
  4150. ‘gl_offs’ field says how many slots to leave. The blank slots
  4151. contain null pointers.
  4152. ‘GLOB_ERR’
  4153. Give up right away and report an error if there is any difficulty
  4154. reading the directories that must be read in order to expand
  4155. PATTERN fully. Such difficulties might include a directory in
  4156. which you don’t have the requisite access. Normally, ‘glob’ tries
  4157. its best to keep on going despite any errors, reading whatever
  4158. directories it can.
  4159. You can exercise even more control than this by specifying an
  4160. error-handler function ERRFUNC when you call ‘glob’. If ERRFUNC is
  4161. not a null pointer, then ‘glob’ doesn’t give up right away when it
  4162. can’t read a directory; instead, it calls ERRFUNC with two
  4163. arguments, like this:
  4164. (*ERRFUNC) (FILENAME, ERROR-CODE)
  4165. The argument FILENAME is the name of the directory that ‘glob’
  4166. couldn’t open or couldn’t read, and ERROR-CODE is the ‘errno’ value
  4167. that was reported to ‘glob’.
  4168. If the error handler function returns nonzero, then ‘glob’ gives up
  4169. right away. Otherwise, it continues.
  4170. ‘GLOB_MARK’
  4171. If the pattern matches the name of a directory, append ‘/’ to the
  4172. directory’s name when returning it.
  4173. ‘GLOB_NOCHECK’
  4174. If the pattern doesn’t match any file names, return the pattern
  4175. itself as if it were a file name that had been matched. (Normally,
  4176. when the pattern doesn’t match anything, ‘glob’ returns that there
  4177. were no matches.)
  4178. ‘GLOB_NOESCAPE’
  4179. Don’t treat the ‘\’ character specially in patterns. Normally, ‘\’
  4180. quotes the following character, turning off its special meaning (if
  4181. any) so that it matches only itself. When quoting is enabled, the
  4182. pattern ‘\?’ matches only the string ‘?’, because the question mark
  4183. in the pattern acts like an ordinary character.
  4184. If you use ‘GLOB_NOESCAPE’, then ‘\’ is an ordinary character.
  4185. ‘glob’ does its work by calling the function ‘fnmatch’ repeatedly.
  4186. It handles the flag ‘GLOB_NOESCAPE’ by turning on the
  4187. ‘FNM_NOESCAPE’ flag in calls to ‘fnmatch’.
  4188. ‘GLOB_NOSORT’
  4189. Don’t sort the file names; return them in no particular order. (In
  4190. practice, the order will depend on the order of the entries in the
  4191. directory.) The only reason _not_ to sort is to save time.
  4192. 
  4193. File: libc.info, Node: More Flags for Globbing, Prev: Flags for Globbing, Up: Globbing
  4194. 10.2.3 More Flags for Globbing
  4195. ------------------------------
  4196. Beside the flags described in the last section, the GNU implementation
  4197. of ‘glob’ allows a few more flags which are also defined in the ‘glob.h’
  4198. file. Some of the extensions implement functionality which is available
  4199. in modern shell implementations.
  4200. ‘GLOB_PERIOD’
  4201. The ‘.’ character (period) is treated special. It cannot be
  4202. matched by wildcards. *Note Wildcard Matching::, ‘FNM_PERIOD’.
  4203. ‘GLOB_MAGCHAR’
  4204. The ‘GLOB_MAGCHAR’ value is not to be given to ‘glob’ in the FLAGS
  4205. parameter. Instead, ‘glob’ sets this bit in the GL_FLAGS element
  4206. of the GLOB_T structure provided as the result if the pattern used
  4207. for matching contains any wildcard character.
  4208. ‘GLOB_ALTDIRFUNC’
  4209. Instead of using the normal functions for accessing the filesystem
  4210. the ‘glob’ implementation uses the user-supplied functions
  4211. specified in the structure pointed to by PGLOB parameter. For more
  4212. information about the functions refer to the sections about
  4213. directory handling see *note Accessing Directories::, and *note
  4214. Reading Attributes::.
  4215. ‘GLOB_BRACE’
  4216. If this flag is given, the handling of braces in the pattern is
  4217. changed. It is now required that braces appear correctly grouped.
  4218. I.e., for each opening brace there must be a closing one. Braces
  4219. can be used recursively. So it is possible to define one brace
  4220. expression in another one. It is important to note that the range
  4221. of each brace expression is completely contained in the outer brace
  4222. expression (if there is one).
  4223. The string between the matching braces is separated into single
  4224. expressions by splitting at ‘,’ (comma) characters. The commas
  4225. themselves are discarded. Please note what we said above about
  4226. recursive brace expressions. The commas used to separate the
  4227. subexpressions must be at the same level. Commas in brace
  4228. subexpressions are not matched. They are used during expansion of
  4229. the brace expression of the deeper level. The example below shows
  4230. this
  4231. glob ("{foo/{,bar,biz},baz}", GLOB_BRACE, NULL, &result)
  4232. is equivalent to the sequence
  4233. glob ("foo/", GLOB_BRACE, NULL, &result)
  4234. glob ("foo/bar", GLOB_BRACE|GLOB_APPEND, NULL, &result)
  4235. glob ("foo/biz", GLOB_BRACE|GLOB_APPEND, NULL, &result)
  4236. glob ("baz", GLOB_BRACE|GLOB_APPEND, NULL, &result)
  4237. if we leave aside error handling.
  4238. ‘GLOB_NOMAGIC’
  4239. If the pattern contains no wildcard constructs (it is a literal
  4240. file name), return it as the sole “matching” word, even if no file
  4241. exists by that name.
  4242. ‘GLOB_TILDE’
  4243. If this flag is used the character ‘~’ (tilde) is handled specially
  4244. if it appears at the beginning of the pattern. Instead of being
  4245. taken verbatim it is used to represent the home directory of a
  4246. known user.
  4247. If ‘~’ is the only character in pattern or it is followed by a ‘/’
  4248. (slash), the home directory of the process owner is substituted.
  4249. Using ‘getlogin’ and ‘getpwnam’ the information is read from the
  4250. system databases. As an example take user ‘bart’ with his home
  4251. directory at ‘/home/bart’. For him a call like
  4252. glob ("~/bin/*", GLOB_TILDE, NULL, &result)
  4253. would return the contents of the directory ‘/home/bart/bin’.
  4254. Instead of referring to the own home directory it is also possible
  4255. to name the home directory of other users. To do so one has to
  4256. append the user name after the tilde character. So the contents of
  4257. user ‘homer’’s ‘bin’ directory can be retrieved by
  4258. glob ("~homer/bin/*", GLOB_TILDE, NULL, &result)
  4259. If the user name is not valid or the home directory cannot be
  4260. determined for some reason the pattern is left untouched and itself
  4261. used as the result. I.e., if in the last example ‘home’ is not
  4262. available the tilde expansion yields to ‘"~homer/bin/*"’ and ‘glob’
  4263. is not looking for a directory named ‘~homer’.
  4264. This functionality is equivalent to what is available in C-shells
  4265. if the ‘nonomatch’ flag is set.
  4266. ‘GLOB_TILDE_CHECK’
  4267. If this flag is used ‘glob’ behaves as if ‘GLOB_TILDE’ is given.
  4268. The only difference is that if the user name is not available or
  4269. the home directory cannot be determined for other reasons this
  4270. leads to an error. ‘glob’ will return ‘GLOB_NOMATCH’ instead of
  4271. using the pattern itself as the name.
  4272. This functionality is equivalent to what is available in C-shells
  4273. if the ‘nonomatch’ flag is not set.
  4274. ‘GLOB_ONLYDIR’
  4275. If this flag is used the globbing function takes this as a *hint*
  4276. that the caller is only interested in directories matching the
  4277. pattern. If the information about the type of the file is easily
  4278. available non-directories will be rejected but no extra work will
  4279. be done to determine the information for each file. I.e., the
  4280. caller must still be able to filter directories out.
  4281. This functionality is only available with the GNU ‘glob’
  4282. implementation. It is mainly used internally to increase the
  4283. performance but might be useful for a user as well and therefore is
  4284. documented here.
  4285. Calling ‘glob’ will in most cases allocate resources which are used
  4286. to represent the result of the function call. If the same object of
  4287. type ‘glob_t’ is used in multiple call to ‘glob’ the resources are freed
  4288. or reused so that no leaks appear. But this does not include the time
  4289. when all ‘glob’ calls are done.
  4290. -- Function: void globfree (glob_t *PGLOB)
  4291. Preliminary: | MT-Safe | AS-Unsafe corrupt heap | AC-Unsafe corrupt
  4292. mem | *Note POSIX Safety Concepts::.
  4293. The ‘globfree’ function frees all resources allocated by previous
  4294. calls to ‘glob’ associated with the object pointed to by PGLOB.
  4295. This function should be called whenever the currently used ‘glob_t’
  4296. typed object isn’t used anymore.
  4297. -- Function: void globfree64 (glob64_t *PGLOB)
  4298. Preliminary: | MT-Safe | AS-Unsafe corrupt lock | AC-Unsafe corrupt
  4299. lock fd mem | *Note POSIX Safety Concepts::.
  4300. This function is equivalent to ‘globfree’ but it frees records of
  4301. type ‘glob64_t’ which were allocated by ‘glob64’.
  4302. 
  4303. File: libc.info, Node: Regular Expressions, Next: Word Expansion, Prev: Globbing, Up: Pattern Matching
  4304. 10.3 Regular Expression Matching
  4305. ================================
  4306. The GNU C Library supports two interfaces for matching regular
  4307. expressions. One is the standard POSIX.2 interface, and the other is
  4308. what the GNU C Library has had for many years.
  4309. Both interfaces are declared in the header file ‘regex.h’. If you
  4310. define ‘_POSIX_C_SOURCE’, then only the POSIX.2 functions, structures,
  4311. and constants are declared.
  4312. * Menu:
  4313. * POSIX Regexp Compilation:: Using ‘regcomp’ to prepare to match.
  4314. * Flags for POSIX Regexps:: Syntax variations for ‘regcomp’.
  4315. * Matching POSIX Regexps:: Using ‘regexec’ to match the compiled
  4316. pattern that you get from ‘regcomp’.
  4317. * Regexp Subexpressions:: Finding which parts of the string were matched.
  4318. * Subexpression Complications:: Find points of which parts were matched.
  4319. * Regexp Cleanup:: Freeing storage; reporting errors.
  4320. 
  4321. File: libc.info, Node: POSIX Regexp Compilation, Next: Flags for POSIX Regexps, Up: Regular Expressions
  4322. 10.3.1 POSIX Regular Expression Compilation
  4323. -------------------------------------------
  4324. Before you can actually match a regular expression, you must “compile”
  4325. it. This is not true compilation—it produces a special data structure,
  4326. not machine instructions. But it is like ordinary compilation in that
  4327. its purpose is to enable you to “execute” the pattern fast. (*Note
  4328. Matching POSIX Regexps::, for how to use the compiled regular expression
  4329. for matching.)
  4330. There is a special data type for compiled regular expressions:
  4331. -- Data Type: regex_t
  4332. This type of object holds a compiled regular expression. It is
  4333. actually a structure. It has just one field that your programs
  4334. should look at:
  4335. ‘re_nsub’
  4336. This field holds the number of parenthetical subexpressions in
  4337. the regular expression that was compiled.
  4338. There are several other fields, but we don’t describe them here,
  4339. because only the functions in the library should use them.
  4340. After you create a ‘regex_t’ object, you can compile a regular
  4341. expression into it by calling ‘regcomp’.
  4342. -- Function: int regcomp (regex_t *restrict COMPILED, const char
  4343. *restrict PATTERN, int CFLAGS)
  4344. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap lock dlopen
  4345. | AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  4346. The function ‘regcomp’ “compiles” a regular expression into a data
  4347. structure that you can use with ‘regexec’ to match against a
  4348. string. The compiled regular expression format is designed for
  4349. efficient matching. ‘regcomp’ stores it into ‘*COMPILED’.
  4350. It’s up to you to allocate an object of type ‘regex_t’ and pass its
  4351. address to ‘regcomp’.
  4352. The argument CFLAGS lets you specify various options that control
  4353. the syntax and semantics of regular expressions. *Note Flags for
  4354. POSIX Regexps::.
  4355. If you use the flag ‘REG_NOSUB’, then ‘regcomp’ omits from the
  4356. compiled regular expression the information necessary to record how
  4357. subexpressions actually match. In this case, you might as well
  4358. pass ‘0’ for the MATCHPTR and NMATCH arguments when you call
  4359. ‘regexec’.
  4360. If you don’t use ‘REG_NOSUB’, then the compiled regular expression
  4361. does have the capacity to record how subexpressions match. Also,
  4362. ‘regcomp’ tells you how many subexpressions PATTERN has, by storing
  4363. the number in ‘COMPILED->re_nsub’. You can use that value to
  4364. decide how long an array to allocate to hold information about
  4365. subexpression matches.
  4366. ‘regcomp’ returns ‘0’ if it succeeds in compiling the regular
  4367. expression; otherwise, it returns a nonzero error code (see the
  4368. table below). You can use ‘regerror’ to produce an error message
  4369. string describing the reason for a nonzero value; see *note Regexp
  4370. Cleanup::.
  4371. Here are the possible nonzero values that ‘regcomp’ can return:
  4372. ‘REG_BADBR’
  4373. There was an invalid ‘\{...\}’ construct in the regular expression.
  4374. A valid ‘\{...\}’ construct must contain either a single number, or
  4375. two numbers in increasing order separated by a comma.
  4376. ‘REG_BADPAT’
  4377. There was a syntax error in the regular expression.
  4378. ‘REG_BADRPT’
  4379. A repetition operator such as ‘?’ or ‘*’ appeared in a bad position
  4380. (with no preceding subexpression to act on).
  4381. ‘REG_ECOLLATE’
  4382. The regular expression referred to an invalid collating element
  4383. (one not defined in the current locale for string collation).
  4384. *Note Locale Categories::.
  4385. ‘REG_ECTYPE’
  4386. The regular expression referred to an invalid character class name.
  4387. ‘REG_EESCAPE’
  4388. The regular expression ended with ‘\’.
  4389. ‘REG_ESUBREG’
  4390. There was an invalid number in the ‘\DIGIT’ construct.
  4391. ‘REG_EBRACK’
  4392. There were unbalanced square brackets in the regular expression.
  4393. ‘REG_EPAREN’
  4394. An extended regular expression had unbalanced parentheses, or a
  4395. basic regular expression had unbalanced ‘\(’ and ‘\)’.
  4396. ‘REG_EBRACE’
  4397. The regular expression had unbalanced ‘\{’ and ‘\}’.
  4398. ‘REG_ERANGE’
  4399. One of the endpoints in a range expression was invalid.
  4400. ‘REG_ESPACE’
  4401. ‘regcomp’ ran out of memory.
  4402. 
  4403. File: libc.info, Node: Flags for POSIX Regexps, Next: Matching POSIX Regexps, Prev: POSIX Regexp Compilation, Up: Regular Expressions
  4404. 10.3.2 Flags for POSIX Regular Expressions
  4405. ------------------------------------------
  4406. These are the bit flags that you can use in the CFLAGS operand when
  4407. compiling a regular expression with ‘regcomp’.
  4408. ‘REG_EXTENDED’
  4409. Treat the pattern as an extended regular expression, rather than as
  4410. a basic regular expression.
  4411. ‘REG_ICASE’
  4412. Ignore case when matching letters.
  4413. ‘REG_NOSUB’
  4414. Don’t bother storing the contents of the MATCHPTR array.
  4415. ‘REG_NEWLINE’
  4416. Treat a newline in STRING as dividing STRING into multiple lines,
  4417. so that ‘$’ can match before the newline and ‘^’ can match after.
  4418. Also, don’t permit ‘.’ to match a newline, and don’t permit
  4419. ‘[^...]’ to match a newline.
  4420. Otherwise, newline acts like any other ordinary character.
  4421. 
  4422. File: libc.info, Node: Matching POSIX Regexps, Next: Regexp Subexpressions, Prev: Flags for POSIX Regexps, Up: Regular Expressions
  4423. 10.3.3 Matching a Compiled POSIX Regular Expression
  4424. ---------------------------------------------------
  4425. Once you have compiled a regular expression, as described in *note POSIX
  4426. Regexp Compilation::, you can match it against strings using ‘regexec’.
  4427. A match anywhere inside the string counts as success, unless the regular
  4428. expression contains anchor characters (‘^’ or ‘$’).
  4429. -- Function: int regexec (const regex_t *restrict COMPILED, const char
  4430. *restrict STRING, size_t NMATCH, regmatch_t
  4431. MATCHPTR[restrict], int EFLAGS)
  4432. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap lock dlopen
  4433. | AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  4434. This function tries to match the compiled regular expression
  4435. ‘*COMPILED’ against STRING.
  4436. ‘regexec’ returns ‘0’ if the regular expression matches; otherwise,
  4437. it returns a nonzero value. See the table below for what nonzero
  4438. values mean. You can use ‘regerror’ to produce an error message
  4439. string describing the reason for a nonzero value; see *note Regexp
  4440. Cleanup::.
  4441. The argument EFLAGS is a word of bit flags that enable various
  4442. options.
  4443. If you want to get information about what part of STRING actually
  4444. matched the regular expression or its subexpressions, use the
  4445. arguments MATCHPTR and NMATCH. Otherwise, pass ‘0’ for NMATCH, and
  4446. ‘NULL’ for MATCHPTR. *Note Regexp Subexpressions::.
  4447. You must match the regular expression with the same set of current
  4448. locales that were in effect when you compiled the regular expression.
  4449. The function ‘regexec’ accepts the following flags in the EFLAGS
  4450. argument:
  4451. ‘REG_NOTBOL’
  4452. Do not regard the beginning of the specified string as the
  4453. beginning of a line; more generally, don’t make any assumptions
  4454. about what text might precede it.
  4455. ‘REG_NOTEOL’
  4456. Do not regard the end of the specified string as the end of a line;
  4457. more generally, don’t make any assumptions about what text might
  4458. follow it.
  4459. Here are the possible nonzero values that ‘regexec’ can return:
  4460. ‘REG_NOMATCH’
  4461. The pattern didn’t match the string. This isn’t really an error.
  4462. ‘REG_ESPACE’
  4463. ‘regexec’ ran out of memory.
  4464. 
  4465. File: libc.info, Node: Regexp Subexpressions, Next: Subexpression Complications, Prev: Matching POSIX Regexps, Up: Regular Expressions
  4466. 10.3.4 Match Results with Subexpressions
  4467. ----------------------------------------
  4468. When ‘regexec’ matches parenthetical subexpressions of PATTERN, it
  4469. records which parts of STRING they match. It returns that information
  4470. by storing the offsets into an array whose elements are structures of
  4471. type ‘regmatch_t’. The first element of the array (index ‘0’) records
  4472. the part of the string that matched the entire regular expression. Each
  4473. other element of the array records the beginning and end of the part
  4474. that matched a single parenthetical subexpression.
  4475. -- Data Type: regmatch_t
  4476. This is the data type of the MATCHPTR array that you pass to
  4477. ‘regexec’. It contains two structure fields, as follows:
  4478. ‘rm_so’
  4479. The offset in STRING of the beginning of a substring. Add
  4480. this value to STRING to get the address of that part.
  4481. ‘rm_eo’
  4482. The offset in STRING of the end of the substring.
  4483. -- Data Type: regoff_t
  4484. ‘regoff_t’ is an alias for another signed integer type. The fields
  4485. of ‘regmatch_t’ have type ‘regoff_t’.
  4486. The ‘regmatch_t’ elements correspond to subexpressions positionally;
  4487. the first element (index ‘1’) records where the first subexpression
  4488. matched, the second element records the second subexpression, and so on.
  4489. The order of the subexpressions is the order in which they begin.
  4490. When you call ‘regexec’, you specify how long the MATCHPTR array is,
  4491. with the NMATCH argument. This tells ‘regexec’ how many elements to
  4492. store. If the actual regular expression has more than NMATCH
  4493. subexpressions, then you won’t get offset information about the rest of
  4494. them. But this doesn’t alter whether the pattern matches a particular
  4495. string or not.
  4496. If you don’t want ‘regexec’ to return any information about where the
  4497. subexpressions matched, you can either supply ‘0’ for NMATCH, or use the
  4498. flag ‘REG_NOSUB’ when you compile the pattern with ‘regcomp’.
  4499. 
  4500. File: libc.info, Node: Subexpression Complications, Next: Regexp Cleanup, Prev: Regexp Subexpressions, Up: Regular Expressions
  4501. 10.3.5 Complications in Subexpression Matching
  4502. ----------------------------------------------
  4503. Sometimes a subexpression matches a substring of no characters. This
  4504. happens when ‘f\(o*\)’ matches the string ‘fum’. (It really matches
  4505. just the ‘f’.) In this case, both of the offsets identify the point in
  4506. the string where the null substring was found. In this example, the
  4507. offsets are both ‘1’.
  4508. Sometimes the entire regular expression can match without using some
  4509. of its subexpressions at all—for example, when ‘ba\(na\)*’ matches the
  4510. string ‘ba’, the parenthetical subexpression is not used. When this
  4511. happens, ‘regexec’ stores ‘-1’ in both fields of the element for that
  4512. subexpression.
  4513. Sometimes matching the entire regular expression can match a
  4514. particular subexpression more than once—for example, when ‘ba\(na\)*’
  4515. matches the string ‘bananana’, the parenthetical subexpression matches
  4516. three times. When this happens, ‘regexec’ usually stores the offsets of
  4517. the last part of the string that matched the subexpression. In the case
  4518. of ‘bananana’, these offsets are ‘6’ and ‘8’.
  4519. But the last match is not always the one that is chosen. It’s more
  4520. accurate to say that the last _opportunity_ to match is the one that
  4521. takes precedence. What this means is that when one subexpression
  4522. appears within another, then the results reported for the inner
  4523. subexpression reflect whatever happened on the last match of the outer
  4524. subexpression. For an example, consider ‘\(ba\(na\)*s \)*’ matching the
  4525. string ‘bananas bas ’. The last time the inner expression actually
  4526. matches is near the end of the first word. But it is _considered_ again
  4527. in the second word, and fails to match there. ‘regexec’ reports nonuse
  4528. of the “na” subexpression.
  4529. Another place where this rule applies is when the regular expression
  4530. \(ba\(na\)*s \|nefer\(ti\)* \)*
  4531. matches ‘bananas nefertiti’. The “na” subexpression does match in the
  4532. first word, but it doesn’t match in the second word because the other
  4533. alternative is used there. Once again, the second repetition of the
  4534. outer subexpression overrides the first, and within that second
  4535. repetition, the “na” subexpression is not used. So ‘regexec’ reports
  4536. nonuse of the “na” subexpression.
  4537. 
  4538. File: libc.info, Node: Regexp Cleanup, Prev: Subexpression Complications, Up: Regular Expressions
  4539. 10.3.6 POSIX Regexp Matching Cleanup
  4540. ------------------------------------
  4541. When you are finished using a compiled regular expression, you can free
  4542. the storage it uses by calling ‘regfree’.
  4543. -- Function: void regfree (regex_t *COMPILED)
  4544. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  4545. POSIX Safety Concepts::.
  4546. Calling ‘regfree’ frees all the storage that ‘*COMPILED’ points to.
  4547. This includes various internal fields of the ‘regex_t’ structure
  4548. that aren’t documented in this manual.
  4549. ‘regfree’ does not free the object ‘*COMPILED’ itself.
  4550. You should always free the space in a ‘regex_t’ structure with
  4551. ‘regfree’ before using the structure to compile another regular
  4552. expression.
  4553. When ‘regcomp’ or ‘regexec’ reports an error, you can use the
  4554. function ‘regerror’ to turn it into an error message string.
  4555. -- Function: size_t regerror (int ERRCODE, const regex_t *restrict
  4556. COMPILED, char *restrict BUFFER, size_t LENGTH)
  4557. Preliminary: | MT-Safe env | AS-Unsafe corrupt heap lock dlopen |
  4558. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  4559. This function produces an error message string for the error code
  4560. ERRCODE, and stores the string in LENGTH bytes of memory starting
  4561. at BUFFER. For the COMPILED argument, supply the same compiled
  4562. regular expression structure that ‘regcomp’ or ‘regexec’ was
  4563. working with when it got the error. Alternatively, you can supply
  4564. ‘NULL’ for COMPILED; you will still get a meaningful error message,
  4565. but it might not be as detailed.
  4566. If the error message can’t fit in LENGTH bytes (including a
  4567. terminating null character), then ‘regerror’ truncates it. The
  4568. string that ‘regerror’ stores is always null-terminated even if it
  4569. has been truncated.
  4570. The return value of ‘regerror’ is the minimum length needed to
  4571. store the entire error message. If this is less than LENGTH, then
  4572. the error message was not truncated, and you can use it.
  4573. Otherwise, you should call ‘regerror’ again with a larger buffer.
  4574. Here is a function which uses ‘regerror’, but always dynamically
  4575. allocates a buffer for the error message:
  4576. char *get_regerror (int errcode, regex_t *compiled)
  4577. {
  4578. size_t length = regerror (errcode, compiled, NULL, 0);
  4579. char *buffer = xmalloc (length);
  4580. (void) regerror (errcode, compiled, buffer, length);
  4581. return buffer;
  4582. }
  4583. 
  4584. File: libc.info, Node: Word Expansion, Prev: Regular Expressions, Up: Pattern Matching
  4585. 10.4 Shell-Style Word Expansion
  4586. ===============================
  4587. “Word expansion” means the process of splitting a string into “words”
  4588. and substituting for variables, commands, and wildcards just as the
  4589. shell does.
  4590. For example, when you write ‘ls -l foo.c’, this string is split into
  4591. three separate words—‘ls’, ‘-l’ and ‘foo.c’. This is the most basic
  4592. function of word expansion.
  4593. When you write ‘ls *.c’, this can become many words, because the word
  4594. ‘*.c’ can be replaced with any number of file names. This is called
  4595. “wildcard expansion”, and it is also a part of word expansion.
  4596. When you use ‘echo $PATH’ to print your path, you are taking
  4597. advantage of “variable substitution”, which is also part of word
  4598. expansion.
  4599. Ordinary programs can perform word expansion just like the shell by
  4600. calling the library function ‘wordexp’.
  4601. * Menu:
  4602. * Expansion Stages:: What word expansion does to a string.
  4603. * Calling Wordexp:: How to call ‘wordexp’.
  4604. * Flags for Wordexp:: Options you can enable in ‘wordexp’.
  4605. * Wordexp Example:: A sample program that does word expansion.
  4606. * Tilde Expansion:: Details of how tilde expansion works.
  4607. * Variable Substitution:: Different types of variable substitution.
  4608. 
  4609. File: libc.info, Node: Expansion Stages, Next: Calling Wordexp, Up: Word Expansion
  4610. 10.4.1 The Stages of Word Expansion
  4611. -----------------------------------
  4612. When word expansion is applied to a sequence of words, it performs the
  4613. following transformations in the order shown here:
  4614. 1. “Tilde expansion”: Replacement of ‘~foo’ with the name of the home
  4615. directory of ‘foo’.
  4616. 2. Next, three different transformations are applied in the same step,
  4617. from left to right:
  4618. • “Variable substitution”: Environment variables are substituted
  4619. for references such as ‘$foo’.
  4620. • “Command substitution”: Constructs such as ‘`cat foo`’ and the
  4621. equivalent ‘$(cat foo)’ are replaced with the output from the
  4622. inner command.
  4623. • “Arithmetic expansion”: Constructs such as ‘$(($x-1))’ are
  4624. replaced with the result of the arithmetic computation.
  4625. 3. “Field splitting”: subdivision of the text into “words”.
  4626. 4. “Wildcard expansion”: The replacement of a construct such as ‘*.c’
  4627. with a list of ‘.c’ file names. Wildcard expansion applies to an
  4628. entire word at a time, and replaces that word with 0 or more file
  4629. names that are themselves words.
  4630. 5. “Quote removal”: The deletion of string-quotes, now that they have
  4631. done their job by inhibiting the above transformations when
  4632. appropriate.
  4633. For the details of these transformations, and how to write the
  4634. constructs that use them, see ‘The BASH Manual’ (to appear).
  4635. 
  4636. File: libc.info, Node: Calling Wordexp, Next: Flags for Wordexp, Prev: Expansion Stages, Up: Word Expansion
  4637. 10.4.2 Calling ‘wordexp’
  4638. ------------------------
  4639. All the functions, constants and data types for word expansion are
  4640. declared in the header file ‘wordexp.h’.
  4641. Word expansion produces a vector of words (strings). To return this
  4642. vector, ‘wordexp’ uses a special data type, ‘wordexp_t’, which is a
  4643. structure. You pass ‘wordexp’ the address of the structure, and it
  4644. fills in the structure’s fields to tell you about the results.
  4645. -- Data Type: wordexp_t
  4646. This data type holds a pointer to a word vector. More precisely,
  4647. it records both the address of the word vector and its size.
  4648. ‘we_wordc’
  4649. The number of elements in the vector.
  4650. ‘we_wordv’
  4651. The address of the vector. This field has type ‘char **’.
  4652. ‘we_offs’
  4653. The offset of the first real element of the vector, from its
  4654. nominal address in the ‘we_wordv’ field. Unlike the other
  4655. fields, this is always an input to ‘wordexp’, rather than an
  4656. output from it.
  4657. If you use a nonzero offset, then that many elements at the
  4658. beginning of the vector are left empty. (The ‘wordexp’
  4659. function fills them with null pointers.)
  4660. The ‘we_offs’ field is meaningful only if you use the
  4661. ‘WRDE_DOOFFS’ flag. Otherwise, the offset is always zero
  4662. regardless of what is in this field, and the first real
  4663. element comes at the beginning of the vector.
  4664. -- Function: int wordexp (const char *WORDS, wordexp_t
  4665. *WORD-VECTOR-PTR, int FLAGS)
  4666. Preliminary: | MT-Unsafe race:utent const:env env sig:ALRM timer
  4667. locale | AS-Unsafe dlopen plugin i18n heap corrupt lock | AC-Unsafe
  4668. corrupt lock fd mem | *Note POSIX Safety Concepts::.
  4669. Perform word expansion on the string WORDS, putting the result in a
  4670. newly allocated vector, and store the size and address of this
  4671. vector into ‘*WORD-VECTOR-PTR’. The argument FLAGS is a
  4672. combination of bit flags; see *note Flags for Wordexp::, for
  4673. details of the flags.
  4674. You shouldn’t use any of the characters ‘|&;<>’ in the string WORDS
  4675. unless they are quoted; likewise for newline. If you use these
  4676. characters unquoted, you will get the ‘WRDE_BADCHAR’ error code.
  4677. Don’t use parentheses or braces unless they are quoted or part of a
  4678. word expansion construct. If you use quotation characters ‘'"`’,
  4679. they should come in pairs that balance.
  4680. The results of word expansion are a sequence of words. The
  4681. function ‘wordexp’ allocates a string for each resulting word, then
  4682. allocates a vector of type ‘char **’ to store the addresses of
  4683. these strings. The last element of the vector is a null pointer.
  4684. This vector is called the “word vector”.
  4685. To return this vector, ‘wordexp’ stores both its address and its
  4686. length (number of elements, not counting the terminating null
  4687. pointer) into ‘*WORD-VECTOR-PTR’.
  4688. If ‘wordexp’ succeeds, it returns 0. Otherwise, it returns one of
  4689. these error codes:
  4690. ‘WRDE_BADCHAR’
  4691. The input string WORDS contains an unquoted invalid character
  4692. such as ‘|’.
  4693. ‘WRDE_BADVAL’
  4694. The input string refers to an undefined shell variable, and
  4695. you used the flag ‘WRDE_UNDEF’ to forbid such references.
  4696. ‘WRDE_CMDSUB’
  4697. The input string uses command substitution, and you used the
  4698. flag ‘WRDE_NOCMD’ to forbid command substitution.
  4699. ‘WRDE_NOSPACE’
  4700. It was impossible to allocate memory to hold the result. In
  4701. this case, ‘wordexp’ can store part of the results—as much as
  4702. it could allocate room for.
  4703. ‘WRDE_SYNTAX’
  4704. There was a syntax error in the input string. For example, an
  4705. unmatched quoting character is a syntax error. This error
  4706. code is also used to signal division by zero and overflow in
  4707. arithmetic expansion.
  4708. -- Function: void wordfree (wordexp_t *WORD-VECTOR-PTR)
  4709. Preliminary: | MT-Safe | AS-Unsafe corrupt heap | AC-Unsafe corrupt
  4710. mem | *Note POSIX Safety Concepts::.
  4711. Free the storage used for the word-strings and vector that
  4712. ‘*WORD-VECTOR-PTR’ points to. This does not free the structure
  4713. ‘*WORD-VECTOR-PTR’ itself—only the other data it points to.
  4714. 
  4715. File: libc.info, Node: Flags for Wordexp, Next: Wordexp Example, Prev: Calling Wordexp, Up: Word Expansion
  4716. 10.4.3 Flags for Word Expansion
  4717. -------------------------------
  4718. This section describes the flags that you can specify in the FLAGS
  4719. argument to ‘wordexp’. Choose the flags you want, and combine them with
  4720. the C operator ‘|’.
  4721. ‘WRDE_APPEND’
  4722. Append the words from this expansion to the vector of words
  4723. produced by previous calls to ‘wordexp’. This way you can
  4724. effectively expand several words as if they were concatenated with
  4725. spaces between them.
  4726. In order for appending to work, you must not modify the contents of
  4727. the word vector structure between calls to ‘wordexp’. And, if you
  4728. set ‘WRDE_DOOFFS’ in the first call to ‘wordexp’, you must also set
  4729. it when you append to the results.
  4730. ‘WRDE_DOOFFS’
  4731. Leave blank slots at the beginning of the vector of words. The
  4732. ‘we_offs’ field says how many slots to leave. The blank slots
  4733. contain null pointers.
  4734. ‘WRDE_NOCMD’
  4735. Don’t do command substitution; if the input requests command
  4736. substitution, report an error.
  4737. ‘WRDE_REUSE’
  4738. Reuse a word vector made by a previous call to ‘wordexp’. Instead
  4739. of allocating a new vector of words, this call to ‘wordexp’ will
  4740. use the vector that already exists (making it larger if necessary).
  4741. Note that the vector may move, so it is not safe to save an old
  4742. pointer and use it again after calling ‘wordexp’. You must fetch
  4743. ‘we_pathv’ anew after each call.
  4744. ‘WRDE_SHOWERR’
  4745. Do show any error messages printed by commands run by command
  4746. substitution. More precisely, allow these commands to inherit the
  4747. standard error output stream of the current process. By default,
  4748. ‘wordexp’ gives these commands a standard error stream that
  4749. discards all output.
  4750. ‘WRDE_UNDEF’
  4751. If the input refers to a shell variable that is not defined, report
  4752. an error.
  4753. 
  4754. File: libc.info, Node: Wordexp Example, Next: Tilde Expansion, Prev: Flags for Wordexp, Up: Word Expansion
  4755. 10.4.4 ‘wordexp’ Example
  4756. ------------------------
  4757. Here is an example of using ‘wordexp’ to expand several strings and use
  4758. the results to run a shell command. It also shows the use of
  4759. ‘WRDE_APPEND’ to concatenate the expansions and of ‘wordfree’ to free
  4760. the space allocated by ‘wordexp’.
  4761. int
  4762. expand_and_execute (const char *program, const char **options)
  4763. {
  4764. wordexp_t result;
  4765. pid_t pid
  4766. int status, i;
  4767. /* Expand the string for the program to run. */
  4768. switch (wordexp (program, &result, 0))
  4769. {
  4770. case 0: /* Successful. */
  4771. break;
  4772. case WRDE_NOSPACE:
  4773. /* If the error was ‘WRDE_NOSPACE’,
  4774. then perhaps part of the result was allocated. */
  4775. wordfree (&result);
  4776. default: /* Some other error. */
  4777. return -1;
  4778. }
  4779. /* Expand the strings specified for the arguments. */
  4780. for (i = 0; options[i] != NULL; i++)
  4781. {
  4782. if (wordexp (options[i], &result, WRDE_APPEND))
  4783. {
  4784. wordfree (&result);
  4785. return -1;
  4786. }
  4787. }
  4788. pid = fork ();
  4789. if (pid == 0)
  4790. {
  4791. /* This is the child process. Execute the command. */
  4792. execv (result.we_wordv[0], result.we_wordv);
  4793. exit (EXIT_FAILURE);
  4794. }
  4795. else if (pid < 0)
  4796. /* The fork failed. Report failure. */
  4797. status = -1;
  4798. else
  4799. /* This is the parent process. Wait for the child to complete. */
  4800. if (waitpid (pid, &status, 0) != pid)
  4801. status = -1;
  4802. wordfree (&result);
  4803. return status;
  4804. }
  4805. 
  4806. File: libc.info, Node: Tilde Expansion, Next: Variable Substitution, Prev: Wordexp Example, Up: Word Expansion
  4807. 10.4.5 Details of Tilde Expansion
  4808. ---------------------------------
  4809. It’s a standard part of shell syntax that you can use ‘~’ at the
  4810. beginning of a file name to stand for your own home directory. You can
  4811. use ‘~USER’ to stand for USER’s home directory.
  4812. “Tilde expansion” is the process of converting these abbreviations to
  4813. the directory names that they stand for.
  4814. Tilde expansion applies to the ‘~’ plus all following characters up
  4815. to whitespace or a slash. It takes place only at the beginning of a
  4816. word, and only if none of the characters to be transformed is quoted in
  4817. any way.
  4818. Plain ‘~’ uses the value of the environment variable ‘HOME’ as the
  4819. proper home directory name. ‘~’ followed by a user name uses
  4820. ‘getpwname’ to look up that user in the user database, and uses whatever
  4821. directory is recorded there. Thus, ‘~’ followed by your own name can
  4822. give different results from plain ‘~’, if the value of ‘HOME’ is not
  4823. really your home directory.
  4824. 
  4825. File: libc.info, Node: Variable Substitution, Prev: Tilde Expansion, Up: Word Expansion
  4826. 10.4.6 Details of Variable Substitution
  4827. ---------------------------------------
  4828. Part of ordinary shell syntax is the use of ‘$VARIABLE’ to substitute
  4829. the value of a shell variable into a command. This is called “variable
  4830. substitution”, and it is one part of doing word expansion.
  4831. There are two basic ways you can write a variable reference for
  4832. substitution:
  4833. ‘${VARIABLE}’
  4834. If you write braces around the variable name, then it is completely
  4835. unambiguous where the variable name ends. You can concatenate
  4836. additional letters onto the end of the variable value by writing
  4837. them immediately after the close brace. For example, ‘${foo}s’
  4838. expands into ‘tractors’.
  4839. ‘$VARIABLE’
  4840. If you do not put braces around the variable name, then the
  4841. variable name consists of all the alphanumeric characters and
  4842. underscores that follow the ‘$’. The next punctuation character
  4843. ends the variable name. Thus, ‘$foo-bar’ refers to the variable
  4844. ‘foo’ and expands into ‘tractor-bar’.
  4845. When you use braces, you can also use various constructs to modify
  4846. the value that is substituted, or test it in various ways.
  4847. ‘${VARIABLE:-DEFAULT}’
  4848. Substitute the value of VARIABLE, but if that is empty or
  4849. undefined, use DEFAULT instead.
  4850. ‘${VARIABLE:=DEFAULT}’
  4851. Substitute the value of VARIABLE, but if that is empty or
  4852. undefined, use DEFAULT instead and set the variable to DEFAULT.
  4853. ‘${VARIABLE:?MESSAGE}’
  4854. If VARIABLE is defined and not empty, substitute its value.
  4855. Otherwise, print MESSAGE as an error message on the standard error
  4856. stream, and consider word expansion a failure.
  4857. ‘${VARIABLE:+REPLACEMENT}’
  4858. Substitute REPLACEMENT, but only if VARIABLE is defined and
  4859. nonempty. Otherwise, substitute nothing for this construct.
  4860. ‘${#VARIABLE}’
  4861. Substitute a numeral which expresses in base ten the number of
  4862. characters in the value of VARIABLE. ‘${#foo}’ stands for ‘7’,
  4863. because ‘tractor’ is seven characters.
  4864. These variants of variable substitution let you remove part of the
  4865. variable’s value before substituting it. The PREFIX and SUFFIX are not
  4866. mere strings; they are wildcard patterns, just like the patterns that
  4867. you use to match multiple file names. But in this context, they match
  4868. against parts of the variable value rather than against file names.
  4869. ‘${VARIABLE%%SUFFIX}’
  4870. Substitute the value of VARIABLE, but first discard from that
  4871. variable any portion at the end that matches the pattern SUFFIX.
  4872. If there is more than one alternative for how to match against
  4873. SUFFIX, this construct uses the longest possible match.
  4874. Thus, ‘${foo%%r*}’ substitutes ‘t’, because the largest match for
  4875. ‘r*’ at the end of ‘tractor’ is ‘ractor’.
  4876. ‘${VARIABLE%SUFFIX}’
  4877. Substitute the value of VARIABLE, but first discard from that
  4878. variable any portion at the end that matches the pattern SUFFIX.
  4879. If there is more than one alternative for how to match against
  4880. SUFFIX, this construct uses the shortest possible alternative.
  4881. Thus, ‘${foo%r*}’ substitutes ‘tracto’, because the shortest match
  4882. for ‘r*’ at the end of ‘tractor’ is just ‘r’.
  4883. ‘${VARIABLE##PREFIX}’
  4884. Substitute the value of VARIABLE, but first discard from that
  4885. variable any portion at the beginning that matches the pattern
  4886. PREFIX.
  4887. If there is more than one alternative for how to match against
  4888. PREFIX, this construct uses the longest possible match.
  4889. Thus, ‘${foo##*t}’ substitutes ‘or’, because the largest match for
  4890. ‘*t’ at the beginning of ‘tractor’ is ‘tract’.
  4891. ‘${VARIABLE#PREFIX}’
  4892. Substitute the value of VARIABLE, but first discard from that
  4893. variable any portion at the beginning that matches the pattern
  4894. PREFIX.
  4895. If there is more than one alternative for how to match against
  4896. PREFIX, this construct uses the shortest possible alternative.
  4897. Thus, ‘${foo#*t}’ substitutes ‘ractor’, because the shortest match
  4898. for ‘*t’ at the beginning of ‘tractor’ is just ‘t’.
  4899. 
  4900. File: libc.info, Node: I/O Overview, Next: I/O on Streams, Prev: Pattern Matching, Up: Top
  4901. 11 Input/Output Overview
  4902. ************************
  4903. Most programs need to do either input (reading data) or output (writing
  4904. data), or most frequently both, in order to do anything useful. The GNU
  4905. C Library provides such a large selection of input and output functions
  4906. that the hardest part is often deciding which function is most
  4907. appropriate!
  4908. This chapter introduces concepts and terminology relating to input
  4909. and output. Other chapters relating to the GNU I/O facilities are:
  4910. • *note I/O on Streams::, which covers the high-level functions that
  4911. operate on streams, including formatted input and output.
  4912. • *note Low-Level I/O::, which covers the basic I/O and control
  4913. functions on file descriptors.
  4914. • *note File System Interface::, which covers functions for operating
  4915. on directories and for manipulating file attributes such as access
  4916. modes and ownership.
  4917. • *note Pipes and FIFOs::, which includes information on the basic
  4918. interprocess communication facilities.
  4919. • *note Sockets::, which covers a more complicated interprocess
  4920. communication facility with support for networking.
  4921. • *note Low-Level Terminal Interface::, which covers functions for
  4922. changing how input and output to terminals or other serial devices
  4923. are processed.
  4924. * Menu:
  4925. * I/O Concepts:: Some basic information and terminology.
  4926. * File Names:: How to refer to a file.
  4927. 
  4928. File: libc.info, Node: I/O Concepts, Next: File Names, Up: I/O Overview
  4929. 11.1 Input/Output Concepts
  4930. ==========================
  4931. Before you can read or write the contents of a file, you must establish
  4932. a connection or communications channel to the file. This process is
  4933. called “opening” the file. You can open a file for reading, writing, or
  4934. both.
  4935. The connection to an open file is represented either as a stream or
  4936. as a file descriptor. You pass this as an argument to the functions
  4937. that do the actual read or write operations, to tell them which file to
  4938. operate on. Certain functions expect streams, and others are designed
  4939. to operate on file descriptors.
  4940. When you have finished reading to or writing from the file, you can
  4941. terminate the connection by “closing” the file. Once you have closed a
  4942. stream or file descriptor, you cannot do any more input or output
  4943. operations on it.
  4944. * Menu:
  4945. * Streams and File Descriptors:: The GNU C Library provides two ways
  4946. to access the contents of files.
  4947. * File Position:: The number of bytes from the
  4948. beginning of the file.
  4949. 
  4950. File: libc.info, Node: Streams and File Descriptors, Next: File Position, Up: I/O Concepts
  4951. 11.1.1 Streams and File Descriptors
  4952. -----------------------------------
  4953. When you want to do input or output to a file, you have a choice of two
  4954. basic mechanisms for representing the connection between your program
  4955. and the file: file descriptors and streams. File descriptors are
  4956. represented as objects of type ‘int’, while streams are represented as
  4957. ‘FILE *’ objects.
  4958. File descriptors provide a primitive, low-level interface to input
  4959. and output operations. Both file descriptors and streams can represent
  4960. a connection to a device (such as a terminal), or a pipe or socket for
  4961. communicating with another process, as well as a normal file. But, if
  4962. you want to do control operations that are specific to a particular kind
  4963. of device, you must use a file descriptor; there are no facilities to
  4964. use streams in this way. You must also use file descriptors if your
  4965. program needs to do input or output in special modes, such as
  4966. nonblocking (or polled) input (*note File Status Flags::).
  4967. Streams provide a higher-level interface, layered on top of the
  4968. primitive file descriptor facilities. The stream interface treats all
  4969. kinds of files pretty much alike—the sole exception being the three
  4970. styles of buffering that you can choose (*note Stream Buffering::).
  4971. The main advantage of using the stream interface is that the set of
  4972. functions for performing actual input and output operations (as opposed
  4973. to control operations) on streams is much richer and more powerful than
  4974. the corresponding facilities for file descriptors. The file descriptor
  4975. interface provides only simple functions for transferring blocks of
  4976. characters, but the stream interface also provides powerful formatted
  4977. input and output functions (‘printf’ and ‘scanf’) as well as functions
  4978. for character- and line-oriented input and output.
  4979. Since streams are implemented in terms of file descriptors, you can
  4980. extract the file descriptor from a stream and perform low-level
  4981. operations directly on the file descriptor. You can also initially open
  4982. a connection as a file descriptor and then make a stream associated with
  4983. that file descriptor.
  4984. In general, you should stick with using streams rather than file
  4985. descriptors, unless there is some specific operation you want to do that
  4986. can only be done on a file descriptor. If you are a beginning
  4987. programmer and aren’t sure what functions to use, we suggest that you
  4988. concentrate on the formatted input functions (*note Formatted Input::)
  4989. and formatted output functions (*note Formatted Output::).
  4990. If you are concerned about portability of your programs to systems
  4991. other than GNU, you should also be aware that file descriptors are not
  4992. as portable as streams. You can expect any system running ISO C to
  4993. support streams, but non-GNU systems may not support file descriptors at
  4994. all, or may only implement a subset of the GNU functions that operate on
  4995. file descriptors. Most of the file descriptor functions in the GNU C
  4996. Library are included in the POSIX.1 standard, however.
  4997. 
  4998. File: libc.info, Node: File Position, Prev: Streams and File Descriptors, Up: I/O Concepts
  4999. 11.1.2 File Position
  5000. --------------------
  5001. One of the attributes of an open file is its “file position” that keeps
  5002. track of where in the file the next character is to be read or written.
  5003. On GNU systems, and all POSIX.1 systems, the file position is simply an
  5004. integer representing the number of bytes from the beginning of the file.
  5005. The file position is normally set to the beginning of the file when
  5006. it is opened, and each time a character is read or written, the file
  5007. position is incremented. In other words, access to the file is normally
  5008. “sequential”.
  5009. Ordinary files permit read or write operations at any position within
  5010. the file. Some other kinds of files may also permit this. Files which
  5011. do permit this are sometimes referred to as “random-access” files. You
  5012. can change the file position using the ‘fseek’ function on a stream
  5013. (*note File Positioning::) or the ‘lseek’ function on a file descriptor
  5014. (*note I/O Primitives::). If you try to change the file position on a
  5015. file that doesn’t support random access, you get the ‘ESPIPE’ error.
  5016. Streams and descriptors that are opened for “append access” are
  5017. treated specially for output: output to such files is _always_ appended
  5018. sequentially to the _end_ of the file, regardless of the file position.
  5019. However, the file position is still used to control where in the file
  5020. reading is done.
  5021. If you think about it, you’ll realize that several programs can read
  5022. a given file at the same time. In order for each program to be able to
  5023. read the file at its own pace, each program must have its own file
  5024. pointer, which is not affected by anything the other programs do.
  5025. In fact, each opening of a file creates a separate file position.
  5026. Thus, if you open a file twice even in the same program, you get two
  5027. streams or descriptors with independent file positions.
  5028. By contrast, if you open a descriptor and then duplicate it to get
  5029. another descriptor, these two descriptors share the same file position:
  5030. changing the file position of one descriptor will affect the other.
  5031. 
  5032. File: libc.info, Node: File Names, Prev: I/O Concepts, Up: I/O Overview
  5033. 11.2 File Names
  5034. ===============
  5035. In order to open a connection to a file, or to perform other operations
  5036. such as deleting a file, you need some way to refer to the file. Nearly
  5037. all files have names that are strings—even files which are actually
  5038. devices such as tape drives or terminals. These strings are called
  5039. “file names”. You specify the file name to say which file you want to
  5040. open or operate on.
  5041. This section describes the conventions for file names and how the
  5042. operating system works with them.
  5043. * Menu:
  5044. * Directories:: Directories contain entries for files.
  5045. * File Name Resolution:: A file name specifies how to look up a file.
  5046. * File Name Errors:: Error conditions relating to file names.
  5047. * File Name Portability:: File name portability and syntax issues.
  5048. 
  5049. File: libc.info, Node: Directories, Next: File Name Resolution, Up: File Names
  5050. 11.2.1 Directories
  5051. ------------------
  5052. In order to understand the syntax of file names, you need to understand
  5053. how the file system is organized into a hierarchy of directories.
  5054. A “directory” is a file that contains information to associate other
  5055. files with names; these associations are called “links” or “directory
  5056. entries”. Sometimes, people speak of “files in a directory”, but in
  5057. reality, a directory only contains pointers to files, not the files
  5058. themselves.
  5059. The name of a file contained in a directory entry is called a “file
  5060. name component”. In general, a file name consists of a sequence of one
  5061. or more such components, separated by the slash character (‘/’). A file
  5062. name which is just one component names a file with respect to its
  5063. directory. A file name with multiple components names a directory, and
  5064. then a file in that directory, and so on.
  5065. Some other documents, such as the POSIX standard, use the term
  5066. “pathname” for what we call a file name, and either “filename” or
  5067. “pathname component” for what this manual calls a file name component.
  5068. We don’t use this terminology because a “path” is something completely
  5069. different (a list of directories to search), and we think that
  5070. “pathname” used for something else will confuse users. We always use
  5071. “file name” and “file name component” (or sometimes just “component”,
  5072. where the context is obvious) in GNU documentation. Some macros use the
  5073. POSIX terminology in their names, such as ‘PATH_MAX’. These macros are
  5074. defined by the POSIX standard, so we cannot change their names.
  5075. You can find more detailed information about operations on
  5076. directories in *note File System Interface::.
  5077. 
  5078. File: libc.info, Node: File Name Resolution, Next: File Name Errors, Prev: Directories, Up: File Names
  5079. 11.2.2 File Name Resolution
  5080. ---------------------------
  5081. A file name consists of file name components separated by slash (‘/’)
  5082. characters. On the systems that the GNU C Library supports, multiple
  5083. successive ‘/’ characters are equivalent to a single ‘/’ character.
  5084. The process of determining what file a file name refers to is called
  5085. “file name resolution”. This is performed by examining the components
  5086. that make up a file name in left-to-right order, and locating each
  5087. successive component in the directory named by the previous component.
  5088. Of course, each of the files that are referenced as directories must
  5089. actually exist, be directories instead of regular files, and have the
  5090. appropriate permissions to be accessible by the process; otherwise the
  5091. file name resolution fails.
  5092. If a file name begins with a ‘/’, the first component in the file
  5093. name is located in the “root directory” of the process (usually all
  5094. processes on the system have the same root directory). Such a file name
  5095. is called an “absolute file name”.
  5096. Otherwise, the first component in the file name is located in the
  5097. current working directory (*note Working Directory::). This kind of
  5098. file name is called a “relative file name”.
  5099. The file name components ‘.’ (“dot”) and ‘..’ (“dot-dot”) have
  5100. special meanings. Every directory has entries for these file name
  5101. components. The file name component ‘.’ refers to the directory itself,
  5102. while the file name component ‘..’ refers to its “parent directory” (the
  5103. directory that contains the link for the directory in question). As a
  5104. special case, ‘..’ in the root directory refers to the root directory
  5105. itself, since it has no parent; thus ‘/..’ is the same as ‘/’.
  5106. Here are some examples of file names:
  5107. ‘/a’
  5108. The file named ‘a’, in the root directory.
  5109. ‘/a/b’
  5110. The file named ‘b’, in the directory named ‘a’ in the root
  5111. directory.
  5112. ‘a’
  5113. The file named ‘a’, in the current working directory.
  5114. ‘/a/./b’
  5115. This is the same as ‘/a/b’.
  5116. ‘./a’
  5117. The file named ‘a’, in the current working directory.
  5118. ‘../a’
  5119. The file named ‘a’, in the parent directory of the current working
  5120. directory.
  5121. A file name that names a directory may optionally end in a ‘/’. You
  5122. can specify a file name of ‘/’ to refer to the root directory, but the
  5123. empty string is not a meaningful file name. If you want to refer to the
  5124. current working directory, use a file name of ‘.’ or ‘./’.
  5125. Unlike some other operating systems, GNU systems don’t have any
  5126. built-in support for file types (or extensions) or file versions as part
  5127. of its file name syntax. Many programs and utilities use conventions
  5128. for file names—for example, files containing C source code usually have
  5129. names suffixed with ‘.c’—but there is nothing in the file system itself
  5130. that enforces this kind of convention.
  5131. 
  5132. File: libc.info, Node: File Name Errors, Next: File Name Portability, Prev: File Name Resolution, Up: File Names
  5133. 11.2.3 File Name Errors
  5134. -----------------------
  5135. Functions that accept file name arguments usually detect these ‘errno’
  5136. error conditions relating to the file name syntax or trouble finding the
  5137. named file. These errors are referred to throughout this manual as the
  5138. “usual file name errors”.
  5139. ‘EACCES’
  5140. The process does not have search permission for a directory
  5141. component of the file name.
  5142. ‘ENAMETOOLONG’
  5143. This error is used when either the total length of a file name is
  5144. greater than ‘PATH_MAX’, or when an individual file name component
  5145. has a length greater than ‘NAME_MAX’. *Note Limits for Files::.
  5146. On GNU/Hurd systems, there is no imposed limit on overall file name
  5147. length, but some file systems may place limits on the length of a
  5148. component.
  5149. ‘ENOENT’
  5150. This error is reported when a file referenced as a directory
  5151. component in the file name doesn’t exist, or when a component is a
  5152. symbolic link whose target file does not exist. *Note Symbolic
  5153. Links::.
  5154. ‘ENOTDIR’
  5155. A file that is referenced as a directory component in the file name
  5156. exists, but it isn’t a directory.
  5157. ‘ELOOP’
  5158. Too many symbolic links were resolved while trying to look up the
  5159. file name. The system has an arbitrary limit on the number of
  5160. symbolic links that may be resolved in looking up a single file
  5161. name, as a primitive way to detect loops. *Note Symbolic Links::.
  5162. 
  5163. File: libc.info, Node: File Name Portability, Prev: File Name Errors, Up: File Names
  5164. 11.2.4 Portability of File Names
  5165. --------------------------------
  5166. The rules for the syntax of file names discussed in *note File Names::,
  5167. are the rules normally used by GNU systems and by other POSIX systems.
  5168. However, other operating systems may use other conventions.
  5169. There are two reasons why it can be important for you to be aware of
  5170. file name portability issues:
  5171. • If your program makes assumptions about file name syntax, or
  5172. contains embedded literal file name strings, it is more difficult
  5173. to get it to run under other operating systems that use different
  5174. syntax conventions.
  5175. • Even if you are not concerned about running your program on
  5176. machines that run other operating systems, it may still be possible
  5177. to access files that use different naming conventions. For
  5178. example, you may be able to access file systems on another computer
  5179. running a different operating system over a network, or read and
  5180. write disks in formats used by other operating systems.
  5181. The ISO C standard says very little about file name syntax, only that
  5182. file names are strings. In addition to varying restrictions on the
  5183. length of file names and what characters can validly appear in a file
  5184. name, different operating systems use different conventions and syntax
  5185. for concepts such as structured directories and file types or
  5186. extensions. Some concepts such as file versions might be supported in
  5187. some operating systems and not by others.
  5188. The POSIX.1 standard allows implementations to put additional
  5189. restrictions on file name syntax, concerning what characters are
  5190. permitted in file names and on the length of file name and file name
  5191. component strings. However, on GNU systems, any character except the
  5192. null character is permitted in a file name string, and on GNU/Hurd
  5193. systems there are no limits on the length of file name strings.
  5194. 
  5195. File: libc.info, Node: I/O on Streams, Next: Low-Level I/O, Prev: I/O Overview, Up: Top
  5196. 12 Input/Output on Streams
  5197. **************************
  5198. This chapter describes the functions for creating streams and performing
  5199. input and output operations on them. As discussed in *note I/O
  5200. Overview::, a stream is a fairly abstract, high-level concept
  5201. representing a communications channel to a file, device, or process.
  5202. * Menu:
  5203. * Streams:: About the data type representing a stream.
  5204. * Standard Streams:: Streams to the standard input and output
  5205. devices are created for you.
  5206. * Opening Streams:: How to create a stream to talk to a file.
  5207. * Closing Streams:: Close a stream when you are finished with it.
  5208. * Streams and Threads:: Issues with streams in threaded programs.
  5209. * Streams and I18N:: Streams in internationalized applications.
  5210. * Simple Output:: Unformatted output by characters and lines.
  5211. * Character Input:: Unformatted input by characters and words.
  5212. * Line Input:: Reading a line or a record from a stream.
  5213. * Unreading:: Peeking ahead/pushing back input just read.
  5214. * Block Input/Output:: Input and output operations on blocks of data.
  5215. * Formatted Output:: ‘printf’ and related functions.
  5216. * Customizing Printf:: You can define new conversion specifiers for
  5217. ‘printf’ and friends.
  5218. * Formatted Input:: ‘scanf’ and related functions.
  5219. * EOF and Errors:: How you can tell if an I/O error happens.
  5220. * Error Recovery:: What you can do about errors.
  5221. * Binary Streams:: Some systems distinguish between text files
  5222. and binary files.
  5223. * File Positioning:: About random-access streams.
  5224. * Portable Positioning:: Random access on peculiar ISO C systems.
  5225. * Stream Buffering:: How to control buffering of streams.
  5226. * Other Kinds of Streams:: Streams that do not necessarily correspond
  5227. to an open file.
  5228. * Formatted Messages:: Print strictly formatted messages.
  5229. 
  5230. File: libc.info, Node: Streams, Next: Standard Streams, Up: I/O on Streams
  5231. 12.1 Streams
  5232. ============
  5233. For historical reasons, the type of the C data structure that represents
  5234. a stream is called ‘FILE’ rather than “stream”. Since most of the
  5235. library functions deal with objects of type ‘FILE *’, sometimes the term
  5236. “file pointer” is also used to mean “stream”. This leads to unfortunate
  5237. confusion over terminology in many books on C. This manual, however, is
  5238. careful to use the terms “file” and “stream” only in the technical
  5239. sense.
  5240. The ‘FILE’ type is declared in the header file ‘stdio.h’.
  5241. -- Data Type: FILE
  5242. This is the data type used to represent stream objects. A ‘FILE’
  5243. object holds all of the internal state information about the
  5244. connection to the associated file, including such things as the
  5245. file position indicator and buffering information. Each stream
  5246. also has error and end-of-file status indicators that can be tested
  5247. with the ‘ferror’ and ‘feof’ functions; see *note EOF and Errors::.
  5248. ‘FILE’ objects are allocated and managed internally by the
  5249. input/output library functions. Don’t try to create your own objects of
  5250. type ‘FILE’; let the library do it. Your programs should deal only with
  5251. pointers to these objects (that is, ‘FILE *’ values) rather than the
  5252. objects themselves.
  5253. 
  5254. File: libc.info, Node: Standard Streams, Next: Opening Streams, Prev: Streams, Up: I/O on Streams
  5255. 12.2 Standard Streams
  5256. =====================
  5257. When the ‘main’ function of your program is invoked, it already has
  5258. three predefined streams open and available for use. These represent
  5259. the “standard” input and output channels that have been established for
  5260. the process.
  5261. These streams are declared in the header file ‘stdio.h’.
  5262. -- Variable: FILE * stdin
  5263. The “standard input” stream, which is the normal source of input
  5264. for the program.
  5265. -- Variable: FILE * stdout
  5266. The “standard output” stream, which is used for normal output from
  5267. the program.
  5268. -- Variable: FILE * stderr
  5269. The “standard error” stream, which is used for error messages and
  5270. diagnostics issued by the program.
  5271. On GNU systems, you can specify what files or processes correspond to
  5272. these streams using the pipe and redirection facilities provided by the
  5273. shell. (The primitives shells use to implement these facilities are
  5274. described in *note File System Interface::.) Most other operating
  5275. systems provide similar mechanisms, but the details of how to use them
  5276. can vary.
  5277. In the GNU C Library, ‘stdin’, ‘stdout’, and ‘stderr’ are normal
  5278. variables which you can set just like any others. For example, to
  5279. redirect the standard output to a file, you could do:
  5280. fclose (stdout);
  5281. stdout = fopen ("standard-output-file", "w");
  5282. Note however, that in other systems ‘stdin’, ‘stdout’, and ‘stderr’
  5283. are macros that you cannot assign to in the normal way. But you can use
  5284. ‘freopen’ to get the effect of closing one and reopening it. *Note
  5285. Opening Streams::.
  5286. The three streams ‘stdin’, ‘stdout’, and ‘stderr’ are not unoriented
  5287. at program start (*note Streams and I18N::).
  5288. 
  5289. File: libc.info, Node: Opening Streams, Next: Closing Streams, Prev: Standard Streams, Up: I/O on Streams
  5290. 12.3 Opening Streams
  5291. ====================
  5292. Opening a file with the ‘fopen’ function creates a new stream and
  5293. establishes a connection between the stream and a file. This may
  5294. involve creating a new file.
  5295. Everything described in this section is declared in the header file
  5296. ‘stdio.h’.
  5297. -- Function: FILE * fopen (const char *FILENAME, const char *OPENTYPE)
  5298. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe mem fd
  5299. lock | *Note POSIX Safety Concepts::.
  5300. The ‘fopen’ function opens a stream for I/O to the file FILENAME,
  5301. and returns a pointer to the stream.
  5302. The OPENTYPE argument is a string that controls how the file is
  5303. opened and specifies attributes of the resulting stream. It must
  5304. begin with one of the following sequences of characters:
  5305. ‘r’
  5306. Open an existing file for reading only.
  5307. ‘w’
  5308. Open the file for writing only. If the file already exists,
  5309. it is truncated to zero length. Otherwise a new file is
  5310. created.
  5311. ‘a’
  5312. Open a file for append access; that is, writing at the end of
  5313. file only. If the file already exists, its initial contents
  5314. are unchanged and output to the stream is appended to the end
  5315. of the file. Otherwise, a new, empty file is created.
  5316. ‘r+’
  5317. Open an existing file for both reading and writing. The
  5318. initial contents of the file are unchanged and the initial
  5319. file position is at the beginning of the file.
  5320. ‘w+’
  5321. Open a file for both reading and writing. If the file already
  5322. exists, it is truncated to zero length. Otherwise, a new file
  5323. is created.
  5324. ‘a+’
  5325. Open or create file for both reading and appending. If the
  5326. file exists, its initial contents are unchanged. Otherwise, a
  5327. new file is created. The initial file position for reading is
  5328. at the beginning of the file, but output is always appended to
  5329. the end of the file.
  5330. As you can see, ‘+’ requests a stream that can do both input and
  5331. output. When using such a stream, you must call ‘fflush’ (*note
  5332. Stream Buffering::) or a file positioning function such as ‘fseek’
  5333. (*note File Positioning::) when switching from reading to writing
  5334. or vice versa. Otherwise, internal buffers might not be emptied
  5335. properly.
  5336. Additional characters may appear after these to specify flags for
  5337. the call. Always put the mode (‘r’, ‘w+’, etc.) first; that is
  5338. the only part you are guaranteed will be understood by all systems.
  5339. The GNU C Library defines additional characters for use in
  5340. OPENTYPE:
  5341. ‘c’
  5342. The file is opened with cancellation in the I/O functions
  5343. disabled.
  5344. ‘e’
  5345. The underlying file descriptor will be closed if you use any
  5346. of the ‘exec...’ functions (*note Executing a File::). (This
  5347. is equivalent to having set ‘FD_CLOEXEC’ on that descriptor.
  5348. *Note Descriptor Flags::.)
  5349. ‘m’
  5350. The file is opened and accessed using ‘mmap’. This is only
  5351. supported with files opened for reading.
  5352. ‘x’
  5353. Insist on creating a new file—if a file FILENAME already
  5354. exists, ‘fopen’ fails rather than opening it. If you use ‘x’
  5355. you are guaranteed that you will not clobber an existing file.
  5356. This is equivalent to the ‘O_EXCL’ option to the ‘open’
  5357. function (*note Opening and Closing Files::).
  5358. The ‘x’ modifier is part of ISO C11, which says the file is
  5359. created with exclusive access; in the GNU C Library this means
  5360. the equivalent of ‘O_EXCL’.
  5361. The character ‘b’ in OPENTYPE has a standard meaning; it requests a
  5362. binary stream rather than a text stream. But this makes no
  5363. difference in POSIX systems (including GNU systems). If both ‘+’
  5364. and ‘b’ are specified, they can appear in either order. *Note
  5365. Binary Streams::.
  5366. If the OPENTYPE string contains the sequence ‘,ccs=STRING’ then
  5367. STRING is taken as the name of a coded character set and ‘fopen’
  5368. will mark the stream as wide-oriented with appropriate conversion
  5369. functions in place to convert from and to the character set STRING.
  5370. Any other stream is opened initially unoriented and the orientation
  5371. is decided with the first file operation. If the first operation
  5372. is a wide character operation, the stream is not only marked as
  5373. wide-oriented, also the conversion functions to convert to the
  5374. coded character set used for the current locale are loaded. This
  5375. will not change anymore from this point on even if the locale
  5376. selected for the ‘LC_CTYPE’ category is changed.
  5377. Any other characters in OPENTYPE are simply ignored. They may be
  5378. meaningful in other systems.
  5379. If the open fails, ‘fopen’ returns a null pointer.
  5380. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  5381. 32 bit machine this function is in fact ‘fopen64’ since the LFS
  5382. interface replaces transparently the old interface.
  5383. You can have multiple streams (or file descriptors) pointing to the
  5384. same file open at the same time. If you do only input, this works
  5385. straightforwardly, but you must be careful if any output streams are
  5386. included. *Note Stream/Descriptor Precautions::. This is equally true
  5387. whether the streams are in one program (not usual) or in several
  5388. programs (which can easily happen). It may be advantageous to use the
  5389. file locking facilities to avoid simultaneous access. *Note File
  5390. Locks::.
  5391. -- Function: FILE * fopen64 (const char *FILENAME, const char
  5392. *OPENTYPE)
  5393. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe mem fd
  5394. lock | *Note POSIX Safety Concepts::.
  5395. This function is similar to ‘fopen’ but the stream it returns a
  5396. pointer for is opened using ‘open64’. Therefore this stream can be
  5397. used even on files larger than 2^31 bytes on 32 bit machines.
  5398. Please note that the return type is still ‘FILE *’. There is no
  5399. special ‘FILE’ type for the LFS interface.
  5400. If the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a 32
  5401. bits machine this function is available under the name ‘fopen’ and
  5402. so transparently replaces the old interface.
  5403. -- Macro: int FOPEN_MAX
  5404. The value of this macro is an integer constant expression that
  5405. represents the minimum number of streams that the implementation
  5406. guarantees can be open simultaneously. You might be able to open
  5407. more than this many streams, but that is not guaranteed. The value
  5408. of this constant is at least eight, which includes the three
  5409. standard streams ‘stdin’, ‘stdout’, and ‘stderr’. In POSIX.1
  5410. systems this value is determined by the ‘OPEN_MAX’ parameter; *note
  5411. General Limits::. In BSD and GNU, it is controlled by the
  5412. ‘RLIMIT_NOFILE’ resource limit; *note Limits on Resources::.
  5413. -- Function: FILE * freopen (const char *FILENAME, const char
  5414. *OPENTYPE, FILE *STREAM)
  5415. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt fd |
  5416. *Note POSIX Safety Concepts::.
  5417. This function is like a combination of ‘fclose’ and ‘fopen’. It
  5418. first closes the stream referred to by STREAM, ignoring any errors
  5419. that are detected in the process. (Because errors are ignored, you
  5420. should not use ‘freopen’ on an output stream if you have actually
  5421. done any output using the stream.) Then the file named by FILENAME
  5422. is opened with mode OPENTYPE as for ‘fopen’, and associated with
  5423. the same stream object STREAM.
  5424. If the operation fails, a null pointer is returned; otherwise,
  5425. ‘freopen’ returns STREAM. On Linux, ‘freopen’ may also fail and
  5426. set ‘errno’ to ‘EBUSY’ when the kernel structure for the old file
  5427. descriptor was not initialized completely before ‘freopen’ was
  5428. called. This can only happen in multi-threaded programs, when two
  5429. threads race to allocate the same file descriptor number. To avoid
  5430. the possibility of this race, do not use ‘close’ to close the
  5431. underlying file descriptor for a ‘FILE’; either use ‘freopen’ while
  5432. the file is still open, or use ‘open’ and then ‘dup2’ to install
  5433. the new file descriptor.
  5434. ‘freopen’ has traditionally been used to connect a standard stream
  5435. such as ‘stdin’ with a file of your own choice. This is useful in
  5436. programs in which use of a standard stream for certain purposes is
  5437. hard-coded. In the GNU C Library, you can simply close the
  5438. standard streams and open new ones with ‘fopen’. But other systems
  5439. lack this ability, so using ‘freopen’ is more portable.
  5440. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  5441. 32 bit machine this function is in fact ‘freopen64’ since the LFS
  5442. interface replaces transparently the old interface.
  5443. -- Function: FILE * freopen64 (const char *FILENAME, const char
  5444. *OPENTYPE, FILE *STREAM)
  5445. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt fd |
  5446. *Note POSIX Safety Concepts::.
  5447. This function is similar to ‘freopen’. The only difference is that
  5448. on 32 bit machine the stream returned is able to read beyond the
  5449. 2^31 bytes limits imposed by the normal interface. It should be
  5450. noted that the stream pointed to by STREAM need not be opened using
  5451. ‘fopen64’ or ‘freopen64’ since its mode is not important for this
  5452. function.
  5453. If the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a 32
  5454. bits machine this function is available under the name ‘freopen’
  5455. and so transparently replaces the old interface.
  5456. In some situations it is useful to know whether a given stream is
  5457. available for reading or writing. This information is normally not
  5458. available and would have to be remembered separately. Solaris
  5459. introduced a few functions to get this information from the stream
  5460. descriptor and these functions are also available in the GNU C Library.
  5461. -- Function: int __freadable (FILE *STREAM)
  5462. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5463. Concepts::.
  5464. The ‘__freadable’ function determines whether the stream STREAM was
  5465. opened to allow reading. In this case the return value is nonzero.
  5466. For write-only streams the function returns zero.
  5467. This function is declared in ‘stdio_ext.h’.
  5468. -- Function: int __fwritable (FILE *STREAM)
  5469. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5470. Concepts::.
  5471. The ‘__fwritable’ function determines whether the stream STREAM was
  5472. opened to allow writing. In this case the return value is nonzero.
  5473. For read-only streams the function returns zero.
  5474. This function is declared in ‘stdio_ext.h’.
  5475. For slightly different kinds of problems there are two more
  5476. functions. They provide even finer-grained information.
  5477. -- Function: int __freading (FILE *STREAM)
  5478. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5479. Concepts::.
  5480. The ‘__freading’ function determines whether the stream STREAM was
  5481. last read from or whether it is opened read-only. In this case the
  5482. return value is nonzero, otherwise it is zero. Determining whether
  5483. a stream opened for reading and writing was last used for writing
  5484. allows to draw conclusions about the content about the buffer,
  5485. among other things.
  5486. This function is declared in ‘stdio_ext.h’.
  5487. -- Function: int __fwriting (FILE *STREAM)
  5488. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5489. Concepts::.
  5490. The ‘__fwriting’ function determines whether the stream STREAM was
  5491. last written to or whether it is opened write-only. In this case
  5492. the return value is nonzero, otherwise it is zero.
  5493. This function is declared in ‘stdio_ext.h’.
  5494. 
  5495. File: libc.info, Node: Closing Streams, Next: Streams and Threads, Prev: Opening Streams, Up: I/O on Streams
  5496. 12.4 Closing Streams
  5497. ====================
  5498. When a stream is closed with ‘fclose’, the connection between the stream
  5499. and the file is canceled. After you have closed a stream, you cannot
  5500. perform any additional operations on it.
  5501. -- Function: int fclose (FILE *STREAM)
  5502. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe lock mem
  5503. fd | *Note POSIX Safety Concepts::.
  5504. This function causes STREAM to be closed and the connection to the
  5505. corresponding file to be broken. Any buffered output is written
  5506. and any buffered input is discarded. The ‘fclose’ function returns
  5507. a value of ‘0’ if the file was closed successfully, and ‘EOF’ if an
  5508. error was detected.
  5509. It is important to check for errors when you call ‘fclose’ to close
  5510. an output stream, because real, everyday errors can be detected at
  5511. this time. For example, when ‘fclose’ writes the remaining
  5512. buffered output, it might get an error because the disk is full.
  5513. Even if you know the buffer is empty, errors can still occur when
  5514. closing a file if you are using NFS.
  5515. The function ‘fclose’ is declared in ‘stdio.h’.
  5516. To close all streams currently available the GNU C Library provides
  5517. another function.
  5518. -- Function: int fcloseall (void)
  5519. Preliminary: | MT-Unsafe race:streams | AS-Unsafe | AC-Safe | *Note
  5520. POSIX Safety Concepts::.
  5521. This function causes all open streams of the process to be closed
  5522. and the connections to corresponding files to be broken. All
  5523. buffered data is written and any buffered input is discarded. The
  5524. ‘fcloseall’ function returns a value of ‘0’ if all the files were
  5525. closed successfully, and ‘EOF’ if an error was detected.
  5526. This function should be used only in special situations, e.g., when
  5527. an error occurred and the program must be aborted. Normally each
  5528. single stream should be closed separately so that problems with
  5529. individual streams can be identified. It is also problematic since
  5530. the standard streams (*note Standard Streams::) will also be
  5531. closed.
  5532. The function ‘fcloseall’ is declared in ‘stdio.h’.
  5533. If the ‘main’ function to your program returns, or if you call the
  5534. ‘exit’ function (*note Normal Termination::), all open streams are
  5535. automatically closed properly. If your program terminates in any other
  5536. manner, such as by calling the ‘abort’ function (*note Aborting a
  5537. Program::) or from a fatal signal (*note Signal Handling::), open
  5538. streams might not be closed properly. Buffered output might not be
  5539. flushed and files may be incomplete. For more information on buffering
  5540. of streams, see *note Stream Buffering::.
  5541. 
  5542. File: libc.info, Node: Streams and Threads, Next: Streams and I18N, Prev: Closing Streams, Up: I/O on Streams
  5543. 12.5 Streams and Threads
  5544. ========================
  5545. Streams can be used in multi-threaded applications in the same way they
  5546. are used in single-threaded applications. But the programmer must be
  5547. aware of the possible complications. It is important to know about
  5548. these also if the program one writes never use threads since the design
  5549. and implementation of many stream functions are heavily influenced by
  5550. the requirements added by multi-threaded programming.
  5551. The POSIX standard requires that by default the stream operations are
  5552. atomic. I.e., issuing two stream operations for the same stream in two
  5553. threads at the same time will cause the operations to be executed as if
  5554. they were issued sequentially. The buffer operations performed while
  5555. reading or writing are protected from other uses of the same stream. To
  5556. do this each stream has an internal lock object which has to be
  5557. (implicitly) acquired before any work can be done.
  5558. But there are situations where this is not enough and there are also
  5559. situations where this is not wanted. The implicit locking is not enough
  5560. if the program requires more than one stream function call to happen
  5561. atomically. One example would be if an output line a program wants to
  5562. generate is created by several function calls. The functions by
  5563. themselves would ensure only atomicity of their own operation, but not
  5564. atomicity over all the function calls. For this it is necessary to
  5565. perform the stream locking in the application code.
  5566. -- Function: void flockfile (FILE *STREAM)
  5567. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe lock | *Note POSIX
  5568. Safety Concepts::.
  5569. The ‘flockfile’ function acquires the internal locking object
  5570. associated with the stream STREAM. This ensures that no other
  5571. thread can explicitly through ‘flockfile’/‘ftrylockfile’ or
  5572. implicitly through the call of a stream function lock the stream.
  5573. The thread will block until the lock is acquired. An explicit call
  5574. to ‘funlockfile’ has to be used to release the lock.
  5575. -- Function: int ftrylockfile (FILE *STREAM)
  5576. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe lock | *Note POSIX
  5577. Safety Concepts::.
  5578. The ‘ftrylockfile’ function tries to acquire the internal locking
  5579. object associated with the stream STREAM just like ‘flockfile’.
  5580. But unlike ‘flockfile’ this function does not block if the lock is
  5581. not available. ‘ftrylockfile’ returns zero if the lock was
  5582. successfully acquired. Otherwise the stream is locked by another
  5583. thread.
  5584. -- Function: void funlockfile (FILE *STREAM)
  5585. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe lock | *Note POSIX
  5586. Safety Concepts::.
  5587. The ‘funlockfile’ function releases the internal locking object of
  5588. the stream STREAM. The stream must have been locked before by a
  5589. call to ‘flockfile’ or a successful call of ‘ftrylockfile’. The
  5590. implicit locking performed by the stream operations do not count.
  5591. The ‘funlockfile’ function does not return an error status and the
  5592. behavior of a call for a stream which is not locked by the current
  5593. thread is undefined.
  5594. The following example shows how the functions above can be used to
  5595. generate an output line atomically even in multi-threaded applications
  5596. (yes, the same job could be done with one ‘fprintf’ call but it is
  5597. sometimes not possible):
  5598. FILE *fp;
  5599. {
  5600. ...
  5601. flockfile (fp);
  5602. fputs ("This is test number ", fp);
  5603. fprintf (fp, "%d\n", test);
  5604. funlockfile (fp)
  5605. }
  5606. Without the explicit locking it would be possible for another thread
  5607. to use the stream FP after the ‘fputs’ call returns and before ‘fprintf’
  5608. was called with the result that the number does not follow the word
  5609. ‘number’.
  5610. From this description it might already be clear that the locking
  5611. objects in streams are no simple mutexes. Since locking the same stream
  5612. twice in the same thread is allowed the locking objects must be
  5613. equivalent to recursive mutexes. These mutexes keep track of the owner
  5614. and the number of times the lock is acquired. The same number of
  5615. ‘funlockfile’ calls by the same threads is necessary to unlock the
  5616. stream completely. For instance:
  5617. void
  5618. foo (FILE *fp)
  5619. {
  5620. ftrylockfile (fp);
  5621. fputs ("in foo\n", fp);
  5622. /* This is very wrong!!! */
  5623. funlockfile (fp);
  5624. }
  5625. It is important here that the ‘funlockfile’ function is only called
  5626. if the ‘ftrylockfile’ function succeeded in locking the stream. It is
  5627. therefore always wrong to ignore the result of ‘ftrylockfile’. And it
  5628. makes no sense since otherwise one would use ‘flockfile’. The result of
  5629. code like that above is that either ‘funlockfile’ tries to free a stream
  5630. that hasn’t been locked by the current thread or it frees the stream
  5631. prematurely. The code should look like this:
  5632. void
  5633. foo (FILE *fp)
  5634. {
  5635. if (ftrylockfile (fp) == 0)
  5636. {
  5637. fputs ("in foo\n", fp);
  5638. funlockfile (fp);
  5639. }
  5640. }
  5641. Now that we covered why it is necessary to have locking it is
  5642. necessary to talk about situations when locking is unwanted and what can
  5643. be done. The locking operations (explicit or implicit) don’t come for
  5644. free. Even if a lock is not taken the cost is not zero. The operations
  5645. which have to be performed require memory operations that are safe in
  5646. multi-processor environments. With the many local caches involved in
  5647. such systems this is quite costly. So it is best to avoid the locking
  5648. completely if it is not needed – because the code in question is never
  5649. used in a context where two or more threads may use a stream at a time.
  5650. This can be determined most of the time for application code; for
  5651. library code which can be used in many contexts one should default to be
  5652. conservative and use locking.
  5653. There are two basic mechanisms to avoid locking. The first is to use
  5654. the ‘_unlocked’ variants of the stream operations. The POSIX standard
  5655. defines quite a few of those and the GNU C Library adds a few more.
  5656. These variants of the functions behave just like the functions with the
  5657. name without the suffix except that they do not lock the stream. Using
  5658. these functions is very desirable since they are potentially much
  5659. faster. This is not only because the locking operation itself is
  5660. avoided. More importantly, functions like ‘putc’ and ‘getc’ are very
  5661. simple and traditionally (before the introduction of threads) were
  5662. implemented as macros which are very fast if the buffer is not empty.
  5663. With the addition of locking requirements these functions are no longer
  5664. implemented as macros since they would expand to too much code. But
  5665. these macros are still available with the same functionality under the
  5666. new names ‘putc_unlocked’ and ‘getc_unlocked’. This possibly huge
  5667. difference of speed also suggests the use of the ‘_unlocked’ functions
  5668. even if locking is required. The difference is that the locking then
  5669. has to be performed in the program:
  5670. void
  5671. foo (FILE *fp, char *buf)
  5672. {
  5673. flockfile (fp);
  5674. while (*buf != '/')
  5675. putc_unlocked (*buf++, fp);
  5676. funlockfile (fp);
  5677. }
  5678. If in this example the ‘putc’ function would be used and the explicit
  5679. locking would be missing the ‘putc’ function would have to acquire the
  5680. lock in every call, potentially many times depending on when the loop
  5681. terminates. Writing it the way illustrated above allows the
  5682. ‘putc_unlocked’ macro to be used which means no locking and direct
  5683. manipulation of the buffer of the stream.
  5684. A second way to avoid locking is by using a non-standard function
  5685. which was introduced in Solaris and is available in the GNU C Library as
  5686. well.
  5687. -- Function: int __fsetlocking (FILE *STREAM, int TYPE)
  5688. Preliminary: | MT-Safe race:stream | AS-Unsafe lock | AC-Safe |
  5689. *Note POSIX Safety Concepts::.
  5690. The ‘__fsetlocking’ function can be used to select whether the
  5691. stream operations will implicitly acquire the locking object of the
  5692. stream STREAM. By default this is done but it can be disabled and
  5693. reinstated using this function. There are three values defined for
  5694. the TYPE parameter.
  5695. ‘FSETLOCKING_INTERNAL’
  5696. The stream ‘stream’ will from now on use the default internal
  5697. locking. Every stream operation with exception of the
  5698. ‘_unlocked’ variants will implicitly lock the stream.
  5699. ‘FSETLOCKING_BYCALLER’
  5700. After the ‘__fsetlocking’ function returns, the user is
  5701. responsible for locking the stream. None of the stream
  5702. operations will implicitly do this anymore until the state is
  5703. set back to ‘FSETLOCKING_INTERNAL’.
  5704. ‘FSETLOCKING_QUERY’
  5705. ‘__fsetlocking’ only queries the current locking state of the
  5706. stream. The return value will be ‘FSETLOCKING_INTERNAL’ or
  5707. ‘FSETLOCKING_BYCALLER’ depending on the state.
  5708. The return value of ‘__fsetlocking’ is either
  5709. ‘FSETLOCKING_INTERNAL’ or ‘FSETLOCKING_BYCALLER’ depending on the
  5710. state of the stream before the call.
  5711. This function and the values for the TYPE parameter are declared in
  5712. ‘stdio_ext.h’.
  5713. This function is especially useful when program code has to be used
  5714. which is written without knowledge about the ‘_unlocked’ functions (or
  5715. if the programmer was too lazy to use them).
  5716. 
  5717. File: libc.info, Node: Streams and I18N, Next: Simple Output, Prev: Streams and Threads, Up: I/O on Streams
  5718. 12.6 Streams in Internationalized Applications
  5719. ==============================================
  5720. ISO C90 introduced the new type ‘wchar_t’ to allow handling larger
  5721. character sets. What was missing was a possibility to output strings of
  5722. ‘wchar_t’ directly. One had to convert them into multibyte strings
  5723. using ‘mbstowcs’ (there was no ‘mbsrtowcs’ yet) and then use the normal
  5724. stream functions. While this is doable it is very cumbersome since
  5725. performing the conversions is not trivial and greatly increases program
  5726. complexity and size.
  5727. The Unix standard early on (I think in XPG4.2) introduced two
  5728. additional format specifiers for the ‘printf’ and ‘scanf’ families of
  5729. functions. Printing and reading of single wide characters was made
  5730. possible using the ‘%C’ specifier and wide character strings can be
  5731. handled with ‘%S’. These modifiers behave just like ‘%c’ and ‘%s’ only
  5732. that they expect the corresponding argument to have the wide character
  5733. type and that the wide character and string are transformed into/from
  5734. multibyte strings before being used.
  5735. This was a beginning but it is still not good enough. Not always is
  5736. it desirable to use ‘printf’ and ‘scanf’. The other, smaller and faster
  5737. functions cannot handle wide characters. Second, it is not possible to
  5738. have a format string for ‘printf’ and ‘scanf’ consisting of wide
  5739. characters. The result is that format strings would have to be
  5740. generated if they have to contain non-basic characters.
  5741. In the Amendment 1 to ISO C90 a whole new set of functions was added
  5742. to solve the problem. Most of the stream functions got a counterpart
  5743. which take a wide character or wide character string instead of a
  5744. character or string respectively. The new functions operate on the same
  5745. streams (like ‘stdout’). This is different from the model of the C++
  5746. runtime library where separate streams for wide and normal I/O are used.
  5747. Being able to use the same stream for wide and normal operations
  5748. comes with a restriction: a stream can be used either for wide
  5749. operations or for normal operations. Once it is decided there is no way
  5750. back. Only a call to ‘freopen’ or ‘freopen64’ can reset the
  5751. “orientation”. The orientation can be decided in three ways:
  5752. • If any of the normal character functions are used (this includes
  5753. the ‘fread’ and ‘fwrite’ functions) the stream is marked as not
  5754. wide oriented.
  5755. • If any of the wide character functions are used the stream is
  5756. marked as wide oriented.
  5757. • The ‘fwide’ function can be used to set the orientation either way.
  5758. It is important to never mix the use of wide and not wide operations
  5759. on a stream. There are no diagnostics issued. The application behavior
  5760. will simply be strange or the application will simply crash. The
  5761. ‘fwide’ function can help avoid this.
  5762. -- Function: int fwide (FILE *STREAM, int MODE)
  5763. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock | *Note
  5764. POSIX Safety Concepts::.
  5765. The ‘fwide’ function can be used to set and query the state of the
  5766. orientation of the stream STREAM. If the MODE parameter has a
  5767. positive value the streams get wide oriented, for negative values
  5768. narrow oriented. It is not possible to overwrite previous
  5769. orientations with ‘fwide’. I.e., if the stream STREAM was already
  5770. oriented before the call nothing is done.
  5771. If MODE is zero the current orientation state is queried and
  5772. nothing is changed.
  5773. The ‘fwide’ function returns a negative value, zero, or a positive
  5774. value if the stream is narrow, not at all, or wide oriented
  5775. respectively.
  5776. This function was introduced in Amendment 1 to ISO C90 and is
  5777. declared in ‘wchar.h’.
  5778. It is generally a good idea to orient a stream as early as possible.
  5779. This can prevent surprise especially for the standard streams ‘stdin’,
  5780. ‘stdout’, and ‘stderr’. If some library function in some situations
  5781. uses one of these streams and this use orients the stream in a different
  5782. way the rest of the application expects it one might end up with hard to
  5783. reproduce errors. Remember that no errors are signal if the streams are
  5784. used incorrectly. Leaving a stream unoriented after creation is
  5785. normally only necessary for library functions which create streams which
  5786. can be used in different contexts.
  5787. When writing code which uses streams and which can be used in
  5788. different contexts it is important to query the orientation of the
  5789. stream before using it (unless the rules of the library interface demand
  5790. a specific orientation). The following little, silly function
  5791. illustrates this.
  5792. void
  5793. print_f (FILE *fp)
  5794. {
  5795. if (fwide (fp, 0) > 0)
  5796. /* Positive return value means wide orientation. */
  5797. fputwc (L'f', fp);
  5798. else
  5799. fputc ('f', fp);
  5800. }
  5801. Note that in this case the function ‘print_f’ decides about the
  5802. orientation of the stream if it was unoriented before (will not happen
  5803. if the advice above is followed).
  5804. The encoding used for the ‘wchar_t’ values is unspecified and the
  5805. user must not make any assumptions about it. For I/O of ‘wchar_t’
  5806. values this means that it is impossible to write these values directly
  5807. to the stream. This is not what follows from the ISO C locale model
  5808. either. What happens instead is that the bytes read from or written to
  5809. the underlying media are first converted into the internal encoding
  5810. chosen by the implementation for ‘wchar_t’. The external encoding is
  5811. determined by the ‘LC_CTYPE’ category of the current locale or by the
  5812. ‘ccs’ part of the mode specification given to ‘fopen’, ‘fopen64’,
  5813. ‘freopen’, or ‘freopen64’. How and when the conversion happens is
  5814. unspecified and it happens invisibly to the user.
  5815. Since a stream is created in the unoriented state it has at that
  5816. point no conversion associated with it. The conversion which will be
  5817. used is determined by the ‘LC_CTYPE’ category selected at the time the
  5818. stream is oriented. If the locales are changed at the runtime this
  5819. might produce surprising results unless one pays attention. This is
  5820. just another good reason to orient the stream explicitly as soon as
  5821. possible, perhaps with a call to ‘fwide’.
  5822. 
  5823. File: libc.info, Node: Simple Output, Next: Character Input, Prev: Streams and I18N, Up: I/O on Streams
  5824. 12.7 Simple Output by Characters or Lines
  5825. =========================================
  5826. This section describes functions for performing character- and
  5827. line-oriented output.
  5828. These narrow stream functions are declared in the header file
  5829. ‘stdio.h’ and the wide stream functions in ‘wchar.h’.
  5830. -- Function: int fputc (int C, FILE *STREAM)
  5831. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  5832. | *Note POSIX Safety Concepts::.
  5833. The ‘fputc’ function converts the character C to type ‘unsigned
  5834. char’, and writes it to the stream STREAM. ‘EOF’ is returned if a
  5835. write error occurs; otherwise the character C is returned.
  5836. -- Function: wint_t fputwc (wchar_t WC, FILE *STREAM)
  5837. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  5838. | *Note POSIX Safety Concepts::.
  5839. The ‘fputwc’ function writes the wide character WC to the stream
  5840. STREAM. ‘WEOF’ is returned if a write error occurs; otherwise the
  5841. character WC is returned.
  5842. -- Function: int fputc_unlocked (int C, FILE *STREAM)
  5843. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  5844. corrupt | *Note POSIX Safety Concepts::.
  5845. The ‘fputc_unlocked’ function is equivalent to the ‘fputc’ function
  5846. except that it does not implicitly lock the stream.
  5847. -- Function: wint_t fputwc_unlocked (wchar_t WC, FILE *STREAM)
  5848. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  5849. corrupt | *Note POSIX Safety Concepts::.
  5850. The ‘fputwc_unlocked’ function is equivalent to the ‘fputwc’
  5851. function except that it does not implicitly lock the stream.
  5852. This function is a GNU extension.
  5853. -- Function: int putc (int C, FILE *STREAM)
  5854. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  5855. | *Note POSIX Safety Concepts::.
  5856. This is just like ‘fputc’, except that most systems implement it as
  5857. a macro, making it faster. One consequence is that it may evaluate
  5858. the STREAM argument more than once, which is an exception to the
  5859. general rule for macros. ‘putc’ is usually the best function to
  5860. use for writing a single character.
  5861. -- Function: wint_t putwc (wchar_t WC, FILE *STREAM)
  5862. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  5863. | *Note POSIX Safety Concepts::.
  5864. This is just like ‘fputwc’, except that it can be implement as a
  5865. macro, making it faster. One consequence is that it may evaluate
  5866. the STREAM argument more than once, which is an exception to the
  5867. general rule for macros. ‘putwc’ is usually the best function to
  5868. use for writing a single wide character.
  5869. -- Function: int putc_unlocked (int C, FILE *STREAM)
  5870. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  5871. corrupt | *Note POSIX Safety Concepts::.
  5872. The ‘putc_unlocked’ function is equivalent to the ‘putc’ function
  5873. except that it does not implicitly lock the stream.
  5874. -- Function: wint_t putwc_unlocked (wchar_t WC, FILE *STREAM)
  5875. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  5876. corrupt | *Note POSIX Safety Concepts::.
  5877. The ‘putwc_unlocked’ function is equivalent to the ‘putwc’ function
  5878. except that it does not implicitly lock the stream.
  5879. This function is a GNU extension.
  5880. -- Function: int putchar (int C)
  5881. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  5882. | *Note POSIX Safety Concepts::.
  5883. The ‘putchar’ function is equivalent to ‘putc’ with ‘stdout’ as the
  5884. value of the STREAM argument.
  5885. -- Function: wint_t putwchar (wchar_t WC)
  5886. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  5887. | *Note POSIX Safety Concepts::.
  5888. The ‘putwchar’ function is equivalent to ‘putwc’ with ‘stdout’ as
  5889. the value of the STREAM argument.
  5890. -- Function: int putchar_unlocked (int C)
  5891. Preliminary: | MT-Unsafe race:stdout | AS-Unsafe corrupt |
  5892. AC-Unsafe corrupt | *Note POSIX Safety Concepts::.
  5893. The ‘putchar_unlocked’ function is equivalent to the ‘putchar’
  5894. function except that it does not implicitly lock the stream.
  5895. -- Function: wint_t putwchar_unlocked (wchar_t WC)
  5896. Preliminary: | MT-Unsafe race:stdout | AS-Unsafe corrupt |
  5897. AC-Unsafe corrupt | *Note POSIX Safety Concepts::.
  5898. The ‘putwchar_unlocked’ function is equivalent to the ‘putwchar’
  5899. function except that it does not implicitly lock the stream.
  5900. This function is a GNU extension.
  5901. -- Function: int fputs (const char *S, FILE *STREAM)
  5902. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  5903. | *Note POSIX Safety Concepts::.
  5904. The function ‘fputs’ writes the string S to the stream STREAM. The
  5905. terminating null character is not written. This function does
  5906. _not_ add a newline character, either. It outputs only the
  5907. characters in the string.
  5908. This function returns ‘EOF’ if a write error occurs, and otherwise
  5909. a non-negative value.
  5910. For example:
  5911. fputs ("Are ", stdout);
  5912. fputs ("you ", stdout);
  5913. fputs ("hungry?\n", stdout);
  5914. outputs the text ‘Are you hungry?’ followed by a newline.
  5915. -- Function: int fputws (const wchar_t *WS, FILE *STREAM)
  5916. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  5917. | *Note POSIX Safety Concepts::.
  5918. The function ‘fputws’ writes the wide character string WS to the
  5919. stream STREAM. The terminating null character is not written.
  5920. This function does _not_ add a newline character, either. It
  5921. outputs only the characters in the string.
  5922. This function returns ‘WEOF’ if a write error occurs, and otherwise
  5923. a non-negative value.
  5924. -- Function: int fputs_unlocked (const char *S, FILE *STREAM)
  5925. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  5926. corrupt | *Note POSIX Safety Concepts::.
  5927. The ‘fputs_unlocked’ function is equivalent to the ‘fputs’ function
  5928. except that it does not implicitly lock the stream.
  5929. This function is a GNU extension.
  5930. -- Function: int fputws_unlocked (const wchar_t *WS, FILE *STREAM)
  5931. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  5932. corrupt | *Note POSIX Safety Concepts::.
  5933. The ‘fputws_unlocked’ function is equivalent to the ‘fputws’
  5934. function except that it does not implicitly lock the stream.
  5935. This function is a GNU extension.
  5936. -- Function: int puts (const char *S)
  5937. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  5938. | *Note POSIX Safety Concepts::.
  5939. The ‘puts’ function writes the string S to the stream ‘stdout’
  5940. followed by a newline. The terminating null character of the
  5941. string is not written. (Note that ‘fputs’ does _not_ write a
  5942. newline as this function does.)
  5943. ‘puts’ is the most convenient function for printing simple
  5944. messages. For example:
  5945. puts ("This is a message.");
  5946. outputs the text ‘This is a message.’ followed by a newline.
  5947. -- Function: int putw (int W, FILE *STREAM)
  5948. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  5949. | *Note POSIX Safety Concepts::.
  5950. This function writes the word W (that is, an ‘int’) to STREAM. It
  5951. is provided for compatibility with SVID, but we recommend you use
  5952. ‘fwrite’ instead (*note Block Input/Output::).