libc.info-5 292 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246
  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: Character Input, Next: Line Input, Prev: Simple Output, Up: I/O on Streams
  2099. 12.8 Character Input
  2100. ====================
  2101. This section describes functions for performing character-oriented
  2102. input. These narrow stream functions are declared in the header file
  2103. ‘stdio.h’ and the wide character functions are declared in ‘wchar.h’.
  2104. These functions return an ‘int’ or ‘wint_t’ value (for narrow and
  2105. wide stream functions respectively) that is either a character of input,
  2106. or the special value ‘EOF’/‘WEOF’ (usually -1). For the narrow stream
  2107. functions it is important to store the result of these functions in a
  2108. variable of type ‘int’ instead of ‘char’, even when you plan to use it
  2109. only as a character. Storing ‘EOF’ in a ‘char’ variable truncates its
  2110. value to the size of a character, so that it is no longer
  2111. distinguishable from the valid character ‘(char) -1’. So always use an
  2112. ‘int’ for the result of ‘getc’ and friends, and check for ‘EOF’ after
  2113. the call; once you’ve verified that the result is not ‘EOF’, you can be
  2114. sure that it will fit in a ‘char’ variable without loss of information.
  2115. -- Function: int fgetc (FILE *STREAM)
  2116. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2117. | *Note POSIX Safety Concepts::.
  2118. This function reads the next character as an ‘unsigned char’ from
  2119. the stream STREAM and returns its value, converted to an ‘int’. If
  2120. an end-of-file condition or read error occurs, ‘EOF’ is returned
  2121. instead.
  2122. -- Function: wint_t fgetwc (FILE *STREAM)
  2123. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2124. | *Note POSIX Safety Concepts::.
  2125. This function reads the next wide character from the stream STREAM
  2126. and returns its value. If an end-of-file condition or read error
  2127. occurs, ‘WEOF’ is returned instead.
  2128. -- Function: int fgetc_unlocked (FILE *STREAM)
  2129. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  2130. corrupt | *Note POSIX Safety Concepts::.
  2131. The ‘fgetc_unlocked’ function is equivalent to the ‘fgetc’ function
  2132. except that it does not implicitly lock the stream.
  2133. -- Function: wint_t fgetwc_unlocked (FILE *STREAM)
  2134. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  2135. corrupt | *Note POSIX Safety Concepts::.
  2136. The ‘fgetwc_unlocked’ function is equivalent to the ‘fgetwc’
  2137. function except that it does not implicitly lock the stream.
  2138. This function is a GNU extension.
  2139. -- Function: int getc (FILE *STREAM)
  2140. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2141. | *Note POSIX Safety Concepts::.
  2142. This is just like ‘fgetc’, except that it is permissible (and
  2143. typical) for it to be implemented as a macro that evaluates the
  2144. STREAM argument more than once. ‘getc’ is often highly optimized,
  2145. so it is usually the best function to use to read a single
  2146. character.
  2147. -- Function: wint_t getwc (FILE *STREAM)
  2148. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2149. | *Note POSIX Safety Concepts::.
  2150. This is just like ‘fgetwc’, except that it is permissible for it to
  2151. be implemented as a macro that evaluates the STREAM argument more
  2152. than once. ‘getwc’ can be highly optimized, so it is usually the
  2153. best function to use to read a single wide character.
  2154. -- Function: int getc_unlocked (FILE *STREAM)
  2155. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  2156. corrupt | *Note POSIX Safety Concepts::.
  2157. The ‘getc_unlocked’ function is equivalent to the ‘getc’ function
  2158. except that it does not implicitly lock the stream.
  2159. -- Function: wint_t getwc_unlocked (FILE *STREAM)
  2160. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  2161. corrupt | *Note POSIX Safety Concepts::.
  2162. The ‘getwc_unlocked’ function is equivalent to the ‘getwc’ function
  2163. except that it does not implicitly lock the stream.
  2164. This function is a GNU extension.
  2165. -- Function: int getchar (void)
  2166. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2167. | *Note POSIX Safety Concepts::.
  2168. The ‘getchar’ function is equivalent to ‘getc’ with ‘stdin’ as the
  2169. value of the STREAM argument.
  2170. -- Function: wint_t getwchar (void)
  2171. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2172. | *Note POSIX Safety Concepts::.
  2173. The ‘getwchar’ function is equivalent to ‘getwc’ with ‘stdin’ as
  2174. the value of the STREAM argument.
  2175. -- Function: int getchar_unlocked (void)
  2176. Preliminary: | MT-Unsafe race:stdin | AS-Unsafe corrupt | AC-Unsafe
  2177. corrupt | *Note POSIX Safety Concepts::.
  2178. The ‘getchar_unlocked’ function is equivalent to the ‘getchar’
  2179. function except that it does not implicitly lock the stream.
  2180. -- Function: wint_t getwchar_unlocked (void)
  2181. Preliminary: | MT-Unsafe race:stdin | AS-Unsafe corrupt | AC-Unsafe
  2182. corrupt | *Note POSIX Safety Concepts::.
  2183. The ‘getwchar_unlocked’ function is equivalent to the ‘getwchar’
  2184. function except that it does not implicitly lock the stream.
  2185. This function is a GNU extension.
  2186. Here is an example of a function that does input using ‘fgetc’. It
  2187. would work just as well using ‘getc’ instead, or using ‘getchar ()’
  2188. instead of ‘fgetc (stdin)’. The code would also work the same for the
  2189. wide character stream functions.
  2190. int
  2191. y_or_n_p (const char *question)
  2192. {
  2193. fputs (question, stdout);
  2194. while (1)
  2195. {
  2196. int c, answer;
  2197. /* Write a space to separate answer from question. */
  2198. fputc (' ', stdout);
  2199. /* Read the first character of the line.
  2200. This should be the answer character, but might not be. */
  2201. c = tolower (fgetc (stdin));
  2202. answer = c;
  2203. /* Discard rest of input line. */
  2204. while (c != '\n' && c != EOF)
  2205. c = fgetc (stdin);
  2206. /* Obey the answer if it was valid. */
  2207. if (answer == 'y')
  2208. return 1;
  2209. if (answer == 'n')
  2210. return 0;
  2211. /* Answer was invalid: ask for valid answer. */
  2212. fputs ("Please answer y or n:", stdout);
  2213. }
  2214. }
  2215. -- Function: int getw (FILE *STREAM)
  2216. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2217. | *Note POSIX Safety Concepts::.
  2218. This function reads a word (that is, an ‘int’) from STREAM. It’s
  2219. provided for compatibility with SVID. We recommend you use ‘fread’
  2220. instead (*note Block Input/Output::). Unlike ‘getc’, any ‘int’
  2221. value could be a valid result. ‘getw’ returns ‘EOF’ when it
  2222. encounters end-of-file or an error, but there is no way to
  2223. distinguish this from an input word with value -1.
  2224. 
  2225. File: libc.info, Node: Line Input, Next: Unreading, Prev: Character Input, Up: I/O on Streams
  2226. 12.9 Line-Oriented Input
  2227. ========================
  2228. Since many programs interpret input on the basis of lines, it is
  2229. convenient to have functions to read a line of text from a stream.
  2230. Standard C has functions to do this, but they aren’t very safe: null
  2231. characters and even (for ‘gets’) long lines can confuse them. So the
  2232. GNU C Library provides the nonstandard ‘getline’ function that makes it
  2233. easy to read lines reliably.
  2234. Another GNU extension, ‘getdelim’, generalizes ‘getline’. It reads a
  2235. delimited record, defined as everything through the next occurrence of a
  2236. specified delimiter character.
  2237. All these functions are declared in ‘stdio.h’.
  2238. -- Function: ssize_t getline (char **LINEPTR, size_t *N, FILE *STREAM)
  2239. Preliminary: | MT-Safe | AS-Unsafe corrupt heap | AC-Unsafe lock
  2240. corrupt mem | *Note POSIX Safety Concepts::.
  2241. This function reads an entire line from STREAM, storing the text
  2242. (including the newline and a terminating null character) in a
  2243. buffer and storing the buffer address in ‘*LINEPTR’.
  2244. Before calling ‘getline’, you should place in ‘*LINEPTR’ the
  2245. address of a buffer ‘*N’ bytes long, allocated with ‘malloc’. If
  2246. this buffer is long enough to hold the line, ‘getline’ stores the
  2247. line in this buffer. Otherwise, ‘getline’ makes the buffer bigger
  2248. using ‘realloc’, storing the new buffer address back in ‘*LINEPTR’
  2249. and the increased size back in ‘*N’. *Note Unconstrained
  2250. Allocation::.
  2251. If you set ‘*LINEPTR’ to a null pointer, and ‘*N’ to zero, before
  2252. the call, then ‘getline’ allocates the initial buffer for you by
  2253. calling ‘malloc’. This buffer remains allocated even if ‘getline’
  2254. encounters errors and is unable to read any bytes.
  2255. In either case, when ‘getline’ returns, ‘*LINEPTR’ is a ‘char *’
  2256. which points to the text of the line.
  2257. When ‘getline’ is successful, it returns the number of characters
  2258. read (including the newline, but not including the terminating
  2259. null). This value enables you to distinguish null characters that
  2260. are part of the line from the null character inserted as a
  2261. terminator.
  2262. This function is a GNU extension, but it is the recommended way to
  2263. read lines from a stream. The alternative standard functions are
  2264. unreliable.
  2265. If an error occurs or end of file is reached without any bytes
  2266. read, ‘getline’ returns ‘-1’.
  2267. -- Function: ssize_t getdelim (char **LINEPTR, size_t *N, int
  2268. DELIMITER, FILE *STREAM)
  2269. Preliminary: | MT-Safe | AS-Unsafe corrupt heap | AC-Unsafe lock
  2270. corrupt mem | *Note POSIX Safety Concepts::.
  2271. This function is like ‘getline’ except that the character which
  2272. tells it to stop reading is not necessarily newline. The argument
  2273. DELIMITER specifies the delimiter character; ‘getdelim’ keeps
  2274. reading until it sees that character (or end of file).
  2275. The text is stored in LINEPTR, including the delimiter character
  2276. and a terminating null. Like ‘getline’, ‘getdelim’ makes LINEPTR
  2277. bigger if it isn’t big enough.
  2278. ‘getline’ is in fact implemented in terms of ‘getdelim’, just like
  2279. this:
  2280. ssize_t
  2281. getline (char **lineptr, size_t *n, FILE *stream)
  2282. {
  2283. return getdelim (lineptr, n, '\n', stream);
  2284. }
  2285. -- Function: char * fgets (char *S, int COUNT, FILE *STREAM)
  2286. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2287. | *Note POSIX Safety Concepts::.
  2288. The ‘fgets’ function reads characters from the stream STREAM up to
  2289. and including a newline character and stores them in the string S,
  2290. adding a null character to mark the end of the string. You must
  2291. supply COUNT characters worth of space in S, but the number of
  2292. characters read is at most COUNT − 1. The extra character space is
  2293. used to hold the null character at the end of the string.
  2294. If the system is already at end of file when you call ‘fgets’, then
  2295. the contents of the array S are unchanged and a null pointer is
  2296. returned. A null pointer is also returned if a read error occurs.
  2297. Otherwise, the return value is the pointer S.
  2298. *Warning:* If the input data has a null character, you can’t tell.
  2299. So don’t use ‘fgets’ unless you know the data cannot contain a
  2300. null. Don’t use it to read files edited by the user because, if
  2301. the user inserts a null character, you should either handle it
  2302. properly or print a clear error message. We recommend using
  2303. ‘getline’ instead of ‘fgets’.
  2304. -- Function: wchar_t * fgetws (wchar_t *WS, int COUNT, FILE *STREAM)
  2305. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2306. | *Note POSIX Safety Concepts::.
  2307. The ‘fgetws’ function reads wide characters from the stream STREAM
  2308. up to and including a newline character and stores them in the
  2309. string WS, adding a null wide character to mark the end of the
  2310. string. You must supply COUNT wide characters worth of space in
  2311. WS, but the number of characters read is at most COUNT − 1. The
  2312. extra character space is used to hold the null wide character at
  2313. the end of the string.
  2314. If the system is already at end of file when you call ‘fgetws’,
  2315. then the contents of the array WS are unchanged and a null pointer
  2316. is returned. A null pointer is also returned if a read error
  2317. occurs. Otherwise, the return value is the pointer WS.
  2318. *Warning:* If the input data has a null wide character (which are
  2319. null bytes in the input stream), you can’t tell. So don’t use
  2320. ‘fgetws’ unless you know the data cannot contain a null. Don’t use
  2321. it to read files edited by the user because, if the user inserts a
  2322. null character, you should either handle it properly or print a
  2323. clear error message.
  2324. -- Function: char * fgets_unlocked (char *S, int COUNT, FILE *STREAM)
  2325. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  2326. corrupt | *Note POSIX Safety Concepts::.
  2327. The ‘fgets_unlocked’ function is equivalent to the ‘fgets’ function
  2328. except that it does not implicitly lock the stream.
  2329. This function is a GNU extension.
  2330. -- Function: wchar_t * fgetws_unlocked (wchar_t *WS, int COUNT, FILE
  2331. *STREAM)
  2332. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  2333. corrupt | *Note POSIX Safety Concepts::.
  2334. The ‘fgetws_unlocked’ function is equivalent to the ‘fgetws’
  2335. function except that it does not implicitly lock the stream.
  2336. This function is a GNU extension.
  2337. -- Deprecated function: char * gets (char *S)
  2338. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2339. | *Note POSIX Safety Concepts::.
  2340. The function ‘gets’ reads characters from the stream ‘stdin’ up to
  2341. the next newline character, and stores them in the string S. The
  2342. newline character is discarded (note that this differs from the
  2343. behavior of ‘fgets’, which copies the newline character into the
  2344. string). If ‘gets’ encounters a read error or end-of-file, it
  2345. returns a null pointer; otherwise it returns S.
  2346. *Warning:* The ‘gets’ function is *very dangerous* because it
  2347. provides no protection against overflowing the string S. The GNU C
  2348. Library includes it for compatibility only. You should *always*
  2349. use ‘fgets’ or ‘getline’ instead. To remind you of this, the
  2350. linker (if using GNU ‘ld’) will issue a warning whenever you use
  2351. ‘gets’.
  2352. 
  2353. File: libc.info, Node: Unreading, Next: Block Input/Output, Prev: Line Input, Up: I/O on Streams
  2354. 12.10 Unreading
  2355. ===============
  2356. In parser programs it is often useful to examine the next character in
  2357. the input stream without removing it from the stream. This is called
  2358. “peeking ahead” at the input because your program gets a glimpse of the
  2359. input it will read next.
  2360. Using stream I/O, you can peek ahead at input by first reading it and
  2361. then “unreading” it (also called “pushing it back” on the stream).
  2362. Unreading a character makes it available to be input again from the
  2363. stream, by the next call to ‘fgetc’ or other input function on that
  2364. stream.
  2365. * Menu:
  2366. * Unreading Idea:: An explanation of unreading with pictures.
  2367. * How Unread:: How to call ‘ungetc’ to do unreading.
  2368. 
  2369. File: libc.info, Node: Unreading Idea, Next: How Unread, Up: Unreading
  2370. 12.10.1 What Unreading Means
  2371. ----------------------------
  2372. Here is a pictorial explanation of unreading. Suppose you have a stream
  2373. reading a file that contains just six characters, the letters ‘foobar’.
  2374. Suppose you have read three characters so far. The situation looks like
  2375. this:
  2376. f o o b a r
  2377. ^
  2378. so the next input character will be ‘b’.
  2379. If instead of reading ‘b’ you unread the letter ‘o’, you get a
  2380. situation like this:
  2381. f o o b a r
  2382. |
  2383. o--
  2384. ^
  2385. so that the next input characters will be ‘o’ and ‘b’.
  2386. If you unread ‘9’ instead of ‘o’, you get this situation:
  2387. f o o b a r
  2388. |
  2389. 9--
  2390. ^
  2391. so that the next input characters will be ‘9’ and ‘b’.
  2392. 
  2393. File: libc.info, Node: How Unread, Prev: Unreading Idea, Up: Unreading
  2394. 12.10.2 Using ‘ungetc’ To Do Unreading
  2395. --------------------------------------
  2396. The function to unread a character is called ‘ungetc’, because it
  2397. reverses the action of ‘getc’.
  2398. -- Function: int ungetc (int C, FILE *STREAM)
  2399. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2400. | *Note POSIX Safety Concepts::.
  2401. The ‘ungetc’ function pushes back the character C onto the input
  2402. stream STREAM. So the next input from STREAM will read C before
  2403. anything else.
  2404. If C is ‘EOF’, ‘ungetc’ does nothing and just returns ‘EOF’. This
  2405. lets you call ‘ungetc’ with the return value of ‘getc’ without
  2406. needing to check for an error from ‘getc’.
  2407. The character that you push back doesn’t have to be the same as the
  2408. last character that was actually read from the stream. In fact, it
  2409. isn’t necessary to actually read any characters from the stream
  2410. before unreading them with ‘ungetc’! But that is a strange way to
  2411. write a program; usually ‘ungetc’ is used only to unread a
  2412. character that was just read from the same stream. The GNU C
  2413. Library supports this even on files opened in binary mode, but
  2414. other systems might not.
  2415. The GNU C Library only supports one character of pushback—in other
  2416. words, it does not work to call ‘ungetc’ twice without doing input
  2417. in between. Other systems might let you push back multiple
  2418. characters; then reading from the stream retrieves the characters
  2419. in the reverse order that they were pushed.
  2420. Pushing back characters doesn’t alter the file; only the internal
  2421. buffering for the stream is affected. If a file positioning
  2422. function (such as ‘fseek’, ‘fseeko’ or ‘rewind’; *note File
  2423. Positioning::) is called, any pending pushed-back characters are
  2424. discarded.
  2425. Unreading a character on a stream that is at end of file clears the
  2426. end-of-file indicator for the stream, because it makes the
  2427. character of input available. After you read that character,
  2428. trying to read again will encounter end of file.
  2429. -- Function: wint_t ungetwc (wint_t WC, FILE *STREAM)
  2430. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2431. | *Note POSIX Safety Concepts::.
  2432. The ‘ungetwc’ function behaves just like ‘ungetc’ just that it
  2433. pushes back a wide character.
  2434. Here is an example showing the use of ‘getc’ and ‘ungetc’ to skip
  2435. over whitespace characters. When this function reaches a non-whitespace
  2436. character, it unreads that character to be seen again on the next read
  2437. operation on the stream.
  2438. #include <stdio.h>
  2439. #include <ctype.h>
  2440. void
  2441. skip_whitespace (FILE *stream)
  2442. {
  2443. int c;
  2444. do
  2445. /* No need to check for ‘EOF’ because it is not
  2446. ‘isspace’, and ‘ungetc’ ignores ‘EOF’. */
  2447. c = getc (stream);
  2448. while (isspace (c));
  2449. ungetc (c, stream);
  2450. }
  2451. 
  2452. File: libc.info, Node: Block Input/Output, Next: Formatted Output, Prev: Unreading, Up: I/O on Streams
  2453. 12.11 Block Input/Output
  2454. ========================
  2455. This section describes how to do input and output operations on blocks
  2456. of data. You can use these functions to read and write binary data, as
  2457. well as to read and write text in fixed-size blocks instead of by
  2458. characters or lines.
  2459. Binary files are typically used to read and write blocks of data in
  2460. the same format as is used to represent the data in a running program.
  2461. In other words, arbitrary blocks of memory—not just character or string
  2462. objects—can be written to a binary file, and meaningfully read in again
  2463. by the same program.
  2464. Storing data in binary form is often considerably more efficient than
  2465. using the formatted I/O functions. Also, for floating-point numbers,
  2466. the binary form avoids possible loss of precision in the conversion
  2467. process. On the other hand, binary files can’t be examined or modified
  2468. easily using many standard file utilities (such as text editors), and
  2469. are not portable between different implementations of the language, or
  2470. different kinds of computers.
  2471. These functions are declared in ‘stdio.h’.
  2472. -- Function: size_t fread (void *DATA, size_t SIZE, size_t COUNT, FILE
  2473. *STREAM)
  2474. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2475. | *Note POSIX Safety Concepts::.
  2476. This function reads up to COUNT objects of size SIZE into the array
  2477. DATA, from the stream STREAM. It returns the number of objects
  2478. actually read, which might be less than COUNT if a read error
  2479. occurs or the end of the file is reached. This function returns a
  2480. value of zero (and doesn’t read anything) if either SIZE or COUNT
  2481. is zero.
  2482. If ‘fread’ encounters end of file in the middle of an object, it
  2483. returns the number of complete objects read, and discards the
  2484. partial object. Therefore, the stream remains at the actual end of
  2485. the file.
  2486. -- Function: size_t fread_unlocked (void *DATA, size_t SIZE, size_t
  2487. COUNT, FILE *STREAM)
  2488. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  2489. corrupt | *Note POSIX Safety Concepts::.
  2490. The ‘fread_unlocked’ function is equivalent to the ‘fread’ function
  2491. except that it does not implicitly lock the stream.
  2492. This function is a GNU extension.
  2493. -- Function: size_t fwrite (const void *DATA, size_t SIZE, size_t
  2494. COUNT, FILE *STREAM)
  2495. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  2496. | *Note POSIX Safety Concepts::.
  2497. This function writes up to COUNT objects of size SIZE from the
  2498. array DATA, to the stream STREAM. The return value is normally
  2499. COUNT, if the call succeeds. Any other value indicates some sort
  2500. of error, such as running out of space.
  2501. -- Function: size_t fwrite_unlocked (const void *DATA, size_t SIZE,
  2502. size_t COUNT, FILE *STREAM)
  2503. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  2504. corrupt | *Note POSIX Safety Concepts::.
  2505. The ‘fwrite_unlocked’ function is equivalent to the ‘fwrite’
  2506. function except that it does not implicitly lock the stream.
  2507. This function is a GNU extension.
  2508. 
  2509. File: libc.info, Node: Formatted Output, Next: Customizing Printf, Prev: Block Input/Output, Up: I/O on Streams
  2510. 12.12 Formatted Output
  2511. ======================
  2512. The functions described in this section (‘printf’ and related functions)
  2513. provide a convenient way to perform formatted output. You call ‘printf’
  2514. with a “format string” or “template string” that specifies how to format
  2515. the values of the remaining arguments.
  2516. Unless your program is a filter that specifically performs line- or
  2517. character-oriented processing, using ‘printf’ or one of the other
  2518. related functions described in this section is usually the easiest and
  2519. most concise way to perform output. These functions are especially
  2520. useful for printing error messages, tables of data, and the like.
  2521. * Menu:
  2522. * Formatted Output Basics:: Some examples to get you started.
  2523. * Output Conversion Syntax:: General syntax of conversion
  2524. specifications.
  2525. * Table of Output Conversions:: Summary of output conversions and
  2526. what they do.
  2527. * Integer Conversions:: Details about formatting of integers.
  2528. * Floating-Point Conversions:: Details about formatting of
  2529. floating-point numbers.
  2530. * Other Output Conversions:: Details about formatting of strings,
  2531. characters, pointers, and the like.
  2532. * Formatted Output Functions:: Descriptions of the actual functions.
  2533. * Dynamic Output:: Functions that allocate memory for the output.
  2534. * Variable Arguments Output:: ‘vprintf’ and friends.
  2535. * Parsing a Template String:: What kinds of args does a given template
  2536. call for?
  2537. * Example of Parsing:: Sample program using ‘parse_printf_format’.
  2538. 
  2539. File: libc.info, Node: Formatted Output Basics, Next: Output Conversion Syntax, Up: Formatted Output
  2540. 12.12.1 Formatted Output Basics
  2541. -------------------------------
  2542. The ‘printf’ function can be used to print any number of arguments. The
  2543. template string argument you supply in a call provides information not
  2544. only about the number of additional arguments, but also about their
  2545. types and what style should be used for printing them.
  2546. Ordinary characters in the template string are simply written to the
  2547. output stream as-is, while “conversion specifications” introduced by a
  2548. ‘%’ character in the template cause subsequent arguments to be formatted
  2549. and written to the output stream. For example,
  2550. int pct = 37;
  2551. char filename[] = "foo.txt";
  2552. printf ("Processing of `%s' is %d%% finished.\nPlease be patient.\n",
  2553. filename, pct);
  2554. produces output like
  2555. Processing of `foo.txt' is 37% finished.
  2556. Please be patient.
  2557. This example shows the use of the ‘%d’ conversion to specify that an
  2558. ‘int’ argument should be printed in decimal notation, the ‘%s’
  2559. conversion to specify printing of a string argument, and the ‘%%’
  2560. conversion to print a literal ‘%’ character.
  2561. There are also conversions for printing an integer argument as an
  2562. unsigned value in octal, decimal, or hexadecimal radix (‘%o’, ‘%u’, or
  2563. ‘%x’, respectively); or as a character value (‘%c’).
  2564. Floating-point numbers can be printed in normal, fixed-point notation
  2565. using the ‘%f’ conversion or in exponential notation using the ‘%e’
  2566. conversion. The ‘%g’ conversion uses either ‘%e’ or ‘%f’ format,
  2567. depending on what is more appropriate for the magnitude of the
  2568. particular number.
  2569. You can control formatting more precisely by writing “modifiers”
  2570. between the ‘%’ and the character that indicates which conversion to
  2571. apply. These slightly alter the ordinary behavior of the conversion.
  2572. For example, most conversion specifications permit you to specify a
  2573. minimum field width and a flag indicating whether you want the result
  2574. left- or right-justified within the field.
  2575. The specific flags and modifiers that are permitted and their
  2576. interpretation vary depending on the particular conversion. They’re all
  2577. described in more detail in the following sections. Don’t worry if this
  2578. all seems excessively complicated at first; you can almost always get
  2579. reasonable free-format output without using any of the modifiers at all.
  2580. The modifiers are mostly used to make the output look “prettier” in
  2581. tables.
  2582. 
  2583. File: libc.info, Node: Output Conversion Syntax, Next: Table of Output Conversions, Prev: Formatted Output Basics, Up: Formatted Output
  2584. 12.12.2 Output Conversion Syntax
  2585. --------------------------------
  2586. This section provides details about the precise syntax of conversion
  2587. specifications that can appear in a ‘printf’ template string.
  2588. Characters in the template string that are not part of a conversion
  2589. specification are printed as-is to the output stream. Multibyte
  2590. character sequences (*note Character Set Handling::) are permitted in a
  2591. template string.
  2592. The conversion specifications in a ‘printf’ template string have the
  2593. general form:
  2594. % [ PARAM-NO $] FLAGS WIDTH [ . PRECISION ] TYPE CONVERSION
  2595. or
  2596. % [ PARAM-NO $] FLAGS WIDTH . * [ PARAM-NO $] TYPE CONVERSION
  2597. For example, in the conversion specifier ‘%-10.8ld’, the ‘-’ is a
  2598. flag, ‘10’ specifies the field width, the precision is ‘8’, the letter
  2599. ‘l’ is a type modifier, and ‘d’ specifies the conversion style. (This
  2600. particular type specifier says to print a ‘long int’ argument in decimal
  2601. notation, with a minimum of 8 digits left-justified in a field at least
  2602. 10 characters wide.)
  2603. In more detail, output conversion specifications consist of an
  2604. initial ‘%’ character followed in sequence by:
  2605. • An optional specification of the parameter used for this format.
  2606. Normally the parameters to the ‘printf’ function are assigned to
  2607. the formats in the order of appearance in the format string. But
  2608. in some situations (such as message translation) this is not
  2609. desirable and this extension allows an explicit parameter to be
  2610. specified.
  2611. The PARAM-NO parts of the format must be integers in the range of 1
  2612. to the maximum number of arguments present to the function call.
  2613. Some implementations limit this number to a certain upper bound.
  2614. The exact limit can be retrieved by the following constant.
  2615. -- Macro: NL_ARGMAX
  2616. The value of ‘NL_ARGMAX’ is the maximum value allowed for the
  2617. specification of a positional parameter in a ‘printf’ call.
  2618. The actual value in effect at runtime can be retrieved by
  2619. using ‘sysconf’ using the ‘_SC_NL_ARGMAX’ parameter *note
  2620. Sysconf Definition::.
  2621. Some systems have a quite low limit such as 9 for System V
  2622. systems. The GNU C Library has no real limit.
  2623. If any of the formats has a specification for the parameter
  2624. position all of them in the format string shall have one.
  2625. Otherwise the behavior is undefined.
  2626. • Zero or more “flag characters” that modify the normal behavior of
  2627. the conversion specification.
  2628. • An optional decimal integer specifying the “minimum field width”.
  2629. If the normal conversion produces fewer characters than this, the
  2630. field is padded with spaces to the specified width. This is a
  2631. _minimum_ value; if the normal conversion produces more characters
  2632. than this, the field is _not_ truncated. Normally, the output is
  2633. right-justified within the field.
  2634. You can also specify a field width of ‘*’. This means that the
  2635. next argument in the argument list (before the actual value to be
  2636. printed) is used as the field width. The value must be an ‘int’.
  2637. If the value is negative, this means to set the ‘-’ flag (see
  2638. below) and to use the absolute value as the field width.
  2639. • An optional “precision” to specify the number of digits to be
  2640. written for the numeric conversions. If the precision is
  2641. specified, it consists of a period (‘.’) followed optionally by a
  2642. decimal integer (which defaults to zero if omitted).
  2643. You can also specify a precision of ‘*’. This means that the next
  2644. argument in the argument list (before the actual value to be
  2645. printed) is used as the precision. The value must be an ‘int’, and
  2646. is ignored if it is negative. If you specify ‘*’ for both the
  2647. field width and precision, the field width argument precedes the
  2648. precision argument. Other C library versions may not recognize
  2649. this syntax.
  2650. • An optional “type modifier character”, which is used to specify the
  2651. data type of the corresponding argument if it differs from the
  2652. default type. (For example, the integer conversions assume a type
  2653. of ‘int’, but you can specify ‘h’, ‘l’, or ‘L’ for other integer
  2654. types.)
  2655. • A character that specifies the conversion to be applied.
  2656. The exact options that are permitted and how they are interpreted
  2657. vary between the different conversion specifiers. See the descriptions
  2658. of the individual conversions for information about the particular
  2659. options that they use.
  2660. With the ‘-Wformat’ option, the GNU C compiler checks calls to
  2661. ‘printf’ and related functions. It examines the format string and
  2662. verifies that the correct number and types of arguments are supplied.
  2663. There is also a GNU C syntax to tell the compiler that a function you
  2664. write uses a ‘printf’-style format string. *Note Declaring Attributes
  2665. of Functions: (gcc)Function Attributes, for more information.
  2666. 
  2667. File: libc.info, Node: Table of Output Conversions, Next: Integer Conversions, Prev: Output Conversion Syntax, Up: Formatted Output
  2668. 12.12.3 Table of Output Conversions
  2669. -----------------------------------
  2670. Here is a table summarizing what all the different conversions do:
  2671. ‘%d’, ‘%i’
  2672. Print an integer as a signed decimal number. *Note Integer
  2673. Conversions::, for details. ‘%d’ and ‘%i’ are synonymous for
  2674. output, but are different when used with ‘scanf’ for input (*note
  2675. Table of Input Conversions::).
  2676. ‘%o’
  2677. Print an integer as an unsigned octal number. *Note Integer
  2678. Conversions::, for details.
  2679. ‘%u’
  2680. Print an integer as an unsigned decimal number. *Note Integer
  2681. Conversions::, for details.
  2682. ‘%x’, ‘%X’
  2683. Print an integer as an unsigned hexadecimal number. ‘%x’ uses
  2684. lower-case letters and ‘%X’ uses upper-case. *Note Integer
  2685. Conversions::, for details.
  2686. ‘%f’
  2687. Print a floating-point number in normal (fixed-point) notation.
  2688. *Note Floating-Point Conversions::, for details.
  2689. ‘%e’, ‘%E’
  2690. Print a floating-point number in exponential notation. ‘%e’ uses
  2691. lower-case letters and ‘%E’ uses upper-case. *Note Floating-Point
  2692. Conversions::, for details.
  2693. ‘%g’, ‘%G’
  2694. Print a floating-point number in either normal or exponential
  2695. notation, whichever is more appropriate for its magnitude. ‘%g’
  2696. uses lower-case letters and ‘%G’ uses upper-case. *Note
  2697. Floating-Point Conversions::, for details.
  2698. ‘%a’, ‘%A’
  2699. Print a floating-point number in a hexadecimal fractional notation
  2700. with the exponent to base 2 represented in decimal digits. ‘%a’
  2701. uses lower-case letters and ‘%A’ uses upper-case. *Note
  2702. Floating-Point Conversions::, for details.
  2703. ‘%c’
  2704. Print a single character. *Note Other Output Conversions::.
  2705. ‘%C’
  2706. This is an alias for ‘%lc’ which is supported for compatibility
  2707. with the Unix standard.
  2708. ‘%s’
  2709. Print a string. *Note Other Output Conversions::.
  2710. ‘%S’
  2711. This is an alias for ‘%ls’ which is supported for compatibility
  2712. with the Unix standard.
  2713. ‘%p’
  2714. Print the value of a pointer. *Note Other Output Conversions::.
  2715. ‘%n’
  2716. Get the number of characters printed so far. *Note Other Output
  2717. Conversions::. Note that this conversion specification never
  2718. produces any output.
  2719. ‘%m’
  2720. Print the string corresponding to the value of ‘errno’. (This is a
  2721. GNU extension.) *Note Other Output Conversions::.
  2722. ‘%%’
  2723. Print a literal ‘%’ character. *Note Other Output Conversions::.
  2724. If the syntax of a conversion specification is invalid, unpredictable
  2725. things will happen, so don’t do this. If there aren’t enough function
  2726. arguments provided to supply values for all the conversion
  2727. specifications in the template string, or if the arguments are not of
  2728. the correct types, the results are unpredictable. If you supply more
  2729. arguments than conversion specifications, the extra argument values are
  2730. simply ignored; this is sometimes useful.
  2731. 
  2732. File: libc.info, Node: Integer Conversions, Next: Floating-Point Conversions, Prev: Table of Output Conversions, Up: Formatted Output
  2733. 12.12.4 Integer Conversions
  2734. ---------------------------
  2735. This section describes the options for the ‘%d’, ‘%i’, ‘%o’, ‘%u’, ‘%x’,
  2736. and ‘%X’ conversion specifications. These conversions print integers in
  2737. various formats.
  2738. The ‘%d’ and ‘%i’ conversion specifications both print an ‘int’
  2739. argument as a signed decimal number; while ‘%o’, ‘%u’, and ‘%x’ print
  2740. the argument as an unsigned octal, decimal, or hexadecimal number
  2741. (respectively). The ‘%X’ conversion specification is just like ‘%x’
  2742. except that it uses the characters ‘ABCDEF’ as digits instead of
  2743. ‘abcdef’.
  2744. The following flags are meaningful:
  2745. ‘-’
  2746. Left-justify the result in the field (instead of the normal
  2747. right-justification).
  2748. ‘+’
  2749. For the signed ‘%d’ and ‘%i’ conversions, print a plus sign if the
  2750. value is positive.
  2751. ‘ ’
  2752. For the signed ‘%d’ and ‘%i’ conversions, if the result doesn’t
  2753. start with a plus or minus sign, prefix it with a space character
  2754. instead. Since the ‘+’ flag ensures that the result includes a
  2755. sign, this flag is ignored if you supply both of them.
  2756. ‘#’
  2757. For the ‘%o’ conversion, this forces the leading digit to be ‘0’,
  2758. as if by increasing the precision. For ‘%x’ or ‘%X’, this prefixes
  2759. a leading ‘0x’ or ‘0X’ (respectively) to the result. This doesn’t
  2760. do anything useful for the ‘%d’, ‘%i’, or ‘%u’ conversions. Using
  2761. this flag produces output which can be parsed by the ‘strtoul’
  2762. function (*note Parsing of Integers::) and ‘scanf’ with the ‘%i’
  2763. conversion (*note Numeric Input Conversions::).
  2764. ‘'’
  2765. Separate the digits into groups as specified by the locale
  2766. specified for the ‘LC_NUMERIC’ category; *note General Numeric::.
  2767. This flag is a GNU extension.
  2768. ‘0’
  2769. Pad the field with zeros instead of spaces. The zeros are placed
  2770. after any indication of sign or base. This flag is ignored if the
  2771. ‘-’ flag is also specified, or if a precision is specified.
  2772. If a precision is supplied, it specifies the minimum number of digits
  2773. to appear; leading zeros are produced if necessary. If you don’t
  2774. specify a precision, the number is printed with as many digits as it
  2775. needs. If you convert a value of zero with an explicit precision of
  2776. zero, then no characters at all are produced.
  2777. Without a type modifier, the corresponding argument is treated as an
  2778. ‘int’ (for the signed conversions ‘%i’ and ‘%d’) or ‘unsigned int’ (for
  2779. the unsigned conversions ‘%o’, ‘%u’, ‘%x’, and ‘%X’). Recall that since
  2780. ‘printf’ and friends are variadic, any ‘char’ and ‘short’ arguments are
  2781. automatically converted to ‘int’ by the default argument promotions.
  2782. For arguments of other integer types, you can use these modifiers:
  2783. ‘hh’
  2784. Specifies that the argument is a ‘signed char’ or ‘unsigned char’,
  2785. as appropriate. A ‘char’ argument is converted to an ‘int’ or
  2786. ‘unsigned int’ by the default argument promotions anyway, but the
  2787. ‘hh’ modifier says to convert it back to a ‘char’ again.
  2788. This modifier was introduced in ISO C99.
  2789. ‘h’
  2790. Specifies that the argument is a ‘short int’ or ‘unsigned short
  2791. int’, as appropriate. A ‘short’ argument is converted to an ‘int’
  2792. or ‘unsigned int’ by the default argument promotions anyway, but
  2793. the ‘h’ modifier says to convert it back to a ‘short’ again.
  2794. ‘j’
  2795. Specifies that the argument is a ‘intmax_t’ or ‘uintmax_t’, as
  2796. appropriate.
  2797. This modifier was introduced in ISO C99.
  2798. ‘l’
  2799. Specifies that the argument is a ‘long int’ or ‘unsigned long int’,
  2800. as appropriate. Two ‘l’ characters are like the ‘L’ modifier,
  2801. below.
  2802. If used with ‘%c’ or ‘%s’ the corresponding parameter is considered
  2803. as a wide character or wide character string respectively. This
  2804. use of ‘l’ was introduced in Amendment 1 to ISO C90.
  2805. ‘L’
  2806. ‘ll’
  2807. ‘q’
  2808. Specifies that the argument is a ‘long long int’. (This type is an
  2809. extension supported by the GNU C compiler. On systems that don’t
  2810. support extra-long integers, this is the same as ‘long int’.)
  2811. The ‘q’ modifier is another name for the same thing, which comes
  2812. from 4.4 BSD; a ‘long long int’ is sometimes called a “quad” ‘int’.
  2813. ‘t’
  2814. Specifies that the argument is a ‘ptrdiff_t’.
  2815. This modifier was introduced in ISO C99.
  2816. ‘z’
  2817. ‘Z’
  2818. Specifies that the argument is a ‘size_t’.
  2819. ‘z’ was introduced in ISO C99. ‘Z’ is a GNU extension predating
  2820. this addition and should not be used in new code.
  2821. Here is an example. Using the template string:
  2822. "|%5d|%-5d|%+5d|%+-5d|% 5d|%05d|%5.0d|%5.2d|%d|\n"
  2823. to print numbers using the different options for the ‘%d’ conversion
  2824. gives results like:
  2825. | 0|0 | +0|+0 | 0|00000| | 00|0|
  2826. | 1|1 | +1|+1 | 1|00001| 1| 01|1|
  2827. | -1|-1 | -1|-1 | -1|-0001| -1| -01|-1|
  2828. |100000|100000|+100000|+100000| 100000|100000|100000|100000|100000|
  2829. In particular, notice what happens in the last case where the number
  2830. is too large to fit in the minimum field width specified.
  2831. Here are some more examples showing how unsigned integers print under
  2832. various format options, using the template string:
  2833. "|%5u|%5o|%5x|%5X|%#5o|%#5x|%#5X|%#10.8x|\n"
  2834. | 0| 0| 0| 0| 0| 0| 0| 00000000|
  2835. | 1| 1| 1| 1| 01| 0x1| 0X1|0x00000001|
  2836. |100000|303240|186a0|186A0|0303240|0x186a0|0X186A0|0x000186a0|
  2837. 
  2838. File: libc.info, Node: Floating-Point Conversions, Next: Other Output Conversions, Prev: Integer Conversions, Up: Formatted Output
  2839. 12.12.5 Floating-Point Conversions
  2840. ----------------------------------
  2841. This section discusses the conversion specifications for floating-point
  2842. numbers: the ‘%f’, ‘%e’, ‘%E’, ‘%g’, and ‘%G’ conversions.
  2843. The ‘%f’ conversion prints its argument in fixed-point notation,
  2844. producing output of the form [‘-’]DDD‘.’DDD, where the number of digits
  2845. following the decimal point is controlled by the precision you specify.
  2846. The ‘%e’ conversion prints its argument in exponential notation,
  2847. producing output of the form [‘-’]D‘.’DDD‘e’[‘+’|‘-’]DD. Again, the
  2848. number of digits following the decimal point is controlled by the
  2849. precision. The exponent always contains at least two digits. The ‘%E’
  2850. conversion is similar but the exponent is marked with the letter ‘E’
  2851. instead of ‘e’.
  2852. The ‘%g’ and ‘%G’ conversions print the argument in the style of ‘%e’
  2853. or ‘%E’ (respectively) if the exponent would be less than -4 or greater
  2854. than or equal to the precision; otherwise they use the ‘%f’ style. A
  2855. precision of ‘0’, is taken as 1. Trailing zeros are removed from the
  2856. fractional portion of the result and a decimal-point character appears
  2857. only if it is followed by a digit.
  2858. The ‘%a’ and ‘%A’ conversions are meant for representing
  2859. floating-point numbers exactly in textual form so that they can be
  2860. exchanged as texts between different programs and/or machines. The
  2861. numbers are represented in the form [‘-’]‘0x’H‘.’HHH‘p’[‘+’|‘-’]DD. At
  2862. the left of the decimal-point character exactly one digit is print.
  2863. This character is only ‘0’ if the number is denormalized. Otherwise the
  2864. value is unspecified; it is implementation dependent how many bits are
  2865. used. The number of hexadecimal digits on the right side of the
  2866. decimal-point character is equal to the precision. If the precision is
  2867. zero it is determined to be large enough to provide an exact
  2868. representation of the number (or it is large enough to distinguish two
  2869. adjacent values if the ‘FLT_RADIX’ is not a power of 2, *note Floating
  2870. Point Parameters::). For the ‘%a’ conversion lower-case characters are
  2871. used to represent the hexadecimal number and the prefix and exponent
  2872. sign are printed as ‘0x’ and ‘p’ respectively. Otherwise upper-case
  2873. characters are used and ‘0X’ and ‘P’ are used for the representation of
  2874. prefix and exponent string. The exponent to the base of two is printed
  2875. as a decimal number using at least one digit but at most as many digits
  2876. as necessary to represent the value exactly.
  2877. If the value to be printed represents infinity or a NaN, the output
  2878. is [‘-’]‘inf’ or ‘nan’ respectively if the conversion specifier is ‘%a’,
  2879. ‘%e’, ‘%f’, or ‘%g’ and it is [‘-’]‘INF’ or ‘NAN’ respectively if the
  2880. conversion is ‘%A’, ‘%E’, or ‘%G’.
  2881. The following flags can be used to modify the behavior:
  2882. ‘-’
  2883. Left-justify the result in the field. Normally the result is
  2884. right-justified.
  2885. ‘+’
  2886. Always include a plus or minus sign in the result.
  2887. ‘ ’
  2888. If the result doesn’t start with a plus or minus sign, prefix it
  2889. with a space instead. Since the ‘+’ flag ensures that the result
  2890. includes a sign, this flag is ignored if you supply both of them.
  2891. ‘#’
  2892. Specifies that the result should always include a decimal point,
  2893. even if no digits follow it. For the ‘%g’ and ‘%G’ conversions,
  2894. this also forces trailing zeros after the decimal point to be left
  2895. in place where they would otherwise be removed.
  2896. ‘'’
  2897. Separate the digits of the integer part of the result into groups
  2898. as specified by the locale specified for the ‘LC_NUMERIC’ category;
  2899. *note General Numeric::. This flag is a GNU extension.
  2900. ‘0’
  2901. Pad the field with zeros instead of spaces; the zeros are placed
  2902. after any sign. This flag is ignored if the ‘-’ flag is also
  2903. specified.
  2904. The precision specifies how many digits follow the decimal-point
  2905. character for the ‘%f’, ‘%e’, and ‘%E’ conversions. For these
  2906. conversions, the default precision is ‘6’. If the precision is
  2907. explicitly ‘0’, this suppresses the decimal point character entirely.
  2908. For the ‘%g’ and ‘%G’ conversions, the precision specifies how many
  2909. significant digits to print. Significant digits are the first digit
  2910. before the decimal point, and all the digits after it. If the precision
  2911. is ‘0’ or not specified for ‘%g’ or ‘%G’, it is treated like a value of
  2912. ‘1’. If the value being printed cannot be expressed accurately in the
  2913. specified number of digits, the value is rounded to the nearest number
  2914. that fits.
  2915. Without a type modifier, the floating-point conversions use an
  2916. argument of type ‘double’. (By the default argument promotions, any
  2917. ‘float’ arguments are automatically converted to ‘double’.) The
  2918. following type modifier is supported:
  2919. ‘L’
  2920. An uppercase ‘L’ specifies that the argument is a ‘long double’.
  2921. Here are some examples showing how numbers print using the various
  2922. floating-point conversions. All of the numbers were printed using this
  2923. template string:
  2924. "|%13.4a|%13.4f|%13.4e|%13.4g|\n"
  2925. Here is the output:
  2926. | 0x0.0000p+0| 0.0000| 0.0000e+00| 0|
  2927. | 0x1.0000p-1| 0.5000| 5.0000e-01| 0.5|
  2928. | 0x1.0000p+0| 1.0000| 1.0000e+00| 1|
  2929. | -0x1.0000p+0| -1.0000| -1.0000e+00| -1|
  2930. | 0x1.9000p+6| 100.0000| 1.0000e+02| 100|
  2931. | 0x1.f400p+9| 1000.0000| 1.0000e+03| 1000|
  2932. | 0x1.3880p+13| 10000.0000| 1.0000e+04| 1e+04|
  2933. | 0x1.81c8p+13| 12345.0000| 1.2345e+04| 1.234e+04|
  2934. | 0x1.86a0p+16| 100000.0000| 1.0000e+05| 1e+05|
  2935. | 0x1.e240p+16| 123456.0000| 1.2346e+05| 1.235e+05|
  2936. Notice how the ‘%g’ conversion drops trailing zeros.
  2937. 
  2938. File: libc.info, Node: Other Output Conversions, Next: Formatted Output Functions, Prev: Floating-Point Conversions, Up: Formatted Output
  2939. 12.12.6 Other Output Conversions
  2940. --------------------------------
  2941. This section describes miscellaneous conversions for ‘printf’.
  2942. The ‘%c’ conversion prints a single character. In case there is no
  2943. ‘l’ modifier the ‘int’ argument is first converted to an ‘unsigned
  2944. char’. Then, if used in a wide stream function, the character is
  2945. converted into the corresponding wide character. The ‘-’ flag can be
  2946. used to specify left-justification in the field, but no other flags are
  2947. defined, and no precision or type modifier can be given. For example:
  2948. printf ("%c%c%c%c%c", 'h', 'e', 'l', 'l', 'o');
  2949. prints ‘hello’.
  2950. If there is an ‘l’ modifier present the argument is expected to be of
  2951. type ‘wint_t’. If used in a multibyte function the wide character is
  2952. converted into a multibyte character before being added to the output.
  2953. In this case more than one output byte can be produced.
  2954. The ‘%s’ conversion prints a string. If no ‘l’ modifier is present
  2955. the corresponding argument must be of type ‘char *’ (or ‘const char *’).
  2956. If used in a wide stream function the string is first converted to a
  2957. wide character string. A precision can be specified to indicate the
  2958. maximum number of characters to write; otherwise characters in the
  2959. string up to but not including the terminating null character are
  2960. written to the output stream. The ‘-’ flag can be used to specify
  2961. left-justification in the field, but no other flags or type modifiers
  2962. are defined for this conversion. For example:
  2963. printf ("%3s%-6s", "no", "where");
  2964. prints ‘ nowhere ’.
  2965. If there is an ‘l’ modifier present, the argument is expected to be
  2966. of type ‘wchar_t’ (or ‘const wchar_t *’).
  2967. If you accidentally pass a null pointer as the argument for a ‘%s’
  2968. conversion, the GNU C Library prints it as ‘(null)’. We think this is
  2969. more useful than crashing. But it’s not good practice to pass a null
  2970. argument intentionally.
  2971. The ‘%m’ conversion prints the string corresponding to the error code
  2972. in ‘errno’. *Note Error Messages::. Thus:
  2973. fprintf (stderr, "can't open `%s': %m\n", filename);
  2974. is equivalent to:
  2975. fprintf (stderr, "can't open `%s': %s\n", filename, strerror (errno));
  2976. The ‘%m’ conversion is a GNU C Library extension.
  2977. The ‘%p’ conversion prints a pointer value. The corresponding
  2978. argument must be of type ‘void *’. In practice, you can use any type of
  2979. pointer.
  2980. In the GNU C Library, non-null pointers are printed as unsigned
  2981. integers, as if a ‘%#x’ conversion were used. Null pointers print as
  2982. ‘(nil)’. (Pointers might print differently in other systems.)
  2983. For example:
  2984. printf ("%p", "testing");
  2985. prints ‘0x’ followed by a hexadecimal number—the address of the string
  2986. constant ‘"testing"’. It does not print the word ‘testing’.
  2987. You can supply the ‘-’ flag with the ‘%p’ conversion to specify
  2988. left-justification, but no other flags, precision, or type modifiers are
  2989. defined.
  2990. The ‘%n’ conversion is unlike any of the other output conversions.
  2991. It uses an argument which must be a pointer to an ‘int’, but instead of
  2992. printing anything it stores the number of characters printed so far by
  2993. this call at that location. The ‘h’ and ‘l’ type modifiers are
  2994. permitted to specify that the argument is of type ‘short int *’ or ‘long
  2995. int *’ instead of ‘int *’, but no flags, field width, or precision are
  2996. permitted.
  2997. For example,
  2998. int nchar;
  2999. printf ("%d %s%n\n", 3, "bears", &nchar);
  3000. prints:
  3001. 3 bears
  3002. and sets ‘nchar’ to ‘7’, because ‘3 bears’ is seven characters.
  3003. The ‘%%’ conversion prints a literal ‘%’ character. This conversion
  3004. doesn’t use an argument, and no flags, field width, precision, or type
  3005. modifiers are permitted.
  3006. 
  3007. File: libc.info, Node: Formatted Output Functions, Next: Dynamic Output, Prev: Other Output Conversions, Up: Formatted Output
  3008. 12.12.7 Formatted Output Functions
  3009. ----------------------------------
  3010. This section describes how to call ‘printf’ and related functions.
  3011. Prototypes for these functions are in the header file ‘stdio.h’.
  3012. Because these functions take a variable number of arguments, you _must_
  3013. declare prototypes for them before using them. Of course, the easiest
  3014. way to make sure you have all the right prototypes is to just include
  3015. ‘stdio.h’.
  3016. -- Function: int printf (const char *TEMPLATE, ...)
  3017. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  3018. mem lock corrupt | *Note POSIX Safety Concepts::.
  3019. The ‘printf’ function prints the optional arguments under the
  3020. control of the template string TEMPLATE to the stream ‘stdout’. It
  3021. returns the number of characters printed, or a negative value if
  3022. there was an output error.
  3023. -- Function: int wprintf (const wchar_t *TEMPLATE, ...)
  3024. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  3025. mem lock corrupt | *Note POSIX Safety Concepts::.
  3026. The ‘wprintf’ function prints the optional arguments under the
  3027. control of the wide template string TEMPLATE to the stream
  3028. ‘stdout’. It returns the number of wide characters printed, or a
  3029. negative value if there was an output error.
  3030. -- Function: int fprintf (FILE *STREAM, const char *TEMPLATE, ...)
  3031. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  3032. mem lock corrupt | *Note POSIX Safety Concepts::.
  3033. This function is just like ‘printf’, except that the output is
  3034. written to the stream STREAM instead of ‘stdout’.
  3035. -- Function: int fwprintf (FILE *STREAM, const wchar_t *TEMPLATE, ...)
  3036. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  3037. mem lock corrupt | *Note POSIX Safety Concepts::.
  3038. This function is just like ‘wprintf’, except that the output is
  3039. written to the stream STREAM instead of ‘stdout’.
  3040. -- Function: int sprintf (char *S, const char *TEMPLATE, ...)
  3041. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  3042. *Note POSIX Safety Concepts::.
  3043. This is like ‘printf’, except that the output is stored in the
  3044. character array S instead of written to a stream. A null character
  3045. is written to mark the end of the string.
  3046. The ‘sprintf’ function returns the number of characters stored in
  3047. the array S, not including the terminating null character.
  3048. The behavior of this function is undefined if copying takes place
  3049. between objects that overlap—for example, if S is also given as an
  3050. argument to be printed under control of the ‘%s’ conversion. *Note
  3051. Copying Strings and Arrays::.
  3052. *Warning:* The ‘sprintf’ function can be *dangerous* because it can
  3053. potentially output more characters than can fit in the allocation
  3054. size of the string S. Remember that the field width given in a
  3055. conversion specification is only a _minimum_ value.
  3056. To avoid this problem, you can use ‘snprintf’ or ‘asprintf’,
  3057. described below.
  3058. -- Function: int swprintf (wchar_t *WS, size_t SIZE, const wchar_t
  3059. *TEMPLATE, ...)
  3060. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  3061. *Note POSIX Safety Concepts::.
  3062. This is like ‘wprintf’, except that the output is stored in the
  3063. wide character array WS instead of written to a stream. A null
  3064. wide character is written to mark the end of the string. The SIZE
  3065. argument specifies the maximum number of characters to produce.
  3066. The trailing null character is counted towards this limit, so you
  3067. should allocate at least SIZE wide characters for the string WS.
  3068. The return value is the number of characters generated for the
  3069. given input, excluding the trailing null. If not all output fits
  3070. into the provided buffer a negative value is returned. You should
  3071. try again with a bigger output string. _Note:_ this is different
  3072. from how ‘snprintf’ handles this situation.
  3073. Note that the corresponding narrow stream function takes fewer
  3074. parameters. ‘swprintf’ in fact corresponds to the ‘snprintf’
  3075. function. Since the ‘sprintf’ function can be dangerous and should
  3076. be avoided the ISO C committee refused to make the same mistake
  3077. again and decided to not define a function exactly corresponding to
  3078. ‘sprintf’.
  3079. -- Function: int snprintf (char *S, size_t SIZE, const char *TEMPLATE,
  3080. ...)
  3081. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  3082. *Note POSIX Safety Concepts::.
  3083. The ‘snprintf’ function is similar to ‘sprintf’, except that the
  3084. SIZE argument specifies the maximum number of characters to
  3085. produce. The trailing null character is counted towards this
  3086. limit, so you should allocate at least SIZE characters for the
  3087. string S. If SIZE is zero, nothing, not even the null byte, shall
  3088. be written and S may be a null pointer.
  3089. The return value is the number of characters which would be
  3090. generated for the given input, excluding the trailing null. If
  3091. this value is greater than or equal to SIZE, not all characters
  3092. from the result have been stored in S. You should try again with a
  3093. bigger output string. Here is an example of doing this:
  3094. /* Construct a message describing the value of a variable
  3095. whose name is NAME and whose value is VALUE. */
  3096. char *
  3097. make_message (char *name, char *value)
  3098. {
  3099. /* Guess we need no more than 100 chars of space. */
  3100. int size = 100;
  3101. char *buffer = (char *) xmalloc (size);
  3102. int nchars;
  3103. if (buffer == NULL)
  3104. return NULL;
  3105. /* Try to print in the allocated space. */
  3106. nchars = snprintf (buffer, size, "value of %s is %s",
  3107. name, value);
  3108. if (nchars >= size)
  3109. {
  3110. /* Reallocate buffer now that we know
  3111. how much space is needed. */
  3112. size = nchars + 1;
  3113. buffer = (char *) xrealloc (buffer, size);
  3114. if (buffer != NULL)
  3115. /* Try again. */
  3116. snprintf (buffer, size, "value of %s is %s",
  3117. name, value);
  3118. }
  3119. /* The last call worked, return the string. */
  3120. return buffer;
  3121. }
  3122. In practice, it is often easier just to use ‘asprintf’, below.
  3123. *Attention:* In versions of the GNU C Library prior to 2.1 the
  3124. return value is the number of characters stored, not including the
  3125. terminating null; unless there was not enough space in S to store
  3126. the result in which case ‘-1’ is returned. This was changed in
  3127. order to comply with the ISO C99 standard.
  3128. 
  3129. File: libc.info, Node: Dynamic Output, Next: Variable Arguments Output, Prev: Formatted Output Functions, Up: Formatted Output
  3130. 12.12.8 Dynamically Allocating Formatted Output
  3131. -----------------------------------------------
  3132. The functions in this section do formatted output and place the results
  3133. in dynamically allocated memory.
  3134. -- Function: int asprintf (char **PTR, const char *TEMPLATE, ...)
  3135. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  3136. *Note POSIX Safety Concepts::.
  3137. This function is similar to ‘sprintf’, except that it dynamically
  3138. allocates a string (as with ‘malloc’; *note Unconstrained
  3139. Allocation::) to hold the output, instead of putting the output in
  3140. a buffer you allocate in advance. The PTR argument should be the
  3141. address of a ‘char *’ object, and a successful call to ‘asprintf’
  3142. stores a pointer to the newly allocated string at that location.
  3143. The return value is the number of characters allocated for the
  3144. buffer, or less than zero if an error occurred. Usually this means
  3145. that the buffer could not be allocated.
  3146. Here is how to use ‘asprintf’ to get the same result as the
  3147. ‘snprintf’ example, but more easily:
  3148. /* Construct a message describing the value of a variable
  3149. whose name is NAME and whose value is VALUE. */
  3150. char *
  3151. make_message (char *name, char *value)
  3152. {
  3153. char *result;
  3154. if (asprintf (&result, "value of %s is %s", name, value) < 0)
  3155. return NULL;
  3156. return result;
  3157. }
  3158. -- Function: int obstack_printf (struct obstack *OBSTACK, const char
  3159. *TEMPLATE, ...)
  3160. Preliminary: | MT-Safe race:obstack locale | AS-Unsafe corrupt heap
  3161. | AC-Unsafe corrupt mem | *Note POSIX Safety Concepts::.
  3162. This function is similar to ‘asprintf’, except that it uses the
  3163. obstack OBSTACK to allocate the space. *Note Obstacks::.
  3164. The characters are written onto the end of the current object. To
  3165. get at them, you must finish the object with ‘obstack_finish’
  3166. (*note Growing Objects::).
  3167. 
  3168. File: libc.info, Node: Variable Arguments Output, Next: Parsing a Template String, Prev: Dynamic Output, Up: Formatted Output
  3169. 12.12.9 Variable Arguments Output Functions
  3170. -------------------------------------------
  3171. The functions ‘vprintf’ and friends are provided so that you can define
  3172. your own variadic ‘printf’-like functions that make use of the same
  3173. internals as the built-in formatted output functions.
  3174. The most natural way to define such functions would be to use a
  3175. language construct to say, “Call ‘printf’ and pass this template plus
  3176. all of my arguments after the first five.” But there is no way to do
  3177. this in C, and it would be hard to provide a way, since at the C
  3178. language level there is no way to tell how many arguments your function
  3179. received.
  3180. Since that method is impossible, we provide alternative functions,
  3181. the ‘vprintf’ series, which lets you pass a ‘va_list’ to describe “all
  3182. of my arguments after the first five.”
  3183. When it is sufficient to define a macro rather than a real function,
  3184. the GNU C compiler provides a way to do this much more easily with
  3185. macros. For example:
  3186. #define myprintf(a, b, c, d, e, rest...) \
  3187. printf (mytemplate , ## rest)
  3188. *Note (cpp)Variadic Macros::, for details. But this is limited to
  3189. macros, and does not apply to real functions at all.
  3190. Before calling ‘vprintf’ or the other functions listed in this
  3191. section, you _must_ call ‘va_start’ (*note Variadic Functions::) to
  3192. initialize a pointer to the variable arguments. Then you can call
  3193. ‘va_arg’ to fetch the arguments that you want to handle yourself. This
  3194. advances the pointer past those arguments.
  3195. Once your ‘va_list’ pointer is pointing at the argument of your
  3196. choice, you are ready to call ‘vprintf’. That argument and all
  3197. subsequent arguments that were passed to your function are used by
  3198. ‘vprintf’ along with the template that you specified separately.
  3199. *Portability Note:* The value of the ‘va_list’ pointer is
  3200. undetermined after the call to ‘vprintf’, so you must not use ‘va_arg’
  3201. after you call ‘vprintf’. Instead, you should call ‘va_end’ to retire
  3202. the pointer from service. You can call ‘va_start’ again and begin
  3203. fetching the arguments from the start of the variable argument list.
  3204. (Alternatively, you can use ‘va_copy’ to make a copy of the ‘va_list’
  3205. pointer before calling ‘vfprintf’.) Calling ‘vprintf’ does not destroy
  3206. the argument list of your function, merely the particular pointer that
  3207. you passed to it.
  3208. Prototypes for these functions are declared in ‘stdio.h’.
  3209. -- Function: int vprintf (const char *TEMPLATE, va_list AP)
  3210. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  3211. mem lock corrupt | *Note POSIX Safety Concepts::.
  3212. This function is similar to ‘printf’ except that, instead of taking
  3213. a variable number of arguments directly, it takes an argument list
  3214. pointer AP.
  3215. -- Function: int vwprintf (const wchar_t *TEMPLATE, va_list AP)
  3216. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  3217. mem lock corrupt | *Note POSIX Safety Concepts::.
  3218. This function is similar to ‘wprintf’ except that, instead of
  3219. taking a variable number of arguments directly, it takes an
  3220. argument list pointer AP.
  3221. -- Function: int vfprintf (FILE *STREAM, const char *TEMPLATE, va_list
  3222. AP)
  3223. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  3224. mem lock corrupt | *Note POSIX Safety Concepts::.
  3225. This is the equivalent of ‘fprintf’ with the variable argument list
  3226. specified directly as for ‘vprintf’.
  3227. -- Function: int vfwprintf (FILE *STREAM, const wchar_t *TEMPLATE,
  3228. va_list AP)
  3229. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  3230. mem lock corrupt | *Note POSIX Safety Concepts::.
  3231. This is the equivalent of ‘fwprintf’ with the variable argument
  3232. list specified directly as for ‘vwprintf’.
  3233. -- Function: int vsprintf (char *S, const char *TEMPLATE, va_list AP)
  3234. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  3235. *Note POSIX Safety Concepts::.
  3236. This is the equivalent of ‘sprintf’ with the variable argument list
  3237. specified directly as for ‘vprintf’.
  3238. -- Function: int vswprintf (wchar_t *WS, size_t SIZE, const wchar_t
  3239. *TEMPLATE, va_list AP)
  3240. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  3241. *Note POSIX Safety Concepts::.
  3242. This is the equivalent of ‘swprintf’ with the variable argument
  3243. list specified directly as for ‘vwprintf’.
  3244. -- Function: int vsnprintf (char *S, size_t SIZE, const char *TEMPLATE,
  3245. va_list AP)
  3246. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  3247. *Note POSIX Safety Concepts::.
  3248. This is the equivalent of ‘snprintf’ with the variable argument
  3249. list specified directly as for ‘vprintf’.
  3250. -- Function: int vasprintf (char **PTR, const char *TEMPLATE, va_list
  3251. AP)
  3252. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  3253. *Note POSIX Safety Concepts::.
  3254. The ‘vasprintf’ function is the equivalent of ‘asprintf’ with the
  3255. variable argument list specified directly as for ‘vprintf’.
  3256. -- Function: int obstack_vprintf (struct obstack *OBSTACK, const char
  3257. *TEMPLATE, va_list AP)
  3258. Preliminary: | MT-Safe race:obstack locale | AS-Unsafe corrupt heap
  3259. | AC-Unsafe corrupt mem | *Note POSIX Safety Concepts::.
  3260. The ‘obstack_vprintf’ function is the equivalent of
  3261. ‘obstack_printf’ with the variable argument list specified directly
  3262. as for ‘vprintf’.
  3263. Here’s an example showing how you might use ‘vfprintf’. This is a
  3264. function that prints error messages to the stream ‘stderr’, along with a
  3265. prefix indicating the name of the program (*note Error Messages::, for a
  3266. description of ‘program_invocation_short_name’).
  3267. #include <stdio.h>
  3268. #include <stdarg.h>
  3269. void
  3270. eprintf (const char *template, ...)
  3271. {
  3272. va_list ap;
  3273. extern char *program_invocation_short_name;
  3274. fprintf (stderr, "%s: ", program_invocation_short_name);
  3275. va_start (ap, template);
  3276. vfprintf (stderr, template, ap);
  3277. va_end (ap);
  3278. }
  3279. You could call ‘eprintf’ like this:
  3280. eprintf ("file `%s' does not exist\n", filename);
  3281. In GNU C, there is a special construct you can use to let the
  3282. compiler know that a function uses a ‘printf’-style format string. Then
  3283. it can check the number and types of arguments in each call to the
  3284. function, and warn you when they do not match the format string. For
  3285. example, take this declaration of ‘eprintf’:
  3286. void eprintf (const char *template, ...)
  3287. __attribute__ ((format (printf, 1, 2)));
  3288. This tells the compiler that ‘eprintf’ uses a format string like
  3289. ‘printf’ (as opposed to ‘scanf’; *note Formatted Input::); the format
  3290. string appears as the first argument; and the arguments to satisfy the
  3291. format begin with the second. *Note Declaring Attributes of Functions:
  3292. (gcc)Function Attributes, for more information.
  3293. 
  3294. File: libc.info, Node: Parsing a Template String, Next: Example of Parsing, Prev: Variable Arguments Output, Up: Formatted Output
  3295. 12.12.10 Parsing a Template String
  3296. ----------------------------------
  3297. You can use the function ‘parse_printf_format’ to obtain information
  3298. about the number and types of arguments that are expected by a given
  3299. template string. This function permits interpreters that provide
  3300. interfaces to ‘printf’ to avoid passing along invalid arguments from the
  3301. user’s program, which could cause a crash.
  3302. All the symbols described in this section are declared in the header
  3303. file ‘printf.h’.
  3304. -- Function: size_t parse_printf_format (const char *TEMPLATE, size_t
  3305. N, int *ARGTYPES)
  3306. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  3307. Safety Concepts::.
  3308. This function returns information about the number and types of
  3309. arguments expected by the ‘printf’ template string TEMPLATE. The
  3310. information is stored in the array ARGTYPES; each element of this
  3311. array describes one argument. This information is encoded using
  3312. the various ‘PA_’ macros, listed below.
  3313. The argument N specifies the number of elements in the array
  3314. ARGTYPES. This is the maximum number of elements that
  3315. ‘parse_printf_format’ will try to write.
  3316. ‘parse_printf_format’ returns the total number of arguments
  3317. required by TEMPLATE. If this number is greater than N, then the
  3318. information returned describes only the first N arguments. If you
  3319. want information about additional arguments, allocate a bigger
  3320. array and call ‘parse_printf_format’ again.
  3321. The argument types are encoded as a combination of a basic type and
  3322. modifier flag bits.
  3323. -- Macro: int PA_FLAG_MASK
  3324. This macro is a bitmask for the type modifier flag bits. You can
  3325. write the expression ‘(argtypes[i] & PA_FLAG_MASK)’ to extract just
  3326. the flag bits for an argument, or ‘(argtypes[i] & ~PA_FLAG_MASK)’
  3327. to extract just the basic type code.
  3328. Here are symbolic constants that represent the basic types; they
  3329. stand for integer values.
  3330. ‘PA_INT’
  3331. This specifies that the base type is ‘int’.
  3332. ‘PA_CHAR’
  3333. This specifies that the base type is ‘int’, cast to ‘char’.
  3334. ‘PA_STRING’
  3335. This specifies that the base type is ‘char *’, a null-terminated
  3336. string.
  3337. ‘PA_POINTER’
  3338. This specifies that the base type is ‘void *’, an arbitrary
  3339. pointer.
  3340. ‘PA_FLOAT’
  3341. This specifies that the base type is ‘float’.
  3342. ‘PA_DOUBLE’
  3343. This specifies that the base type is ‘double’.
  3344. ‘PA_LAST’
  3345. You can define additional base types for your own programs as
  3346. offsets from ‘PA_LAST’. For example, if you have data types ‘foo’
  3347. and ‘bar’ with their own specialized ‘printf’ conversions, you
  3348. could define encodings for these types as:
  3349. #define PA_FOO PA_LAST
  3350. #define PA_BAR (PA_LAST + 1)
  3351. Here are the flag bits that modify a basic type. They are combined
  3352. with the code for the basic type using inclusive-or.
  3353. ‘PA_FLAG_PTR’
  3354. If this bit is set, it indicates that the encoded type is a pointer
  3355. to the base type, rather than an immediate value. For example,
  3356. ‘PA_INT|PA_FLAG_PTR’ represents the type ‘int *’.
  3357. ‘PA_FLAG_SHORT’
  3358. If this bit is set, it indicates that the base type is modified
  3359. with ‘short’. (This corresponds to the ‘h’ type modifier.)
  3360. ‘PA_FLAG_LONG’
  3361. If this bit is set, it indicates that the base type is modified
  3362. with ‘long’. (This corresponds to the ‘l’ type modifier.)
  3363. ‘PA_FLAG_LONG_LONG’
  3364. If this bit is set, it indicates that the base type is modified
  3365. with ‘long long’. (This corresponds to the ‘L’ type modifier.)
  3366. ‘PA_FLAG_LONG_DOUBLE’
  3367. This is a synonym for ‘PA_FLAG_LONG_LONG’, used by convention with
  3368. a base type of ‘PA_DOUBLE’ to indicate a type of ‘long double’.
  3369. For an example of using these facilities, see *note Example of
  3370. Parsing::.
  3371. 
  3372. File: libc.info, Node: Example of Parsing, Prev: Parsing a Template String, Up: Formatted Output
  3373. 12.12.11 Example of Parsing a Template String
  3374. ---------------------------------------------
  3375. Here is an example of decoding argument types for a format string. We
  3376. assume this is part of an interpreter which contains arguments of type
  3377. ‘NUMBER’, ‘CHAR’, ‘STRING’ and ‘STRUCTURE’ (and perhaps others which are
  3378. not valid here).
  3379. /* Test whether the NARGS specified objects
  3380. in the vector ARGS are valid
  3381. for the format string FORMAT:
  3382. if so, return 1.
  3383. If not, return 0 after printing an error message. */
  3384. int
  3385. validate_args (char *format, int nargs, OBJECT *args)
  3386. {
  3387. int *argtypes;
  3388. int nwanted;
  3389. /* Get the information about the arguments.
  3390. Each conversion specification must be at least two characters
  3391. long, so there cannot be more specifications than half the
  3392. length of the string. */
  3393. argtypes = (int *) alloca (strlen (format) / 2 * sizeof (int));
  3394. nwanted = parse_printf_format (format, nargs, argtypes);
  3395. /* Check the number of arguments. */
  3396. if (nwanted > nargs)
  3397. {
  3398. error ("too few arguments (at least %d required)", nwanted);
  3399. return 0;
  3400. }
  3401. /* Check the C type wanted for each argument
  3402. and see if the object given is suitable. */
  3403. for (i = 0; i < nwanted; i++)
  3404. {
  3405. int wanted;
  3406. if (argtypes[i] & PA_FLAG_PTR)
  3407. wanted = STRUCTURE;
  3408. else
  3409. switch (argtypes[i] & ~PA_FLAG_MASK)
  3410. {
  3411. case PA_INT:
  3412. case PA_FLOAT:
  3413. case PA_DOUBLE:
  3414. wanted = NUMBER;
  3415. break;
  3416. case PA_CHAR:
  3417. wanted = CHAR;
  3418. break;
  3419. case PA_STRING:
  3420. wanted = STRING;
  3421. break;
  3422. case PA_POINTER:
  3423. wanted = STRUCTURE;
  3424. break;
  3425. }
  3426. if (TYPE (args[i]) != wanted)
  3427. {
  3428. error ("type mismatch for arg number %d", i);
  3429. return 0;
  3430. }
  3431. }
  3432. return 1;
  3433. }
  3434. 
  3435. File: libc.info, Node: Customizing Printf, Next: Formatted Input, Prev: Formatted Output, Up: I/O on Streams
  3436. 12.13 Customizing ‘printf’
  3437. ==========================
  3438. The GNU C Library lets you define your own custom conversion specifiers
  3439. for ‘printf’ template strings, to teach ‘printf’ clever ways to print
  3440. the important data structures of your program.
  3441. The way you do this is by registering the conversion with the
  3442. function ‘register_printf_function’; see *note Registering New
  3443. Conversions::. One of the arguments you pass to this function is a
  3444. pointer to a handler function that produces the actual output; see *note
  3445. Defining the Output Handler::, for information on how to write this
  3446. function.
  3447. You can also install a function that just returns information about
  3448. the number and type of arguments expected by the conversion specifier.
  3449. *Note Parsing a Template String::, for information about this.
  3450. The facilities of this section are declared in the header file
  3451. ‘printf.h’.
  3452. * Menu:
  3453. * Registering New Conversions:: Using ‘register_printf_function’
  3454. to register a new output conversion.
  3455. * Conversion Specifier Options:: The handler must be able to get
  3456. the options specified in the
  3457. template when it is called.
  3458. * Defining the Output Handler:: Defining the handler and arginfo
  3459. functions that are passed as arguments
  3460. to ‘register_printf_function’.
  3461. * Printf Extension Example:: How to define a ‘printf’
  3462. handler function.
  3463. * Predefined Printf Handlers:: Predefined ‘printf’ handlers.
  3464. *Portability Note:* The ability to extend the syntax of ‘printf’
  3465. template strings is a GNU extension. ISO standard C has nothing
  3466. similar. When using the GNU C compiler or any other compiler that
  3467. interprets calls to standard I/O functions according to the rules of the
  3468. language standard it is necessary to disable such handling by the
  3469. appropriate compiler option. Otherwise the behavior of a program that
  3470. relies on the extension is undefined.
  3471. 
  3472. File: libc.info, Node: Registering New Conversions, Next: Conversion Specifier Options, Up: Customizing Printf
  3473. 12.13.1 Registering New Conversions
  3474. -----------------------------------
  3475. The function to register a new output conversion is
  3476. ‘register_printf_function’, declared in ‘printf.h’.
  3477. -- Function: int register_printf_function (int SPEC, printf_function
  3478. HANDLER-FUNCTION, printf_arginfo_function ARGINFO-FUNCTION)
  3479. Preliminary: | MT-Unsafe const:printfext | AS-Unsafe heap lock |
  3480. AC-Unsafe mem lock | *Note POSIX Safety Concepts::.
  3481. This function defines the conversion specifier character SPEC.
  3482. Thus, if SPEC is ‘'Y'’, it defines the conversion ‘%Y’. You can
  3483. redefine the built-in conversions like ‘%s’, but flag characters
  3484. like ‘#’ and type modifiers like ‘l’ can never be used as
  3485. conversions; calling ‘register_printf_function’ for those
  3486. characters has no effect. It is advisable not to use lowercase
  3487. letters, since the ISO C standard warns that additional lowercase
  3488. letters may be standardized in future editions of the standard.
  3489. The HANDLER-FUNCTION is the function called by ‘printf’ and friends
  3490. when this conversion appears in a template string. *Note Defining
  3491. the Output Handler::, for information about how to define a
  3492. function to pass as this argument. If you specify a null pointer,
  3493. any existing handler function for SPEC is removed.
  3494. The ARGINFO-FUNCTION is the function called by
  3495. ‘parse_printf_format’ when this conversion appears in a template
  3496. string. *Note Parsing a Template String::, for information about
  3497. this.
  3498. *Attention:* In the GNU C Library versions before 2.0 the
  3499. ARGINFO-FUNCTION function did not need to be installed unless the
  3500. user used the ‘parse_printf_format’ function. This has changed.
  3501. Now a call to any of the ‘printf’ functions will call this function
  3502. when this format specifier appears in the format string.
  3503. The return value is ‘0’ on success, and ‘-1’ on failure (which
  3504. occurs if SPEC is out of range).
  3505. *Portability Note:* It is possible to redefine the standard output
  3506. conversions but doing so is strongly discouraged because it may
  3507. interfere with the behavior of programs and compiler
  3508. implementations that assume the effects of the conversions conform
  3509. to the relevant language standards. In addition, conforming
  3510. compilers need not guarantee that the function registered for a
  3511. standard conversion will be called for each such conversion in
  3512. every format string in a program.
  3513. 
  3514. File: libc.info, Node: Conversion Specifier Options, Next: Defining the Output Handler, Prev: Registering New Conversions, Up: Customizing Printf
  3515. 12.13.2 Conversion Specifier Options
  3516. ------------------------------------
  3517. If you define a meaning for ‘%A’, what if the template contains ‘%+23A’
  3518. or ‘%-#A’? To implement a sensible meaning for these, the handler when
  3519. called needs to be able to get the options specified in the template.
  3520. Both the HANDLER-FUNCTION and ARGINFO-FUNCTION accept an argument
  3521. that points to a ‘struct printf_info’, which contains information about
  3522. the options appearing in an instance of the conversion specifier. This
  3523. data type is declared in the header file ‘printf.h’.
  3524. -- Type: struct printf_info
  3525. This structure is used to pass information about the options
  3526. appearing in an instance of a conversion specifier in a ‘printf’
  3527. template string to the handler and arginfo functions for that
  3528. specifier. It contains the following members:
  3529. ‘int prec’
  3530. This is the precision specified. The value is ‘-1’ if no
  3531. precision was specified. If the precision was given as ‘*’,
  3532. the ‘printf_info’ structure passed to the handler function
  3533. contains the actual value retrieved from the argument list.
  3534. But the structure passed to the arginfo function contains a
  3535. value of ‘INT_MIN’, since the actual value is not known.
  3536. ‘int width’
  3537. This is the minimum field width specified. The value is ‘0’
  3538. if no width was specified. If the field width was given as
  3539. ‘*’, the ‘printf_info’ structure passed to the handler
  3540. function contains the actual value retrieved from the argument
  3541. list. But the structure passed to the arginfo function
  3542. contains a value of ‘INT_MIN’, since the actual value is not
  3543. known.
  3544. ‘wchar_t spec’
  3545. This is the conversion specifier character specified. It’s
  3546. stored in the structure so that you can register the same
  3547. handler function for multiple characters, but still have a way
  3548. to tell them apart when the handler function is called.
  3549. ‘unsigned int is_long_double’
  3550. This is a boolean that is true if the ‘L’, ‘ll’, or ‘q’ type
  3551. modifier was specified. For integer conversions, this
  3552. indicates ‘long long int’, as opposed to ‘long double’ for
  3553. floating point conversions.
  3554. ‘unsigned int is_char’
  3555. This is a boolean that is true if the ‘hh’ type modifier was
  3556. specified.
  3557. ‘unsigned int is_short’
  3558. This is a boolean that is true if the ‘h’ type modifier was
  3559. specified.
  3560. ‘unsigned int is_long’
  3561. This is a boolean that is true if the ‘l’ type modifier was
  3562. specified.
  3563. ‘unsigned int alt’
  3564. This is a boolean that is true if the ‘#’ flag was specified.
  3565. ‘unsigned int space’
  3566. This is a boolean that is true if the ‘ ’ flag was specified.
  3567. ‘unsigned int left’
  3568. This is a boolean that is true if the ‘-’ flag was specified.
  3569. ‘unsigned int showsign’
  3570. This is a boolean that is true if the ‘+’ flag was specified.
  3571. ‘unsigned int group’
  3572. This is a boolean that is true if the ‘'’ flag was specified.
  3573. ‘unsigned int extra’
  3574. This flag has a special meaning depending on the context. It
  3575. could be used freely by the user-defined handlers but when
  3576. called from the ‘printf’ function this variable always
  3577. contains the value ‘0’.
  3578. ‘unsigned int wide’
  3579. This flag is set if the stream is wide oriented.
  3580. ‘wchar_t pad’
  3581. This is the character to use for padding the output to the
  3582. minimum field width. The value is ‘'0'’ if the ‘0’ flag was
  3583. specified, and ‘' '’ otherwise.
  3584. 
  3585. File: libc.info, Node: Defining the Output Handler, Next: Printf Extension Example, Prev: Conversion Specifier Options, Up: Customizing Printf
  3586. 12.13.3 Defining the Output Handler
  3587. -----------------------------------
  3588. Now let’s look at how to define the handler and arginfo functions which
  3589. are passed as arguments to ‘register_printf_function’.
  3590. *Compatibility Note:* The interface changed in the GNU C Library
  3591. version 2.0. Previously the third argument was of type ‘va_list *’.
  3592. You should define your handler functions with a prototype like:
  3593. int FUNCTION (FILE *stream, const struct printf_info *info,
  3594. const void *const *args)
  3595. The STREAM argument passed to the handler function is the stream to
  3596. which it should write output.
  3597. The INFO argument is a pointer to a structure that contains
  3598. information about the various options that were included with the
  3599. conversion in the template string. You should not modify this structure
  3600. inside your handler function. *Note Conversion Specifier Options::, for
  3601. a description of this data structure.
  3602. The ARGS is a vector of pointers to the arguments data. The number
  3603. of arguments was determined by calling the argument information function
  3604. provided by the user.
  3605. Your handler function should return a value just like ‘printf’ does:
  3606. it should return the number of characters it has written, or a negative
  3607. value to indicate an error.
  3608. -- Data Type: printf_function
  3609. This is the data type that a handler function should have.
  3610. If you are going to use ‘parse_printf_format’ in your application,
  3611. you must also define a function to pass as the ARGINFO-FUNCTION argument
  3612. for each new conversion you install with ‘register_printf_function’.
  3613. You have to define these functions with a prototype like:
  3614. int FUNCTION (const struct printf_info *info,
  3615. size_t n, int *argtypes)
  3616. The return value from the function should be the number of arguments
  3617. the conversion expects. The function should also fill in no more than N
  3618. elements of the ARGTYPES array with information about the types of each
  3619. of these arguments. This information is encoded using the various ‘PA_’
  3620. macros. (You will notice that this is the same calling convention
  3621. ‘parse_printf_format’ itself uses.)
  3622. -- Data Type: printf_arginfo_function
  3623. This type is used to describe functions that return information
  3624. about the number and type of arguments used by a conversion
  3625. specifier.
  3626. 
  3627. File: libc.info, Node: Printf Extension Example, Next: Predefined Printf Handlers, Prev: Defining the Output Handler, Up: Customizing Printf
  3628. 12.13.4 ‘printf’ Extension Example
  3629. ----------------------------------
  3630. Here is an example showing how to define a ‘printf’ handler function.
  3631. This program defines a data structure called a ‘Widget’ and defines the
  3632. ‘%W’ conversion to print information about ‘Widget *’ arguments,
  3633. including the pointer value and the name stored in the data structure.
  3634. The ‘%W’ conversion supports the minimum field width and
  3635. left-justification options, but ignores everything else.
  3636. #include <stdio.h>
  3637. #include <stdlib.h>
  3638. #include <printf.h>
  3639. typedef struct
  3640. {
  3641. char *name;
  3642. }
  3643. Widget;
  3644. int
  3645. print_widget (FILE *stream,
  3646. const struct printf_info *info,
  3647. const void *const *args)
  3648. {
  3649. const Widget *w;
  3650. char *buffer;
  3651. int len;
  3652. /* Format the output into a string. */
  3653. w = *((const Widget **) (args[0]));
  3654. len = asprintf (&buffer, "<Widget %p: %s>", w, w->name);
  3655. if (len == -1)
  3656. return -1;
  3657. /* Pad to the minimum field width and print to the stream. */
  3658. len = fprintf (stream, "%*s",
  3659. (info->left ? -info->width : info->width),
  3660. buffer);
  3661. /* Clean up and return. */
  3662. free (buffer);
  3663. return len;
  3664. }
  3665. int
  3666. print_widget_arginfo (const struct printf_info *info, size_t n,
  3667. int *argtypes)
  3668. {
  3669. /* We always take exactly one argument and this is a pointer to the
  3670. structure.. */
  3671. if (n > 0)
  3672. argtypes[0] = PA_POINTER;
  3673. return 1;
  3674. }
  3675. int
  3676. main (void)
  3677. {
  3678. /* Make a widget to print. */
  3679. Widget mywidget;
  3680. mywidget.name = "mywidget";
  3681. /* Register the print function for widgets. */
  3682. register_printf_function ('W', print_widget, print_widget_arginfo);
  3683. /* Now print the widget. */
  3684. printf ("|%W|\n", &mywidget);
  3685. printf ("|%35W|\n", &mywidget);
  3686. printf ("|%-35W|\n", &mywidget);
  3687. return 0;
  3688. }
  3689. The output produced by this program looks like:
  3690. |<Widget 0xffeffb7c: mywidget>|
  3691. | <Widget 0xffeffb7c: mywidget>|
  3692. |<Widget 0xffeffb7c: mywidget> |
  3693. 
  3694. File: libc.info, Node: Predefined Printf Handlers, Prev: Printf Extension Example, Up: Customizing Printf
  3695. 12.13.5 Predefined ‘printf’ Handlers
  3696. ------------------------------------
  3697. The GNU C Library also contains a concrete and useful application of the
  3698. ‘printf’ handler extension. There are two functions available which
  3699. implement a special way to print floating-point numbers.
  3700. -- Function: int printf_size (FILE *FP, const struct printf_info *INFO,
  3701. const void *const *ARGS)
  3702. Preliminary: | MT-Safe race:fp locale | AS-Unsafe corrupt heap |
  3703. AC-Unsafe mem corrupt | *Note POSIX Safety Concepts::.
  3704. Print a given floating point number as for the format ‘%f’ except
  3705. that there is a postfix character indicating the divisor for the
  3706. number to make this less than 1000. There are two possible
  3707. divisors: powers of 1024 or powers of 1000. Which one is used
  3708. depends on the format character specified while registered this
  3709. handler. If the character is of lower case, 1024 is used. For
  3710. upper case characters, 1000 is used.
  3711. The postfix tag corresponds to bytes, kilobytes, megabytes,
  3712. gigabytes, etc. The full table is:
  3713. low Multiplier From Upper Multiplier
  3714. ’ ’ 1 ’ ’ 1
  3715. k 2^10 (1024) kilo K 10^3 (1000)
  3716. m 2^20 mega M 10^6
  3717. g 2^30 giga G 10^9
  3718. t 2^40 tera T 10^12
  3719. p 2^50 peta P 10^15
  3720. e 2^60 exa E 10^18
  3721. z 2^70 zetta Z 10^21
  3722. y 2^80 yotta Y 10^24
  3723. The default precision is 3, i.e., 1024 is printed with a lower-case
  3724. format character as if it were ‘%.3fk’ and will yield ‘1.000k’.
  3725. Due to the requirements of ‘register_printf_function’ we must also
  3726. provide the function which returns information about the arguments.
  3727. -- Function: int printf_size_info (const struct printf_info *INFO,
  3728. size_t N, int *ARGTYPES)
  3729. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3730. Concepts::.
  3731. This function will return in ARGTYPES the information about the
  3732. used parameters in the way the ‘vfprintf’ implementation expects
  3733. it. The format always takes one argument.
  3734. To use these functions both functions must be registered with a call
  3735. like
  3736. register_printf_function ('B', printf_size, printf_size_info);
  3737. Here we register the functions to print numbers as powers of 1000
  3738. since the format character ‘'B'’ is an upper-case character. If we
  3739. would additionally use ‘'b'’ in a line like
  3740. register_printf_function ('b', printf_size, printf_size_info);
  3741. we could also print using a power of 1024. Please note that all that is
  3742. different in these two lines is the format specifier. The ‘printf_size’
  3743. function knows about the difference between lower and upper case format
  3744. specifiers.
  3745. The use of ‘'B'’ and ‘'b'’ is no coincidence. Rather it is the
  3746. preferred way to use this functionality since it is available on some
  3747. other systems which also use format specifiers.
  3748. 
  3749. File: libc.info, Node: Formatted Input, Next: EOF and Errors, Prev: Customizing Printf, Up: I/O on Streams
  3750. 12.14 Formatted Input
  3751. =====================
  3752. The functions described in this section (‘scanf’ and related functions)
  3753. provide facilities for formatted input analogous to the formatted output
  3754. facilities. These functions provide a mechanism for reading arbitrary
  3755. values under the control of a “format string” or “template string”.
  3756. * Menu:
  3757. * Formatted Input Basics:: Some basics to get you started.
  3758. * Input Conversion Syntax:: Syntax of conversion specifications.
  3759. * Table of Input Conversions:: Summary of input conversions and what they do.
  3760. * Numeric Input Conversions:: Details of conversions for reading numbers.
  3761. * String Input Conversions:: Details of conversions for reading strings.
  3762. * Dynamic String Input:: String conversions that ‘malloc’ the buffer.
  3763. * Other Input Conversions:: Details of miscellaneous other conversions.
  3764. * Formatted Input Functions:: Descriptions of the actual functions.
  3765. * Variable Arguments Input:: ‘vscanf’ and friends.
  3766. 
  3767. File: libc.info, Node: Formatted Input Basics, Next: Input Conversion Syntax, Up: Formatted Input
  3768. 12.14.1 Formatted Input Basics
  3769. ------------------------------
  3770. Calls to ‘scanf’ are superficially similar to calls to ‘printf’ in that
  3771. arbitrary arguments are read under the control of a template string.
  3772. While the syntax of the conversion specifications in the template is
  3773. very similar to that for ‘printf’, the interpretation of the template is
  3774. oriented more towards free-format input and simple pattern matching,
  3775. rather than fixed-field formatting. For example, most ‘scanf’
  3776. conversions skip over any amount of “white space” (including spaces,
  3777. tabs, and newlines) in the input file, and there is no concept of
  3778. precision for the numeric input conversions as there is for the
  3779. corresponding output conversions. Ordinarily, non-whitespace characters
  3780. in the template are expected to match characters in the input stream
  3781. exactly, but a matching failure is distinct from an input error on the
  3782. stream.
  3783. Another area of difference between ‘scanf’ and ‘printf’ is that you
  3784. must remember to supply pointers rather than immediate values as the
  3785. optional arguments to ‘scanf’; the values that are read are stored in
  3786. the objects that the pointers point to. Even experienced programmers
  3787. tend to forget this occasionally, so if your program is getting strange
  3788. errors that seem to be related to ‘scanf’, you might want to
  3789. double-check this.
  3790. When a “matching failure” occurs, ‘scanf’ returns immediately,
  3791. leaving the first non-matching character as the next character to be
  3792. read from the stream. The normal return value from ‘scanf’ is the
  3793. number of values that were assigned, so you can use this to determine if
  3794. a matching error happened before all the expected values were read.
  3795. The ‘scanf’ function is typically used for things like reading in the
  3796. contents of tables. For example, here is a function that uses ‘scanf’
  3797. to initialize an array of ‘double’:
  3798. void
  3799. readarray (double *array, int n)
  3800. {
  3801. int i;
  3802. for (i=0; i<n; i++)
  3803. if (scanf (" %lf", &(array[i])) != 1)
  3804. invalid_input_error ();
  3805. }
  3806. The formatted input functions are not used as frequently as the
  3807. formatted output functions. Partly, this is because it takes some care
  3808. to use them properly. Another reason is that it is difficult to recover
  3809. from a matching error.
  3810. If you are trying to read input that doesn’t match a single, fixed
  3811. pattern, you may be better off using a tool such as Flex to generate a
  3812. lexical scanner, or Bison to generate a parser, rather than using
  3813. ‘scanf’. For more information about these tools, see *note
  3814. (flex.info)Top::, and *note (bison.info)Top::.
  3815. 
  3816. File: libc.info, Node: Input Conversion Syntax, Next: Table of Input Conversions, Prev: Formatted Input Basics, Up: Formatted Input
  3817. 12.14.2 Input Conversion Syntax
  3818. -------------------------------
  3819. A ‘scanf’ template string is a string that contains ordinary multibyte
  3820. characters interspersed with conversion specifications that start with
  3821. ‘%’.
  3822. Any whitespace character (as defined by the ‘isspace’ function; *note
  3823. Classification of Characters::) in the template causes any number of
  3824. whitespace characters in the input stream to be read and discarded. The
  3825. whitespace characters that are matched need not be exactly the same
  3826. whitespace characters that appear in the template string. For example,
  3827. write ‘ , ’ in the template to recognize a comma with optional
  3828. whitespace before and after.
  3829. Other characters in the template string that are not part of
  3830. conversion specifications must match characters in the input stream
  3831. exactly; if this is not the case, a matching failure occurs.
  3832. The conversion specifications in a ‘scanf’ template string have the
  3833. general form:
  3834. % FLAGS WIDTH TYPE CONVERSION
  3835. In more detail, an input conversion specification consists of an
  3836. initial ‘%’ character followed in sequence by:
  3837. • An optional “flag character” ‘*’, which says to ignore the text
  3838. read for this specification. When ‘scanf’ finds a conversion
  3839. specification that uses this flag, it reads input as directed by
  3840. the rest of the conversion specification, but it discards this
  3841. input, does not use a pointer argument, and does not increment the
  3842. count of successful assignments.
  3843. • An optional flag character ‘a’ (valid with string conversions only)
  3844. which requests allocation of a buffer long enough to store the
  3845. string in. (This is a GNU extension.) *Note Dynamic String
  3846. Input::.
  3847. • An optional decimal integer that specifies the “maximum field
  3848. width”. Reading of characters from the input stream stops either
  3849. when this maximum is reached or when a non-matching character is
  3850. found, whichever happens first. Most conversions discard initial
  3851. whitespace characters (those that don’t are explicitly documented),
  3852. and these discarded characters don’t count towards the maximum
  3853. field width. String input conversions store a null character to
  3854. mark the end of the input; the maximum field width does not include
  3855. this terminator.
  3856. • An optional “type modifier character”. For example, you can
  3857. specify a type modifier of ‘l’ with integer conversions such as
  3858. ‘%d’ to specify that the argument is a pointer to a ‘long int’
  3859. rather than a pointer to an ‘int’.
  3860. • A character that specifies the conversion to be applied.
  3861. The exact options that are permitted and how they are interpreted
  3862. vary between the different conversion specifiers. See the descriptions
  3863. of the individual conversions for information about the particular
  3864. options that they allow.
  3865. With the ‘-Wformat’ option, the GNU C compiler checks calls to
  3866. ‘scanf’ and related functions. It examines the format string and
  3867. verifies that the correct number and types of arguments are supplied.
  3868. There is also a GNU C syntax to tell the compiler that a function you
  3869. write uses a ‘scanf’-style format string. *Note Declaring Attributes of
  3870. Functions: (gcc)Function Attributes, for more information.
  3871. 
  3872. File: libc.info, Node: Table of Input Conversions, Next: Numeric Input Conversions, Prev: Input Conversion Syntax, Up: Formatted Input
  3873. 12.14.3 Table of Input Conversions
  3874. ----------------------------------
  3875. Here is a table that summarizes the various conversion specifications:
  3876. ‘%d’
  3877. Matches an optionally signed integer written in decimal. *Note
  3878. Numeric Input Conversions::.
  3879. ‘%i’
  3880. Matches an optionally signed integer in any of the formats that the
  3881. C language defines for specifying an integer constant. *Note
  3882. Numeric Input Conversions::.
  3883. ‘%o’
  3884. Matches an unsigned integer written in octal radix. *Note Numeric
  3885. Input Conversions::.
  3886. ‘%u’
  3887. Matches an unsigned integer written in decimal radix. *Note
  3888. Numeric Input Conversions::.
  3889. ‘%x’, ‘%X’
  3890. Matches an unsigned integer written in hexadecimal radix. *Note
  3891. Numeric Input Conversions::.
  3892. ‘%e’, ‘%f’, ‘%g’, ‘%E’, ‘%G’
  3893. Matches an optionally signed floating-point number. *Note Numeric
  3894. Input Conversions::.
  3895. ‘%s’
  3896. Matches a string containing only non-whitespace characters. *Note
  3897. String Input Conversions::. The presence of the ‘l’ modifier
  3898. determines whether the output is stored as a wide character string
  3899. or a multibyte string. If ‘%s’ is used in a wide character
  3900. function the string is converted as with multiple calls to
  3901. ‘wcrtomb’ into a multibyte string. This means that the buffer must
  3902. provide room for ‘MB_CUR_MAX’ bytes for each wide character read.
  3903. In case ‘%ls’ is used in a multibyte function the result is
  3904. converted into wide characters as with multiple calls of ‘mbrtowc’
  3905. before being stored in the user provided buffer.
  3906. ‘%S’
  3907. This is an alias for ‘%ls’ which is supported for compatibility
  3908. with the Unix standard.
  3909. ‘%[’
  3910. Matches a string of characters that belong to a specified set.
  3911. *Note String Input Conversions::. The presence of the ‘l’ modifier
  3912. determines whether the output is stored as a wide character string
  3913. or a multibyte string. If ‘%[’ is used in a wide character
  3914. function the string is converted as with multiple calls to
  3915. ‘wcrtomb’ into a multibyte string. This means that the buffer must
  3916. provide room for ‘MB_CUR_MAX’ bytes for each wide character read.
  3917. In case ‘%l[’ is used in a multibyte function the result is
  3918. converted into wide characters as with multiple calls of ‘mbrtowc’
  3919. before being stored in the user provided buffer.
  3920. ‘%c’
  3921. Matches a string of one or more characters; the number of
  3922. characters read is controlled by the maximum field width given for
  3923. the conversion. *Note String Input Conversions::.
  3924. If ‘%c’ is used in a wide stream function the read value is
  3925. converted from a wide character to the corresponding multibyte
  3926. character before storing it. Note that this conversion can produce
  3927. more than one byte of output and therefore the provided buffer must
  3928. be large enough for up to ‘MB_CUR_MAX’ bytes for each character.
  3929. If ‘%lc’ is used in a multibyte function the input is treated as a
  3930. multibyte sequence (and not bytes) and the result is converted as
  3931. with calls to ‘mbrtowc’.
  3932. ‘%C’
  3933. This is an alias for ‘%lc’ which is supported for compatibility
  3934. with the Unix standard.
  3935. ‘%p’
  3936. Matches a pointer value in the same implementation-defined format
  3937. used by the ‘%p’ output conversion for ‘printf’. *Note Other Input
  3938. Conversions::.
  3939. ‘%n’
  3940. This conversion doesn’t read any characters; it records the number
  3941. of characters read so far by this call. *Note Other Input
  3942. Conversions::.
  3943. ‘%%’
  3944. This matches a literal ‘%’ character in the input stream. No
  3945. corresponding argument is used. *Note Other Input Conversions::.
  3946. If the syntax of a conversion specification is invalid, the behavior
  3947. is undefined. If there aren’t enough function arguments provided to
  3948. supply addresses for all the conversion specifications in the template
  3949. strings that perform assignments, or if the arguments are not of the
  3950. correct types, the behavior is also undefined. On the other hand, extra
  3951. arguments are simply ignored.
  3952. 
  3953. File: libc.info, Node: Numeric Input Conversions, Next: String Input Conversions, Prev: Table of Input Conversions, Up: Formatted Input
  3954. 12.14.4 Numeric Input Conversions
  3955. ---------------------------------
  3956. This section describes the ‘scanf’ conversions for reading numeric
  3957. values.
  3958. The ‘%d’ conversion matches an optionally signed integer in decimal
  3959. radix. The syntax that is recognized is the same as that for the
  3960. ‘strtol’ function (*note Parsing of Integers::) with the value ‘10’ for
  3961. the BASE argument.
  3962. The ‘%i’ conversion matches an optionally signed integer in any of
  3963. the formats that the C language defines for specifying an integer
  3964. constant. The syntax that is recognized is the same as that for the
  3965. ‘strtol’ function (*note Parsing of Integers::) with the value ‘0’ for
  3966. the BASE argument. (You can print integers in this syntax with ‘printf’
  3967. by using the ‘#’ flag character with the ‘%x’, ‘%o’, or ‘%d’ conversion.
  3968. *Note Integer Conversions::.)
  3969. For example, any of the strings ‘10’, ‘0xa’, or ‘012’ could be read
  3970. in as integers under the ‘%i’ conversion. Each of these specifies a
  3971. number with decimal value ‘10’.
  3972. The ‘%o’, ‘%u’, and ‘%x’ conversions match unsigned integers in
  3973. octal, decimal, and hexadecimal radices, respectively. The syntax that
  3974. is recognized is the same as that for the ‘strtoul’ function (*note
  3975. Parsing of Integers::) with the appropriate value (‘8’, ‘10’, or ‘16’)
  3976. for the BASE argument.
  3977. The ‘%X’ conversion is identical to the ‘%x’ conversion. They both
  3978. permit either uppercase or lowercase letters to be used as digits.
  3979. The default type of the corresponding argument for the ‘%d’ and ‘%i’
  3980. conversions is ‘int *’, and ‘unsigned int *’ for the other integer
  3981. conversions. You can use the following type modifiers to specify other
  3982. sizes of integer:
  3983. ‘hh’
  3984. Specifies that the argument is a ‘signed char *’ or ‘unsigned char
  3985. *’.
  3986. This modifier was introduced in ISO C99.
  3987. ‘h’
  3988. Specifies that the argument is a ‘short int *’ or ‘unsigned short
  3989. int *’.
  3990. ‘j’
  3991. Specifies that the argument is a ‘intmax_t *’ or ‘uintmax_t *’.
  3992. This modifier was introduced in ISO C99.
  3993. ‘l’
  3994. Specifies that the argument is a ‘long int *’ or ‘unsigned long int
  3995. *’. Two ‘l’ characters is like the ‘L’ modifier, below.
  3996. If used with ‘%c’ or ‘%s’ the corresponding parameter is considered
  3997. as a pointer to a wide character or wide character string
  3998. respectively. This use of ‘l’ was introduced in Amendment 1 to
  3999. ISO C90.
  4000. ‘ll’
  4001. ‘L’
  4002. ‘q’
  4003. Specifies that the argument is a ‘long long int *’ or ‘unsigned
  4004. long long int *’. (The ‘long long’ type is an extension supported
  4005. by the GNU C compiler. For systems that don’t provide extra-long
  4006. integers, this is the same as ‘long int’.)
  4007. The ‘q’ modifier is another name for the same thing, which comes
  4008. from 4.4 BSD; a ‘long long int’ is sometimes called a “quad” ‘int’.
  4009. ‘t’
  4010. Specifies that the argument is a ‘ptrdiff_t *’.
  4011. This modifier was introduced in ISO C99.
  4012. ‘z’
  4013. Specifies that the argument is a ‘size_t *’.
  4014. This modifier was introduced in ISO C99.
  4015. All of the ‘%e’, ‘%f’, ‘%g’, ‘%E’, and ‘%G’ input conversions are
  4016. interchangeable. They all match an optionally signed floating point
  4017. number, in the same syntax as for the ‘strtod’ function (*note Parsing
  4018. of Floats::).
  4019. For the floating-point input conversions, the default argument type
  4020. is ‘float *’. (This is different from the corresponding output
  4021. conversions, where the default type is ‘double’; remember that ‘float’
  4022. arguments to ‘printf’ are converted to ‘double’ by the default argument
  4023. promotions, but ‘float *’ arguments are not promoted to ‘double *’.)
  4024. You can specify other sizes of float using these type modifiers:
  4025. ‘l’
  4026. Specifies that the argument is of type ‘double *’.
  4027. ‘L’
  4028. Specifies that the argument is of type ‘long double *’.
  4029. For all the above number parsing formats there is an additional
  4030. optional flag ‘'’. When this flag is given the ‘scanf’ function expects
  4031. the number represented in the input string to be formatted according to
  4032. the grouping rules of the currently selected locale (*note General
  4033. Numeric::).
  4034. If the ‘"C"’ or ‘"POSIX"’ locale is selected there is no difference.
  4035. But for a locale which specifies values for the appropriate fields in
  4036. the locale the input must have the correct form in the input. Otherwise
  4037. the longest prefix with a correct form is processed.
  4038. 
  4039. File: libc.info, Node: String Input Conversions, Next: Dynamic String Input, Prev: Numeric Input Conversions, Up: Formatted Input
  4040. 12.14.5 String Input Conversions
  4041. --------------------------------
  4042. This section describes the ‘scanf’ input conversions for reading string
  4043. and character values: ‘%s’, ‘%S’, ‘%[’, ‘%c’, and ‘%C’.
  4044. You have two options for how to receive the input from these
  4045. conversions:
  4046. • Provide a buffer to store it in. This is the default. You should
  4047. provide an argument of type ‘char *’ or ‘wchar_t *’ (the latter if
  4048. the ‘l’ modifier is present).
  4049. *Warning:* To make a robust program, you must make sure that the
  4050. input (plus its terminating null) cannot possibly exceed the size
  4051. of the buffer you provide. In general, the only way to do this is
  4052. to specify a maximum field width one less than the buffer size.
  4053. *If you provide the buffer, always specify a maximum field width to
  4054. prevent overflow.*
  4055. • Ask ‘scanf’ to allocate a big enough buffer, by specifying the ‘a’
  4056. flag character. This is a GNU extension. You should provide an
  4057. argument of type ‘char **’ for the buffer address to be stored in.
  4058. *Note Dynamic String Input::.
  4059. The ‘%c’ conversion is the simplest: it matches a fixed number of
  4060. characters, always. The maximum field width says how many characters to
  4061. read; if you don’t specify the maximum, the default is 1. This
  4062. conversion doesn’t append a null character to the end of the text it
  4063. reads. It also does not skip over initial whitespace characters. It
  4064. reads precisely the next N characters, and fails if it cannot get that
  4065. many. Since there is always a maximum field width with ‘%c’ (whether
  4066. specified, or 1 by default), you can always prevent overflow by making
  4067. the buffer long enough.
  4068. If the format is ‘%lc’ or ‘%C’ the function stores wide characters
  4069. which are converted using the conversion determined at the time the
  4070. stream was opened from the external byte stream. The number of bytes
  4071. read from the medium is limited by ‘MB_CUR_LEN * N’ but at most N wide
  4072. characters get stored in the output string.
  4073. The ‘%s’ conversion matches a string of non-whitespace characters.
  4074. It skips and discards initial whitespace, but stops when it encounters
  4075. more whitespace after having read something. It stores a null character
  4076. at the end of the text that it reads.
  4077. For example, reading the input:
  4078. hello, world
  4079. with the conversion ‘%10c’ produces ‘" hello, wo"’, but reading the same
  4080. input with the conversion ‘%10s’ produces ‘"hello,"’.
  4081. *Warning:* If you do not specify a field width for ‘%s’, then the
  4082. number of characters read is limited only by where the next whitespace
  4083. character appears. This almost certainly means that invalid input can
  4084. make your program crash—which is a bug.
  4085. The ‘%ls’ and ‘%S’ format are handled just like ‘%s’ except that the
  4086. external byte sequence is converted using the conversion associated with
  4087. the stream to wide characters with their own encoding. A width or
  4088. precision specified with the format do not directly determine how many
  4089. bytes are read from the stream since they measure wide characters. But
  4090. an upper limit can be computed by multiplying the value of the width or
  4091. precision by ‘MB_CUR_MAX’.
  4092. To read in characters that belong to an arbitrary set of your choice,
  4093. use the ‘%[’ conversion. You specify the set between the ‘[’ character
  4094. and a following ‘]’ character, using the same syntax used in regular
  4095. expressions for explicit sets of characters. As special cases:
  4096. • A literal ‘]’ character can be specified as the first character of
  4097. the set.
  4098. • An embedded ‘-’ character (that is, one that is not the first or
  4099. last character of the set) is used to specify a range of
  4100. characters.
  4101. • If a caret character ‘^’ immediately follows the initial ‘[’, then
  4102. the set of allowed input characters is everything _except_ the
  4103. characters listed.
  4104. The ‘%[’ conversion does not skip over initial whitespace characters.
  4105. Note that the “character class” syntax available in character sets
  4106. that appear inside regular expressions (such as ‘[:alpha:]’) is _not_
  4107. available in the ‘%[’ conversion.
  4108. Here are some examples of ‘%[’ conversions and what they mean:
  4109. ‘%25[1234567890]’
  4110. Matches a string of up to 25 digits.
  4111. ‘%25[][]’
  4112. Matches a string of up to 25 square brackets.
  4113. ‘%25[^ \f\n\r\t\v]’
  4114. Matches a string up to 25 characters long that doesn’t contain any
  4115. of the standard whitespace characters. This is slightly different
  4116. from ‘%s’, because if the input begins with a whitespace character,
  4117. ‘%[’ reports a matching failure while ‘%s’ simply discards the
  4118. initial whitespace.
  4119. ‘%25[a-z]’
  4120. Matches up to 25 lowercase characters.
  4121. As for ‘%c’ and ‘%s’ the ‘%[’ format is also modified to produce wide
  4122. characters if the ‘l’ modifier is present. All what is said about ‘%ls’
  4123. above is true for ‘%l[’.
  4124. One more reminder: the ‘%s’ and ‘%[’ conversions are *dangerous* if
  4125. you don’t specify a maximum width or use the ‘a’ flag, because input too
  4126. long would overflow whatever buffer you have provided for it. No matter
  4127. how long your buffer is, a user could supply input that is longer. A
  4128. well-written program reports invalid input with a comprehensible error
  4129. message, not with a crash.
  4130. 
  4131. File: libc.info, Node: Dynamic String Input, Next: Other Input Conversions, Prev: String Input Conversions, Up: Formatted Input
  4132. 12.14.6 Dynamically Allocating String Conversions
  4133. -------------------------------------------------
  4134. A GNU extension to formatted input lets you safely read a string with no
  4135. maximum size. Using this feature, you don’t supply a buffer; instead,
  4136. ‘scanf’ allocates a buffer big enough to hold the data and gives you its
  4137. address. To use this feature, write ‘a’ as a flag character, as in
  4138. ‘%as’ or ‘%a[0-9a-z]’.
  4139. The pointer argument you supply for where to store the input should
  4140. have type ‘char **’. The ‘scanf’ function allocates a buffer and stores
  4141. its address in the word that the argument points to. You should free
  4142. the buffer with ‘free’ when you no longer need it.
  4143. Here is an example of using the ‘a’ flag with the ‘%[...]’ conversion
  4144. specification to read a “variable assignment” of the form ‘VARIABLE =
  4145. VALUE’.
  4146. {
  4147. char *variable, *value;
  4148. if (2 > scanf ("%a[a-zA-Z0-9] = %a[^\n]\n",
  4149. &variable, &value))
  4150. {
  4151. invalid_input_error ();
  4152. return 0;
  4153. }
  4154. ...
  4155. }
  4156. 
  4157. File: libc.info, Node: Other Input Conversions, Next: Formatted Input Functions, Prev: Dynamic String Input, Up: Formatted Input
  4158. 12.14.7 Other Input Conversions
  4159. -------------------------------
  4160. This section describes the miscellaneous input conversions.
  4161. The ‘%p’ conversion is used to read a pointer value. It recognizes
  4162. the same syntax used by the ‘%p’ output conversion for ‘printf’ (*note
  4163. Other Output Conversions::); that is, a hexadecimal number just as the
  4164. ‘%x’ conversion accepts. The corresponding argument should be of type
  4165. ‘void **’; that is, the address of a place to store a pointer.
  4166. The resulting pointer value is not guaranteed to be valid if it was
  4167. not originally written during the same program execution that reads it
  4168. in.
  4169. The ‘%n’ conversion produces the number of characters read so far by
  4170. this call. The corresponding argument should be of type ‘int *’. This
  4171. conversion works in the same way as the ‘%n’ conversion for ‘printf’;
  4172. see *note Other Output Conversions::, for an example.
  4173. The ‘%n’ conversion is the only mechanism for determining the success
  4174. of literal matches or conversions with suppressed assignments. If the
  4175. ‘%n’ follows the locus of a matching failure, then no value is stored
  4176. for it since ‘scanf’ returns before processing the ‘%n’. If you store
  4177. ‘-1’ in that argument slot before calling ‘scanf’, the presence of ‘-1’
  4178. after ‘scanf’ indicates an error occurred before the ‘%n’ was reached.
  4179. Finally, the ‘%%’ conversion matches a literal ‘%’ character in the
  4180. input stream, without using an argument. This conversion does not
  4181. permit any flags, field width, or type modifier to be specified.
  4182. 
  4183. File: libc.info, Node: Formatted Input Functions, Next: Variable Arguments Input, Prev: Other Input Conversions, Up: Formatted Input
  4184. 12.14.8 Formatted Input Functions
  4185. ---------------------------------
  4186. Here are the descriptions of the functions for performing formatted
  4187. input. Prototypes for these functions are in the header file ‘stdio.h’.
  4188. -- Function: int scanf (const char *TEMPLATE, ...)
  4189. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  4190. mem lock corrupt | *Note POSIX Safety Concepts::.
  4191. The ‘scanf’ function reads formatted input from the stream ‘stdin’
  4192. under the control of the template string TEMPLATE. The optional
  4193. arguments are pointers to the places which receive the resulting
  4194. values.
  4195. The return value is normally the number of successful assignments.
  4196. If an end-of-file condition is detected before any matches are
  4197. performed, including matches against whitespace and literal
  4198. characters in the template, then ‘EOF’ is returned.
  4199. -- Function: int wscanf (const wchar_t *TEMPLATE, ...)
  4200. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  4201. mem lock corrupt | *Note POSIX Safety Concepts::.
  4202. The ‘wscanf’ function reads formatted input from the stream ‘stdin’
  4203. under the control of the template string TEMPLATE. The optional
  4204. arguments are pointers to the places which receive the resulting
  4205. values.
  4206. The return value is normally the number of successful assignments.
  4207. If an end-of-file condition is detected before any matches are
  4208. performed, including matches against whitespace and literal
  4209. characters in the template, then ‘WEOF’ is returned.
  4210. -- Function: int fscanf (FILE *STREAM, const char *TEMPLATE, ...)
  4211. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  4212. mem lock corrupt | *Note POSIX Safety Concepts::.
  4213. This function is just like ‘scanf’, except that the input is read
  4214. from the stream STREAM instead of ‘stdin’.
  4215. -- Function: int fwscanf (FILE *STREAM, const wchar_t *TEMPLATE, ...)
  4216. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  4217. mem lock corrupt | *Note POSIX Safety Concepts::.
  4218. This function is just like ‘wscanf’, except that the input is read
  4219. from the stream STREAM instead of ‘stdin’.
  4220. -- Function: int sscanf (const char *S, const char *TEMPLATE, ...)
  4221. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  4222. *Note POSIX Safety Concepts::.
  4223. This is like ‘scanf’, except that the characters are taken from the
  4224. null-terminated string S instead of from a stream. Reaching the
  4225. end of the string is treated as an end-of-file condition.
  4226. The behavior of this function is undefined if copying takes place
  4227. between objects that overlap—for example, if S is also given as an
  4228. argument to receive a string read under control of the ‘%s’, ‘%S’,
  4229. or ‘%[’ conversion.
  4230. -- Function: int swscanf (const wchar_t *WS, const wchar_t *TEMPLATE,
  4231. ...)
  4232. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  4233. *Note POSIX Safety Concepts::.
  4234. This is like ‘wscanf’, except that the characters are taken from
  4235. the null-terminated string WS instead of from a stream. Reaching
  4236. the end of the string is treated as an end-of-file condition.
  4237. The behavior of this function is undefined if copying takes place
  4238. between objects that overlap—for example, if WS is also given as an
  4239. argument to receive a string read under control of the ‘%s’, ‘%S’,
  4240. or ‘%[’ conversion.
  4241. 
  4242. File: libc.info, Node: Variable Arguments Input, Prev: Formatted Input Functions, Up: Formatted Input
  4243. 12.14.9 Variable Arguments Input Functions
  4244. ------------------------------------------
  4245. The functions ‘vscanf’ and friends are provided so that you can define
  4246. your own variadic ‘scanf’-like functions that make use of the same
  4247. internals as the built-in formatted output functions. These functions
  4248. are analogous to the ‘vprintf’ series of output functions. *Note
  4249. Variable Arguments Output::, for important information on how to use
  4250. them.
  4251. *Portability Note:* The functions listed in this section were
  4252. introduced in ISO C99 and were before available as GNU extensions.
  4253. -- Function: int vscanf (const char *TEMPLATE, va_list AP)
  4254. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  4255. mem lock corrupt | *Note POSIX Safety Concepts::.
  4256. This function is similar to ‘scanf’, but instead of taking a
  4257. variable number of arguments directly, it takes an argument list
  4258. pointer AP of type ‘va_list’ (*note Variadic Functions::).
  4259. -- Function: int vwscanf (const wchar_t *TEMPLATE, va_list AP)
  4260. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  4261. mem lock corrupt | *Note POSIX Safety Concepts::.
  4262. This function is similar to ‘wscanf’, but instead of taking a
  4263. variable number of arguments directly, it takes an argument list
  4264. pointer AP of type ‘va_list’ (*note Variadic Functions::).
  4265. -- Function: int vfscanf (FILE *STREAM, const char *TEMPLATE, va_list
  4266. AP)
  4267. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  4268. mem lock corrupt | *Note POSIX Safety Concepts::.
  4269. This is the equivalent of ‘fscanf’ with the variable argument list
  4270. specified directly as for ‘vscanf’.
  4271. -- Function: int vfwscanf (FILE *STREAM, const wchar_t *TEMPLATE,
  4272. va_list AP)
  4273. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  4274. mem lock corrupt | *Note POSIX Safety Concepts::.
  4275. This is the equivalent of ‘fwscanf’ with the variable argument list
  4276. specified directly as for ‘vwscanf’.
  4277. -- Function: int vsscanf (const char *S, const char *TEMPLATE, va_list
  4278. AP)
  4279. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  4280. *Note POSIX Safety Concepts::.
  4281. This is the equivalent of ‘sscanf’ with the variable argument list
  4282. specified directly as for ‘vscanf’.
  4283. -- Function: int vswscanf (const wchar_t *S, const wchar_t *TEMPLATE,
  4284. va_list AP)
  4285. Preliminary: | MT-Safe locale | AS-Unsafe heap | AC-Unsafe mem |
  4286. *Note POSIX Safety Concepts::.
  4287. This is the equivalent of ‘swscanf’ with the variable argument list
  4288. specified directly as for ‘vwscanf’.
  4289. In GNU C, there is a special construct you can use to let the
  4290. compiler know that a function uses a ‘scanf’-style format string. Then
  4291. it can check the number and types of arguments in each call to the
  4292. function, and warn you when they do not match the format string. For
  4293. details, see *note Declaring Attributes of Functions: (gcc)Function
  4294. Attributes.
  4295. 
  4296. File: libc.info, Node: EOF and Errors, Next: Error Recovery, Prev: Formatted Input, Up: I/O on Streams
  4297. 12.15 End-Of-File and Errors
  4298. ============================
  4299. Many of the functions described in this chapter return the value of the
  4300. macro ‘EOF’ to indicate unsuccessful completion of the operation. Since
  4301. ‘EOF’ is used to report both end of file and random errors, it’s often
  4302. better to use the ‘feof’ function to check explicitly for end of file
  4303. and ‘ferror’ to check for errors. These functions check indicators that
  4304. are part of the internal state of the stream object, indicators set if
  4305. the appropriate condition was detected by a previous I/O operation on
  4306. that stream.
  4307. -- Macro: int EOF
  4308. This macro is an integer value that is returned by a number of
  4309. narrow stream functions to indicate an end-of-file condition, or
  4310. some other error situation. With the GNU C Library, ‘EOF’ is ‘-1’.
  4311. In other libraries, its value may be some other negative number.
  4312. This symbol is declared in ‘stdio.h’.
  4313. -- Macro: int WEOF
  4314. This macro is an integer value that is returned by a number of wide
  4315. stream functions to indicate an end-of-file condition, or some
  4316. other error situation. With the GNU C Library, ‘WEOF’ is ‘-1’. In
  4317. other libraries, its value may be some other negative number.
  4318. This symbol is declared in ‘wchar.h’.
  4319. -- Function: int feof (FILE *STREAM)
  4320. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe lock | *Note POSIX
  4321. Safety Concepts::.
  4322. The ‘feof’ function returns nonzero if and only if the end-of-file
  4323. indicator for the stream STREAM is set.
  4324. This symbol is declared in ‘stdio.h’.
  4325. -- Function: int feof_unlocked (FILE *STREAM)
  4326. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4327. Concepts::.
  4328. The ‘feof_unlocked’ function is equivalent to the ‘feof’ function
  4329. except that it does not implicitly lock the stream.
  4330. This function is a GNU extension.
  4331. This symbol is declared in ‘stdio.h’.
  4332. -- Function: int ferror (FILE *STREAM)
  4333. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe lock | *Note POSIX
  4334. Safety Concepts::.
  4335. The ‘ferror’ function returns nonzero if and only if the error
  4336. indicator for the stream STREAM is set, indicating that an error
  4337. has occurred on a previous operation on the stream.
  4338. This symbol is declared in ‘stdio.h’.
  4339. -- Function: int ferror_unlocked (FILE *STREAM)
  4340. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4341. Concepts::.
  4342. The ‘ferror_unlocked’ function is equivalent to the ‘ferror’
  4343. function except that it does not implicitly lock the stream.
  4344. This function is a GNU extension.
  4345. This symbol is declared in ‘stdio.h’.
  4346. In addition to setting the error indicator associated with the
  4347. stream, the functions that operate on streams also set ‘errno’ in the
  4348. same way as the corresponding low-level functions that operate on file
  4349. descriptors. For example, all of the functions that perform output to a
  4350. stream—such as ‘fputc’, ‘printf’, and ‘fflush’—are implemented in terms
  4351. of ‘write’, and all of the ‘errno’ error conditions defined for ‘write’
  4352. are meaningful for these functions. For more information about the
  4353. descriptor-level I/O functions, see *note Low-Level I/O::.
  4354. 
  4355. File: libc.info, Node: Error Recovery, Next: Binary Streams, Prev: EOF and Errors, Up: I/O on Streams
  4356. 12.16 Recovering from errors
  4357. ============================
  4358. You may explicitly clear the error and EOF flags with the ‘clearerr’
  4359. function.
  4360. -- Function: void clearerr (FILE *STREAM)
  4361. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe lock | *Note POSIX
  4362. Safety Concepts::.
  4363. This function clears the end-of-file and error indicators for the
  4364. stream STREAM.
  4365. The file positioning functions (*note File Positioning::) also
  4366. clear the end-of-file indicator for the stream.
  4367. -- Function: void clearerr_unlocked (FILE *STREAM)
  4368. Preliminary: | MT-Safe race:stream | AS-Safe | AC-Safe | *Note
  4369. POSIX Safety Concepts::.
  4370. The ‘clearerr_unlocked’ function is equivalent to the ‘clearerr’
  4371. function except that it does not implicitly lock the stream.
  4372. This function is a GNU extension.
  4373. Note that it is _not_ correct to just clear the error flag and retry
  4374. a failed stream operation. After a failed write, any number of
  4375. characters since the last buffer flush may have been committed to the
  4376. file, while some buffered data may have been discarded. Merely retrying
  4377. can thus cause lost or repeated data.
  4378. A failed read may leave the file pointer in an inappropriate position
  4379. for a second try. In both cases, you should seek to a known position
  4380. before retrying.
  4381. Most errors that can happen are not recoverable — a second try will
  4382. always fail again in the same way. So usually it is best to give up and
  4383. report the error to the user, rather than install complicated recovery
  4384. logic.
  4385. One important exception is ‘EINTR’ (*note Interrupted Primitives::).
  4386. Many stream I/O implementations will treat it as an ordinary error,
  4387. which can be quite inconvenient. You can avoid this hassle by
  4388. installing all signals with the ‘SA_RESTART’ flag.
  4389. For similar reasons, setting nonblocking I/O on a stream’s file
  4390. descriptor is not usually advisable.
  4391. 
  4392. File: libc.info, Node: Binary Streams, Next: File Positioning, Prev: Error Recovery, Up: I/O on Streams
  4393. 12.17 Text and Binary Streams
  4394. =============================
  4395. GNU systems and other POSIX-compatible operating systems organize all
  4396. files as uniform sequences of characters. However, some other systems
  4397. make a distinction between files containing text and files containing
  4398. binary data, and the input and output facilities of ISO C provide for
  4399. this distinction. This section tells you how to write programs portable
  4400. to such systems.
  4401. When you open a stream, you can specify either a “text stream” or a
  4402. “binary stream”. You indicate that you want a binary stream by
  4403. specifying the ‘b’ modifier in the OPENTYPE argument to ‘fopen’; see
  4404. *note Opening Streams::. Without this option, ‘fopen’ opens the file as
  4405. a text stream.
  4406. Text and binary streams differ in several ways:
  4407. • The data read from a text stream is divided into “lines” which are
  4408. terminated by newline (‘'\n'’) characters, while a binary stream is
  4409. simply a long series of characters. A text stream might on some
  4410. systems fail to handle lines more than 254 characters long
  4411. (including the terminating newline character).
  4412. • On some systems, text files can contain only printing characters,
  4413. horizontal tab characters, and newlines, and so text streams may
  4414. not support other characters. However, binary streams can handle
  4415. any character value.
  4416. • Space characters that are written immediately preceding a newline
  4417. character in a text stream may disappear when the file is read in
  4418. again.
  4419. • More generally, there need not be a one-to-one mapping between
  4420. characters that are read from or written to a text stream, and the
  4421. characters in the actual file.
  4422. Since a binary stream is always more capable and more predictable
  4423. than a text stream, you might wonder what purpose text streams serve.
  4424. Why not simply always use binary streams? The answer is that on these
  4425. operating systems, text and binary streams use different file formats,
  4426. and the only way to read or write “an ordinary file of text” that can
  4427. work with other text-oriented programs is through a text stream.
  4428. In the GNU C Library, and on all POSIX systems, there is no
  4429. difference between text streams and binary streams. When you open a
  4430. stream, you get the same kind of stream regardless of whether you ask
  4431. for binary. This stream can handle any file content, and has none of
  4432. the restrictions that text streams sometimes have.
  4433. 
  4434. File: libc.info, Node: File Positioning, Next: Portable Positioning, Prev: Binary Streams, Up: I/O on Streams
  4435. 12.18 File Positioning
  4436. ======================
  4437. The “file position” of a stream describes where in the file the stream
  4438. is currently reading or writing. I/O on the stream advances the file
  4439. position through the file. On GNU systems, the file position is
  4440. represented as an integer, which counts the number of bytes from the
  4441. beginning of the file. *Note File Position::.
  4442. During I/O to an ordinary disk file, you can change the file position
  4443. whenever you wish, so as to read or write any portion of the file. Some
  4444. other kinds of files may also permit this. Files which support changing
  4445. the file position are sometimes referred to as “random-access” files.
  4446. You can use the functions in this section to examine or modify the
  4447. file position indicator associated with a stream. The symbols listed
  4448. below are declared in the header file ‘stdio.h’.
  4449. -- Function: long int ftell (FILE *STREAM)
  4450. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4451. | *Note POSIX Safety Concepts::.
  4452. This function returns the current file position of the stream
  4453. STREAM.
  4454. This function can fail if the stream doesn’t support file
  4455. positioning, or if the file position can’t be represented in a
  4456. ‘long int’, and possibly for other reasons as well. If a failure
  4457. occurs, a value of ‘-1’ is returned.
  4458. -- Function: off_t ftello (FILE *STREAM)
  4459. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4460. | *Note POSIX Safety Concepts::.
  4461. The ‘ftello’ function is similar to ‘ftell’, except that it returns
  4462. a value of type ‘off_t’. Systems which support this type use it to
  4463. describe all file positions, unlike the POSIX specification which
  4464. uses a long int. The two are not necessarily the same size.
  4465. Therefore, using ftell can lead to problems if the implementation
  4466. is written on top of a POSIX compliant low-level I/O
  4467. implementation, and using ‘ftello’ is preferable whenever it is
  4468. available.
  4469. If this function fails it returns ‘(off_t) -1’. This can happen
  4470. due to missing support for file positioning or internal errors.
  4471. Otherwise the return value is the current file position.
  4472. The function is an extension defined in the Unix Single
  4473. Specification version 2.
  4474. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  4475. 32 bit system this function is in fact ‘ftello64’. I.e., the LFS
  4476. interface transparently replaces the old interface.
  4477. -- Function: off64_t ftello64 (FILE *STREAM)
  4478. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4479. | *Note POSIX Safety Concepts::.
  4480. This function is similar to ‘ftello’ with the only difference that
  4481. the return value is of type ‘off64_t’. This also requires that the
  4482. stream STREAM was opened using either ‘fopen64’, ‘freopen64’, or
  4483. ‘tmpfile64’ since otherwise the underlying file operations to
  4484. position the file pointer beyond the 2^31 bytes limit might fail.
  4485. If the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a 32
  4486. bits machine this function is available under the name ‘ftello’ and
  4487. so transparently replaces the old interface.
  4488. -- Function: int fseek (FILE *STREAM, long int OFFSET, int WHENCE)
  4489. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4490. | *Note POSIX Safety Concepts::.
  4491. The ‘fseek’ function is used to change the file position of the
  4492. stream STREAM. The value of WHENCE must be one of the constants
  4493. ‘SEEK_SET’, ‘SEEK_CUR’, or ‘SEEK_END’, to indicate whether the
  4494. OFFSET is relative to the beginning of the file, the current file
  4495. position, or the end of the file, respectively.
  4496. This function returns a value of zero if the operation was
  4497. successful, and a nonzero value to indicate failure. A successful
  4498. call also clears the end-of-file indicator of STREAM and discards
  4499. any characters that were “pushed back” by the use of ‘ungetc’.
  4500. ‘fseek’ either flushes any buffered output before setting the file
  4501. position or else remembers it so it will be written later in its
  4502. proper place in the file.
  4503. -- Function: int fseeko (FILE *STREAM, off_t OFFSET, int WHENCE)
  4504. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4505. | *Note POSIX Safety Concepts::.
  4506. This function is similar to ‘fseek’ but it corrects a problem with
  4507. ‘fseek’ in a system with POSIX types. Using a value of type ‘long
  4508. int’ for the offset is not compatible with POSIX. ‘fseeko’ uses the
  4509. correct type ‘off_t’ for the OFFSET parameter.
  4510. For this reason it is a good idea to prefer ‘ftello’ whenever it is
  4511. available since its functionality is (if different at all) closer
  4512. the underlying definition.
  4513. The functionality and return value are the same as for ‘fseek’.
  4514. The function is an extension defined in the Unix Single
  4515. Specification version 2.
  4516. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  4517. 32 bit system this function is in fact ‘fseeko64’. I.e., the LFS
  4518. interface transparently replaces the old interface.
  4519. -- Function: int fseeko64 (FILE *STREAM, off64_t OFFSET, int WHENCE)
  4520. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4521. | *Note POSIX Safety Concepts::.
  4522. This function is similar to ‘fseeko’ with the only difference that
  4523. the OFFSET parameter is of type ‘off64_t’. This also requires that
  4524. the stream STREAM was opened using either ‘fopen64’, ‘freopen64’,
  4525. or ‘tmpfile64’ since otherwise the underlying file operations to
  4526. position the file pointer beyond the 2^31 bytes limit might fail.
  4527. If the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a 32
  4528. bits machine this function is available under the name ‘fseeko’ and
  4529. so transparently replaces the old interface.
  4530. *Portability Note:* In non-POSIX systems, ‘ftell’, ‘ftello’, ‘fseek’
  4531. and ‘fseeko’ might work reliably only on binary streams. *Note Binary
  4532. Streams::.
  4533. The following symbolic constants are defined for use as the WHENCE
  4534. argument to ‘fseek’. They are also used with the ‘lseek’ function
  4535. (*note I/O Primitives::) and to specify offsets for file locks (*note
  4536. Control Operations::).
  4537. -- Macro: int SEEK_SET
  4538. This is an integer constant which, when used as the WHENCE argument
  4539. to the ‘fseek’ or ‘fseeko’ functions, specifies that the offset
  4540. provided is relative to the beginning of the file.
  4541. -- Macro: int SEEK_CUR
  4542. This is an integer constant which, when used as the WHENCE argument
  4543. to the ‘fseek’ or ‘fseeko’ functions, specifies that the offset
  4544. provided is relative to the current file position.
  4545. -- Macro: int SEEK_END
  4546. This is an integer constant which, when used as the WHENCE argument
  4547. to the ‘fseek’ or ‘fseeko’ functions, specifies that the offset
  4548. provided is relative to the end of the file.
  4549. -- Function: void rewind (FILE *STREAM)
  4550. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4551. | *Note POSIX Safety Concepts::.
  4552. The ‘rewind’ function positions the stream STREAM at the beginning
  4553. of the file. It is equivalent to calling ‘fseek’ or ‘fseeko’ on
  4554. the STREAM with an OFFSET argument of ‘0L’ and a WHENCE argument of
  4555. ‘SEEK_SET’, except that the return value is discarded and the error
  4556. indicator for the stream is reset.
  4557. These three aliases for the ‘SEEK_...’ constants exist for the sake
  4558. of compatibility with older BSD systems. They are defined in two
  4559. different header files: ‘fcntl.h’ and ‘sys/file.h’.
  4560. ‘L_SET’
  4561. An alias for ‘SEEK_SET’.
  4562. ‘L_INCR’
  4563. An alias for ‘SEEK_CUR’.
  4564. ‘L_XTND’
  4565. An alias for ‘SEEK_END’.
  4566. 
  4567. File: libc.info, Node: Portable Positioning, Next: Stream Buffering, Prev: File Positioning, Up: I/O on Streams
  4568. 12.19 Portable File-Position Functions
  4569. ======================================
  4570. On GNU systems, the file position is truly a character count. You can
  4571. specify any character count value as an argument to ‘fseek’ or ‘fseeko’
  4572. and get reliable results for any random access file. However, some
  4573. ISO C systems do not represent file positions in this way.
  4574. On some systems where text streams truly differ from binary streams,
  4575. it is impossible to represent the file position of a text stream as a
  4576. count of characters from the beginning of the file. For example, the
  4577. file position on some systems must encode both a record offset within
  4578. the file, and a character offset within the record.
  4579. As a consequence, if you want your programs to be portable to these
  4580. systems, you must observe certain rules:
  4581. • The value returned from ‘ftell’ on a text stream has no predictable
  4582. relationship to the number of characters you have read so far. The
  4583. only thing you can rely on is that you can use it subsequently as
  4584. the OFFSET argument to ‘fseek’ or ‘fseeko’ to move back to the same
  4585. file position.
  4586. • In a call to ‘fseek’ or ‘fseeko’ on a text stream, either the
  4587. OFFSET must be zero, or WHENCE must be ‘SEEK_SET’ and the OFFSET
  4588. must be the result of an earlier call to ‘ftell’ on the same
  4589. stream.
  4590. • The value of the file position indicator of a text stream is
  4591. undefined while there are characters that have been pushed back
  4592. with ‘ungetc’ that haven’t been read or discarded. *Note
  4593. Unreading::.
  4594. But even if you observe these rules, you may still have trouble for
  4595. long files, because ‘ftell’ and ‘fseek’ use a ‘long int’ value to
  4596. represent the file position. This type may not have room to encode all
  4597. the file positions in a large file. Using the ‘ftello’ and ‘fseeko’
  4598. functions might help here since the ‘off_t’ type is expected to be able
  4599. to hold all file position values but this still does not help to handle
  4600. additional information which must be associated with a file position.
  4601. So if you do want to support systems with peculiar encodings for the
  4602. file positions, it is better to use the functions ‘fgetpos’ and
  4603. ‘fsetpos’ instead. These functions represent the file position using
  4604. the data type ‘fpos_t’, whose internal representation varies from system
  4605. to system.
  4606. These symbols are declared in the header file ‘stdio.h’.
  4607. -- Data Type: fpos_t
  4608. This is the type of an object that can encode information about the
  4609. file position of a stream, for use by the functions ‘fgetpos’ and
  4610. ‘fsetpos’.
  4611. In the GNU C Library, ‘fpos_t’ is an opaque data structure that
  4612. contains internal data to represent file offset and conversion
  4613. state information. In other systems, it might have a different
  4614. internal representation.
  4615. When compiling with ‘_FILE_OFFSET_BITS == 64’ on a 32 bit machine
  4616. this type is in fact equivalent to ‘fpos64_t’ since the LFS
  4617. interface transparently replaces the old interface.
  4618. -- Data Type: fpos64_t
  4619. This is the type of an object that can encode information about the
  4620. file position of a stream, for use by the functions ‘fgetpos64’ and
  4621. ‘fsetpos64’.
  4622. In the GNU C Library, ‘fpos64_t’ is an opaque data structure that
  4623. contains internal data to represent file offset and conversion
  4624. state information. In other systems, it might have a different
  4625. internal representation.
  4626. -- Function: int fgetpos (FILE *STREAM, fpos_t *POSITION)
  4627. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4628. | *Note POSIX Safety Concepts::.
  4629. This function stores the value of the file position indicator for
  4630. the stream STREAM in the ‘fpos_t’ object pointed to by POSITION.
  4631. If successful, ‘fgetpos’ returns zero; otherwise it returns a
  4632. nonzero value and stores an implementation-defined positive value
  4633. in ‘errno’.
  4634. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  4635. 32 bit system the function is in fact ‘fgetpos64’. I.e., the LFS
  4636. interface transparently replaces the old interface.
  4637. -- Function: int fgetpos64 (FILE *STREAM, fpos64_t *POSITION)
  4638. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4639. | *Note POSIX Safety Concepts::.
  4640. This function is similar to ‘fgetpos’ but the file position is
  4641. returned in a variable of type ‘fpos64_t’ to which POSITION points.
  4642. If the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a 32
  4643. bits machine this function is available under the name ‘fgetpos’
  4644. and so transparently replaces the old interface.
  4645. -- Function: int fsetpos (FILE *STREAM, const fpos_t *POSITION)
  4646. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4647. | *Note POSIX Safety Concepts::.
  4648. This function sets the file position indicator for the stream
  4649. STREAM to the position POSITION, which must have been set by a
  4650. previous call to ‘fgetpos’ on the same stream. If successful,
  4651. ‘fsetpos’ clears the end-of-file indicator on the stream, discards
  4652. any characters that were “pushed back” by the use of ‘ungetc’, and
  4653. returns a value of zero. Otherwise, ‘fsetpos’ returns a nonzero
  4654. value and stores an implementation-defined positive value in
  4655. ‘errno’.
  4656. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  4657. 32 bit system the function is in fact ‘fsetpos64’. I.e., the LFS
  4658. interface transparently replaces the old interface.
  4659. -- Function: int fsetpos64 (FILE *STREAM, const fpos64_t *POSITION)
  4660. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4661. | *Note POSIX Safety Concepts::.
  4662. This function is similar to ‘fsetpos’ but the file position used
  4663. for positioning is provided in a variable of type ‘fpos64_t’ to
  4664. which POSITION points.
  4665. If the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a 32
  4666. bits machine this function is available under the name ‘fsetpos’
  4667. and so transparently replaces the old interface.
  4668. 
  4669. File: libc.info, Node: Stream Buffering, Next: Other Kinds of Streams, Prev: Portable Positioning, Up: I/O on Streams
  4670. 12.20 Stream Buffering
  4671. ======================
  4672. Characters that are written to a stream are normally accumulated and
  4673. transmitted asynchronously to the file in a block, instead of appearing
  4674. as soon as they are output by the application program. Similarly,
  4675. streams often retrieve input from the host environment in blocks rather
  4676. than on a character-by-character basis. This is called “buffering”.
  4677. If you are writing programs that do interactive input and output
  4678. using streams, you need to understand how buffering works when you
  4679. design the user interface to your program. Otherwise, you might find
  4680. that output (such as progress or prompt messages) doesn’t appear when
  4681. you intended it to, or displays some other unexpected behavior.
  4682. This section deals only with controlling when characters are
  4683. transmitted between the stream and the file or device, and _not_ with
  4684. how things like echoing, flow control, and the like are handled on
  4685. specific classes of devices. For information on common control
  4686. operations on terminal devices, see *note Low-Level Terminal
  4687. Interface::.
  4688. You can bypass the stream buffering facilities altogether by using
  4689. the low-level input and output functions that operate on file
  4690. descriptors instead. *Note Low-Level I/O::.
  4691. * Menu:
  4692. * Buffering Concepts:: Terminology is defined here.
  4693. * Flushing Buffers:: How to ensure that output buffers are flushed.
  4694. * Controlling Buffering:: How to specify what kind of buffering to use.
  4695. 
  4696. File: libc.info, Node: Buffering Concepts, Next: Flushing Buffers, Up: Stream Buffering
  4697. 12.20.1 Buffering Concepts
  4698. --------------------------
  4699. There are three different kinds of buffering strategies:
  4700. • Characters written to or read from an “unbuffered” stream are
  4701. transmitted individually to or from the file as soon as possible.
  4702. • Characters written to a “line buffered” stream are transmitted to
  4703. the file in blocks when a newline character is encountered.
  4704. • Characters written to or read from a “fully buffered” stream are
  4705. transmitted to or from the file in blocks of arbitrary size.
  4706. Newly opened streams are normally fully buffered, with one exception:
  4707. a stream connected to an interactive device such as a terminal is
  4708. initially line buffered. *Note Controlling Buffering::, for information
  4709. on how to select a different kind of buffering. Usually the automatic
  4710. selection gives you the most convenient kind of buffering for the file
  4711. or device you open.
  4712. The use of line buffering for interactive devices implies that output
  4713. messages ending in a newline will appear immediately—which is usually
  4714. what you want. Output that doesn’t end in a newline might or might not
  4715. show up immediately, so if you want them to appear immediately, you
  4716. should flush buffered output explicitly with ‘fflush’, as described in
  4717. *note Flushing Buffers::.
  4718. 
  4719. File: libc.info, Node: Flushing Buffers, Next: Controlling Buffering, Prev: Buffering Concepts, Up: Stream Buffering
  4720. 12.20.2 Flushing Buffers
  4721. ------------------------
  4722. “Flushing” output on a buffered stream means transmitting all
  4723. accumulated characters to the file. There are many circumstances when
  4724. buffered output on a stream is flushed automatically:
  4725. • When you try to do output and the output buffer is full.
  4726. • When the stream is closed. *Note Closing Streams::.
  4727. • When the program terminates by calling ‘exit’. *Note Normal
  4728. Termination::.
  4729. • When a newline is written, if the stream is line buffered.
  4730. • Whenever an input operation on _any_ stream actually reads data
  4731. from its file.
  4732. If you want to flush the buffered output at another time, call
  4733. ‘fflush’, which is declared in the header file ‘stdio.h’.
  4734. -- Function: int fflush (FILE *STREAM)
  4735. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4736. | *Note POSIX Safety Concepts::.
  4737. This function causes any buffered output on STREAM to be delivered
  4738. to the file. If STREAM is a null pointer, then ‘fflush’ causes
  4739. buffered output on _all_ open output streams to be flushed.
  4740. This function returns ‘EOF’ if a write error occurs, or zero
  4741. otherwise.
  4742. -- Function: int fflush_unlocked (FILE *STREAM)
  4743. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  4744. corrupt | *Note POSIX Safety Concepts::.
  4745. The ‘fflush_unlocked’ function is equivalent to the ‘fflush’
  4746. function except that it does not implicitly lock the stream.
  4747. The ‘fflush’ function can be used to flush all streams currently
  4748. opened. While this is useful in some situations it does often more than
  4749. necessary since it might be done in situations when terminal input is
  4750. required and the program wants to be sure that all output is visible on
  4751. the terminal. But this means that only line buffered streams have to be
  4752. flushed. Solaris introduced a function especially for this. It was
  4753. always available in the GNU C Library in some form but never officially
  4754. exported.
  4755. -- Function: void _flushlbf (void)
  4756. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4757. | *Note POSIX Safety Concepts::.
  4758. The ‘_flushlbf’ function flushes all line buffered streams
  4759. currently opened.
  4760. This function is declared in the ‘stdio_ext.h’ header.
  4761. *Compatibility Note:* Some brain-damaged operating systems have been
  4762. known to be so thoroughly fixated on line-oriented input and output that
  4763. flushing a line buffered stream causes a newline to be written!
  4764. Fortunately, this “feature” seems to be becoming less common. You do
  4765. not need to worry about this with the GNU C Library.
  4766. In some situations it might be useful to not flush the output pending
  4767. for a stream but instead simply forget it. If transmission is costly
  4768. and the output is not needed anymore this is valid reasoning. In this
  4769. situation a non-standard function introduced in Solaris and available in
  4770. the GNU C Library can be used.
  4771. -- Function: void __fpurge (FILE *STREAM)
  4772. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Unsafe
  4773. corrupt | *Note POSIX Safety Concepts::.
  4774. The ‘__fpurge’ function causes the buffer of the stream STREAM to
  4775. be emptied. If the stream is currently in read mode all input in
  4776. the buffer is lost. If the stream is in output mode the buffered
  4777. output is not written to the device (or whatever other underlying
  4778. storage) and the buffer is cleared.
  4779. This function is declared in ‘stdio_ext.h’.
  4780. 
  4781. File: libc.info, Node: Controlling Buffering, Prev: Flushing Buffers, Up: Stream Buffering
  4782. 12.20.3 Controlling Which Kind of Buffering
  4783. -------------------------------------------
  4784. After opening a stream (but before any other operations have been
  4785. performed on it), you can explicitly specify what kind of buffering you
  4786. want it to have using the ‘setvbuf’ function.
  4787. The facilities listed in this section are declared in the header file
  4788. ‘stdio.h’.
  4789. -- Function: int setvbuf (FILE *STREAM, char *BUF, int MODE, size_t
  4790. SIZE)
  4791. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4792. | *Note POSIX Safety Concepts::.
  4793. This function is used to specify that the stream STREAM should have
  4794. the buffering mode MODE, which can be either ‘_IOFBF’ (for full
  4795. buffering), ‘_IOLBF’ (for line buffering), or ‘_IONBF’ (for
  4796. unbuffered input/output).
  4797. If you specify a null pointer as the BUF argument, then ‘setvbuf’
  4798. allocates a buffer itself using ‘malloc’. This buffer will be
  4799. freed when you close the stream.
  4800. Otherwise, BUF should be a character array that can hold at least
  4801. SIZE characters. You should not free the space for this array as
  4802. long as the stream remains open and this array remains its buffer.
  4803. You should usually either allocate it statically, or ‘malloc’
  4804. (*note Unconstrained Allocation::) the buffer. Using an automatic
  4805. array is not a good idea unless you close the file before exiting
  4806. the block that declares the array.
  4807. While the array remains a stream buffer, the stream I/O functions
  4808. will use the buffer for their internal purposes. You shouldn’t try
  4809. to access the values in the array directly while the stream is
  4810. using it for buffering.
  4811. The ‘setvbuf’ function returns zero on success, or a nonzero value
  4812. if the value of MODE is not valid or if the request could not be
  4813. honored.
  4814. -- Macro: int _IOFBF
  4815. The value of this macro is an integer constant expression that can
  4816. be used as the MODE argument to the ‘setvbuf’ function to specify
  4817. that the stream should be fully buffered.
  4818. -- Macro: int _IOLBF
  4819. The value of this macro is an integer constant expression that can
  4820. be used as the MODE argument to the ‘setvbuf’ function to specify
  4821. that the stream should be line buffered.
  4822. -- Macro: int _IONBF
  4823. The value of this macro is an integer constant expression that can
  4824. be used as the MODE argument to the ‘setvbuf’ function to specify
  4825. that the stream should be unbuffered.
  4826. -- Macro: int BUFSIZ
  4827. The value of this macro is an integer constant expression that is
  4828. good to use for the SIZE argument to ‘setvbuf’. This value is
  4829. guaranteed to be at least ‘256’.
  4830. The value of ‘BUFSIZ’ is chosen on each system so as to make stream
  4831. I/O efficient. So it is a good idea to use ‘BUFSIZ’ as the size
  4832. for the buffer when you call ‘setvbuf’.
  4833. Actually, you can get an even better value to use for the buffer
  4834. size by means of the ‘fstat’ system call: it is found in the
  4835. ‘st_blksize’ field of the file attributes. *Note Attribute
  4836. Meanings::.
  4837. Sometimes people also use ‘BUFSIZ’ as the allocation size of
  4838. buffers used for related purposes, such as strings used to receive
  4839. a line of input with ‘fgets’ (*note Character Input::). There is
  4840. no particular reason to use ‘BUFSIZ’ for this instead of any other
  4841. integer, except that it might lead to doing I/O in chunks of an
  4842. efficient size.
  4843. -- Function: void setbuf (FILE *STREAM, char *BUF)
  4844. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4845. | *Note POSIX Safety Concepts::.
  4846. If BUF is a null pointer, the effect of this function is equivalent
  4847. to calling ‘setvbuf’ with a MODE argument of ‘_IONBF’. Otherwise,
  4848. it is equivalent to calling ‘setvbuf’ with BUF, and a MODE of
  4849. ‘_IOFBF’ and a SIZE argument of ‘BUFSIZ’.
  4850. The ‘setbuf’ function is provided for compatibility with old code;
  4851. use ‘setvbuf’ in all new programs.
  4852. -- Function: void setbuffer (FILE *STREAM, char *BUF, size_t SIZE)
  4853. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4854. | *Note POSIX Safety Concepts::.
  4855. If BUF is a null pointer, this function makes STREAM unbuffered.
  4856. Otherwise, it makes STREAM fully buffered using BUF as the buffer.
  4857. The SIZE argument specifies the length of BUF.
  4858. This function is provided for compatibility with old BSD code. Use
  4859. ‘setvbuf’ instead.
  4860. -- Function: void setlinebuf (FILE *STREAM)
  4861. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  4862. | *Note POSIX Safety Concepts::.
  4863. This function makes STREAM be line buffered, and allocates the
  4864. buffer for you.
  4865. This function is provided for compatibility with old BSD code. Use
  4866. ‘setvbuf’ instead.
  4867. It is possible to query whether a given stream is line buffered or
  4868. not using a non-standard function introduced in Solaris and available in
  4869. the GNU C Library.
  4870. -- Function: int __flbf (FILE *STREAM)
  4871. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4872. Concepts::.
  4873. The ‘__flbf’ function will return a nonzero value in case the
  4874. stream STREAM is line buffered. Otherwise the return value is
  4875. zero.
  4876. This function is declared in the ‘stdio_ext.h’ header.
  4877. Two more extensions allow to determine the size of the buffer and how
  4878. much of it is used. These functions were also introduced in Solaris.
  4879. -- Function: size_t __fbufsize (FILE *STREAM)
  4880. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Safe |
  4881. *Note POSIX Safety Concepts::.
  4882. The ‘__fbufsize’ function return the size of the buffer in the
  4883. stream STREAM. This value can be used to optimize the use of the
  4884. stream.
  4885. This function is declared in the ‘stdio_ext.h’ header.
  4886. -- Function: size_t __fpending (FILE *STREAM)
  4887. Preliminary: | MT-Safe race:stream | AS-Unsafe corrupt | AC-Safe |
  4888. *Note POSIX Safety Concepts::.
  4889. The ‘__fpending’ function returns the number of bytes currently in
  4890. the output buffer. For wide-oriented streams the measuring unit is
  4891. wide characters. This function should not be used on buffers in
  4892. read mode or opened read-only.
  4893. This function is declared in the ‘stdio_ext.h’ header.
  4894. 
  4895. File: libc.info, Node: Other Kinds of Streams, Next: Formatted Messages, Prev: Stream Buffering, Up: I/O on Streams
  4896. 12.21 Other Kinds of Streams
  4897. ============================
  4898. The GNU C Library provides ways for you to define additional kinds of
  4899. streams that do not necessarily correspond to an open file.
  4900. One such type of stream takes input from or writes output to a
  4901. string. These kinds of streams are used internally to implement the
  4902. ‘sprintf’ and ‘sscanf’ functions. You can also create such a stream
  4903. explicitly, using the functions described in *note String Streams::.
  4904. More generally, you can define streams that do input/output to
  4905. arbitrary objects using functions supplied by your program. This
  4906. protocol is discussed in *note Custom Streams::.
  4907. *Portability Note:* The facilities described in this section are
  4908. specific to GNU. Other systems or C implementations might or might not
  4909. provide equivalent functionality.
  4910. * Menu:
  4911. * String Streams:: Streams that get data from or put data in
  4912. a string or memory buffer.
  4913. * Custom Streams:: Defining your own streams with an arbitrary
  4914. input data source and/or output data sink.
  4915. 
  4916. File: libc.info, Node: String Streams, Next: Custom Streams, Up: Other Kinds of Streams
  4917. 12.21.1 String Streams
  4918. ----------------------
  4919. The ‘fmemopen’ and ‘open_memstream’ functions allow you to do I/O to a
  4920. string or memory buffer. These facilities are declared in ‘stdio.h’.
  4921. -- Function: FILE * fmemopen (void *BUF, size_t SIZE, const char
  4922. *OPENTYPE)
  4923. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe mem lock |
  4924. *Note POSIX Safety Concepts::.
  4925. This function opens a stream that allows the access specified by
  4926. the OPENTYPE argument, that reads from or writes to the buffer
  4927. specified by the argument BUF. This array must be at least SIZE
  4928. bytes long.
  4929. If you specify a null pointer as the BUF argument, ‘fmemopen’
  4930. dynamically allocates an array SIZE bytes long (as with ‘malloc’;
  4931. *note Unconstrained Allocation::). This is really only useful if
  4932. you are going to write things to the buffer and then read them back
  4933. in again, because you have no way of actually getting a pointer to
  4934. the buffer (for this, try ‘open_memstream’, below). The buffer is
  4935. freed when the stream is closed.
  4936. The argument OPENTYPE is the same as in ‘fopen’ (*note Opening
  4937. Streams::). If the OPENTYPE specifies append mode, then the
  4938. initial file position is set to the first null character in the
  4939. buffer. Otherwise the initial file position is at the beginning of
  4940. the buffer.
  4941. When a stream open for writing is flushed or closed, a null
  4942. character (zero byte) is written at the end of the buffer if it
  4943. fits. You should add an extra byte to the SIZE argument to account
  4944. for this. Attempts to write more than SIZE bytes to the buffer
  4945. result in an error.
  4946. For a stream open for reading, null characters (zero bytes) in the
  4947. buffer do not count as “end of file”. Read operations indicate end
  4948. of file only when the file position advances past SIZE bytes. So,
  4949. if you want to read characters from a null-terminated string, you
  4950. should supply the length of the string as the SIZE argument.
  4951. Here is an example of using ‘fmemopen’ to create a stream for reading
  4952. from a string:
  4953. #include <stdio.h>
  4954. static char buffer[] = "foobar";
  4955. int
  4956. main (void)
  4957. {
  4958. int ch;
  4959. FILE *stream;
  4960. stream = fmemopen (buffer, strlen (buffer), "r");
  4961. while ((ch = fgetc (stream)) != EOF)
  4962. printf ("Got %c\n", ch);
  4963. fclose (stream);
  4964. return 0;
  4965. }
  4966. This program produces the following output:
  4967. Got f
  4968. Got o
  4969. Got o
  4970. Got b
  4971. Got a
  4972. Got r
  4973. -- Function: FILE * open_memstream (char **PTR, size_t *SIZELOC)
  4974. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  4975. POSIX Safety Concepts::.
  4976. This function opens a stream for writing to a buffer. The buffer
  4977. is allocated dynamically and grown as necessary, using ‘malloc’.
  4978. After you’ve closed the stream, this buffer is your responsibility
  4979. to clean up using ‘free’ or ‘realloc’. *Note Unconstrained
  4980. Allocation::.
  4981. When the stream is closed with ‘fclose’ or flushed with ‘fflush’,
  4982. the locations PTR and SIZELOC are updated to contain the pointer to
  4983. the buffer and its size. The values thus stored remain valid only
  4984. as long as no further output on the stream takes place. If you do
  4985. more output, you must flush the stream again to store new values
  4986. before you use them again.
  4987. A null character is written at the end of the buffer. This null
  4988. character is _not_ included in the size value stored at SIZELOC.
  4989. You can move the stream’s file position with ‘fseek’ or ‘fseeko’
  4990. (*note File Positioning::). Moving the file position past the end
  4991. of the data already written fills the intervening space with
  4992. zeroes.
  4993. Here is an example of using ‘open_memstream’:
  4994. #include <stdio.h>
  4995. int
  4996. main (void)
  4997. {
  4998. char *bp;
  4999. size_t size;
  5000. FILE *stream;
  5001. stream = open_memstream (&bp, &size);
  5002. fprintf (stream, "hello");
  5003. fflush (stream);
  5004. printf ("buf = `%s', size = %zu\n", bp, size);
  5005. fprintf (stream, ", world");
  5006. fclose (stream);
  5007. printf ("buf = `%s', size = %zu\n", bp, size);
  5008. return 0;
  5009. }
  5010. This program produces the following output:
  5011. buf = `hello', size = 5
  5012. buf = `hello, world', size = 12
  5013. 
  5014. File: libc.info, Node: Custom Streams, Prev: String Streams, Up: Other Kinds of Streams
  5015. 12.21.2 Programming Your Own Custom Streams
  5016. -------------------------------------------
  5017. This section describes how you can make a stream that gets input from an
  5018. arbitrary data source or writes output to an arbitrary data sink
  5019. programmed by you. We call these “custom streams”. The functions and
  5020. types described here are all GNU extensions.
  5021. * Menu:
  5022. * Streams and Cookies:: The “cookie” records where to fetch or
  5023. store data that is read or written.
  5024. * Hook Functions:: How you should define the four “hook
  5025. functions” that a custom stream needs.
  5026. 
  5027. File: libc.info, Node: Streams and Cookies, Next: Hook Functions, Up: Custom Streams
  5028. 12.21.2.1 Custom Streams and Cookies
  5029. ....................................
  5030. Inside every custom stream is a special object called the “cookie”.
  5031. This is an object supplied by you which records where to fetch or store
  5032. the data read or written. It is up to you to define a data type to use
  5033. for the cookie. The stream functions in the library never refer
  5034. directly to its contents, and they don’t even know what the type is;
  5035. they record its address with type ‘void *’.
  5036. To implement a custom stream, you must specify _how_ to fetch or
  5037. store the data in the specified place. You do this by defining “hook
  5038. functions” to read, write, change “file position”, and close the stream.
  5039. All four of these functions will be passed the stream’s cookie so they
  5040. can tell where to fetch or store the data. The library functions don’t
  5041. know what’s inside the cookie, but your functions will know.
  5042. When you create a custom stream, you must specify the cookie pointer,
  5043. and also the four hook functions stored in a structure of type
  5044. ‘cookie_io_functions_t’.
  5045. These facilities are declared in ‘stdio.h’.
  5046. -- Data Type: cookie_io_functions_t
  5047. This is a structure type that holds the functions that define the
  5048. communications protocol between the stream and its cookie. It has
  5049. the following members:
  5050. ‘cookie_read_function_t *read’
  5051. This is the function that reads data from the cookie. If the
  5052. value is a null pointer instead of a function, then read
  5053. operations on this stream always return ‘EOF’.
  5054. ‘cookie_write_function_t *write’
  5055. This is the function that writes data to the cookie. If the
  5056. value is a null pointer instead of a function, then data
  5057. written to the stream is discarded.
  5058. ‘cookie_seek_function_t *seek’
  5059. This is the function that performs the equivalent of file
  5060. positioning on the cookie. If the value is a null pointer
  5061. instead of a function, calls to ‘fseek’ or ‘fseeko’ on this
  5062. stream can only seek to locations within the buffer; any
  5063. attempt to seek outside the buffer will return an ‘ESPIPE’
  5064. error.
  5065. ‘cookie_close_function_t *close’
  5066. This function performs any appropriate cleanup on the cookie
  5067. when closing the stream. If the value is a null pointer
  5068. instead of a function, nothing special is done to close the
  5069. cookie when the stream is closed.
  5070. -- Function: FILE * fopencookie (void *COOKIE, const char *OPENTYPE,
  5071. cookie_io_functions_t IO-FUNCTIONS)
  5072. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe mem lock |
  5073. *Note POSIX Safety Concepts::.
  5074. This function actually creates the stream for communicating with
  5075. the COOKIE using the functions in the IO-FUNCTIONS argument. The
  5076. OPENTYPE argument is interpreted as for ‘fopen’; see *note Opening
  5077. Streams::. (But note that the “truncate on open” option is
  5078. ignored.) The new stream is fully buffered.
  5079. The ‘fopencookie’ function returns the newly created stream, or a
  5080. null pointer in case of an error.
  5081. 
  5082. File: libc.info, Node: Hook Functions, Prev: Streams and Cookies, Up: Custom Streams
  5083. 12.21.2.2 Custom Stream Hook Functions
  5084. ......................................
  5085. Here are more details on how you should define the four hook functions
  5086. that a custom stream needs.
  5087. You should define the function to read data from the cookie as:
  5088. ssize_t READER (void *COOKIE, char *BUFFER, size_t SIZE)
  5089. This is very similar to the ‘read’ function; see *note I/O
  5090. Primitives::. Your function should transfer up to SIZE bytes into the
  5091. BUFFER, and return the number of bytes read, or zero to indicate
  5092. end-of-file. You can return a value of ‘-1’ to indicate an error.
  5093. You should define the function to write data to the cookie as:
  5094. ssize_t WRITER (void *COOKIE, const char *BUFFER, size_t SIZE)
  5095. This is very similar to the ‘write’ function; see *note I/O
  5096. Primitives::. Your function should transfer up to SIZE bytes from the
  5097. buffer, and return the number of bytes written. You can return a value
  5098. of ‘0’ to indicate an error. You must not return any negative value.
  5099. You should define the function to perform seek operations on the
  5100. cookie as:
  5101. int SEEKER (void *COOKIE, off64_t *POSITION, int WHENCE)
  5102. For this function, the POSITION and WHENCE arguments are interpreted
  5103. as for ‘fgetpos’; see *note Portable Positioning::.
  5104. After doing the seek operation, your function should store the
  5105. resulting file position relative to the beginning of the file in
  5106. POSITION. Your function should return a value of ‘0’ on success and
  5107. ‘-1’ to indicate an error.
  5108. You should define the function to do cleanup operations on the cookie
  5109. appropriate for closing the stream as:
  5110. int CLEANER (void *COOKIE)
  5111. Your function should return ‘-1’ to indicate an error, and ‘0’
  5112. otherwise.
  5113. -- Data Type: cookie_read_function_t
  5114. This is the data type that the read function for a custom stream
  5115. should have. If you declare the function as shown above, this is
  5116. the type it will have.
  5117. -- Data Type: cookie_write_function_t
  5118. The data type of the write function for a custom stream.
  5119. -- Data Type: cookie_seek_function_t
  5120. The data type of the seek function for a custom stream.
  5121. -- Data Type: cookie_close_function_t
  5122. The data type of the close function for a custom stream.
  5123. 
  5124. File: libc.info, Node: Formatted Messages, Prev: Other Kinds of Streams, Up: I/O on Streams
  5125. 12.22 Formatted Messages
  5126. ========================
  5127. On systems which are based on System V messages of programs (especially
  5128. the system tools) are printed in a strict form using the ‘fmtmsg’
  5129. function. The uniformity sometimes helps the user to interpret messages
  5130. and the strictness tests of the ‘fmtmsg’ function ensure that the
  5131. programmer follows some minimal requirements.
  5132. * Menu:
  5133. * Printing Formatted Messages:: The ‘fmtmsg’ function.
  5134. * Adding Severity Classes:: Add more severity classes.
  5135. * Example:: How to use ‘fmtmsg’ and ‘addseverity’.
  5136. 
  5137. File: libc.info, Node: Printing Formatted Messages, Next: Adding Severity Classes, Up: Formatted Messages
  5138. 12.22.1 Printing Formatted Messages
  5139. -----------------------------------
  5140. Messages can be printed to standard error and/or to the console. To
  5141. select the destination the programmer can use the following two values,
  5142. bitwise OR combined if wanted, for the CLASSIFICATION parameter of
  5143. ‘fmtmsg’:
  5144. ‘MM_PRINT’
  5145. Display the message in standard error.
  5146. ‘MM_CONSOLE’
  5147. Display the message on the system console.
  5148. The erroneous piece of the system can be signalled by exactly one of
  5149. the following values which also is bitwise ORed with the CLASSIFICATION
  5150. parameter to ‘fmtmsg’:
  5151. ‘MM_HARD’
  5152. The source of the condition is some hardware.
  5153. ‘MM_SOFT’
  5154. The source of the condition is some software.
  5155. ‘MM_FIRM’
  5156. The source of the condition is some firmware.
  5157. A third component of the CLASSIFICATION parameter to ‘fmtmsg’ can
  5158. describe the part of the system which detects the problem. This is done
  5159. by using exactly one of the following values:
  5160. ‘MM_APPL’
  5161. The erroneous condition is detected by the application.
  5162. ‘MM_UTIL’
  5163. The erroneous condition is detected by a utility.
  5164. ‘MM_OPSYS’
  5165. The erroneous condition is detected by the operating system.
  5166. A last component of CLASSIFICATION can signal the results of this
  5167. message. Exactly one of the following values can be used:
  5168. ‘MM_RECOVER’
  5169. It is a recoverable error.
  5170. ‘MM_NRECOV’
  5171. It is a non-recoverable error.
  5172. -- Function: int fmtmsg (long int CLASSIFICATION, const char *LABEL,
  5173. int SEVERITY, const char *TEXT, const char *ACTION, const char
  5174. *TAG)
  5175. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Safe | *Note POSIX
  5176. Safety Concepts::.
  5177. Display a message described by its parameters on the device(s)
  5178. specified in the CLASSIFICATION parameter. The LABEL parameter
  5179. identifies the source of the message. The string should consist of
  5180. two colon separated parts where the first part has not more than 10
  5181. and the second part not more than 14 characters. The TEXT
  5182. parameter describes the condition of the error, the ACTION
  5183. parameter possible steps to recover from the error and the TAG
  5184. parameter is a reference to the online documentation where more
  5185. information can be found. It should contain the LABEL value and a
  5186. unique identification number.
  5187. Each of the parameters can be a special value which means this
  5188. value is to be omitted. The symbolic names for these values are:
  5189. ‘MM_NULLLBL’
  5190. Ignore LABEL parameter.
  5191. ‘MM_NULLSEV’
  5192. Ignore SEVERITY parameter.
  5193. ‘MM_NULLMC’
  5194. Ignore CLASSIFICATION parameter. This implies that nothing is
  5195. actually printed.
  5196. ‘MM_NULLTXT’
  5197. Ignore TEXT parameter.
  5198. ‘MM_NULLACT’
  5199. Ignore ACTION parameter.
  5200. ‘MM_NULLTAG’
  5201. Ignore TAG parameter.
  5202. There is another way certain fields can be omitted from the output
  5203. to standard error. This is described below in the description of
  5204. environment variables influencing the behavior.
  5205. The SEVERITY parameter can have one of the values in the following
  5206. table:
  5207. ‘MM_NOSEV’
  5208. Nothing is printed, this value is the same as ‘MM_NULLSEV’.
  5209. ‘MM_HALT’
  5210. This value is printed as ‘HALT’.
  5211. ‘MM_ERROR’
  5212. This value is printed as ‘ERROR’.
  5213. ‘MM_WARNING’
  5214. This value is printed as ‘WARNING’.
  5215. ‘MM_INFO’
  5216. This value is printed as ‘INFO’.
  5217. The numeric value of these five macros are between ‘0’ and ‘4’.
  5218. Using the environment variable ‘SEV_LEVEL’ or using the
  5219. ‘addseverity’ function one can add more severity levels with their
  5220. corresponding string to print. This is described below (*note
  5221. Adding Severity Classes::).
  5222. If no parameter is ignored the output looks like this:
  5223. LABEL: SEVERITY-STRING: TEXT
  5224. TO FIX: ACTION TAG
  5225. The colons, new line characters and the ‘TO FIX’ string are
  5226. inserted if necessary, i.e., if the corresponding parameter is not
  5227. ignored.
  5228. This function is specified in the X/Open Portability Guide. It is
  5229. also available on all systems derived from System V.
  5230. The function returns the value ‘MM_OK’ if no error occurred. If
  5231. only the printing to standard error failed, it returns ‘MM_NOMSG’.
  5232. If printing to the console fails, it returns ‘MM_NOCON’. If
  5233. nothing is printed ‘MM_NOTOK’ is returned. Among situations where
  5234. all outputs fail this last value is also returned if a parameter
  5235. value is incorrect.
  5236. There are two environment variables which influence the behavior of
  5237. ‘fmtmsg’. The first is ‘MSGVERB’. It is used to control the output
  5238. actually happening on standard error (_not_ the console output). Each
  5239. of the five fields can explicitly be enabled. To do this the user has
  5240. to put the ‘MSGVERB’ variable with a format like the following in the
  5241. environment before calling the ‘fmtmsg’ function the first time:
  5242. MSGVERB=KEYWORD[:KEYWORD[:...]]
  5243. Valid KEYWORDs are ‘label’, ‘severity’, ‘text’, ‘action’, and ‘tag’.
  5244. If the environment variable is not given or is the empty string, a not
  5245. supported keyword is given or the value is somehow else invalid, no part
  5246. of the message is masked out.
  5247. The second environment variable which influences the behavior of
  5248. ‘fmtmsg’ is ‘SEV_LEVEL’. This variable and the change in the behavior
  5249. of ‘fmtmsg’ is not specified in the X/Open Portability Guide. It is
  5250. available in System V systems, though. It can be used to introduce new
  5251. severity levels. By default, only the five severity levels described
  5252. above are available. Any other numeric value would make ‘fmtmsg’ print
  5253. nothing.
  5254. If the user puts ‘SEV_LEVEL’ with a format like
  5255. SEV_LEVEL=[DESCRIPTION[:DESCRIPTION[:...]]]
  5256. in the environment of the process before the first call to ‘fmtmsg’,
  5257. where DESCRIPTION has a value of the form
  5258. SEVERITY-KEYWORD,LEVEL,PRINTSTRING
  5259. The SEVERITY-KEYWORD part is not used by ‘fmtmsg’ but it has to be
  5260. present. The LEVEL part is a string representation of a number. The
  5261. numeric value must be a number greater than 4. This value must be used
  5262. in the SEVERITY parameter of ‘fmtmsg’ to select this class. It is not
  5263. possible to overwrite any of the predefined classes. The PRINTSTRING is
  5264. the string printed when a message of this class is processed by ‘fmtmsg’
  5265. (see above, ‘fmtsmg’ does not print the numeric value but instead the
  5266. string representation).
  5267. 
  5268. File: libc.info, Node: Adding Severity Classes, Next: Example, Prev: Printing Formatted Messages, Up: Formatted Messages
  5269. 12.22.2 Adding Severity Classes
  5270. -------------------------------
  5271. There is another possibility to introduce severity classes besides using
  5272. the environment variable ‘SEV_LEVEL’. This simplifies the task of
  5273. introducing new classes in a running program. One could use the
  5274. ‘setenv’ or ‘putenv’ function to set the environment variable, but this
  5275. is toilsome.
  5276. -- Function: int addseverity (int SEVERITY, const char *STRING)
  5277. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe lock mem |
  5278. *Note POSIX Safety Concepts::.
  5279. This function allows the introduction of new severity classes which
  5280. can be addressed by the SEVERITY parameter of the ‘fmtmsg’
  5281. function. The SEVERITY parameter of ‘addseverity’ must match the
  5282. value for the parameter with the same name of ‘fmtmsg’, and STRING
  5283. is the string printed in the actual messages instead of the numeric
  5284. value.
  5285. If STRING is ‘NULL’ the severity class with the numeric value
  5286. according to SEVERITY is removed.
  5287. It is not possible to overwrite or remove one of the default
  5288. severity classes. All calls to ‘addseverity’ with SEVERITY set to
  5289. one of the values for the default classes will fail.
  5290. The return value is ‘MM_OK’ if the task was successfully performed.
  5291. If the return value is ‘MM_NOTOK’ something went wrong. This could
  5292. mean that no more memory is available or a class is not available
  5293. when it has to be removed.
  5294. This function is not specified in the X/Open Portability Guide
  5295. although the ‘fmtsmg’ function is. It is available on System V
  5296. systems.
  5297. 
  5298. File: libc.info, Node: Example, Prev: Adding Severity Classes, Up: Formatted Messages
  5299. 12.22.3 How to use ‘fmtmsg’ and ‘addseverity’
  5300. ---------------------------------------------
  5301. Here is a simple example program to illustrate the use of both functions
  5302. described in this section.
  5303. #include <fmtmsg.h>
  5304. int
  5305. main (void)
  5306. {
  5307. addseverity (5, "NOTE2");
  5308. fmtmsg (MM_PRINT, "only1field", MM_INFO, "text2", "action2", "tag2");
  5309. fmtmsg (MM_PRINT, "UX:cat", 5, "invalid syntax", "refer to manual",
  5310. "UX:cat:001");
  5311. fmtmsg (MM_PRINT, "label:foo", 6, "text", "action", "tag");
  5312. return 0;
  5313. }
  5314. The second call to ‘fmtmsg’ illustrates a use of this function as it
  5315. usually occurs on System V systems, which heavily use this function. It
  5316. seems worthwhile to give a short explanation here of how this system
  5317. works on System V. The value of the LABEL field (‘UX:cat’) says that the
  5318. error occurred in the Unix program ‘cat’. The explanation of the error
  5319. follows and the value for the ACTION parameter is ‘"refer to manual"’.
  5320. One could be more specific here, if necessary. The TAG field contains,
  5321. as proposed above, the value of the string given for the LABEL
  5322. parameter, and additionally a unique ID (‘001’ in this case). For a GNU
  5323. environment this string could contain a reference to the corresponding
  5324. node in the Info page for the program.
  5325. Running this program without specifying the ‘MSGVERB’ and ‘SEV_LEVEL’
  5326. function produces the following output:
  5327. UX:cat: NOTE2: invalid syntax
  5328. TO FIX: refer to manual UX:cat:001
  5329. We see the different fields of the message and how the extra glue
  5330. (the colons and the ‘TO FIX’ string) is printed. But only one of the
  5331. three calls to ‘fmtmsg’ produced output. The first call does not print
  5332. anything because the LABEL parameter is not in the correct form. The
  5333. string must contain two fields, separated by a colon (*note Printing
  5334. Formatted Messages::). The third ‘fmtmsg’ call produced no output since
  5335. the class with the numeric value ‘6’ is not defined. Although a class
  5336. with numeric value ‘5’ is also not defined by default, the call to
  5337. ‘addseverity’ introduces it and the second call to ‘fmtmsg’ produces the
  5338. above output.
  5339. When we change the environment of the program to contain
  5340. ‘SEV_LEVEL=XXX,6,NOTE’ when running it we get a different result:
  5341. UX:cat: NOTE2: invalid syntax
  5342. TO FIX: refer to manual UX:cat:001
  5343. label:foo: NOTE: text
  5344. TO FIX: action tag
  5345. Now the third call to ‘fmtmsg’ produced some output and we see how
  5346. the string ‘NOTE’ from the environment variable appears in the message.
  5347. Now we can reduce the output by specifying which fields we are
  5348. interested in. If we additionally set the environment variable
  5349. ‘MSGVERB’ to the value ‘severity:label:action’ we get the following
  5350. output:
  5351. UX:cat: NOTE2
  5352. TO FIX: refer to manual
  5353. label:foo: NOTE
  5354. TO FIX: action
  5355. I.e., the output produced by the TEXT and the TAG parameters to ‘fmtmsg’
  5356. vanished. Please also note that now there is no colon after the ‘NOTE’
  5357. and ‘NOTE2’ strings in the output. This is not necessary since there is
  5358. no more output on this line because the text is missing.
  5359. 
  5360. File: libc.info, Node: Low-Level I/O, Next: File System Interface, Prev: I/O on Streams, Up: Top
  5361. 13 Low-Level Input/Output
  5362. *************************
  5363. This chapter describes functions for performing low-level input/output
  5364. operations on file descriptors. These functions include the primitives
  5365. for the higher-level I/O functions described in *note I/O on Streams::,
  5366. as well as functions for performing low-level control operations for
  5367. which there are no equivalents on streams.
  5368. Stream-level I/O is more flexible and usually more convenient;
  5369. therefore, programmers generally use the descriptor-level functions only
  5370. when necessary. These are some of the usual reasons:
  5371. • For reading binary files in large chunks.
  5372. • For reading an entire file into core before parsing it.
  5373. • To perform operations other than data transfer, which can only be
  5374. done with a descriptor. (You can use ‘fileno’ to get the
  5375. descriptor corresponding to a stream.)
  5376. • To pass descriptors to a child process. (The child can create its
  5377. own stream to use a descriptor that it inherits, but cannot inherit
  5378. a stream directly.)
  5379. * Menu:
  5380. * Opening and Closing Files:: How to open and close file
  5381. descriptors.
  5382. * I/O Primitives:: Reading and writing data.
  5383. * File Position Primitive:: Setting a descriptor’s file
  5384. position.
  5385. * Descriptors and Streams:: Converting descriptor to stream
  5386. or vice-versa.
  5387. * Stream/Descriptor Precautions:: Precautions needed if you use both
  5388. descriptors and streams.
  5389. * Scatter-Gather:: Fast I/O to discontinuous buffers.
  5390. * Copying File Data:: Copying data between files.
  5391. * Memory-mapped I/O:: Using files like memory.
  5392. * Waiting for I/O:: How to check for input or output
  5393. on multiple file descriptors.
  5394. * Synchronizing I/O:: Making sure all I/O actions completed.
  5395. * Asynchronous I/O:: Perform I/O in parallel.
  5396. * Control Operations:: Various other operations on file
  5397. descriptors.
  5398. * Duplicating Descriptors:: Fcntl commands for duplicating
  5399. file descriptors.
  5400. * Descriptor Flags:: Fcntl commands for manipulating
  5401. flags associated with file
  5402. descriptors.
  5403. * File Status Flags:: Fcntl commands for manipulating
  5404. flags associated with open files.
  5405. * File Locks:: Fcntl commands for implementing
  5406. file locking.
  5407. * Open File Description Locks:: Fcntl commands for implementing
  5408. open file description locking.
  5409. * Open File Description Locks Example:: An example of open file description lock
  5410. usage
  5411. * Interrupt Input:: Getting an asynchronous signal when
  5412. input arrives.
  5413. * IOCTLs:: Generic I/O Control operations.
  5414. 
  5415. File: libc.info, Node: Opening and Closing Files, Next: I/O Primitives, Up: Low-Level I/O
  5416. 13.1 Opening and Closing Files
  5417. ==============================
  5418. This section describes the primitives for opening and closing files
  5419. using file descriptors. The ‘open’ and ‘creat’ functions are declared
  5420. in the header file ‘fcntl.h’, while ‘close’ is declared in ‘unistd.h’.
  5421. -- Function: int open (const char *FILENAME, int FLAGS[, mode_t MODE])
  5422. Preliminary: | MT-Safe | AS-Safe | AC-Safe fd | *Note POSIX Safety
  5423. Concepts::.
  5424. The ‘open’ function creates and returns a new file descriptor for
  5425. the file named by FILENAME. Initially, the file position indicator
  5426. for the file is at the beginning of the file. The argument MODE
  5427. (*note Permission Bits::) is used only when a file is created, but
  5428. it doesn’t hurt to supply the argument in any case.
  5429. The FLAGS argument controls how the file is to be opened. This is
  5430. a bit mask; you create the value by the bitwise OR of the
  5431. appropriate parameters (using the ‘|’ operator in C). *Note File
  5432. Status Flags::, for the parameters available.
  5433. The normal return value from ‘open’ is a non-negative integer file
  5434. descriptor. In the case of an error, a value of -1 is returned
  5435. instead. In addition to the usual file name errors (*note File
  5436. Name Errors::), the following ‘errno’ error conditions are defined
  5437. for this function:
  5438. ‘EACCES’
  5439. The file exists but is not readable/writable as requested by
  5440. the FLAGS argument, or the file does not exist and the
  5441. directory is unwritable so it cannot be created.
  5442. ‘EEXIST’
  5443. Both ‘O_CREAT’ and ‘O_EXCL’ are set, and the named file
  5444. already exists.
  5445. ‘EINTR’
  5446. The ‘open’ operation was interrupted by a signal. *Note
  5447. Interrupted Primitives::.
  5448. ‘EISDIR’
  5449. The FLAGS argument specified write access, and the file is a
  5450. directory.
  5451. ‘EMFILE’
  5452. The process has too many files open. The maximum number of
  5453. file descriptors is controlled by the ‘RLIMIT_NOFILE’ resource
  5454. limit; *note Limits on Resources::.
  5455. ‘ENFILE’
  5456. The entire system, or perhaps the file system which contains
  5457. the directory, cannot support any additional open files at the
  5458. moment. (This problem cannot happen on GNU/Hurd systems.)
  5459. ‘ENOENT’
  5460. The named file does not exist, and ‘O_CREAT’ is not specified.
  5461. ‘ENOSPC’
  5462. The directory or file system that would contain the new file
  5463. cannot be extended, because there is no disk space left.
  5464. ‘ENXIO’
  5465. ‘O_NONBLOCK’ and ‘O_WRONLY’ are both set in the FLAGS
  5466. argument, the file named by FILENAME is a FIFO (*note Pipes
  5467. and FIFOs::), and no process has the file open for reading.
  5468. ‘EROFS’
  5469. The file resides on a read-only file system and any of
  5470. ‘O_WRONLY’, ‘O_RDWR’, and ‘O_TRUNC’ are set in the FLAGS
  5471. argument, or ‘O_CREAT’ is set and the file does not already
  5472. exist.
  5473. If on a 32 bit machine the sources are translated with
  5474. ‘_FILE_OFFSET_BITS == 64’ the function ‘open’ returns a file
  5475. descriptor opened in the large file mode which enables the file
  5476. handling functions to use files up to 2^63 bytes in size and offset
  5477. from −2^63 to 2^63. This happens transparently for the user since
  5478. all of the low-level file handling functions are equally replaced.
  5479. This function is a cancellation point in multi-threaded programs.
  5480. This is a problem if the thread allocates some resources (like
  5481. memory, file descriptors, semaphores or whatever) at the time
  5482. ‘open’ is called. If the thread gets canceled these resources stay
  5483. allocated until the program ends. To avoid this calls to ‘open’
  5484. should be protected using cancellation handlers.
  5485. The ‘open’ function is the underlying primitive for the ‘fopen’ and
  5486. ‘freopen’ functions, that create streams.
  5487. -- Function: int open64 (const char *FILENAME, int FLAGS[, mode_t
  5488. MODE])
  5489. Preliminary: | MT-Safe | AS-Safe | AC-Safe fd | *Note POSIX Safety
  5490. Concepts::.
  5491. This function is similar to ‘open’. It returns a file descriptor
  5492. which can be used to access the file named by FILENAME. The only
  5493. difference is that on 32 bit systems the file is opened in the
  5494. large file mode. I.e., file length and file offsets can exceed 31
  5495. bits.
  5496. When the sources are translated with ‘_FILE_OFFSET_BITS == 64’ this
  5497. function is actually available under the name ‘open’. I.e., the
  5498. new, extended API using 64 bit file sizes and offsets transparently
  5499. replaces the old API.
  5500. -- Obsolete function: int creat (const char *FILENAME, mode_t MODE)
  5501. Preliminary: | MT-Safe | AS-Safe | AC-Safe fd | *Note POSIX Safety
  5502. Concepts::.
  5503. This function is obsolete. The call:
  5504. creat (FILENAME, MODE)
  5505. is equivalent to:
  5506. open (FILENAME, O_WRONLY | O_CREAT | O_TRUNC, MODE)
  5507. If on a 32 bit machine the sources are translated with
  5508. ‘_FILE_OFFSET_BITS == 64’ the function ‘creat’ returns a file
  5509. descriptor opened in the large file mode which enables the file
  5510. handling functions to use files up to 2^63 in size and offset from
  5511. −2^63 to 2^63. This happens transparently for the user since all
  5512. of the low-level file handling functions are equally replaced.
  5513. -- Obsolete function: int creat64 (const char *FILENAME, mode_t MODE)
  5514. Preliminary: | MT-Safe | AS-Safe | AC-Safe fd | *Note POSIX Safety
  5515. Concepts::.
  5516. This function is similar to ‘creat’. It returns a file descriptor
  5517. which can be used to access the file named by FILENAME. The only
  5518. difference is that on 32 bit systems the file is opened in the
  5519. large file mode. I.e., file length and file offsets can exceed 31
  5520. bits.
  5521. To use this file descriptor one must not use the normal operations
  5522. but instead the counterparts named ‘*64’, e.g., ‘read64’.
  5523. When the sources are translated with ‘_FILE_OFFSET_BITS == 64’ this
  5524. function is actually available under the name ‘open’. I.e., the
  5525. new, extended API using 64 bit file sizes and offsets transparently
  5526. replaces the old API.
  5527. -- Function: int close (int FILEDES)
  5528. Preliminary: | MT-Safe | AS-Safe | AC-Safe fd | *Note POSIX Safety
  5529. Concepts::.
  5530. The function ‘close’ closes the file descriptor FILEDES. Closing a
  5531. file has the following consequences:
  5532. • The file descriptor is deallocated.
  5533. • Any record locks owned by the process on the file are
  5534. unlocked.
  5535. • When all file descriptors associated with a pipe or FIFO have
  5536. been closed, any unread data is discarded.
  5537. This function is a cancellation point in multi-threaded programs.
  5538. This is a problem if the thread allocates some resources (like
  5539. memory, file descriptors, semaphores or whatever) at the time
  5540. ‘close’ is called. If the thread gets canceled these resources
  5541. stay allocated until the program ends. To avoid this, calls to
  5542. ‘close’ should be protected using cancellation handlers.
  5543. The normal return value from ‘close’ is 0; a value of -1 is
  5544. returned in case of failure. The following ‘errno’ error
  5545. conditions are defined for this function:
  5546. ‘EBADF’
  5547. The FILEDES argument is not a valid file descriptor.
  5548. ‘EINTR’
  5549. The ‘close’ call was interrupted by a signal. *Note
  5550. Interrupted Primitives::. Here is an example of how to handle
  5551. ‘EINTR’ properly:
  5552. TEMP_FAILURE_RETRY (close (desc));
  5553. ‘ENOSPC’
  5554. ‘EIO’
  5555. ‘EDQUOT’
  5556. When the file is accessed by NFS, these errors from ‘write’
  5557. can sometimes not be detected until ‘close’. *Note I/O
  5558. Primitives::, for details on their meaning.
  5559. Please note that there is _no_ separate ‘close64’ function. This
  5560. is not necessary since this function does not determine nor depend
  5561. on the mode of the file. The kernel which performs the ‘close’
  5562. operation knows which mode the descriptor is used for and can
  5563. handle this situation.
  5564. To close a stream, call ‘fclose’ (*note Closing Streams::) instead of
  5565. trying to close its underlying file descriptor with ‘close’. This
  5566. flushes any buffered output and updates the stream object to indicate
  5567. that it is closed.
  5568. 
  5569. File: libc.info, Node: I/O Primitives, Next: File Position Primitive, Prev: Opening and Closing Files, Up: Low-Level I/O
  5570. 13.2 Input and Output Primitives
  5571. ================================
  5572. This section describes the functions for performing primitive input and
  5573. output operations on file descriptors: ‘read’, ‘write’, and ‘lseek’.
  5574. These functions are declared in the header file ‘unistd.h’.
  5575. -- Data Type: ssize_t
  5576. This data type is used to represent the sizes of blocks that can be
  5577. read or written in a single operation. It is similar to ‘size_t’,
  5578. but must be a signed type.
  5579. -- Function: ssize_t read (int FILEDES, void *BUFFER, size_t SIZE)
  5580. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5581. Concepts::.
  5582. The ‘read’ function reads up to SIZE bytes from the file with
  5583. descriptor FILEDES, storing the results in the BUFFER. (This is
  5584. not necessarily a character string, and no terminating null
  5585. character is added.)
  5586. The return value is the number of bytes actually read. This might
  5587. be less than SIZE; for example, if there aren’t that many bytes
  5588. left in the file or if there aren’t that many bytes immediately
  5589. available. The exact behavior depends on what kind of file it is.
  5590. Note that reading less than SIZE bytes is not an error.
  5591. A value of zero indicates end-of-file (except if the value of the
  5592. SIZE argument is also zero). This is not considered an error. If
  5593. you keep calling ‘read’ while at end-of-file, it will keep
  5594. returning zero and doing nothing else.
  5595. If ‘read’ returns at least one character, there is no way you can
  5596. tell whether end-of-file was reached. But if you did reach the
  5597. end, the next read will return zero.
  5598. In case of an error, ‘read’ returns -1. The following ‘errno’
  5599. error conditions are defined for this function:
  5600. ‘EAGAIN’
  5601. Normally, when no input is immediately available, ‘read’ waits
  5602. for some input. But if the ‘O_NONBLOCK’ flag is set for the
  5603. file (*note File Status Flags::), ‘read’ returns immediately
  5604. without reading any data, and reports this error.
  5605. *Compatibility Note:* Most versions of BSD Unix use a
  5606. different error code for this: ‘EWOULDBLOCK’. In the GNU C
  5607. Library, ‘EWOULDBLOCK’ is an alias for ‘EAGAIN’, so it doesn’t
  5608. matter which name you use.
  5609. On some systems, reading a large amount of data from a
  5610. character special file can also fail with ‘EAGAIN’ if the
  5611. kernel cannot find enough physical memory to lock down the
  5612. user’s pages. This is limited to devices that transfer with
  5613. direct memory access into the user’s memory, which means it
  5614. does not include terminals, since they always use separate
  5615. buffers inside the kernel. This problem never happens on
  5616. GNU/Hurd systems.
  5617. Any condition that could result in ‘EAGAIN’ can instead result
  5618. in a successful ‘read’ which returns fewer bytes than
  5619. requested. Calling ‘read’ again immediately would result in
  5620. ‘EAGAIN’.
  5621. ‘EBADF’
  5622. The FILEDES argument is not a valid file descriptor, or is not
  5623. open for reading.
  5624. ‘EINTR’
  5625. ‘read’ was interrupted by a signal while it was waiting for
  5626. input. *Note Interrupted Primitives::. A signal will not
  5627. necessarily cause ‘read’ to return ‘EINTR’; it may instead
  5628. result in a successful ‘read’ which returns fewer bytes than
  5629. requested.
  5630. ‘EIO’
  5631. For many devices, and for disk files, this error code
  5632. indicates a hardware error.
  5633. ‘EIO’ also occurs when a background process tries to read from
  5634. the controlling terminal, and the normal action of stopping
  5635. the process by sending it a ‘SIGTTIN’ signal isn’t working.
  5636. This might happen if the signal is being blocked or ignored,
  5637. or because the process group is orphaned. *Note Job
  5638. Control::, for more information about job control, and *note
  5639. Signal Handling::, for information about signals.
  5640. ‘EINVAL’
  5641. In some systems, when reading from a character or block
  5642. device, position and size offsets must be aligned to a
  5643. particular block size. This error indicates that the offsets
  5644. were not properly aligned.
  5645. Please note that there is no function named ‘read64’. This is not
  5646. necessary since this function does not directly modify or handle
  5647. the possibly wide file offset. Since the kernel handles this state
  5648. internally, the ‘read’ function can be used for all cases.
  5649. This function is a cancellation point in multi-threaded programs.
  5650. This is a problem if the thread allocates some resources (like
  5651. memory, file descriptors, semaphores or whatever) at the time
  5652. ‘read’ is called. If the thread gets canceled these resources stay
  5653. allocated until the program ends. To avoid this, calls to ‘read’
  5654. should be protected using cancellation handlers.
  5655. The ‘read’ function is the underlying primitive for all of the
  5656. functions that read from streams, such as ‘fgetc’.
  5657. -- Function: ssize_t pread (int FILEDES, void *BUFFER, size_t SIZE,
  5658. off_t OFFSET)
  5659. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5660. Concepts::.
  5661. The ‘pread’ function is similar to the ‘read’ function. The first
  5662. three arguments are identical, and the return values and error
  5663. codes also correspond.
  5664. The difference is the fourth argument and its handling. The data
  5665. block is not read from the current position of the file descriptor
  5666. ‘filedes’. Instead the data is read from the file starting at
  5667. position OFFSET. The position of the file descriptor itself is not
  5668. affected by the operation. The value is the same as before the
  5669. call.
  5670. When the source file is compiled with ‘_FILE_OFFSET_BITS == 64’ the
  5671. ‘pread’ function is in fact ‘pread64’ and the type ‘off_t’ has 64
  5672. bits, which makes it possible to handle files up to 2^63 bytes in
  5673. length.
  5674. The return value of ‘pread’ describes the number of bytes read. In
  5675. the error case it returns -1 like ‘read’ does and the error codes
  5676. are also the same, with these additions:
  5677. ‘EINVAL’
  5678. The value given for OFFSET is negative and therefore illegal.
  5679. ‘ESPIPE’
  5680. The file descriptor FILEDES is associated with a pipe or a
  5681. FIFO and this device does not allow positioning of the file
  5682. pointer.
  5683. The function is an extension defined in the Unix Single
  5684. Specification version 2.
  5685. -- Function: ssize_t pread64 (int FILEDES, void *BUFFER, size_t SIZE,
  5686. off64_t OFFSET)
  5687. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5688. Concepts::.
  5689. This function is similar to the ‘pread’ function. The difference
  5690. is that the OFFSET parameter is of type ‘off64_t’ instead of
  5691. ‘off_t’ which makes it possible on 32 bit machines to address files
  5692. larger than 2^31 bytes and up to 2^63 bytes. The file descriptor
  5693. ‘filedes’ must be opened using ‘open64’ since otherwise the large
  5694. offsets possible with ‘off64_t’ will lead to errors with a
  5695. descriptor in small file mode.
  5696. When the source file is compiled with ‘_FILE_OFFSET_BITS == 64’ on
  5697. a 32 bit machine this function is actually available under the name
  5698. ‘pread’ and so transparently replaces the 32 bit interface.
  5699. -- Function: ssize_t write (int FILEDES, const void *BUFFER, size_t
  5700. SIZE)
  5701. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5702. Concepts::.
  5703. The ‘write’ function writes up to SIZE bytes from BUFFER to the
  5704. file with descriptor FILEDES. The data in BUFFER is not
  5705. necessarily a character string and a null character is output like
  5706. any other character.
  5707. The return value is the number of bytes actually written. This may
  5708. be SIZE, but can always be smaller. Your program should always
  5709. call ‘write’ in a loop, iterating until all the data is written.
  5710. Once ‘write’ returns, the data is enqueued to be written and can be
  5711. read back right away, but it is not necessarily written out to
  5712. permanent storage immediately. You can use ‘fsync’ when you need
  5713. to be sure your data has been permanently stored before continuing.
  5714. (It is more efficient for the system to batch up consecutive writes
  5715. and do them all at once when convenient. Normally they will always
  5716. be written to disk within a minute or less.) Modern systems
  5717. provide another function ‘fdatasync’ which guarantees integrity
  5718. only for the file data and is therefore faster. You can use the
  5719. ‘O_FSYNC’ open mode to make ‘write’ always store the data to disk
  5720. before returning; *note Operating Modes::.
  5721. In the case of an error, ‘write’ returns -1. The following ‘errno’
  5722. error conditions are defined for this function:
  5723. ‘EAGAIN’
  5724. Normally, ‘write’ blocks until the write operation is
  5725. complete. But if the ‘O_NONBLOCK’ flag is set for the file
  5726. (*note Control Operations::), it returns immediately without
  5727. writing any data and reports this error. An example of a
  5728. situation that might cause the process to block on output is
  5729. writing to a terminal device that supports flow control, where
  5730. output has been suspended by receipt of a STOP character.
  5731. *Compatibility Note:* Most versions of BSD Unix use a
  5732. different error code for this: ‘EWOULDBLOCK’. In the GNU C
  5733. Library, ‘EWOULDBLOCK’ is an alias for ‘EAGAIN’, so it doesn’t
  5734. matter which name you use.
  5735. On some systems, writing a large amount of data from a
  5736. character special file can also fail with ‘EAGAIN’ if the
  5737. kernel cannot find enough physical memory to lock down the
  5738. user’s pages. This is limited to devices that transfer with
  5739. direct memory access into the user’s memory, which means it
  5740. does not include terminals, since they always use separate
  5741. buffers inside the kernel. This problem does not arise on
  5742. GNU/Hurd systems.
  5743. ‘EBADF’
  5744. The FILEDES argument is not a valid file descriptor, or is not
  5745. open for writing.
  5746. ‘EFBIG’
  5747. The size of the file would become larger than the
  5748. implementation can support.
  5749. ‘EINTR’
  5750. The ‘write’ operation was interrupted by a signal while it was
  5751. blocked waiting for completion. A signal will not necessarily
  5752. cause ‘write’ to return ‘EINTR’; it may instead result in a
  5753. successful ‘write’ which writes fewer bytes than requested.
  5754. *Note Interrupted Primitives::.
  5755. ‘EIO’
  5756. For many devices, and for disk files, this error code
  5757. indicates a hardware error.
  5758. ‘ENOSPC’
  5759. The device containing the file is full.
  5760. ‘EPIPE’
  5761. This error is returned when you try to write to a pipe or FIFO
  5762. that isn’t open for reading by any process. When this
  5763. happens, a ‘SIGPIPE’ signal is also sent to the process; see
  5764. *note Signal Handling::.
  5765. ‘EINVAL’
  5766. In some systems, when writing to a character or block device,
  5767. position and size offsets must be aligned to a particular
  5768. block size. This error indicates that the offsets were not
  5769. properly aligned.
  5770. Unless you have arranged to prevent ‘EINTR’ failures, you should
  5771. check ‘errno’ after each failing call to ‘write’, and if the error
  5772. was ‘EINTR’, you should simply repeat the call. *Note Interrupted
  5773. Primitives::. The easy way to do this is with the macro
  5774. ‘TEMP_FAILURE_RETRY’, as follows:
  5775. nbytes = TEMP_FAILURE_RETRY (write (desc, buffer, count));
  5776. Please note that there is no function named ‘write64’. This is not
  5777. necessary since this function does not directly modify or handle
  5778. the possibly wide file offset. Since the kernel handles this state
  5779. internally the ‘write’ function can be used for all cases.
  5780. This function is a cancellation point in multi-threaded programs.
  5781. This is a problem if the thread allocates some resources (like
  5782. memory, file descriptors, semaphores or whatever) at the time
  5783. ‘write’ is called. If the thread gets canceled these resources
  5784. stay allocated until the program ends. To avoid this, calls to
  5785. ‘write’ should be protected using cancellation handlers.
  5786. The ‘write’ function is the underlying primitive for all of the
  5787. functions that write to streams, such as ‘fputc’.
  5788. -- Function: ssize_t pwrite (int FILEDES, const void *BUFFER, size_t
  5789. SIZE, off_t OFFSET)
  5790. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5791. Concepts::.
  5792. The ‘pwrite’ function is similar to the ‘write’ function. The
  5793. first three arguments are identical, and the return values and
  5794. error codes also correspond.
  5795. The difference is the fourth argument and its handling. The data
  5796. block is not written to the current position of the file descriptor
  5797. ‘filedes’. Instead the data is written to the file starting at
  5798. position OFFSET. The position of the file descriptor itself is not
  5799. affected by the operation. The value is the same as before the
  5800. call.
  5801. However, on Linux, if a file is opened with ‘O_APPEND’, ‘pwrite’
  5802. appends data to the end of the file, regardless of the value of
  5803. ‘offset’.
  5804. When the source file is compiled with ‘_FILE_OFFSET_BITS == 64’ the
  5805. ‘pwrite’ function is in fact ‘pwrite64’ and the type ‘off_t’ has 64
  5806. bits, which makes it possible to handle files up to 2^63 bytes in
  5807. length.
  5808. The return value of ‘pwrite’ describes the number of written bytes.
  5809. In the error case it returns -1 like ‘write’ does and the error
  5810. codes are also the same, with these additions:
  5811. ‘EINVAL’
  5812. The value given for OFFSET is negative and therefore illegal.
  5813. ‘ESPIPE’
  5814. The file descriptor FILEDES is associated with a pipe or a
  5815. FIFO and this device does not allow positioning of the file
  5816. pointer.
  5817. The function is an extension defined in the Unix Single
  5818. Specification version 2.
  5819. -- Function: ssize_t pwrite64 (int FILEDES, const void *BUFFER, size_t
  5820. SIZE, off64_t OFFSET)
  5821. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5822. Concepts::.
  5823. This function is similar to the ‘pwrite’ function. The difference
  5824. is that the OFFSET parameter is of type ‘off64_t’ instead of
  5825. ‘off_t’ which makes it possible on 32 bit machines to address files
  5826. larger than 2^31 bytes and up to 2^63 bytes. The file descriptor
  5827. ‘filedes’ must be opened using ‘open64’ since otherwise the large
  5828. offsets possible with ‘off64_t’ will lead to errors with a
  5829. descriptor in small file mode.
  5830. When the source file is compiled using ‘_FILE_OFFSET_BITS == 64’ on
  5831. a 32 bit machine this function is actually available under the name
  5832. ‘pwrite’ and so transparently replaces the 32 bit interface.
  5833. 
  5834. File: libc.info, Node: File Position Primitive, Next: Descriptors and Streams, Prev: I/O Primitives, Up: Low-Level I/O
  5835. 13.3 Setting the File Position of a Descriptor
  5836. ==============================================
  5837. Just as you can set the file position of a stream with ‘fseek’, you can
  5838. set the file position of a descriptor with ‘lseek’. This specifies the
  5839. position in the file for the next ‘read’ or ‘write’ operation. *Note
  5840. File Positioning::, for more information on the file position and what
  5841. it means.
  5842. To read the current file position value from a descriptor, use ‘lseek
  5843. (DESC, 0, SEEK_CUR)’.
  5844. -- Function: off_t lseek (int FILEDES, off_t OFFSET, int WHENCE)
  5845. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5846. Concepts::.
  5847. The ‘lseek’ function is used to change the file position of the
  5848. file with descriptor FILEDES.
  5849. The WHENCE argument specifies how the OFFSET should be interpreted,
  5850. in the same way as for the ‘fseek’ function, and it must be one of
  5851. the symbolic constants ‘SEEK_SET’, ‘SEEK_CUR’, or ‘SEEK_END’.
  5852. ‘SEEK_SET’
  5853. Specifies that OFFSET is a count of characters from the
  5854. beginning of the file.
  5855. ‘SEEK_CUR’
  5856. Specifies that OFFSET is a count of characters from the
  5857. current file position. This count may be positive or
  5858. negative.
  5859. ‘SEEK_END’
  5860. Specifies that OFFSET is a count of characters from the end of
  5861. the file. A negative count specifies a position within the
  5862. current extent of the file; a positive count specifies a
  5863. position past the current end. If you set the position past
  5864. the current end, and actually write data, you will extend the
  5865. file with zeros up to that position.
  5866. The return value from ‘lseek’ is normally the resulting file
  5867. position, measured in bytes from the beginning of the file. You
  5868. can use this feature together with ‘SEEK_CUR’ to read the current
  5869. file position.
  5870. If you want to append to the file, setting the file position to the
  5871. current end of file with ‘SEEK_END’ is not sufficient. Another
  5872. process may write more data after you seek but before you write,
  5873. extending the file so the position you write onto clobbers their
  5874. data. Instead, use the ‘O_APPEND’ operating mode; *note Operating
  5875. Modes::.
  5876. You can set the file position past the current end of the file.
  5877. This does not by itself make the file longer; ‘lseek’ never changes
  5878. the file. But subsequent output at that position will extend the
  5879. file. Characters between the previous end of file and the new
  5880. position are filled with zeros. Extending the file in this way can
  5881. create a “hole”: the blocks of zeros are not actually allocated on
  5882. disk, so the file takes up less space than it appears to; it is
  5883. then called a “sparse file”.
  5884. If the file position cannot be changed, or the operation is in some
  5885. way invalid, ‘lseek’ returns a value of -1. The following ‘errno’
  5886. error conditions are defined for this function:
  5887. ‘EBADF’
  5888. The FILEDES is not a valid file descriptor.
  5889. ‘EINVAL’
  5890. The WHENCE argument value is not valid, or the resulting file
  5891. offset is not valid. A file offset is invalid.
  5892. ‘ESPIPE’
  5893. The FILEDES corresponds to an object that cannot be
  5894. positioned, such as a pipe, FIFO or terminal device. (POSIX.1
  5895. specifies this error only for pipes and FIFOs, but on GNU
  5896. systems, you always get ‘ESPIPE’ if the object is not
  5897. seekable.)
  5898. When the source file is compiled with ‘_FILE_OFFSET_BITS == 64’ the
  5899. ‘lseek’ function is in fact ‘lseek64’ and the type ‘off_t’ has 64
  5900. bits which makes it possible to handle files up to 2^63 bytes in
  5901. length.
  5902. This function is a cancellation point in multi-threaded programs.
  5903. This is a problem if the thread allocates some resources (like
  5904. memory, file descriptors, semaphores or whatever) at the time
  5905. ‘lseek’ is called. If the thread gets canceled these resources
  5906. stay allocated until the program ends. To avoid this calls to
  5907. ‘lseek’ should be protected using cancellation handlers.
  5908. The ‘lseek’ function is the underlying primitive for the ‘fseek’,
  5909. ‘fseeko’, ‘ftell’, ‘ftello’ and ‘rewind’ functions, which operate
  5910. on streams instead of file descriptors.
  5911. -- Function: off64_t lseek64 (int FILEDES, off64_t OFFSET, int WHENCE)
  5912. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5913. Concepts::.
  5914. This function is similar to the ‘lseek’ function. The difference
  5915. is that the OFFSET parameter is of type ‘off64_t’ instead of
  5916. ‘off_t’ which makes it possible on 32 bit machines to address files
  5917. larger than 2^31 bytes and up to 2^63 bytes. The file descriptor
  5918. ‘filedes’ must be opened using ‘open64’ since otherwise the large
  5919. offsets possible with ‘off64_t’ will lead to errors with a
  5920. descriptor in small file mode.
  5921. When the source file is compiled with ‘_FILE_OFFSET_BITS == 64’ on
  5922. a 32 bits machine this function is actually available under the
  5923. name ‘lseek’ and so transparently replaces the 32 bit interface.
  5924. You can have multiple descriptors for the same file if you open the
  5925. file more than once, or if you duplicate a descriptor with ‘dup’.
  5926. Descriptors that come from separate calls to ‘open’ have independent
  5927. file positions; using ‘lseek’ on one descriptor has no effect on the
  5928. other. For example,
  5929. {
  5930. int d1, d2;
  5931. char buf[4];
  5932. d1 = open ("foo", O_RDONLY);
  5933. d2 = open ("foo", O_RDONLY);
  5934. lseek (d1, 1024, SEEK_SET);
  5935. read (d2, buf, 4);
  5936. }
  5937. will read the first four characters of the file ‘foo’. (The
  5938. error-checking code necessary for a real program has been omitted here
  5939. for brevity.)
  5940. By contrast, descriptors made by duplication share a common file
  5941. position with the original descriptor that was duplicated. Anything
  5942. which alters the file position of one of the duplicates, including
  5943. reading or writing data, affects all of them alike. Thus, for example,
  5944. {
  5945. int d1, d2, d3;
  5946. char buf1[4], buf2[4];
  5947. d1 = open ("foo", O_RDONLY);
  5948. d2 = dup (d1);
  5949. d3 = dup (d2);
  5950. lseek (d3, 1024, SEEK_SET);
  5951. read (d1, buf1, 4);
  5952. read (d2, buf2, 4);
  5953. }
  5954. will read four characters starting with the 1024’th character of ‘foo’,
  5955. and then four more characters starting with the 1028’th character.
  5956. -- Data Type: off_t
  5957. This is a signed integer type used to represent file sizes. In the
  5958. GNU C Library, this type is no narrower than ‘int’.
  5959. If the source is compiled with ‘_FILE_OFFSET_BITS == 64’ this type
  5960. is transparently replaced by ‘off64_t’.
  5961. -- Data Type: off64_t
  5962. This type is used similar to ‘off_t’. The difference is that even
  5963. on 32 bit machines, where the ‘off_t’ type would have 32 bits,
  5964. ‘off64_t’ has 64 bits and so is able to address files up to 2^63
  5965. bytes in length.
  5966. When compiling with ‘_FILE_OFFSET_BITS == 64’ this type is
  5967. available under the name ‘off_t’.
  5968. These aliases for the ‘SEEK_...’ constants exist for the sake of
  5969. compatibility with older BSD systems. They are defined in two different
  5970. header files: ‘fcntl.h’ and ‘sys/file.h’.
  5971. ‘L_SET’
  5972. An alias for ‘SEEK_SET’.
  5973. ‘L_INCR’
  5974. An alias for ‘SEEK_CUR’.
  5975. ‘L_XTND’
  5976. An alias for ‘SEEK_END’.