libc.info-3 289 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882
  1. This is libc.info, produced by makeinfo version 7.3 from libc.texinfo.
  2. This is ‘The GNU C Library Reference Manual’, for version 2.43.
  3. Copyright © 1993-2026 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. * BAUD_MAX: (libc)Line Speed.
  25. * BC_BASE_MAX: (libc)Utility Limits.
  26. * BC_DIM_MAX: (libc)Utility Limits.
  27. * BC_SCALE_MAX: (libc)Utility Limits.
  28. * BC_STRING_MAX: (libc)Utility Limits.
  29. * BRKINT: (libc)Input Modes.
  30. * BUFSIZ: (libc)Controlling Buffering.
  31. * CCTS_OFLOW: (libc)Control Modes.
  32. * CHAR_BIT: (libc)Width of Type.
  33. * CHILD_MAX: (libc)General Limits.
  34. * CIGNORE: (libc)Control Modes.
  35. * CLK_TCK: (libc)Processor Time.
  36. * CLOCAL: (libc)Control Modes.
  37. * CLOCKS_PER_SEC: (libc)CPU Time.
  38. * CLOCK_BOOTTIME: (libc)Getting the Time.
  39. * CLOCK_BOOTTIME_ALARM: (libc)Getting the Time.
  40. * CLOCK_MONOTONIC: (libc)Getting the Time.
  41. * CLOCK_MONOTONIC_COARSE: (libc)Getting the Time.
  42. * CLOCK_MONOTONIC_RAW: (libc)Getting the Time.
  43. * CLOCK_PROCESS_CPUTIME_ID: (libc)Getting the Time.
  44. * CLOCK_REALTIME: (libc)Getting the Time.
  45. * CLOCK_REALTIME_ALARM: (libc)Getting the Time.
  46. * CLOCK_REALTIME_COARSE: (libc)Getting the Time.
  47. * CLOCK_TAI: (libc)Getting the Time.
  48. * CLOCK_THREAD_CPUTIME_ID: (libc)Getting the Time.
  49. * COLL_WEIGHTS_MAX: (libc)Utility Limits.
  50. * CPU_ALLOC: (libc)CPU Affinity.
  51. * CPU_ALLOC_SIZE: (libc)CPU Affinity.
  52. * CPU_AND: (libc)CPU Affinity.
  53. * CPU_AND_S: (libc)CPU Affinity.
  54. * CPU_CLR: (libc)CPU Affinity.
  55. * CPU_CLR_S: (libc)CPU Affinity.
  56. * CPU_COUNT: (libc)CPU Affinity.
  57. * CPU_COUNT_S: (libc)CPU Affinity.
  58. * CPU_EQUAL: (libc)CPU Affinity.
  59. * CPU_EQUAL_S: (libc)CPU Affinity.
  60. * CPU_FEATURE_ACTIVE: (libc)X86.
  61. * CPU_FEATURE_PRESENT: (libc)X86.
  62. * CPU_FREE: (libc)CPU Affinity.
  63. * CPU_ISSET: (libc)CPU Affinity.
  64. * CPU_ISSET_S: (libc)CPU Affinity.
  65. * CPU_OR: (libc)CPU Affinity.
  66. * CPU_OR_S: (libc)CPU Affinity.
  67. * CPU_SET: (libc)CPU Affinity.
  68. * CPU_SETSIZE: (libc)CPU Affinity.
  69. * CPU_SET_S: (libc)CPU Affinity.
  70. * CPU_XOR: (libc)CPU Affinity.
  71. * CPU_XOR_S: (libc)CPU Affinity.
  72. * CPU_ZERO: (libc)CPU Affinity.
  73. * CPU_ZERO_S: (libc)CPU Affinity.
  74. * CREAD: (libc)Control Modes.
  75. * CRTS_IFLOW: (libc)Control Modes.
  76. * CS5: (libc)Control Modes.
  77. * CS6: (libc)Control Modes.
  78. * CS7: (libc)Control Modes.
  79. * CS8: (libc)Control Modes.
  80. * CSIZE: (libc)Control Modes.
  81. * CSTOPB: (libc)Control Modes.
  82. * DLFO_EH_SEGMENT_TYPE: (libc)Dynamic Linker Introspection.
  83. * DLFO_STRUCT_HAS_EH_COUNT: (libc)Dynamic Linker Introspection.
  84. * DLFO_STRUCT_HAS_EH_DBASE: (libc)Dynamic Linker Introspection.
  85. * DTTOIF: (libc)Directory Entries.
  86. * E2BIG: (libc)Error Codes.
  87. * EACCES: (libc)Error Codes.
  88. * EADDRINUSE: (libc)Error Codes.
  89. * EADDRNOTAVAIL: (libc)Error Codes.
  90. * EADV: (libc)Error Codes.
  91. * EAFNOSUPPORT: (libc)Error Codes.
  92. * EAGAIN: (libc)Error Codes.
  93. * EALREADY: (libc)Error Codes.
  94. * EAUTH: (libc)Error Codes.
  95. * EBACKGROUND: (libc)Error Codes.
  96. * EBADE: (libc)Error Codes.
  97. * EBADF: (libc)Error Codes.
  98. * EBADFD: (libc)Error Codes.
  99. * EBADMSG: (libc)Error Codes.
  100. * EBADR: (libc)Error Codes.
  101. * EBADRPC: (libc)Error Codes.
  102. * EBADRQC: (libc)Error Codes.
  103. * EBADSLT: (libc)Error Codes.
  104. * EBFONT: (libc)Error Codes.
  105. * EBUSY: (libc)Error Codes.
  106. * ECANCELED: (libc)Error Codes.
  107. * ECHILD: (libc)Error Codes.
  108. * ECHO: (libc)Local Modes.
  109. * ECHOCTL: (libc)Local Modes.
  110. * ECHOE: (libc)Local Modes.
  111. * ECHOK: (libc)Local Modes.
  112. * ECHOKE: (libc)Local Modes.
  113. * ECHONL: (libc)Local Modes.
  114. * ECHOPRT: (libc)Local Modes.
  115. * ECHRNG: (libc)Error Codes.
  116. * ECOMM: (libc)Error Codes.
  117. * ECONNABORTED: (libc)Error Codes.
  118. * ECONNREFUSED: (libc)Error Codes.
  119. * ECONNRESET: (libc)Error Codes.
  120. * ED: (libc)Error Codes.
  121. * EDEADLK: (libc)Error Codes.
  122. * EDEADLOCK: (libc)Error Codes.
  123. * EDESTADDRREQ: (libc)Error Codes.
  124. * EDIED: (libc)Error Codes.
  125. * EDOM: (libc)Error Codes.
  126. * EDOTDOT: (libc)Error Codes.
  127. * EDQUOT: (libc)Error Codes.
  128. * EEXIST: (libc)Error Codes.
  129. * EFAULT: (libc)Error Codes.
  130. * EFBIG: (libc)Error Codes.
  131. * EFTYPE: (libc)Error Codes.
  132. * EGRATUITOUS: (libc)Error Codes.
  133. * EGREGIOUS: (libc)Error Codes.
  134. * EHOSTDOWN: (libc)Error Codes.
  135. * EHOSTUNREACH: (libc)Error Codes.
  136. * EHWPOISON: (libc)Error Codes.
  137. * EIDRM: (libc)Error Codes.
  138. * EIEIO: (libc)Error Codes.
  139. * EILSEQ: (libc)Error Codes.
  140. * EINPROGRESS: (libc)Error Codes.
  141. * EINTR: (libc)Error Codes.
  142. * EINVAL: (libc)Error Codes.
  143. * EIO: (libc)Error Codes.
  144. * EISCONN: (libc)Error Codes.
  145. * EISDIR: (libc)Error Codes.
  146. * EISNAM: (libc)Error Codes.
  147. * EKEYEXPIRED: (libc)Error Codes.
  148. * EKEYREJECTED: (libc)Error Codes.
  149. * EKEYREVOKED: (libc)Error Codes.
  150. * EL2HLT: (libc)Error Codes.
  151. * EL2NSYNC: (libc)Error Codes.
  152. * EL3HLT: (libc)Error Codes.
  153. * EL3RST: (libc)Error Codes.
  154. * ELIBACC: (libc)Error Codes.
  155. * ELIBBAD: (libc)Error Codes.
  156. * ELIBEXEC: (libc)Error Codes.
  157. * ELIBMAX: (libc)Error Codes.
  158. * ELIBSCN: (libc)Error Codes.
  159. * ELNRNG: (libc)Error Codes.
  160. * ELOOP: (libc)Error Codes.
  161. * EMEDIUMTYPE: (libc)Error Codes.
  162. * EMFILE: (libc)Error Codes.
  163. * EMLINK: (libc)Error Codes.
  164. * EMSGSIZE: (libc)Error Codes.
  165. * EMULTIHOP: (libc)Error Codes.
  166. * ENAMETOOLONG: (libc)Error Codes.
  167. * ENAVAIL: (libc)Error Codes.
  168. * ENEEDAUTH: (libc)Error Codes.
  169. * ENETDOWN: (libc)Error Codes.
  170. * ENETRESET: (libc)Error Codes.
  171. * ENETUNREACH: (libc)Error Codes.
  172. * ENFILE: (libc)Error Codes.
  173. * ENOANO: (libc)Error Codes.
  174. * ENOBUFS: (libc)Error Codes.
  175. * ENOCSI: (libc)Error Codes.
  176. * ENODATA: (libc)Error Codes.
  177. * ENODEV: (libc)Error Codes.
  178. * ENOENT: (libc)Error Codes.
  179. * ENOEXEC: (libc)Error Codes.
  180. * ENOKEY: (libc)Error Codes.
  181. * ENOLCK: (libc)Error Codes.
  182. * ENOLINK: (libc)Error Codes.
  183. * ENOMEDIUM: (libc)Error Codes.
  184. * ENOMEM: (libc)Error Codes.
  185. * ENOMSG: (libc)Error Codes.
  186. * ENONET: (libc)Error Codes.
  187. * ENOPKG: (libc)Error Codes.
  188. * ENOPROTOOPT: (libc)Error Codes.
  189. * ENOSPC: (libc)Error Codes.
  190. * ENOSR: (libc)Error Codes.
  191. * ENOSTR: (libc)Error Codes.
  192. * ENOSYS: (libc)Error Codes.
  193. * ENOTBLK: (libc)Error Codes.
  194. * ENOTCONN: (libc)Error Codes.
  195. * ENOTDIR: (libc)Error Codes.
  196. * ENOTEMPTY: (libc)Error Codes.
  197. * ENOTNAM: (libc)Error Codes.
  198. * ENOTRECOVERABLE: (libc)Error Codes.
  199. * ENOTSOCK: (libc)Error Codes.
  200. * ENOTSUP: (libc)Error Codes.
  201. * ENOTTY: (libc)Error Codes.
  202. * ENOTUNIQ: (libc)Error Codes.
  203. * ENXIO: (libc)Error Codes.
  204. * EOF: (libc)EOF and Errors.
  205. * EOPNOTSUPP: (libc)Error Codes.
  206. * EOVERFLOW: (libc)Error Codes.
  207. * EOWNERDEAD: (libc)Error Codes.
  208. * EPERM: (libc)Error Codes.
  209. * EPFNOSUPPORT: (libc)Error Codes.
  210. * EPIPE: (libc)Error Codes.
  211. * EPROCLIM: (libc)Error Codes.
  212. * EPROCUNAVAIL: (libc)Error Codes.
  213. * EPROGMISMATCH: (libc)Error Codes.
  214. * EPROGUNAVAIL: (libc)Error Codes.
  215. * EPROTO: (libc)Error Codes.
  216. * EPROTONOSUPPORT: (libc)Error Codes.
  217. * EPROTOTYPE: (libc)Error Codes.
  218. * EQUIV_CLASS_MAX: (libc)Utility Limits.
  219. * ERANGE: (libc)Error Codes.
  220. * EREMCHG: (libc)Error Codes.
  221. * EREMOTE: (libc)Error Codes.
  222. * EREMOTEIO: (libc)Error Codes.
  223. * ERESTART: (libc)Error Codes.
  224. * ERFKILL: (libc)Error Codes.
  225. * EROFS: (libc)Error Codes.
  226. * ERPCMISMATCH: (libc)Error Codes.
  227. * ESHUTDOWN: (libc)Error Codes.
  228. * ESOCKTNOSUPPORT: (libc)Error Codes.
  229. * ESPIPE: (libc)Error Codes.
  230. * ESRCH: (libc)Error Codes.
  231. * ESRMNT: (libc)Error Codes.
  232. * ESTALE: (libc)Error Codes.
  233. * ESTRPIPE: (libc)Error Codes.
  234. * ETIME: (libc)Error Codes.
  235. * ETIMEDOUT: (libc)Error Codes.
  236. * ETOOMANYREFS: (libc)Error Codes.
  237. * ETXTBSY: (libc)Error Codes.
  238. * EUCLEAN: (libc)Error Codes.
  239. * EUNATCH: (libc)Error Codes.
  240. * EUSERS: (libc)Error Codes.
  241. * EWOULDBLOCK: (libc)Error Codes.
  242. * EXDEV: (libc)Error Codes.
  243. * EXFULL: (libc)Error Codes.
  244. * EXIT_FAILURE: (libc)Exit Status.
  245. * EXIT_SUCCESS: (libc)Exit Status.
  246. * EXPR_NEST_MAX: (libc)Utility Limits.
  247. * FD_CLOEXEC: (libc)Descriptor Flags.
  248. * FD_CLR: (libc)Waiting for I/O.
  249. * FD_ISSET: (libc)Waiting for I/O.
  250. * FD_SET: (libc)Waiting for I/O.
  251. * FD_SETSIZE: (libc)Waiting for I/O.
  252. * FD_ZERO: (libc)Waiting for I/O.
  253. * FE_SNANS_ALWAYS_SIGNAL: (libc)Infinity and NaN.
  254. * FILENAME_MAX: (libc)Limits for Files.
  255. * FLUSHO: (libc)Local Modes.
  256. * FOPEN_MAX: (libc)Opening Streams.
  257. * FP_ILOGB0: (libc)Exponents and Logarithms.
  258. * FP_ILOGBNAN: (libc)Exponents and Logarithms.
  259. * FP_LLOGB0: (libc)Exponents and Logarithms.
  260. * FP_LLOGBNAN: (libc)Exponents and Logarithms.
  261. * F_DUPFD: (libc)Duplicating Descriptors.
  262. * F_GETFD: (libc)Descriptor Flags.
  263. * F_GETFL: (libc)Getting File Status Flags.
  264. * F_GETLK: (libc)File Locks.
  265. * F_GETOWN: (libc)Interrupt Input.
  266. * F_OFD_GETLK: (libc)Open File Description Locks.
  267. * F_OFD_SETLK: (libc)Open File Description Locks.
  268. * F_OFD_SETLKW: (libc)Open File Description Locks.
  269. * F_OK: (libc)Testing File Access.
  270. * F_SETFD: (libc)Descriptor Flags.
  271. * F_SETFL: (libc)Getting File Status Flags.
  272. * F_SETLK: (libc)File Locks.
  273. * F_SETLKW: (libc)File Locks.
  274. * F_SETOWN: (libc)Interrupt Input.
  275. * HUGE_VAL: (libc)Math Error Reporting.
  276. * HUGE_VALF: (libc)Math Error Reporting.
  277. * HUGE_VALL: (libc)Math Error Reporting.
  278. * HUGE_VAL_FN: (libc)Math Error Reporting.
  279. * HUGE_VAL_FNx: (libc)Math Error Reporting.
  280. * HUPCL: (libc)Control Modes.
  281. * I: (libc)Complex Numbers.
  282. * ICANON: (libc)Local Modes.
  283. * ICRNL: (libc)Input Modes.
  284. * IEXTEN: (libc)Local Modes.
  285. * IFNAMSIZ: (libc)Interface Naming.
  286. * IFTODT: (libc)Directory Entries.
  287. * IGNBRK: (libc)Input Modes.
  288. * IGNCR: (libc)Input Modes.
  289. * IGNPAR: (libc)Input Modes.
  290. * IMAXBEL: (libc)Input Modes.
  291. * INADDR_ANY: (libc)Host Address Data Type.
  292. * INADDR_BROADCAST: (libc)Host Address Data Type.
  293. * INADDR_LOOPBACK: (libc)Host Address Data Type.
  294. * INADDR_NONE: (libc)Host Address Data Type.
  295. * INFINITY: (libc)Infinity and NaN.
  296. * INLCR: (libc)Input Modes.
  297. * INPCK: (libc)Input Modes.
  298. * IPPORT_RESERVED: (libc)Ports.
  299. * IPPORT_USERRESERVED: (libc)Ports.
  300. * ISIG: (libc)Local Modes.
  301. * ISTRIP: (libc)Input Modes.
  302. * IXANY: (libc)Input Modes.
  303. * IXOFF: (libc)Input Modes.
  304. * IXON: (libc)Input Modes.
  305. * LINE_MAX: (libc)Utility Limits.
  306. * LINK_MAX: (libc)Limits for Files.
  307. * L_ctermid: (libc)Identifying the Terminal.
  308. * L_cuserid: (libc)Who Logged In.
  309. * L_tmpnam: (libc)Temporary Files.
  310. * MAXNAMLEN: (libc)Limits for Files.
  311. * MAXSYMLINKS: (libc)Symbolic Links.
  312. * MAX_CANON: (libc)Limits for Files.
  313. * MAX_INPUT: (libc)Limits for Files.
  314. * MB_CUR_MAX: (libc)Selecting the Conversion.
  315. * MB_LEN_MAX: (libc)Selecting the Conversion.
  316. * MDMBUF: (libc)Control Modes.
  317. * MSG_DONTROUTE: (libc)Socket Data Options.
  318. * MSG_OOB: (libc)Socket Data Options.
  319. * MSG_PEEK: (libc)Socket Data Options.
  320. * NAME_MAX: (libc)Limits for Files.
  321. * NAN: (libc)Infinity and NaN.
  322. * NCCS: (libc)Mode Data Types.
  323. * NGROUPS_MAX: (libc)General Limits.
  324. * NOFLSH: (libc)Local Modes.
  325. * NOKERNINFO: (libc)Local Modes.
  326. * NSIG: (libc)Standard Signals.
  327. * NULL: (libc)Null Pointer Constant.
  328. * ONLCR: (libc)Output Modes.
  329. * ONOEOT: (libc)Output Modes.
  330. * OPEN_MAX: (libc)General Limits.
  331. * OPOST: (libc)Output Modes.
  332. * OXTABS: (libc)Output Modes.
  333. * O_ACCMODE: (libc)Access Modes.
  334. * O_APPEND: (libc)Operating Modes.
  335. * O_ASYNC: (libc)Operating Modes.
  336. * O_CREAT: (libc)Open-time Flags.
  337. * O_DIRECTORY: (libc)Open-time Flags.
  338. * O_EXCL: (libc)Open-time Flags.
  339. * O_EXEC: (libc)Access Modes.
  340. * O_EXLOCK: (libc)Open-time Flags.
  341. * O_FSYNC: (libc)Operating Modes.
  342. * O_IGNORE_CTTY: (libc)Open-time Flags.
  343. * O_NDELAY: (libc)Operating Modes.
  344. * O_NOATIME: (libc)Operating Modes.
  345. * O_NOCTTY: (libc)Open-time Flags.
  346. * O_NOFOLLOW: (libc)Open-time Flags.
  347. * O_NOLINK: (libc)Open-time Flags.
  348. * O_NONBLOCK: (libc)Open-time Flags.
  349. * O_NONBLOCK: (libc)Operating Modes.
  350. * O_NOTRANS: (libc)Open-time Flags.
  351. * O_PATH: (libc)Access Modes.
  352. * O_RDONLY: (libc)Access Modes.
  353. * O_RDWR: (libc)Access Modes.
  354. * O_READ: (libc)Access Modes.
  355. * O_SHLOCK: (libc)Open-time Flags.
  356. * O_SYNC: (libc)Operating Modes.
  357. * O_TMPFILE: (libc)Open-time Flags.
  358. * O_TRUNC: (libc)Open-time Flags.
  359. * O_WRITE: (libc)Access Modes.
  360. * O_WRONLY: (libc)Access Modes.
  361. * PARENB: (libc)Control Modes.
  362. * PARMRK: (libc)Input Modes.
  363. * PARODD: (libc)Control Modes.
  364. * PATH_MAX: (libc)Limits for Files.
  365. * PA_FLAG_MASK: (libc)Parsing a Template String.
  366. * PENDIN: (libc)Local Modes.
  367. * PF_FILE: (libc)Local Namespace Details.
  368. * PF_INET6: (libc)Internet Namespace.
  369. * PF_INET: (libc)Internet Namespace.
  370. * PF_LOCAL: (libc)Local Namespace Details.
  371. * PF_UNIX: (libc)Local Namespace Details.
  372. * PIPE_BUF: (libc)Limits for Files.
  373. * PTHREAD_ATTR_NO_SIGMASK_NP: (libc)Initial Thread Signal Mask.
  374. * P_tmpdir: (libc)Temporary Files.
  375. * RAND_MAX: (libc)ISO Random.
  376. * RE_DUP_MAX: (libc)General Limits.
  377. * RLIM_INFINITY: (libc)Limits on Resources.
  378. * RSEQ_SIG: (libc)Restartable Sequences.
  379. * R_OK: (libc)Testing File Access.
  380. * SA_NOCLDSTOP: (libc)Flags for Sigaction.
  381. * SA_NOCLDWAIT: (libc)Flags for Sigaction.
  382. * SA_NODEFER: (libc)Flags for Sigaction.
  383. * SA_ONSTACK: (libc)Flags for Sigaction.
  384. * SA_RESETHAND: (libc)Flags for Sigaction.
  385. * SA_RESTART: (libc)Flags for Sigaction.
  386. * SA_SIGINFO: (libc)Flags for Sigaction.
  387. * SEEK_CUR: (libc)File Positioning.
  388. * SEEK_END: (libc)File Positioning.
  389. * SEEK_SET: (libc)File Positioning.
  390. * SIGABRT: (libc)Program Error Signals.
  391. * SIGALRM: (libc)Alarm Signals.
  392. * SIGBUS: (libc)Program Error Signals.
  393. * SIGCHLD: (libc)Job Control Signals.
  394. * SIGCLD: (libc)Job Control Signals.
  395. * SIGCONT: (libc)Job Control Signals.
  396. * SIGEMT: (libc)Program Error Signals.
  397. * SIGFPE: (libc)Program Error Signals.
  398. * SIGHUP: (libc)Termination Signals.
  399. * SIGILL: (libc)Program Error Signals.
  400. * SIGINFO: (libc)Miscellaneous Signals.
  401. * SIGINT: (libc)Termination Signals.
  402. * SIGIO: (libc)Asynchronous I/O Signals.
  403. * SIGIOT: (libc)Program Error Signals.
  404. * SIGKILL: (libc)Termination Signals.
  405. * SIGLOST: (libc)Operation Error Signals.
  406. * SIGPIPE: (libc)Operation Error Signals.
  407. * SIGPOLL: (libc)Asynchronous I/O Signals.
  408. * SIGPROF: (libc)Alarm Signals.
  409. * SIGPWR: (libc)Miscellaneous Signals.
  410. * SIGQUIT: (libc)Termination Signals.
  411. * SIGSEGV: (libc)Program Error Signals.
  412. * SIGSTKFLT: (libc)Program Error Signals.
  413. * SIGSTOP: (libc)Job Control Signals.
  414. * SIGSYS: (libc)Program Error Signals.
  415. * SIGTERM: (libc)Termination Signals.
  416. * SIGTRAP: (libc)Program Error Signals.
  417. * SIGTSTP: (libc)Job Control Signals.
  418. * SIGTTIN: (libc)Job Control Signals.
  419. * SIGTTOU: (libc)Job Control Signals.
  420. * SIGURG: (libc)Asynchronous I/O Signals.
  421. * SIGUSR1: (libc)Miscellaneous Signals.
  422. * SIGUSR2: (libc)Miscellaneous Signals.
  423. * SIGVTALRM: (libc)Alarm Signals.
  424. * SIGWINCH: (libc)Miscellaneous Signals.
  425. * SIGXCPU: (libc)Operation Error Signals.
  426. * SIGXFSZ: (libc)Operation Error Signals.
  427. * SIG_ERR: (libc)Basic Signal Handling.
  428. * SNAN: (libc)Infinity and NaN.
  429. * SNANF: (libc)Infinity and NaN.
  430. * SNANFN: (libc)Infinity and NaN.
  431. * SNANFNx: (libc)Infinity and NaN.
  432. * SNANL: (libc)Infinity and NaN.
  433. * SOCK_DGRAM: (libc)Communication Styles.
  434. * SOCK_RAW: (libc)Communication Styles.
  435. * SOCK_RDM: (libc)Communication Styles.
  436. * SOCK_SEQPACKET: (libc)Communication Styles.
  437. * SOCK_STREAM: (libc)Communication Styles.
  438. * SOL_SOCKET: (libc)Socket-Level Options.
  439. * SPEED_MAX: (libc)Line Speed.
  440. * SSIZE_MAX: (libc)General Limits.
  441. * STREAM_MAX: (libc)General Limits.
  442. * SUN_LEN: (libc)Local Namespace Details.
  443. * S_IFMT: (libc)Testing File Type.
  444. * S_ISBLK: (libc)Testing File Type.
  445. * S_ISCHR: (libc)Testing File Type.
  446. * S_ISDIR: (libc)Testing File Type.
  447. * S_ISFIFO: (libc)Testing File Type.
  448. * S_ISLNK: (libc)Testing File Type.
  449. * S_ISREG: (libc)Testing File Type.
  450. * S_ISSOCK: (libc)Testing File Type.
  451. * S_TYPEISMQ: (libc)Testing File Type.
  452. * S_TYPEISSEM: (libc)Testing File Type.
  453. * S_TYPEISSHM: (libc)Testing File Type.
  454. * TIME_UTC: (libc)Getting the Time.
  455. * TMP_MAX: (libc)Temporary Files.
  456. * TOSTOP: (libc)Local Modes.
  457. * TZNAME_MAX: (libc)General Limits.
  458. * VDISCARD: (libc)Other Special.
  459. * VDSUSP: (libc)Signal Characters.
  460. * VEOF: (libc)Editing Characters.
  461. * VEOL2: (libc)Editing Characters.
  462. * VEOL: (libc)Editing Characters.
  463. * VERASE: (libc)Editing Characters.
  464. * VINTR: (libc)Signal Characters.
  465. * VKILL: (libc)Editing Characters.
  466. * VLNEXT: (libc)Other Special.
  467. * VMIN: (libc)Noncanonical Input.
  468. * VQUIT: (libc)Signal Characters.
  469. * VREPRINT: (libc)Editing Characters.
  470. * VSTART: (libc)Start/Stop Characters.
  471. * VSTATUS: (libc)Other Special.
  472. * VSTOP: (libc)Start/Stop Characters.
  473. * VSUSP: (libc)Signal Characters.
  474. * VTIME: (libc)Noncanonical Input.
  475. * VWERASE: (libc)Editing Characters.
  476. * WCHAR_MAX: (libc)Extended Char Intro.
  477. * WCHAR_MIN: (libc)Extended Char Intro.
  478. * WCOREDUMP: (libc)Process Completion Status.
  479. * WEOF: (libc)EOF and Errors.
  480. * WEOF: (libc)Extended Char Intro.
  481. * WEXITSTATUS: (libc)Process Completion Status.
  482. * WIFEXITED: (libc)Process Completion Status.
  483. * WIFSIGNALED: (libc)Process Completion Status.
  484. * WIFSTOPPED: (libc)Process Completion Status.
  485. * WSTOPSIG: (libc)Process Completion Status.
  486. * WTERMSIG: (libc)Process Completion Status.
  487. * W_OK: (libc)Testing File Access.
  488. * X_OK: (libc)Testing File Access.
  489. * _Complex_I: (libc)Complex Numbers.
  490. * _Exit: (libc)Termination Internals.
  491. * _Fork: (libc)Creating a Process.
  492. * _IOFBF: (libc)Controlling Buffering.
  493. * _IOLBF: (libc)Controlling Buffering.
  494. * _IONBF: (libc)Controlling Buffering.
  495. * _Imaginary_I: (libc)Complex Numbers.
  496. * _PATH_UTMP: (libc)Manipulating the Database.
  497. * _PATH_WTMP: (libc)Manipulating the Database.
  498. * _POSIX2_C_DEV: (libc)System Options.
  499. * _POSIX2_C_VERSION: (libc)Version Supported.
  500. * _POSIX2_FORT_DEV: (libc)System Options.
  501. * _POSIX2_FORT_RUN: (libc)System Options.
  502. * _POSIX2_LOCALEDEF: (libc)System Options.
  503. * _POSIX2_SW_DEV: (libc)System Options.
  504. * _POSIX_CHOWN_RESTRICTED: (libc)Options for Files.
  505. * _POSIX_JOB_CONTROL: (libc)System Options.
  506. * _POSIX_NO_TRUNC: (libc)Options for Files.
  507. * _POSIX_SAVED_IDS: (libc)System Options.
  508. * _POSIX_VDISABLE: (libc)Options for Files.
  509. * _POSIX_VERSION: (libc)Version Supported.
  510. * __fbufsize: (libc)Controlling Buffering.
  511. * __flbf: (libc)Controlling Buffering.
  512. * __fpending: (libc)Controlling Buffering.
  513. * __fpurge: (libc)Flushing Buffers.
  514. * __freadable: (libc)Opening Streams.
  515. * __freading: (libc)Opening Streams.
  516. * __fsetlocking: (libc)Streams and Threads.
  517. * __fwritable: (libc)Opening Streams.
  518. * __fwriting: (libc)Opening Streams.
  519. * __gconv_end_fct: (libc)glibc iconv Implementation.
  520. * __gconv_fct: (libc)glibc iconv Implementation.
  521. * __gconv_init_fct: (libc)glibc iconv Implementation.
  522. * __ppc_get_timebase: (libc)PowerPC.
  523. * __ppc_get_timebase_freq: (libc)PowerPC.
  524. * __ppc_mdoio: (libc)PowerPC.
  525. * __ppc_mdoom: (libc)PowerPC.
  526. * __ppc_set_ppr_low: (libc)PowerPC.
  527. * __ppc_set_ppr_med: (libc)PowerPC.
  528. * __ppc_set_ppr_med_high: (libc)PowerPC.
  529. * __ppc_set_ppr_med_low: (libc)PowerPC.
  530. * __ppc_set_ppr_very_low: (libc)PowerPC.
  531. * __ppc_yield: (libc)PowerPC.
  532. * __riscv_flush_icache: (libc)RISC-V.
  533. * __va_copy: (libc)Argument Macros.
  534. * __x86_get_cpuid_feature_leaf: (libc)X86.
  535. * _dl_find_object: (libc)Dynamic Linker Introspection.
  536. * _exit: (libc)Termination Internals.
  537. * _flushlbf: (libc)Flushing Buffers.
  538. * _tolower: (libc)Case Conversion.
  539. * _toupper: (libc)Case Conversion.
  540. * a64l: (libc)Encode Binary Data.
  541. * abort: (libc)Aborting a Program.
  542. * abs: (libc)Absolute Value.
  543. * accept: (libc)Accepting Connections.
  544. * access: (libc)Testing File Access.
  545. * acos: (libc)Inverse Trig Functions.
  546. * acosf: (libc)Inverse Trig Functions.
  547. * acosfN: (libc)Inverse Trig Functions.
  548. * acosfNx: (libc)Inverse Trig Functions.
  549. * acosh: (libc)Hyperbolic Functions.
  550. * acoshf: (libc)Hyperbolic Functions.
  551. * acoshfN: (libc)Hyperbolic Functions.
  552. * acoshfNx: (libc)Hyperbolic Functions.
  553. * acoshl: (libc)Hyperbolic Functions.
  554. * acosl: (libc)Inverse Trig Functions.
  555. * acospi: (libc)Inverse Trig Functions.
  556. * acospif: (libc)Inverse Trig Functions.
  557. * acospifN: (libc)Inverse Trig Functions.
  558. * acospifNx: (libc)Inverse Trig Functions.
  559. * acospil: (libc)Inverse Trig Functions.
  560. * addmntent: (libc)mtab.
  561. * addseverity: (libc)Adding Severity Classes.
  562. * adjtime: (libc)Setting and Adjusting the Time.
  563. * adjtimex: (libc)Setting and Adjusting the Time.
  564. * aio_cancel64: (libc)Cancel AIO Operations.
  565. * aio_cancel: (libc)Cancel AIO Operations.
  566. * aio_error64: (libc)Status of AIO Operations.
  567. * aio_error: (libc)Status of AIO Operations.
  568. * aio_fsync64: (libc)Synchronizing AIO Operations.
  569. * aio_fsync: (libc)Synchronizing AIO Operations.
  570. * aio_init: (libc)Configuration of AIO.
  571. * aio_read64: (libc)Asynchronous Reads/Writes.
  572. * aio_read: (libc)Asynchronous Reads/Writes.
  573. * aio_return64: (libc)Status of AIO Operations.
  574. * aio_return: (libc)Status of AIO Operations.
  575. * aio_suspend64: (libc)Synchronizing AIO Operations.
  576. * aio_suspend: (libc)Synchronizing AIO Operations.
  577. * aio_write64: (libc)Asynchronous Reads/Writes.
  578. * aio_write: (libc)Asynchronous Reads/Writes.
  579. * alarm: (libc)Setting an Alarm.
  580. * aligned_alloc: (libc)Aligned Memory Blocks.
  581. * alloca: (libc)Variable Size Automatic.
  582. * alphasort64: (libc)Scanning Directory Content.
  583. * alphasort: (libc)Scanning Directory Content.
  584. * arc4random: (libc)High Quality Random.
  585. * arc4random_buf: (libc)High Quality Random.
  586. * arc4random_uniform: (libc)High Quality Random.
  587. * argp_error: (libc)Argp Helper Functions.
  588. * argp_failure: (libc)Argp Helper Functions.
  589. * argp_help: (libc)Argp Help.
  590. * argp_parse: (libc)Argp.
  591. * argp_state_help: (libc)Argp Helper Functions.
  592. * argp_usage: (libc)Argp Helper Functions.
  593. * argz_add: (libc)Argz Functions.
  594. * argz_add_sep: (libc)Argz Functions.
  595. * argz_append: (libc)Argz Functions.
  596. * argz_count: (libc)Argz Functions.
  597. * argz_create: (libc)Argz Functions.
  598. * argz_create_sep: (libc)Argz Functions.
  599. * argz_delete: (libc)Argz Functions.
  600. * argz_extract: (libc)Argz Functions.
  601. * argz_insert: (libc)Argz Functions.
  602. * argz_next: (libc)Argz Functions.
  603. * argz_replace: (libc)Argz Functions.
  604. * argz_stringify: (libc)Argz Functions.
  605. * asctime: (libc)Formatting Calendar Time.
  606. * asctime_r: (libc)Formatting Calendar Time.
  607. * asin: (libc)Inverse Trig Functions.
  608. * asinf: (libc)Inverse Trig Functions.
  609. * asinfN: (libc)Inverse Trig Functions.
  610. * asinfNx: (libc)Inverse Trig Functions.
  611. * asinh: (libc)Hyperbolic Functions.
  612. * asinhf: (libc)Hyperbolic Functions.
  613. * asinhfN: (libc)Hyperbolic Functions.
  614. * asinhfNx: (libc)Hyperbolic Functions.
  615. * asinhl: (libc)Hyperbolic Functions.
  616. * asinl: (libc)Inverse Trig Functions.
  617. * asinpi: (libc)Inverse Trig Functions.
  618. * asinpif: (libc)Inverse Trig Functions.
  619. * asinpifN: (libc)Inverse Trig Functions.
  620. * asinpifNx: (libc)Inverse Trig Functions.
  621. * asinpil: (libc)Inverse Trig Functions.
  622. * asprintf: (libc)Dynamic Output.
  623. * assert: (libc)Consistency Checking.
  624. * assert_perror: (libc)Consistency Checking.
  625. * atan2: (libc)Inverse Trig Functions.
  626. * atan2f: (libc)Inverse Trig Functions.
  627. * atan2fN: (libc)Inverse Trig Functions.
  628. * atan2fNx: (libc)Inverse Trig Functions.
  629. * atan2l: (libc)Inverse Trig Functions.
  630. * atan2pi: (libc)Inverse Trig Functions.
  631. * atan2pif: (libc)Inverse Trig Functions.
  632. * atan2pifN: (libc)Inverse Trig Functions.
  633. * atan2pifNx: (libc)Inverse Trig Functions.
  634. * atan2pil: (libc)Inverse Trig Functions.
  635. * atan: (libc)Inverse Trig Functions.
  636. * atanf: (libc)Inverse Trig Functions.
  637. * atanfN: (libc)Inverse Trig Functions.
  638. * atanfNx: (libc)Inverse Trig Functions.
  639. * atanh: (libc)Hyperbolic Functions.
  640. * atanhf: (libc)Hyperbolic Functions.
  641. * atanhfN: (libc)Hyperbolic Functions.
  642. * atanhfNx: (libc)Hyperbolic Functions.
  643. * atanhl: (libc)Hyperbolic Functions.
  644. * atanl: (libc)Inverse Trig Functions.
  645. * atanpi: (libc)Inverse Trig Functions.
  646. * atanpif: (libc)Inverse Trig Functions.
  647. * atanpifN: (libc)Inverse Trig Functions.
  648. * atanpifNx: (libc)Inverse Trig Functions.
  649. * atanpil: (libc)Inverse Trig Functions.
  650. * atexit: (libc)Cleanups on Exit.
  651. * atof: (libc)Parsing of Floats.
  652. * atoi: (libc)Parsing of Integers.
  653. * atol: (libc)Parsing of Integers.
  654. * atoll: (libc)Parsing of Integers.
  655. * backtrace: (libc)Backtraces.
  656. * backtrace_symbols: (libc)Backtraces.
  657. * backtrace_symbols_fd: (libc)Backtraces.
  658. * basename: (libc)Finding Tokens in a String.
  659. * basename: (libc)Finding Tokens in a String.
  660. * bcmp: (libc)String/Array Comparison.
  661. * bcopy: (libc)Copying Strings and Arrays.
  662. * bind: (libc)Setting Address.
  663. * bind_textdomain_codeset: (libc)Charset conversion in gettext.
  664. * bindtextdomain: (libc)Locating gettext catalog.
  665. * brk: (libc)Resizing the Data Segment.
  666. * bsearch: (libc)Array Search Function.
  667. * btowc: (libc)Converting a Character.
  668. * bzero: (libc)Copying Strings and Arrays.
  669. * cabs: (libc)Absolute Value.
  670. * cabsf: (libc)Absolute Value.
  671. * cabsfN: (libc)Absolute Value.
  672. * cabsfNx: (libc)Absolute Value.
  673. * cabsl: (libc)Absolute Value.
  674. * cacos: (libc)Inverse Trig Functions.
  675. * cacosf: (libc)Inverse Trig Functions.
  676. * cacosfN: (libc)Inverse Trig Functions.
  677. * cacosfNx: (libc)Inverse Trig Functions.
  678. * cacosh: (libc)Hyperbolic Functions.
  679. * cacoshf: (libc)Hyperbolic Functions.
  680. * cacoshfN: (libc)Hyperbolic Functions.
  681. * cacoshfNx: (libc)Hyperbolic Functions.
  682. * cacoshl: (libc)Hyperbolic Functions.
  683. * cacosl: (libc)Inverse Trig Functions.
  684. * call_once: (libc)Call Once.
  685. * calloc: (libc)Allocating Cleared Space.
  686. * canonicalize: (libc)FP Bit Twiddling.
  687. * canonicalize_file_name: (libc)Symbolic Links.
  688. * canonicalizef: (libc)FP Bit Twiddling.
  689. * canonicalizefN: (libc)FP Bit Twiddling.
  690. * canonicalizefNx: (libc)FP Bit Twiddling.
  691. * canonicalizel: (libc)FP Bit Twiddling.
  692. * carg: (libc)Operations on Complex.
  693. * cargf: (libc)Operations on Complex.
  694. * cargfN: (libc)Operations on Complex.
  695. * cargfNx: (libc)Operations on Complex.
  696. * cargl: (libc)Operations on Complex.
  697. * casin: (libc)Inverse Trig Functions.
  698. * casinf: (libc)Inverse Trig Functions.
  699. * casinfN: (libc)Inverse Trig Functions.
  700. * casinfNx: (libc)Inverse Trig Functions.
  701. * casinh: (libc)Hyperbolic Functions.
  702. * casinhf: (libc)Hyperbolic Functions.
  703. * casinhfN: (libc)Hyperbolic Functions.
  704. * casinhfNx: (libc)Hyperbolic Functions.
  705. * casinhl: (libc)Hyperbolic Functions.
  706. * casinl: (libc)Inverse Trig Functions.
  707. * catan: (libc)Inverse Trig Functions.
  708. * catanf: (libc)Inverse Trig Functions.
  709. * catanfN: (libc)Inverse Trig Functions.
  710. * catanfNx: (libc)Inverse Trig Functions.
  711. * catanh: (libc)Hyperbolic Functions.
  712. * catanhf: (libc)Hyperbolic Functions.
  713. * catanhfN: (libc)Hyperbolic Functions.
  714. * catanhfNx: (libc)Hyperbolic Functions.
  715. * catanhl: (libc)Hyperbolic Functions.
  716. * catanl: (libc)Inverse Trig Functions.
  717. * catclose: (libc)The catgets Functions.
  718. * catgets: (libc)The catgets Functions.
  719. * catopen: (libc)The catgets Functions.
  720. * cbrt: (libc)Exponents and Logarithms.
  721. * cbrtf: (libc)Exponents and Logarithms.
  722. * cbrtfN: (libc)Exponents and Logarithms.
  723. * cbrtfNx: (libc)Exponents and Logarithms.
  724. * cbrtl: (libc)Exponents and Logarithms.
  725. * ccos: (libc)Trig Functions.
  726. * ccosf: (libc)Trig Functions.
  727. * ccosfN: (libc)Trig Functions.
  728. * ccosfNx: (libc)Trig Functions.
  729. * ccosh: (libc)Hyperbolic Functions.
  730. * ccoshf: (libc)Hyperbolic Functions.
  731. * ccoshfN: (libc)Hyperbolic Functions.
  732. * ccoshfNx: (libc)Hyperbolic Functions.
  733. * ccoshl: (libc)Hyperbolic Functions.
  734. * ccosl: (libc)Trig Functions.
  735. * ceil: (libc)Rounding Functions.
  736. * ceilf: (libc)Rounding Functions.
  737. * ceilfN: (libc)Rounding Functions.
  738. * ceilfNx: (libc)Rounding Functions.
  739. * ceill: (libc)Rounding Functions.
  740. * cexp: (libc)Exponents and Logarithms.
  741. * cexpf: (libc)Exponents and Logarithms.
  742. * cexpfN: (libc)Exponents and Logarithms.
  743. * cexpfNx: (libc)Exponents and Logarithms.
  744. * cexpl: (libc)Exponents and Logarithms.
  745. * cfgetibaud: (libc)Line Speed.
  746. * cfgetispeed: (libc)Line Speed.
  747. * cfgetobaud: (libc)Line Speed.
  748. * cfgetospeed: (libc)Line Speed.
  749. * cfmakeraw: (libc)Noncanonical Input.
  750. * cfsetbaud: (libc)Line Speed.
  751. * cfsetibaud: (libc)Line Speed.
  752. * cfsetispeed: (libc)Line Speed.
  753. * cfsetobaud: (libc)Line Speed.
  754. * cfsetospeed: (libc)Line Speed.
  755. * cfsetspeed: (libc)Line Speed.
  756. * chdir: (libc)Working Directory.
  757. * chmod: (libc)Setting Permissions.
  758. * chown: (libc)File Owner.
  759. * cimag: (libc)Operations on Complex.
  760. * cimagf: (libc)Operations on Complex.
  761. * cimagfN: (libc)Operations on Complex.
  762. * cimagfNx: (libc)Operations on Complex.
  763. * cimagl: (libc)Operations on Complex.
  764. * clearenv: (libc)Environment Access.
  765. * clearerr: (libc)Error Recovery.
  766. * clearerr_unlocked: (libc)Error Recovery.
  767. * clock: (libc)CPU Time.
  768. * clock_getres: (libc)Getting the Time.
  769. * clock_gettime: (libc)Getting the Time.
  770. * clock_nanosleep: (libc)Sleeping.
  771. * clock_settime: (libc)Setting and Adjusting the Time.
  772. * clog10: (libc)Exponents and Logarithms.
  773. * clog10f: (libc)Exponents and Logarithms.
  774. * clog10fN: (libc)Exponents and Logarithms.
  775. * clog10fNx: (libc)Exponents and Logarithms.
  776. * clog10l: (libc)Exponents and Logarithms.
  777. * clog: (libc)Exponents and Logarithms.
  778. * clogf: (libc)Exponents and Logarithms.
  779. * clogfN: (libc)Exponents and Logarithms.
  780. * clogfNx: (libc)Exponents and Logarithms.
  781. * clogl: (libc)Exponents and Logarithms.
  782. * close: (libc)Opening and Closing Files.
  783. * close_range: (libc)Opening and Closing Files.
  784. * closedir: (libc)Reading/Closing Directory.
  785. * closefrom: (libc)Opening and Closing Files.
  786. * closelog: (libc)closelog.
  787. * cnd_broadcast: (libc)ISO C Condition Variables.
  788. * cnd_destroy: (libc)ISO C Condition Variables.
  789. * cnd_init: (libc)ISO C Condition Variables.
  790. * cnd_signal: (libc)ISO C Condition Variables.
  791. * cnd_timedwait: (libc)ISO C Condition Variables.
  792. * cnd_wait: (libc)ISO C Condition Variables.
  793. * compoundn: (libc)Exponents and Logarithms.
  794. * compoundnf: (libc)Exponents and Logarithms.
  795. * compoundnfN: (libc)Exponents and Logarithms.
  796. * compoundnfNx: (libc)Exponents and Logarithms.
  797. * compoundnl: (libc)Exponents and Logarithms.
  798. * confstr: (libc)String Parameters.
  799. * conj: (libc)Operations on Complex.
  800. * conjf: (libc)Operations on Complex.
  801. * conjfN: (libc)Operations on Complex.
  802. * conjfNx: (libc)Operations on Complex.
  803. * conjl: (libc)Operations on Complex.
  804. * connect: (libc)Connecting.
  805. * copy_file_range: (libc)Copying File Data.
  806. * copysign: (libc)FP Bit Twiddling.
  807. * copysignf: (libc)FP Bit Twiddling.
  808. * copysignfN: (libc)FP Bit Twiddling.
  809. * copysignfNx: (libc)FP Bit Twiddling.
  810. * copysignl: (libc)FP Bit Twiddling.
  811. * cos: (libc)Trig Functions.
  812. * cosf: (libc)Trig Functions.
  813. * cosfN: (libc)Trig Functions.
  814. * cosfNx: (libc)Trig Functions.
  815. * cosh: (libc)Hyperbolic Functions.
  816. * coshf: (libc)Hyperbolic Functions.
  817. * coshfN: (libc)Hyperbolic Functions.
  818. * coshfNx: (libc)Hyperbolic Functions.
  819. * coshl: (libc)Hyperbolic Functions.
  820. * cosl: (libc)Trig Functions.
  821. * cospi: (libc)Trig Functions.
  822. * cospif: (libc)Trig Functions.
  823. * cospifN: (libc)Trig Functions.
  824. * cospifNx: (libc)Trig Functions.
  825. * cospil: (libc)Trig Functions.
  826. * cpow: (libc)Exponents and Logarithms.
  827. * cpowf: (libc)Exponents and Logarithms.
  828. * cpowfN: (libc)Exponents and Logarithms.
  829. * cpowfNx: (libc)Exponents and Logarithms.
  830. * cpowl: (libc)Exponents and Logarithms.
  831. * cproj: (libc)Operations on Complex.
  832. * cprojf: (libc)Operations on Complex.
  833. * cprojfN: (libc)Operations on Complex.
  834. * cprojfNx: (libc)Operations on Complex.
  835. * cprojl: (libc)Operations on Complex.
  836. * creal: (libc)Operations on Complex.
  837. * crealf: (libc)Operations on Complex.
  838. * crealfN: (libc)Operations on Complex.
  839. * crealfNx: (libc)Operations on Complex.
  840. * creall: (libc)Operations on Complex.
  841. * creat64: (libc)Opening and Closing Files.
  842. * creat: (libc)Opening and Closing Files.
  843. * csin: (libc)Trig Functions.
  844. * csinf: (libc)Trig Functions.
  845. * csinfN: (libc)Trig Functions.
  846. * csinfNx: (libc)Trig Functions.
  847. * csinh: (libc)Hyperbolic Functions.
  848. * csinhf: (libc)Hyperbolic Functions.
  849. * csinhfN: (libc)Hyperbolic Functions.
  850. * csinhfNx: (libc)Hyperbolic Functions.
  851. * csinhl: (libc)Hyperbolic Functions.
  852. * csinl: (libc)Trig Functions.
  853. * csqrt: (libc)Exponents and Logarithms.
  854. * csqrtf: (libc)Exponents and Logarithms.
  855. * csqrtfN: (libc)Exponents and Logarithms.
  856. * csqrtfNx: (libc)Exponents and Logarithms.
  857. * csqrtl: (libc)Exponents and Logarithms.
  858. * ctan: (libc)Trig Functions.
  859. * ctanf: (libc)Trig Functions.
  860. * ctanfN: (libc)Trig Functions.
  861. * ctanfNx: (libc)Trig Functions.
  862. * ctanh: (libc)Hyperbolic Functions.
  863. * ctanhf: (libc)Hyperbolic Functions.
  864. * ctanhfN: (libc)Hyperbolic Functions.
  865. * ctanhfNx: (libc)Hyperbolic Functions.
  866. * ctanhl: (libc)Hyperbolic Functions.
  867. * ctanl: (libc)Trig Functions.
  868. * ctermid: (libc)Identifying the Terminal.
  869. * ctime: (libc)Formatting Calendar Time.
  870. * ctime_r: (libc)Formatting Calendar Time.
  871. * cuserid: (libc)Who Logged In.
  872. * daddl: (libc)Misc FP Arithmetic.
  873. * dcgettext: (libc)Translation with gettext.
  874. * dcngettext: (libc)Advanced gettext functions.
  875. * ddivl: (libc)Misc FP Arithmetic.
  876. * dfmal: (libc)Misc FP Arithmetic.
  877. * dgettext: (libc)Translation with gettext.
  878. * difftime: (libc)Calculating Elapsed Time.
  879. * dirfd: (libc)Opening a Directory.
  880. * dirname: (libc)Finding Tokens in a String.
  881. * div: (libc)Integer Division.
  882. * dlinfo: (libc)Dynamic Linker Introspection.
  883. * dmull: (libc)Misc FP Arithmetic.
  884. * dngettext: (libc)Advanced gettext functions.
  885. * dprintf: (libc)Formatted Output Functions.
  886. * drand48: (libc)SVID Random.
  887. * drand48_r: (libc)SVID Random.
  888. * drem: (libc)Remainder Functions.
  889. * dremf: (libc)Remainder Functions.
  890. * dreml: (libc)Remainder Functions.
  891. * dsqrtl: (libc)Misc FP Arithmetic.
  892. * dsubl: (libc)Misc FP Arithmetic.
  893. * dup2: (libc)Duplicating Descriptors.
  894. * dup3: (libc)Duplicating Descriptors.
  895. * dup: (libc)Duplicating Descriptors.
  896. * ecvt: (libc)System V Number Conversion.
  897. * ecvt_r: (libc)System V Number Conversion.
  898. * endfsent: (libc)fstab.
  899. * endgrent: (libc)Scanning All Groups.
  900. * endhostent: (libc)Host Names.
  901. * endmntent: (libc)mtab.
  902. * endnetent: (libc)Networks Database.
  903. * endnetgrent: (libc)Lookup Netgroup.
  904. * endprotoent: (libc)Protocols Database.
  905. * endpwent: (libc)Scanning All Users.
  906. * endservent: (libc)Services Database.
  907. * endutent: (libc)Manipulating the Database.
  908. * endutxent: (libc)XPG Functions.
  909. * envz_add: (libc)Envz Functions.
  910. * envz_entry: (libc)Envz Functions.
  911. * envz_get: (libc)Envz Functions.
  912. * envz_merge: (libc)Envz Functions.
  913. * envz_remove: (libc)Envz Functions.
  914. * envz_strip: (libc)Envz Functions.
  915. * epoll_create: (libc)Other Low-Level I/O APIs.
  916. * epoll_wait: (libc)Other Low-Level I/O APIs.
  917. * erand48: (libc)SVID Random.
  918. * erand48_r: (libc)SVID Random.
  919. * erf: (libc)Special Functions.
  920. * erfc: (libc)Special Functions.
  921. * erfcf: (libc)Special Functions.
  922. * erfcfN: (libc)Special Functions.
  923. * erfcfNx: (libc)Special Functions.
  924. * erfcl: (libc)Special Functions.
  925. * erff: (libc)Special Functions.
  926. * erffN: (libc)Special Functions.
  927. * erffNx: (libc)Special Functions.
  928. * erfl: (libc)Special Functions.
  929. * err: (libc)Error Messages.
  930. * errno: (libc)Checking for Errors.
  931. * error: (libc)Error Messages.
  932. * error_at_line: (libc)Error Messages.
  933. * errx: (libc)Error Messages.
  934. * execl: (libc)Executing a File.
  935. * execle: (libc)Executing a File.
  936. * execlp: (libc)Executing a File.
  937. * execv: (libc)Executing a File.
  938. * execve: (libc)Executing a File.
  939. * execvp: (libc)Executing a File.
  940. * exit: (libc)Normal Termination.
  941. * exp10: (libc)Exponents and Logarithms.
  942. * exp10f: (libc)Exponents and Logarithms.
  943. * exp10fN: (libc)Exponents and Logarithms.
  944. * exp10fNx: (libc)Exponents and Logarithms.
  945. * exp10l: (libc)Exponents and Logarithms.
  946. * exp10m1: (libc)Exponents and Logarithms.
  947. * exp10m1f: (libc)Exponents and Logarithms.
  948. * exp10m1fN: (libc)Exponents and Logarithms.
  949. * exp10m1fNx: (libc)Exponents and Logarithms.
  950. * exp10m1l: (libc)Exponents and Logarithms.
  951. * exp2: (libc)Exponents and Logarithms.
  952. * exp2f: (libc)Exponents and Logarithms.
  953. * exp2fN: (libc)Exponents and Logarithms.
  954. * exp2fNx: (libc)Exponents and Logarithms.
  955. * exp2l: (libc)Exponents and Logarithms.
  956. * exp2m1: (libc)Exponents and Logarithms.
  957. * exp2m1f: (libc)Exponents and Logarithms.
  958. * exp2m1fN: (libc)Exponents and Logarithms.
  959. * exp2m1fNx: (libc)Exponents and Logarithms.
  960. * exp2m1l: (libc)Exponents and Logarithms.
  961. * exp: (libc)Exponents and Logarithms.
  962. * expf: (libc)Exponents and Logarithms.
  963. * expfN: (libc)Exponents and Logarithms.
  964. * expfNx: (libc)Exponents and Logarithms.
  965. * expl: (libc)Exponents and Logarithms.
  966. * explicit_bzero: (libc)Erasing Sensitive Data.
  967. * expm1: (libc)Exponents and Logarithms.
  968. * expm1f: (libc)Exponents and Logarithms.
  969. * expm1fN: (libc)Exponents and Logarithms.
  970. * expm1fNx: (libc)Exponents and Logarithms.
  971. * expm1l: (libc)Exponents and Logarithms.
  972. * fMaddfN: (libc)Misc FP Arithmetic.
  973. * fMaddfNx: (libc)Misc FP Arithmetic.
  974. * fMdivfN: (libc)Misc FP Arithmetic.
  975. * fMdivfNx: (libc)Misc FP Arithmetic.
  976. * fMfmafN: (libc)Misc FP Arithmetic.
  977. * fMfmafNx: (libc)Misc FP Arithmetic.
  978. * fMmulfN: (libc)Misc FP Arithmetic.
  979. * fMmulfNx: (libc)Misc FP Arithmetic.
  980. * fMsqrtfN: (libc)Misc FP Arithmetic.
  981. * fMsqrtfNx: (libc)Misc FP Arithmetic.
  982. * fMsubfN: (libc)Misc FP Arithmetic.
  983. * fMsubfNx: (libc)Misc FP Arithmetic.
  984. * fMxaddfN: (libc)Misc FP Arithmetic.
  985. * fMxaddfNx: (libc)Misc FP Arithmetic.
  986. * fMxdivfN: (libc)Misc FP Arithmetic.
  987. * fMxdivfNx: (libc)Misc FP Arithmetic.
  988. * fMxfmafN: (libc)Misc FP Arithmetic.
  989. * fMxfmafNx: (libc)Misc FP Arithmetic.
  990. * fMxmulfN: (libc)Misc FP Arithmetic.
  991. * fMxmulfNx: (libc)Misc FP Arithmetic.
  992. * fMxsqrtfN: (libc)Misc FP Arithmetic.
  993. * fMxsqrtfNx: (libc)Misc FP Arithmetic.
  994. * fMxsubfN: (libc)Misc FP Arithmetic.
  995. * fMxsubfNx: (libc)Misc FP Arithmetic.
  996. * fabs: (libc)Absolute Value.
  997. * fabsf: (libc)Absolute Value.
  998. * fabsfN: (libc)Absolute Value.
  999. * fabsfNx: (libc)Absolute Value.
  1000. * fabsl: (libc)Absolute Value.
  1001. * faccessat: (libc)Testing File Access.
  1002. * fadd: (libc)Misc FP Arithmetic.
  1003. * faddl: (libc)Misc FP Arithmetic.
  1004. * fchdir: (libc)Working Directory.
  1005. * fchmod: (libc)Setting Permissions.
  1006. * fchown: (libc)File Owner.
  1007. * fclose: (libc)Closing Streams.
  1008. * fcloseall: (libc)Closing Streams.
  1009. * fcntl: (libc)Control Operations.
  1010. * fcvt: (libc)System V Number Conversion.
  1011. * fcvt_r: (libc)System V Number Conversion.
  1012. * fdatasync: (libc)Synchronizing I/O.
  1013. * fdim: (libc)Misc FP Arithmetic.
  1014. * fdimf: (libc)Misc FP Arithmetic.
  1015. * fdimfN: (libc)Misc FP Arithmetic.
  1016. * fdimfNx: (libc)Misc FP Arithmetic.
  1017. * fdiml: (libc)Misc FP Arithmetic.
  1018. * fdiv: (libc)Misc FP Arithmetic.
  1019. * fdivl: (libc)Misc FP Arithmetic.
  1020. * fdopen: (libc)Descriptors and Streams.
  1021. * fdopendir: (libc)Opening a Directory.
  1022. * feclearexcept: (libc)Status bit operations.
  1023. * fedisableexcept: (libc)Control Functions.
  1024. * feenableexcept: (libc)Control Functions.
  1025. * fegetenv: (libc)Control Functions.
  1026. * fegetexcept: (libc)Control Functions.
  1027. * fegetexceptflag: (libc)Status bit operations.
  1028. * fegetmode: (libc)Control Functions.
  1029. * fegetround: (libc)Rounding.
  1030. * feholdexcept: (libc)Control Functions.
  1031. * feof: (libc)EOF and Errors.
  1032. * feof_unlocked: (libc)EOF and Errors.
  1033. * feraiseexcept: (libc)Status bit operations.
  1034. * ferror: (libc)EOF and Errors.
  1035. * ferror_unlocked: (libc)EOF and Errors.
  1036. * fesetenv: (libc)Control Functions.
  1037. * fesetexcept: (libc)Status bit operations.
  1038. * fesetexceptflag: (libc)Status bit operations.
  1039. * fesetmode: (libc)Control Functions.
  1040. * fesetround: (libc)Rounding.
  1041. * fetestexcept: (libc)Status bit operations.
  1042. * fetestexceptflag: (libc)Status bit operations.
  1043. * feupdateenv: (libc)Control Functions.
  1044. * fexecve: (libc)Executing a File.
  1045. * fflush: (libc)Flushing Buffers.
  1046. * fflush_unlocked: (libc)Flushing Buffers.
  1047. * ffma: (libc)Misc FP Arithmetic.
  1048. * ffmal: (libc)Misc FP Arithmetic.
  1049. * fgetc: (libc)Character Input.
  1050. * fgetc_unlocked: (libc)Character Input.
  1051. * fgetgrent: (libc)Scanning All Groups.
  1052. * fgetgrent_r: (libc)Scanning All Groups.
  1053. * fgetpos64: (libc)Portable Positioning.
  1054. * fgetpos: (libc)Portable Positioning.
  1055. * fgetpwent: (libc)Scanning All Users.
  1056. * fgetpwent_r: (libc)Scanning All Users.
  1057. * fgets: (libc)Line Input.
  1058. * fgets_unlocked: (libc)Line Input.
  1059. * fgetwc: (libc)Character Input.
  1060. * fgetwc_unlocked: (libc)Character Input.
  1061. * fgetws: (libc)Line Input.
  1062. * fgetws_unlocked: (libc)Line Input.
  1063. * fileno: (libc)Descriptors and Streams.
  1064. * fileno_unlocked: (libc)Descriptors and Streams.
  1065. * finite: (libc)Floating Point Classes.
  1066. * finitef: (libc)Floating Point Classes.
  1067. * finitel: (libc)Floating Point Classes.
  1068. * flockfile: (libc)Streams and Threads.
  1069. * floor: (libc)Rounding Functions.
  1070. * floorf: (libc)Rounding Functions.
  1071. * floorfN: (libc)Rounding Functions.
  1072. * floorfNx: (libc)Rounding Functions.
  1073. * floorl: (libc)Rounding Functions.
  1074. * fma: (libc)Misc FP Arithmetic.
  1075. * fmaf: (libc)Misc FP Arithmetic.
  1076. * fmafN: (libc)Misc FP Arithmetic.
  1077. * fmafNx: (libc)Misc FP Arithmetic.
  1078. * fmal: (libc)Misc FP Arithmetic.
  1079. * fmax: (libc)Misc FP Arithmetic.
  1080. * fmaxf: (libc)Misc FP Arithmetic.
  1081. * fmaxfN: (libc)Misc FP Arithmetic.
  1082. * fmaxfNx: (libc)Misc FP Arithmetic.
  1083. * fmaximum: (libc)Misc FP Arithmetic.
  1084. * fmaximum_mag: (libc)Misc FP Arithmetic.
  1085. * fmaximum_mag_num: (libc)Misc FP Arithmetic.
  1086. * fmaximum_mag_numf: (libc)Misc FP Arithmetic.
  1087. * fmaximum_mag_numfN: (libc)Misc FP Arithmetic.
  1088. * fmaximum_mag_numfNx: (libc)Misc FP Arithmetic.
  1089. * fmaximum_mag_numl: (libc)Misc FP Arithmetic.
  1090. * fmaximum_magf: (libc)Misc FP Arithmetic.
  1091. * fmaximum_magfN: (libc)Misc FP Arithmetic.
  1092. * fmaximum_magfNx: (libc)Misc FP Arithmetic.
  1093. * fmaximum_magl: (libc)Misc FP Arithmetic.
  1094. * fmaximum_num: (libc)Misc FP Arithmetic.
  1095. * fmaximum_numf: (libc)Misc FP Arithmetic.
  1096. * fmaximum_numfN: (libc)Misc FP Arithmetic.
  1097. * fmaximum_numfNx: (libc)Misc FP Arithmetic.
  1098. * fmaximum_numl: (libc)Misc FP Arithmetic.
  1099. * fmaximumf: (libc)Misc FP Arithmetic.
  1100. * fmaximumfN: (libc)Misc FP Arithmetic.
  1101. * fmaximumfNx: (libc)Misc FP Arithmetic.
  1102. * fmaximuml: (libc)Misc FP Arithmetic.
  1103. * fmaxl: (libc)Misc FP Arithmetic.
  1104. * fmaxmag: (libc)Misc FP Arithmetic.
  1105. * fmaxmagf: (libc)Misc FP Arithmetic.
  1106. * fmaxmagfN: (libc)Misc FP Arithmetic.
  1107. * fmaxmagfNx: (libc)Misc FP Arithmetic.
  1108. * fmaxmagl: (libc)Misc FP Arithmetic.
  1109. * fmemopen: (libc)String Streams.
  1110. * fmin: (libc)Misc FP Arithmetic.
  1111. * fminf: (libc)Misc FP Arithmetic.
  1112. * fminfN: (libc)Misc FP Arithmetic.
  1113. * fminfNx: (libc)Misc FP Arithmetic.
  1114. * fminimum: (libc)Misc FP Arithmetic.
  1115. * fminimum_mag: (libc)Misc FP Arithmetic.
  1116. * fminimum_mag_num: (libc)Misc FP Arithmetic.
  1117. * fminimum_mag_numf: (libc)Misc FP Arithmetic.
  1118. * fminimum_mag_numfN: (libc)Misc FP Arithmetic.
  1119. * fminimum_mag_numfNx: (libc)Misc FP Arithmetic.
  1120. * fminimum_mag_numl: (libc)Misc FP Arithmetic.
  1121. * fminimum_magf: (libc)Misc FP Arithmetic.
  1122. * fminimum_magfN: (libc)Misc FP Arithmetic.
  1123. * fminimum_magfNx: (libc)Misc FP Arithmetic.
  1124. * fminimum_magl: (libc)Misc FP Arithmetic.
  1125. * fminimum_num: (libc)Misc FP Arithmetic.
  1126. * fminimum_numf: (libc)Misc FP Arithmetic.
  1127. * fminimum_numfN: (libc)Misc FP Arithmetic.
  1128. * fminimum_numfNx: (libc)Misc FP Arithmetic.
  1129. * fminimum_numl: (libc)Misc FP Arithmetic.
  1130. * fminimumf: (libc)Misc FP Arithmetic.
  1131. * fminimumfN: (libc)Misc FP Arithmetic.
  1132. * fminimumfNx: (libc)Misc FP Arithmetic.
  1133. * fminimuml: (libc)Misc FP Arithmetic.
  1134. * fminl: (libc)Misc FP Arithmetic.
  1135. * fminmag: (libc)Misc FP Arithmetic.
  1136. * fminmagf: (libc)Misc FP Arithmetic.
  1137. * fminmagfN: (libc)Misc FP Arithmetic.
  1138. * fminmagfNx: (libc)Misc FP Arithmetic.
  1139. * fminmagl: (libc)Misc FP Arithmetic.
  1140. * fmod: (libc)Remainder Functions.
  1141. * fmodf: (libc)Remainder Functions.
  1142. * fmodfN: (libc)Remainder Functions.
  1143. * fmodfNx: (libc)Remainder Functions.
  1144. * fmodl: (libc)Remainder Functions.
  1145. * fmtmsg: (libc)Printing Formatted Messages.
  1146. * fmul: (libc)Misc FP Arithmetic.
  1147. * fmull: (libc)Misc FP Arithmetic.
  1148. * fnmatch: (libc)Wildcard Matching.
  1149. * fopen64: (libc)Opening Streams.
  1150. * fopen: (libc)Opening Streams.
  1151. * fopencookie: (libc)Streams and Cookies.
  1152. * fork: (libc)Creating a Process.
  1153. * forkpty: (libc)Pseudo-Terminal Pairs.
  1154. * fpathconf: (libc)Pathconf.
  1155. * fpclassify: (libc)Floating Point Classes.
  1156. * fprintf: (libc)Formatted Output Functions.
  1157. * fputc: (libc)Simple Output.
  1158. * fputc_unlocked: (libc)Simple Output.
  1159. * fputs: (libc)Simple Output.
  1160. * fputs_unlocked: (libc)Simple Output.
  1161. * fputwc: (libc)Simple Output.
  1162. * fputwc_unlocked: (libc)Simple Output.
  1163. * fputws: (libc)Simple Output.
  1164. * fputws_unlocked: (libc)Simple Output.
  1165. * fread: (libc)Block Input/Output.
  1166. * fread_unlocked: (libc)Block Input/Output.
  1167. * free: (libc)Freeing after Malloc.
  1168. * free_aligned_sized: (libc)Freeing after Malloc.
  1169. * free_sized: (libc)Freeing after Malloc.
  1170. * freopen64: (libc)Opening Streams.
  1171. * freopen: (libc)Opening Streams.
  1172. * frexp: (libc)Normalization Functions.
  1173. * frexpf: (libc)Normalization Functions.
  1174. * frexpfN: (libc)Normalization Functions.
  1175. * frexpfNx: (libc)Normalization Functions.
  1176. * frexpl: (libc)Normalization Functions.
  1177. * fromfp: (libc)Rounding Functions.
  1178. * fromfpf: (libc)Rounding Functions.
  1179. * fromfpfN: (libc)Rounding Functions.
  1180. * fromfpfNx: (libc)Rounding Functions.
  1181. * fromfpl: (libc)Rounding Functions.
  1182. * fromfpx: (libc)Rounding Functions.
  1183. * fromfpxf: (libc)Rounding Functions.
  1184. * fromfpxfN: (libc)Rounding Functions.
  1185. * fromfpxfNx: (libc)Rounding Functions.
  1186. * fromfpxl: (libc)Rounding Functions.
  1187. * fscanf: (libc)Formatted Input Functions.
  1188. * fseek: (libc)File Positioning.
  1189. * fseeko64: (libc)File Positioning.
  1190. * fseeko: (libc)File Positioning.
  1191. * fsetpos64: (libc)Portable Positioning.
  1192. * fsetpos: (libc)Portable Positioning.
  1193. * fsqrt: (libc)Misc FP Arithmetic.
  1194. * fsqrtl: (libc)Misc FP Arithmetic.
  1195. * fstat64: (libc)Reading Attributes.
  1196. * fstat: (libc)Reading Attributes.
  1197. * fstatat64: (libc)Reading Attributes.
  1198. * fstatat: (libc)Reading Attributes.
  1199. * fsub: (libc)Misc FP Arithmetic.
  1200. * fsubl: (libc)Misc FP Arithmetic.
  1201. * fsync: (libc)Synchronizing I/O.
  1202. * ftell: (libc)File Positioning.
  1203. * ftello64: (libc)File Positioning.
  1204. * ftello: (libc)File Positioning.
  1205. * ftruncate64: (libc)File Size.
  1206. * ftruncate: (libc)File Size.
  1207. * ftrylockfile: (libc)Streams and Threads.
  1208. * ftw64: (libc)Working with Directory Trees.
  1209. * ftw: (libc)Working with Directory Trees.
  1210. * funlockfile: (libc)Streams and Threads.
  1211. * futimens: (libc)File Times.
  1212. * futimes: (libc)File Times.
  1213. * fwide: (libc)Streams and I18N.
  1214. * fwprintf: (libc)Formatted Output Functions.
  1215. * fwrite: (libc)Block Input/Output.
  1216. * fwrite_unlocked: (libc)Block Input/Output.
  1217. * fwscanf: (libc)Formatted Input Functions.
  1218. * gamma: (libc)Special Functions.
  1219. * gammaf: (libc)Special Functions.
  1220. * gammal: (libc)Special Functions.
  1221. * gcvt: (libc)System V Number Conversion.
  1222. * get_avphys_pages: (libc)Query Memory Parameters.
  1223. * get_current_dir_name: (libc)Working Directory.
  1224. * get_nprocs: (libc)Processor Resources.
  1225. * get_nprocs_conf: (libc)Processor Resources.
  1226. * get_phys_pages: (libc)Query Memory Parameters.
  1227. * getauxval: (libc)Auxiliary Vector.
  1228. * getc: (libc)Character Input.
  1229. * getc_unlocked: (libc)Character Input.
  1230. * getchar: (libc)Character Input.
  1231. * getchar_unlocked: (libc)Character Input.
  1232. * getcontext: (libc)System V contexts.
  1233. * getcpu: (libc)CPU Affinity.
  1234. * getcwd: (libc)Working Directory.
  1235. * getdate: (libc)General Time String Parsing.
  1236. * getdate_r: (libc)General Time String Parsing.
  1237. * getdelim: (libc)Line Input.
  1238. * getdents64: (libc)Low-level Directory Access.
  1239. * getdomainname: (libc)Host Identification.
  1240. * getegid: (libc)Reading Persona.
  1241. * getentropy: (libc)Unpredictable Bytes.
  1242. * getenv: (libc)Environment Access.
  1243. * geteuid: (libc)Reading Persona.
  1244. * getfsent: (libc)fstab.
  1245. * getfsfile: (libc)fstab.
  1246. * getfsspec: (libc)fstab.
  1247. * getgid: (libc)Reading Persona.
  1248. * getgrent: (libc)Scanning All Groups.
  1249. * getgrent_r: (libc)Scanning All Groups.
  1250. * getgrgid: (libc)Lookup Group.
  1251. * getgrgid_r: (libc)Lookup Group.
  1252. * getgrnam: (libc)Lookup Group.
  1253. * getgrnam_r: (libc)Lookup Group.
  1254. * getgrouplist: (libc)Setting Groups.
  1255. * getgroups: (libc)Reading Persona.
  1256. * gethostbyaddr: (libc)Host Names.
  1257. * gethostbyaddr_r: (libc)Host Names.
  1258. * gethostbyname2: (libc)Host Names.
  1259. * gethostbyname2_r: (libc)Host Names.
  1260. * gethostbyname: (libc)Host Names.
  1261. * gethostbyname_r: (libc)Host Names.
  1262. * gethostent: (libc)Host Names.
  1263. * gethostid: (libc)Host Identification.
  1264. * gethostname: (libc)Host Identification.
  1265. * getitimer: (libc)Setting an Alarm.
  1266. * getline: (libc)Line Input.
  1267. * getloadavg: (libc)Processor Resources.
  1268. * getlogin: (libc)Who Logged In.
  1269. * getmntent: (libc)mtab.
  1270. * getmntent_r: (libc)mtab.
  1271. * getnetbyaddr: (libc)Networks Database.
  1272. * getnetbyname: (libc)Networks Database.
  1273. * getnetent: (libc)Networks Database.
  1274. * getnetgrent: (libc)Lookup Netgroup.
  1275. * getnetgrent_r: (libc)Lookup Netgroup.
  1276. * getopt: (libc)Using Getopt.
  1277. * getopt_long: (libc)Getopt Long Options.
  1278. * getopt_long_only: (libc)Getopt Long Options.
  1279. * getpagesize: (libc)Query Memory Parameters.
  1280. * getpass: (libc)getpass.
  1281. * getpayload: (libc)FP Bit Twiddling.
  1282. * getpayloadf: (libc)FP Bit Twiddling.
  1283. * getpayloadfN: (libc)FP Bit Twiddling.
  1284. * getpayloadfNx: (libc)FP Bit Twiddling.
  1285. * getpayloadl: (libc)FP Bit Twiddling.
  1286. * getpeername: (libc)Who is Connected.
  1287. * getpgid: (libc)Process Group Functions.
  1288. * getpgrp: (libc)Process Group Functions.
  1289. * getpid: (libc)Process Identification.
  1290. * getppid: (libc)Process Identification.
  1291. * getpriority: (libc)Traditional Scheduling Functions.
  1292. * getprotobyname: (libc)Protocols Database.
  1293. * getprotobynumber: (libc)Protocols Database.
  1294. * getprotoent: (libc)Protocols Database.
  1295. * getpt: (libc)Allocation.
  1296. * getpwent: (libc)Scanning All Users.
  1297. * getpwent_r: (libc)Scanning All Users.
  1298. * getpwnam: (libc)Lookup User.
  1299. * getpwnam_r: (libc)Lookup User.
  1300. * getpwuid: (libc)Lookup User.
  1301. * getpwuid_r: (libc)Lookup User.
  1302. * getrandom: (libc)Unpredictable Bytes.
  1303. * getrlimit64: (libc)Limits on Resources.
  1304. * getrlimit: (libc)Limits on Resources.
  1305. * getrusage: (libc)Resource Usage.
  1306. * gets: (libc)Line Input.
  1307. * getservbyname: (libc)Services Database.
  1308. * getservbyport: (libc)Services Database.
  1309. * getservent: (libc)Services Database.
  1310. * getsid: (libc)Process Group Functions.
  1311. * getsockname: (libc)Reading Address.
  1312. * getsockopt: (libc)Socket Option Functions.
  1313. * getsubopt: (libc)Suboptions.
  1314. * gettext: (libc)Translation with gettext.
  1315. * gettid: (libc)Process Identification.
  1316. * gettimeofday: (libc)Getting the Time.
  1317. * getuid: (libc)Reading Persona.
  1318. * getumask: (libc)Setting Permissions.
  1319. * getutent: (libc)Manipulating the Database.
  1320. * getutent_r: (libc)Manipulating the Database.
  1321. * getutid: (libc)Manipulating the Database.
  1322. * getutid_r: (libc)Manipulating the Database.
  1323. * getutline: (libc)Manipulating the Database.
  1324. * getutline_r: (libc)Manipulating the Database.
  1325. * getutmp: (libc)XPG Functions.
  1326. * getutmpx: (libc)XPG Functions.
  1327. * getutxent: (libc)XPG Functions.
  1328. * getutxid: (libc)XPG Functions.
  1329. * getutxline: (libc)XPG Functions.
  1330. * getw: (libc)Character Input.
  1331. * getwc: (libc)Character Input.
  1332. * getwc_unlocked: (libc)Character Input.
  1333. * getwchar: (libc)Character Input.
  1334. * getwchar_unlocked: (libc)Character Input.
  1335. * getwd: (libc)Working Directory.
  1336. * glob64: (libc)Calling Glob.
  1337. * glob: (libc)Calling Glob.
  1338. * globfree64: (libc)More Flags for Globbing.
  1339. * globfree: (libc)More Flags for Globbing.
  1340. * gmtime: (libc)Broken-down Time.
  1341. * gmtime_r: (libc)Broken-down Time.
  1342. * grantpt: (libc)Allocation.
  1343. * gsignal: (libc)Signaling Yourself.
  1344. * gtty: (libc)BSD Terminal Modes.
  1345. * hasmntopt: (libc)mtab.
  1346. * hcreate: (libc)Hash Search Function.
  1347. * hcreate_r: (libc)Hash Search Function.
  1348. * hdestroy: (libc)Hash Search Function.
  1349. * hdestroy_r: (libc)Hash Search Function.
  1350. * hsearch: (libc)Hash Search Function.
  1351. * hsearch_r: (libc)Hash Search Function.
  1352. * htonl: (libc)Byte Order.
  1353. * htons: (libc)Byte Order.
  1354. * hypot: (libc)Exponents and Logarithms.
  1355. * hypotf: (libc)Exponents and Logarithms.
  1356. * hypotfN: (libc)Exponents and Logarithms.
  1357. * hypotfNx: (libc)Exponents and Logarithms.
  1358. * hypotl: (libc)Exponents and Logarithms.
  1359. * iconv: (libc)Generic Conversion Interface.
  1360. * iconv_close: (libc)Generic Conversion Interface.
  1361. * iconv_open: (libc)Generic Conversion Interface.
  1362. * if_freenameindex: (libc)Interface Naming.
  1363. * if_indextoname: (libc)Interface Naming.
  1364. * if_nameindex: (libc)Interface Naming.
  1365. * if_nametoindex: (libc)Interface Naming.
  1366. * ilogb: (libc)Exponents and Logarithms.
  1367. * ilogbf: (libc)Exponents and Logarithms.
  1368. * ilogbfN: (libc)Exponents and Logarithms.
  1369. * ilogbfNx: (libc)Exponents and Logarithms.
  1370. * ilogbl: (libc)Exponents and Logarithms.
  1371. * imaxabs: (libc)Absolute Value.
  1372. * imaxdiv: (libc)Integer Division.
  1373. * in6addr_any: (libc)Host Address Data Type.
  1374. * in6addr_loopback: (libc)Host Address Data Type.
  1375. * index: (libc)Search Functions.
  1376. * inet_addr: (libc)Host Address Functions.
  1377. * inet_aton: (libc)Host Address Functions.
  1378. * inet_lnaof: (libc)Host Address Functions.
  1379. * inet_makeaddr: (libc)Host Address Functions.
  1380. * inet_netof: (libc)Host Address Functions.
  1381. * inet_network: (libc)Host Address Functions.
  1382. * inet_ntoa: (libc)Host Address Functions.
  1383. * inet_ntop: (libc)Host Address Functions.
  1384. * inet_pton: (libc)Host Address Functions.
  1385. * initgroups: (libc)Setting Groups.
  1386. * initstate: (libc)BSD Random.
  1387. * initstate_r: (libc)BSD Random.
  1388. * innetgr: (libc)Netgroup Membership.
  1389. * ioctl: (libc)IOCTLs.
  1390. * isalnum: (libc)Classification of Characters.
  1391. * isalpha: (libc)Classification of Characters.
  1392. * isascii: (libc)Classification of Characters.
  1393. * isatty: (libc)Is It a Terminal.
  1394. * isblank: (libc)Classification of Characters.
  1395. * iscanonical: (libc)Floating Point Classes.
  1396. * iscntrl: (libc)Classification of Characters.
  1397. * isdigit: (libc)Classification of Characters.
  1398. * iseqsig: (libc)FP Comparison Functions.
  1399. * isfinite: (libc)Floating Point Classes.
  1400. * isgraph: (libc)Classification of Characters.
  1401. * isgreater: (libc)FP Comparison Functions.
  1402. * isgreaterequal: (libc)FP Comparison Functions.
  1403. * isinf: (libc)Floating Point Classes.
  1404. * isinff: (libc)Floating Point Classes.
  1405. * isinfl: (libc)Floating Point Classes.
  1406. * isless: (libc)FP Comparison Functions.
  1407. * islessequal: (libc)FP Comparison Functions.
  1408. * islessgreater: (libc)FP Comparison Functions.
  1409. * islower: (libc)Classification of Characters.
  1410. * isnan: (libc)Floating Point Classes.
  1411. * isnan: (libc)Floating Point Classes.
  1412. * isnanf: (libc)Floating Point Classes.
  1413. * isnanl: (libc)Floating Point Classes.
  1414. * isnormal: (libc)Floating Point Classes.
  1415. * isprint: (libc)Classification of Characters.
  1416. * ispunct: (libc)Classification of Characters.
  1417. * issignaling: (libc)Floating Point Classes.
  1418. * isspace: (libc)Classification of Characters.
  1419. * issubnormal: (libc)Floating Point Classes.
  1420. * isunordered: (libc)FP Comparison Functions.
  1421. * isupper: (libc)Classification of Characters.
  1422. * iswalnum: (libc)Classification of Wide Characters.
  1423. * iswalpha: (libc)Classification of Wide Characters.
  1424. * iswblank: (libc)Classification of Wide Characters.
  1425. * iswcntrl: (libc)Classification of Wide Characters.
  1426. * iswctype: (libc)Classification of Wide Characters.
  1427. * iswdigit: (libc)Classification of Wide Characters.
  1428. * iswgraph: (libc)Classification of Wide Characters.
  1429. * iswlower: (libc)Classification of Wide Characters.
  1430. * iswprint: (libc)Classification of Wide Characters.
  1431. * iswpunct: (libc)Classification of Wide Characters.
  1432. * iswspace: (libc)Classification of Wide Characters.
  1433. * iswupper: (libc)Classification of Wide Characters.
  1434. * iswxdigit: (libc)Classification of Wide Characters.
  1435. * isxdigit: (libc)Classification of Characters.
  1436. * iszero: (libc)Floating Point Classes.
  1437. * j0: (libc)Special Functions.
  1438. * j0f: (libc)Special Functions.
  1439. * j0fN: (libc)Special Functions.
  1440. * j0fNx: (libc)Special Functions.
  1441. * j0l: (libc)Special Functions.
  1442. * j1: (libc)Special Functions.
  1443. * j1f: (libc)Special Functions.
  1444. * j1fN: (libc)Special Functions.
  1445. * j1fNx: (libc)Special Functions.
  1446. * j1l: (libc)Special Functions.
  1447. * jn: (libc)Special Functions.
  1448. * jnf: (libc)Special Functions.
  1449. * jnfN: (libc)Special Functions.
  1450. * jnfNx: (libc)Special Functions.
  1451. * jnl: (libc)Special Functions.
  1452. * jrand48: (libc)SVID Random.
  1453. * jrand48_r: (libc)SVID Random.
  1454. * kill: (libc)Signaling Another Process.
  1455. * killpg: (libc)Signaling Another Process.
  1456. * l64a: (libc)Encode Binary Data.
  1457. * labs: (libc)Absolute Value.
  1458. * lcong48: (libc)SVID Random.
  1459. * lcong48_r: (libc)SVID Random.
  1460. * ldexp: (libc)Normalization Functions.
  1461. * ldexpf: (libc)Normalization Functions.
  1462. * ldexpfN: (libc)Normalization Functions.
  1463. * ldexpfNx: (libc)Normalization Functions.
  1464. * ldexpl: (libc)Normalization Functions.
  1465. * ldiv: (libc)Integer Division.
  1466. * lfind: (libc)Array Search Function.
  1467. * lgamma: (libc)Special Functions.
  1468. * lgamma_r: (libc)Special Functions.
  1469. * lgammaf: (libc)Special Functions.
  1470. * lgammafN: (libc)Special Functions.
  1471. * lgammafN_r: (libc)Special Functions.
  1472. * lgammafNx: (libc)Special Functions.
  1473. * lgammafNx_r: (libc)Special Functions.
  1474. * lgammaf_r: (libc)Special Functions.
  1475. * lgammal: (libc)Special Functions.
  1476. * lgammal_r: (libc)Special Functions.
  1477. * link: (libc)Hard Links.
  1478. * linkat: (libc)Hard Links.
  1479. * lio_listio64: (libc)Asynchronous Reads/Writes.
  1480. * lio_listio: (libc)Asynchronous Reads/Writes.
  1481. * listen: (libc)Listening.
  1482. * llabs: (libc)Absolute Value.
  1483. * lldiv: (libc)Integer Division.
  1484. * llogb: (libc)Exponents and Logarithms.
  1485. * llogbf: (libc)Exponents and Logarithms.
  1486. * llogbfN: (libc)Exponents and Logarithms.
  1487. * llogbfNx: (libc)Exponents and Logarithms.
  1488. * llogbl: (libc)Exponents and Logarithms.
  1489. * llrint: (libc)Rounding Functions.
  1490. * llrintf: (libc)Rounding Functions.
  1491. * llrintfN: (libc)Rounding Functions.
  1492. * llrintfNx: (libc)Rounding Functions.
  1493. * llrintl: (libc)Rounding Functions.
  1494. * llround: (libc)Rounding Functions.
  1495. * llroundf: (libc)Rounding Functions.
  1496. * llroundfN: (libc)Rounding Functions.
  1497. * llroundfNx: (libc)Rounding Functions.
  1498. * llroundl: (libc)Rounding Functions.
  1499. * localeconv: (libc)The Lame Way to Locale Data.
  1500. * localtime: (libc)Broken-down Time.
  1501. * localtime_r: (libc)Broken-down Time.
  1502. * log10: (libc)Exponents and Logarithms.
  1503. * log10f: (libc)Exponents and Logarithms.
  1504. * log10fN: (libc)Exponents and Logarithms.
  1505. * log10fNx: (libc)Exponents and Logarithms.
  1506. * log10l: (libc)Exponents and Logarithms.
  1507. * log10p1: (libc)Exponents and Logarithms.
  1508. * log10p1f: (libc)Exponents and Logarithms.
  1509. * log10p1fN: (libc)Exponents and Logarithms.
  1510. * log10p1fNx: (libc)Exponents and Logarithms.
  1511. * log10p1l: (libc)Exponents and Logarithms.
  1512. * log1p: (libc)Exponents and Logarithms.
  1513. * log1pf: (libc)Exponents and Logarithms.
  1514. * log1pfN: (libc)Exponents and Logarithms.
  1515. * log1pfNx: (libc)Exponents and Logarithms.
  1516. * log1pl: (libc)Exponents and Logarithms.
  1517. * log2: (libc)Exponents and Logarithms.
  1518. * log2f: (libc)Exponents and Logarithms.
  1519. * log2fN: (libc)Exponents and Logarithms.
  1520. * log2fNx: (libc)Exponents and Logarithms.
  1521. * log2l: (libc)Exponents and Logarithms.
  1522. * log2p1: (libc)Exponents and Logarithms.
  1523. * log2p1f: (libc)Exponents and Logarithms.
  1524. * log2p1fN: (libc)Exponents and Logarithms.
  1525. * log2p1fNx: (libc)Exponents and Logarithms.
  1526. * log2p1l: (libc)Exponents and Logarithms.
  1527. * log: (libc)Exponents and Logarithms.
  1528. * logb: (libc)Exponents and Logarithms.
  1529. * logbf: (libc)Exponents and Logarithms.
  1530. * logbfN: (libc)Exponents and Logarithms.
  1531. * logbfNx: (libc)Exponents and Logarithms.
  1532. * logbl: (libc)Exponents and Logarithms.
  1533. * logf: (libc)Exponents and Logarithms.
  1534. * logfN: (libc)Exponents and Logarithms.
  1535. * logfNx: (libc)Exponents and Logarithms.
  1536. * login: (libc)Logging In and Out.
  1537. * login_tty: (libc)Logging In and Out.
  1538. * logl: (libc)Exponents and Logarithms.
  1539. * logout: (libc)Logging In and Out.
  1540. * logp1: (libc)Exponents and Logarithms.
  1541. * logp1f: (libc)Exponents and Logarithms.
  1542. * logp1fN: (libc)Exponents and Logarithms.
  1543. * logp1fNx: (libc)Exponents and Logarithms.
  1544. * logp1l: (libc)Exponents and Logarithms.
  1545. * logwtmp: (libc)Logging In and Out.
  1546. * longjmp: (libc)Non-Local Details.
  1547. * lrand48: (libc)SVID Random.
  1548. * lrand48_r: (libc)SVID Random.
  1549. * lrint: (libc)Rounding Functions.
  1550. * lrintf: (libc)Rounding Functions.
  1551. * lrintfN: (libc)Rounding Functions.
  1552. * lrintfNx: (libc)Rounding Functions.
  1553. * lrintl: (libc)Rounding Functions.
  1554. * lround: (libc)Rounding Functions.
  1555. * lroundf: (libc)Rounding Functions.
  1556. * lroundfN: (libc)Rounding Functions.
  1557. * lroundfNx: (libc)Rounding Functions.
  1558. * lroundl: (libc)Rounding Functions.
  1559. * lsearch: (libc)Array Search Function.
  1560. * lseek64: (libc)File Position Primitive.
  1561. * lseek: (libc)File Position Primitive.
  1562. * lstat64: (libc)Reading Attributes.
  1563. * lstat: (libc)Reading Attributes.
  1564. * lutimes: (libc)File Times.
  1565. * madvise: (libc)Memory-mapped I/O.
  1566. * makecontext: (libc)System V contexts.
  1567. * mallinfo2: (libc)Statistics of Malloc.
  1568. * malloc: (libc)Basic Allocation.
  1569. * mallopt: (libc)Malloc Tunable Parameters.
  1570. * mblen: (libc)Non-reentrant Character Conversion.
  1571. * mbrlen: (libc)Converting a Character.
  1572. * mbrtowc: (libc)Converting a Character.
  1573. * mbsinit: (libc)Keeping the state.
  1574. * mbsnrtowcs: (libc)Converting Strings.
  1575. * mbsrtowcs: (libc)Converting Strings.
  1576. * mbstowcs: (libc)Non-reentrant String Conversion.
  1577. * mbtowc: (libc)Non-reentrant Character Conversion.
  1578. * mcheck: (libc)Heap Consistency Checking.
  1579. * memalign: (libc)Aligned Memory Blocks.
  1580. * memalignment: (libc)Aligned Memory Blocks.
  1581. * memccpy: (libc)Copying Strings and Arrays.
  1582. * memchr: (libc)Search Functions.
  1583. * memcmp: (libc)String/Array Comparison.
  1584. * memcpy: (libc)Copying Strings and Arrays.
  1585. * memfd_create: (libc)Memory-mapped I/O.
  1586. * memfrob: (libc)Obfuscating Data.
  1587. * memmem: (libc)Search Functions.
  1588. * memmove: (libc)Copying Strings and Arrays.
  1589. * mempcpy: (libc)Copying Strings and Arrays.
  1590. * memrchr: (libc)Search Functions.
  1591. * memset: (libc)Copying Strings and Arrays.
  1592. * memset_explicit: (libc)Erasing Sensitive Data.
  1593. * mkdir: (libc)Creating Directories.
  1594. * mkdirat: (libc)Creating Directories.
  1595. * mkdtemp: (libc)Temporary Files.
  1596. * mkfifo: (libc)FIFO Special Files.
  1597. * mknod: (libc)Making Special Files.
  1598. * mkstemp: (libc)Temporary Files.
  1599. * mktemp: (libc)Temporary Files.
  1600. * mktime: (libc)Broken-down Time.
  1601. * mlock2: (libc)Page Lock Functions.
  1602. * mlock: (libc)Page Lock Functions.
  1603. * mlockall: (libc)Page Lock Functions.
  1604. * mmap64: (libc)Memory-mapped I/O.
  1605. * mmap: (libc)Memory-mapped I/O.
  1606. * modf: (libc)Rounding Functions.
  1607. * modff: (libc)Rounding Functions.
  1608. * modffN: (libc)Rounding Functions.
  1609. * modffNx: (libc)Rounding Functions.
  1610. * modfl: (libc)Rounding Functions.
  1611. * mount: (libc)Mount-Unmount-Remount.
  1612. * mprobe: (libc)Heap Consistency Checking.
  1613. * mprotect: (libc)Memory Protection.
  1614. * mrand48: (libc)SVID Random.
  1615. * mrand48_r: (libc)SVID Random.
  1616. * mremap: (libc)Memory-mapped I/O.
  1617. * mseal: (libc)Memory Protection.
  1618. * msync: (libc)Memory-mapped I/O.
  1619. * mtrace: (libc)Tracing malloc.
  1620. * mtx_destroy: (libc)ISO C Mutexes.
  1621. * mtx_init: (libc)ISO C Mutexes.
  1622. * mtx_lock: (libc)ISO C Mutexes.
  1623. * mtx_timedlock: (libc)ISO C Mutexes.
  1624. * mtx_trylock: (libc)ISO C Mutexes.
  1625. * mtx_unlock: (libc)ISO C Mutexes.
  1626. * munlock: (libc)Page Lock Functions.
  1627. * munlockall: (libc)Page Lock Functions.
  1628. * munmap: (libc)Memory-mapped I/O.
  1629. * muntrace: (libc)Tracing malloc.
  1630. * nan: (libc)FP Bit Twiddling.
  1631. * nanf: (libc)FP Bit Twiddling.
  1632. * nanfN: (libc)FP Bit Twiddling.
  1633. * nanfNx: (libc)FP Bit Twiddling.
  1634. * nanl: (libc)FP Bit Twiddling.
  1635. * nanosleep: (libc)Sleeping.
  1636. * nearbyint: (libc)Rounding Functions.
  1637. * nearbyintf: (libc)Rounding Functions.
  1638. * nearbyintfN: (libc)Rounding Functions.
  1639. * nearbyintfNx: (libc)Rounding Functions.
  1640. * nearbyintl: (libc)Rounding Functions.
  1641. * nextafter: (libc)FP Bit Twiddling.
  1642. * nextafterf: (libc)FP Bit Twiddling.
  1643. * nextafterfN: (libc)FP Bit Twiddling.
  1644. * nextafterfNx: (libc)FP Bit Twiddling.
  1645. * nextafterl: (libc)FP Bit Twiddling.
  1646. * nextdown: (libc)FP Bit Twiddling.
  1647. * nextdownf: (libc)FP Bit Twiddling.
  1648. * nextdownfN: (libc)FP Bit Twiddling.
  1649. * nextdownfNx: (libc)FP Bit Twiddling.
  1650. * nextdownl: (libc)FP Bit Twiddling.
  1651. * nexttoward: (libc)FP Bit Twiddling.
  1652. * nexttowardf: (libc)FP Bit Twiddling.
  1653. * nexttowardl: (libc)FP Bit Twiddling.
  1654. * nextup: (libc)FP Bit Twiddling.
  1655. * nextupf: (libc)FP Bit Twiddling.
  1656. * nextupfN: (libc)FP Bit Twiddling.
  1657. * nextupfNx: (libc)FP Bit Twiddling.
  1658. * nextupl: (libc)FP Bit Twiddling.
  1659. * nftw64: (libc)Working with Directory Trees.
  1660. * nftw: (libc)Working with Directory Trees.
  1661. * ngettext: (libc)Advanced gettext functions.
  1662. * nice: (libc)Traditional Scheduling Functions.
  1663. * nl_langinfo: (libc)The Elegant and Fast Way.
  1664. * nrand48: (libc)SVID Random.
  1665. * nrand48_r: (libc)SVID Random.
  1666. * ntohl: (libc)Byte Order.
  1667. * ntohs: (libc)Byte Order.
  1668. * ntp_adjtime: (libc)Setting and Adjusting the Time.
  1669. * ntp_gettime: (libc)Setting and Adjusting the Time.
  1670. * obstack_1grow: (libc)Growing Objects.
  1671. * obstack_1grow_fast: (libc)Extra Fast Growing.
  1672. * obstack_alignment_mask: (libc)Obstacks Data Alignment.
  1673. * obstack_alloc: (libc)Allocation in an Obstack.
  1674. * obstack_base: (libc)Status of an Obstack.
  1675. * obstack_blank: (libc)Growing Objects.
  1676. * obstack_blank_fast: (libc)Extra Fast Growing.
  1677. * obstack_chunk_size: (libc)Obstack Chunks.
  1678. * obstack_copy0: (libc)Allocation in an Obstack.
  1679. * obstack_copy: (libc)Allocation in an Obstack.
  1680. * obstack_finish: (libc)Growing Objects.
  1681. * obstack_free: (libc)Freeing Obstack Objects.
  1682. * obstack_grow0: (libc)Growing Objects.
  1683. * obstack_grow: (libc)Growing Objects.
  1684. * obstack_init: (libc)Preparing for Obstacks.
  1685. * obstack_int_grow: (libc)Growing Objects.
  1686. * obstack_int_grow_fast: (libc)Extra Fast Growing.
  1687. * obstack_next_free: (libc)Status of an Obstack.
  1688. * obstack_object_size: (libc)Growing Objects.
  1689. * obstack_object_size: (libc)Status of an Obstack.
  1690. * obstack_printf: (libc)Dynamic Output.
  1691. * obstack_ptr_grow: (libc)Growing Objects.
  1692. * obstack_ptr_grow_fast: (libc)Extra Fast Growing.
  1693. * obstack_room: (libc)Extra Fast Growing.
  1694. * obstack_vprintf: (libc)Variable Arguments Output.
  1695. * offsetof: (libc)Structure Measurement.
  1696. * on_exit: (libc)Cleanups on Exit.
  1697. * open64: (libc)Opening and Closing Files.
  1698. * open: (libc)Opening and Closing Files.
  1699. * open_memstream: (libc)String Streams.
  1700. * openat2: (libc)Opening and Closing Files.
  1701. * openat64: (libc)Opening and Closing Files.
  1702. * openat: (libc)Opening and Closing Files.
  1703. * opendir: (libc)Opening a Directory.
  1704. * openlog: (libc)openlog.
  1705. * openpty: (libc)Pseudo-Terminal Pairs.
  1706. * parse_printf_format: (libc)Parsing a Template String.
  1707. * pathconf: (libc)Pathconf.
  1708. * pause: (libc)Using Pause.
  1709. * pclose: (libc)Pipe to a Subprocess.
  1710. * perror: (libc)Error Messages.
  1711. * pidfd_getpid: (libc)Querying a Process.
  1712. * pipe: (libc)Creating a Pipe.
  1713. * pkey_alloc: (libc)Memory Protection.
  1714. * pkey_free: (libc)Memory Protection.
  1715. * pkey_get: (libc)Memory Protection.
  1716. * pkey_mprotect: (libc)Memory Protection.
  1717. * pkey_set: (libc)Memory Protection.
  1718. * poll: (libc)Other Low-Level I/O APIs.
  1719. * popen: (libc)Pipe to a Subprocess.
  1720. * posix_fallocate64: (libc)Storage Allocation.
  1721. * posix_fallocate: (libc)Storage Allocation.
  1722. * posix_memalign: (libc)Aligned Memory Blocks.
  1723. * posix_openpt: (libc)Allocation.
  1724. * pow: (libc)Exponents and Logarithms.
  1725. * powf: (libc)Exponents and Logarithms.
  1726. * powfN: (libc)Exponents and Logarithms.
  1727. * powfNx: (libc)Exponents and Logarithms.
  1728. * powl: (libc)Exponents and Logarithms.
  1729. * pown: (libc)Exponents and Logarithms.
  1730. * pownf: (libc)Exponents and Logarithms.
  1731. * pownfN: (libc)Exponents and Logarithms.
  1732. * pownfNx: (libc)Exponents and Logarithms.
  1733. * pownl: (libc)Exponents and Logarithms.
  1734. * powr: (libc)Exponents and Logarithms.
  1735. * powrf: (libc)Exponents and Logarithms.
  1736. * powrfN: (libc)Exponents and Logarithms.
  1737. * powrfNx: (libc)Exponents and Logarithms.
  1738. * powrl: (libc)Exponents and Logarithms.
  1739. * pread64: (libc)I/O Primitives.
  1740. * pread: (libc)I/O Primitives.
  1741. * preadv2: (libc)Scatter-Gather.
  1742. * preadv64: (libc)Scatter-Gather.
  1743. * preadv64v2: (libc)Scatter-Gather.
  1744. * preadv: (libc)Scatter-Gather.
  1745. * printf: (libc)Formatted Output Functions.
  1746. * printf_size: (libc)Predefined Printf Handlers.
  1747. * printf_size_info: (libc)Predefined Printf Handlers.
  1748. * psignal: (libc)Signal Messages.
  1749. * pthread_attr_destroy: (libc)Creating and Destroying Threads.
  1750. * pthread_attr_getaffinity_np: (libc)Thread CPU Affinity.
  1751. * pthread_attr_getdetachstate: (libc)Creating and Destroying Threads.
  1752. * pthread_attr_getsigmask_np: (libc)Initial Thread Signal Mask.
  1753. * pthread_attr_init: (libc)Creating and Destroying Threads.
  1754. * pthread_attr_setaffinity_np: (libc)Thread CPU Affinity.
  1755. * pthread_attr_setdetachstate: (libc)Creating and Destroying Threads.
  1756. * pthread_attr_setsigmask_np: (libc)Initial Thread Signal Mask.
  1757. * pthread_barrier_destroy: (libc)POSIX Barriers.
  1758. * pthread_barrier_init: (libc)POSIX Barriers.
  1759. * pthread_barrier_wait: (libc)POSIX Barriers.
  1760. * pthread_clockjoin_np: (libc)Joining Threads.
  1761. * pthread_cond_clockwait: (libc)Waiting with Explicit Clocks.
  1762. * pthread_create: (libc)Creating and Destroying Threads.
  1763. * pthread_detach: (libc)Creating and Destroying Threads.
  1764. * pthread_equal: (libc)POSIX Threads Other APIs.
  1765. * pthread_getaffinity_np: (libc)Thread CPU Affinity.
  1766. * pthread_getattr_default_np: (libc)Default Thread Attributes.
  1767. * pthread_getcpuclockid: (libc)POSIX Threads Other APIs.
  1768. * pthread_getname_np: (libc)Thread Names.
  1769. * pthread_getspecific: (libc)Thread-specific Data.
  1770. * pthread_gettid_np: (libc)Process Identification.
  1771. * pthread_join: (libc)Creating and Destroying Threads.
  1772. * pthread_key_create: (libc)Thread-specific Data.
  1773. * pthread_key_delete: (libc)Thread-specific Data.
  1774. * pthread_kill: (libc)Creating and Destroying Threads.
  1775. * pthread_mutex_clocklock: (libc)POSIX Mutexes.
  1776. * pthread_mutex_destroy: (libc)POSIX Mutexes.
  1777. * pthread_mutex_init: (libc)POSIX Mutexes.
  1778. * pthread_mutex_lock: (libc)POSIX Mutexes.
  1779. * pthread_mutex_timedlock: (libc)POSIX Mutexes.
  1780. * pthread_mutex_trylock: (libc)POSIX Mutexes.
  1781. * pthread_mutex_unlock: (libc)POSIX Mutexes.
  1782. * pthread_mutexattr_destroy: (libc)POSIX Mutexes.
  1783. * pthread_mutexattr_gettype: (libc)POSIX Mutexes.
  1784. * pthread_mutexattr_init: (libc)POSIX Mutexes.
  1785. * pthread_mutexattr_settype: (libc)POSIX Mutexes.
  1786. * pthread_once: (libc)POSIX Threads Other APIs.
  1787. * pthread_rwlock_clockrdlock: (libc)Waiting with Explicit Clocks.
  1788. * pthread_rwlock_clockwrlock: (libc)Waiting with Explicit Clocks.
  1789. * pthread_self: (libc)Creating and Destroying Threads.
  1790. * pthread_setaffinity_np: (libc)Thread CPU Affinity.
  1791. * pthread_setattr_default_np: (libc)Default Thread Attributes.
  1792. * pthread_setname_np: (libc)Thread Names.
  1793. * pthread_setspecific: (libc)Thread-specific Data.
  1794. * pthread_sigmask: (libc)POSIX Threads Other APIs.
  1795. * pthread_spin_destroy: (libc)POSIX Spin Locks.
  1796. * pthread_spin_init: (libc)POSIX Spin Locks.
  1797. * pthread_spin_lock: (libc)POSIX Spin Locks.
  1798. * pthread_spin_trylock: (libc)POSIX Spin Locks.
  1799. * pthread_spin_unlock: (libc)POSIX Spin Locks.
  1800. * pthread_timedjoin_np: (libc)Joining Threads.
  1801. * pthread_tryjoin_np: (libc)Joining Threads.
  1802. * ptsname: (libc)Allocation.
  1803. * ptsname_r: (libc)Allocation.
  1804. * putc: (libc)Simple Output.
  1805. * putc_unlocked: (libc)Simple Output.
  1806. * putchar: (libc)Simple Output.
  1807. * putchar_unlocked: (libc)Simple Output.
  1808. * putenv: (libc)Environment Access.
  1809. * putpwent: (libc)Writing a User Entry.
  1810. * puts: (libc)Simple Output.
  1811. * pututline: (libc)Manipulating the Database.
  1812. * pututxline: (libc)XPG Functions.
  1813. * putw: (libc)Simple Output.
  1814. * putwc: (libc)Simple Output.
  1815. * putwc_unlocked: (libc)Simple Output.
  1816. * putwchar: (libc)Simple Output.
  1817. * putwchar_unlocked: (libc)Simple Output.
  1818. * pwrite64: (libc)I/O Primitives.
  1819. * pwrite: (libc)I/O Primitives.
  1820. * pwritev2: (libc)Scatter-Gather.
  1821. * pwritev64: (libc)Scatter-Gather.
  1822. * pwritev64v2: (libc)Scatter-Gather.
  1823. * pwritev: (libc)Scatter-Gather.
  1824. * qecvt: (libc)System V Number Conversion.
  1825. * qecvt_r: (libc)System V Number Conversion.
  1826. * qfcvt: (libc)System V Number Conversion.
  1827. * qfcvt_r: (libc)System V Number Conversion.
  1828. * qgcvt: (libc)System V Number Conversion.
  1829. * qsort: (libc)Array Sort Function.
  1830. * raise: (libc)Signaling Yourself.
  1831. * rand: (libc)ISO Random.
  1832. * rand_r: (libc)ISO Random.
  1833. * random: (libc)BSD Random.
  1834. * random_r: (libc)BSD Random.
  1835. * rawmemchr: (libc)Search Functions.
  1836. * read: (libc)I/O Primitives.
  1837. * readdir64: (libc)Reading/Closing Directory.
  1838. * readdir64_r: (libc)Reading/Closing Directory.
  1839. * readdir: (libc)Reading/Closing Directory.
  1840. * readdir_r: (libc)Reading/Closing Directory.
  1841. * readlink: (libc)Symbolic Links.
  1842. * readv: (libc)Scatter-Gather.
  1843. * realloc: (libc)Changing Block Size.
  1844. * reallocarray: (libc)Changing Block Size.
  1845. * realpath: (libc)Symbolic Links.
  1846. * recv: (libc)Receiving Data.
  1847. * recvfrom: (libc)Receiving Datagrams.
  1848. * recvmsg: (libc)Other Socket APIs.
  1849. * regcomp: (libc)POSIX Regexp Compilation.
  1850. * regerror: (libc)Regexp Cleanup.
  1851. * regexec: (libc)Matching POSIX Regexps.
  1852. * regfree: (libc)Regexp Cleanup.
  1853. * register_printf_function: (libc)Registering New Conversions.
  1854. * remainder: (libc)Remainder Functions.
  1855. * remainderf: (libc)Remainder Functions.
  1856. * remainderfN: (libc)Remainder Functions.
  1857. * remainderfNx: (libc)Remainder Functions.
  1858. * remainderl: (libc)Remainder Functions.
  1859. * remove: (libc)Deleting Files.
  1860. * rename: (libc)Renaming Files.
  1861. * renameat: (libc)Renaming Files.
  1862. * rewind: (libc)File Positioning.
  1863. * rewinddir: (libc)Random Access Directory.
  1864. * rindex: (libc)Search Functions.
  1865. * rint: (libc)Rounding Functions.
  1866. * rintf: (libc)Rounding Functions.
  1867. * rintfN: (libc)Rounding Functions.
  1868. * rintfNx: (libc)Rounding Functions.
  1869. * rintl: (libc)Rounding Functions.
  1870. * rmdir: (libc)Deleting Files.
  1871. * rootn: (libc)Exponents and Logarithms.
  1872. * rootnf: (libc)Exponents and Logarithms.
  1873. * rootnfN: (libc)Exponents and Logarithms.
  1874. * rootnfNx: (libc)Exponents and Logarithms.
  1875. * rootnl: (libc)Exponents and Logarithms.
  1876. * round: (libc)Rounding Functions.
  1877. * roundeven: (libc)Rounding Functions.
  1878. * roundevenf: (libc)Rounding Functions.
  1879. * roundevenfN: (libc)Rounding Functions.
  1880. * roundevenfNx: (libc)Rounding Functions.
  1881. * roundevenl: (libc)Rounding Functions.
  1882. * roundf: (libc)Rounding Functions.
  1883. * roundfN: (libc)Rounding Functions.
  1884. * roundfNx: (libc)Rounding Functions.
  1885. * roundl: (libc)Rounding Functions.
  1886. * rpmatch: (libc)Yes-or-No Questions.
  1887. * rsqrt: (libc)Exponents and Logarithms.
  1888. * rsqrtf: (libc)Exponents and Logarithms.
  1889. * rsqrtfN: (libc)Exponents and Logarithms.
  1890. * rsqrtfNx: (libc)Exponents and Logarithms.
  1891. * rsqrtl: (libc)Exponents and Logarithms.
  1892. * sbrk: (libc)Resizing the Data Segment.
  1893. * scalb: (libc)Normalization Functions.
  1894. * scalbf: (libc)Normalization Functions.
  1895. * scalbl: (libc)Normalization Functions.
  1896. * scalbln: (libc)Normalization Functions.
  1897. * scalblnf: (libc)Normalization Functions.
  1898. * scalblnfN: (libc)Normalization Functions.
  1899. * scalblnfNx: (libc)Normalization Functions.
  1900. * scalblnl: (libc)Normalization Functions.
  1901. * scalbn: (libc)Normalization Functions.
  1902. * scalbnf: (libc)Normalization Functions.
  1903. * scalbnfN: (libc)Normalization Functions.
  1904. * scalbnfNx: (libc)Normalization Functions.
  1905. * scalbnl: (libc)Normalization Functions.
  1906. * scandir64: (libc)Scanning Directory Content.
  1907. * scandir: (libc)Scanning Directory Content.
  1908. * scanf: (libc)Formatted Input Functions.
  1909. * sched_get_priority_max: (libc)Basic Scheduling Functions.
  1910. * sched_get_priority_min: (libc)Basic Scheduling Functions.
  1911. * sched_getaffinity: (libc)CPU Affinity.
  1912. * sched_getattr: (libc)Extensible Scheduling.
  1913. * sched_getcpu: (libc)CPU Affinity.
  1914. * sched_getparam: (libc)Basic Scheduling Functions.
  1915. * sched_getscheduler: (libc)Basic Scheduling Functions.
  1916. * sched_rr_get_interval: (libc)Basic Scheduling Functions.
  1917. * sched_setaffinity: (libc)CPU Affinity.
  1918. * sched_setattr: (libc)Extensible Scheduling.
  1919. * sched_setparam: (libc)Basic Scheduling Functions.
  1920. * sched_setscheduler: (libc)Basic Scheduling Functions.
  1921. * sched_yield: (libc)Basic Scheduling Functions.
  1922. * secure_getenv: (libc)Environment Access.
  1923. * seed48: (libc)SVID Random.
  1924. * seed48_r: (libc)SVID Random.
  1925. * seekdir: (libc)Random Access Directory.
  1926. * select: (libc)Waiting for I/O.
  1927. * sem_clockwait: (libc)POSIX Semaphores.
  1928. * sem_close: (libc)POSIX Semaphores.
  1929. * sem_destroy: (libc)POSIX Semaphores.
  1930. * sem_getvalue: (libc)POSIX Semaphores.
  1931. * sem_init: (libc)POSIX Semaphores.
  1932. * sem_open: (libc)POSIX Semaphores.
  1933. * sem_post: (libc)POSIX Semaphores.
  1934. * sem_timedwait: (libc)POSIX Semaphores.
  1935. * sem_trywait: (libc)POSIX Semaphores.
  1936. * sem_unlink: (libc)POSIX Semaphores.
  1937. * sem_wait: (libc)POSIX Semaphores.
  1938. * semctl: (libc)Semaphores.
  1939. * semget: (libc)Semaphores.
  1940. * semop: (libc)Semaphores.
  1941. * semtimedop: (libc)Semaphores.
  1942. * send: (libc)Sending Data.
  1943. * sendmsg: (libc)Other Socket APIs.
  1944. * sendto: (libc)Sending Datagrams.
  1945. * setbuf: (libc)Controlling Buffering.
  1946. * setbuffer: (libc)Controlling Buffering.
  1947. * setcontext: (libc)System V contexts.
  1948. * setdomainname: (libc)Host Identification.
  1949. * setegid: (libc)Setting Groups.
  1950. * setenv: (libc)Environment Access.
  1951. * seteuid: (libc)Setting User ID.
  1952. * setfsent: (libc)fstab.
  1953. * setgid: (libc)Setting Groups.
  1954. * setgrent: (libc)Scanning All Groups.
  1955. * setgroups: (libc)Setting Groups.
  1956. * sethostent: (libc)Host Names.
  1957. * sethostid: (libc)Host Identification.
  1958. * sethostname: (libc)Host Identification.
  1959. * setitimer: (libc)Setting an Alarm.
  1960. * setjmp: (libc)Non-Local Details.
  1961. * setlinebuf: (libc)Controlling Buffering.
  1962. * setlocale: (libc)Setting the Locale.
  1963. * setlogmask: (libc)setlogmask.
  1964. * setmntent: (libc)mtab.
  1965. * setnetent: (libc)Networks Database.
  1966. * setnetgrent: (libc)Lookup Netgroup.
  1967. * setpayload: (libc)FP Bit Twiddling.
  1968. * setpayloadf: (libc)FP Bit Twiddling.
  1969. * setpayloadfN: (libc)FP Bit Twiddling.
  1970. * setpayloadfNx: (libc)FP Bit Twiddling.
  1971. * setpayloadl: (libc)FP Bit Twiddling.
  1972. * setpayloadsig: (libc)FP Bit Twiddling.
  1973. * setpayloadsigf: (libc)FP Bit Twiddling.
  1974. * setpayloadsigfN: (libc)FP Bit Twiddling.
  1975. * setpayloadsigfNx: (libc)FP Bit Twiddling.
  1976. * setpayloadsigl: (libc)FP Bit Twiddling.
  1977. * setpgid: (libc)Process Group Functions.
  1978. * setpgrp: (libc)Process Group Functions.
  1979. * setpriority: (libc)Traditional Scheduling Functions.
  1980. * setprotoent: (libc)Protocols Database.
  1981. * setpwent: (libc)Scanning All Users.
  1982. * setregid: (libc)Setting Groups.
  1983. * setreuid: (libc)Setting User ID.
  1984. * setrlimit64: (libc)Limits on Resources.
  1985. * setrlimit: (libc)Limits on Resources.
  1986. * setservent: (libc)Services Database.
  1987. * setsid: (libc)Process Group Functions.
  1988. * setsockopt: (libc)Socket Option Functions.
  1989. * setstate: (libc)BSD Random.
  1990. * setstate_r: (libc)BSD Random.
  1991. * settimeofday: (libc)Setting and Adjusting the Time.
  1992. * setuid: (libc)Setting User ID.
  1993. * setutent: (libc)Manipulating the Database.
  1994. * setutxent: (libc)XPG Functions.
  1995. * setvbuf: (libc)Controlling Buffering.
  1996. * shm_open: (libc)Memory-mapped I/O.
  1997. * shm_unlink: (libc)Memory-mapped I/O.
  1998. * shutdown: (libc)Closing a Socket.
  1999. * sigabbrev_np: (libc)Signal Messages.
  2000. * sigaction: (libc)Advanced Signal Handling.
  2001. * sigaddset: (libc)Signal Sets.
  2002. * sigaltstack: (libc)Signal Stack.
  2003. * sigblock: (libc)BSD Signal Handling.
  2004. * sigdelset: (libc)Signal Sets.
  2005. * sigdescr_np: (libc)Signal Messages.
  2006. * sigemptyset: (libc)Signal Sets.
  2007. * sigfillset: (libc)Signal Sets.
  2008. * siginterrupt: (libc)BSD Signal Handling.
  2009. * sigismember: (libc)Signal Sets.
  2010. * siglongjmp: (libc)Non-Local Exits and Signals.
  2011. * sigmask: (libc)BSD Signal Handling.
  2012. * signal: (libc)Basic Signal Handling.
  2013. * signbit: (libc)FP Bit Twiddling.
  2014. * significand: (libc)Normalization Functions.
  2015. * significandf: (libc)Normalization Functions.
  2016. * significandl: (libc)Normalization Functions.
  2017. * sigpause: (libc)BSD Signal Handling.
  2018. * sigpending: (libc)Checking for Pending Signals.
  2019. * sigprocmask: (libc)Process Signal Mask.
  2020. * sigsetjmp: (libc)Non-Local Exits and Signals.
  2021. * sigsetmask: (libc)BSD Signal Handling.
  2022. * sigstack: (libc)Signal Stack.
  2023. * sigsuspend: (libc)Sigsuspend.
  2024. * sin: (libc)Trig Functions.
  2025. * sincos: (libc)Trig Functions.
  2026. * sincosf: (libc)Trig Functions.
  2027. * sincosfN: (libc)Trig Functions.
  2028. * sincosfNx: (libc)Trig Functions.
  2029. * sincosl: (libc)Trig Functions.
  2030. * sinf: (libc)Trig Functions.
  2031. * sinfN: (libc)Trig Functions.
  2032. * sinfNx: (libc)Trig Functions.
  2033. * sinh: (libc)Hyperbolic Functions.
  2034. * sinhf: (libc)Hyperbolic Functions.
  2035. * sinhfN: (libc)Hyperbolic Functions.
  2036. * sinhfNx: (libc)Hyperbolic Functions.
  2037. * sinhl: (libc)Hyperbolic Functions.
  2038. * sinl: (libc)Trig Functions.
  2039. * sinpi: (libc)Trig Functions.
  2040. * sinpif: (libc)Trig Functions.
  2041. * sinpifN: (libc)Trig Functions.
  2042. * sinpifNx: (libc)Trig Functions.
  2043. * sinpil: (libc)Trig Functions.
  2044. * sleep: (libc)Sleeping.
  2045. * snprintf: (libc)Formatted Output Functions.
  2046. * socket: (libc)Creating a Socket.
  2047. * socketpair: (libc)Socket Pairs.
  2048. * sprintf: (libc)Formatted Output Functions.
  2049. * sqrt: (libc)Exponents and Logarithms.
  2050. * sqrtf: (libc)Exponents and Logarithms.
  2051. * sqrtfN: (libc)Exponents and Logarithms.
  2052. * sqrtfNx: (libc)Exponents and Logarithms.
  2053. * sqrtl: (libc)Exponents and Logarithms.
  2054. * srand48: (libc)SVID Random.
  2055. * srand48_r: (libc)SVID Random.
  2056. * srand: (libc)ISO Random.
  2057. * srandom: (libc)BSD Random.
  2058. * srandom_r: (libc)BSD Random.
  2059. * sscanf: (libc)Formatted Input Functions.
  2060. * ssignal: (libc)Basic Signal Handling.
  2061. * stat64: (libc)Reading Attributes.
  2062. * stat: (libc)Reading Attributes.
  2063. * stdc_bit_ceil_uc: (libc)Bit Manipulation.
  2064. * stdc_bit_ceil_ui: (libc)Bit Manipulation.
  2065. * stdc_bit_ceil_ul: (libc)Bit Manipulation.
  2066. * stdc_bit_ceil_ull: (libc)Bit Manipulation.
  2067. * stdc_bit_ceil_us: (libc)Bit Manipulation.
  2068. * stdc_bit_floor_uc: (libc)Bit Manipulation.
  2069. * stdc_bit_floor_ui: (libc)Bit Manipulation.
  2070. * stdc_bit_floor_ul: (libc)Bit Manipulation.
  2071. * stdc_bit_floor_ull: (libc)Bit Manipulation.
  2072. * stdc_bit_floor_us: (libc)Bit Manipulation.
  2073. * stdc_bit_width_uc: (libc)Bit Manipulation.
  2074. * stdc_bit_width_ui: (libc)Bit Manipulation.
  2075. * stdc_bit_width_ul: (libc)Bit Manipulation.
  2076. * stdc_bit_width_ull: (libc)Bit Manipulation.
  2077. * stdc_bit_width_us: (libc)Bit Manipulation.
  2078. * stdc_count_ones_uc: (libc)Bit Manipulation.
  2079. * stdc_count_ones_ui: (libc)Bit Manipulation.
  2080. * stdc_count_ones_ul: (libc)Bit Manipulation.
  2081. * stdc_count_ones_ull: (libc)Bit Manipulation.
  2082. * stdc_count_ones_us: (libc)Bit Manipulation.
  2083. * stdc_count_zeros_uc: (libc)Bit Manipulation.
  2084. * stdc_count_zeros_ui: (libc)Bit Manipulation.
  2085. * stdc_count_zeros_ul: (libc)Bit Manipulation.
  2086. * stdc_count_zeros_ull: (libc)Bit Manipulation.
  2087. * stdc_count_zeros_us: (libc)Bit Manipulation.
  2088. * stdc_first_leading_one_uc: (libc)Bit Manipulation.
  2089. * stdc_first_leading_one_ui: (libc)Bit Manipulation.
  2090. * stdc_first_leading_one_ul: (libc)Bit Manipulation.
  2091. * stdc_first_leading_one_ull: (libc)Bit Manipulation.
  2092. * stdc_first_leading_one_us: (libc)Bit Manipulation.
  2093. * stdc_first_leading_zero_uc: (libc)Bit Manipulation.
  2094. * stdc_first_leading_zero_ui: (libc)Bit Manipulation.
  2095. * stdc_first_leading_zero_ul: (libc)Bit Manipulation.
  2096. * stdc_first_leading_zero_ull: (libc)Bit Manipulation.
  2097. * stdc_first_leading_zero_us: (libc)Bit Manipulation.
  2098. * stdc_first_trailing_one_uc: (libc)Bit Manipulation.
  2099. * stdc_first_trailing_one_ui: (libc)Bit Manipulation.
  2100. * stdc_first_trailing_one_ul: (libc)Bit Manipulation.
  2101. * stdc_first_trailing_one_ull: (libc)Bit Manipulation.
  2102. * stdc_first_trailing_one_us: (libc)Bit Manipulation.
  2103. * stdc_first_trailing_zero_uc: (libc)Bit Manipulation.
  2104. * stdc_first_trailing_zero_ui: (libc)Bit Manipulation.
  2105. * stdc_first_trailing_zero_ul: (libc)Bit Manipulation.
  2106. * stdc_first_trailing_zero_ull: (libc)Bit Manipulation.
  2107. * stdc_first_trailing_zero_us: (libc)Bit Manipulation.
  2108. * stdc_has_single_bit_uc: (libc)Bit Manipulation.
  2109. * stdc_has_single_bit_ui: (libc)Bit Manipulation.
  2110. * stdc_has_single_bit_ul: (libc)Bit Manipulation.
  2111. * stdc_has_single_bit_ull: (libc)Bit Manipulation.
  2112. * stdc_has_single_bit_us: (libc)Bit Manipulation.
  2113. * stdc_leading_ones_uc: (libc)Bit Manipulation.
  2114. * stdc_leading_ones_ui: (libc)Bit Manipulation.
  2115. * stdc_leading_ones_ul: (libc)Bit Manipulation.
  2116. * stdc_leading_ones_ull: (libc)Bit Manipulation.
  2117. * stdc_leading_ones_us: (libc)Bit Manipulation.
  2118. * stdc_leading_zeros_uc: (libc)Bit Manipulation.
  2119. * stdc_leading_zeros_ui: (libc)Bit Manipulation.
  2120. * stdc_leading_zeros_ul: (libc)Bit Manipulation.
  2121. * stdc_leading_zeros_ull: (libc)Bit Manipulation.
  2122. * stdc_leading_zeros_us: (libc)Bit Manipulation.
  2123. * stdc_trailing_ones_uc: (libc)Bit Manipulation.
  2124. * stdc_trailing_ones_ui: (libc)Bit Manipulation.
  2125. * stdc_trailing_ones_ul: (libc)Bit Manipulation.
  2126. * stdc_trailing_ones_ull: (libc)Bit Manipulation.
  2127. * stdc_trailing_ones_us: (libc)Bit Manipulation.
  2128. * stdc_trailing_zeros_uc: (libc)Bit Manipulation.
  2129. * stdc_trailing_zeros_ui: (libc)Bit Manipulation.
  2130. * stdc_trailing_zeros_ul: (libc)Bit Manipulation.
  2131. * stdc_trailing_zeros_ull: (libc)Bit Manipulation.
  2132. * stdc_trailing_zeros_us: (libc)Bit Manipulation.
  2133. * stime: (libc)Setting and Adjusting the Time.
  2134. * stpcpy: (libc)Copying Strings and Arrays.
  2135. * stpncpy: (libc)Truncating Strings.
  2136. * strcasecmp: (libc)String/Array Comparison.
  2137. * strcasestr: (libc)Search Functions.
  2138. * strcat: (libc)Concatenating Strings.
  2139. * strchr: (libc)Search Functions.
  2140. * strchrnul: (libc)Search Functions.
  2141. * strcmp: (libc)String/Array Comparison.
  2142. * strcoll: (libc)Collation Functions.
  2143. * strcpy: (libc)Copying Strings and Arrays.
  2144. * strcspn: (libc)Search Functions.
  2145. * strdup: (libc)Copying Strings and Arrays.
  2146. * strdupa: (libc)Copying Strings and Arrays.
  2147. * strerror: (libc)Error Messages.
  2148. * strerror_l: (libc)Error Messages.
  2149. * strerror_r: (libc)Error Messages.
  2150. * strerror_r: (libc)Error Messages.
  2151. * strerrordesc_np: (libc)Error Messages.
  2152. * strerrorname_np: (libc)Error Messages.
  2153. * strfmon: (libc)Formatting Numbers.
  2154. * strfromd: (libc)Printing of Floats.
  2155. * strfromf: (libc)Printing of Floats.
  2156. * strfromfN: (libc)Printing of Floats.
  2157. * strfromfNx: (libc)Printing of Floats.
  2158. * strfroml: (libc)Printing of Floats.
  2159. * strfry: (libc)Shuffling Bytes.
  2160. * strftime: (libc)Formatting Calendar Time.
  2161. * strftime_l: (libc)Formatting Calendar Time.
  2162. * strlcat: (libc)Truncating Strings.
  2163. * strlcpy: (libc)Truncating Strings.
  2164. * strlen: (libc)String Length.
  2165. * strncasecmp: (libc)String/Array Comparison.
  2166. * strncat: (libc)Truncating Strings.
  2167. * strncmp: (libc)String/Array Comparison.
  2168. * strncpy: (libc)Truncating Strings.
  2169. * strndup: (libc)Truncating Strings.
  2170. * strndupa: (libc)Truncating Strings.
  2171. * strnlen: (libc)String Length.
  2172. * strpbrk: (libc)Search Functions.
  2173. * strptime: (libc)Low-Level Time String Parsing.
  2174. * strrchr: (libc)Search Functions.
  2175. * strsep: (libc)Finding Tokens in a String.
  2176. * strsignal: (libc)Signal Messages.
  2177. * strspn: (libc)Search Functions.
  2178. * strstr: (libc)Search Functions.
  2179. * strtod: (libc)Parsing of Floats.
  2180. * strtof: (libc)Parsing of Floats.
  2181. * strtofN: (libc)Parsing of Floats.
  2182. * strtofNx: (libc)Parsing of Floats.
  2183. * strtoimax: (libc)Parsing of Integers.
  2184. * strtok: (libc)Finding Tokens in a String.
  2185. * strtok_r: (libc)Finding Tokens in a String.
  2186. * strtol: (libc)Parsing of Integers.
  2187. * strtold: (libc)Parsing of Floats.
  2188. * strtoll: (libc)Parsing of Integers.
  2189. * strtoq: (libc)Parsing of Integers.
  2190. * strtoul: (libc)Parsing of Integers.
  2191. * strtoull: (libc)Parsing of Integers.
  2192. * strtoumax: (libc)Parsing of Integers.
  2193. * strtouq: (libc)Parsing of Integers.
  2194. * strverscmp: (libc)String/Array Comparison.
  2195. * strxfrm: (libc)Collation Functions.
  2196. * stty: (libc)BSD Terminal Modes.
  2197. * swapcontext: (libc)System V contexts.
  2198. * swprintf: (libc)Formatted Output Functions.
  2199. * swscanf: (libc)Formatted Input Functions.
  2200. * symlink: (libc)Symbolic Links.
  2201. * sync: (libc)Synchronizing I/O.
  2202. * syscall: (libc)System Calls.
  2203. * sysconf: (libc)Sysconf Definition.
  2204. * syslog: (libc)syslog; vsyslog.
  2205. * system: (libc)Running a Command.
  2206. * sysv_signal: (libc)Basic Signal Handling.
  2207. * tan: (libc)Trig Functions.
  2208. * tanf: (libc)Trig Functions.
  2209. * tanfN: (libc)Trig Functions.
  2210. * tanfNx: (libc)Trig Functions.
  2211. * tanh: (libc)Hyperbolic Functions.
  2212. * tanhf: (libc)Hyperbolic Functions.
  2213. * tanhfN: (libc)Hyperbolic Functions.
  2214. * tanhfNx: (libc)Hyperbolic Functions.
  2215. * tanhl: (libc)Hyperbolic Functions.
  2216. * tanl: (libc)Trig Functions.
  2217. * tanpi: (libc)Trig Functions.
  2218. * tanpif: (libc)Trig Functions.
  2219. * tanpifN: (libc)Trig Functions.
  2220. * tanpifNx: (libc)Trig Functions.
  2221. * tanpil: (libc)Trig Functions.
  2222. * tcdrain: (libc)Line Control.
  2223. * tcflow: (libc)Line Control.
  2224. * tcflush: (libc)Line Control.
  2225. * tcgetattr: (libc)Mode Functions.
  2226. * tcgetpgrp: (libc)Terminal Access Functions.
  2227. * tcgetsid: (libc)Terminal Access Functions.
  2228. * tcsendbreak: (libc)Line Control.
  2229. * tcsetattr: (libc)Mode Functions.
  2230. * tcsetpgrp: (libc)Terminal Access Functions.
  2231. * tdelete: (libc)Tree Search Function.
  2232. * tdestroy: (libc)Tree Search Function.
  2233. * telldir: (libc)Random Access Directory.
  2234. * tempnam: (libc)Temporary Files.
  2235. * textdomain: (libc)Locating gettext catalog.
  2236. * tfind: (libc)Tree Search Function.
  2237. * tgamma: (libc)Special Functions.
  2238. * tgammaf: (libc)Special Functions.
  2239. * tgammafN: (libc)Special Functions.
  2240. * tgammafNx: (libc)Special Functions.
  2241. * tgammal: (libc)Special Functions.
  2242. * tgkill: (libc)Signaling Another Process.
  2243. * thrd_create: (libc)ISO C Thread Management.
  2244. * thrd_current: (libc)ISO C Thread Management.
  2245. * thrd_detach: (libc)ISO C Thread Management.
  2246. * thrd_equal: (libc)ISO C Thread Management.
  2247. * thrd_exit: (libc)ISO C Thread Management.
  2248. * thrd_join: (libc)ISO C Thread Management.
  2249. * thrd_sleep: (libc)ISO C Thread Management.
  2250. * thrd_yield: (libc)ISO C Thread Management.
  2251. * time: (libc)Getting the Time.
  2252. * timegm: (libc)Broken-down Time.
  2253. * timelocal: (libc)Broken-down Time.
  2254. * times: (libc)Processor Time.
  2255. * timespec_get: (libc)Getting the Time.
  2256. * timespec_getres: (libc)Getting the Time.
  2257. * tmpfile64: (libc)Temporary Files.
  2258. * tmpfile: (libc)Temporary Files.
  2259. * tmpnam: (libc)Temporary Files.
  2260. * tmpnam_r: (libc)Temporary Files.
  2261. * toascii: (libc)Case Conversion.
  2262. * tolower: (libc)Case Conversion.
  2263. * totalorder: (libc)FP Comparison Functions.
  2264. * totalorderf: (libc)FP Comparison Functions.
  2265. * totalorderfN: (libc)FP Comparison Functions.
  2266. * totalorderfNx: (libc)FP Comparison Functions.
  2267. * totalorderl: (libc)FP Comparison Functions.
  2268. * totalordermag: (libc)FP Comparison Functions.
  2269. * totalordermagf: (libc)FP Comparison Functions.
  2270. * totalordermagfN: (libc)FP Comparison Functions.
  2271. * totalordermagfNx: (libc)FP Comparison Functions.
  2272. * totalordermagl: (libc)FP Comparison Functions.
  2273. * toupper: (libc)Case Conversion.
  2274. * towctrans: (libc)Wide Character Case Conversion.
  2275. * towlower: (libc)Wide Character Case Conversion.
  2276. * towupper: (libc)Wide Character Case Conversion.
  2277. * trunc: (libc)Rounding Functions.
  2278. * truncate64: (libc)File Size.
  2279. * truncate: (libc)File Size.
  2280. * truncf: (libc)Rounding Functions.
  2281. * truncfN: (libc)Rounding Functions.
  2282. * truncfNx: (libc)Rounding Functions.
  2283. * truncl: (libc)Rounding Functions.
  2284. * tsearch: (libc)Tree Search Function.
  2285. * tss_create: (libc)ISO C Thread-local Storage.
  2286. * tss_delete: (libc)ISO C Thread-local Storage.
  2287. * tss_get: (libc)ISO C Thread-local Storage.
  2288. * tss_set: (libc)ISO C Thread-local Storage.
  2289. * ttyname: (libc)Is It a Terminal.
  2290. * ttyname_r: (libc)Is It a Terminal.
  2291. * twalk: (libc)Tree Search Function.
  2292. * twalk_r: (libc)Tree Search Function.
  2293. * tzset: (libc)Time Zone State.
  2294. * uabs: (libc)Absolute Value.
  2295. * ufromfp: (libc)Rounding Functions.
  2296. * ufromfpf: (libc)Rounding Functions.
  2297. * ufromfpfN: (libc)Rounding Functions.
  2298. * ufromfpfNx: (libc)Rounding Functions.
  2299. * ufromfpl: (libc)Rounding Functions.
  2300. * ufromfpx: (libc)Rounding Functions.
  2301. * ufromfpxf: (libc)Rounding Functions.
  2302. * ufromfpxfN: (libc)Rounding Functions.
  2303. * ufromfpxfNx: (libc)Rounding Functions.
  2304. * ufromfpxl: (libc)Rounding Functions.
  2305. * ulabs: (libc)Absolute Value.
  2306. * ulimit: (libc)Limits on Resources.
  2307. * ullabs: (libc)Absolute Value.
  2308. * umask: (libc)Setting Permissions.
  2309. * umaxabs: (libc)Absolute Value.
  2310. * umount2: (libc)Mount-Unmount-Remount.
  2311. * umount: (libc)Mount-Unmount-Remount.
  2312. * uname: (libc)Platform Type.
  2313. * ungetc: (libc)How Unread.
  2314. * ungetwc: (libc)How Unread.
  2315. * unlink: (libc)Deleting Files.
  2316. * unlinkat: (libc)Deleting Files.
  2317. * unlockpt: (libc)Allocation.
  2318. * unsetenv: (libc)Environment Access.
  2319. * updwtmp: (libc)Manipulating the Database.
  2320. * utime: (libc)File Times.
  2321. * utimensat: (libc)File Times.
  2322. * utimes: (libc)File Times.
  2323. * utmpname: (libc)Manipulating the Database.
  2324. * utmpxname: (libc)XPG Functions.
  2325. * va_arg: (libc)Argument Macros.
  2326. * va_copy: (libc)Argument Macros.
  2327. * va_end: (libc)Argument Macros.
  2328. * va_start: (libc)Argument Macros.
  2329. * valloc: (libc)Aligned Memory Blocks.
  2330. * vasprintf: (libc)Variable Arguments Output.
  2331. * vdprintf: (libc)Variable Arguments Output.
  2332. * verr: (libc)Error Messages.
  2333. * verrx: (libc)Error Messages.
  2334. * versionsort64: (libc)Scanning Directory Content.
  2335. * versionsort: (libc)Scanning Directory Content.
  2336. * vfork: (libc)Creating a Process.
  2337. * vfprintf: (libc)Variable Arguments Output.
  2338. * vfscanf: (libc)Variable Arguments Input.
  2339. * vfwprintf: (libc)Variable Arguments Output.
  2340. * vfwscanf: (libc)Variable Arguments Input.
  2341. * vlimit: (libc)Limits on Resources.
  2342. * vprintf: (libc)Variable Arguments Output.
  2343. * vscanf: (libc)Variable Arguments Input.
  2344. * vsnprintf: (libc)Variable Arguments Output.
  2345. * vsprintf: (libc)Variable Arguments Output.
  2346. * vsscanf: (libc)Variable Arguments Input.
  2347. * vswprintf: (libc)Variable Arguments Output.
  2348. * vswscanf: (libc)Variable Arguments Input.
  2349. * vsyslog: (libc)syslog; vsyslog.
  2350. * vwarn: (libc)Error Messages.
  2351. * vwarnx: (libc)Error Messages.
  2352. * vwprintf: (libc)Variable Arguments Output.
  2353. * vwscanf: (libc)Variable Arguments Input.
  2354. * wait3: (libc)BSD Wait Functions.
  2355. * wait4: (libc)Process Completion.
  2356. * wait: (libc)Process Completion.
  2357. * waitpid: (libc)Process Completion.
  2358. * warn: (libc)Error Messages.
  2359. * warnx: (libc)Error Messages.
  2360. * wcpcpy: (libc)Copying Strings and Arrays.
  2361. * wcpncpy: (libc)Truncating Strings.
  2362. * wcrtomb: (libc)Converting a Character.
  2363. * wcscasecmp: (libc)String/Array Comparison.
  2364. * wcscat: (libc)Concatenating Strings.
  2365. * wcschr: (libc)Search Functions.
  2366. * wcschrnul: (libc)Search Functions.
  2367. * wcscmp: (libc)String/Array Comparison.
  2368. * wcscoll: (libc)Collation Functions.
  2369. * wcscpy: (libc)Copying Strings and Arrays.
  2370. * wcscspn: (libc)Search Functions.
  2371. * wcsdup: (libc)Copying Strings and Arrays.
  2372. * wcsftime: (libc)Formatting Calendar Time.
  2373. * wcslcat: (libc)Truncating Strings.
  2374. * wcslcpy: (libc)Truncating Strings.
  2375. * wcslen: (libc)String Length.
  2376. * wcsncasecmp: (libc)String/Array Comparison.
  2377. * wcsncat: (libc)Truncating Strings.
  2378. * wcsncmp: (libc)String/Array Comparison.
  2379. * wcsncpy: (libc)Truncating Strings.
  2380. * wcsnlen: (libc)String Length.
  2381. * wcsnrtombs: (libc)Converting Strings.
  2382. * wcspbrk: (libc)Search Functions.
  2383. * wcsrchr: (libc)Search Functions.
  2384. * wcsrtombs: (libc)Converting Strings.
  2385. * wcsspn: (libc)Search Functions.
  2386. * wcsstr: (libc)Search Functions.
  2387. * wcstod: (libc)Parsing of Floats.
  2388. * wcstof: (libc)Parsing of Floats.
  2389. * wcstofN: (libc)Parsing of Floats.
  2390. * wcstofNx: (libc)Parsing of Floats.
  2391. * wcstoimax: (libc)Parsing of Integers.
  2392. * wcstok: (libc)Finding Tokens in a String.
  2393. * wcstol: (libc)Parsing of Integers.
  2394. * wcstold: (libc)Parsing of Floats.
  2395. * wcstoll: (libc)Parsing of Integers.
  2396. * wcstombs: (libc)Non-reentrant String Conversion.
  2397. * wcstoq: (libc)Parsing of Integers.
  2398. * wcstoul: (libc)Parsing of Integers.
  2399. * wcstoull: (libc)Parsing of Integers.
  2400. * wcstoumax: (libc)Parsing of Integers.
  2401. * wcstouq: (libc)Parsing of Integers.
  2402. * wcswcs: (libc)Search Functions.
  2403. * wcsxfrm: (libc)Collation Functions.
  2404. * wctob: (libc)Converting a Character.
  2405. * wctomb: (libc)Non-reentrant Character Conversion.
  2406. * wctrans: (libc)Wide Character Case Conversion.
  2407. * wctype: (libc)Classification of Wide Characters.
  2408. * wmemchr: (libc)Search Functions.
  2409. * wmemcmp: (libc)String/Array Comparison.
  2410. * wmemcpy: (libc)Copying Strings and Arrays.
  2411. * wmemmove: (libc)Copying Strings and Arrays.
  2412. * wmempcpy: (libc)Copying Strings and Arrays.
  2413. * wmemset: (libc)Copying Strings and Arrays.
  2414. * wordexp: (libc)Calling Wordexp.
  2415. * wordfree: (libc)Calling Wordexp.
  2416. * wprintf: (libc)Formatted Output Functions.
  2417. * write: (libc)I/O Primitives.
  2418. * writev: (libc)Scatter-Gather.
  2419. * wscanf: (libc)Formatted Input Functions.
  2420. * y0: (libc)Special Functions.
  2421. * y0f: (libc)Special Functions.
  2422. * y0fN: (libc)Special Functions.
  2423. * y0fNx: (libc)Special Functions.
  2424. * y0l: (libc)Special Functions.
  2425. * y1: (libc)Special Functions.
  2426. * y1f: (libc)Special Functions.
  2427. * y1fN: (libc)Special Functions.
  2428. * y1fNx: (libc)Special Functions.
  2429. * y1l: (libc)Special Functions.
  2430. * yn: (libc)Special Functions.
  2431. * ynf: (libc)Special Functions.
  2432. * ynfN: (libc)Special Functions.
  2433. * ynfNx: (libc)Special Functions.
  2434. * ynl: (libc)Special Functions.
  2435. END-INFO-DIR-ENTRY
  2436. 
  2437. File: libc.info, Node: Collation Functions, Next: Search Functions, Prev: String/Array Comparison, Up: String and Array Utilities
  2438. 5.8 Collation Functions
  2439. =======================
  2440. In some locales, the conventions for lexicographic ordering differ from
  2441. the strict numeric ordering of character codes. For example, in Spanish
  2442. most glyphs with diacritical marks such as accents are not considered
  2443. distinct letters for the purposes of collation. On the other hand, in
  2444. Czech the two-character sequence ‘ch’ is treated as a single letter that
  2445. is collated between ‘h’ and ‘i’.
  2446. You can use the functions ‘strcoll’ and ‘strxfrm’ (declared in the
  2447. headers file ‘string.h’) and ‘wcscoll’ and ‘wcsxfrm’ (declared in the
  2448. headers file ‘wchar’) to compare strings using a collation ordering
  2449. appropriate for the current locale. The locale used by these functions
  2450. in particular can be specified by setting the locale for the
  2451. ‘LC_COLLATE’ category; see *note Locales::.
  2452. In the standard C locale, the collation sequence for ‘strcoll’ is the
  2453. same as that for ‘strcmp’. Similarly, ‘wcscoll’ and ‘wcscmp’ are the
  2454. same in this situation.
  2455. Effectively, the way these functions work is by applying a mapping to
  2456. transform the characters in a multibyte string to a byte sequence that
  2457. represents the string's position in the collating sequence of the
  2458. current locale. Comparing two such byte sequences in a simple fashion
  2459. is equivalent to comparing the strings with the locale's collating
  2460. sequence.
  2461. The functions ‘strcoll’ and ‘wcscoll’ perform this translation
  2462. implicitly, in order to do one comparison. By contrast, ‘strxfrm’ and
  2463. ‘wcsxfrm’ perform the mapping explicitly. If you are making multiple
  2464. comparisons using the same string or set of strings, it is likely to be
  2465. more efficient to use ‘strxfrm’ or ‘wcsxfrm’ to transform all the
  2466. strings just once, and subsequently compare the transformed strings with
  2467. ‘strcmp’ or ‘wcscmp’.
  2468. -- Function: int strcoll (const char *S1, const char *S2)
  2469. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  2470. *Note POSIX Safety Concepts::.
  2471. The ‘strcoll’ function is similar to ‘strcmp’ but uses the
  2472. collating sequence of the current locale for collation (the
  2473. ‘LC_COLLATE’ locale). The arguments are multibyte strings.
  2474. -- Function: int wcscoll (const wchar_t *WS1, const wchar_t *WS2)
  2475. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  2476. *Note POSIX Safety Concepts::.
  2477. The ‘wcscoll’ function is similar to ‘wcscmp’ but uses the
  2478. collating sequence of the current locale for collation (the
  2479. ‘LC_COLLATE’ locale).
  2480. Here is an example of sorting an array of strings, using ‘strcoll’ to
  2481. compare them. The actual sort algorithm is not written here; it comes
  2482. from ‘qsort’ (*note Array Sort Function::). The job of the code shown
  2483. here is to say how to compare the strings while sorting them. (Later on
  2484. in this section, we will show a way to do this more efficiently using
  2485. ‘strxfrm’.)
  2486. /* This is the comparison function used with ‘qsort’. */
  2487. int
  2488. compare_elements (const void *v1, const void *v2)
  2489. {
  2490. char * const *p1 = v1;
  2491. char * const *p2 = v2;
  2492. return strcoll (*p1, *p2);
  2493. }
  2494. /* This is the entry point--the function to sort
  2495. strings using the locale's collating sequence. */
  2496. void
  2497. sort_strings (char **array, int nstrings)
  2498. {
  2499. /* Sort ‘temp_array’ by comparing the strings. */
  2500. qsort (array, nstrings,
  2501. sizeof (char *), compare_elements);
  2502. }
  2503. -- Function: size_t strxfrm (char *restrict TO, const char *restrict
  2504. FROM, size_t SIZE)
  2505. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  2506. *Note POSIX Safety Concepts::.
  2507. The function ‘strxfrm’ transforms the multibyte string FROM using
  2508. the collation transformation determined by the locale currently
  2509. selected for collation, and stores the transformed string in the
  2510. array TO. Up to SIZE bytes (including a terminating null byte) are
  2511. stored.
  2512. The behavior is undefined if the strings TO and FROM overlap; see
  2513. *note Copying Strings and Arrays::.
  2514. The return value is the length of the entire transformed string.
  2515. This value is not affected by the value of SIZE, but if it is
  2516. greater or equal than SIZE, it means that the transformed string
  2517. did not entirely fit in the array TO. In this case, only as much
  2518. of the string as actually fits was stored. To get the whole
  2519. transformed string, call ‘strxfrm’ again with a bigger output
  2520. array.
  2521. The transformed string may be longer than the original string, and
  2522. it may also be shorter.
  2523. If SIZE is zero, no bytes are stored in TO. In this case,
  2524. ‘strxfrm’ simply returns the number of bytes that would be the
  2525. length of the transformed string. This is useful for determining
  2526. what size the allocated array should be. It does not matter what
  2527. TO is if SIZE is zero; TO may even be a null pointer.
  2528. -- Function: size_t wcsxfrm (wchar_t *restrict WTO, const wchar_t
  2529. *WFROM, size_t SIZE)
  2530. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  2531. *Note POSIX Safety Concepts::.
  2532. The function ‘wcsxfrm’ transforms wide string WFROM using the
  2533. collation transformation determined by the locale currently
  2534. selected for collation, and stores the transformed string in the
  2535. array WTO. Up to SIZE wide characters (including a terminating
  2536. null wide character) are stored.
  2537. The behavior is undefined if the strings WTO and WFROM overlap; see
  2538. *note Copying Strings and Arrays::.
  2539. The return value is the length of the entire transformed wide
  2540. string. This value is not affected by the value of SIZE, but if it
  2541. is greater or equal than SIZE, it means that the transformed wide
  2542. string did not entirely fit in the array WTO. In this case, only
  2543. as much of the wide string as actually fits was stored. To get the
  2544. whole transformed wide string, call ‘wcsxfrm’ again with a bigger
  2545. output array.
  2546. The transformed wide string may be longer than the original wide
  2547. string, and it may also be shorter.
  2548. If SIZE is zero, no wide characters are stored in TO. In this
  2549. case, ‘wcsxfrm’ simply returns the number of wide characters that
  2550. would be the length of the transformed wide string. This is useful
  2551. for determining what size the allocated array should be (remember
  2552. to multiply with ‘sizeof (wchar_t)’). It does not matter what WTO
  2553. is if SIZE is zero; WTO may even be a null pointer.
  2554. Here is an example of how you can use ‘strxfrm’ when you plan to do
  2555. many comparisons. It does the same thing as the previous example, but
  2556. much faster, because it has to transform each string only once, no
  2557. matter how many times it is compared with other strings. Even the time
  2558. needed to allocate and free storage is much less than the time we save,
  2559. when there are many strings.
  2560. struct sorter { char *input; char *transformed; };
  2561. /* This is the comparison function used with ‘qsort’
  2562. to sort an array of ‘struct sorter’. */
  2563. int
  2564. compare_elements (const void *v1, const void *v2)
  2565. {
  2566. const struct sorter *p1 = v1;
  2567. const struct sorter *p2 = v2;
  2568. return strcmp (p1->transformed, p2->transformed);
  2569. }
  2570. /* This is the entry point--the function to sort
  2571. strings using the locale's collating sequence. */
  2572. void
  2573. sort_strings_fast (char **array, int nstrings)
  2574. {
  2575. struct sorter temp_array[nstrings];
  2576. int i;
  2577. /* Set up ‘temp_array’. Each element contains
  2578. one input string and its transformed string. */
  2579. for (i = 0; i < nstrings; i++)
  2580. {
  2581. size_t length = strlen (array[i]) * 2;
  2582. char *transformed;
  2583. size_t transformed_length;
  2584. temp_array[i].input = array[i];
  2585. /* First try a buffer perhaps big enough. */
  2586. transformed = (char *) xmalloc (length);
  2587. /* Transform ‘array[i]’. */
  2588. transformed_length = strxfrm (transformed, array[i], length);
  2589. /* If the buffer was not large enough, resize it
  2590. and try again. */
  2591. if (transformed_length >= length)
  2592. {
  2593. /* Allocate the needed space. +1 for terminating
  2594. ‘'\0'’ byte. */
  2595. transformed = xrealloc (transformed,
  2596. transformed_length + 1);
  2597. /* The return value is not interesting because we know
  2598. how long the transformed string is. */
  2599. (void) strxfrm (transformed, array[i],
  2600. transformed_length + 1);
  2601. }
  2602. temp_array[i].transformed = transformed;
  2603. }
  2604. /* Sort ‘temp_array’ by comparing transformed strings. */
  2605. qsort (temp_array, nstrings,
  2606. sizeof (struct sorter), compare_elements);
  2607. /* Put the elements back in the permanent array
  2608. in their sorted order. */
  2609. for (i = 0; i < nstrings; i++)
  2610. array[i] = temp_array[i].input;
  2611. /* Free the strings we allocated. */
  2612. for (i = 0; i < nstrings; i++)
  2613. free (temp_array[i].transformed);
  2614. }
  2615. The interesting part of this code for the wide character version
  2616. would look like this:
  2617. void
  2618. sort_strings_fast (wchar_t **array, int nstrings)
  2619. {
  2620. ...
  2621. /* Transform ‘array[i]’. */
  2622. transformed_length = wcsxfrm (transformed, array[i], length);
  2623. /* If the buffer was not large enough, resize it
  2624. and try again. */
  2625. if (transformed_length >= length)
  2626. {
  2627. /* Allocate the needed space. +1 for terminating
  2628. ‘L'\0'’ wide character. */
  2629. transformed = xreallocarray (transformed,
  2630. transformed_length + 1,
  2631. sizeof *transformed);
  2632. /* The return value is not interesting because we know
  2633. how long the transformed string is. */
  2634. (void) wcsxfrm (transformed, array[i],
  2635. transformed_length + 1);
  2636. }
  2637. ...
  2638. Note the additional multiplication with ‘sizeof (wchar_t)’ in the
  2639. ‘realloc’ call.
  2640. *Compatibility Note:* The string collation functions are a new
  2641. feature of ISO C90. Older C dialects have no equivalent feature. The
  2642. wide character versions were introduced in Amendment 1 to ISO C90.
  2643. 
  2644. File: libc.info, Node: Search Functions, Next: Finding Tokens in a String, Prev: Collation Functions, Up: String and Array Utilities
  2645. 5.9 Search Functions
  2646. ====================
  2647. This section describes library functions which perform various kinds of
  2648. searching operations on strings and arrays. These functions are
  2649. declared in the header file ‘string.h’.
  2650. -- Function: void * memchr (const void *BLOCK, int C, size_t SIZE)
  2651. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2652. Concepts::.
  2653. This function finds the first occurrence of the byte C (converted
  2654. to an ‘unsigned char’) in the initial SIZE bytes of the object
  2655. beginning at BLOCK. The return value is a pointer to the located
  2656. byte, or a null pointer if no match was found.
  2657. In ISO C23 and later, this function is qualifier-generic: that is,
  2658. it is also implemented as a function-like macro, and when the macro
  2659. is used and BLOCK has a type that is a pointer to a
  2660. ‘const’-qualified object type, ‘memchr’ returns ‘const void *’. As
  2661. an obsolescent feature, if the macro is suppressed the external
  2662. function returns ‘void *’ regardless. The function is also
  2663. qualifier-generic in C++.
  2664. -- Function: wchar_t * wmemchr (const wchar_t *BLOCK, wchar_t WC,
  2665. size_t SIZE)
  2666. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2667. Concepts::.
  2668. This function finds the first occurrence of the wide character WC
  2669. in the initial SIZE wide characters of the object beginning at
  2670. BLOCK. The return value is a pointer to the located wide
  2671. character, or a null pointer if no match was found.
  2672. In ISO C23 and later, this function is qualifier-generic: that is,
  2673. it is also implemented as a function-like macro, and when the macro
  2674. is used and BLOCK has a type that is a pointer to a
  2675. ‘const’-qualified object type, ‘wmemchr’ returns ‘const wchar_t *’.
  2676. As an obsolescent feature, if the macro is suppressed the external
  2677. function returns ‘wchar_t *’ regardless. The function is also
  2678. qualifier-generic in C++.
  2679. -- Function: void * rawmemchr (const void *BLOCK, int C)
  2680. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2681. Concepts::.
  2682. Often the ‘memchr’ function is used with the knowledge that the
  2683. byte C is available in the memory block specified by the
  2684. parameters. But this means that the SIZE parameter is not really
  2685. needed and that the tests performed with it at runtime (to check
  2686. whether the end of the block is reached) are not needed.
  2687. The ‘rawmemchr’ function exists for just this situation which is
  2688. surprisingly frequent. The interface is similar to ‘memchr’ except
  2689. that the SIZE parameter is missing. The function will look beyond
  2690. the end of the block pointed to by BLOCK in case the programmer
  2691. made an error in assuming that the byte C is present in the block.
  2692. In this case the result is unspecified. Otherwise the return value
  2693. is a pointer to the located byte.
  2694. When looking for the end of a string, use ‘strchr’.
  2695. This function is a GNU extension.
  2696. -- Function: void * memrchr (const void *BLOCK, int C, size_t SIZE)
  2697. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2698. Concepts::.
  2699. The function ‘memrchr’ is like ‘memchr’, except that it searches
  2700. backwards from the end of the block defined by BLOCK and SIZE
  2701. (instead of forwards from the front).
  2702. This function is a GNU extension.
  2703. -- Function: char * strchr (const char *STRING, int C)
  2704. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2705. Concepts::.
  2706. The ‘strchr’ function finds the first occurrence of the byte C
  2707. (converted to a ‘char’) in the string beginning at STRING. The
  2708. return value is a pointer to the located byte, or a null pointer if
  2709. no match was found.
  2710. For example,
  2711. strchr ("hello, world", 'l')
  2712. ⇒ "llo, world"
  2713. strchr ("hello, world", '?')
  2714. ⇒ NULL
  2715. The terminating null byte is considered to be part of the string,
  2716. so you can use this function get a pointer to the end of a string
  2717. by specifying zero as the value of the C argument.
  2718. When ‘strchr’ returns a null pointer, it does not let you know the
  2719. position of the terminating null byte it has found. If you need
  2720. that information, it is better (but less portable) to use
  2721. ‘strchrnul’ than to search for it a second time.
  2722. In ISO C23 and later, this function is qualifier-generic: that is,
  2723. it is also implemented as a function-like macro, and when the macro
  2724. is used and STRING has a type that is a pointer to a
  2725. ‘const’-qualified object type, ‘strchr’ returns ‘const char *’. As
  2726. an obsolescent feature, if the macro is suppressed the external
  2727. function returns ‘char *’ regardless. The function is also
  2728. qualifier-generic in C++.
  2729. -- Function: wchar_t * wcschr (const wchar_t *WSTRING, wchar_t WC)
  2730. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2731. Concepts::.
  2732. The ‘wcschr’ function finds the first occurrence of the wide
  2733. character WC in the wide string beginning at WSTRING. The return
  2734. value is a pointer to the located wide character, or a null pointer
  2735. if no match was found.
  2736. The terminating null wide character is considered to be part of the
  2737. wide string, so you can use this function get a pointer to the end
  2738. of a wide string by specifying a null wide character as the value
  2739. of the WC argument. It would be better (but less portable) to use
  2740. ‘wcschrnul’ in this case, though.
  2741. In ISO C23 and later, this function is qualifier-generic: that is,
  2742. it is also implemented as a function-like macro, and when the macro
  2743. is used and WSTRING has a type that is a pointer to a
  2744. ‘const’-qualified object type, ‘wcschr’ returns ‘const wchar_t *’.
  2745. As an obsolescent feature, if the macro is suppressed the external
  2746. function returns ‘wchar_t *’ regardless. The function is also
  2747. qualifier-generic in C++.
  2748. -- Function: char * strchrnul (const char *STRING, int C)
  2749. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2750. Concepts::.
  2751. ‘strchrnul’ is the same as ‘strchr’ except that if it does not find
  2752. the byte, it returns a pointer to string's terminating null byte
  2753. rather than a null pointer.
  2754. This function is a GNU extension.
  2755. -- Function: wchar_t * wcschrnul (const wchar_t *WSTRING, wchar_t WC)
  2756. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2757. Concepts::.
  2758. ‘wcschrnul’ is the same as ‘wcschr’ except that if it does not find
  2759. the wide character, it returns a pointer to the wide string's
  2760. terminating null wide character rather than a null pointer.
  2761. This function is a GNU extension.
  2762. One useful, but unusual, use of the ‘strchr’ function is when one
  2763. wants to have a pointer pointing to the null byte terminating a string.
  2764. This is often written in this way:
  2765. s += strlen (s);
  2766. This is almost optimal but the addition operation duplicated a bit of
  2767. the work already done in the ‘strlen’ function. A better solution is
  2768. this:
  2769. s = strchr (s, '\0');
  2770. There is no restriction on the second parameter of ‘strchr’ so it
  2771. could very well also be zero. Those readers thinking very hard about
  2772. this might now point out that the ‘strchr’ function is more expensive
  2773. than the ‘strlen’ function since we have two abort criteria. This is
  2774. right. But in the GNU C Library the implementation of ‘strchr’ is
  2775. optimized in a special way so that ‘strchr’ actually is faster.
  2776. -- Function: char * strrchr (const char *STRING, int C)
  2777. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2778. Concepts::.
  2779. The function ‘strrchr’ is like ‘strchr’, except that it searches
  2780. backwards from the end of the string STRING (instead of forwards
  2781. from the front).
  2782. For example,
  2783. strrchr ("hello, world", 'l')
  2784. ⇒ "ld"
  2785. In ISO C23 and later, this function is qualifier-generic: that is,
  2786. it is also implemented as a function-like macro, and when the macro
  2787. is used and STRING has a type that is a pointer to a
  2788. ‘const’-qualified object type, ‘strrchr’ returns ‘const char *’.
  2789. As an obsolescent feature, if the macro is suppressed the external
  2790. function returns ‘char *’ regardless. The function is also
  2791. qualifier-generic in C++.
  2792. -- Function: wchar_t * wcsrchr (const wchar_t *WSTRING, wchar_t WC)
  2793. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2794. Concepts::.
  2795. The function ‘wcsrchr’ is like ‘wcschr’, except that it searches
  2796. backwards from the end of the string WSTRING (instead of forwards
  2797. from the front).
  2798. In ISO C23 and later, this function is qualifier-generic: that is,
  2799. it is also implemented as a function-like macro, and when the macro
  2800. is used and WSTRING has a type that is a pointer to a
  2801. ‘const’-qualified object type, ‘wcsrchr’ returns ‘const wchar_t *’.
  2802. As an obsolescent feature, if the macro is suppressed the external
  2803. function returns ‘wchar_t *’ regardless. The function is also
  2804. qualifier-generic in C++.
  2805. -- Function: char * strstr (const char *HAYSTACK, const char *NEEDLE)
  2806. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2807. Concepts::.
  2808. This is like ‘strchr’, except that it searches HAYSTACK for a
  2809. substring NEEDLE rather than just a single byte. It returns a
  2810. pointer into the string HAYSTACK that is the first byte of the
  2811. substring, or a null pointer if no match was found. If NEEDLE is
  2812. an empty string, the function returns HAYSTACK.
  2813. For example,
  2814. strstr ("hello, world", "l")
  2815. ⇒ "llo, world"
  2816. strstr ("hello, world", "wo")
  2817. ⇒ "world"
  2818. In ISO C23 and later, this function is qualifier-generic: that is,
  2819. it is also implemented as a function-like macro, and when the macro
  2820. is used and HAYSTACK has a type that is a pointer to a
  2821. ‘const’-qualified object type, ‘strstr’ returns ‘const char *’. As
  2822. an obsolescent feature, if the macro is suppressed the external
  2823. function returns ‘char *’ regardless. The function is also
  2824. qualifier-generic in C++.
  2825. -- Function: wchar_t * wcsstr (const wchar_t *HAYSTACK, const wchar_t
  2826. *NEEDLE)
  2827. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2828. Concepts::.
  2829. This is like ‘wcschr’, except that it searches HAYSTACK for a
  2830. substring NEEDLE rather than just a single wide character. It
  2831. returns a pointer into the string HAYSTACK that is the first wide
  2832. character of the substring, or a null pointer if no match was
  2833. found. If NEEDLE is an empty string, the function returns
  2834. HAYSTACK.
  2835. In ISO C23 and later, this function is qualifier-generic: that is,
  2836. it is also implemented as a function-like macro, and when the macro
  2837. is used and HAYSTACK has a type that is a pointer to a
  2838. ‘const’-qualified object type, ‘wcsstr’ returns ‘const wchar_t *’.
  2839. As an obsolescent feature, if the macro is suppressed the external
  2840. function returns ‘wchar_t *’ regardless. The function is also
  2841. qualifier-generic in C++.
  2842. -- Function: wchar_t * wcswcs (const wchar_t *HAYSTACK, const wchar_t
  2843. *NEEDLE)
  2844. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2845. Concepts::.
  2846. ‘wcswcs’ is a deprecated alias for ‘wcsstr’. This is the name
  2847. originally used in the X/Open Portability Guide before the
  2848. Amendment 1 to ISO C90 was published.
  2849. -- Function: char * strcasestr (const char *HAYSTACK, const char
  2850. *NEEDLE)
  2851. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  2852. Safety Concepts::.
  2853. This is like ‘strstr’, except that it ignores case in searching for
  2854. the substring. Like ‘strcasecmp’, it is locale dependent how
  2855. uppercase and lowercase characters are related, and arguments are
  2856. multibyte strings.
  2857. For example,
  2858. strcasestr ("hello, world", "L")
  2859. ⇒ "llo, world"
  2860. strcasestr ("hello, World", "wo")
  2861. ⇒ "World"
  2862. -- Function: void * memmem (const void *HAYSTACK, size_t HAYSTACK-LEN,
  2863. const void *NEEDLE, size_t NEEDLE-LEN)
  2864. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2865. Concepts::.
  2866. This is like ‘strstr’, but NEEDLE and HAYSTACK are byte arrays
  2867. rather than strings. NEEDLE-LEN is the length of NEEDLE and
  2868. HAYSTACK-LEN is the length of HAYSTACK.
  2869. This function was originally a GNU extension, but was added in
  2870. POSIX.1-2024.
  2871. -- Function: size_t strspn (const char *STRING, const char *SKIPSET)
  2872. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2873. Concepts::.
  2874. The ‘strspn’ ("string span") function returns the length of the
  2875. initial substring of STRING that consists entirely of bytes that
  2876. are members of the set specified by the string SKIPSET. The order
  2877. of the bytes in SKIPSET is not important.
  2878. For example,
  2879. strspn ("hello, world", "abcdefghijklmnopqrstuvwxyz")
  2880. ⇒ 5
  2881. In a multibyte string, characters consisting of more than one byte
  2882. are not treated as single entities. Each byte is treated
  2883. separately. The function is not locale-dependent.
  2884. -- Function: size_t wcsspn (const wchar_t *WSTRING, const wchar_t
  2885. *SKIPSET)
  2886. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2887. Concepts::.
  2888. The ‘wcsspn’ ("wide character string span") function returns the
  2889. length of the initial substring of WSTRING that consists entirely
  2890. of wide characters that are members of the set specified by the
  2891. string SKIPSET. The order of the wide characters in SKIPSET is not
  2892. important.
  2893. -- Function: size_t strcspn (const char *STRING, const char *STOPSET)
  2894. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2895. Concepts::.
  2896. The ‘strcspn’ ("string complement span") function returns the
  2897. length of the initial substring of STRING that consists entirely of
  2898. bytes that are _not_ members of the set specified by the string
  2899. STOPSET. (In other words, it returns the offset of the first byte
  2900. in STRING that is a member of the set STOPSET.)
  2901. For example,
  2902. strcspn ("hello, world", " \t\n,.;!?")
  2903. ⇒ 5
  2904. In a multibyte string, characters consisting of more than one byte
  2905. are not treated as a single entities. Each byte is treated
  2906. separately. The function is not locale-dependent.
  2907. -- Function: size_t wcscspn (const wchar_t *WSTRING, const wchar_t
  2908. *STOPSET)
  2909. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2910. Concepts::.
  2911. The ‘wcscspn’ ("wide character string complement span") function
  2912. returns the length of the initial substring of WSTRING that
  2913. consists entirely of wide characters that are _not_ members of the
  2914. set specified by the string STOPSET. (In other words, it returns
  2915. the offset of the first wide character in STRING that is a member
  2916. of the set STOPSET.)
  2917. -- Function: char * strpbrk (const char *STRING, const char *STOPSET)
  2918. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2919. Concepts::.
  2920. The ‘strpbrk’ ("string pointer break") function is related to
  2921. ‘strcspn’, except that it returns a pointer to the first byte in
  2922. STRING that is a member of the set STOPSET instead of the length of
  2923. the initial substring. It returns a null pointer if no such byte
  2924. from STOPSET is found.
  2925. For example,
  2926. strpbrk ("hello, world", " \t\n,.;!?")
  2927. ⇒ ", world"
  2928. In a multibyte string, characters consisting of more than one byte
  2929. are not treated as single entities. Each byte is treated
  2930. separately. The function is not locale-dependent.
  2931. In ISO C23 and later, this function is qualifier-generic: that is,
  2932. it is also implemented as a function-like macro, and when the macro
  2933. is used and STRING has a type that is a pointer to a
  2934. ‘const’-qualified object type, ‘strpbrk’ returns ‘const char *’.
  2935. As an obsolescent feature, if the macro is suppressed the external
  2936. function returns ‘char *’ regardless. The function is also
  2937. qualifier-generic in C++.
  2938. -- Function: wchar_t * wcspbrk (const wchar_t *WSTRING, const wchar_t
  2939. *STOPSET)
  2940. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2941. Concepts::.
  2942. The ‘wcspbrk’ ("wide character string pointer break") function is
  2943. related to ‘wcscspn’, except that it returns a pointer to the first
  2944. wide character in WSTRING that is a member of the set STOPSET
  2945. instead of the length of the initial substring. It returns a null
  2946. pointer if no such wide character from STOPSET is found.
  2947. In ISO C23 and later, this function is qualifier-generic: that is,
  2948. it is also implemented as a function-like macro, and when the macro
  2949. is used and WSTRING has a type that is a pointer to a
  2950. ‘const’-qualified object type, ‘wcspbrk’ returns ‘const wchar_t *’.
  2951. As an obsolescent feature, if the macro is suppressed the external
  2952. function returns ‘wchar_t *’ regardless. The function is also
  2953. qualifier-generic in C++.
  2954. 5.9.1 Compatibility String Search Functions
  2955. -------------------------------------------
  2956. -- Function: char * index (const char *STRING, int C)
  2957. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2958. Concepts::.
  2959. ‘index’ is another name for ‘strchr’; they are exactly the same.
  2960. New code should always use ‘strchr’ since this name is defined in
  2961. ISO C while ‘index’ is a BSD invention which never was available on
  2962. System V derived systems.
  2963. -- Function: char * rindex (const char *STRING, int C)
  2964. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2965. Concepts::.
  2966. ‘rindex’ is another name for ‘strrchr’; they are exactly the same.
  2967. New code should always use ‘strrchr’ since this name is defined in
  2968. ISO C while ‘rindex’ is a BSD invention which never was available
  2969. on System V derived systems.
  2970. 
  2971. File: libc.info, Node: Finding Tokens in a String, Next: Erasing Sensitive Data, Prev: Search Functions, Up: String and Array Utilities
  2972. 5.10 Finding Tokens in a String
  2973. ===============================
  2974. It's fairly common for programs to have a need to do some simple kinds
  2975. of lexical analysis and parsing, such as splitting a command string up
  2976. into tokens. You can do this with the ‘strtok’ function, declared in
  2977. the header file ‘string.h’.
  2978. -- Function: char * strtok (char *restrict NEWSTRING, const char
  2979. *restrict DELIMITERS)
  2980. Preliminary: | MT-Unsafe race:strtok | AS-Unsafe | AC-Safe | *Note
  2981. POSIX Safety Concepts::.
  2982. A string can be split into tokens by making a series of calls to
  2983. the function ‘strtok’.
  2984. The string to be split up is passed as the NEWSTRING argument on
  2985. the first call only. The ‘strtok’ function uses this to set up
  2986. some internal state information. Subsequent calls to get
  2987. additional tokens from the same string are indicated by passing a
  2988. null pointer as the NEWSTRING argument. Calling ‘strtok’ with
  2989. another non-null NEWSTRING argument reinitializes the state
  2990. information. It is guaranteed that no other library function ever
  2991. calls ‘strtok’ behind your back (which would mess up this internal
  2992. state information).
  2993. The DELIMITERS argument is a string that specifies a set of
  2994. delimiters that may surround the token being extracted. All the
  2995. initial bytes that are members of this set are discarded. The
  2996. first byte that is _not_ a member of this set of delimiters marks
  2997. the beginning of the next token. The end of the token is found by
  2998. looking for the next byte that is a member of the delimiter set.
  2999. This byte in the original string NEWSTRING is overwritten by a null
  3000. byte, and the pointer to the beginning of the token in NEWSTRING is
  3001. returned.
  3002. On the next call to ‘strtok’, the searching begins at the next byte
  3003. beyond the one that marked the end of the previous token. Note
  3004. that the set of delimiters DELIMITERS do not have to be the same on
  3005. every call in a series of calls to ‘strtok’.
  3006. If the end of the string NEWSTRING is reached, or if the remainder
  3007. of string consists only of delimiter bytes, ‘strtok’ returns a null
  3008. pointer.
  3009. In a multibyte string, characters consisting of more than one byte
  3010. are not treated as single entities. Each byte is treated
  3011. separately. The function is not locale-dependent.
  3012. -- Function: wchar_t * wcstok (wchar_t *NEWSTRING, const wchar_t
  3013. *DELIMITERS, wchar_t **SAVE_PTR)
  3014. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3015. Concepts::.
  3016. A string can be split into tokens by making a series of calls to
  3017. the function ‘wcstok’.
  3018. The string to be split up is passed as the NEWSTRING argument on
  3019. the first call only. The ‘wcstok’ function uses this to set up
  3020. some internal state information. Subsequent calls to get
  3021. additional tokens from the same wide string are indicated by
  3022. passing a null pointer as the NEWSTRING argument, which causes the
  3023. pointer previously stored in SAVE_PTR to be used instead.
  3024. The DELIMITERS argument is a wide string that specifies a set of
  3025. delimiters that may surround the token being extracted. All the
  3026. initial wide characters that are members of this set are discarded.
  3027. The first wide character that is _not_ a member of this set of
  3028. delimiters marks the beginning of the next token. The end of the
  3029. token is found by looking for the next wide character that is a
  3030. member of the delimiter set. This wide character in the original
  3031. wide string NEWSTRING is overwritten by a null wide character, the
  3032. pointer past the overwritten wide character is saved in SAVE_PTR,
  3033. and the pointer to the beginning of the token in NEWSTRING is
  3034. returned.
  3035. On the next call to ‘wcstok’, the searching begins at the next wide
  3036. character beyond the one that marked the end of the previous token.
  3037. Note that the set of delimiters DELIMITERS do not have to be the
  3038. same on every call in a series of calls to ‘wcstok’.
  3039. If the end of the wide string NEWSTRING is reached, or if the
  3040. remainder of string consists only of delimiter wide characters,
  3041. ‘wcstok’ returns a null pointer.
  3042. *Warning:* Since ‘strtok’ and ‘wcstok’ alter the string they is
  3043. parsing, you should always copy the string to a temporary buffer before
  3044. parsing it with ‘strtok’/‘wcstok’ (*note Copying Strings and Arrays::).
  3045. If you allow ‘strtok’ or ‘wcstok’ to modify a string that came from
  3046. another part of your program, you are asking for trouble; that string
  3047. might be used for other purposes after ‘strtok’ or ‘wcstok’ has modified
  3048. it, and it would not have the expected value.
  3049. The string that you are operating on might even be a constant. Then
  3050. when ‘strtok’ or ‘wcstok’ tries to modify it, your program will get a
  3051. fatal signal for writing in read-only memory. *Note Program Error
  3052. Signals::. Even if the operation of ‘strtok’ or ‘wcstok’ would not
  3053. require a modification of the string (e.g., if there is exactly one
  3054. token) the string can (and in the GNU C Library case will) be modified.
  3055. This is a special case of a general principle: if a part of a program
  3056. does not have as its purpose the modification of a certain data
  3057. structure, then it is error-prone to modify the data structure
  3058. temporarily.
  3059. The function ‘strtok’ is not reentrant, whereas ‘wcstok’ is. *Note
  3060. Nonreentrancy::, for a discussion of where and why reentrancy is
  3061. important.
  3062. Here is a simple example showing the use of ‘strtok’.
  3063. #include <string.h>
  3064. #include <stddef.h>
  3065. ...
  3066. const char string[] = "words separated by spaces -- and, punctuation!";
  3067. const char delimiters[] = " .,;:!-";
  3068. char *token, *cp;
  3069. ...
  3070. cp = strdupa (string); /* Make writable copy. */
  3071. token = strtok (cp, delimiters); /* token => "words" */
  3072. token = strtok (NULL, delimiters); /* token => "separated" */
  3073. token = strtok (NULL, delimiters); /* token => "by" */
  3074. token = strtok (NULL, delimiters); /* token => "spaces" */
  3075. token = strtok (NULL, delimiters); /* token => "and" */
  3076. token = strtok (NULL, delimiters); /* token => "punctuation" */
  3077. token = strtok (NULL, delimiters); /* token => NULL */
  3078. The GNU C Library contains two more functions for tokenizing a string
  3079. which overcome the limitation of non-reentrancy. They are not available
  3080. available for wide strings.
  3081. -- Function: char * strtok_r (char *NEWSTRING, const char *DELIMITERS,
  3082. char **SAVE_PTR)
  3083. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3084. Concepts::.
  3085. Just like ‘strtok’, this function splits the string into several
  3086. tokens which can be accessed by successive calls to ‘strtok_r’.
  3087. The difference is that, as in ‘wcstok’, the information about the
  3088. next token is stored in the space pointed to by the third argument,
  3089. SAVE_PTR, which is a pointer to a string pointer. Calling
  3090. ‘strtok_r’ with a null pointer for NEWSTRING and leaving SAVE_PTR
  3091. between the calls unchanged does the job without hindering
  3092. reentrancy.
  3093. This function is defined in POSIX.1 and can be found on many
  3094. systems which support multi-threading.
  3095. -- Function: char * strsep (char **STRING_PTR, const char *DELIMITER)
  3096. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3097. Concepts::.
  3098. This function has a similar functionality as ‘strtok_r’ with the
  3099. NEWSTRING argument replaced by the SAVE_PTR argument. The
  3100. initialization of the moving pointer has to be done by the user.
  3101. Successive calls to ‘strsep’ move the pointer along the tokens
  3102. separated by DELIMITER, returning the address of the next token and
  3103. updating STRING_PTR to point to the beginning of the next token.
  3104. One difference between ‘strsep’ and ‘strtok_r’ is that if the input
  3105. string contains more than one byte from DELIMITER in a row ‘strsep’
  3106. returns an empty string for each pair of bytes from DELIMITER.
  3107. This means that a program normally should test for ‘strsep’
  3108. returning an empty string before processing it.
  3109. This function was introduced in 4.3BSD and therefore is widely
  3110. available.
  3111. Here is how the above example looks like when ‘strsep’ is used.
  3112. #include <string.h>
  3113. #include <stddef.h>
  3114. ...
  3115. const char string[] = "words separated by spaces -- and, punctuation!";
  3116. const char delimiters[] = " .,;:!-";
  3117. char *running;
  3118. char *token;
  3119. ...
  3120. running = strdupa (string);
  3121. token = strsep (&running, delimiters); /* token => "words" */
  3122. token = strsep (&running, delimiters); /* token => "separated" */
  3123. token = strsep (&running, delimiters); /* token => "by" */
  3124. token = strsep (&running, delimiters); /* token => "spaces" */
  3125. token = strsep (&running, delimiters); /* token => "" */
  3126. token = strsep (&running, delimiters); /* token => "" */
  3127. token = strsep (&running, delimiters); /* token => "" */
  3128. token = strsep (&running, delimiters); /* token => "and" */
  3129. token = strsep (&running, delimiters); /* token => "" */
  3130. token = strsep (&running, delimiters); /* token => "punctuation" */
  3131. token = strsep (&running, delimiters); /* token => "" */
  3132. token = strsep (&running, delimiters); /* token => NULL */
  3133. -- Function: char * basename (const char *FILENAME)
  3134. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3135. Concepts::.
  3136. The GNU version of the ‘basename’ function returns the last
  3137. component of the path in FILENAME. This function is the preferred
  3138. usage, since it does not modify the argument, FILENAME, and
  3139. respects trailing slashes. The prototype for ‘basename’ can be
  3140. found in ‘string.h’. Note, this function is overridden by the XPG
  3141. version, if ‘libgen.h’ is included.
  3142. Example of using GNU ‘basename’:
  3143. #include <string.h>
  3144. int
  3145. main (int argc, char *argv[])
  3146. {
  3147. char *prog = basename (argv[0]);
  3148. if (argc < 2)
  3149. {
  3150. fprintf (stderr, "Usage %s <arg>\n", prog);
  3151. exit (1);
  3152. }
  3153. ...
  3154. }
  3155. *Portability Note:* This function may produce different results on
  3156. different systems.
  3157. -- Function: char * basename (char *PATH)
  3158. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3159. Concepts::.
  3160. This is the standard XPG defined ‘basename’. It is similar in
  3161. spirit to the GNU version, but may modify the PATH by removing
  3162. trailing '/' bytes. If the PATH is made up entirely of '/' bytes,
  3163. then "/" will be returned. Also, if PATH is ‘NULL’ or an empty
  3164. string, then "." is returned. The prototype for the XPG version
  3165. can be found in ‘libgen.h’.
  3166. Example of using XPG ‘basename’:
  3167. #include <libgen.h>
  3168. int
  3169. main (int argc, char *argv[])
  3170. {
  3171. char *prog;
  3172. char *path = strdupa (argv[0]);
  3173. prog = basename (path);
  3174. if (argc < 2)
  3175. {
  3176. fprintf (stderr, "Usage %s <arg>\n", prog);
  3177. exit (1);
  3178. }
  3179. ...
  3180. }
  3181. -- Function: char * dirname (char *PATH)
  3182. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3183. Concepts::.
  3184. The ‘dirname’ function is the compliment to the XPG version of
  3185. ‘basename’. It returns the parent directory of the file specified
  3186. by PATH. If PATH is ‘NULL’, an empty string, or contains no '/'
  3187. bytes, then "." is returned. The prototype for this function can
  3188. be found in ‘libgen.h’.
  3189. 
  3190. File: libc.info, Node: Erasing Sensitive Data, Next: Shuffling Bytes, Prev: Finding Tokens in a String, Up: String and Array Utilities
  3191. 5.11 Erasing Sensitive Data
  3192. ===========================
  3193. Sensitive data, such as cryptographic keys, should be erased from memory
  3194. after use, to reduce the risk that a bug will expose it to the outside
  3195. world. However, compiler optimizations may determine that an erasure
  3196. operation is "unnecessary," and remove it from the generated code,
  3197. because no _correct_ program could access the variable or heap object
  3198. containing the sensitive data after it's deallocated. Since erasure is
  3199. a precaution against bugs, this optimization is inappropriate.
  3200. The functions ‘explicit_bzero’ and ‘memset_explicit’ erase a block of
  3201. memory, and guarantee that the compiler will not remove the erasure as
  3202. "unnecessary."
  3203. #include <string.h>
  3204. extern void encrypt (const char *key, const char *in,
  3205. char *out, size_t n);
  3206. extern void genkey (const char *phrase, char *key);
  3207. void encrypt_with_phrase (const char *phrase, const char *in,
  3208. char *out, size_t n)
  3209. {
  3210. char key[16];
  3211. genkey (phrase, key);
  3212. encrypt (key, in, out, n);
  3213. explicit_bzero (key, 16);
  3214. }
  3215. In this example, if ‘memset’, ‘bzero’, or a hand-written loop had been
  3216. used, the compiler might remove them as "unnecessary."
  3217. *Warning:* ‘explicit_bzero’ and ‘memset_explicit’ do not guarantee
  3218. that sensitive data is _completely_ erased from the computer's memory.
  3219. There may be copies in temporary storage areas, such as registers and
  3220. "scratch" stack space; since these are invisible to the source code, a
  3221. library function cannot erase them.
  3222. Also, ‘explicit_bzero’ and ‘memset_explicit’ only operate on RAM. If
  3223. a sensitive data object never needs to have its address taken other than
  3224. to call ‘explicit_bzero’ or ‘memset_explicit’, it might be stored
  3225. entirely in CPU registers _until_ the call to ‘explicit_bzero’ or
  3226. ‘memset_explicit’. Then it will be copied into RAM, the copy will be
  3227. erased, and the original will remain intact. Data in RAM is more likely
  3228. to be exposed by a bug than data in registers, so this creates a brief
  3229. window where the data is at greater risk of exposure than it would have
  3230. been if the program didn't try to erase it at all.
  3231. Declaring sensitive variables as ‘volatile’ will make both the above
  3232. problems _worse_; a ‘volatile’ variable will be stored in memory for its
  3233. entire lifetime, and the compiler will make _more_ copies of it than it
  3234. would otherwise have. Attempting to erase a normal variable "by hand"
  3235. through a ‘volatile’-qualified pointer doesn't work at all--because the
  3236. variable itself is not ‘volatile’, some compilers will ignore the
  3237. qualification on the pointer and remove the erasure anyway.
  3238. Having said all that, in most situations, using ‘explicit_bzero’ or
  3239. ‘memset_explicit’ is better than not using it. At present, the only way
  3240. to do a more thorough job is to write the entire sensitive operation in
  3241. assembly language. We anticipate that future compilers will recognize
  3242. calls to ‘explicit_bzero’ or ‘memset_explicit’ and take appropriate
  3243. steps to erase all the copies of the affected data, wherever they may
  3244. be.
  3245. -- Function: void explicit_bzero (void *BLOCK, size_t LEN)
  3246. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3247. Concepts::.
  3248. ‘explicit_bzero’ writes zero into LEN bytes of memory beginning at
  3249. BLOCK, just as ‘bzero’ would. The zeroes are always written, even
  3250. if the compiler could determine that this is "unnecessary" because
  3251. no correct program could read them back.
  3252. *Note:* The _only_ optimization that ‘explicit_bzero’ disables is
  3253. removal of "unnecessary" writes to memory. The compiler can
  3254. perform all the other optimizations that it could for a call to
  3255. ‘memset’. For instance, it may replace the function call with
  3256. inline memory writes, and it may assume that BLOCK cannot be a null
  3257. pointer.
  3258. *Portability Note:* This function first appeared in OpenBSD 5.5 and
  3259. has not been standardized. Other systems may provide the same
  3260. functionality under a different name, such as ‘explicit_memset’,
  3261. ‘memset_s’, or ‘SecureZeroMemory’.
  3262. The GNU C Library declares this function in ‘string.h’, but on
  3263. other systems it may be in ‘strings.h’ instead.
  3264. -- Function: void * memset_explicit (void *BLOCK, int C, size_t SIZE)
  3265. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3266. Concepts::.
  3267. This function copies the value of C (converted to an ‘unsigned
  3268. char’) into each of the first SIZE bytes of the object beginning at
  3269. BLOCK, just as ‘memset’ would. It returns the value of BLOCK. The
  3270. bytes are always written, even if the compiler could determine that
  3271. this is "unnecessary" because no correct program could read them
  3272. back.
  3273. *Note:* The _only_ optimization that ‘memset_explicit’ disables is
  3274. removal of "unnecessary" writes to memory. The compiler can
  3275. perform all the other optimizations that it could for a call to
  3276. ‘memset’. For instance, it may replace the function call with
  3277. inline memory writes, and it may assume that BLOCK cannot be a null
  3278. pointer.
  3279. 
  3280. File: libc.info, Node: Shuffling Bytes, Next: Obfuscating Data, Prev: Erasing Sensitive Data, Up: String and Array Utilities
  3281. 5.12 Shuffling Bytes
  3282. ====================
  3283. The function below addresses the perennial programming quandary: "How do
  3284. I take good data in string form and painlessly turn it into garbage?"
  3285. This is not a difficult thing to code for oneself, but the authors of
  3286. the GNU C Library wish to make it as convenient as possible.
  3287. To _erase_ data, use ‘explicit_bzero’ (*note Erasing Sensitive
  3288. Data::); to obfuscate it reversibly, use ‘memfrob’ (*note Obfuscating
  3289. Data::).
  3290. -- Function: char * strfry (char *STRING)
  3291. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3292. Concepts::.
  3293. ‘strfry’ performs an in-place shuffle on STRING. Each character is
  3294. swapped to a position selected at random, within the portion of the
  3295. string starting with the character's original position. (This is
  3296. the Fisher-Yates algorithm for unbiased shuffling.)
  3297. Calling ‘strfry’ will not disturb any of the random number
  3298. generators that have global state (*note Pseudo-Random Numbers::).
  3299. The return value of ‘strfry’ is always STRING.
  3300. *Portability Note:* This function is unique to the GNU C Library.
  3301. It is declared in ‘string.h’.
  3302. 
  3303. File: libc.info, Node: Obfuscating Data, Next: Encode Binary Data, Prev: Shuffling Bytes, Up: String and Array Utilities
  3304. 5.13 Obfuscating Data
  3305. =====================
  3306. The ‘memfrob’ function reversibly obfuscates an array of binary data.
  3307. This is not true encryption; the obfuscated data still bears a clear
  3308. relationship to the original, and no secret key is required to undo the
  3309. obfuscation. It is analogous to the "Rot13" cipher used on Usenet for
  3310. obscuring offensive jokes, spoilers for works of fiction, and so on, but
  3311. it can be applied to arbitrary binary data.
  3312. Programs that need true encryption--a transformation that completely
  3313. obscures the original and cannot be reversed without knowledge of a
  3314. secret key--should use a dedicated cryptography library, such as
  3315. libgcrypt.
  3316. Programs that need to _destroy_ data should use ‘explicit_bzero’
  3317. (*note Erasing Sensitive Data::), or possibly ‘strfry’ (*note Shuffling
  3318. Bytes::).
  3319. -- Function: void * memfrob (void *MEM, size_t LENGTH)
  3320. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3321. Concepts::.
  3322. The function ‘memfrob’ obfuscates LENGTH bytes of data beginning at
  3323. MEM, in place. Each byte is bitwise xor-ed with the binary pattern
  3324. 00101010 (hexadecimal 0x2A). The return value is always MEM.
  3325. ‘memfrob’ a second time on the same data returns it to its original
  3326. state.
  3327. *Portability Note:* This function is unique to the GNU C Library.
  3328. It is declared in ‘string.h’.
  3329. 
  3330. File: libc.info, Node: Encode Binary Data, Next: Argz and Envz Vectors, Prev: Obfuscating Data, Up: String and Array Utilities
  3331. 5.14 Encode Binary Data
  3332. =======================
  3333. To store or transfer binary data in environments which only support text
  3334. one has to encode the binary data by mapping the input bytes to bytes in
  3335. the range allowed for storing or transferring. SVID systems (and
  3336. nowadays XPG compliant systems) provide minimal support for this task.
  3337. -- Function: char * l64a (long int N)
  3338. Preliminary: | MT-Unsafe race:l64a | AS-Unsafe | AC-Safe | *Note
  3339. POSIX Safety Concepts::.
  3340. This function encodes a 32-bit input value using bytes from the
  3341. basic character set. It returns a pointer to a 7 byte buffer which
  3342. contains an encoded version of N. To encode a series of bytes the
  3343. user must copy the returned string to a destination buffer. It
  3344. returns the empty string if N is zero, which is somewhat bizarre
  3345. but mandated by the standard.
  3346. *Warning:* Since a static buffer is used this function should not
  3347. be used in multi-threaded programs. There is no thread-safe
  3348. alternative to this function in the C library.
  3349. *Compatibility Note:* The XPG standard states that the return value
  3350. of ‘l64a’ is undefined if N is negative. In the GNU
  3351. implementation, ‘l64a’ treats its argument as unsigned, so it will
  3352. return a sensible encoding for any nonzero N; however, portable
  3353. programs should not rely on this.
  3354. To encode a large buffer ‘l64a’ must be called in a loop, once for
  3355. each 32-bit word of the buffer. For example, one could do
  3356. something like this:
  3357. char *
  3358. encode (const void *buf, size_t len)
  3359. {
  3360. /* We know in advance how long the buffer has to be. */
  3361. unsigned char *in = (unsigned char *) buf;
  3362. char *out = malloc (6 + ((len + 3) / 4) * 6 + 1);
  3363. char *cp = out, *p;
  3364. /* Encode the length. */
  3365. /* Using 'htonl' is necessary so that the data can be
  3366. decoded even on machines with different byte order.
  3367. 'l64a' can return a string shorter than 6 bytes, so
  3368. we pad it with encoding of 0 ('.') at the end by
  3369. hand. */
  3370. p = stpcpy (cp, l64a (htonl (len)));
  3371. cp = mempcpy (p, "......", 6 - (p - cp));
  3372. while (len > 3)
  3373. {
  3374. unsigned long int n = *in++;
  3375. n = (n << 8) | *in++;
  3376. n = (n << 8) | *in++;
  3377. n = (n << 8) | *in++;
  3378. len -= 4;
  3379. p = stpcpy (cp, l64a (htonl (n)));
  3380. cp = mempcpy (p, "......", 6 - (p - cp));
  3381. }
  3382. if (len > 0)
  3383. {
  3384. unsigned long int n = *in++;
  3385. if (--len > 0)
  3386. {
  3387. n = (n << 8) | *in++;
  3388. if (--len > 0)
  3389. n = (n << 8) | *in;
  3390. }
  3391. cp = stpcpy (cp, l64a (htonl (n)));
  3392. }
  3393. *cp = '\0';
  3394. return out;
  3395. }
  3396. It is strange that the library does not provide the complete
  3397. functionality needed but so be it.
  3398. To decode data produced with ‘l64a’ the following function should be
  3399. used.
  3400. -- Function: long int a64l (const char *STRING)
  3401. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3402. Concepts::.
  3403. The parameter STRING should contain a string which was produced by
  3404. a call to ‘l64a’. The function processes at least 6 bytes of this
  3405. string, and decodes the bytes it finds according to the table
  3406. below. It stops decoding when it finds a byte not in the table,
  3407. rather like ‘atoi’; if you have a buffer which has been broken into
  3408. lines, you must be careful to skip over the end-of-line bytes.
  3409. The decoded number is returned as a ‘long int’ value.
  3410. The ‘l64a’ and ‘a64l’ functions use a base 64 encoding, in which each
  3411. byte of an encoded string represents six bits of an input word. These
  3412. symbols are used for the base 64 digits:
  3413. 0 1 2 3 4 5 6 7
  3414. 0 ‘.’ ‘/’ ‘0’ ‘1’ ‘2’ ‘3’ ‘4’ ‘5’
  3415. 8 ‘6’ ‘7’ ‘8’ ‘9’ ‘A’ ‘B’ ‘C’ ‘D’
  3416. 16 ‘E’ ‘F’ ‘G’ ‘H’ ‘I’ ‘J’ ‘K’ ‘L’
  3417. 24 ‘M’ ‘N’ ‘O’ ‘P’ ‘Q’ ‘R’ ‘S’ ‘T’
  3418. 32 ‘U’ ‘V’ ‘W’ ‘X’ ‘Y’ ‘Z’ ‘a’ ‘b’
  3419. 40 ‘c’ ‘d’ ‘e’ ‘f’ ‘g’ ‘h’ ‘i’ ‘j’
  3420. 48 ‘k’ ‘l’ ‘m’ ‘n’ ‘o’ ‘p’ ‘q’ ‘r’
  3421. 56 ‘s’ ‘t’ ‘u’ ‘v’ ‘w’ ‘x’ ‘y’ ‘z’
  3422. This encoding scheme is not standard. There are some other encoding
  3423. methods which are much more widely used (UU encoding, MIME encoding).
  3424. Generally, it is better to use one of these encodings.
  3425. 
  3426. File: libc.info, Node: Argz and Envz Vectors, Prev: Encode Binary Data, Up: String and Array Utilities
  3427. 5.15 Argz and Envz Vectors
  3428. ==========================
  3429. “argz vectors” are vectors of strings in a contiguous block of memory,
  3430. each element separated from its neighbors by null bytes (‘'\0'’).
  3431. “Envz vectors” are an extension of argz vectors where each element is
  3432. a name-value pair, separated by a ‘'='’ byte (as in a Unix environment).
  3433. * Menu:
  3434. * Argz Functions:: Operations on argz vectors.
  3435. * Envz Functions:: Additional operations on environment vectors.
  3436. 
  3437. File: libc.info, Node: Argz Functions, Next: Envz Functions, Up: Argz and Envz Vectors
  3438. 5.15.1 Argz Functions
  3439. ---------------------
  3440. Each argz vector is represented by a pointer to the first element, of
  3441. type ‘char *’, and a size, of type ‘size_t’, both of which can be
  3442. initialized to ‘0’ to represent an empty argz vector. All argz
  3443. functions accept either a pointer and a size argument, or pointers to
  3444. them, if they will be modified.
  3445. The argz functions use ‘malloc’/‘realloc’ to allocate/grow argz
  3446. vectors, and so any argz vector created using these functions may be
  3447. freed by using ‘free’; conversely, any argz function that may grow a
  3448. string expects that string to have been allocated using ‘malloc’ (those
  3449. argz functions that only examine their arguments or modify them in place
  3450. will work on any sort of memory). *Note Unconstrained Allocation::.
  3451. All argz functions that do memory allocation have a return type of
  3452. ‘error_t’, and return ‘0’ for success, and ‘ENOMEM’ if an allocation
  3453. error occurs.
  3454. These functions are declared in the standard include file ‘argz.h’.
  3455. -- Function: error_t argz_create (char *const ARGV[], char **ARGZ,
  3456. size_t *ARGZ_LEN)
  3457. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3458. POSIX Safety Concepts::.
  3459. The ‘argz_create’ function converts the Unix-style argument vector
  3460. ARGV (a vector of pointers to normal C strings, terminated by
  3461. ‘(char *)0’; *note Program Arguments::) into an argz vector with
  3462. the same elements, which is returned in ARGZ and ARGZ_LEN.
  3463. -- Function: error_t argz_create_sep (const char *STRING, int SEP, char
  3464. **ARGZ, size_t *ARGZ_LEN)
  3465. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3466. POSIX Safety Concepts::.
  3467. The ‘argz_create_sep’ function converts the string STRING into an
  3468. argz vector (returned in ARGZ and ARGZ_LEN) by splitting it into
  3469. elements at every occurrence of the byte SEP.
  3470. -- Function: size_t argz_count (const char *ARGZ, size_t ARGZ_LEN)
  3471. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3472. Concepts::.
  3473. Returns the number of elements in the argz vector ARGZ and
  3474. ARGZ_LEN.
  3475. -- Function: void argz_extract (const char *ARGZ, size_t ARGZ_LEN, char
  3476. **ARGV)
  3477. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3478. Concepts::.
  3479. The ‘argz_extract’ function converts the argz vector ARGZ and
  3480. ARGZ_LEN into a Unix-style argument vector stored in ARGV, by
  3481. putting pointers to every element in ARGZ into successive positions
  3482. in ARGV, followed by a terminator of ‘0’. ARGV must be
  3483. pre-allocated with enough space to hold all the elements in ARGZ
  3484. plus the terminating ‘(char *)0’ (‘(argz_count (ARGZ, ARGZ_LEN) +
  3485. 1) * sizeof (char *)’ bytes should be enough). Note that the
  3486. string pointers stored into ARGV point into ARGZ--they are not
  3487. copies--and so ARGZ must be copied if it will be changed while ARGV
  3488. is still active. This function is useful for passing the elements
  3489. in ARGZ to an exec function (*note Executing a File::).
  3490. -- Function: void argz_stringify (char *ARGZ, size_t LEN, int SEP)
  3491. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3492. Concepts::.
  3493. The ‘argz_stringify’ converts ARGZ into a normal string with the
  3494. elements separated by the byte SEP, by replacing each ‘'\0'’ inside
  3495. ARGZ (except the last one, which terminates the string) with SEP.
  3496. This is handy for printing ARGZ in a readable manner.
  3497. -- Function: error_t argz_add (char **ARGZ, size_t *ARGZ_LEN, const
  3498. char *STR)
  3499. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3500. POSIX Safety Concepts::.
  3501. The ‘argz_add’ function adds the string STR to the end of the argz
  3502. vector ‘*ARGZ’, and updates ‘*ARGZ’ and ‘*ARGZ_LEN’ accordingly.
  3503. -- Function: error_t argz_add_sep (char **ARGZ, size_t *ARGZ_LEN, const
  3504. char *STR, int DELIM)
  3505. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3506. POSIX Safety Concepts::.
  3507. The ‘argz_add_sep’ function is similar to ‘argz_add’, but STR is
  3508. split into separate elements in the result at occurrences of the
  3509. byte DELIM. This is useful, for instance, for adding the
  3510. components of a Unix search path to an argz vector, by using a
  3511. value of ‘':'’ for DELIM.
  3512. -- Function: error_t argz_append (char **ARGZ, size_t *ARGZ_LEN, const
  3513. char *BUF, size_t BUF_LEN)
  3514. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3515. POSIX Safety Concepts::.
  3516. The ‘argz_append’ function appends BUF_LEN bytes starting at BUF to
  3517. the argz vector ‘*ARGZ’, reallocating ‘*ARGZ’ to accommodate it,
  3518. and adding BUF_LEN to ‘*ARGZ_LEN’.
  3519. -- Function: void argz_delete (char **ARGZ, size_t *ARGZ_LEN, char
  3520. *ENTRY)
  3521. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3522. POSIX Safety Concepts::.
  3523. If ENTRY points to the beginning of one of the elements in the argz
  3524. vector ‘*ARGZ’, the ‘argz_delete’ function will remove this entry
  3525. and reallocate ‘*ARGZ’, modifying ‘*ARGZ’ and ‘*ARGZ_LEN’
  3526. accordingly. Note that as destructive argz functions usually
  3527. reallocate their argz argument, pointers into argz vectors such as
  3528. ENTRY will then become invalid.
  3529. -- Function: error_t argz_insert (char **ARGZ, size_t *ARGZ_LEN, char
  3530. *BEFORE, const char *ENTRY)
  3531. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3532. POSIX Safety Concepts::.
  3533. The ‘argz_insert’ function inserts the string ENTRY into the argz
  3534. vector ‘*ARGZ’ at a point just before the existing element pointed
  3535. to by BEFORE, reallocating ‘*ARGZ’ and updating ‘*ARGZ’ and
  3536. ‘*ARGZ_LEN’. If BEFORE is ‘0’, ENTRY is added to the end instead
  3537. (as if by ‘argz_add’). Since the first element is in fact the same
  3538. as ‘*ARGZ’, passing in ‘*ARGZ’ as the value of BEFORE will result
  3539. in ENTRY being inserted at the beginning.
  3540. -- Function: char * argz_next (const char *ARGZ, size_t ARGZ_LEN, const
  3541. char *ENTRY)
  3542. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3543. Concepts::.
  3544. The ‘argz_next’ function provides a convenient way of iterating
  3545. over the elements in the argz vector ARGZ. It returns a pointer to
  3546. the next element in ARGZ after the element ENTRY, or ‘0’ if there
  3547. are no elements following ENTRY. If ENTRY is ‘0’, the first
  3548. element of ARGZ is returned.
  3549. This behavior suggests two styles of iteration:
  3550. char *entry = 0;
  3551. while ((entry = argz_next (ARGZ, ARGZ_LEN, entry)))
  3552. ACTION;
  3553. (the double parentheses are necessary to make some C compilers shut
  3554. up about what they consider a questionable ‘while’-test) and:
  3555. char *entry;
  3556. for (entry = ARGZ;
  3557. entry;
  3558. entry = argz_next (ARGZ, ARGZ_LEN, entry))
  3559. ACTION;
  3560. Note that the latter depends on ARGZ having a value of ‘0’ if it is
  3561. empty (rather than a pointer to an empty block of memory); this
  3562. invariant is maintained for argz vectors created by the functions
  3563. here.
  3564. -- Function: error_t argz_replace (char **ARGZ, size_t *ARGZ_LEN,
  3565. const char *STR, const char *WITH, unsigned *REPLACE_COUNT)
  3566. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3567. POSIX Safety Concepts::.
  3568. Replace any occurrences of the string STR in ARGZ with WITH,
  3569. reallocating ARGZ as necessary. If REPLACE_COUNT is non-zero,
  3570. ‘*REPLACE_COUNT’ will be incremented by the number of replacements
  3571. performed.
  3572. 
  3573. File: libc.info, Node: Envz Functions, Prev: Argz Functions, Up: Argz and Envz Vectors
  3574. 5.15.2 Envz Functions
  3575. ---------------------
  3576. Envz vectors are just argz vectors with additional constraints on the
  3577. form of each element; as such, argz functions can also be used on them,
  3578. where it makes sense.
  3579. Each element in an envz vector is a name-value pair, separated by a
  3580. ‘'='’ byte; if multiple ‘'='’ bytes are present in an element, those
  3581. after the first are considered part of the value, and treated like all
  3582. other non-‘'\0'’ bytes.
  3583. If _no_ ‘'='’ bytes are present in an element, that element is
  3584. considered the name of a "null" entry, as distinct from an entry with an
  3585. empty value: ‘envz_get’ will return ‘0’ if given the name of null entry,
  3586. whereas an entry with an empty value would result in a value of ‘""’;
  3587. ‘envz_entry’ will still find such entries, however. Null entries can be
  3588. removed with the ‘envz_strip’ function.
  3589. As with argz functions, envz functions that may allocate memory (and
  3590. thus fail) have a return type of ‘error_t’, and return either ‘0’ or
  3591. ‘ENOMEM’.
  3592. These functions are declared in the standard include file ‘envz.h’.
  3593. -- Function: char * envz_entry (const char *ENVZ, size_t ENVZ_LEN,
  3594. const char *NAME)
  3595. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3596. Concepts::.
  3597. The ‘envz_entry’ function finds the entry in ENVZ with the name
  3598. NAME, and returns a pointer to the whole entry--that is, the argz
  3599. element which begins with NAME followed by a ‘'='’ byte. If there
  3600. is no entry with that name, ‘0’ is returned.
  3601. -- Function: char * envz_get (const char *ENVZ, size_t ENVZ_LEN, const
  3602. char *NAME)
  3603. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3604. Concepts::.
  3605. The ‘envz_get’ function finds the entry in ENVZ with the name NAME
  3606. (like ‘envz_entry’), and returns a pointer to the value portion of
  3607. that entry (following the ‘'='’). If there is no entry with that
  3608. name (or only a null entry), ‘0’ is returned.
  3609. -- Function: error_t envz_add (char **ENVZ, size_t *ENVZ_LEN, const
  3610. char *NAME, const char *VALUE)
  3611. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3612. POSIX Safety Concepts::.
  3613. The ‘envz_add’ function adds an entry to ‘*ENVZ’ (updating ‘*ENVZ’
  3614. and ‘*ENVZ_LEN’) with the name NAME, and value VALUE. If an entry
  3615. with the same name already exists in ENVZ, it is removed first. If
  3616. VALUE is ‘0’, then the new entry will be the special null type of
  3617. entry (mentioned above).
  3618. -- Function: error_t envz_merge (char **ENVZ, size_t *ENVZ_LEN, const
  3619. char *ENVZ2, size_t ENVZ2_LEN, int OVERRIDE)
  3620. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3621. POSIX Safety Concepts::.
  3622. The ‘envz_merge’ function adds each entry in ENVZ2 to ENVZ, as if
  3623. with ‘envz_add’, updating ‘*ENVZ’ and ‘*ENVZ_LEN’. If OVERRIDE is
  3624. true, then values in ENVZ2 will supersede those with the same name
  3625. in ENVZ, otherwise not.
  3626. Null entries are treated just like other entries in this respect,
  3627. so a null entry in ENVZ can prevent an entry of the same name in
  3628. ENVZ2 from being added to ENVZ, if OVERRIDE is false.
  3629. -- Function: void envz_strip (char **ENVZ, size_t *ENVZ_LEN)
  3630. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3631. Concepts::.
  3632. The ‘envz_strip’ function removes any null entries from ENVZ,
  3633. updating ‘*ENVZ’ and ‘*ENVZ_LEN’.
  3634. -- Function: void envz_remove (char **ENVZ, size_t *ENVZ_LEN, const
  3635. char *NAME)
  3636. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  3637. POSIX Safety Concepts::.
  3638. The ‘envz_remove’ function removes an entry named NAME from ENVZ,
  3639. updating ‘*ENVZ’ and ‘*ENVZ_LEN’.
  3640. 
  3641. File: libc.info, Node: Character Set Handling, Next: Locales, Prev: String and Array Utilities, Up: Top
  3642. 6 Character Set Handling
  3643. ************************
  3644. Character sets used in the early days of computing had only six, seven,
  3645. or eight bits for each character: there was never a case where more than
  3646. eight bits (one byte) were used to represent a single character. The
  3647. limitations of this approach became more apparent as more people
  3648. grappled with non-Roman character sets, where not all the characters
  3649. that make up a language's character set can be represented by 2^8
  3650. choices. This chapter shows the functionality that was added to the C
  3651. library to support multiple character sets.
  3652. * Menu:
  3653. * Extended Char Intro:: Introduction to Extended Characters.
  3654. * Charset Function Overview:: Overview about Character Handling
  3655. Functions.
  3656. * Restartable multibyte conversion:: Restartable multibyte conversion
  3657. Functions.
  3658. * Non-reentrant Conversion:: Non-reentrant Conversion Function.
  3659. * Generic Charset Conversion:: Generic Charset Conversion.
  3660. 
  3661. File: libc.info, Node: Extended Char Intro, Next: Charset Function Overview, Up: Character Set Handling
  3662. 6.1 Introduction to Extended Characters
  3663. =======================================
  3664. A variety of solutions are available to overcome the differences between
  3665. character sets with a 1:1 relation between bytes and characters and
  3666. character sets with ratios of 2:1 or 4:1. The remainder of this section
  3667. gives a few examples to help understand the design decisions made while
  3668. developing the functionality of the C library.
  3669. A distinction we have to make right away is between internal and
  3670. external representation. “Internal representation” means the
  3671. representation used by a program while keeping the text in memory.
  3672. External representations are used when text is stored or transmitted
  3673. through some communication channel. Examples of external
  3674. representations include files waiting in a directory to be read and
  3675. parsed.
  3676. Traditionally there has been no difference between the two
  3677. representations. It was equally comfortable and useful to use the same
  3678. single-byte representation internally and externally. This comfort
  3679. level decreases with more and larger character sets.
  3680. One of the problems to overcome with the internal representation is
  3681. handling text that is externally encoded using different character sets.
  3682. Assume a program that reads two texts and compares them using some
  3683. metric. The comparison can be usefully done only if the texts are
  3684. internally kept in a common format.
  3685. For such a common format (= character set) eight bits are certainly
  3686. no longer enough. So the smallest entity will have to grow: “wide
  3687. characters” will now be used. Instead of one byte per character, two or
  3688. four will be used instead. (Three are not good to address in memory and
  3689. more than four bytes seem not to be necessary).
  3690. As shown in some other part of this manual, a completely new family
  3691. has been created of functions that can handle wide character texts in
  3692. memory. The most commonly used character sets for such internal wide
  3693. character representations are Unicode and ISO 10646 (also known as UCS
  3694. for Universal Character Set). Unicode was originally planned as a
  3695. 16-bit character set; whereas, ISO 10646 was designed to be a 31-bit
  3696. large code space. The two standards are practically identical. They
  3697. have the same character repertoire and code table, but Unicode specifies
  3698. added semantics. At the moment, only characters in the first ‘0x10000’
  3699. code positions (the so-called Basic Multilingual Plane, BMP) have been
  3700. assigned, but the assignment of more specialized characters outside this
  3701. 16-bit space is already in progress. A number of encodings have been
  3702. defined for Unicode and ISO 10646 characters: UCS-2 is a 16-bit word
  3703. that can only represent characters from the BMP, UCS-4 is a 32-bit word
  3704. than can represent any Unicode and ISO 10646 character, UTF-8 is an
  3705. ASCII compatible encoding where ASCII characters are represented by
  3706. ASCII bytes and non-ASCII characters by sequences of 2-6 non-ASCII
  3707. bytes, and finally UTF-16 is an extension of UCS-2 in which pairs of
  3708. certain UCS-2 words can be used to encode non-BMP characters up to
  3709. ‘0x10ffff’.
  3710. To represent wide characters the ‘char’ type is not suitable. For
  3711. this reason the ISO C standard introduces a new type that is designed to
  3712. keep one character of a wide character string. To maintain the
  3713. similarity there is also a type corresponding to ‘int’ for those
  3714. functions that take a single wide character.
  3715. -- Data type: wchar_t
  3716. This data type is used as the base type for wide character strings.
  3717. In other words, arrays of objects of this type are the equivalent
  3718. of ‘char[]’ for multibyte character strings. The type is defined
  3719. in ‘stddef.h’.
  3720. The ISO C90 standard, where ‘wchar_t’ was introduced, does not say
  3721. anything specific about the representation. It only requires that
  3722. this type is capable of storing all elements of the basic character
  3723. set. Therefore it would be legitimate to define ‘wchar_t’ as
  3724. ‘char’, which might make sense for embedded systems.
  3725. But in the GNU C Library ‘wchar_t’ is always 32 bits wide and,
  3726. therefore, capable of representing all UCS-4 values and, therefore,
  3727. covering all of ISO 10646. Some Unix systems define ‘wchar_t’ as a
  3728. 16-bit type and thereby follow Unicode very strictly. This
  3729. definition is perfectly fine with the standard, but it also means
  3730. that to represent all characters from Unicode and ISO 10646 one has
  3731. to use UTF-16 surrogate characters, which is in fact a
  3732. multi-wide-character encoding. But resorting to
  3733. multi-wide-character encoding contradicts the purpose of the
  3734. ‘wchar_t’ type.
  3735. -- Data type: wint_t
  3736. ‘wint_t’ is a data type used for parameters and variables that
  3737. contain a single wide character. As the name suggests this type is
  3738. the equivalent of ‘int’ when using the normal ‘char’ strings. The
  3739. types ‘wchar_t’ and ‘wint_t’ often have the same representation if
  3740. their size is 32 bits wide but if ‘wchar_t’ is defined as ‘char’
  3741. the type ‘wint_t’ must be defined as ‘int’ due to the parameter
  3742. promotion.
  3743. This type is defined in ‘wchar.h’ and was introduced in Amendment 1
  3744. to ISO C90.
  3745. As there are for the ‘char’ data type macros are available for
  3746. specifying the minimum and maximum value representable in an object of
  3747. type ‘wchar_t’.
  3748. -- Macro: wint_t WCHAR_MIN
  3749. The macro ‘WCHAR_MIN’ evaluates to the minimum value representable
  3750. by an object of type ‘wint_t’.
  3751. This macro was introduced in Amendment 1 to ISO C90.
  3752. -- Macro: wint_t WCHAR_MAX
  3753. The macro ‘WCHAR_MAX’ evaluates to the maximum value representable
  3754. by an object of type ‘wint_t’.
  3755. This macro was introduced in Amendment 1 to ISO C90.
  3756. Another special wide character value is the equivalent to ‘EOF’.
  3757. -- Macro: wint_t WEOF
  3758. The macro ‘WEOF’ evaluates to a constant expression of type
  3759. ‘wint_t’ whose value is different from any member of the extended
  3760. character set.
  3761. ‘WEOF’ need not be the same value as ‘EOF’ and unlike ‘EOF’ it also
  3762. need _not_ be negative. In other words, sloppy code like
  3763. {
  3764. int c;
  3765. ...
  3766. while ((c = getc (fp)) < 0)
  3767. ...
  3768. }
  3769. has to be rewritten to use ‘WEOF’ explicitly when wide characters
  3770. are used:
  3771. {
  3772. wint_t c;
  3773. ...
  3774. while ((c = getwc (fp)) != WEOF)
  3775. ...
  3776. }
  3777. This macro was introduced in Amendment 1 to ISO C90 and is defined
  3778. in ‘wchar.h’.
  3779. These internal representations present problems when it comes to
  3780. storage and transmittal. Because each single wide character consists of
  3781. more than one byte, they are affected by byte-ordering. Thus, machines
  3782. with different endianesses would see different values when accessing the
  3783. same data. This byte ordering concern also applies for communication
  3784. protocols that are all byte-based and therefore require that the sender
  3785. has to decide about splitting the wide character in bytes. A last (but
  3786. not least important) point is that wide characters often require more
  3787. storage space than a customized byte-oriented character set.
  3788. For all the above reasons, an external encoding that is different
  3789. from the internal encoding is often used if the latter is UCS-2 or
  3790. UCS-4. The external encoding is byte-based and can be chosen
  3791. appropriately for the environment and for the texts to be handled. A
  3792. variety of different character sets can be used for this external
  3793. encoding (information that will not be exhaustively presented
  3794. here-instead, a description of the major groups will suffice). All of
  3795. the ASCII-based character sets fulfill one requirement: they are
  3796. "filesystem safe." This means that the character ‘'/'’ is used in the
  3797. encoding _only_ to represent itself. Things are a bit different for
  3798. character sets like EBCDIC (Extended Binary Coded Decimal Interchange
  3799. Code, a character set family used by IBM), but if the operating system
  3800. does not understand EBCDIC directly the parameters-to-system calls have
  3801. to be converted first anyhow.
  3802. • The simplest character sets are single-byte character sets. There
  3803. can be only up to 256 characters (for 8 bit character sets), which
  3804. is not sufficient to cover all languages but might be sufficient to
  3805. handle a specific text. Handling of a 8 bit character sets is
  3806. simple. This is not true for other kinds presented later, and
  3807. therefore, the application one uses might require the use of 8 bit
  3808. character sets.
  3809. • The ISO 2022 standard defines a mechanism for extended character
  3810. sets where one character _can_ be represented by more than one
  3811. byte. This is achieved by associating a state with the text.
  3812. Characters that can be used to change the state can be embedded in
  3813. the text. Each byte in the text might have a different
  3814. interpretation in each state. The state might even influence
  3815. whether a given byte stands for a character on its own or whether
  3816. it has to be combined with some more bytes.
  3817. In most uses of ISO 2022 the defined character sets do not allow
  3818. state changes that cover more than the next character. This has
  3819. the big advantage that whenever one can identify the beginning of
  3820. the byte sequence of a character one can interpret a text
  3821. correctly. Examples of character sets using this policy are the
  3822. various EUC character sets (used by Sun's operating systems,
  3823. EUC-JP, EUC-KR, EUC-TW, and EUC-CN) or Shift_JIS (SJIS, a Japanese
  3824. encoding).
  3825. But there are also character sets using a state that is valid for
  3826. more than one character and has to be changed by another byte
  3827. sequence. Examples for this are ISO-2022-JP, ISO-2022-KR, and
  3828. ISO-2022-CN.
  3829. • Early attempts to fix 8 bit character sets for other languages
  3830. using the Roman alphabet lead to character sets like ISO 6937.
  3831. Here bytes representing characters like the acute accent do not
  3832. produce output themselves: one has to combine them with other
  3833. characters to get the desired result. For example, the byte
  3834. sequence ‘0xc2 0x61’ (non-spacing acute accent, followed by
  3835. lower-case 'a') to get the "small a with acute" character. To get
  3836. the acute accent character on its own, one has to write ‘0xc2 0x20’
  3837. (the non-spacing acute followed by a space).
  3838. Character sets like ISO 6937 are used in some embedded systems such
  3839. as teletex.
  3840. • Instead of converting the Unicode or ISO 10646 text used
  3841. internally, it is often also sufficient to simply use an encoding
  3842. different than UCS-2/UCS-4. The Unicode and ISO 10646 standards
  3843. even specify such an encoding: UTF-8. This encoding is able to
  3844. represent all of ISO 10646 31 bits in a byte string of length one
  3845. to six.
  3846. There were a few other attempts to encode ISO 10646 such as UTF-7,
  3847. but UTF-8 is today the only encoding that should be used. In fact,
  3848. with any luck UTF-8 will soon be the only external encoding that
  3849. has to be supported. It proves to be universally usable and its
  3850. only disadvantage is that it favors Roman languages by making the
  3851. byte string representation of other scripts (Cyrillic, Greek, Asian
  3852. scripts) longer than necessary if using a specific character set
  3853. for these scripts. Methods like the Unicode compression scheme can
  3854. alleviate these problems.
  3855. The question remaining is: how to select the character set or
  3856. encoding to use. The answer: you cannot decide about it yourself, it is
  3857. decided by the developers of the system or the majority of the users.
  3858. Since the goal is interoperability one has to use whatever the other
  3859. people one works with use. If there are no constraints, the selection
  3860. is based on the requirements the expected circle of users will have. In
  3861. other words, if a project is expected to be used in only, say, Russia it
  3862. is fine to use KOI8-R or a similar character set. But if at the same
  3863. time people from, say, Greece are participating one should use a
  3864. character set that allows all people to collaborate.
  3865. The most widely useful solution seems to be: go with the most general
  3866. character set, namely ISO 10646. Use UTF-8 as the external encoding and
  3867. problems about users not being able to use their own language adequately
  3868. are a thing of the past.
  3869. One final comment about the choice of the wide character
  3870. representation is necessary at this point. We have said above that the
  3871. natural choice is using Unicode or ISO 10646. This is not required, but
  3872. at least encouraged, by the ISO C standard. The standard defines at
  3873. least a macro ‘__STDC_ISO_10646__’ that is only defined on systems where
  3874. the ‘wchar_t’ type encodes ISO 10646 characters. If this symbol is not
  3875. defined one should avoid making assumptions about the wide character
  3876. representation. If the programmer uses only the functions provided by
  3877. the C library to handle wide character strings there should be no
  3878. compatibility problems with other systems.
  3879. 
  3880. File: libc.info, Node: Charset Function Overview, Next: Restartable multibyte conversion, Prev: Extended Char Intro, Up: Character Set Handling
  3881. 6.2 Overview about Character Handling Functions
  3882. ===============================================
  3883. A Unix C library contains three different sets of functions in two
  3884. families to handle character set conversion. One of the function
  3885. families (the most commonly used) is specified in the ISO C90 standard
  3886. and, therefore, is portable even beyond the Unix world. Unfortunately
  3887. this family is the least useful one. These functions should be avoided
  3888. whenever possible, especially when developing libraries (as opposed to
  3889. applications).
  3890. The second family of functions got introduced in the early Unix
  3891. standards (XPG2) and is still part of the latest and greatest Unix
  3892. standard: Unix 98. It is also the most powerful and useful set of
  3893. functions. But we will start with the functions defined in Amendment 1
  3894. to ISO C90.
  3895. 
  3896. File: libc.info, Node: Restartable multibyte conversion, Next: Non-reentrant Conversion, Prev: Charset Function Overview, Up: Character Set Handling
  3897. 6.3 Restartable Multibyte Conversion Functions
  3898. ==============================================
  3899. The ISO C standard defines functions to convert strings from a multibyte
  3900. representation to wide character strings. There are a number of
  3901. peculiarities:
  3902. • The character set assumed for the multibyte encoding is not
  3903. specified as an argument to the functions. Instead the character
  3904. set specified by the ‘LC_CTYPE’ category of the current locale is
  3905. used; see *note Locale Categories::.
  3906. • The functions handling more than one character at a time require
  3907. NUL terminated strings as the argument (i.e., converting blocks of
  3908. text does not work unless one can add a NUL byte at an appropriate
  3909. place). The GNU C Library contains some extensions to the standard
  3910. that allow specifying a size, but basically they also expect
  3911. terminated strings.
  3912. Despite these limitations the ISO C functions can be used in many
  3913. contexts. In graphical user interfaces, for instance, it is not
  3914. uncommon to have functions that require text to be displayed in a wide
  3915. character string if the text is not simple ASCII. The text itself might
  3916. come from a file with translations and the user should decide about the
  3917. current locale, which determines the translation and therefore also the
  3918. external encoding used. In such a situation (and many others) the
  3919. functions described here are perfect. If more freedom while performing
  3920. the conversion is necessary take a look at the ‘iconv’ functions (*note
  3921. Generic Charset Conversion::).
  3922. * Menu:
  3923. * Selecting the Conversion:: Selecting the conversion and its properties.
  3924. * Keeping the state:: Representing the state of the conversion.
  3925. * Converting a Character:: Converting Single Characters.
  3926. * Converting Strings:: Converting Multibyte and Wide Character
  3927. Strings.
  3928. * Multibyte Conversion Example:: A Complete Multibyte Conversion Example.
  3929. 
  3930. File: libc.info, Node: Selecting the Conversion, Next: Keeping the state, Up: Restartable multibyte conversion
  3931. 6.3.1 Selecting the conversion and its properties
  3932. -------------------------------------------------
  3933. We already said above that the currently selected locale for the
  3934. ‘LC_CTYPE’ category decides the conversion that is performed by the
  3935. functions we are about to describe. Each locale uses its own character
  3936. set (given as an argument to ‘localedef’) and this is the one assumed as
  3937. the external multibyte encoding. The wide character set is always UCS-4
  3938. in the GNU C Library.
  3939. A characteristic of each multibyte character set is the maximum
  3940. number of bytes that can be necessary to represent one character. This
  3941. information is quite important when writing code that uses the
  3942. conversion functions (as shown in the examples below). The ISO C
  3943. standard defines two macros that provide this information.
  3944. -- Macro: int MB_LEN_MAX
  3945. ‘MB_LEN_MAX’ specifies the maximum number of bytes in the multibyte
  3946. sequence for a single character in any of the supported locales.
  3947. It is a compile-time constant and is defined in ‘limits.h’.
  3948. -- Macro: int MB_CUR_MAX
  3949. ‘MB_CUR_MAX’ expands into a positive integer expression that is the
  3950. maximum number of bytes in a multibyte character in the current
  3951. locale. The value is never greater than ‘MB_LEN_MAX’. Unlike
  3952. ‘MB_LEN_MAX’ this macro need not be a compile-time constant, and in
  3953. the GNU C Library it is not.
  3954. ‘MB_CUR_MAX’ is defined in ‘stdlib.h’.
  3955. Two different macros are necessary since strictly ISO C90 compilers
  3956. do not allow variable length array definitions, but still it is
  3957. desirable to avoid dynamic allocation. This incomplete piece of code
  3958. shows the problem:
  3959. {
  3960. char buf[MB_LEN_MAX];
  3961. ssize_t len = 0;
  3962. while (! feof (fp))
  3963. {
  3964. fread (&buf[len], 1, MB_CUR_MAX - len, fp);
  3965. /* ... process buf */
  3966. len -= used;
  3967. }
  3968. }
  3969. The code in the inner loop is expected to have always enough bytes in
  3970. the array BUF to convert one multibyte character. The array BUF has to
  3971. be sized statically since many compilers do not allow a variable size.
  3972. The ‘fread’ call makes sure that ‘MB_CUR_MAX’ bytes are always available
  3973. in BUF. Note that it isn't a problem if ‘MB_CUR_MAX’ is not a
  3974. compile-time constant.
  3975. 
  3976. File: libc.info, Node: Keeping the state, Next: Converting a Character, Prev: Selecting the Conversion, Up: Restartable multibyte conversion
  3977. 6.3.2 Representing the state of the conversion
  3978. ----------------------------------------------
  3979. In the introduction of this chapter it was said that certain character
  3980. sets use a “stateful” encoding. That is, the encoded values depend in
  3981. some way on the previous bytes in the text.
  3982. Since the conversion functions allow converting a text in more than
  3983. one step we must have a way to pass this information from one call of
  3984. the functions to another.
  3985. -- Data type: mbstate_t
  3986. A variable of type ‘mbstate_t’ can contain all the information
  3987. about the “shift state” needed from one call to a conversion
  3988. function to another.
  3989. ‘mbstate_t’ is defined in ‘wchar.h’. It was introduced in
  3990. Amendment 1 to ISO C90.
  3991. To use objects of type ‘mbstate_t’ the programmer has to define such
  3992. objects (normally as local variables on the stack) and pass a pointer to
  3993. the object to the conversion functions. This way the conversion
  3994. function can update the object if the current multibyte character set is
  3995. stateful.
  3996. There is no specific function or initializer to put the state object
  3997. in any specific state. The rules are that the object should always
  3998. represent the initial state before the first use, and this is achieved
  3999. by clearing the whole variable with code such as follows:
  4000. {
  4001. mbstate_t state;
  4002. memset (&state, '\0', sizeof (state));
  4003. /* from now on STATE can be used. */
  4004. ...
  4005. }
  4006. When using the conversion functions to generate output it is often
  4007. necessary to test whether the current state corresponds to the initial
  4008. state. This is necessary, for example, to decide whether to emit escape
  4009. sequences to set the state to the initial state at certain sequence
  4010. points. Communication protocols often require this.
  4011. -- Function: int mbsinit (const mbstate_t *PS)
  4012. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4013. Concepts::.
  4014. The ‘mbsinit’ function determines whether the state object pointed
  4015. to by PS is in the initial state. If PS is a null pointer or the
  4016. object is in the initial state the return value is nonzero.
  4017. Otherwise it is zero.
  4018. ‘mbsinit’ was introduced in Amendment 1 to ISO C90 and is declared
  4019. in ‘wchar.h’.
  4020. Code using ‘mbsinit’ often looks similar to this:
  4021. {
  4022. mbstate_t state;
  4023. memset (&state, '\0', sizeof (state));
  4024. /* Use STATE. */
  4025. ...
  4026. if (! mbsinit (&state))
  4027. {
  4028. /* Emit code to return to initial state. */
  4029. const wchar_t empty[] = L"";
  4030. const wchar_t *srcp = empty;
  4031. wcsrtombs (outbuf, &srcp, outbuflen, &state);
  4032. }
  4033. ...
  4034. }
  4035. The code to emit the escape sequence to get back to the initial state
  4036. is interesting. The ‘wcsrtombs’ function can be used to determine the
  4037. necessary output code (*note Converting Strings::). Please note that
  4038. with the GNU C Library it is not necessary to perform this extra action
  4039. for the conversion from multibyte text to wide character text since the
  4040. wide character encoding is not stateful. But there is nothing mentioned
  4041. in any standard that prohibits making ‘wchar_t’ use a stateful encoding.
  4042. 
  4043. File: libc.info, Node: Converting a Character, Next: Converting Strings, Prev: Keeping the state, Up: Restartable multibyte conversion
  4044. 6.3.3 Converting Single Characters
  4045. ----------------------------------
  4046. The most fundamental of the conversion functions are those dealing with
  4047. single characters. Please note that this does not always mean single
  4048. bytes. But since there is very often a subset of the multibyte
  4049. character set that consists of single byte sequences, there are
  4050. functions to help with converting bytes. Frequently, ASCII is a subset
  4051. of the multibyte character set. In such a scenario, each ASCII
  4052. character stands for itself, and all other characters have at least a
  4053. first byte that is beyond the range 0 to 127.
  4054. -- Function: wint_t btowc (int C)
  4055. Preliminary: | MT-Safe | AS-Unsafe corrupt heap lock dlopen |
  4056. AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  4057. The ‘btowc’ function ("byte to wide character") converts a valid
  4058. single byte character C in the initial shift state into the wide
  4059. character equivalent using the conversion rules from the currently
  4060. selected locale of the ‘LC_CTYPE’ category.
  4061. If ‘(unsigned char) C’ is no valid single byte multibyte character
  4062. or if C is ‘EOF’, the function returns ‘WEOF’.
  4063. Please note the restriction of C being tested for validity only in
  4064. the initial shift state. No ‘mbstate_t’ object is used from which
  4065. the state information is taken, and the function also does not use
  4066. any static state.
  4067. The ‘btowc’ function was introduced in Amendment 1 to ISO C90 and
  4068. is declared in ‘wchar.h’.
  4069. Despite the limitation that the single byte value is always
  4070. interpreted in the initial state, this function is actually useful most
  4071. of the time. Most characters are either entirely single-byte character
  4072. sets or they are extensions to ASCII. But then it is possible to write
  4073. code like this (not that this specific example is very useful):
  4074. wchar_t *
  4075. itow (unsigned long int val)
  4076. {
  4077. static wchar_t buf[30];
  4078. wchar_t *wcp = &buf[29];
  4079. *wcp = L'\0';
  4080. while (val != 0)
  4081. {
  4082. *--wcp = btowc ('0' + val % 10);
  4083. val /= 10;
  4084. }
  4085. if (wcp == &buf[29])
  4086. *--wcp = L'0';
  4087. return wcp;
  4088. }
  4089. Why is it necessary to use such a complicated implementation and not
  4090. simply cast ‘'0' + val % 10’ to a wide character? The answer is that
  4091. there is no guarantee that one can perform this kind of arithmetic on
  4092. the character of the character set used for ‘wchar_t’ representation.
  4093. In other situations the bytes are not constant at compile time and so
  4094. the compiler cannot do the work. In situations like this, using ‘btowc’
  4095. is required.
  4096. There is also a function for the conversion in the other direction.
  4097. -- Function: int wctob (wint_t C)
  4098. Preliminary: | MT-Safe | AS-Unsafe corrupt heap lock dlopen |
  4099. AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  4100. The ‘wctob’ function ("wide character to byte") takes as the
  4101. parameter a valid wide character. If the multibyte representation
  4102. for this character in the initial state is exactly one byte long,
  4103. the return value of this function is this character. Otherwise the
  4104. return value is ‘EOF’.
  4105. ‘wctob’ was introduced in Amendment 1 to ISO C90 and is declared in
  4106. ‘wchar.h’.
  4107. There are more general functions to convert single characters from
  4108. multibyte representation to wide characters and vice versa. These
  4109. functions pose no limit on the length of the multibyte representation
  4110. and they also do not require it to be in the initial state.
  4111. -- Function: size_t mbrtowc (wchar_t *restrict PWC, const char
  4112. *restrict S, size_t N, mbstate_t *restrict PS)
  4113. Preliminary: | MT-Unsafe race:mbrtowc/!ps | AS-Unsafe corrupt heap
  4114. lock dlopen | AC-Unsafe corrupt lock mem fd | *Note POSIX Safety
  4115. Concepts::.
  4116. The ‘mbrtowc’ function ("multibyte restartable to wide character")
  4117. converts the next multibyte character in the string pointed to by S
  4118. into a wide character and stores it in the location pointed to by
  4119. PWC. The conversion is performed according to the locale currently
  4120. selected for the ‘LC_CTYPE’ category. If the conversion for the
  4121. character set used in the locale requires a state, the multibyte
  4122. string is interpreted in the state represented by the object
  4123. pointed to by PS. If PS is a null pointer, a static, internal
  4124. state variable used only by the ‘mbrtowc’ function is used.
  4125. If the next multibyte character corresponds to the null wide
  4126. character, the return value of the function is 0 and the state
  4127. object is afterwards in the initial state. If the next N or fewer
  4128. bytes form a correct multibyte character, the return value is the
  4129. number of bytes starting from S that form the multibyte character.
  4130. The conversion state is updated according to the bytes consumed in
  4131. the conversion. In both cases the wide character (either the
  4132. ‘L'\0'’ or the one found in the conversion) is stored in the string
  4133. pointed to by PWC if PWC is not null.
  4134. If the first N bytes of the multibyte string possibly form a valid
  4135. multibyte character but there are more than N bytes needed to
  4136. complete it, the return value of the function is ‘(size_t) -2’ and
  4137. no value is stored in ‘*PWC’. The conversion state is updated and
  4138. all N input bytes are consumed and should not be submitted again.
  4139. Please note that this can happen even if N has a value greater than
  4140. or equal to ‘MB_CUR_MAX’ since the input might contain redundant
  4141. shift sequences.
  4142. If the first ‘n’ bytes of the multibyte string cannot possibly form
  4143. a valid multibyte character, no value is stored, the global
  4144. variable ‘errno’ is set to the value ‘EILSEQ’, and the function
  4145. returns ‘(size_t) -1’. The conversion state is afterwards
  4146. undefined.
  4147. As specified, the ‘mbrtowc’ function could deal with multibyte
  4148. sequences which contain embedded null bytes (which happens in
  4149. Unicode encodings such as UTF-16), but the GNU C Library does not
  4150. support such multibyte encodings. When encountering a null input
  4151. byte, the function will either return zero, or return ‘(size_t)
  4152. -1)’ and report a ‘EILSEQ’ error. The ‘iconv’ function can be used
  4153. for converting between arbitrary encodings. *Note Generic
  4154. Conversion Interface::.
  4155. ‘mbrtowc’ was introduced in Amendment 1 to ISO C90 and is declared
  4156. in ‘wchar.h’.
  4157. A function that copies a multibyte string into a wide character
  4158. string while at the same time converting all lowercase characters into
  4159. uppercase could look like this:
  4160. wchar_t *
  4161. mbstouwcs (const char *s)
  4162. {
  4163. /* Include the null terminator in the conversion. */
  4164. size_t len = strlen (s) + 1;
  4165. wchar_t *result = reallocarray (NULL, len, sizeof (wchar_t));
  4166. if (result == NULL)
  4167. return NULL;
  4168. wchar_t *wcp = result;
  4169. mbstate_t state;
  4170. memset (&state, '\0', sizeof (state));
  4171. while (true)
  4172. {
  4173. wchar_t wc;
  4174. size_t nbytes = mbrtowc (&wc, s, len, &state);
  4175. if (nbytes == 0)
  4176. {
  4177. /* Terminate the result string. */
  4178. *wcp = L'\0';
  4179. break;
  4180. }
  4181. else if (nbytes == (size_t) -2)
  4182. {
  4183. /* Truncated input string. */
  4184. errno = EILSEQ;
  4185. free (result);
  4186. return NULL;
  4187. }
  4188. else if (nbytes == (size_t) -1)
  4189. {
  4190. /* Some other error (including EILSEQ). */
  4191. free (result);
  4192. return NULL;
  4193. }
  4194. else
  4195. {
  4196. /* A character was converted. */
  4197. *wcp++ = towupper (wc);
  4198. len -= nbytes;
  4199. s += nbytes;
  4200. }
  4201. }
  4202. return result;
  4203. }
  4204. In the inner loop, a single wide character is stored in ‘wc’, and the
  4205. number of consumed bytes is stored in the variable ‘nbytes’. If the
  4206. conversion is successful, the uppercase variant of the wide character is
  4207. stored in the ‘result’ array and the pointer to the input string and the
  4208. number of available bytes is adjusted. If the ‘mbrtowc’ function
  4209. returns zero, the null input byte has not been converted, so it must be
  4210. stored explicitly in the result.
  4211. The above code uses the fact that there can never be more wide
  4212. characters in the converted result than there are bytes in the multibyte
  4213. input string. This method yields a pessimistic guess about the size of
  4214. the result, and if many wide character strings have to be constructed
  4215. this way or if the strings are long, the extra memory required to be
  4216. allocated because the input string contains multibyte characters might
  4217. be significant. The allocated memory block can be resized to the
  4218. correct size before returning it, but a better solution might be to
  4219. allocate just the right amount of space for the result right away.
  4220. Unfortunately there is no function to compute the length of the wide
  4221. character string directly from the multibyte string. There is, however,
  4222. a function that does part of the work.
  4223. -- Function: size_t mbrlen (const char *restrict S, size_t N, mbstate_t
  4224. *PS)
  4225. Preliminary: | MT-Unsafe race:mbrlen/!ps | AS-Unsafe corrupt heap
  4226. lock dlopen | AC-Unsafe corrupt lock mem fd | *Note POSIX Safety
  4227. Concepts::.
  4228. The ‘mbrlen’ function ("multibyte restartable length") computes the
  4229. number of at most N bytes starting at S, which form the next valid
  4230. and complete multibyte character.
  4231. If the next multibyte character corresponds to the NUL wide
  4232. character, the return value is 0. If the next N bytes form a valid
  4233. multibyte character, the number of bytes belonging to this
  4234. multibyte character byte sequence is returned.
  4235. If the first N bytes possibly form a valid multibyte character but
  4236. the character is incomplete, the return value is ‘(size_t) -2’.
  4237. Otherwise the multibyte character sequence is invalid and the
  4238. return value is ‘(size_t) -1’.
  4239. The multibyte sequence is interpreted in the state represented by
  4240. the object pointed to by PS. If PS is a null pointer, a state
  4241. object local to ‘mbrlen’ is used.
  4242. ‘mbrlen’ was introduced in Amendment 1 to ISO C90 and is declared
  4243. in ‘wchar.h’.
  4244. The attentive reader now will note that ‘mbrlen’ can be implemented
  4245. as
  4246. mbrtowc (NULL, s, n, ps != NULL ? ps : &internal)
  4247. This is true and in fact is mentioned in the official specification.
  4248. How can this function be used to determine the length of the wide
  4249. character string created from a multibyte character string? It is not
  4250. directly usable, but we can define a function ‘mbslen’ using it:
  4251. size_t
  4252. mbslen (const char *s)
  4253. {
  4254. mbstate_t state;
  4255. size_t result = 0;
  4256. size_t nbytes;
  4257. memset (&state, '\0', sizeof (state));
  4258. while ((nbytes = mbrlen (s, MB_LEN_MAX, &state)) > 0)
  4259. {
  4260. if (nbytes >= (size_t) -2)
  4261. /* Something is wrong. */
  4262. return (size_t) -1;
  4263. s += nbytes;
  4264. ++result;
  4265. }
  4266. return result;
  4267. }
  4268. This function simply calls ‘mbrlen’ for each multibyte character in
  4269. the string and counts the number of function calls. Please note that we
  4270. here use ‘MB_LEN_MAX’ as the size argument in the ‘mbrlen’ call. This
  4271. is acceptable since a) this value is larger than the length of the
  4272. longest multibyte character sequence and b) we know that the string S
  4273. ends with a NUL byte, which cannot be part of any other multibyte
  4274. character sequence but the one representing the NUL wide character.
  4275. Therefore, the ‘mbrlen’ function will never read invalid memory.
  4276. Now that this function is available (just to make this clear, this
  4277. function is _not_ part of the GNU C Library) we can compute the number
  4278. of wide characters required to store the converted multibyte character
  4279. string S using
  4280. wcs_bytes = (mbslen (s) + 1) * sizeof (wchar_t);
  4281. Please note that the ‘mbslen’ function is quite inefficient. The
  4282. implementation of ‘mbstouwcs’ with ‘mbslen’ would have to perform the
  4283. conversion of the multibyte character input string twice, and this
  4284. conversion might be quite expensive. So it is necessary to think about
  4285. the consequences of using the easier but imprecise method before doing
  4286. the work twice.
  4287. -- Function: size_t wcrtomb (char *restrict S, wchar_t WC, mbstate_t
  4288. *restrict PS)
  4289. Preliminary: | MT-Unsafe race:wcrtomb/!ps | AS-Unsafe corrupt heap
  4290. lock dlopen | AC-Unsafe corrupt lock mem fd | *Note POSIX Safety
  4291. Concepts::.
  4292. The ‘wcrtomb’ function ("wide character restartable to multibyte")
  4293. converts a single wide character into a multibyte string
  4294. corresponding to that wide character.
  4295. If S is a null pointer, the function resets the state stored in the
  4296. object pointed to by PS (or the internal ‘mbstate_t’ object) to the
  4297. initial state. This can also be achieved by a call like this:
  4298. wcrtombs (temp_buf, L'\0', ps)
  4299. since, if S is a null pointer, ‘wcrtomb’ performs as if it writes
  4300. into an internal buffer, which is guaranteed to be large enough.
  4301. If WC is the NUL wide character, ‘wcrtomb’ emits, if necessary, a
  4302. shift sequence to get the state PS into the initial state followed
  4303. by a single NUL byte, which is stored in the string S.
  4304. Otherwise a byte sequence (possibly including shift sequences) is
  4305. written into the string S. This only happens if WC is a valid wide
  4306. character (i.e., it has a multibyte representation in the character
  4307. set selected by locale of the ‘LC_CTYPE’ category). If WC is no
  4308. valid wide character, nothing is stored in the strings S, ‘errno’
  4309. is set to ‘EILSEQ’, the conversion state in PS is undefined and the
  4310. return value is ‘(size_t) -1’.
  4311. If no error occurred the function returns the number of bytes
  4312. stored in the string S. This includes all bytes representing shift
  4313. sequences.
  4314. One word about the interface of the function: there is no parameter
  4315. specifying the length of the array S, so the caller has to make
  4316. sure that there is enough space available, otherwise buffer
  4317. overruns can occur. This version of the GNU C Library does not
  4318. assume that S is at least MB_CUR_MAX bytes long, but programs that
  4319. need to run on GNU C Library versions that have this assumption
  4320. documented in the manual must comply with this limit.
  4321. ‘wcrtomb’ was introduced in Amendment 1 to ISO C90 and is declared
  4322. in ‘wchar.h’.
  4323. Using ‘wcrtomb’ is as easy as using ‘mbrtowc’. The following example
  4324. appends a wide character string to a multibyte character string. Again,
  4325. the code is not really useful (or correct), it is simply here to
  4326. demonstrate the use and some problems.
  4327. char *
  4328. mbscatwcs (char *s, size_t len, const wchar_t *ws)
  4329. {
  4330. mbstate_t state;
  4331. /* Find the end of the existing string. */
  4332. char *wp = strchr (s, '\0');
  4333. len -= wp - s;
  4334. memset (&state, '\0', sizeof (state));
  4335. do
  4336. {
  4337. size_t nbytes;
  4338. if (len < MB_CUR_LEN)
  4339. {
  4340. /* We cannot guarantee that the next
  4341. character fits into the buffer, so
  4342. return an error. */
  4343. errno = E2BIG;
  4344. return NULL;
  4345. }
  4346. nbytes = wcrtomb (wp, *ws, &state);
  4347. if (nbytes == (size_t) -1)
  4348. /* Error in the conversion. */
  4349. return NULL;
  4350. len -= nbytes;
  4351. wp += nbytes;
  4352. }
  4353. while (*ws++ != L'\0');
  4354. return s;
  4355. }
  4356. First the function has to find the end of the string currently in the
  4357. array S. The ‘strchr’ call does this very efficiently since a
  4358. requirement for multibyte character representations is that the NUL byte
  4359. is never used except to represent itself (and in this context, the end
  4360. of the string).
  4361. After initializing the state object the loop is entered where the
  4362. first task is to make sure there is enough room in the array S. We
  4363. abort if there are not at least ‘MB_CUR_LEN’ bytes available. This is
  4364. not always optimal but we have no other choice. We might have less than
  4365. ‘MB_CUR_LEN’ bytes available but the next multibyte character might also
  4366. be only one byte long. At the time the ‘wcrtomb’ call returns it is too
  4367. late to decide whether the buffer was large enough. If this solution is
  4368. unsuitable, there is a very slow but more accurate solution.
  4369. ...
  4370. if (len < MB_CUR_LEN)
  4371. {
  4372. mbstate_t temp_state;
  4373. memcpy (&temp_state, &state, sizeof (state));
  4374. if (wcrtomb (NULL, *ws, &temp_state) > len)
  4375. {
  4376. /* We cannot guarantee that the next
  4377. character fits into the buffer, so
  4378. return an error. */
  4379. errno = E2BIG;
  4380. return NULL;
  4381. }
  4382. }
  4383. ...
  4384. Here we perform the conversion that might overflow the buffer so that
  4385. we are afterwards in the position to make an exact decision about the
  4386. buffer size. Please note the ‘NULL’ argument for the destination buffer
  4387. in the new ‘wcrtomb’ call; since we are not interested in the converted
  4388. text at this point, this is a nice way to express this. The most
  4389. unusual thing about this piece of code certainly is the duplication of
  4390. the conversion state object, but if a change of the state is necessary
  4391. to emit the next multibyte character, we want to have the same shift
  4392. state change performed in the real conversion. Therefore, we have to
  4393. preserve the initial shift state information.
  4394. There are certainly many more and even better solutions to this
  4395. problem. This example is only provided for educational purposes.
  4396. 
  4397. File: libc.info, Node: Converting Strings, Next: Multibyte Conversion Example, Prev: Converting a Character, Up: Restartable multibyte conversion
  4398. 6.3.4 Converting Multibyte and Wide Character Strings
  4399. -----------------------------------------------------
  4400. The functions described in the previous section only convert a single
  4401. character at a time. Most operations to be performed in real-world
  4402. programs include strings and therefore the ISO C standard also defines
  4403. conversions on entire strings. However, the defined set of functions is
  4404. quite limited; therefore, the GNU C Library contains a few extensions
  4405. that can help in some important situations.
  4406. -- Function: size_t mbsrtowcs (wchar_t *restrict DST, const char
  4407. **restrict SRC, size_t LEN, mbstate_t *restrict PS)
  4408. Preliminary: | MT-Unsafe race:mbsrtowcs/!ps | AS-Unsafe corrupt
  4409. heap lock dlopen | AC-Unsafe corrupt lock mem fd | *Note POSIX
  4410. Safety Concepts::.
  4411. The ‘mbsrtowcs’ function ("multibyte string restartable to wide
  4412. character string") converts the NUL-terminated multibyte character
  4413. string at ‘*SRC’ into an equivalent wide character string,
  4414. including the NUL wide character at the end. The conversion is
  4415. started using the state information from the object pointed to by
  4416. PS or from an internal object of ‘mbsrtowcs’ if PS is a null
  4417. pointer. Before returning, the state object is updated to match
  4418. the state after the last converted character. The state is the
  4419. initial state if the terminating NUL byte is reached and converted.
  4420. If DST is not a null pointer, the result is stored in the array
  4421. pointed to by DST; otherwise, the conversion result is not
  4422. available since it is stored in an internal buffer.
  4423. If LEN wide characters are stored in the array DST before reaching
  4424. the end of the input string, the conversion stops and LEN is
  4425. returned. If DST is a null pointer, LEN is never checked.
  4426. Another reason for a premature return from the function call is if
  4427. the input string contains an invalid multibyte sequence. In this
  4428. case the global variable ‘errno’ is set to ‘EILSEQ’ and the
  4429. function returns ‘(size_t) -1’.
  4430. In all other cases the function returns the number of wide
  4431. characters converted during this call. If DST is not null,
  4432. ‘mbsrtowcs’ stores in the pointer pointed to by SRC either a null
  4433. pointer (if the NUL byte in the input string was reached) or the
  4434. address of the byte following the last converted multibyte
  4435. character.
  4436. Like ‘mbstowcs’ the DST parameter may be a null pointer and the
  4437. function can be used to count the number of wide characters that
  4438. would be required.
  4439. ‘mbsrtowcs’ was introduced in Amendment 1 to ISO C90 and is
  4440. declared in ‘wchar.h’.
  4441. The definition of the ‘mbsrtowcs’ function has one important
  4442. limitation. The requirement that DST has to be a NUL-terminated string
  4443. provides problems if one wants to convert buffers with text. A buffer
  4444. is not normally a collection of NUL-terminated strings but instead a
  4445. continuous collection of lines, separated by newline characters. Now
  4446. assume that a function to convert one line from a buffer is needed.
  4447. Since the line is not NUL-terminated, the source pointer cannot directly
  4448. point into the unmodified text buffer. This means, either one inserts
  4449. the NUL byte at the appropriate place for the time of the ‘mbsrtowcs’
  4450. function call (which is not doable for a read-only buffer or in a
  4451. multi-threaded application) or one copies the line in an extra buffer
  4452. where it can be terminated by a NUL byte. Note that it is not in
  4453. general possible to limit the number of characters to convert by setting
  4454. the parameter LEN to any specific value. Since it is not known how many
  4455. bytes each multibyte character sequence is in length, one can only
  4456. guess.
  4457. There is still a problem with the method of NUL-terminating a line
  4458. right after the newline character, which could lead to very strange
  4459. results. As said in the description of the ‘mbsrtowcs’ function above,
  4460. the conversion state is guaranteed to be in the initial shift state
  4461. after processing the NUL byte at the end of the input string. But this
  4462. NUL byte is not really part of the text (i.e., the conversion state
  4463. after the newline in the original text could be something different than
  4464. the initial shift state and therefore the first character of the next
  4465. line is encoded using this state). But the state in question is never
  4466. accessible to the user since the conversion stops after the NUL byte
  4467. (which resets the state). Most stateful character sets in use today
  4468. require that the shift state after a newline be the initial state-but
  4469. this is not a strict guarantee. Therefore, simply NUL-terminating a
  4470. piece of a running text is not always an adequate solution and,
  4471. therefore, should never be used in generally used code.
  4472. The generic conversion interface (*note Generic Charset Conversion::)
  4473. does not have this limitation (it simply works on buffers, not strings),
  4474. and the GNU C Library contains a set of functions that take additional
  4475. parameters specifying the maximal number of bytes that are consumed from
  4476. the input string. This way the problem of ‘mbsrtowcs’'s example above
  4477. could be solved by determining the line length and passing this length
  4478. to the function.
  4479. -- Function: size_t wcsrtombs (char *restrict DST, const wchar_t
  4480. **restrict SRC, size_t LEN, mbstate_t *restrict PS)
  4481. Preliminary: | MT-Unsafe race:wcsrtombs/!ps | AS-Unsafe corrupt
  4482. heap lock dlopen | AC-Unsafe corrupt lock mem fd | *Note POSIX
  4483. Safety Concepts::.
  4484. The ‘wcsrtombs’ function ("wide character string restartable to
  4485. multibyte string") converts the NUL-terminated wide character
  4486. string at ‘*SRC’ into an equivalent multibyte character string and
  4487. stores the result in the array pointed to by DST. The NUL wide
  4488. character is also converted. The conversion starts in the state
  4489. described in the object pointed to by PS or by a state object local
  4490. to ‘wcsrtombs’ in case PS is a null pointer. If DST is a null
  4491. pointer, the conversion is performed as usual but the result is not
  4492. available. If all characters of the input string were successfully
  4493. converted and if DST is not a null pointer, the pointer pointed to
  4494. by SRC gets assigned a null pointer.
  4495. If one of the wide characters in the input string has no valid
  4496. multibyte character equivalent, the conversion stops early, sets
  4497. the global variable ‘errno’ to ‘EILSEQ’, and returns ‘(size_t) -1’.
  4498. Another reason for a premature stop is if DST is not a null pointer
  4499. and the next converted character would require more than LEN bytes
  4500. in total to the array DST. In this case (and if DST is not a null
  4501. pointer) the pointer pointed to by SRC is assigned a value pointing
  4502. to the wide character right after the last one successfully
  4503. converted.
  4504. Except in the case of an encoding error the return value of the
  4505. ‘wcsrtombs’ function is the number of bytes in all the multibyte
  4506. character sequences which were or would have been (if DST was not a
  4507. null) stored in DST. Before returning, the state in the object
  4508. pointed to by PS (or the internal object in case PS is a null
  4509. pointer) is updated to reflect the state after the last conversion.
  4510. The state is the initial shift state in case the terminating NUL
  4511. wide character was converted.
  4512. The ‘wcsrtombs’ function was introduced in Amendment 1 to ISO C90
  4513. and is declared in ‘wchar.h’.
  4514. The restriction mentioned above for the ‘mbsrtowcs’ function applies
  4515. here also. There is no possibility of directly controlling the number
  4516. of input characters. One has to place the NUL wide character at the
  4517. correct place or control the consumed input indirectly via the available
  4518. output array size (the LEN parameter).
  4519. -- Function: size_t mbsnrtowcs (wchar_t *restrict DST, const char
  4520. **restrict SRC, size_t NMC, size_t LEN, mbstate_t *restrict
  4521. PS)
  4522. Preliminary: | MT-Unsafe race:mbsnrtowcs/!ps | AS-Unsafe corrupt
  4523. heap lock dlopen | AC-Unsafe corrupt lock mem fd | *Note POSIX
  4524. Safety Concepts::.
  4525. The ‘mbsnrtowcs’ function is very similar to the ‘mbsrtowcs’
  4526. function. All the parameters are the same except for NMC, which is
  4527. new. The return value is the same as for ‘mbsrtowcs’.
  4528. This new parameter specifies how many bytes at most can be used
  4529. from the multibyte character string. In other words, the multibyte
  4530. character string ‘*SRC’ need not be NUL-terminated. But if a NUL
  4531. byte is found within the NMC first bytes of the string, the
  4532. conversion stops there.
  4533. Like ‘mbstowcs’ the DST parameter may be a null pointer and the
  4534. function can be used to count the number of wide characters that
  4535. would be required.
  4536. This function is a GNU extension. It is meant to work around the
  4537. problems mentioned above. Now it is possible to convert a buffer
  4538. with multibyte character text piece by piece without having to care
  4539. about inserting NUL bytes and the effect of NUL bytes on the
  4540. conversion state.
  4541. A function to convert a multibyte string into a wide character string
  4542. and display it could be written like this (this is not a really useful
  4543. example):
  4544. void
  4545. showmbs (const char *src, FILE *fp)
  4546. {
  4547. mbstate_t state;
  4548. int cnt = 0;
  4549. memset (&state, '\0', sizeof (state));
  4550. while (1)
  4551. {
  4552. wchar_t linebuf[100];
  4553. const char *endp = strchr (src, '\n');
  4554. size_t n;
  4555. /* Exit if there is no more line. */
  4556. if (endp == NULL)
  4557. break;
  4558. n = mbsnrtowcs (linebuf, &src, endp - src, 99, &state);
  4559. linebuf[n] = L'\0';
  4560. fprintf (fp, "line %d: \"%S\"\n", linebuf);
  4561. }
  4562. }
  4563. There is no problem with the state after a call to ‘mbsnrtowcs’.
  4564. Since we don't insert characters in the strings that were not in there
  4565. right from the beginning and we use STATE only for the conversion of the
  4566. given buffer, there is no problem with altering the state.
  4567. -- Function: size_t wcsnrtombs (char *restrict DST, const wchar_t
  4568. **restrict SRC, size_t NWC, size_t LEN, mbstate_t *restrict
  4569. PS)
  4570. Preliminary: | MT-Unsafe race:wcsnrtombs/!ps | AS-Unsafe corrupt
  4571. heap lock dlopen | AC-Unsafe corrupt lock mem fd | *Note POSIX
  4572. Safety Concepts::.
  4573. The ‘wcsnrtombs’ function implements the conversion from wide
  4574. character strings to multibyte character strings. It is similar to
  4575. ‘wcsrtombs’ but, just like ‘mbsnrtowcs’, it takes an extra
  4576. parameter, which specifies the length of the input string.
  4577. No more than NWC wide characters from the input string ‘*SRC’ are
  4578. converted. If the input string contains a NUL wide character in
  4579. the first NWC characters, the conversion stops at this place.
  4580. The ‘wcsnrtombs’ function is a GNU extension and just like
  4581. ‘mbsnrtowcs’ helps in situations where no NUL-terminated input
  4582. strings are available.
  4583. 
  4584. File: libc.info, Node: Multibyte Conversion Example, Prev: Converting Strings, Up: Restartable multibyte conversion
  4585. 6.3.5 A Complete Multibyte Conversion Example
  4586. ---------------------------------------------
  4587. The example programs given in the last sections are only brief and do
  4588. not contain all the error checking, etc. Presented here is a complete
  4589. and documented example. It features the ‘mbrtowc’ function but it
  4590. should be easy to derive versions using the other functions.
  4591. int
  4592. file_mbsrtowcs (int input, int output)
  4593. {
  4594. /* Note the use of ‘MB_LEN_MAX’.
  4595. ‘MB_CUR_MAX’ cannot portably be used here. */
  4596. char buffer[BUFSIZ + MB_LEN_MAX];
  4597. mbstate_t state;
  4598. int filled = 0;
  4599. int eof = 0;
  4600. /* Initialize the state. */
  4601. memset (&state, '\0', sizeof (state));
  4602. while (!eof)
  4603. {
  4604. ssize_t nread;
  4605. ssize_t nwrite;
  4606. char *inp = buffer;
  4607. wchar_t outbuf[BUFSIZ];
  4608. wchar_t *outp = outbuf;
  4609. /* Fill up the buffer from the input file. */
  4610. nread = read (input, buffer + filled, BUFSIZ);
  4611. if (nread < 0)
  4612. {
  4613. perror ("read");
  4614. return 0;
  4615. }
  4616. /* If we reach end of file, make a note to read no more. */
  4617. if (nread == 0)
  4618. eof = 1;
  4619. /* ‘filled’ is now the number of bytes in ‘buffer’. */
  4620. filled += nread;
  4621. /* Convert those bytes to wide characters-as many as we can. */
  4622. while (1)
  4623. {
  4624. size_t thislen = mbrtowc (outp, inp, filled, &state);
  4625. /* Stop converting at invalid character;
  4626. this can mean we have read just the first part
  4627. of a valid character. */
  4628. if (thislen == (size_t) -1)
  4629. break;
  4630. /* We want to handle embedded NUL bytes
  4631. but the return value is 0. Correct this. */
  4632. if (thislen == 0)
  4633. thislen = 1;
  4634. /* Advance past this character. */
  4635. inp += thislen;
  4636. filled -= thislen;
  4637. ++outp;
  4638. }
  4639. /* Write the wide characters we just made. */
  4640. nwrite = write (output, outbuf,
  4641. (outp - outbuf) * sizeof (wchar_t));
  4642. if (nwrite < 0)
  4643. {
  4644. perror ("write");
  4645. return 0;
  4646. }
  4647. /* See if we have a _real_ invalid character. */
  4648. if ((eof && filled > 0) || filled >= MB_CUR_MAX)
  4649. {
  4650. error (0, 0, "invalid multibyte character");
  4651. return 0;
  4652. }
  4653. /* If any characters must be carried forward,
  4654. put them at the beginning of ‘buffer’. */
  4655. if (filled > 0)
  4656. memmove (buffer, inp, filled);
  4657. }
  4658. return 1;
  4659. }
  4660. 
  4661. File: libc.info, Node: Non-reentrant Conversion, Next: Generic Charset Conversion, Prev: Restartable multibyte conversion, Up: Character Set Handling
  4662. 6.4 Non-reentrant Conversion Function
  4663. =====================================
  4664. The functions described in the previous chapter are defined in
  4665. Amendment 1 to ISO C90, but the original ISO C90 standard also contained
  4666. functions for character set conversion. The reason that these original
  4667. functions are not described first is that they are almost entirely
  4668. useless.
  4669. The problem is that all the conversion functions described in the
  4670. original ISO C90 use a local state. Using a local state implies that
  4671. multiple conversions at the same time (not only when using threads)
  4672. cannot be done, and that you cannot first convert single characters and
  4673. then strings since you cannot tell the conversion functions which state
  4674. to use.
  4675. These original functions are therefore usable only in a very limited
  4676. set of situations. One must complete converting the entire string
  4677. before starting a new one, and each string/text must be converted with
  4678. the same function (there is no problem with the library itself; it is
  4679. guaranteed that no library function changes the state of any of these
  4680. functions). *For the above reasons it is highly requested that the
  4681. functions described in the previous section be used in place of
  4682. non-reentrant conversion functions.*
  4683. * Menu:
  4684. * Non-reentrant Character Conversion:: Non-reentrant Conversion of Single
  4685. Characters.
  4686. * Non-reentrant String Conversion:: Non-reentrant Conversion of Strings.
  4687. * Shift State:: States in Non-reentrant Functions.
  4688. 
  4689. File: libc.info, Node: Non-reentrant Character Conversion, Next: Non-reentrant String Conversion, Up: Non-reentrant Conversion
  4690. 6.4.1 Non-reentrant Conversion of Single Characters
  4691. ---------------------------------------------------
  4692. -- Function: int mbtowc (wchar_t *restrict RESULT, const char *restrict
  4693. STRING, size_t SIZE)
  4694. Preliminary: | MT-Unsafe race | AS-Unsafe corrupt heap lock dlopen
  4695. | AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  4696. The ‘mbtowc’ ("multibyte to wide character") function when called
  4697. with non-null STRING converts the first multibyte character
  4698. beginning at STRING to its corresponding wide character code. It
  4699. stores the result in ‘*RESULT’.
  4700. ‘mbtowc’ never examines more than SIZE bytes. (The idea is to
  4701. supply for SIZE the number of bytes of data you have in hand.)
  4702. ‘mbtowc’ with non-null STRING distinguishes three possibilities:
  4703. the first SIZE bytes at STRING start with valid multibyte
  4704. characters, they start with an invalid byte sequence or just part
  4705. of a character, or STRING points to an empty string (a null
  4706. character).
  4707. For a valid multibyte character, ‘mbtowc’ converts it to a wide
  4708. character and stores that in ‘*RESULT’, and returns the number of
  4709. bytes in that character (always at least 1 and never more than
  4710. SIZE).
  4711. For an invalid byte sequence, ‘mbtowc’ returns -1. For an empty
  4712. string, it returns 0, also storing ‘'\0'’ in ‘*RESULT’.
  4713. If the multibyte character code uses shift characters, then
  4714. ‘mbtowc’ maintains and updates a shift state as it scans. If you
  4715. call ‘mbtowc’ with a null pointer for STRING, that initializes the
  4716. shift state to its standard initial value. It also returns nonzero
  4717. if the multibyte character code in use actually has a shift state.
  4718. *Note Shift State::.
  4719. -- Function: int wctomb (char *STRING, wchar_t WCHAR)
  4720. Preliminary: | MT-Unsafe race | AS-Unsafe corrupt heap lock dlopen
  4721. | AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  4722. The ‘wctomb’ ("wide character to multibyte") function converts the
  4723. wide character code WCHAR to its corresponding multibyte character
  4724. sequence, and stores the result in bytes starting at STRING. At
  4725. most ‘MB_CUR_MAX’ characters are stored.
  4726. ‘wctomb’ with non-null STRING distinguishes three possibilities for
  4727. WCHAR: a valid wide character code (one that can be translated to a
  4728. multibyte character), an invalid code, and ‘L'\0'’.
  4729. Given a valid code, ‘wctomb’ converts it to a multibyte character,
  4730. storing the bytes starting at STRING. Then it returns the number
  4731. of bytes in that character (always at least 1 and never more than
  4732. ‘MB_CUR_MAX’).
  4733. If WCHAR is an invalid wide character code, ‘wctomb’ returns -1.
  4734. If WCHAR is ‘L'\0'’, it returns ‘0’, also storing ‘'\0'’ in
  4735. ‘*STRING’.
  4736. If the multibyte character code uses shift characters, then
  4737. ‘wctomb’ maintains and updates a shift state as it scans. If you
  4738. call ‘wctomb’ with a null pointer for STRING, that initializes the
  4739. shift state to its standard initial value. It also returns nonzero
  4740. if the multibyte character code in use actually has a shift state.
  4741. *Note Shift State::.
  4742. Calling this function with a WCHAR argument of zero when STRING is
  4743. not null has the side-effect of reinitializing the stored shift
  4744. state _as well as_ storing the multibyte character ‘'\0'’ and
  4745. returning 0.
  4746. Similar to ‘mbrlen’ there is also a non-reentrant function that
  4747. computes the length of a multibyte character. It can be defined in
  4748. terms of ‘mbtowc’.
  4749. -- Function: int mblen (const char *STRING, size_t SIZE)
  4750. Preliminary: | MT-Unsafe race | AS-Unsafe corrupt heap lock dlopen
  4751. | AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  4752. The ‘mblen’ function with a non-null STRING argument returns the
  4753. number of bytes that make up the multibyte character beginning at
  4754. STRING, never examining more than SIZE bytes. (The idea is to
  4755. supply for SIZE the number of bytes of data you have in hand.)
  4756. The return value of ‘mblen’ distinguishes three possibilities: the
  4757. first SIZE bytes at STRING start with valid multibyte characters,
  4758. they start with an invalid byte sequence or just part of a
  4759. character, or STRING points to an empty string (a null character).
  4760. For a valid multibyte character, ‘mblen’ returns the number of
  4761. bytes in that character (always at least ‘1’ and never more than
  4762. SIZE). For an invalid byte sequence, ‘mblen’ returns -1. For an
  4763. empty string, it returns 0.
  4764. If the multibyte character code uses shift characters, then ‘mblen’
  4765. maintains and updates a shift state as it scans. If you call
  4766. ‘mblen’ with a null pointer for STRING, that initializes the shift
  4767. state to its standard initial value. It also returns a nonzero
  4768. value if the multibyte character code in use actually has a shift
  4769. state. *Note Shift State::.
  4770. The function ‘mblen’ is declared in ‘stdlib.h’.
  4771. 
  4772. File: libc.info, Node: Non-reentrant String Conversion, Next: Shift State, Prev: Non-reentrant Character Conversion, Up: Non-reentrant Conversion
  4773. 6.4.2 Non-reentrant Conversion of Strings
  4774. -----------------------------------------
  4775. For convenience the ISO C90 standard also defines functions to convert
  4776. entire strings instead of single characters. These functions suffer
  4777. from the same problems as their reentrant counterparts from Amendment 1
  4778. to ISO C90; see *note Converting Strings::.
  4779. -- Function: size_t mbstowcs (wchar_t *WSTRING, const char *STRING,
  4780. size_t SIZE)
  4781. Preliminary: | MT-Safe | AS-Unsafe corrupt heap lock dlopen |
  4782. AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  4783. The ‘mbstowcs’ ("multibyte string to wide character string")
  4784. function converts the null-terminated string of multibyte
  4785. characters STRING to an array of wide character codes, storing not
  4786. more than SIZE wide characters into the array beginning at WSTRING.
  4787. The terminating null character counts towards the size, so if SIZE
  4788. is less than the actual number of wide characters resulting from
  4789. STRING, no terminating null character is stored.
  4790. The conversion of characters from STRING begins in the initial
  4791. shift state.
  4792. If an invalid multibyte character sequence is found, the ‘mbstowcs’
  4793. function returns a value of -1. Otherwise, it returns the number
  4794. of wide characters stored in the array WSTRING. This number does
  4795. not include the terminating null character, which is present if the
  4796. number is less than SIZE.
  4797. Here is an example showing how to convert a string of multibyte
  4798. characters, allocating enough space for the result.
  4799. wchar_t *
  4800. mbstowcs_alloc (const char *string)
  4801. {
  4802. size_t size = strlen (string) + 1;
  4803. wchar_t *buf = xmalloc (size * sizeof (wchar_t));
  4804. size = mbstowcs (buf, string, size);
  4805. if (size == (size_t) -1)
  4806. return NULL;
  4807. buf = xreallocarray (buf, size + 1, sizeof *buf);
  4808. return buf;
  4809. }
  4810. If WSTRING is a null pointer then no output is written and the
  4811. conversion proceeds as above, and the result is returned. In
  4812. practice such behaviour is useful for calculating the exact number
  4813. of wide characters required to convert STRING. This behaviour of
  4814. accepting a null pointer for WSTRING is an XPG4.2 extension that is
  4815. not specified in ISO C and is optional in POSIX.
  4816. -- Function: size_t wcstombs (char *STRING, const wchar_t *WSTRING,
  4817. size_t SIZE)
  4818. Preliminary: | MT-Safe | AS-Unsafe corrupt heap lock dlopen |
  4819. AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  4820. The ‘wcstombs’ ("wide character string to multibyte string")
  4821. function converts the null-terminated wide character array WSTRING
  4822. into a string containing multibyte characters, storing not more
  4823. than SIZE bytes starting at STRING, followed by a terminating null
  4824. character if there is room. The conversion of characters begins in
  4825. the initial shift state.
  4826. The terminating null character counts towards the size, so if SIZE
  4827. is less than or equal to the number of bytes needed in WSTRING, no
  4828. terminating null character is stored.
  4829. If a code that does not correspond to a valid multibyte character
  4830. is found, the ‘wcstombs’ function returns a value of -1.
  4831. Otherwise, the return value is the number of bytes stored in the
  4832. array STRING. This number does not include the terminating null
  4833. character, which is present if the number is less than SIZE.
  4834. 
  4835. File: libc.info, Node: Shift State, Prev: Non-reentrant String Conversion, Up: Non-reentrant Conversion
  4836. 6.4.3 States in Non-reentrant Functions
  4837. ---------------------------------------
  4838. In some multibyte character codes, the _meaning_ of any particular byte
  4839. sequence is not fixed; it depends on what other sequences have come
  4840. earlier in the same string. Typically there are just a few sequences
  4841. that can change the meaning of other sequences; these few are called
  4842. “shift sequences” and we say that they set the “shift state” for other
  4843. sequences that follow.
  4844. To illustrate shift state and shift sequences, suppose we decide that
  4845. the sequence ‘0200’ (just one byte) enters Japanese mode, in which pairs
  4846. of bytes in the range from ‘0240’ to ‘0377’ are single characters, while
  4847. ‘0201’ enters Latin-1 mode, in which single bytes in the range from
  4848. ‘0240’ to ‘0377’ are characters, and interpreted according to the ISO
  4849. Latin-1 character set. This is a multibyte code that has two
  4850. alternative shift states ("Japanese mode" and "Latin-1 mode"), and two
  4851. shift sequences that specify particular shift states.
  4852. When the multibyte character code in use has shift states, then
  4853. ‘mblen’, ‘mbtowc’, and ‘wctomb’ must maintain and update the current
  4854. shift state as they scan the string. To make this work properly, you
  4855. must follow these rules:
  4856. • Before starting to scan a string, call the function with a null
  4857. pointer for the multibyte character address--for example, ‘mblen
  4858. (NULL, 0)’. This initializes the shift state to its standard
  4859. initial value.
  4860. • Scan the string one character at a time, in order. Do not "back
  4861. up" and rescan characters already scanned, and do not intersperse
  4862. the processing of different strings.
  4863. Here is an example of using ‘mblen’ following these rules:
  4864. void
  4865. scan_string (char *s)
  4866. {
  4867. int length = strlen (s);
  4868. /* Initialize shift state. */
  4869. mblen (NULL, 0);
  4870. while (1)
  4871. {
  4872. int thischar = mblen (s, length);
  4873. /* Deal with end of string and invalid characters. */
  4874. if (thischar == 0)
  4875. break;
  4876. if (thischar == -1)
  4877. {
  4878. error ("invalid multibyte character");
  4879. break;
  4880. }
  4881. /* Advance past this character. */
  4882. s += thischar;
  4883. length -= thischar;
  4884. }
  4885. }
  4886. The functions ‘mblen’, ‘mbtowc’ and ‘wctomb’ are not reentrant when
  4887. using a multibyte code that uses a shift state. However, no other
  4888. library functions call these functions, so you don't have to worry that
  4889. the shift state will be changed mysteriously.
  4890. 
  4891. File: libc.info, Node: Generic Charset Conversion, Prev: Non-reentrant Conversion, Up: Character Set Handling
  4892. 6.5 Generic Charset Conversion
  4893. ==============================
  4894. The conversion functions mentioned so far in this chapter all had in
  4895. common that they operate on character sets that are not directly
  4896. specified by the functions. The multibyte encoding used is specified by
  4897. the currently selected locale for the ‘LC_CTYPE’ category. The wide
  4898. character set is fixed by the implementation (in the case of the GNU C
  4899. Library it is always UCS-4 encoded ISO 10646).
  4900. This has of course several problems when it comes to general
  4901. character conversion:
  4902. • For every conversion where neither the source nor the destination
  4903. character set is the character set of the locale for the ‘LC_CTYPE’
  4904. category, one has to change the ‘LC_CTYPE’ locale using
  4905. ‘setlocale’.
  4906. Changing the ‘LC_CTYPE’ locale introduces major problems for the
  4907. rest of the programs since several more functions (e.g., the
  4908. character classification functions, *note Classification of
  4909. Characters::) use the ‘LC_CTYPE’ category.
  4910. • Parallel conversions to and from different character sets are not
  4911. possible since the ‘LC_CTYPE’ selection is global and shared by all
  4912. threads.
  4913. • If neither the source nor the destination character set is the
  4914. character set used for ‘wchar_t’ representation, there is at least
  4915. a two-step process necessary to convert a text using the functions
  4916. above. One would have to select the source character set as the
  4917. multibyte encoding, convert the text into a ‘wchar_t’ text, select
  4918. the destination character set as the multibyte encoding, and
  4919. convert the wide character text to the multibyte (= destination)
  4920. character set.
  4921. Even if this is possible (which is not guaranteed) it is a very
  4922. tiring work. Plus it suffers from the other two raised points even
  4923. more due to the steady changing of the locale.
  4924. The XPG2 standard defines a completely new set of functions, which
  4925. has none of these limitations. They are not at all coupled to the
  4926. selected locales, and they have no constraints on the character sets
  4927. selected for source and destination. Only the set of available
  4928. conversions limits them. The standard does not specify that any
  4929. conversion at all must be available. Such availability is a measure of
  4930. the quality of the implementation.
  4931. In the following text first the interface to ‘iconv’ and then the
  4932. conversion function, will be described. Comparisons with other
  4933. implementations will show what obstacles stand in the way of portable
  4934. applications. Finally, the implementation is described in so far as
  4935. might interest the advanced user who wants to extend conversion
  4936. capabilities.
  4937. * Menu:
  4938. * Generic Conversion Interface:: Generic Character Set Conversion Interface.
  4939. * iconv Examples:: A complete ‘iconv’ example.
  4940. * Other iconv Implementations:: Some Details about other ‘iconv’
  4941. Implementations.
  4942. * glibc iconv Implementation:: The ‘iconv’ Implementation in the GNU C
  4943. library.
  4944. 
  4945. File: libc.info, Node: Generic Conversion Interface, Next: iconv Examples, Up: Generic Charset Conversion
  4946. 6.5.1 Generic Character Set Conversion Interface
  4947. ------------------------------------------------
  4948. This set of functions follows the traditional cycle of using a resource:
  4949. open-use-close. The interface consists of three functions, each of
  4950. which implements one step.
  4951. Before the interfaces are described it is necessary to introduce a
  4952. data type. Just like other open-use-close interfaces the functions
  4953. introduced here work using handles and the ‘iconv.h’ header defines a
  4954. special type for the handles used.
  4955. -- Data Type: iconv_t
  4956. This data type is an abstract type defined in ‘iconv.h’. The user
  4957. must not assume anything about the definition of this type; it must
  4958. be completely opaque.
  4959. Objects of this type can be assigned handles for the conversions
  4960. using the ‘iconv’ functions. The objects themselves need not be
  4961. freed, but the conversions for which the handles stand for have to.
  4962. The first step is the function to create a handle.
  4963. -- Function: iconv_t iconv_open (const char *TOCODE, const char
  4964. *FROMCODE)
  4965. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap lock dlopen
  4966. | AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  4967. The ‘iconv_open’ function has to be used before starting a
  4968. conversion. The two parameters this function takes determine the
  4969. source and destination character set for the conversion, and if the
  4970. implementation has the possibility to perform such a conversion,
  4971. the function returns a handle.
  4972. If the wanted conversion is not available, the ‘iconv_open’
  4973. function returns ‘(iconv_t) -1’. In this case the global variable
  4974. ‘errno’ can have the following values:
  4975. ‘EMFILE’
  4976. The process already has ‘OPEN_MAX’ file descriptors open.
  4977. ‘ENFILE’
  4978. The system limit of open files is reached.
  4979. ‘ENOMEM’
  4980. Not enough memory to carry out the operation.
  4981. ‘EINVAL’
  4982. The conversion from FROMCODE to TOCODE is not supported.
  4983. It is not possible to use the same descriptor in different threads
  4984. to perform independent conversions. The data structures associated
  4985. with the descriptor include information about the conversion state.
  4986. This must not be messed up by using it in different conversions.
  4987. An ‘iconv’ descriptor is like a file descriptor as for every use a
  4988. new descriptor must be created. The descriptor does not stand for
  4989. all of the conversions from FROMSET to TOSET.
  4990. The GNU C Library implementation of ‘iconv_open’ has one
  4991. significant extension to other implementations. To ease the
  4992. extension of the set of available conversions, the implementation
  4993. allows storing the necessary files with data and code in an
  4994. arbitrary number of directories. How this extension must be
  4995. written will be explained below (*note glibc iconv
  4996. Implementation::). Here it is only important to say that all
  4997. directories mentioned in the ‘GCONV_PATH’ environment variable are
  4998. considered only if they contain a file ‘gconv-modules’. These
  4999. directories need not necessarily be created by the system
  5000. administrator. In fact, this extension is introduced to help users
  5001. writing and using their own, new conversions. Of course, this does
  5002. not work for security reasons in SUID binaries; in this case only
  5003. the system directory is considered and this normally is
  5004. ‘PREFIX/lib/gconv’. The ‘GCONV_PATH’ environment variable is
  5005. examined exactly once at the first call of the ‘iconv_open’
  5006. function. Later modifications of the variable have no effect.
  5007. The ‘iconv_open’ function was introduced early in the X/Open
  5008. Portability Guide, version 2. It is supported by all commercial
  5009. Unices as it is required for the Unix branding. However, the
  5010. quality and completeness of the implementation varies widely. The
  5011. ‘iconv_open’ function is declared in ‘iconv.h’.
  5012. The ‘iconv’ implementation can associate large data structure with
  5013. the handle returned by ‘iconv_open’. Therefore, it is crucial to free
  5014. all the resources once all conversions are carried out and the
  5015. conversion is not needed anymore.
  5016. -- Function: int iconv_close (iconv_t CD)
  5017. Preliminary: | MT-Safe | AS-Unsafe corrupt heap lock dlopen |
  5018. AC-Unsafe corrupt lock mem | *Note POSIX Safety Concepts::.
  5019. The ‘iconv_close’ function frees all resources associated with the
  5020. handle CD, which must have been returned by a successful call to
  5021. the ‘iconv_open’ function.
  5022. If the function call was successful the return value is 0.
  5023. Otherwise it is -1 and ‘errno’ is set appropriately. Defined
  5024. errors are:
  5025. ‘EBADF’
  5026. The conversion descriptor is invalid.
  5027. The ‘iconv_close’ function was introduced together with the rest of
  5028. the ‘iconv’ functions in XPG2 and is declared in ‘iconv.h’.
  5029. The standard defines only one actual conversion function. This has,
  5030. therefore, the most general interface: it allows conversion from one
  5031. buffer to another. Conversion from a file to a buffer, vice versa, or
  5032. even file to file can be implemented on top of it.
  5033. -- Function: size_t iconv (iconv_t CD, char **INBUF, size_t
  5034. *INBYTESLEFT, char **OUTBUF, size_t *OUTBYTESLEFT)
  5035. Preliminary: | MT-Safe race:cd | AS-Safe | AC-Unsafe corrupt |
  5036. *Note POSIX Safety Concepts::.
  5037. The ‘iconv’ function converts the text in the input buffer
  5038. according to the rules associated with the descriptor CD and stores
  5039. the result in the output buffer. It is possible to call the
  5040. function for the same text several times in a row since for
  5041. stateful character sets the necessary state information is kept in
  5042. the data structures associated with the descriptor.
  5043. The input buffer is specified by ‘*INBUF’ and it contains
  5044. ‘*INBYTESLEFT’ bytes. The extra indirection is necessary for
  5045. communicating the used input back to the caller (see below). It is
  5046. important to note that the buffer pointer is of type ‘char’ and the
  5047. length is measured in bytes even if the input text is encoded in
  5048. wide characters.
  5049. The output buffer is specified in a similar way. ‘*OUTBUF’ points
  5050. to the beginning of the buffer with at least ‘*OUTBYTESLEFT’ bytes
  5051. room for the result. The buffer pointer again is of type ‘char’
  5052. and the length is measured in bytes. If OUTBUF or ‘*OUTBUF’ is a
  5053. null pointer, the conversion is performed but no output is
  5054. available.
  5055. If INBUF is a null pointer, the ‘iconv’ function performs the
  5056. necessary action to put the state of the conversion into the
  5057. initial state. This is obviously a no-op for non-stateful
  5058. encodings, but if the encoding has a state, such a function call
  5059. might put some byte sequences in the output buffer, which perform
  5060. the necessary state changes. The next call with INBUF not being a
  5061. null pointer then simply goes on from the initial state. It is
  5062. important that the programmer never makes any assumption as to
  5063. whether the conversion has to deal with states. Even if the input
  5064. and output character sets are not stateful, the implementation
  5065. might still have to keep states. This is due to the implementation
  5066. chosen for the GNU C Library as it is described below. Therefore
  5067. an ‘iconv’ call to reset the state should always be performed if
  5068. some protocol requires this for the output text.
  5069. The conversion stops for one of three reasons. The first is that
  5070. all characters from the input buffer are converted. This actually
  5071. can mean two things: either all bytes from the input buffer are
  5072. consumed or there are some bytes at the end of the buffer that
  5073. possibly can form a complete character but the input is incomplete.
  5074. The second reason for a stop is that the output buffer is full.
  5075. And the third reason is that the input contains invalid characters.
  5076. In all of these cases the buffer pointers after the last successful
  5077. conversion, for the input and output buffers, are stored in INBUF
  5078. and OUTBUF, and the available room in each buffer is stored in
  5079. INBYTESLEFT and OUTBYTESLEFT.
  5080. Since the character sets selected in the ‘iconv_open’ call can be
  5081. almost arbitrary, there can be situations where the input buffer
  5082. contains valid characters, which have no identical representation
  5083. in the output character set. The behavior in this situation is
  5084. undefined. The _current_ behavior of the GNU C Library in this
  5085. situation is to return with an error immediately. This certainly
  5086. is not the most desirable solution; therefore, future versions will
  5087. provide better ones, but they are not yet finished.
  5088. If all input from the input buffer is successfully converted and
  5089. stored in the output buffer, the function returns the number of
  5090. non-reversible conversions performed. In all other cases the
  5091. return value is ‘(size_t) -1’ and ‘errno’ is set appropriately. In
  5092. such cases the value pointed to by INBYTESLEFT is nonzero.
  5093. ‘EILSEQ’
  5094. The conversion stopped because of an invalid byte sequence in
  5095. the input. After the call, ‘*INBUF’ points at the first byte
  5096. of the invalid byte sequence.
  5097. ‘E2BIG’
  5098. The conversion stopped because it ran out of space in the
  5099. output buffer.
  5100. ‘EINVAL’
  5101. The conversion stopped because of an incomplete byte sequence
  5102. at the end of the input buffer.
  5103. ‘EBADF’
  5104. The CD argument is invalid.
  5105. The ‘iconv’ function was introduced in the XPG2 standard and is
  5106. declared in the ‘iconv.h’ header.
  5107. The definition of the ‘iconv’ function is quite good overall. It
  5108. provides quite flexible functionality. The only problems lie in the
  5109. boundary cases, which are incomplete byte sequences at the end of the
  5110. input buffer and invalid input. A third problem, which is not really a
  5111. design problem, is the way conversions are selected. The standard does
  5112. not say anything about the legitimate names, a minimal set of available
  5113. conversions. We will see how this negatively impacts other
  5114. implementations, as demonstrated below.
  5115. 
  5116. File: libc.info, Node: iconv Examples, Next: Other iconv Implementations, Prev: Generic Conversion Interface, Up: Generic Charset Conversion
  5117. 6.5.2 A complete ‘iconv’ example
  5118. --------------------------------
  5119. The example below features a solution for a common problem. Given that
  5120. one knows the internal encoding used by the system for ‘wchar_t’
  5121. strings, one often is in the position to read text from a file and store
  5122. it in wide character buffers. One can do this using ‘mbsrtowcs’, but
  5123. then we run into the problems discussed above.
  5124. int
  5125. file2wcs (int fd, const char *charset, wchar_t *outbuf, size_t avail)
  5126. {
  5127. char inbuf[BUFSIZ];
  5128. size_t insize = 0;
  5129. char *wrptr = (char *) outbuf;
  5130. int result = 0;
  5131. iconv_t cd;
  5132. cd = iconv_open ("WCHAR_T", charset);
  5133. if (cd == (iconv_t) -1)
  5134. {
  5135. /* Something went wrong. */
  5136. if (errno == EINVAL)
  5137. error (0, 0, "conversion from '%s' to wchar_t not available",
  5138. charset);
  5139. else
  5140. perror ("iconv_open");
  5141. /* Terminate the output string. */
  5142. *outbuf = L'\0';
  5143. return -1;
  5144. }
  5145. while (avail > 0)
  5146. {
  5147. size_t nread;
  5148. size_t nconv;
  5149. char *inptr = inbuf;
  5150. /* Read more input. */
  5151. nread = read (fd, inbuf + insize, sizeof (inbuf) - insize);
  5152. if (nread == 0)
  5153. {
  5154. /* When we come here the file is completely read.
  5155. This still could mean there are some unused
  5156. characters in the ‘inbuf’. Put them back. */
  5157. if (lseek (fd, -insize, SEEK_CUR) == -1)
  5158. result = -1;
  5159. /* Now write out the byte sequence to get into the
  5160. initial state if this is necessary. */
  5161. iconv (cd, NULL, NULL, &wrptr, &avail);
  5162. break;
  5163. }
  5164. insize += nread;
  5165. /* Do the conversion. */
  5166. nconv = iconv (cd, &inptr, &insize, &wrptr, &avail);
  5167. if (nconv == (size_t) -1)
  5168. {
  5169. /* Not everything went right. It might only be
  5170. an unfinished byte sequence at the end of the
  5171. buffer. Or it is a real problem. */
  5172. if (errno == EINVAL)
  5173. /* This is harmless. Simply move the unused
  5174. bytes to the beginning of the buffer so that
  5175. they can be used in the next round. */
  5176. memmove (inbuf, inptr, insize);
  5177. else
  5178. {
  5179. /* It is a real problem. Maybe we ran out of
  5180. space in the output buffer or we have invalid
  5181. input. In any case back the file pointer to
  5182. the position of the last processed byte. */
  5183. lseek (fd, -insize, SEEK_CUR);
  5184. result = -1;
  5185. break;
  5186. }
  5187. }
  5188. }
  5189. /* Terminate the output string. */
  5190. if (avail >= sizeof (wchar_t))
  5191. *((wchar_t *) wrptr) = L'\0';
  5192. if (iconv_close (cd) != 0)
  5193. perror ("iconv_close");
  5194. return (wchar_t *) wrptr - outbuf;
  5195. }
  5196. This example shows the most important aspects of using the ‘iconv’
  5197. functions. It shows how successive calls to ‘iconv’ can be used to
  5198. convert large amounts of text. The user does not have to care about
  5199. stateful encodings as the functions take care of everything.
  5200. An interesting point is the case where ‘iconv’ returns an error and
  5201. ‘errno’ is set to ‘EINVAL’. This is not really an error in the
  5202. transformation. It can happen whenever the input character set contains
  5203. byte sequences of more than one byte for some character and texts are
  5204. not processed in one piece. In this case there is a chance that a
  5205. multibyte sequence is cut. The caller can then simply read the
  5206. remainder of the takes and feed the offending bytes together with new
  5207. character from the input to ‘iconv’ and continue the work. The internal
  5208. state kept in the descriptor is _not_ unspecified after such an event as
  5209. is the case with the conversion functions from the ISO C standard.
  5210. The example also shows the problem of using wide character strings
  5211. with ‘iconv’. As explained in the description of the ‘iconv’ function
  5212. above, the function always takes a pointer to a ‘char’ array and the
  5213. available space is measured in bytes. In the example, the output buffer
  5214. is a wide character buffer; therefore, we use a local variable WRPTR of
  5215. type ‘char *’, which is used in the ‘iconv’ calls.
  5216. This looks rather innocent but can lead to problems on platforms that
  5217. have tight restriction on alignment. Therefore the caller of ‘iconv’
  5218. has to make sure that the pointers passed are suitable for access of
  5219. characters from the appropriate character set. Since, in the above
  5220. case, the input parameter to the function is a ‘wchar_t’ pointer, this
  5221. is the case (unless the user violates alignment when computing the
  5222. parameter). But in other situations, especially when writing generic
  5223. functions where one does not know what type of character set one uses
  5224. and, therefore, treats text as a sequence of bytes, it might become
  5225. tricky.
  5226. 
  5227. File: libc.info, Node: Other iconv Implementations, Next: glibc iconv Implementation, Prev: iconv Examples, Up: Generic Charset Conversion
  5228. 6.5.3 Some Details about other ‘iconv’ Implementations
  5229. ------------------------------------------------------
  5230. This is not really the place to discuss the ‘iconv’ implementation of
  5231. other systems but it is necessary to know a bit about them to write
  5232. portable programs. The above mentioned problems with the specification
  5233. of the ‘iconv’ functions can lead to portability issues.
  5234. The first thing to notice is that, due to the large number of
  5235. character sets in use, it is certainly not practical to encode the
  5236. conversions directly in the C library. Therefore, the conversion
  5237. information must come from files outside the C library. This is usually
  5238. done in one or both of the following ways:
  5239. • The C library contains a set of generic conversion functions that
  5240. can read the needed conversion tables and other information from
  5241. data files. These files get loaded when necessary.
  5242. This solution is problematic as it requires a great deal of effort
  5243. to apply to all character sets (potentially an infinite set). The
  5244. differences in the structure of the different character sets is so
  5245. large that many different variants of the table-processing
  5246. functions must be developed. In addition, the generic nature of
  5247. these functions make them slower than specifically implemented
  5248. functions.
  5249. • The C library only contains a framework that can dynamically load
  5250. object files and execute the conversion functions contained
  5251. therein.
  5252. This solution provides much more flexibility. The C library itself
  5253. contains only very little code and therefore reduces the general
  5254. memory footprint. Also, with a documented interface between the C
  5255. library and the loadable modules it is possible for third parties
  5256. to extend the set of available conversion modules. A drawback of
  5257. this solution is that dynamic loading must be available.
  5258. Some implementations in commercial Unices implement a mixture of
  5259. these possibilities; the majority implement only the second solution.
  5260. Using loadable modules moves the code out of the library itself and
  5261. keeps the door open for extensions and improvements, but this design is
  5262. also limiting on some platforms since not many platforms support dynamic
  5263. loading in statically linked programs. On platforms without this
  5264. capability it is therefore not possible to use this interface in
  5265. statically linked programs. The GNU C Library has, on ELF platforms, no
  5266. problems with dynamic loading in these situations; therefore, this point
  5267. is moot. The danger is that one gets acquainted with this situation and
  5268. forgets about the restrictions on other systems.
  5269. A second thing to know about other ‘iconv’ implementations is that
  5270. the number of available conversions is often very limited. Some
  5271. implementations provide, in the standard release (not special
  5272. international or developer releases), at most 100 to 200 conversion
  5273. possibilities. This does not mean 200 different character sets are
  5274. supported; for example, conversions from one character set to a set of
  5275. 10 others might count as 10 conversions. Together with the other
  5276. direction this makes 20 conversion possibilities used up by one
  5277. character set. One can imagine the thin coverage these platforms
  5278. provide. Some Unix vendors even provide only a handful of conversions,
  5279. which renders them useless for almost all uses.
  5280. This directly leads to a third and probably the most problematic
  5281. point. The way the ‘iconv’ conversion functions are implemented on all
  5282. known Unix systems and the availability of the conversion functions from
  5283. character set A to B and the conversion from B to C does _not_ imply
  5284. that the conversion from A to C is available.
  5285. This might not seem unreasonable and problematic at first, but it is
  5286. a quite big problem as one will notice shortly after hitting it. To
  5287. show the problem we assume to write a program that has to convert from A
  5288. to C. A call like
  5289. cd = iconv_open ("C", "A");
  5290. fails according to the assumption above. But what does the program do
  5291. now? The conversion is necessary; therefore, simply giving up is not an
  5292. option.
  5293. This is a nuisance. The ‘iconv’ function should take care of this.
  5294. But how should the program proceed from here on? If it tries to convert
  5295. to character set B, first the two ‘iconv_open’ calls
  5296. cd1 = iconv_open ("B", "A");
  5297. and
  5298. cd2 = iconv_open ("C", "B");
  5299. will succeed, but how to find B?
  5300. Unfortunately, the answer is: there is no general solution. On some
  5301. systems guessing might help. On those systems most character sets can
  5302. convert to and from UTF-8 encoded ISO 10646 or Unicode text. Besides
  5303. this only some very system-specific methods can help. Since the
  5304. conversion functions come from loadable modules and these modules must
  5305. be stored somewhere in the filesystem, one _could_ try to find them and
  5306. determine from the available file which conversions are available and
  5307. whether there is an indirect route from A to C.
  5308. This example shows one of the design errors of ‘iconv’ mentioned
  5309. above. It should at least be possible to determine the list of
  5310. available conversions programmatically so that if ‘iconv_open’ says
  5311. there is no such conversion, one could make sure this also is true for
  5312. indirect routes.
  5313. 
  5314. File: libc.info, Node: glibc iconv Implementation, Prev: Other iconv Implementations, Up: Generic Charset Conversion
  5315. 6.5.4 The ‘iconv’ Implementation in the GNU C Library
  5316. -----------------------------------------------------
  5317. After reading about the problems of ‘iconv’ implementations in the last
  5318. section it is certainly good to note that the implementation in the GNU
  5319. C Library has none of the problems mentioned above. What follows is a
  5320. step-by-step analysis of the points raised above. The evaluation is
  5321. based on the current state of the development (as of January 1999). The
  5322. development of the ‘iconv’ functions is not complete, but basic
  5323. functionality has solidified.
  5324. The GNU C Library's ‘iconv’ implementation uses shared loadable
  5325. modules to implement the conversions. A very small number of
  5326. conversions are built into the library itself but these are only rather
  5327. trivial conversions.
  5328. All the benefits of loadable modules are available in the GNU C
  5329. Library implementation. This is especially appealing since the
  5330. interface is well documented (see below), and it, therefore, is easy to
  5331. write new conversion modules. The drawback of using loadable objects is
  5332. not a problem in the GNU C Library, at least on ELF systems. Since the
  5333. library is able to load shared objects even in statically linked
  5334. binaries, static linking need not be forbidden in case one wants to use
  5335. ‘iconv’.
  5336. The second mentioned problem is the number of supported conversions.
  5337. Currently, the GNU C Library supports more than 150 character sets. The
  5338. way the implementation is designed the number of supported conversions
  5339. is greater than 22350 (150 times 149). If any conversion from or to a
  5340. character set is missing, it can be added easily.
  5341. Particularly impressive as it may be, this high number is due to the
  5342. fact that the GNU C Library implementation of ‘iconv’ does not have the
  5343. third problem mentioned above (i.e., whenever there is a conversion from
  5344. a character set A to B and from B to C it is always possible to convert
  5345. from A to C directly). If the ‘iconv_open’ returns an error and sets
  5346. ‘errno’ to ‘EINVAL’, there is no known way, directly or indirectly, to
  5347. perform the wanted conversion.
  5348. Triangulation is achieved by providing for each character set a
  5349. conversion from and to UCS-4 encoded ISO 10646. Using ISO 10646 as an
  5350. intermediate representation it is possible to “triangulate” (i.e.,
  5351. convert with an intermediate representation).
  5352. There is no inherent requirement to provide a conversion to ISO 10646
  5353. for a new character set, and it is also possible to provide other
  5354. conversions where neither source nor destination character set is
  5355. ISO 10646. The existing set of conversions is simply meant to cover all
  5356. conversions that might be of interest.
  5357. All currently available conversions use the triangulation method
  5358. above, making conversion run unnecessarily slow. If, for example,
  5359. somebody often needs the conversion from ISO-2022-JP to EUC-JP, a
  5360. quicker solution would involve direct conversion between the two
  5361. character sets, skipping the input to ISO 10646 first. The two
  5362. character sets of interest are much more similar to each other than to
  5363. ISO 10646.
  5364. In such a situation one easily can write a new conversion and provide
  5365. it as a better alternative. The GNU C Library ‘iconv’ implementation
  5366. would automatically use the module implementing the conversion if it is
  5367. specified to be more efficient.
  5368. 6.5.4.1 Format of ‘gconv-modules’ files
  5369. .......................................
  5370. All information about the available conversions comes from a file named
  5371. ‘gconv-modules’, which can be found in any of the directories along the
  5372. ‘GCONV_PATH’. The ‘gconv-modules’ files are line-oriented text files,
  5373. where each of the lines has one of the following formats:
  5374. • If the first non-whitespace character is a ‘#’ the line contains
  5375. only comments and is ignored.
  5376. • Lines starting with ‘alias’ define an alias name for a character
  5377. set. Two more words are expected on the line. The first word
  5378. defines the alias name, and the second defines the original name of
  5379. the character set. The effect is that it is possible to use the
  5380. alias name in the FROMSET or TOSET parameters of ‘iconv_open’ and
  5381. achieve the same result as when using the real character set name.
  5382. This is quite important as a character set has often many different
  5383. names. There is normally an official name but this need not
  5384. correspond to the most popular name. Besides this many character
  5385. sets have special names that are somehow constructed. For example,
  5386. all character sets specified by the ISO have an alias of the form
  5387. ‘ISO-IR-NNN’ where NNN is the registration number. This allows
  5388. programs that know about the registration number to construct
  5389. character set names and use them in ‘iconv_open’ calls. More on
  5390. the available names and aliases follows below.
  5391. • Lines starting with ‘module’ introduce an available conversion
  5392. module. These lines must contain three or four more words.
  5393. The first word specifies the source character set, the second word
  5394. the destination character set of conversion implemented in this
  5395. module, and the third word is the name of the loadable module. The
  5396. filename is constructed by appending the usual shared object suffix
  5397. (normally ‘.so’) and this file is then supposed to be found in the
  5398. same directory the ‘gconv-modules’ file is in. The last word on
  5399. the line, which is optional, is a numeric value representing the
  5400. cost of the conversion. If this word is missing, a cost of 1 is
  5401. assumed. The numeric value itself does not matter that much; what
  5402. counts are the relative values of the sums of costs for all
  5403. possible conversion paths. Below is a more precise description of
  5404. the use of the cost value.
  5405. Returning to the example above where one has written a module to
  5406. directly convert from ISO-2022-JP to EUC-JP and back. All that has to
  5407. be done is to put the new module, let its name be ISO2022JP-EUCJP.so, in
  5408. a directory and add a file ‘gconv-modules’ with the following content in
  5409. the same directory:
  5410. module ISO-2022-JP// EUC-JP// ISO2022JP-EUCJP 1
  5411. module EUC-JP// ISO-2022-JP// ISO2022JP-EUCJP 1
  5412. To see why this is sufficient, it is necessary to understand how the
  5413. conversion used by ‘iconv’ (and described in the descriptor) is
  5414. selected. The approach to this problem is quite simple.
  5415. At the first call of the ‘iconv_open’ function the program reads all
  5416. available ‘gconv-modules’ files and builds up two tables: one containing
  5417. all the known aliases and another that contains the information about
  5418. the conversions and which shared object implements them.
  5419. 6.5.4.2 Finding the conversion path in ‘iconv’
  5420. ..............................................
  5421. The set of available conversions form a directed graph with weighted
  5422. edges. The weights on the edges are the costs specified in the
  5423. ‘gconv-modules’ files. The ‘iconv_open’ function uses an algorithm
  5424. suitable for search for the best path in such a graph and so constructs
  5425. a list of conversions that must be performed in succession to get the
  5426. transformation from the source to the destination character set.
  5427. Explaining why the above ‘gconv-modules’ files allows the ‘iconv’
  5428. implementation to resolve the specific ISO-2022-JP to EUC-JP conversion
  5429. module instead of the conversion coming with the library itself is
  5430. straightforward. Since the latter conversion takes two steps (from
  5431. ISO-2022-JP to ISO 10646 and then from ISO 10646 to EUC-JP), the cost is
  5432. 1+1 = 2. The above ‘gconv-modules’ file, however, specifies that the
  5433. new conversion modules can perform this conversion with only the cost of
  5434. 1.
  5435. A mysterious item about the ‘gconv-modules’ file above (and also the
  5436. file coming with the GNU C Library) are the names of the character sets
  5437. specified in the ‘module’ lines. Why do almost all the names end in
  5438. ‘//’? And this is not all: the names can actually be regular
  5439. expressions. At this point in time this mystery should not be revealed,
  5440. unless you have the relevant spell-casting materials: ashes from an
  5441. original DOS 6.2 boot disk burnt in effigy, a crucifix blessed by St.
  5442. Emacs, assorted herbal roots from Central America, sand from Cebu, etc.
  5443. Sorry! *The part of the implementation where this is used is not yet
  5444. finished. For now please simply follow the existing examples. It'll
  5445. become clearer once it is. -drepper*
  5446. A last remark about the ‘gconv-modules’ is about the names not ending
  5447. with ‘//’. A character set named ‘INTERNAL’ is often mentioned. From
  5448. the discussion above and the chosen name it should have become clear
  5449. that this is the name for the representation used in the intermediate
  5450. step of the triangulation. We have said that this is UCS-4 but actually
  5451. that is not quite right. The UCS-4 specification also includes the
  5452. specification of the byte ordering used. Since a UCS-4 value consists
  5453. of four bytes, a stored value is affected by byte ordering. The
  5454. internal representation is _not_ the same as UCS-4 in case the byte
  5455. ordering of the processor (or at least the running process) is not the
  5456. same as the one required for UCS-4. This is done for performance
  5457. reasons as one does not want to perform unnecessary byte-swapping
  5458. operations if one is not interested in actually seeing the result in
  5459. UCS-4. To avoid trouble with endianness, the internal representation
  5460. consistently is named ‘INTERNAL’ even on big-endian systems where the
  5461. representations are identical.
  5462. 6.5.4.3 ‘iconv’ module data structures
  5463. ......................................
  5464. So far this section has described how modules are located and considered
  5465. to be used. What remains to be described is the interface of the
  5466. modules so that one can write new ones. This section describes the
  5467. interface as it is in use in January 1999. The interface will change a
  5468. bit in the future but, with luck, only in an upwardly compatible way.
  5469. The definitions necessary to write new modules are publicly available
  5470. in the non-standard header ‘gconv.h’. The following text, therefore,
  5471. describes the definitions from this header file. First, however, it is
  5472. necessary to get an overview.
  5473. From the perspective of the user of ‘iconv’ the interface is quite
  5474. simple: the ‘iconv_open’ function returns a handle that can be used in
  5475. calls to ‘iconv’, and finally the handle is freed with a call to
  5476. ‘iconv_close’. The problem is that the handle has to be able to
  5477. represent the possibly long sequences of conversion steps and also the
  5478. state of each conversion since the handle is all that is passed to the
  5479. ‘iconv’ function. Therefore, the data structures are really the
  5480. elements necessary to understanding the implementation.
  5481. We need two different kinds of data structures. The first describes
  5482. the conversion and the second describes the state etc. There are really
  5483. two type definitions like this in ‘gconv.h’.
  5484. -- Data type: struct __gconv_step
  5485. This data structure describes one conversion a module can perform.
  5486. For each function in a loaded module with conversion functions
  5487. there is exactly one object of this type. This object is shared by
  5488. all users of the conversion (i.e., this object does not contain any
  5489. information corresponding to an actual conversion; it only
  5490. describes the conversion itself).
  5491. ‘struct __gconv_loaded_object *__shlib_handle’
  5492. ‘const char *__modname’
  5493. ‘int __counter’
  5494. All these elements of the structure are used internally in the
  5495. C library to coordinate loading and unloading the shared
  5496. object. One must not expect any of the other elements to be
  5497. available or initialized.
  5498. ‘const char *__from_name’
  5499. ‘const char *__to_name’
  5500. ‘__from_name’ and ‘__to_name’ contain the names of the source
  5501. and destination character sets. They can be used to identify
  5502. the actual conversion to be carried out since one module might
  5503. implement conversions for more than one character set and/or
  5504. direction.
  5505. ‘gconv_fct __fct’
  5506. ‘gconv_init_fct __init_fct’
  5507. ‘gconv_end_fct __end_fct’
  5508. These elements contain pointers to the functions in the
  5509. loadable module. The interface will be explained below.
  5510. ‘int __min_needed_from’
  5511. ‘int __max_needed_from’
  5512. ‘int __min_needed_to’
  5513. ‘int __max_needed_to;’
  5514. These values have to be supplied in the init function of the
  5515. module. The ‘__min_needed_from’ value specifies how many
  5516. bytes a character of the source character set at least needs.
  5517. The ‘__max_needed_from’ specifies the maximum value that also
  5518. includes possible shift sequences.
  5519. The ‘__min_needed_to’ and ‘__max_needed_to’ values serve the
  5520. same purpose as ‘__min_needed_from’ and ‘__max_needed_from’
  5521. but this time for the destination character set.
  5522. It is crucial that these values be accurate since otherwise
  5523. the conversion functions will have problems or not work at
  5524. all.
  5525. ‘int __stateful’
  5526. This element must also be initialized by the init function.
  5527. ‘int __stateful’ is nonzero if the source character set is
  5528. stateful. Otherwise it is zero.
  5529. ‘void *__data’
  5530. This element can be used freely by the conversion functions in
  5531. the module. ‘void *__data’ can be used to communicate extra
  5532. information from one call to another. ‘void *__data’ need not
  5533. be initialized if not needed at all. If ‘void *__data’
  5534. element is assigned a pointer to dynamically allocated memory
  5535. (presumably in the init function) it has to be made sure that
  5536. the end function deallocates the memory. Otherwise the
  5537. application will leak memory.
  5538. It is important to be aware that this data structure is shared
  5539. by all users of this specification conversion and therefore
  5540. the ‘__data’ element must not contain data specific to one
  5541. specific use of the conversion function.
  5542. -- Data type: struct __gconv_step_data
  5543. This is the data structure that contains the information specific
  5544. to each use of the conversion functions.
  5545. ‘char *__outbuf’
  5546. ‘char *__outbufend’
  5547. These elements specify the output buffer for the conversion
  5548. step. The ‘__outbuf’ element points to the beginning of the
  5549. buffer, and ‘__outbufend’ points to the byte following the
  5550. last byte in the buffer. The conversion function must not
  5551. assume anything about the size of the buffer but it can be
  5552. safely assumed there is room for at least one complete
  5553. character in the output buffer.
  5554. Once the conversion is finished, if the conversion is the last
  5555. step, the ‘__outbuf’ element must be modified to point after
  5556. the last byte written into the buffer to signal how much
  5557. output is available. If this conversion step is not the last
  5558. one, the element must not be modified. The ‘__outbufend’
  5559. element must not be modified.
  5560. ‘int __flags’
  5561. This field is a set of flags. The ‘__GCONV_IS_LAST’ bit is
  5562. set if this conversion step is the last one. This information
  5563. is necessary for the recursion. See the description of the
  5564. conversion function internals below. This element must never
  5565. be modified.
  5566. ‘int __invocation_counter’
  5567. The conversion function can use this element to see how many
  5568. calls of the conversion function already happened. Some
  5569. character sets require a certain prolog when generating
  5570. output, and by comparing this value with zero, one can find
  5571. out whether it is the first call and whether, therefore, the
  5572. prolog should be emitted. This element must never be
  5573. modified.
  5574. ‘int __internal_use’
  5575. This element is another one rarely used but needed in certain
  5576. situations. It is assigned a nonzero value in case the
  5577. conversion functions are used to implement ‘mbsrtowcs’ et.al.
  5578. (i.e., the function is not used directly through the ‘iconv’
  5579. interface).
  5580. This sometimes makes a difference as it is expected that the
  5581. ‘iconv’ functions are used to translate entire texts while the
  5582. ‘mbsrtowcs’ functions are normally used only to convert single
  5583. strings and might be used multiple times to convert entire
  5584. texts.
  5585. But in this situation we would have problem complying with
  5586. some rules of the character set specification. Some character
  5587. sets require a prolog, which must appear exactly once for an
  5588. entire text. If a number of ‘mbsrtowcs’ calls are used to
  5589. convert the text, only the first call must add the prolog.
  5590. However, because there is no communication between the
  5591. different calls of ‘mbsrtowcs’, the conversion functions have
  5592. no possibility to find this out. The situation is different
  5593. for sequences of ‘iconv’ calls since the handle allows access
  5594. to the needed information.
  5595. The ‘int __internal_use’ element is mostly used together with
  5596. ‘__invocation_counter’ as follows:
  5597. if (!data->__internal_use
  5598. && data->__invocation_counter == 0)
  5599. /* Emit prolog. */
  5600. ...
  5601. This element must never be modified.
  5602. ‘mbstate_t *__statep’
  5603. The ‘__statep’ element points to an object of type ‘mbstate_t’
  5604. (*note Keeping the state::). The conversion of a stateful
  5605. character set must use the object pointed to by ‘__statep’ to
  5606. store information about the conversion state. The ‘__statep’
  5607. element itself must never be modified.
  5608. ‘mbstate_t __state’
  5609. This element must _never_ be used directly. It is only part
  5610. of this structure to have the needed space allocated.
  5611. 6.5.4.4 ‘iconv’ module interfaces
  5612. .................................
  5613. With the knowledge about the data structures we now can describe the
  5614. conversion function itself. To understand the interface a bit of
  5615. knowledge is necessary about the functionality in the C library that
  5616. loads the objects with the conversions.
  5617. It is often the case that one conversion is used more than once
  5618. (i.e., there are several ‘iconv_open’ calls for the same set of
  5619. character sets during one program run). The ‘mbsrtowcs’ et.al.
  5620. functions in the GNU C Library also use the ‘iconv’ functionality, which
  5621. increases the number of uses of the same functions even more.
  5622. Because of this multiple use of conversions, the modules do not get
  5623. loaded exclusively for one conversion. Instead a module once loaded can
  5624. be used by an arbitrary number of ‘iconv’ or ‘mbsrtowcs’ calls at the
  5625. same time. The splitting of the information between conversion-
  5626. function-specific information and conversion data makes this possible.
  5627. The last section showed the two data structures used to do this.
  5628. This is of course also reflected in the interface and semantics of
  5629. the functions that the modules must provide. There are three functions
  5630. that must have the following names:
  5631. ‘gconv_init’
  5632. The ‘gconv_init’ function initializes the conversion function
  5633. specific data structure. This very same object is shared by all
  5634. conversions that use this conversion and, therefore, no state
  5635. information about the conversion itself must be stored in here. If
  5636. a module implements more than one conversion, the ‘gconv_init’
  5637. function will be called multiple times.
  5638. ‘gconv_end’
  5639. The ‘gconv_end’ function is responsible for freeing all resources
  5640. allocated by the ‘gconv_init’ function. If there is nothing to do,
  5641. this function can be missing. Special care must be taken if the
  5642. module implements more than one conversion and the ‘gconv_init’
  5643. function does not allocate the same resources for all conversions.
  5644. ‘gconv’
  5645. This is the actual conversion function. It is called to convert
  5646. one block of text. It gets passed the conversion step information
  5647. initialized by ‘gconv_init’ and the conversion data, specific to
  5648. this use of the conversion functions.
  5649. There are three data types defined for the three module interface
  5650. functions and these define the interface.
  5651. -- Data type: int (*__gconv_init_fct) (struct __gconv_step *)
  5652. This specifies the interface of the initialization function of the
  5653. module. It is called exactly once for each conversion the module
  5654. implements.
  5655. As explained in the description of the ‘struct __gconv_step’ data
  5656. structure above the initialization function has to initialize parts
  5657. of it.
  5658. ‘__min_needed_from’
  5659. ‘__max_needed_from’
  5660. ‘__min_needed_to’
  5661. ‘__max_needed_to’
  5662. These elements must be initialized to the exact numbers of the
  5663. minimum and maximum number of bytes used by one character in
  5664. the source and destination character sets, respectively. If
  5665. the characters all have the same size, the minimum and maximum
  5666. values are the same.
  5667. ‘__stateful’
  5668. This element must be initialized to a nonzero value if the
  5669. source character set is stateful. Otherwise it must be zero.
  5670. If the initialization function needs to communicate some
  5671. information to the conversion function, this communication can
  5672. happen using the ‘__data’ element of the ‘__gconv_step’ structure.
  5673. But since this data is shared by all the conversions, it must not
  5674. be modified by the conversion function. The example below shows
  5675. how this can be used.
  5676. #define MIN_NEEDED_FROM 1
  5677. #define MAX_NEEDED_FROM 4
  5678. #define MIN_NEEDED_TO 4
  5679. #define MAX_NEEDED_TO 4
  5680. int
  5681. gconv_init (struct __gconv_step *step)
  5682. {
  5683. /* Determine which direction. */
  5684. struct iso2022jp_data *new_data;
  5685. enum direction dir = illegal_dir;
  5686. enum variant var = illegal_var;
  5687. int result;
  5688. if (__strcasecmp (step->__from_name, "ISO-2022-JP//") == 0)
  5689. {
  5690. dir = from_iso2022jp;
  5691. var = iso2022jp;
  5692. }
  5693. else if (__strcasecmp (step->__to_name, "ISO-2022-JP//") == 0)
  5694. {
  5695. dir = to_iso2022jp;
  5696. var = iso2022jp;
  5697. }
  5698. else if (__strcasecmp (step->__from_name, "ISO-2022-JP-2//") == 0)
  5699. {
  5700. dir = from_iso2022jp;
  5701. var = iso2022jp2;
  5702. }
  5703. else if (__strcasecmp (step->__to_name, "ISO-2022-JP-2//") == 0)
  5704. {
  5705. dir = to_iso2022jp;
  5706. var = iso2022jp2;
  5707. }
  5708. result = __GCONV_NOCONV;
  5709. if (dir != illegal_dir)
  5710. {
  5711. new_data = (struct iso2022jp_data *)
  5712. malloc (sizeof (struct iso2022jp_data));
  5713. result = __GCONV_NOMEM;
  5714. if (new_data != NULL)
  5715. {
  5716. new_data->dir = dir;
  5717. new_data->var = var;
  5718. step->__data = new_data;
  5719. if (dir == from_iso2022jp)
  5720. {
  5721. step->__min_needed_from = MIN_NEEDED_FROM;
  5722. step->__max_needed_from = MAX_NEEDED_FROM;
  5723. step->__min_needed_to = MIN_NEEDED_TO;
  5724. step->__max_needed_to = MAX_NEEDED_TO;
  5725. }
  5726. else
  5727. {
  5728. step->__min_needed_from = MIN_NEEDED_TO;
  5729. step->__max_needed_from = MAX_NEEDED_TO;
  5730. step->__min_needed_to = MIN_NEEDED_FROM;
  5731. step->__max_needed_to = MAX_NEEDED_FROM + 2;
  5732. }
  5733. /* Yes, this is a stateful encoding. */
  5734. step->__stateful = 1;
  5735. result = __GCONV_OK;
  5736. }
  5737. }
  5738. return result;
  5739. }
  5740. The function first checks which conversion is wanted. The module
  5741. from which this function is taken implements four different
  5742. conversions; which one is selected can be determined by comparing
  5743. the names. The comparison should always be done without paying
  5744. attention to the case.
  5745. Next, a data structure, which contains the necessary information
  5746. about which conversion is selected, is allocated. The data
  5747. structure ‘struct iso2022jp_data’ is locally defined since, outside
  5748. the module, this data is not used at all. Please note that if all
  5749. four conversions this module supports are requested there are four
  5750. data blocks.
  5751. One interesting thing is the initialization of the ‘__min_’ and
  5752. ‘__max_’ elements of the step data object. A single ISO-2022-JP
  5753. character can consist of one to four bytes. Therefore the
  5754. ‘MIN_NEEDED_FROM’ and ‘MAX_NEEDED_FROM’ macros are defined this
  5755. way. The output is always the ‘INTERNAL’ character set (aka UCS-4)
  5756. and therefore each character consists of exactly four bytes. For
  5757. the conversion from ‘INTERNAL’ to ISO-2022-JP we have to take into
  5758. account that escape sequences might be necessary to switch the
  5759. character sets. Therefore the ‘__max_needed_to’ element for this
  5760. direction gets assigned ‘MAX_NEEDED_FROM + 2’. This takes into
  5761. account the two bytes needed for the escape sequences to signal the
  5762. switching. The asymmetry in the maximum values for the two
  5763. directions can be explained easily: when reading ISO-2022-JP text,
  5764. escape sequences can be handled alone (i.e., it is not necessary to
  5765. process a real character since the effect of the escape sequence
  5766. can be recorded in the state information). The situation is
  5767. different for the other direction. Since it is in general not
  5768. known which character comes next, one cannot emit escape sequences
  5769. to change the state in advance. This means the escape sequences
  5770. have to be emitted together with the next character. Therefore one
  5771. needs more room than only for the character itself.
  5772. The possible return values of the initialization function are:
  5773. ‘__GCONV_OK’
  5774. The initialization succeeded
  5775. ‘__GCONV_NOCONV’
  5776. The requested conversion is not supported in the module. This
  5777. can happen if the ‘gconv-modules’ file has errors.
  5778. ‘__GCONV_NOMEM’
  5779. Memory required to store additional information could not be
  5780. allocated.
  5781. The function called before the module is unloaded is significantly
  5782. easier. It often has nothing at all to do; in which case it can be left
  5783. out completely.
  5784. -- Data type: void (*__gconv_end_fct) (struct gconv_step *)
  5785. The task of this function is to free all resources allocated in the
  5786. initialization function. Therefore only the ‘__data’ element of
  5787. the object pointed to by the argument is of interest. Continuing
  5788. the example from the initialization function, the finalization
  5789. function looks like this:
  5790. void
  5791. gconv_end (struct __gconv_step *data)
  5792. {
  5793. free (data->__data);
  5794. }
  5795. The most important function is the conversion function itself, which
  5796. can get quite complicated for complex character sets. But since this is
  5797. not of interest here, we will only describe a possible skeleton for the
  5798. conversion function.
  5799. -- Data type: int (*__gconv_fct) (struct __gconv_step *, struct
  5800. __gconv_step_data *, const char **, const char *, size_t *,
  5801. int)
  5802. The conversion function can be called for two basic reasons: to
  5803. convert text or to reset the state. From the description of the
  5804. ‘iconv’ function it can be seen why the flushing mode is necessary.
  5805. What mode is selected is determined by the sixth argument, an
  5806. integer. This argument being nonzero means that flushing is
  5807. selected.
  5808. Common to both modes is where the output buffer can be found. The
  5809. information about this buffer is stored in the conversion step
  5810. data. A pointer to this information is passed as the second
  5811. argument to this function. The description of the ‘struct
  5812. __gconv_step_data’ structure has more information on the conversion
  5813. step data.
  5814. What has to be done for flushing depends on the source character
  5815. set. If the source character set is not stateful, nothing has to
  5816. be done. Otherwise the function has to emit a byte sequence to
  5817. bring the state object into the initial state. Once this all
  5818. happened the other conversion modules in the chain of conversions
  5819. have to get the same chance. Whether another step follows can be
  5820. determined from the ‘__GCONV_IS_LAST’ flag in the ‘__flags’ field
  5821. of the step data structure to which the first parameter points.
  5822. The more interesting mode is when actual text has to be converted.
  5823. The first step in this case is to convert as much text as possible
  5824. from the input buffer and store the result in the output buffer.
  5825. The start of the input buffer is determined by the third argument,
  5826. which is a pointer to a pointer variable referencing the beginning
  5827. of the buffer. The fourth argument is a pointer to the byte right
  5828. after the last byte in the buffer.
  5829. The conversion has to be performed according to the current state
  5830. if the character set is stateful. The state is stored in an object
  5831. pointed to by the ‘__statep’ element of the step data (second
  5832. argument). Once either the input buffer is empty or the output
  5833. buffer is full the conversion stops. At this point, the pointer
  5834. variable referenced by the third parameter must point to the byte
  5835. following the last processed byte (i.e., if all of the input is
  5836. consumed, this pointer and the fourth parameter have the same
  5837. value).
  5838. What now happens depends on whether this step is the last one. If
  5839. it is the last step, the only thing that has to be done is to
  5840. update the ‘__outbuf’ element of the step data structure to point
  5841. after the last written byte. This update gives the caller the
  5842. information on how much text is available in the output buffer. In
  5843. addition, the variable pointed to by the fifth parameter, which is
  5844. of type ‘size_t’, must be incremented by the number of characters
  5845. (_not bytes_) that were converted in a non-reversible way. Then,
  5846. the function can return.
  5847. In case the step is not the last one, the later conversion
  5848. functions have to get a chance to do their work. Therefore, the
  5849. appropriate conversion function has to be called. The information
  5850. about the functions is stored in the conversion data structures,
  5851. passed as the first parameter. This information and the step data
  5852. are stored in arrays, so the next element in both cases can be
  5853. found by simple pointer arithmetic:
  5854. int
  5855. gconv (struct __gconv_step *step, struct __gconv_step_data *data,
  5856. const char **inbuf, const char *inbufend, size_t *written,
  5857. int do_flush)
  5858. {
  5859. struct __gconv_step *next_step = step + 1;
  5860. struct __gconv_step_data *next_data = data + 1;
  5861. ...
  5862. The ‘next_step’ pointer references the next step information and
  5863. ‘next_data’ the next data record. The call of the next function
  5864. therefore will look similar to this:
  5865. next_step->__fct (next_step, next_data, &outerr, outbuf,
  5866. written, 0)
  5867. But this is not yet all. Once the function call returns the
  5868. conversion function might have some more to do. If the return
  5869. value of the function is ‘__GCONV_EMPTY_INPUT’, more room is
  5870. available in the output buffer. Unless the input buffer is empty,
  5871. the conversion functions start all over again and process the rest
  5872. of the input buffer. If the return value is not
  5873. ‘__GCONV_EMPTY_INPUT’, something went wrong and we have to recover
  5874. from this.
  5875. A requirement for the conversion function is that the input buffer
  5876. pointer (the third argument) always point to the last character
  5877. that was put in converted form into the output buffer. This is
  5878. trivially true after the conversion performed in the current step,
  5879. but if the conversion functions deeper downstream stop prematurely,
  5880. not all characters from the output buffer are consumed and,
  5881. therefore, the input buffer pointers must be backed off to the
  5882. right position.
  5883. Correcting the input buffers is easy to do if the input and output
  5884. character sets have a fixed width for all characters. In this
  5885. situation we can compute how many characters are left in the output
  5886. buffer and, therefore, can correct the input buffer pointer
  5887. appropriately with a similar computation. Things are getting
  5888. tricky if either character set has characters represented with
  5889. variable length byte sequences, and it gets even more complicated
  5890. if the conversion has to take care of the state. In these cases
  5891. the conversion has to be performed once again, from the known state
  5892. before the initial conversion (i.e., if necessary the state of the
  5893. conversion has to be reset and the conversion loop has to be
  5894. executed again). The difference now is that it is known how much
  5895. input must be created, and the conversion can stop before
  5896. converting the first unused character. Once this is done the input
  5897. buffer pointers must be updated again and the function can return.
  5898. One final thing should be mentioned. If it is necessary for the
  5899. conversion to know whether it is the first invocation (in case a
  5900. prolog has to be emitted), the conversion function should increment
  5901. the ‘__invocation_counter’ element of the step data structure just
  5902. before returning to the caller. See the description of the ‘struct
  5903. __gconv_step_data’ structure above for more information on how this
  5904. can be used.
  5905. The return value must be one of the following values:
  5906. ‘__GCONV_EMPTY_INPUT’
  5907. All input was consumed and there is room left in the output
  5908. buffer.
  5909. ‘__GCONV_FULL_OUTPUT’
  5910. No more room in the output buffer. In case this is not the
  5911. last step this value is propagated down from the call of the
  5912. next conversion function in the chain.
  5913. ‘__GCONV_INCOMPLETE_INPUT’
  5914. The input buffer is not entirely empty since it contains an
  5915. incomplete character sequence.
  5916. The following example provides a framework for a conversion
  5917. function. In case a new conversion has to be written the holes in
  5918. this implementation have to be filled and that is it.
  5919. int
  5920. gconv (struct __gconv_step *step, struct __gconv_step_data *data,
  5921. const char **inbuf, const char *inbufend, size_t *written,
  5922. int do_flush)
  5923. {
  5924. struct __gconv_step *next_step = step + 1;
  5925. struct __gconv_step_data *next_data = data + 1;
  5926. gconv_fct fct = next_step->__fct;
  5927. int status;
  5928. /* If the function is called with no input this means we have
  5929. to reset to the initial state. The possibly partly
  5930. converted input is dropped. */
  5931. if (do_flush)
  5932. {
  5933. status = __GCONV_OK;
  5934. /* Possible emit a byte sequence which put the state object
  5935. into the initial state. */
  5936. /* Call the steps down the chain if there are any but only
  5937. if we successfully emitted the escape sequence. */
  5938. if (status == __GCONV_OK && ! (data->__flags & __GCONV_IS_LAST))
  5939. status = fct (next_step, next_data, NULL, NULL,
  5940. written, 1);
  5941. }
  5942. else
  5943. {
  5944. /* We preserve the initial values of the pointer variables. */
  5945. const char *inptr = *inbuf;
  5946. char *outbuf = data->__outbuf;
  5947. char *outend = data->__outbufend;
  5948. char *outptr;
  5949. do
  5950. {
  5951. /* Remember the start value for this round. */
  5952. inptr = *inbuf;
  5953. /* The outbuf buffer is empty. */
  5954. outptr = outbuf;
  5955. /* For stateful encodings the state must be safe here. */
  5956. /* Run the conversion loop. ‘status’ is set
  5957. appropriately afterwards. */
  5958. /* If this is the last step, leave the loop. There is
  5959. nothing we can do. */
  5960. if (data->__flags & __GCONV_IS_LAST)
  5961. {
  5962. /* Store information about how many bytes are
  5963. available. */
  5964. data->__outbuf = outbuf;
  5965. /* If any non-reversible conversions were performed,
  5966. add the number to ‘*written’. */
  5967. break;
  5968. }
  5969. /* Write out all output that was produced. */
  5970. if (outbuf > outptr)
  5971. {
  5972. const char *outerr = data->__outbuf;
  5973. int result;
  5974. result = fct (next_step, next_data, &outerr,
  5975. outbuf, written, 0);
  5976. if (result != __GCONV_EMPTY_INPUT)
  5977. {
  5978. if (outerr != outbuf)
  5979. {
  5980. /* Reset the input buffer pointer. We
  5981. document here the complex case. */
  5982. size_t nstatus;
  5983. /* Reload the pointers. */
  5984. *inbuf = inptr;
  5985. outbuf = outptr;
  5986. /* Possibly reset the state. */
  5987. /* Redo the conversion, but this time
  5988. the end of the output buffer is at
  5989. ‘outerr’. */
  5990. }
  5991. /* Change the status. */
  5992. status = result;
  5993. }
  5994. else
  5995. /* All the output is consumed, we can make
  5996. another run if everything was ok. */
  5997. if (status == __GCONV_FULL_OUTPUT)
  5998. status = __GCONV_OK;
  5999. }
  6000. }
  6001. while (status == __GCONV_OK);
  6002. /* We finished one use of this step. */
  6003. ++data->__invocation_counter;
  6004. }
  6005. return status;
  6006. }
  6007. This information should be sufficient to write new modules. Anybody
  6008. doing so should also take a look at the available source code in the GNU
  6009. C Library sources. It contains many examples of working and optimized
  6010. modules.