123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092 |
- /*++
- Copyright (c) 2013 Minoca Corp.
- This file is licensed under the terms of the GNU Lesser General Public
- License version 3. Alternative licensing terms are available. Contact
- info@minocacorp.com for details.
- Module Name:
- unistd.h
- Abstract:
- This header contains standard system types and definitions.
- Author:
- Evan Green 5-Mar-2013
- --*/
- #ifndef _UNISTD_H
- #define _UNISTD_H
- //
- // ------------------------------------------------------------------- Includes
- //
- #include <sys/types.h>
- #include <stddef.h>
- #include <stdint.h>
- //
- // ---------------------------------------------------------------- Definitions
- //
- #ifdef __cplusplus
- extern "C" {
- #endif
- //
- // Define the POSIX version this implementation (mostly) conforms to.
- //
- #define _POSIX_VERSION 200809L
- #define _POSIX2_VERSION 200809L
- #define _XOPEN_VERSION 700
- //
- // Define the POSIX constants for options and option groups.
- //
- #define _POSIX_BARRIERS 200809L
- #define _POSIX_CHOWN_RESTRICTED 1
- #define _POSIX_CLOCK_SELECTION 200809L
- #define _POSIX_CPUTIME -1
- #define _POSIX_FSYNC 200809L
- #define _POSIX_IPV6 200809L
- #define _POSIX_JOB_CONTROL 1
- #define _POSIX_MAPPED_FILES 200809L
- #define _POSIX_MEMLOCK -1
- #define _POSIX_MEMLOCK_RANGE -1
- #define _POSIX_MEMORY_PROTECTION 200809L
- #define _POSIX_MESSAGE_PASSING -1
- #define _POSIX_MONOTONIC_CLOCK 200809L
- #define _POSIX_NO_TRUNC 0
- #define _POSIX_PRIORITIZED_IO -1
- #define _POSIX_PRIORITY_SCHEDULING -1
- #define _POSIX_RAW_SOCKETS 200809L
- #define _POSIX_READER_WRITER_LOCKS 200809L
- #define _POSIX_REALTIME_SIGNALS 200809L
- #define _POSIX_REGEXP 1
- #define _POSIX_SAVED_IDS 1
- #define _POSIX_SEMAPHORES 200809L
- #define _POSIX_SHARED_MEMORY_OBJECTS 200809L
- #define _POSIX_SHELL 1
- #define _POSIX_SPAWN 200809L
- #define _POSIX_SPIN_LOCKS -1
- #define _POSIX_SPORADIC_SERVER -1
- #define _POSIX_SYNCHRONIZED_IO 200890L
- #define _POSIX_THREAD_ATTR_STACKADDR 200809L
- #define _POSIX_THREAD_ATTR_STACKSIZE 200809L
- #define _POSIX_THREAD_CPUTIME -1
- #define _POSIX_THREAD_PRIO_INHERIT -1
- #define _POSIX_THREAD_PRIO_PROTECT -1
- #define _POSIX_THREAD_PRIORITY_SCHEDULING -1
- #define _POSIX_THREAD_PROCESS_SHARED 200809L
- #define _POSIX_THREAD_ROBUST_PRIO_INHERIT -1
- #define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1
- #define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
- #define _POSIX_THREAD_SPORADIC_SERVER -1
- #define _POSIX_THREADS 200809L
- #define _POSIX_TIMEOUTS 200809L
- #define _POSIX_TIMERS 200809L
- #define _POSIX_TRACE -1
- #define _POSIX_TRACE_EVENT_FILTER -1
- #define _POSIX_TRACE_INHERIT -1
- #define _POSIX_TRACE_LOG -1
- #define _POSIX_TYPED_MEMORY_OBJECTS -1
- #if (__SIZEOF_POINTER__ == 8)
- #define _POSIX_V6_ILP32_OFF32 -1
- #define _POSIX_V6_ILP32_OFFBIG -1
- #define _POSIX_V6_LP64_OFF64 1
- #define _POSIX_V6_LPBIG_OFFBIG -1
- #define _POSIX_V7_ILP32_OFF32 -1
- #define _POSIX_V7_ILP32_OFFBIG -1
- #define _POSIX_V7_LP64_OFF64 1
- #define _POSIX_V7_LPBIG_OFFBIG -1
- #else
- #define _POSIX_V6_ILP32_OFF32 -1
- #define _POSIX_V6_ILP32_OFFBIG 1
- #define _POSIX_V6_LP64_OFF64 -1
- #define _POSIX_V6_LPBIG_OFFBIG -1
- #define _POSIX_V7_ILP32_OFF32 -1
- #define _POSIX_V7_ILP32_OFFBIG 1
- #define _POSIX_V7_LP64_OFF64 -1
- #define _POSIX_V7_LPBIG_OFFBIG -1
- #endif
- #define _POSIX2_C_BIND 200809L
- #define _POSIX2_C_DEV 200809L
- #define _POSIX2_CHAR_TERM 1
- #define _POSIX2_FORT_DEV -1
- #define _POSIX2_FORT_RUN -1
- #define _POSIX2_LOCALEDEF 200809L
- #define _POSIX2_PBS -1
- #define _POSIX2_PBS_ACCOUNTING -1
- #define _POSIX2_PBS_CHECKPOINT -1
- #define _POSIX2_PBS_LOCATE -1
- #define _POSIX2_PBS_MESSAGE -1
- #define _POSIX2_PBS_TRACK -1
- #define _POSIX2_SW_DEV 200809L
- #define _POSIX2_UPE 200809L
- #define _XOPEN_CRYPT 1
- #define _XOPEN_ENH_I18N 1
- #define _XOPEN_REALTIME -1
- #define _XOPEN_REALTIME_THREADS -1
- #define _XOPEN_SHM 1
- #define _XOPEN_STREAMS -1
- #define _XOPEN_UNIX 1
- #define _XOPEN_UUCP -1
- //
- // Define all libcrypt API functions to be imports unless otherwise specified.
- //
- #ifndef LIBCRYPT_API
- #define LIBCRYPT_API __DLLIMPORT
- #endif
- //
- // Define the value of a character that shall disable terminal special
- // character handling.
- //
- #define _POSIX_VDISABLE '\0'
- //
- // Define the standard file descriptors.
- //
- #define STDIN_FILENO 0
- #define STDOUT_FILENO 1
- #define STDERR_FILENO 2
- //
- // Define flags used in calls to "access" that specify whether a given path
- // is readable, writable, or executable. Also define a flag indicating if the
- // file exists at all. Note that these constants match up with the
- // EFFECTIVE_ACCESS_* definitions used by the kernel.
- //
- #define F_OK 0x00000000
- #define X_OK 0x00000001
- #define W_OK 0x00000002
- #define R_OK 0x00000004
- //
- // Define sysconf constants.
- //
- //
- // Determine the number of clock ticks per second for the clock_t type.
- //
- #define _SC_CLK_TCK 1
- //
- // Determine the size of a page on this system.
- //
- #define _SC_PAGE_SIZE 2
- #define _SC_PAGESIZE _SC_PAGE_SIZE
- //
- // Determine the maximum length of arguments to the exec functions.
- //
- #define _SC_ARG_MAX 3
- //
- // Determine the number of simultaneous processes per user ID.
- //
- #define _SC_CHILD_MAX 4
- //
- // Determine the maximum length of a hostname, not including the null
- // terminator, as returned by gethostname.
- //
- #define _SC_HOST_NAME_MAX 5
- //
- // Determine the maximum length of a login name, including the null terminator.
- //
- #define _SC_LOGIN_NAME_MAX 6
- //
- // Determine the maximum number of files that a process can have open at any
- // time.
- //
- #define _SC_OPEN_MAX 7
- //
- // Determine the maximum number of repeated occurrences of a BRE permitted by
- // regexec and regcomp.
- //
- #define _SC_RE_DUP_MAX 8
- //
- // Determine the maximum number of streams that a process can have open at any
- // time.
- //
- #define _SC_STREAM_MAX 9
- //
- // Determine the maximum number of symbolic links seen in a pathname before
- // resolution returns ELOOP.
- //
- #define _SC_SYMLOOP_MAX 10
- //
- // Determine the maximum length of a terminal device name, including the null
- // terminator.
- //
- #define _SC_TTY_NAME_MAX 11
- //
- // Determine the maximum number of bytes in a timezone name.
- //
- #define _SC_TZNAME_MAX 12
- //
- // Determine the year and month the POSIX.1 standard was approved in the
- // format YYYYMML. The value 199009 indicates the September 1990 revision.
- //
- #define _SC_VERSION 13
- //
- // Determine the maximum obase value accepted by the bc utility.
- //
- #define _SC_BC_BASE_MAX 14
- //
- // Determine the maximum value of elements permitted in an array by the bc
- // utility.
- //
- #define _SC_BC_DIM_MAX 15
- //
- // Determine the maximum scale value allowed by the bc utility.
- //
- #define _SC_BC_SCALE_MAX 16
- //
- // Determine the maximum length of a string accepted by the bc utility.
- //
- #define _SC_BC_STRING_MAX 17
- //
- // Determine the maximum number of weights that can be assigned to an entry
- // of the LC_COLLATE order keyword in the locale definition file.
- //
- #define _SC_COLL_WEIGHTS_MAX 18
- //
- // Determine the maximum number of expressions which can be nested within
- // parentheses by the expr utility.
- //
- #define _SC_EXPR_NEST_MAX 19
- //
- // Determine the maximum length of a utility's input line, either from standard
- // input or from a file. This includes space for a trailing newline.
- //
- //
- #define _SC_LINE_MAX 20
- //
- // Determine the version of the POSIX.2 standard in the format of YYYYMML.
- //
- #define _SC_2_VERSION 21
- //
- // Determine whether the POSIX.2 C language development facilities are
- // supported.
- //
- #define _SC_2_C_DEV 22
- //
- // Determine whether the POSIX.2 FORTRAN development utilities are supported.
- //
- #define _SC_2_FORT_DEV 23
- //
- // Determine whether the POSIX.2 FORTRAN runtime utilities are supported.
- //
- #define _SC_2_FORT_RUN 24
- //
- // Determine whether the POSIX.2 creation of locales via localedef is supported.
- //
- #define _SC_2_LOCALEDEF 25
- //
- // Determine whether the POSIX.2 software development utilities option is
- // supported.
- //
- #define _SC_2_SW_DEV 26
- //
- // Determine the total number of physical pages in the system.
- //
- #define _SC_PHYS_PAGES 27
- //
- // Determine the total number of physical pages in the system that are
- // currently allocated.
- //
- #define _SC_AVPHYS_PAGES 28
- //
- // Determine the number of processors configured.
- //
- #define _SC_NPROCESSORS_CONF 29
- //
- // Determine the number of processors online.
- //
- #define _SC_NPROCESSORS_ONLN 30
- //
- // Define the maximum size of getgrgid_r and getgrnam_r data buffers.
- //
- #define _SC_GETGR_R_SIZE_MAX 31
- //
- // Define the maximum size of getpwuid_r and getpwnam_r data buffers.
- //
- #define _SC_GETPW_R_SIZE_MAX 32
- //
- // Define the maximum number of groups in the system.
- //
- #define _SC_NGROUPS_MAX 33
- //
- // Determine whether POSIX thread barriers are supported.
- //
- #define _SC_BARRIERS 34
- //
- // Determine whether POSIX clock selection is supported.
- //
- #define _SC_CLOCK_SELECTION 35
- //
- // Determine whether the Process CPU-Time Clocks option is supported.
- //
- #define _SC_CPUTIME 36
- //
- // Determine whether the File Synchronization option is supported.
- //
- #define _SC_FSYNC 37
- //
- // Determine whether the IPv6 option is supported.
- //
- #define _SC_IPV6 38
- //
- // Determine whether job control is supported.
- //
- #define _SC_JOB_CONTROL 39
- //
- // Determine whether memory mapped files are supported.
- //
- #define _SC_MAPPED_FILES 40
- //
- // Determine whether the Process Memory Locking option is supported.
- //
- #define _SC_MEMLOCK 41
- //
- // Determine whether the Range Memory Locking option is supported.
- //
- #define _SC_MEMLOCK_RANGE 42
- //
- // Determine whether memory protection is supported.
- //
- #define _SC_MEMORY_PROTECTION 43
- //
- // Determine whether the Message Passing option is supported.
- //
- #define _SC_MESSAGE_PASSING 44
- //
- // Determine whether the the Monotonic Clock option is supported.
- //
- #define _SC_MONOTONIC_CLOCK 45
- //
- // Determine whether the Prioritized Input and Output option is supported.
- //
- #define _SC_PRIORITIZED_IO 46
- //
- // Determine whether the Process Scheduling opion is supported.
- //
- #define _SC_PRIORITY_SCHEDULING 47
- //
- // Determine whether the Raw Sockets options is supported.
- //
- #define _SC_RAW_SOCKETS 48
- //
- // Determine whether read-write locks are supported.
- //
- #define _SC_READER_WRITER_LOCKS 49
- //
- // Determine whether realtime signals are supported.
- //
- #define _SC_REALTIME_SIGNALS 50
- //
- // Determine whether regular expression handling is supported.
- //
- #define _SC_REGEXP 51
- //
- // Determine whether each process has a saved set-user-ID and a saved
- // set-group-ID.
- //
- #define _SC_SAVED_IDS 52
- //
- // Determine whether semaphores are supported.
- //
- #define _SC_SEMAPHORES 53
- //
- // Determine whether the Shared Memory Objects option is supported.
- //
- #define _SC_SHARED_MEMORY_OBJECTS 54
- //
- // Determine whether the POSIX shell is supported.
- //
- #define _SC_SHELL 55
- //
- // Determine whetherthe Spawn option is supported.
- //
- #define _SC_SPAWN 56
- //
- // Determine whether the Spin Locks options is supported.
- //
- #define _SC_SPIN_LOCKS 57
- //
- // Determine whether the Process Sporadic Server option is supported.
- //
- #define _SC_SPORADIC_SERVER 58
- //
- // Determine whether the Synchronized Input and Output option is supported.
- //
- #define _SC_SYNCHRONIZED_IO 59
- //
- // Determine whether the Thread Stack Address Attribute option is supported.
- //
- #define _SC_THREAD_ATTR_STACKADDR 60
- //
- // Determine whether the Thread Stack Size Attribute option is supported.
- //
- #define _SC_THREAD_ATTR_STACKSIZE 61
- //
- // Determine whether the Thread CPU-Time Clocks option is supported.
- //
- #define _SC_THREAD_CPUTIME 62
- //
- // Determine whether the Non-Robust Mutex Priority Inheritance option is
- // supported.
- //
- #define _SC_THREAD_PRIO_INHERIT 63
- //
- // Determine whether the Non-Robust Mutex Priority Protection option is
- // supported.
- //
- #define _SC_THREAD_PRIO_PROTECT 64
- //
- // Determine whether the Thread Execution Scheduilng option is supported.
- //
- #define _SC_THREAD_PRIORITY_SCHEDULING 65
- //
- // Determine whether the Thread Process-Shared Synchronization option is
- // supported.
- //
- #define _SC_THREAD_PROCESS_SHARED 66
- //
- // Determine whether the Robust Mutex Priority Inheritance option is supported.
- //
- #define _SC_THREAD_ROBUST_PRIO_INHERIT 67
- //
- // Determine whether the Robust Mutex Priority Protection option is supported.
- //
- #define _SC_THREAD_ROBUST_PRIO_PROTECT 68
- //
- // Determine whether thread-safe functions are supported.
- //
- #define _SC_THREAD_SAFE_FUNCTIONS 69
- //
- // Determine whether the Thread Sporadic Server option is supported.
- //
- #define _SC_THREAD_SPORADIC_SERVER 70
- //
- // Determine whether threads are supported.
- //
- #define _SC_THREADS 71
- //
- // Determine whether timeouts are supported.
- //
- #define _SC_TIMEOUTS 72
- //
- // Determine whether timers are supported.
- //
- #define _SC_TIMERS 73
- //
- // Determine whether the Trace option is supported.
- //
- #define _SC_TRACE 74
- //
- // Determine whether the Trace Event Filter option is supported.
- //
- #define _SC_TRACE_EVENT_FILTER 75
- //
- // Determine whether the Trace Inherit option is supported.
- //
- #define _SC_TRACE_INHERIT 76
- //
- // Determine whether the Trace Log option is supported.
- //
- #define _SC_TRACE_LOG 77
- //
- // Determine whether the Typed Memory Objects option is supported.
- //
- #define _SC_TYPED_MEMORY_OBJECTS 78
- //
- // Determine whether the C-language compilation environment has 32-bit int,
- // long, pointer, and off_t types.
- //
- #define _SC_V6_ILP32_OFF32 79
- //
- // Determine whether the C-language compilation environment has 32-bit int,
- // long, and pointer types, and an off_t type of at least 64-bits.
- //
- #define _SC_V6_ILP32_OFFBIG 80
- //
- // Determine whether the C-language compilation environment has 32-bit int and
- // 64-bit long, pointer, and off_t types.
- //
- #define _SC_V6_LP64_OFF64 81
- //
- // Determine whether the C-language compilation environment has an int type of
- // at least 32-bits and long, pointer, and off_t types of at least 64-bits.
- //
- #define _SC_V6_LPBIG_OFFBIG 82
- //
- // Determine whether the C-language compilation environment has 32-bit int,
- // long, pointer, and off_t types.
- //
- #define _SC_V7_ILP32_OFF32 83
- //
- // Determine whether the C-language compilation environment has 32-bit int,
- // long, and pointer types, and an off_t type of at least 64-bits.
- //
- #define _SC_V7_ILP32_OFFBIG 84
- //
- // Determine whether the C-language compilation environment has 32-bit int and
- // 64-bit long, pointer, and off_t types.
- //
- #define _SC_V7_LP64_OFF64 85
- //
- // Determine whether the C-language compilation environment has an int type of
- // at least 32-bits and long, pointer, and off_t types of at least 64-bits.
- //
- #define _SC_V7_LPBIG_OFFBIG 86
- //
- // Determine whether the C-Language Binding option is supported.
- //
- #define _SC_2_C_BIND 87
- //
- // Determine whether the Terminal Characteristics option is supported.
- //
- #define _SC_2_CHAR_TERM 88
- //
- // Determine whether the Batch Environment Services and Utilities option is
- // supported.
- //
- #define _SC_2_PBS 89
- //
- // Determine whether the Batch Accounting option is supported.
- //
- #define _SC_2_PBS_ACCOUNTING 90
- //
- // Determine whether the Batch Checkpoint/Restart option is supported.
- //
- #define _SC_2_PBS_CHECKPOINT 91
- //
- // Determine whether the Locate Batch Job Request option is supported.
- //
- #define _SC_2_PBS_LOCATE 92
- //
- // Determine whether the Batch Job Message Request option is supported.
- //
- #define _SC_2_PBS_MESSAGE 93
- //
- // Determine whether the Track Batch Job Request option is supported.
- //
- #define _SC_2_PBS_TRACK 94
- //
- // Determine whether the User Portability Utilities option is supported.
- //
- #define _SC_2_UPE 95
- //
- // Determine whether the X/Open Encryption Option Group is supported.
- //
- #define _SC_XOPEN_CRYPT 96
- //
- // Determine whether the Issue 4, Version 2 Enhanced Internationalization
- // Option Group is supported.
- //
- #define _SC_XOPEN_ENH_I18N 97
- //
- // Determine whether the X/Open Realtime Option Group is supported.
- //
- #define _SC_XOPEN_REALTIME 98
- //
- // Determine whether the X/Open Realtime Threads Option Group is supported.
- //
- #define _SC_XOPEN_REALTIME_THREADS 99
- //
- // Determine whether the Issue 4, Version 2 Shared Memory Option Group is
- // supported.
- //
- #define _SC_XOPEN_SHM 100
- //
- // Determine whether the XSI STREAMS Option Group is supported.
- //
- #define _SC_XOPEN_STREAMS 101
- //
- // Determine whether the XSI option is supported.
- //
- #define _SC_XOPEN_UNIX 102
- //
- // Determine whether the UUCP Utilities option is supported.
- //
- #define _SC_XOPEN_UUCP 103
- //
- // Determine the version of the X/Open Portability Guide.
- //
- #define _SC_XOPEN_VERSION 104
- //
- // Define pathconf and fpathconf constants.
- //
- //
- // When referring to a directory, the system supports the creation of symbolic
- // links within that directory.
- //
- #define _PC_2_SYMLINKS 1
- //
- // Get the minimum number of bytes of storage actually allocated for any
- // portion of a file.
- //
- #define _PC_ALLOC_SIZE_MIN 2
- //
- // Determine whether asynchronous I/O operations may be performed for the
- // associated file.
- //
- #define _PC_ASYNC_IO 3
- //
- // Determine whether the use of chown and fchown is restricted to a process
- // with appropriate privileges, and to changing the group ID of a file only to
- // the effective group ID of the process or to one of its supplementary group
- // IDs.
- //
- #define _PC_CHOWN_RESTRICTED 4
- //
- // Determine the minimum number of bits needed to represent, as a signed
- // integer, the maximum size of a regular file allowed in the specified
- // directory.
- //
- #define _PC_FILESIZEBITS 5
- //
- // Determine the maximum number of links to a single file.
- //
- #define _PC_LINK_MAX 6
- //
- // Determine the maximum number of bytes in a terminal canonical input line.
- //
- #define _PC_MAX_CANON 7
- //
- // Determine the minimum number of bytes for which space is available in the
- // terminal input queue. This is also the maximum number of bytes a conforming
- // application may require to be typed as input before reading them.
- //
- #define _PC_MAX_INPUT 8
- //
- // Determine the maximum number of bytes in a file name, not including the
- // null terminator.
- //
- #define _PC_NAME_MAX 9
- //
- // Determine whether pathname components longer than NAME_MAX generate an error.
- //
- #define _PC_NO_TRUNC 10
- //
- // Determine the minimum number of bytes in a path name, including the null
- // terminator.
- //
- #define _PC_PATH_MAX 11
- //
- // Determine the maximum number of bytes that is guaranteed to be atomic when
- // writing to a pipe.
- //
- #define _PC_PIPE_BUF 12
- //
- // Determine whether prioritized input or output operations may be performed
- // for the associated file.
- //
- #define _PC_PRIO_IO 13
- //
- // Determine the recommended increment for file transfer sizes between
- // POSIX_REC_MIN_XFER_SIZE and POSIX_REC_MAX_XFER_SIZE.
- //
- #define _PC_REC_INCR_XFER_SIZE 14
- //
- // Determine the minimum recommended transfer size.
- //
- #define _PC_REC_MIN_XFER_SIZE 15
- //
- // Determine the recommended transfer alignment.
- //
- #define _PC_REC_XFER_ALIGN 16
- //
- // Determine the maximum number of bytes in a symbolic link.
- //
- #define _PC_SYMLINK_MAX 17
- //
- // Determine whether synchronized input or output operations may be performed
- // for the associated file.
- //
- #define _PC_SYNC_IO 18
- //
- // Determine the value of a character that shall disable terminal special
- // character handling.
- //
- #define _PC_VDISABLE 19
- //
- // Define function values that can be passed to the lockf function.
- //
- //
- // Use this function to unlock a previously locked region.
- //
- #define F_ULOCK 0
- //
- // Use this function to lock a region for exclusive use.
- //
- #define F_LOCK 1
- //
- // Use this function to test and lock a region for exclusive use, without
- // blocking.
- //
- #define F_TLOCK 2
- //
- // Use this function to test a region for locks held by other processes.
- //
- #define F_TEST 3
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // Define the environment.
- //
- LIBC_API extern char **environ;
- //
- // Define some globals from getopt.h. See getopt.h for full descriptions of
- // each of these variables. The header getopt.h is not included in this file
- // because some declarations (like struct option) should not be included here.
- //
- LIBC_API extern char *optarg;
- LIBC_API extern int optind;
- LIBC_API extern int opterr;
- LIBC_API extern int optopt;
- LIBC_API extern int optreset;
- //
- // -------------------------------------------------------- Function Prototypes
- //
- LIBC_API
- int
- brk (
- void *Address
- );
- /*++
- Routine Description:
- This routine sets the current program break to the specified address.
- New programs should use malloc and free in favor of this deprecated
- legacy function. This function is likely to fail if any other memory
- functions such as malloc or free are used. Other functions, including the
- C library, may use malloc and free silently. This function is neither
- thread-safe nor reentrant.
- Arguments:
- Address - Supplies the new address of the program break.
- Return Value:
- 0 on success.
- -1 on failure, and errno is set to indicate the error.
- --*/
- LIBC_API
- void *
- sbrk (
- intptr_t Increment
- );
- /*++
- Routine Description:
- This routine increments the current program break by the given number of
- bytes. If the value is negative, the program break is decreased.
- New programs should use malloc and free in favor of this deprecated
- legacy function. This function is likely to fail if any other memory
- functions such as malloc or free are used. Other functions, including the
- C library, may use malloc and free silently. This function is neither
- thread-safe nor reentrant.
- Arguments:
- Increment - Supplies the amount to add or remove from the program break.
- Return Value:
- Returns the original program break address before this function changed it
- on success.
- (void *)-1 on failure, and errno is set to indicate the error.
- --*/
- LIBC_API
- int
- execl (
- const char *Path,
- const char *Argument0,
- ...
- );
- /*++
- Routine Description:
- This routine replaces the current process image with a new image.
- Arguments:
- Path - Supplies a pointer to a string containing the fully specified path
- of the file to execute.
- Argument0 - Supplies the first argument to execute, usually the same as
- the command name.
- ... - Supplies the arguments to the program. The argument list must be
- terminated with a NULL.
- Return Value:
- Does not return on success, the current process is gutted and replaced with
- the specified image.
- -1 on error, and the errno variable will be set to contain more information.
- --*/
- LIBC_API
- int
- execv (
- const char *Path,
- char *const Arguments[]
- );
- /*++
- Routine Description:
- This routine replaces the current process image with a new image.
- Arguments:
- Path - Supplies a pointer to a string containing the fully specified path
- of the file to execute.
- Arguments - Supplies an array of pointers to strings containing the
- arguments to pass to the program.
- Return Value:
- Does not return on success, the current process is gutted and replaced with
- the specified image.
- -1 on error, and the errno variable will be set to contain more information.
- --*/
- LIBC_API
- int
- execle (
- const char *Path,
- const char *Argument0,
- ...
- );
- /*++
- Routine Description:
- This routine replaces the current process image with a new image. The
- parameters to this function also include the environment variables to use.
- Arguments:
- Path - Supplies a pointer to a string containing the fully specified path
- of the file to execute.
- Argument0 - Supplies the first argument to the program, usually the same
- as the program name.
- ... - Supplies the arguments to the program. The argument list must be
- terminated with a NULL. After the NULL an array of strings representing
- the environment is expected (think of it like a final argument after
- the NULL in the form const char *envp[]).
- Return Value:
- Does not return on success, the current process is gutted and replaced with
- the specified image.
- -1 on error, and the errno variable will be set to contain more information.
- --*/
- LIBC_API
- int
- execve (
- const char *Path,
- char *const Arguments[],
- char *const Environment[]
- );
- /*++
- Routine Description:
- This routine replaces the current process image with a new image. The
- parameters to this function also include the environment variables to use.
- Arguments:
- Path - Supplies a pointer to a string containing the fully specified path
- of the file to execute.
- Arguments - Supplies an array of pointers to strings containing the
- arguments to pass to the program.
- Environment - Supplies an array of pointers to strings containing the
- environment variables to pass to the program.
- Return Value:
- Does not return on success, the current process is gutted and replaced with
- the specified image.
- -1 on error, and the errno variable will be set to contain more information.
- --*/
- LIBC_API
- int
- execlp (
- const char *File,
- const char *Argument0,
- ...
- );
- /*++
- Routine Description:
- This routine replaces the current process image with a new image. If the
- given file is found but of an unrecognized binary format, then a shell
- interpreter will be launched and passed the file.
- Arguments:
- File - Supplies a pointer to a string containing the name of the executable,
- which will be searched for on the PATH if the string does not contain a
- slash.
- Argument0 - Supplies the first argument to the program. Additional arguments
- follow in the ellipses. The argument list must be terminated with a
- NULL.
- ... - Supplies any remaining arguments.
- Return Value:
- Does not return on success, the current process is gutted and replaced with
- the specified image.
- -1 on error, and the errno variable will be set to contain more information.
- --*/
- LIBC_API
- int
- execvp (
- const char *File,
- char *const Arguments[]
- );
- /*++
- Routine Description:
- This routine replaces the current process image with a new image. If the
- given file is found but of an unrecognized binary format, then a shell
- interpreter will be launched and passed the file.
- Arguments:
- File - Supplies a pointer to a string containing the name of the executable,
- which will be searched for on the PATH if the string does not contain a
- slash.
- Arguments - Supplies an array of pointers to strings containing the
- arguments to pass to the program.
- Return Value:
- Does not return on success, the current process is gutted and replaced with
- the specified image.
- -1 on error, and the errno variable will be set to contain more information.
- --*/
- LIBC_API
- int
- execvpe (
- const char *File,
- char *const Arguments[],
- char *const Environment[]
- );
- /*++
- Routine Description:
- This routine replaces the current process image with a new image. The
- parameters to this function also include the environment variables to use.
- If the given file is found but of an unrecognized binary format, then a
- shell interpreter will be launched and passed the file.
- Arguments:
- File - Supplies a pointer to a string containing the name of the executable,
- which will be searched for on the PATH if the string does not contain a
- slash.
- Arguments - Supplies an array of pointers to strings containing the
- arguments to pass to the program.
- Environment - Supplies an array of pointers to strings containing the
- environment variables to pass to the program.
- Return Value:
- Does not return on success, the current process is gutted and replaced with
- the specified image.
- -1 on error, and the errno variable will be set to contain more information.
- --*/
- LIBC_API
- __NO_RETURN
- void
- _exit (
- int Status
- );
- /*++
- Routine Description:
- This routine terminates the current process. It does not call any routines
- registered to run upon exit.
- Arguments:
- Status - Supplies a status code to return to the parent program.
- Return Value:
- None. This routine does not return.
- --*/
- LIBC_API
- int
- close (
- int FileDescriptor
- );
- /*++
- Routine Description:
- This routine closes a file descriptor.
- Arguments:
- FileDescriptor - Supplies the file descriptor to close.
- Return Value:
- 0 on success.
- -1 if the file could not be closed properly. The state of the file
- descriptor is undefined, but in many cases is still open. The errno
- variable will be set to contain more detailed information.
- --*/
- LIBC_API
- int
- closefrom (
- int FileDescriptor
- );
- /*++
- Routine Description:
- This routine closes all file descriptors with a value greater than or
- equal to the given file descriptor.
- Arguments:
- FileDescriptor - Supplies the minimum file descriptor number.
- Return Value:
- 0 on success.
- -1 if a file descriptor could not be closed properly. The state of the file
- descriptor is undefined, but in many cases is still open. The errno
- variable will be set to contain more detailed information.
- --*/
- LIBC_API
- ssize_t
- read (
- int FileDescriptor,
- void *Buffer,
- size_t ByteCount
- );
- /*++
- Routine Description:
- This routine attempts to read the specifed number of bytes from the given
- open file descriptor.
- Arguments:
- FileDescriptor - Supplies the file descriptor returned by the open function.
- Buffer - Supplies a pointer to the buffer where the read bytes will be
- returned.
- ByteCount - Supplies the number of bytes to read.
- Return Value:
- Returns the number of bytes successfully read from the file.
- -1 on failure, and errno will contain more information.
- --*/
- LIBC_API
- ssize_t
- pread (
- int FileDescriptor,
- void *Buffer,
- size_t ByteCount,
- off_t Offset
- );
- /*++
- Routine Description:
- This routine attempts to read the specifed number of bytes from the given
- open file descriptor at a given offset. It does not change the current
- file pointer.
- Arguments:
- FileDescriptor - Supplies the file descriptor returned by the open function.
- Buffer - Supplies a pointer to the buffer where the read bytes will be
- returned.
- ByteCount - Supplies the number of bytes to read.
- Offset - Supplies the offset from the start of the file to read from.
- Return Value:
- Returns the number of bytes successfully read from the file.
- -1 on failure, and errno will contain more information.
- --*/
- LIBC_API
- ssize_t
- write (
- int FileDescriptor,
- const void *Buffer,
- size_t ByteCount
- );
- /*++
- Routine Description:
- This routine attempts to write the specifed number of bytes to the given
- open file descriptor.
- Arguments:
- FileDescriptor - Supplies the file descriptor returned by the open function.
- Buffer - Supplies a pointer to the buffer containing the bytes to be
- written.
- ByteCount - Supplies the number of bytes to write.
- Return Value:
- Returns the number of bytes successfully written to the file.
- -1 on failure, and errno will contain more information.
- --*/
- LIBC_API
- ssize_t
- pwrite (
- int FileDescriptor,
- const void *Buffer,
- size_t ByteCount,
- off_t Offset
- );
- /*++
- Routine Description:
- This routine attempts to write the specifed number of bytes to the given
- open file descriptor at a given offset. It does not update the current
- file position.
- Arguments:
- FileDescriptor - Supplies the file descriptor returned by the open function.
- Buffer - Supplies a pointer to the buffer containing the bytes to be
- written.
- ByteCount - Supplies the number of bytes to write.
- Offset - Supplies the offset from the start of the file to write to.
- Return Value:
- Returns the number of bytes successfully written to the file.
- -1 on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- fsync (
- int FileDescriptor
- );
- /*++
- Routine Description:
- This routine flushes all the data associated with the open file descriptor
- to its corresponding backing device. It does not return until the data has
- been flushed.
- Arguments:
- FileDescriptor - Supplies the file descriptor returned by the open function.
- Return Value:
- 0 on success.
- -1 on failure, and the errno variable will be set to contain more
- information.
- --*/
- LIBC_API
- int
- fdatasync (
- int FileDescriptor
- );
- /*++
- Routine Description:
- This routine flushes all the data associated with the open file descriptor
- to its corresponding backing device. It does not return until the data has
- been flushed. It is similar to fsync but does not flush modified metadata
- if that metadata is unimportant to retrieving the file later. For example,
- last access and modified times wouldn't require a metadata flush, but file
- size change would.
- Arguments:
- FileDescriptor - Supplies the file descriptor returned by the open function.
- Return Value:
- 0 on success.
- -1 on failure, and the errno variable will be set to contain more
- information.
- --*/
- LIBC_API
- void
- sync (
- void
- );
- /*++
- Routine Description:
- This routine schedules a flush for all file system related data that is in
- memory. Upon return, it is not guaranteed that the writing of the data is
- complete.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- LIBC_API
- off_t
- lseek (
- int FileDescriptor,
- off_t Offset,
- int Whence
- );
- /*++
- Routine Description:
- This routine sets the file offset for the open file descriptor.
- Arguments:
- FileDescriptor - Supplies the file descriptor returned by the open function.
- Offset - Supplies the offset from the reference location given in the
- Whence argument.
- Whence - Supplies the reference location to base the offset off of. Valid
- value are:
- SEEK_SET - The offset will be added to the the beginning of the file.
- SEEK_CUR - The offset will be added to the current file position.
- SEEK_END - The offset will be added to the end of the file.
- Return Value:
- Returns the resulting file offset after the operation.
- -1 on failure, and errno will contain more information. The file offset
- will remain unchanged.
- --*/
- LIBC_API
- int
- ftruncate (
- int FileDescriptor,
- off_t NewSize
- );
- /*++
- Routine Description:
- This routine sets the file size of the given file descriptor. If the new
- size is smaller than the original size, then the remaining data will be
- discarded. If the new size is larger than the original size, then the
- extra space will be filled with zeroes.
- Arguments:
- FileDescriptor - Supplies the file descriptor whose size should be
- modified.
- NewSize - Supplies the new size of the file descriptor in bytes.
- Return Value:
- 0 on success.
- -1 on failure. The errno variable will be set to indicate the error.
- --*/
- LIBC_API
- int
- truncate (
- const char *Path,
- off_t NewSize
- );
- /*++
- Routine Description:
- This routine sets the file size of the given file path. If the new size is
- smaller than the original size, then the remaining data will be discarded.
- If the new size is larger than the original size, then the extra space will
- be filled with zeroes.
- Arguments:
- Path - Supplies a pointer to a null terminated string containing the path
- of the file whose size should be changed.
- NewSize - Supplies the new size of the file descriptor in bytes.
- Return Value:
- 0 on success.
- -1 on failure. The errno variable will be set to indicate the error.
- --*/
- LIBC_API
- int
- pipe (
- int FileDescriptors[2]
- );
- /*++
- Routine Description:
- This routine creates an anonymous pipe.
- Arguments:
- FileDescriptors - Supplies a pointer where handles will be returned
- representing the read and write ends of the pipe.
- Return Value:
- 0 on success.
- -1 on failure. The errno variable will be set to indicate the error.
- --*/
- LIBC_API
- int
- pipe2 (
- int FileDescriptors[2],
- int Flags
- );
- /*++
- Routine Description:
- This routine creates an anonymous pipe.
- Arguments:
- FileDescriptors - Supplies a pointer where handles will be returned
- representing the read and write ends of the pipe.
- Flags - Supplies a bitfield of open flags governing the behavior of the new
- descriptors. Only O_NONBLOCK and O_CLOEXEC are honored.
- Return Value:
- 0 on success.
- -1 on failure. The errno variable will be set to indicate the error.
- --*/
- LIBC_API
- int
- symlink (
- const char *LinkTarget,
- const char *LinkName
- );
- /*++
- Routine Description:
- This routine creates a symbolic link with the given name pointed at the
- supplied target path.
- Arguments:
- LinkTarget - Supplies the location that the link points to.
- LinkName - Supplies the path where the link should be created.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- symlinkat (
- const char *LinkTarget,
- int Directory,
- const char *LinkName
- );
- /*++
- Routine Description:
- This routine creates a symbolic link with the given name pointed at the
- supplied target path.
- Arguments:
- LinkTarget - Supplies the location that the link points to.
- Directory - Supplies an optional file descriptor. If the given path to the
- link name is a relative path, the directory referenced by this
- descriptor will be used as a starting point for path resolution. Supply
- AT_FDCWD to use the working directory for relative paths.
- LinkName - Supplies the path where the link should be created.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- ssize_t
- readlink (
- const char *Path,
- char *LinkDestinationBuffer,
- size_t LinkDestinationBufferSize
- );
- /*++
- Routine Description:
- This routine reads the destination path of a symbolic link.
- Arguments:
- Path - Supplies a pointer to the symbolic link path.
- LinkDestinationBuffer - Supplies a pointer to a buffer where the
- destination of the link will be returned. A null terminator is not
- written.
- LinkDestinationBufferSize - Supplies the size of the link destination
- buffer in bytes.
- Return Value:
- Returns the number of bytes placed into the buffer on success.
- -1 on failure. The errno variable will be set to indicate the error, and
- the buffer will remain unchanged.
- --*/
- LIBC_API
- ssize_t
- readlinkat (
- int Directory,
- const char *Path,
- char *LinkDestinationBuffer,
- size_t LinkDestinationBufferSize
- );
- /*++
- Routine Description:
- This routine reads the destination path of a symbolic link.
- Arguments:
- Directory - Supplies an optional file descriptor. If the given path
- is a relative path, the directory referenced by this descriptor will
- be used as a starting point for path resolution. Supply AT_FDCWD to
- use the working directory for relative paths.
- Path - Supplies a pointer to the symbolic link path.
- LinkDestinationBuffer - Supplies a pointer to a buffer where the
- destination of the link will be returned. A null terminator is not
- written.
- LinkDestinationBufferSize - Supplies the size of the link destination
- buffer in bytes.
- Return Value:
- Returns the number of bytes placed into the buffer on success.
- -1 on failure. The errno variable will be set to indicate the error, and
- the buffer will remain unchanged.
- --*/
- LIBC_API
- int
- link (
- const char *ExistingFile,
- const char *LinkPath
- );
- /*++
- Routine Description:
- This routine creates a hard link to the given file.
- Arguments:
- ExistingFile - Supplies a pointer to a null-terminated string containing
- the path to the file that already exists.
- LinkPath - Supplies a pointer to a null-terminated string containing the
- path of the new link to create.
- Return Value:
- 0 on success.
- -1 on failure. The errno variable will be set to indicate the error.
- --*/
- LIBC_API
- int
- linkat (
- int ExistingFileDirectory,
- const char *ExistingFile,
- int LinkPathDirectory,
- const char *LinkPath,
- int Flags
- );
- /*++
- Routine Description:
- This routine creates a hard link to the given file.
- Arguments:
- ExistingFileDirectory - Supplies an optional file descriptor. If the given
- existing file path is a relative path, the directory referenced by this
- descriptor will be used as a starting point for path resolution. Supply
- AT_FDCWD to use the working directory for relative paths.
- ExistingFile - Supplies a pointer to a null-terminated string containing
- the path to the file that already exists.
- LinkPathDirectory - Supplies an optional file descriptor. If the given new
- link is a relative path, the directory referenced by this descriptor
- will be used as a starting point for path resolution. Supply AT_FDCWD
- to use the working directory for relative paths.
- LinkPath - Supplies a pointer to a null-terminated string containing the
- path of the new link to create.
- Flags - Supplies AT_SYMLINK_FOLLOW if the routine should link to the
- destination of the symbolic link if the existing file path is a
- symbolic link. Supply 0 to create a link to the symbolic link itself.
- Return Value:
- 0 on success.
- -1 on failure. The errno variable will be set to indicate the error.
- --*/
- LIBC_API
- int
- unlink (
- const char *Path
- );
- /*++
- Routine Description:
- This routine attempts to delete the object at the given path. If the path
- points to a directory, the directory must be empty. If the path points to
- a file, the hard link count on the file is decremented. If the hard link
- count reaches zero and no processes have the file open, the contents of the
- file are destroyed. If processes have open handles to the file, the
- destruction of the file contents are deferred until the last handle to the
- old file is closed. If the path points to a symbolic link, the link itself
- is removed and not the destination. The removal of the entry from the
- directory is immediate.
- Arguments:
- Path - Supplies a pointer to a null terminated string containing the path
- of the entry to remove.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to provide more details. In failure
- cases, the directory will not be removed.
- --*/
- LIBC_API
- int
- unlinkat (
- int Directory,
- const char *Path,
- int Flags
- );
- /*++
- Routine Description:
- This routine attempts to delete the object at the given path. If the path
- points to a directory, the directory must be empty. If the path points to
- a file, the hard link count on the file is decremented. If the hard link
- count reaches zero and no processes have the file open, the contents of the
- file are destroyed. If processes have open handles to the file, the
- destruction of the file contents are deferred until the last handle to the
- old file is closed. If the path points to a symbolic link, the link itself
- is removed and not the destination. The removal of the entry from the
- directory is immediate.
- Arguments:
- Directory - Supplies an optional file descriptor. If the given path
- is a relative path, the directory referenced by this descriptor will
- be used as a starting point for path resolution. Supply AT_FDCWD to
- use the working directory for relative paths.
- Path - Supplies a pointer to a null terminated string containing the path
- of the entry to remove.
- Flags - Supplies a bitfield of flags. Supply AT_REMOVEDIR to attempt to
- remove a directory (and only a directory). Supply zero to attempt to
- remove a non-directory.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to provide more details. In failure
- cases, the directory will not be removed.
- --*/
- LIBC_API
- int
- dup (
- int FileDescriptor
- );
- /*++
- Routine Description:
- This routine duplicates the given file descriptor.
- Arguments:
- FileDescriptor - Supplies the file descriptor to duplicate.
- Return Value:
- Returns the new file descriptor which represents a copy of the original
- file descriptor.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- dup2 (
- int FileDescriptor,
- int CopyDescriptor
- );
- /*++
- Routine Description:
- This routine duplicates the given file descriptor to the destination
- descriptor, closing the original destination descriptor file along the way.
- Arguments:
- FileDescriptor - Supplies the file descriptor to duplicate.
- CopyDescriptor - Supplies the descriptor number of returned copy.
- Return Value:
- Returns the new file descriptor which represents a copy of the original,
- which is also equal to the input copy descriptor parameter.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- dup3 (
- int FileDescriptor,
- int CopyDescriptor,
- int Flags
- );
- /*++
- Routine Description:
- This routine duplicates the given file descriptor to the destination
- descriptor, closing the original destination descriptor file along the way.
- Arguments:
- FileDescriptor - Supplies the file descriptor to duplicate.
- CopyDescriptor - Supplies the descriptor number of returned copy. If this
- is equal to the original file descriptor, then the call fails with
- EINVAL.
- Flags - Supplies O_* open flags governing the new descriptor. Only
- O_CLOEXEC is permitted.
- Return Value:
- Returns the new file descriptor which represents a copy of the original,
- which is also equal to the input copy descriptor parameter.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- lockf (
- int FileDescriptor,
- int Function,
- off_t Size
- );
- /*++
- Routine Description:
- This routine locks or unlocks sections of a file with advisory-mode locks.
- All locks for a process are removed when the process terminates. Record
- locking is supported at least for regular files, and may be supported for
- other file types.
- Arguments:
- FileDescriptor - Supplies the file descriptor to query. To establish a
- lock, the given file descriptor must be opened with O_WRONLY or O_RDWR.
- Function - Supplies the action to be taken. Valid values are:
- F_ULOCK - Unlocks a locked section.
- F_LOCK - Locks a section for exclusive use (blocking if already locked).
- F_TLOCK - Test and lock for exclusive use, not blocking.
- F_TEST - Test for a section of locks by other processes.
- Size - Supplies the number of contiguous bytes to be locked or unlocked.
- The section to be locked or unlocked starts at the current offset in
- the file and extends forward for a positve size or backwards for a
- negative size (the preceding bytes up to but not including the current
- offset). If size is 0, the section from the current offset through the
- largest possible offset shall be locked. Locks may exist past the
- current end of file.
- Return Value:
- 0 on success.
- -1 on error, and errno will be set to contain more information. The errno
- variable may be set to the following values:
- EACCES or EAGAIN if the function argument is F_TLOCK or F_TEST and the
- section is already locked by another process.
- EDEADLK if the function argument is F_LOCK and a deadlock is detected.
- EINVAL if the function is valid or the size plus the current offset is less
- than zero.
- EOVERFLOW if the range cannot properly be represented in an off_t.
- --*/
- LIBC_API
- int
- isatty (
- int FileDescriptor
- );
- /*++
- Routine Description:
- This routine determines if the given file descriptor is backed by an
- interactive terminal device or not.
- Arguments:
- FileDescriptor - Supplies the file descriptor to query.
- Return Value:
- 1 if the given file descriptor is backed by a terminal device.
- 0 on error or if the file descriptor is not a terminal device. On error,
- the errno variable will be set to give more details.
- --*/
- LIBC_API
- int
- rmdir (
- const char *Path
- );
- /*++
- Routine Description:
- This routine attempts to unlink a directory. The directory must be empty or
- the operation will fail.
- Arguments:
- Path - Supplies a pointer to a null terminated string containing the path
- of the directory to remove.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to provide more details. In failure
- cases, the directory will not be removed.
- --*/
- LIBC_API
- char *
- getcwd (
- char *Buffer,
- size_t BufferSize
- );
- /*++
- Routine Description:
- This routine returns a pointer to a null terminated string containing the
- path to the current working directory.
- Arguments:
- Buffer - Supplies a pointer to a buffer where the string should be returned.
- If NULL is supplied, then malloc will be used to allocate a buffer of
- the appropriate size, and it is therefore the caller's responsibility
- to free this memory.
- BufferSize - Supplies the size of the buffer, in bytes.
- Return Value:
- Returns a pointer to a string containing the current working directory on
- success.
- NULL on failure. Errno will contain more information.
- --*/
- LIBC_API
- int
- chdir (
- const char *Path
- );
- /*++
- Routine Description:
- This routine changes the current working directory (the starting point for
- all paths that don't begin with a path separator).
- Arguments:
- Path - Supplies a pointer to the null terminated string containing the
- path of the new working directory.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to provide more details. On failure,
- the current working directory will not be changed.
- --*/
- LIBC_API
- int
- fchdir (
- int FileDescriptor
- );
- /*++
- Routine Description:
- This routine changes the current working directory (the starting point for
- all paths that don't begin with a path separator) using an already open
- file descriptor to that directory.
- Arguments:
- FileDescriptor - Supplies the open file handle to the directory to change
- to.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to provide more details. On failure,
- the current working directory will not be changed.
- --*/
- LIBC_API
- int
- chroot (
- const char *Path
- );
- /*++
- Routine Description:
- This routine changes the current root directory. The working directory is
- not changed. The caller must have sufficient privileges to change root
- directories.
- Arguments:
- Path - Supplies a pointer to the null terminated string containing the
- path of the new root directory.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to provide more details. On failure,
- the current root directory will not be changed. Errno may be set to the
- following values, among others:
- EACCES if search permission is denied on a component of the path prefix.
- EPERM if the caller has insufficient privileges.
- --*/
- LIBC_API
- int
- fchroot (
- int FileDescriptor
- );
- /*++
- Routine Description:
- This routine changes the current root directory using an already open file
- descriptor to that directory. The caller must have sufficient privileges
- to change root directories.
- Arguments:
- FileDescriptor - Supplies the open file handle to the directory to change
- to.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to provide more details. On failure,
- the current root directory will not be changed.
- --*/
- LIBC_API
- int
- fchown (
- int FileDescriptor,
- uid_t Owner,
- gid_t Group
- );
- /*++
- Routine Description:
- This routine sets the file owner and group of the file opened with the
- given file descriptor.
- Arguments:
- FileDescriptor - Supplies the file descriptor whose owner and group should
- be modified.
- Owner - Supplies the new owner of the file.
- Group - Supplies the new group of the file.
- Return Value:
- 0 on success.
- -1 on failure. The errno variable will be set to indicate the error.
- --*/
- LIBC_API
- int
- chown (
- const char *Path,
- uid_t Owner,
- gid_t Group
- );
- /*++
- Routine Description:
- This routine sets the file owner of the given path.
- Arguments:
- Path - Supplies a pointer to the path whose owner should be changed.
- Owner - Supplies the new owner of the path.
- Group - Supplies the new owner group of the path.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- lchown (
- const char *Path,
- uid_t Owner,
- gid_t Group
- );
- /*++
- Routine Description:
- This routine sets the file owner of the given path. The only difference
- between this routine and chown is that if the path given to this routine
- refers to a symbolic link, the operation will be done on the link itself
- (as opposed to the destination of the link, which is what chown would
- operate on).
- Arguments:
- Path - Supplies a pointer to the path whose owner should be changed.
- Owner - Supplies the new owner of the path.
- Group - Supplies the new owner group of the path.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- fchownat (
- int Directory,
- const char *Path,
- uid_t Owner,
- gid_t Group,
- int Flags
- );
- /*++
- Routine Description:
- This routine sets the file owner of the given path.
- Arguments:
- Directory - Supplies an optional file descriptor. If the given path
- is a relative path, the directory referenced by this descriptor will
- be used as a starting point for path resolution. Supply AT_FDCWD to
- use the working directory for relative paths.
- Path - Supplies a pointer to the path whose owner should be changed.
- Owner - Supplies the new owner of the path.
- Group - Supplies the new owner group of the path.
- Flags - Supplies AT_SYMLINK_NOFOLLOW if the routine should modify
- information for the symbolic link itself, or 0 if the call should
- follow a symbolic link at the destination.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- pid_t
- getpid (
- void
- );
- /*++
- Routine Description:
- This routine returns the current process identifier.
- Arguments:
- None.
- Return Value:
- Returns the process identifier.
- --*/
- LIBC_API
- pid_t
- getppid (
- void
- );
- /*++
- Routine Description:
- This routine returns the current process' parent process identifier.
- Arguments:
- None.
- Return Value:
- Returns the parent process identifier.
- --*/
- LIBC_API
- pid_t
- getpgid (
- pid_t ProcessId
- );
- /*++
- Routine Description:
- This routine returns the process group identifier of the process with
- the given ID, or the calling process.
- Arguments:
- ProcessId - Supplies the process ID to return the process group for. Supply
- 0 to return the process group ID of the calling process.
- Return Value:
- Returns the process group ID of the given process (or the current process).
- (pid_t)-1 and errno will be set to EPERM if the desired process is out of
- this session and the implementation doesn't allow cross session requests,
- ESRCH if no such process exists, or EINVAL if the pid argument is invalid.
- --*/
- LIBC_API
- pid_t
- getpgrp (
- void
- );
- /*++
- Routine Description:
- This routine returns the process group identifier of the calling process.
- Arguments:
- None.
- Return Value:
- Returns the process group ID of the calling process.
- --*/
- LIBC_API
- int
- setpgid (
- pid_t ProcessId,
- pid_t ProcessGroupId
- );
- /*++
- Routine Description:
- This routine joins an existing process group or creates a new process group
- within the session of the calling process. The process group ID of a
- session leader will not change.
- Arguments:
- ProcessId - Supplies the process ID of the process to put in a new process
- group. Supply 0 to use the current process.
- ProcessGroupId - Supplies the new process group to put the process in.
- Supply zero to set the process group ID to the same numerical value as
- the specified process ID.
- Return Value:
- 0 on success.
- -1 on failure and errno will be set to contain more information.
- --*/
- LIBC_API
- pid_t
- setpgrp (
- void
- );
- /*++
- Routine Description:
- This routine sets the process group ID of the calling process to the
- process ID of the calling process. This routine has no effect if the
- calling process is a session leader.
- Arguments:
- None.
- Return Value:
- Returns the process group ID of the calling process.
- --*/
- LIBC_API
- pid_t
- getsid (
- pid_t ProcessId
- );
- /*++
- Routine Description:
- This routine returns the process group ID of the process that is the
- session leader of the given process. If the given parameter is 0, then
- the current process ID is used as the parameter.
- Arguments:
- ProcessId - Supplies a process ID of the process whose session leader
- should be returned.
- Return Value:
- Returns the process group ID of the session leader of the specified process.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- pid_t
- setsid (
- void
- );
- /*++
- Routine Description:
- This routine creates a new session if the calling process is not a
- process group leader. The calling process will be the session leader of
- the new session, and will be the process group leader of a new process
- group, and will have no controlling terminal. The process group ID of the
- calling process will be set equal to the process ID of the calling process.
- The calling process will be the only process in the new process group and
- the only process in the new session.
- Arguments:
- None.
- Return Value:
- Returns the value of the new process group ID of the calling process.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- pid_t
- fork (
- void
- );
- /*++
- Routine Description:
- This routine creates a new process by copying the existing process.
- Arguments:
- None.
- Return Value:
- Returns 0 to the child process.
- Returns the process ID of the child process to the parent process.
- Returns -1 to the parent process on error, and the errno variable will be
- set to provide more information about the error.
- --*/
- LIBC_API
- uid_t
- getuid (
- void
- );
- /*++
- Routine Description:
- This routine returns the current real user ID.
- Arguments:
- None.
- Return Value:
- Returns the real user ID.
- --*/
- LIBC_API
- gid_t
- getgid (
- void
- );
- /*++
- Routine Description:
- This routine returns the current real group ID.
- Arguments:
- None.
- Return Value:
- Returns the real group ID.
- --*/
- LIBC_API
- uid_t
- geteuid (
- void
- );
- /*++
- Routine Description:
- This routine returns the current effective user ID, which represents the
- privilege level with which this process can perform operations. Normally
- this is the same as the real user ID, but binaries with the setuid
- permission bit set the effective user ID to their own when they're run.
- Arguments:
- None.
- Return Value:
- Returns the effective user ID.
- --*/
- LIBC_API
- gid_t
- getegid (
- void
- );
- /*++
- Routine Description:
- This routine returns the current effective group ID, which represents the
- privilege level with which this process can perform operations. Normally
- this is the same as the real group ID, but binaries with the setgid
- permission bit set the effective group ID to their own when they're run.
- Arguments:
- None.
- Return Value:
- Returns the effective group ID.
- --*/
- LIBC_API
- int
- setuid (
- uid_t UserId
- );
- /*++
- Routine Description:
- This routine sets the real user ID, effective user ID, and saved
- set-user-ID of the calling process to the given user ID. This only occurs
- if the process has the appropriate privileges to do this. If the process
- does not have appropriate privileges but the given user ID is equal to the
- real user ID or the saved set-user-ID, then this routine sets the effective
- user ID to the given user ID; the real user ID and saved set-user-ID remain
- unchanged.
- Arguments:
- UserId - Supplies the user ID to change to.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information. Common
- errors include EINVAL if the user ID is not valid, and EPERM if the
- process does not have appropriate privileges and the given ID does not
- match the real user ID or saved set-user-ID.
- --*/
- LIBC_API
- int
- setgid (
- gid_t GroupId
- );
- /*++
- Routine Description:
- This routine sets the real group ID, effective group ID, and saved
- set-group-ID of the calling process to the given group ID. This only occurs
- if the process has the appropriate privileges to do this. If the process
- does not have appropriate privileges but the given group ID is equal to the
- real group ID or the saved set-group-ID, then this routine sets the
- effective group ID to the given group ID; the real group ID and saved
- set-group-ID remain unchanged.
- Arguments:
- GroupId - Supplies the group ID to change to.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information. Common
- errors include EINVAL if the group ID is not valid, and EPERM if the
- process does not have appropriate privileges and the given ID does not
- match the real group ID or saved set-group-ID.
- --*/
- LIBC_API
- int
- seteuid (
- uid_t UserId
- );
- /*++
- Routine Description:
- This routine sets the effective user ID of the calling process to the given
- user ID. The real user ID and saved set-user-ID remain unchanged. This only
- occurs if the process has appropriate privileges, or if the real user ID
- is equal to the saved set-user-ID.
- Arguments:
- UserId - Supplies the effective user ID to change to.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information. Common
- errors include EINVAL if the user ID is not valid, and EPERM if the
- process does not have appropriate privileges and the given ID does not
- match the real user ID or saved set-user-ID.
- --*/
- LIBC_API
- int
- setegid (
- gid_t GroupId
- );
- /*++
- Routine Description:
- This routine sets the effective group ID of the calling process to the
- given group ID. The real group ID and saved set-group-ID remain unchanged.
- This only occurs if the process has appropriate privileges, or if the real
- group ID is equal to the saved set-group-ID.
- Arguments:
- GroupId - Supplies the effective group ID to change to.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information. Common
- errors include EINVAL if the group ID is not valid, and EPERM if the
- process does not have appropriate privileges and the given ID does not
- match the real group ID or saved set-group-ID.
- --*/
- LIBC_API
- int
- setreuid (
- uid_t RealUserId,
- uid_t EffectiveUserId
- );
- /*++
- Routine Description:
- This routine sets the real and/or effective user IDs of the current process
- to the given values. This only occurs if the process has appropriate
- privileges. Unprivileged processes may only set the effective user ID to
- the real or saved user IDs. Unprivileged users may only set the real
- group ID to the saved or effective user IDs. If the real user ID is being
- set, or the effective user ID is being set to something other than the
- previous real user ID, then the saved user ID is also set to the new
- effective user ID.
- Arguments:
- RealUserId - Supplies the real user ID to change to. If -1 is supplied, the
- real user ID will not be changed.
- EffectiveUserId - Supplies the effective user ID to change to. If -1 is
- supplied, the effective user ID will not be changed.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information. Common
- errors include EINVAL if a user ID is not valid, and EPERM if the
- process does not have appropriate privileges and the given effective ID
- does not match the real user ID or saved set-user-ID.
- --*/
- LIBC_API
- int
- setregid (
- gid_t RealGroupId,
- gid_t EffectiveGroupId
- );
- /*++
- Routine Description:
- This routine sets the real and/or effective group IDs of the current process
- to the given values. This only occurs if the process has appropriate
- privileges. Unprivileged processes may only set the effective group ID to
- the real or saved group IDs. Unprivileged users may only set the real
- group ID to the saved or effective group IDs. If the real group ID is being
- set, or the effective group ID is being set to something other than the
- previous real group ID, then the saved group ID is also set to the new
- effective group ID.
- Arguments:
- RealGroupId - Supplies the real group ID to change to. If -1 is supplied,
- the real group ID will not be changed.
- EffectiveGroupId - Supplies the effective group ID to change to. If -1 is
- supplied, the effective group ID will not be changed.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information. Common
- errors include EINVAL if a group ID is not valid, and EPERM if the
- process does not have appropriate privileges and the given effective ID
- does not match the real group ID or saved set-group-ID.
- --*/
- LIBC_API
- int
- setresuid (
- uid_t RealUserId,
- uid_t EffectiveUserId,
- uid_t SavedUserId
- );
- /*++
- Routine Description:
- This routine sets the real, effective, and saved user IDs of the calling
- thread. A unprivileged process may set each one of these to one of the
- current real, effective, or saved user ID. A process with the setuid
- permission may set these to any values.
- Arguments:
- RealUserId - Supplies the real user ID to set, or -1 to leave the value
- unchanged.
- EffectiveUserId - Supplies the effective user ID to set, or -1 to leave the
- value unchanged.
- SavedUserId - Supplies the saved user ID to set, or -1 to leave the value
- unchanged.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information. This may
- fail even for root, so the return value must always be checked.
- --*/
- LIBC_API
- int
- setresgid (
- gid_t RealGroupId,
- gid_t EffectiveGroupId,
- gid_t SavedGroupId
- );
- /*++
- Routine Description:
- This routine sets the real, effective, and saved group IDs of the calling
- thread. A unprivileged process may set each one of these to one of the
- current real, effective, or saved group ID. A process with the setuid
- permission may set these to any values.
- Arguments:
- RealGroupId - Supplies the real group ID to set, or -1 to leave the value
- unchanged.
- EffectiveGroupId - Supplies the effective group ID to set, or -1 to leave
- the value unchanged.
- SavedGroupId - Supplies the saved group ID to set, or -1 to leave the value
- unchanged.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information. This may
- fail even for root, so the return value must always be checked.
- --*/
- LIBC_API
- int
- getgroups (
- int ElementCount,
- gid_t GroupList[]
- );
- /*++
- Routine Description:
- This routine returns the array of supplementary groups that the current
- user belongs to.
- Arguments:
- ElementCount - Supplies the size (in elements) of the supplied group list
- buffer.
- GroupList - Supplies a buffer where the user's supplementary groups will
- be returned.
- Return Value:
- Returns the number of supplementary groups that the current user belongs to.
- The full count is returned even if the element count is less than that so
- that the caller can regroup (get it) and try again if the buffer allocated
- was too small.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- char *
- getlogin (
- void
- );
- /*++
- Routine Description:
- This routine returns a pointer to a string containing the user name
- associated by the login activity with the controlling terminal of the
- current process. This routine is neither reentrant nor thread safe.
- Arguments:
- None.
- Return Value:
- Returns a pointer to a buffer containing the name of the logged in user.
- This data may be overwritten by a subsequent call to this function.
- NULL on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- getlogin_r (
- char *Buffer,
- size_t BufferSize
- );
- /*++
- Routine Description:
- This routine returns a pointer to a string containing the user name
- associated by the login activity with the controlling terminal of the
- current process. This routine is thread safe and reentrant.
- Arguments:
- Buffer - Supplies a pointer to the buffer where the login name will be
- returned.
- BufferSize - Supplies the size of the supplied buffer in bytes.
- Return Value:
- 0 on success.
- Returns an error number on failure.
- --*/
- LIBC_API
- int
- pause (
- void
- );
- /*++
- Routine Description:
- This routine suspends execution until a signal is caught and handled by the
- application. This routine is known to be frought with timing problems, as
- the most common use for it involves checking if a signal has occurred, and
- calling pause if not. Unfortunately that doesn't work as a signal can come
- in after the check but before the call to pause. Pause is really only
- useful if the entirety of the application functionality is implemented
- inside signal handlers.
- Arguments:
- None.
- Return Value:
- -1 always. A return rather negatively is thought of as a failure of the
- function. The errno variable will be set to indicate the "error".
- --*/
- LIBC_API
- long
- sysconf (
- int Variable
- );
- /*++
- Routine Description:
- This routine gets the system value for the given variable index. These
- variables are not expected to change within a single invocation of a
- process, and therefore need only be queried once per process.
- Arguments:
- Variable - Supplies the variable to get. See _SC_* definitions.
- Return Value:
- Returns the value for that variable.
- -1 if the variable has no limit. The errno variable will be left unchanged.
- -1 if the variable was invalid, and errno will be set to EINVAL.
- --*/
- LIBC_API
- long
- fpathconf (
- int FileDescriptor,
- int Variable
- );
- /*++
- Routine Description:
- This routine gets the current value of a configurable limit or option
- that is associated with the given open file descriptor.
- Arguments:
- FileDescriptor - Supplies the file descriptor to query the value for.
- Variable - Supplies the variable to get. See _PC_* definitions.
- Return Value:
- Returns the value for that variable.
- -1 if the variable has no limit. The errno variable will be left unchanged.
- -1 if the variable was invalid, and errno will be set to EINVAL.
- --*/
- LIBC_API
- long
- pathconf (
- const char *Path,
- int Variable
- );
- /*++
- Routine Description:
- This routine gets the current value of a configurable limit or option
- that is associated with the given file or directory path.
- Arguments:
- Path - Supplies a pointer to a null terminated string containing the file
- or directory path to get the configuration limit for.
- Variable - Supplies the variable to get. See _PC_* definitions.
- Return Value:
- Returns the value for that variable.
- -1 if the variable has no limit. The errno variable will be left unchanged.
- -1 if the variable was invalid, and errno will be set to EINVAL.
- --*/
- LIBC_API
- int
- getdtablesize (
- void
- );
- /*++
- Routine Description:
- This routine returns the maximum number of file descriptors that are
- supported.
- Arguments:
- None.
- Return Value:
- Returns the maximum number of file descriptors that one process can have
- open.
- --*/
- LIBC_API
- int
- getpagesize (
- void
- );
- /*++
- Routine Description:
- This routine returns the number of bytes in the basic unit of memory
- allocation on the current machine, the page. This routine is provided for
- historical reasons, new applications should use sysconf(_SC_PAGESIZE)
- (which is in fact exactly what this routine turns around and does).
- Arguments:
- None.
- Return Value:
- Returns the number of bytes in a memory page.
- --*/
- LIBC_API
- unsigned int
- alarm (
- unsigned int Seconds
- );
- /*++
- Routine Description:
- This routine converts causes the system to generate a SIGALRM signal for
- the process after the number of realtime seconds specified by the given
- parameter have elapsed. Processor scheduling delays may prevent the process
- from handling the signal as soon as it is generated. Alarm requests are not
- stacked; only one SIGALRM generation can be scheduled in this manner. If
- the SIGALRM signal has not yet been generated, the call shall result in
- rescheduling the time at which the SIGALRM signal is generated.
- Arguments:
- Seconds - Supplies the number of seconds from now that the alarm should
- fire in. If this value is 0, then a pending alarm request, if any, is
- canceled.
- Return Value:
- If there is a previous alarm request with time remaining, then the
- (non-zero) number of seconds until the alarm would have signaled is
- returned.
- 0 otherwise. The specification for this function says that it cannot fail.
- In reality, it might, and errno should be checked if 0 is returned.
- --*/
- LIBC_API
- unsigned
- sleep (
- unsigned Seconds
- );
- /*++
- Routine Description:
- This routine suspends execution of the calling thread until either the
- given number of realtime seconds has elapsed or a signal was delivered.
- Arguments:
- Seconds - Supplies the number of seconds to sleep for.
- Return Value:
- None.
- --*/
- LIBC_API
- int
- usleep (
- useconds_t Microseconds
- );
- /*++
- Routine Description:
- This routine suspends execution of the calling thread until either the
- given number of realtime microseconds has elapsed or a signal was delivered.
- Arguments:
- Microseconds - Supplies the number of microseconds to sleep for.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- access (
- const char *Path,
- int Mode
- );
- /*++
- Routine Description:
- This routine checks the given path for accessibility using the real user
- ID.
- Arguments:
- Path - Supplies the path string of the file to get the accessibility
- information for.
- Mode - Supplies the mode bits the caller is interested in. Valid values are
- F_OK to check if the file exists, R_OK to check if the file is readable,
- W_OK to check if the file is writable, and X_OK to check if the file is
- executable.
- Return Value:
- 0 on success.
- -1 on failure and the errno variable will be set to provide more
- information.
- --*/
- LIBC_API
- int
- faccessat (
- int Directory,
- const char *Path,
- int Mode,
- int Flags
- );
- /*++
- Routine Description:
- This routine checks the given path for accessibility using the real user
- ID and real group ID rather than the effective user and group IDs.
- Arguments:
- Directory - Supplies an optional file descriptor. If the given path
- is a relative path, the directory referenced by this descriptor will
- be used as a starting point for path resolution. Supply AT_FDCWD to
- use the working directory for relative paths.
- Path - Supplies the path string of the file to get the accessibility
- information for.
- Mode - Supplies the mode bits the caller is interested in. Valid values are
- F_OK to check if the file exists, R_OK to check if the file is readable,
- W_OK to check if the file is writable, and X_OK to check if the file is
- executable.
- Flags - Supplies a bitfield of flags. Supply AT_EACCESS if the checks for
- accessibility should be performed using the effective user and group
- ID rather than the real user and group ID.
- Return Value:
- 0 on success.
- -1 on failure and the errno variable will be set to provide more
- information.
- --*/
- LIBC_API
- char *
- ttyname (
- int FileDescriptor
- );
- /*++
- Routine Description:
- This routine returns the null-terminated pathname of the terminal
- associated with the given file descriptor. This function is neither
- reentrant nor thread safe.
- Arguments:
- FileDescriptor - Supplies the file descriptor to query.
- Return Value:
- Returns a pointer to the supplied buffer on success. This buffer may be
- overwritten by subsequent calls to this routine.
- NULL on failure and errno will be set to contain more information. Common
- error values are:
- EBADF if the file descriptor is not valid.
- ENOTTY if the file descriptor is not a terminal.
- ENOMEM if not enough memory was available.
- --*/
- LIBC_API
- char *
- ttyname_r (
- int FileDescriptor,
- char *Name,
- size_t NameSize
- );
- /*++
- Routine Description:
- This routine returns the null-terminated pathname of the terminal
- associated with the given file descriptor.
- Arguments:
- FileDescriptor - Supplies the file descriptor to query.
- Name - Supplies a pointer to the buffer where the name will be returned
- on success.
- NameSize - Supplies the size of the name buffer in bytes.
- Return Value:
- Returns a pointer to the supplied buffer on success.
- NULL on failure and errno will be set to contain more information. Common
- error values are:
- EBADF if the file descriptor is not valid.
- ENOTTY if the file descriptor is not a terminal.
- ERANGE if the supplied buffer was not large enough.
- --*/
- LIBC_API
- int
- tcsetpgrp (
- int FileDescriptor,
- pid_t ProcessGroupId
- );
- /*++
- Routine Description:
- This routine sets the foreground process group ID associated with the
- given terminal file descriptor. The application shall ensure that the file
- associated with the given descriptor is the controlling terminal of the
- calling process and the controlling terminal is currently associated with
- the session of the calling process. The application shall ensure that the
- given process group ID is led by a process in the same session as the
- calling process.
- Arguments:
- FileDescriptor - Supplies the file descriptor of the terminal.
- ProcessGroupId - Supplies the process group ID to set for the terminal.
- Return Value:
- 0 on success.
- -1 on failure, and the errno will be set to contain more information.
- --*/
- LIBC_API
- pid_t
- tcgetpgrp (
- int FileDescriptor
- );
- /*++
- Routine Description:
- This routine returns the value of the process group ID of the foreground
- process associated with the given terminal. If ther is no foreground
- process group, this routine returns a value greater than 1 that does not
- match the process group ID of any existing process group.
- Arguments:
- FileDescriptor - Supplies the file descriptor of the terminal.
- Return Value:
- Returns the process group ID of the foreground process associated with the
- terminal on success.
- -1 on failure, and errno will be set to contain more information. Possible
- values of errno are:
- EBADF if the file descriptor is invalid.
- ENOTTY if the calling process does not having a controlling terminal, or
- the file is not the controlling terminal.
- --*/
- LIBC_API
- int
- gethostname (
- char *Name,
- size_t NameLength
- );
- /*++
- Routine Description:
- This routine returns the network host name for the current machine.
- Arguments:
- Name - Supplies a pointer where the null-terminated name will be returned
- on success.
- NameLength - Supplies the length of the name buffer in bytes.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to indicate the error.
- --*/
- LIBC_API
- int
- getdomainname (
- char *Name,
- size_t NameLength
- );
- /*++
- Routine Description:
- This routine returns the network domain name for the current machine.
- Arguments:
- Name - Supplies a pointer where the null-terminated name will be returned
- on success.
- NameLength - Supplies the length of the name buffer in bytes.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to indicate the error.
- --*/
- LIBC_API
- int
- sethostname (
- const char *Name,
- size_t Size
- );
- /*++
- Routine Description:
- This routine sets the network host name for the current machine.
- Arguments:
- Name - Supplies a pointer to the new name to set.
- Size - Supplies the size of the name, not including a null terminator.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to indicate the error.
- --*/
- LIBC_API
- int
- setdomainname (
- const char *Name,
- size_t Size
- );
- /*++
- Routine Description:
- This routine sets the network domain name for the current machine.
- Arguments:
- Name - Supplies a pointer to the new name to set.
- Size - Supplies the size of the name, not including a null terminator.
- Return Value:
- 0 on success.
- -1 on failure, and errno will be set to indicate the error.
- --*/
- LIBC_API
- void
- swab (
- const void *Source,
- void *Destination,
- ssize_t ByteCount
- );
- /*++
- Routine Description:
- This routine copies bytes from a source buffer to a destination, exchanging
- adjacent bytes. The source and destination buffers should not overlap.
- Arguments:
- Source - Supplies the source buffer.
- Destination - Supplies the destination buffer (which should not overlap
- with the source buffer).
- ByteCount - Supplies the number of bytes to copy. This should be even. If
- it is odd, the byte count will be truncated down to an even boundary,
- so the last odd byte will not be copied.
- Return Value:
- None.
- --*/
- LIBCRYPT_API
- char *
- crypt (
- const char *Key,
- const char *Salt
- );
- /*++
- Routine Description:
- This routine encrypts a user's password using various encryption/hashing
- standards. The default is DES, which is fairly weak and subject to
- dictionary attacks.
- Arguments:
- Key - Supplies the key, a user's plaintext password.
- Salt - Supplies a two character salt to use to perterb the results. If this
- string starts with a $ and a number, alternate hashing algorithms are
- selected. The format is $id$salt$encrypted. ID can be 1 for MD5, 5 for
- SHA-256, or 6 for SHA-512.
- Return Value:
- Returns a pointer to the encrypted password (plus ID and salt information
- in cases where an alternate mechanism is used). This is a static buffer,
- which may be overwritten by subsequent calls to crypt.
- --*/
- LIBC_API
- char *
- getpass (
- const char *Prompt
- );
- /*++
- Routine Description:
- This routine reads outputs the given prompt, and reads in a line of input
- without echoing it. This routine attempts to use the process' controlling
- terminal, or stdin/stderr otherwise.
- Arguments:
- Prompt - Supplies a pointer to the prompt to print.
- Return Value:
- Returns a pointer to the entered input on success. If this is a password,
- the caller should be sure to clear this buffer out as soon as possible.
- NULL on failure.
- --*/
- LIBC_API
- char *
- getusershell (
- void
- );
- /*++
- Routine Description:
- This routine returns the next permitted user shell in the database of
- valid shells. This opens the file if necessary. This routine is neither
- thread-safe nor reentrant.
- Arguments:
- None.
- Return Value:
- Returns a pointer to a string containing the next shell on success. This
- buffer may be overwritten by subsequent calls to getusershell.
- NULL on failure or end-of-database.
- --*/
- LIBC_API
- void
- setusershell (
- void
- );
- /*++
- Routine Description:
- This routine rewinds the user shells database back to the beginning.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- LIBC_API
- void
- endusershell (
- void
- );
- /*++
- Routine Description:
- This routine closes the permitted user shells database.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- LIBC_API
- int
- getopt (
- int ArgumentCount,
- char *const Arguments[],
- const char *Options
- );
- /*++
- Routine Description:
- This routine parses command line arguments, successively returning each
- passed in argument. This routine is neither reentrant nor thread safe.
- Arguments:
- ArgumentCount - Supplies the argument count from main.
- Arguments - Supplies the argument array from main.
- Options - Supplies a pointer to a null terminated string containing the set
- of accepted options. Each character represents an allowed option. If
- a character is followed by a colon ':', then that option takes an
- argument. If an option with an argument is found and there are more
- characters in the current string, then the remainder of that string
- will be returned. Otherwise, the next argument will be returned. If
- there is no next argument, that's considered an error.
- Return Value:
- Returns the next option character on success. The global variable optind
- will be updated to reflect the index of the next argument to be processed.
- It will be initialied by the system to 1. If the option takes an argument,
- the global variable optarg will be set to point at that argument.
- Returns '?' if the option found is not in the recognized option string. The
- optopt global variable will be set to the unrecognized option that resulted
- in this condition. The '?' character is also returned if the options string
- does not begin with a colon ':' and a required argument is not found. If the
- opterr global variable has not been set to 0 by the user, then an error
- will be printed to standard error.
- Returns ':' if the options string begins with a colon and a required
- argument is missing. If the opterr global variable has not been set to 0 by
- the user, then an error will be printed to standard error.
- -1 if a non-option was encountered. In this case the optind global variable
- will be set to the first non-option argument.
- --*/
- LIBC_API
- int
- nice (
- int Increment
- );
- /*++
- Routine Description:
- This routine adds the given value to the current process' nice value. A
- process' nice value is a non-negative number for which a more positive
- value results in less favorable scheduling. Valid nice values are between
- 0 and 2 * NZERO - 1.
- Arguments:
- Increment - Supplies the increment to add to the current nice value.
- Return Value:
- Returns the new nice value minus NZERO. Note that this can result in a
- successful return value of -1. Callers checking for errors should set
- errno to 0 before calling this function, then check errno after.
- -1 on failure, and errno will be set to indicate more information. This may
- fail with EPERM if the increment is negative and the caller does not have
- appropriate privileges.
- --*/
- #ifdef __cplusplus
- }
- #endif
- #endif
|