libc.info-3 297 KB

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