123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910 |
- /*++
- 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:
- stdio.h
- Abstract:
- This header contains standard C input and output definitions.
- Author:
- Evan Green 4-Mar-2013
- --*/
- #ifndef _STDIO_H
- #define _STDIO_H
- //
- // ------------------------------------------------------------------- Includes
- //
- #include <libcbase.h>
- #include <sys/types.h>
- #include <stdarg.h>
- #include <stddef.h>
- //
- // ---------------------------------------------------------------- Definitions
- //
- #ifdef __cplusplus
- extern "C" {
- #endif
- //
- // Define the End Of File value returned by some file operation functions.
- //
- #define EOF (-1)
- //
- // Define the size of the standard I/O file stream buffers.
- //
- #define BUFSIZ 8192
- //
- // Define file buffering modes.
- //
- //
- // In this mode files are fully buffered, meaning they will use the internal
- // stream buffer to batch calls to the operating system as much as possible.
- //
- #define _IOFBF 1
- //
- // In this mode files are line buffered, which is the same as fully buffered
- // except a flush occurs whenever a newline is output.
- //
- #define _IOLBF 2
- //
- // In this mode files are not buffered, all reads and writes go directly to the
- // low level file interface.
- //
- #define _IONBF 3
- //
- // Define seek reference locations.
- //
- //
- // Specify this value to indicate that an offset starts from the beginning of
- // the file (the offset is set directly as the file pointer).
- //
- #define SEEK_SET 0
- //
- // Specify this value to indicate that the offset should be added to the
- // current file position.
- //
- #define SEEK_CUR 1
- //
- // Specify this value to indicate that the offset should be added to the end
- // of the file.
- //
- #define SEEK_END 2
- //
- // Define the maximum number of streams which the implementation guarantees
- // can be open simultaneously. It's effectively limitless, but a value is
- // presented here for compatibility.
- //
- #define FOPEN_MAX 16
- //
- // Define the maximum size of a temporary file name.
- //
- #define L_tmpnam 20
- //
- // Define the maximum size of the controlling terminal.
- //
- #define L_ctermid 256
- //
- // Define the location of a temporary directory.
- //
- #define P_tmpdir "/tmp"
- //
- // Define the number of times an application can call the temporary file name
- // functions reliably.
- //
- #define TMP_MAX 60466176
- //
- // Define the maximum reliable length of a file name.
- //
- #define FILENAME_MAX 4096
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- //
- // Define the opaque file type.
- //
- typedef struct _FILE FILE;
- //
- // Define the multibyte state in here as opposed to wchar.h to avoid a nasty
- // circular dependency where stdio.h needs mbstate_t, but wchar.h needs FILE.
- //
- /*++
- Structure Description:
- This structure stores the current shift state for a multibyte character
- conversion.
- Members:
- Data - Stores the opaque multibyte state data.
- --*/
- typedef struct {
- long Data[6];
- } mbstate_t;
- /*++
- Structure Description:
- This structure defines the type used for completely specifying a file type.
- Users must treat this as an opaque type, as its contents may change without
- notice.
- Members:
- Offset - Storees the file offset.
- ShiftState - Stores the multi-byte shift state at the given offset.
- --*/
- typedef struct {
- off_t Offset;
- mbstate_t ShiftState;
- } fpos_t;
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // Define the standard file pointers.
- //
- LIBC_API extern FILE *stdin;
- LIBC_API extern FILE *stdout;
- LIBC_API extern FILE *stderr;
- //
- // -------------------------------------------------------- Function Prototypes
- //
- LIBC_API
- char *
- ctermid (
- char *Buffer
- );
- /*++
- Routine Description:
- This routine returns the null-terminated path of the controlling terminal
- for the current process. Access to the terminal path returned by this
- function is not guaranteed.
- Arguments:
- Buffer - Supplies an optional pointer to a buffer of at least length
- L_ctermid where the path to the terminal will be returned. If this is
- NULL, static storage will be used and returned, in which case the
- caller should not modify or free the buffer.
- Return Value:
- Returns a pointer to the string containing the path of the controlling
- terminal on success.
- NULL on failure.
- --*/
- LIBC_API
- char *
- ctermid_r (
- char *Buffer
- );
- /*++
- Routine Description:
- This routine returns the null-terminated path of the controlling terminal
- for the current process.
- Arguments:
- Buffer - Supplies a pointer to a buffer of at least length L_ctermid where
- the path to the terminal will be returned.
- Return Value:
- Returns a pointer to the supplied buffer on success.
- NULL on failure.
- --*/
- LIBC_API
- int
- rename (
- const char *SourcePath,
- const char *DestinationPath
- );
- /*++
- Routine Description:
- This routine attempts to rename the object at the given path. This routine
- operates on symbolic links themselves, not the destinations of symbolic
- links. If the source and destination paths are equal, this routine will do
- nothing and return successfully. If the source path is not a directory, the
- destination path must not be a directory. If the destination file exists,
- it will be deleted. The caller must have write access in both the old and
- new directories. If the source path is a directory, the destination path
- must not exist or be an empty directory. The destination path must not have
- a path prefix of the source (ie it's illegal to move /my/path into
- /my/path/stuff).
- Arguments:
- SourcePath - Supplies a pointer to a null terminated string containing the
- name of the file or directory to rename.
- DestinationPath - Supplies a pointer to a null terminated string
- containing the path to rename the file or directory to. This path
- cannot span file systems.
- Return Value:
- 0 on success.
- -1 on failure, and the errno variable will be set to contain more
- information.
- --*/
- LIBC_API
- int
- renameat (
- int SourceDirectory,
- const char *SourcePath,
- int DestinationDirectory,
- const char *DestinationPath
- );
- /*++
- Routine Description:
- This routine operates the same as the rename function, except it allows
- relative source and/or destination paths to begin from a directory
- specified by the given file descriptors.
- Arguments:
- SourceDirectory - Supplies a file descriptor to the directory to start
- source path searches from. If the source path is absolute, this value
- is ignored. If this is AT_FDCWD, then source path searches will
- start from the current working directory.
- SourcePath - Supplies a pointer to a null terminated string containing the
- name of the file or directory to rename.
- DestinationPath - Supplies a pointer to a null terminated string
- containing the path to rename the file or directory to. This path
- cannot span file systems.
- DestinationDirectory - Supplies an optional file descriptor to the
- directory to start destination path searches from. If the destination
- path is absolute, this value is ignored. If this is AT_FDCWD, then
- destination path searches will start from the current working directory.
- Return Value:
- 0 on success.
- -1 on failure, and the errno variable will be set to contain more
- information.
- --*/
- LIBC_API
- int
- remove (
- const char *Path
- );
- /*++
- Routine Description:
- This routine attempts to delete the object at the given path. If the
- object pointed to by the given path is a directory, the behavior of remove
- is identical to rmdir. Otherwise, the behavior of remove is identical to
- unlink.
- 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
- FILE *
- fopen (
- const char *FileName,
- const char *Mode
- );
- /*++
- Routine Description:
- This routine opens the given file and associates a stream with it.
- Arguments:
- FileName - Supplies a pointer to a string containing the path to the file
- to open.
- Mode - Supplies a pointer to a null terminated string specifying the mode
- to open the file with. Valid value are "r", "w", "a", and may optionally
- have a + or b appended to it. The + symbol opens the file for updating,
- meaning that the system does not flush immediately after writes. The "b"
- option has no effect.
- Return Value:
- Returns a pointer to the file stream on success.
- NULL on failure, and errno contains more information.
- --*/
- LIBC_API
- FILE *
- fdopen (
- int OpenFileDescriptor,
- const char *Mode
- );
- /*++
- Routine Description:
- This routine associates a stream with the given file descriptor. The mode
- argument must agree with the flags the original descriptor was opened with.
- On success, the stream now "owns" the file descriptor, a call to fclose
- on the stream will also call close on the underlying descriptor.
- Arguments:
- OpenFileDescriptor - Supplies the open file descriptor to create a stream
- around.
- Mode - Supplies a pointer to a null terminated string specifying the mode
- to open the file with. Valid value are "r", "w", "a", and may optionally
- have a + or b appended to it. The + symbol opens the file for updating,
- meaning that the system does not flush immediately after writes. The "b"
- option has no effect.
- Return Value:
- Returns a pointer to the file stream on success.
- NULL on failure, and errno contains more information.
- --*/
- LIBC_API
- FILE *
- freopen (
- const char *FileName,
- const char *Mode,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine attempts to flush the given stream and close any file
- descriptor associated with the stream. Failure to flush or close the
- file descriptor is ignored. The error and end-of-file indicators are
- cleared. This routine then attempts to open the given file with the given
- mode and associate it with the stream. The previous file descriptor
- associated with this stream is closed whether or not the new descriptor
- could be opened.
- The standard says that passing in NULL for the file name will change the
- permissions of the existing descriptor. This implementation currently does
- not support that and sets errno to EBADF if attempted.
- Arguments:
- FileName - Supplies a pointer to the path to open and associate with this
- stream.
- Mode - Supplies a pointer to the string describing the desired access to
- this path. This takes the same format as the fopen mode string.
- Stream - Supplies a pointer to the open stream.
- Return Value:
- Returns a pointer to the given stream on success, now with a different
- file descriptor.
- NULL on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- fclose (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine closes an open file stream.
- Arguments:
- Stream - Supplies a pointer to the open stream.
- Return Value:
- 0 on success.
- Returns EOF if there was an error flushing or closing the stream.
- --*/
- LIBC_API
- size_t
- fread (
- void *Buffer,
- size_t Size,
- size_t ItemCount,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine reads from a file stream.
- Arguments:
- Buffer - Supplies a pointer to the buffer where the data will be returned.
- Size - Supplies the size of each element to read.
- ItemCount - Supplies the number of elements to read.
- Stream - Supplies a pointer to the file stream object to read from.
- Return Value:
- Returns the number of elements successfully read from the file. On failure,
- the error indicator for the stream will be set, and errno will set to
- provide details on the error that occurred.
- --*/
- LIBC_API
- size_t
- fread_unlocked (
- void *Buffer,
- size_t Size,
- size_t ItemCount,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine reads from a file stream without acquiring the internal file
- lock.
- Arguments:
- Buffer - Supplies a pointer to the buffer where the data will be returned.
- Size - Supplies the size of each element to read.
- ItemCount - Supplies the number of elements to read.
- Stream - Supplies a pointer to the file stream object to read from.
- Return Value:
- Returns the number of elements successfully read from the file. On failure,
- the error indicator for the stream will be set, and errno will set to
- provide details on the error that occurred.
- --*/
- LIBC_API
- size_t
- fwrite (
- const void *Buffer,
- size_t Size,
- size_t ItemCount,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine writes to a file stream.
- Arguments:
- Buffer - Supplies a pointer to the buffer containing the data to write.
- Size - Supplies the size of each element to write.
- ItemCount - Supplies the number of elements to write.
- Stream - Supplies a pointer to the file stream object to write to.
- Return Value:
- Returns the number of elements successfully written to the file. On failure,
- the error indicator for the stream will be set, and errno will set to
- provide details on the error that occurred.
- --*/
- LIBC_API
- size_t
- fwrite_unlocked (
- const void *Buffer,
- size_t Size,
- size_t ItemCount,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine writes to a file stream without acquiring the internal file
- lock.
- Arguments:
- Buffer - Supplies a pointer to the buffer containing the data to write.
- Size - Supplies the size of each element to write.
- ItemCount - Supplies the number of elements to write.
- Stream - Supplies a pointer to the file stream object to write to.
- Return Value:
- Returns the number of elements successfully written to the file. On failure,
- the error indicator for the stream will be set, and errno will set to
- provide details on the error that occurred.
- --*/
- LIBC_API
- int
- fflush (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine flushes any data sitting in the file stream that has not yet
- made it out to the operating system. This is only relevant for output
- streams.
- Arguments:
- Stream - Supplies a pointer to the open file stream to flush.
- Return Value:
- 0 on success.
- EOF on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- fflush_unlocked (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine flushes any data sitting in the file stream that has not yet
- made it out to the operating system. This routine does not acquire the
- internal stream lock. This is only relevant for output streams.
- Arguments:
- Stream - Supplies a pointer to the open file stream to flush.
- Return Value:
- 0 on success.
- EOF on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- long
- ftell (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine returns the given stream's file position.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Return Value:
- Returns the current file position on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- off_t
- ftello (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine returns the given stream's file position.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Return Value:
- Returns the current file position on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- off64_t
- ftello64 (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine returns the given stream's file position.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Return Value:
- Returns the current file position on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- off_t
- ftello_unlocked (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine returns the given stream's file position.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Return Value:
- Returns the current file position on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- fseek (
- FILE *Stream,
- long Offset,
- int Whence
- );
- /*++
- Routine Description:
- This routine sets the file position indicator for the given stream. If a
- read or write error occurs, the error indicator will be set for the stream
- and fseek fails. This routine will undo any effects of a previous call to
- unget.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Offset - Supplies the offset from the reference point 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:
- 0 on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- fseeko (
- FILE *Stream,
- off_t Offset,
- int Whence
- );
- /*++
- Routine Description:
- This routine sets the file position indicator for the given stream. If a
- read or write error occurs, the error indicator will be set for the stream
- and fseek fails. This routine will undo any effects of a previous call to
- unget.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Offset - Supplies the offset from the reference point 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:
- 0 on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- fseeko64 (
- FILE *Stream,
- off64_t Offset,
- int Whence
- );
- /*++
- Routine Description:
- This routine sets the file position indicator for the given stream. If a
- read or write error occurs, the error indicator will be set for the stream
- and fseek fails. This routine will undo any effects of a previous call to
- unget.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Offset - Supplies the offset from the reference point 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:
- 0 on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- fseeko_unlocked (
- FILE *Stream,
- off_t Offset,
- int Whence
- );
- /*++
- Routine Description:
- This routine sets the file position indicator for the given stream. If a
- read or write error occurs, the error indicator will be set for the stream
- and fseek fails. This routine does not acquire the internal stream lock.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Offset - Supplies the offset from the reference point 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:
- 0 on success.
- -1 on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- fgetpos (
- FILE *Stream,
- fpos_t *Position
- );
- /*++
- Routine Description:
- This routine returns an opaque structure representing the current absolute
- position within the given stream.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Position - Supplies a pointer where the opaque position will be returned.
- Callers must not presume that they can cast this type to an integer or
- compare these types in any way, they only serve as possible inputs to
- fsetpos to restore a file position to its current location.
- Return Value:
- 0 on success.
- -1 on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- fsetpos (
- FILE *Stream,
- const fpos_t *Position
- );
- /*++
- Routine Description:
- This routine sets the current file position.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Position - Supplies a pointer where the opaque position that was returned
- by a previous call to fgetpos.
- Return Value:
- 0 on success.
- -1 on failure, and errno will contain more information.
- --*/
- LIBC_API
- void
- rewind (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine positions the file indicator back to the beginning. It shall
- be equivalent to fseek(Stream, 0, SEEK_SET) except that it also clears
- the error indicator.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Return Value:
- None. Applications wishing to detect an error occurring during this
- function should set errno 0, call the function, and then check errno.
- --*/
- LIBC_API
- int
- fileno (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine returns the integer file descriptor associated with the given
- stream.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Return Value:
- Returns the integer value of the file descriptor associated with the given
- stream on success.
- -1 on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- fgetc (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine reads one byte from the given file stream.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Return Value:
- Returns the byte on success.
- EOF on failure or the end of the file, and errno will contain more
- information.
- --*/
- LIBC_API
- int
- fgetc_unlocked (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine reads one byte from the given file stream without acquiring
- the internal stream lock.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Return Value:
- Returns the byte on success.
- EOF on failure or the end of the file, and errno will contain more
- information.
- --*/
- LIBC_API
- int
- getchar (
- void
- );
- /*++
- Routine Description:
- This routine reads one byte from stdin.
- Arguments:
- None.
- Return Value:
- Returns the byte from stdin on success.
- -1 on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- getchar_unlocked (
- void
- );
- /*++
- Routine Description:
- This routine reads one byte from stdin without acquiring the file lock.
- Arguments:
- None.
- Return Value:
- Returns the byte from stdin on success.
- -1 on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- getc (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine reads one byte from the given file stream. It is equivalent to
- the fgetc function.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Return Value:
- Returns the byte on success.
- EOF on failure or the end of the file, and errno will contain more
- information.
- --*/
- LIBC_API
- int
- getc_unlocked (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine reads one byte from the given file stream, without acquiring
- the internal file lock. It is equivalent to the fgetc_unlocked function.
- Arguments:
- Stream - Supplies a pointer to the open file stream.
- Return Value:
- Returns the byte on success.
- EOF on failure or the end of the file, and errno will contain more
- information.
- --*/
- LIBC_API
- char *
- gets (
- char *Line
- );
- /*++
- Routine Description:
- This routine gets a line of input from standard in, writing bytes to the
- supplied line until a newline or end of file is reached. The newline (if
- found) will be discarded and the string null terminated.
- Use of this function is highly discouraged, as there is no bound on the
- size of text the user can put on one line. Any use of this function is a
- security hole. Use fgets instead.
- Arguments:
- Line - Supplies a pointer where the line will be returned on success.
- Return Value:
- Returns a pointer to the supplied line buffer on success.
- NULL if EOF was encountered.
- --*/
- LIBC_API
- char *
- fgets (
- char *Buffer,
- int BufferSize,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine reads bytes from the given stream and places them in the
- given buffer until the buffer fills up, a newline is read and transferred,
- or the end of the file is reached. The string is then terminated with a
- null byte.
- Arguments:
- Buffer - Supplies a pointer to the buffer where the read characters should
- be returned.
- BufferSize - Supplies the size of the supplied buffer in bytes.
- Stream - Supplies a pointer to the file stream to read out of.
- Return Value:
- Returns the given buffer on success. If the stream is at end-of-file, the
- end-of-file indicator shall be set and this routine returns NULL. If a
- read error occurs, the error indicator for the stream shall be set, and
- this routine returns NULL. The errno variable may also be set to contain
- more information.
- --*/
- LIBC_API
- char *
- fgets_unlocked (
- char *Buffer,
- int BufferSize,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine reads bytes from the given stream and places them in the
- given buffer until the buffer fills up, a newline is read and transferred,
- or the end of the file is reached. The string is then terminated with a
- null byte.
- Arguments:
- Buffer - Supplies a pointer to the buffer where the read characters should
- be returned.
- BufferSize - Supplies the size of the supplied buffer in bytes.
- Stream - Supplies a pointer to the file stream to read out of.
- Return Value:
- Returns the given buffer on success. If the stream is at end-of-file, the
- end-of-file indicator shall be set and this routine returns NULL. If a
- read error occurs, the error indicator for the stream shall be set, and
- this routine returns NULL. The errno variable may also be set to contain
- more information.
- --*/
- LIBC_API
- int
- fputc (
- int Character,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine writes a byte to the given file stream.
- Arguments:
- Character - Supplies the character (converted to an unsigned char) to
- write.
- Stream - Supplies the stream to write the character to.
- Return Value:
- Returns the byte it has written on success.
- EOF on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- fputc_unlocked (
- int Character,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine writes a byte to the given file stream without acquiring the
- internal stream lock.
- Arguments:
- Character - Supplies the character (converted to an unsigned char) to
- write.
- Stream - Supplies the stream to write the character to.
- Return Value:
- Returns the byte it has written on success.
- EOF on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- putc (
- int Character,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine writes a byte to the given file stream. It is equivalent to
- the fputc function.
- Arguments:
- Character - Supplies the character (converted to an unsigned char) to
- write.
- Stream - Supplies the stream to write the character to.
- Return Value:
- Returns the byte it has written on success.
- EOF on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- putc_unlocked (
- int Character,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine writes a byte to the given file stream without acquiring the
- stream lock. It is equivalent to the fputc_unlocked function.
- Arguments:
- Character - Supplies the character (converted to an unsigned char) to
- write.
- Stream - Supplies the stream to write the character to.
- Return Value:
- Returns the byte it has written on success.
- EOF on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- putchar (
- int Character
- );
- /*++
- Routine Description:
- This routine writes a byte to standard out. This routine is equivalent to
- fputc(Character, stdout).
- Arguments:
- Character - Supplies the character (converted to an unsigned char) to
- write.
- Return Value:
- Returns the byte it has written on success.
- EOF on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- putchar_unlocked (
- int Character
- );
- /*++
- Routine Description:
- This routine writes a byte to standard out, without acquiring the stream
- lock. This routine is equivalent to fputc_unlocked(Character, stdout).
- Arguments:
- Character - Supplies the character (converted to an unsigned char) to
- write.
- Return Value:
- Returns the byte it has written on success.
- EOF on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- puts (
- const char *String
- );
- /*++
- Routine Description:
- This routine writes the given string to standard out. The null terminating
- byte is not written.
- Arguments:
- String - Supplies a pointer to the null terminated string to write to.
- Stream - Supplies the stream to write the character to.
- Return Value:
- Returns a non-negative number on success.
- Returns EOF on failure, and the error indicator will be set for the stream.
- The errno variable will also be set to provide more information.
- --*/
- LIBC_API
- int
- fputs (
- const char *String,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine writes the given string to the given file stream. The null
- terminating byte is not written.
- Arguments:
- String - Supplies a pointer to the null terminated string to write to.
- Stream - Supplies the stream to write the character to.
- Return Value:
- Returns a non-negative number on success.
- Returns EOF on failure, and the error indicator will be set for the stream.
- The errno variable will also be set to provide more information.
- --*/
- LIBC_API
- int
- fputs_unlocked (
- const char *String,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine writes the given string to the given file stream. The null
- terminating byte is not written. This routine does not acquire the stream
- lock.
- Arguments:
- String - Supplies a pointer to the null terminated string to write to.
- Stream - Supplies the stream to write the character to.
- Return Value:
- Returns a non-negative number on success.
- Returns EOF on failure, and the error indicator will be set for the stream.
- The errno variable will also be set to provide more information.
- --*/
- LIBC_API
- int
- ungetc (
- int Character,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine pushes the specified character back onto the input stream. The
- pushed back character shall be returned by subsequent reads on that stream
- in the reverse order of their pushing. A successful intervening call to
- seek or flush will discard any pushed back bytes for the stream. One byte
- of push back is provided.
- Arguments:
- Character - Supplies the character (converted to an unsigned char) to
- push back.
- Stream - Supplies the stream to push the character on to.
- Return Value:
- Returns the byte pushed back on success.
- EOF on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- ungetc_unlocked (
- int Character,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine pushes the specified character back onto the input stream. The
- pushed back character shall be returned by subsequent reads on that stream
- in the reverse order of their pushing. A successful intervening call to
- seek or flush will discard any pushed back bytes for the stream. One byte
- of push back is provided. This routine does not acquire the internal
- stream lock.
- Arguments:
- Character - Supplies the character (converted to an unsigned char) to
- push back.
- Stream - Supplies the stream to push the character on to.
- Return Value:
- Returns the byte pushed back on success.
- EOF on failure, and errno will contain more information.
- --*/
- LIBC_API
- int
- setvbuf (
- FILE *Stream,
- char *Buffer,
- int Mode,
- size_t BufferSize
- );
- /*++
- Routine Description:
- This routine sets the buffering mode and buffer (optionally) for the given
- file stream.
- Arguments:
- Stream - Supplies a pointer to the file stream whose buffering
- characteristics should be altered.
- Buffer - Supplies an optional pointer to the buffer to use for fully
- buffered or line buffered mode. If either of those two modes are
- supplied and this buffer is not supplied, one will be malloced.
- Mode - Supplies the buffering mode to set for this file stream. Valid
- value are:
- _IONBF - Disable buffering on this file stream. All reads and writes
- will go straight to the low level I/O interface.
- _IOFBF - Fully buffered mode. The stream interface will batch reads
- and writes to the low level I/O interface to optimize performance.
- _IOLBF - Line buffered mode. This mode behaves the same as fully
- buffered mode, except that the buffer is flushed automatically when
- a newline character is written to the stream. For input buffers,
- the behavior is no different from fully buffered mode.
- BufferSize - Supplies the size of the supplied buffer in bytes.
- Return Value:
- 0 on success.
- -1 on failure, and errno will contain more information.
- --*/
- LIBC_API
- void
- setbuf (
- FILE *Stream,
- char *Buffer
- );
- /*++
- Routine Description:
- This routine sets the internal buffer on a stream. If the given buffer is
- not NULL, this routine shall be equivalent to:
- setvbuf(Stream, Buffer, _IOFBF, BUFSIZ);
- or,
- setvbuf(Stream, Buffer, _IONBF, BUFSIZ);
- if the given buffer is a NULL pointer.
- Arguments:
- Stream - Supplies a pointer to the file stream.
- Buffer - Supplies the optional buffer to use.
- Return Value:
- None.
- --*/
- LIBC_API
- void
- clearerr (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine clears the error and end-of-file indicators for the given
- stream.
- Arguments:
- Stream - Supplies a pointer to the file stream.
- Return Value:
- None.
- --*/
- LIBC_API
- void
- clearerr_unlocked (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine clears the error and end-of-file indicators for the given
- stream. This routine does not acquire the file lock.
- Arguments:
- Stream - Supplies a pointer to the file stream.
- Return Value:
- None.
- --*/
- LIBC_API
- int
- feof (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine returns whether or not the current stream has attempted to
- read beyond the end of the file.
- Arguments:
- Stream - Supplies a pointer to the file stream.
- Return Value:
- Returns non-zero if the end of file indicator is set for the given stream.
- --*/
- LIBC_API
- int
- feof_unlocked (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine returns whether or not the current stream has attempted to
- read beyond the end of the file, without acquiring the file lock.
- Arguments:
- Stream - Supplies a pointer to the file stream.
- Return Value:
- Returns non-zero if the end of file indicator is set for the given stream.
- --*/
- LIBC_API
- int
- ferror (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine returns whether or not the error indicator is set for the
- current stream.
- Arguments:
- Stream - Supplies a pointer to the file stream.
- Return Value:
- Returns non-zero if the error indicator is set for the given stream.
- --*/
- LIBC_API
- int
- ferror_unlocked (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine returns whether or not the error indicator is set for the
- current stream, without acquiring the file lock.
- Arguments:
- Stream - Supplies a pointer to the file stream.
- Return Value:
- Returns non-zero if the error indicator is set for the given stream.
- --*/
- LIBC_API
- void
- flockfile (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine explicitly locks a file stream. It can be used on the standard
- I/O streams to group a batch of I/O together.
- Arguments:
- Stream - Supplies a pointer to the file stream.
- Return Value:
- None.
- --*/
- LIBC_API
- int
- ftrylockfile (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine attempts to acquire the lock for a given stream.
- Arguments:
- Stream - Supplies a pointer to the file stream.
- Return Value:
- 0 if the lock was successfully acquired.
- Non-zero if the file lock could not be acquired.
- --*/
- LIBC_API
- void
- funlockfile (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine explicitly unlocks a file stream that had been previously
- locked with flockfile or ftrylockfile (on a successful attempt).
- Arguments:
- Stream - Supplies a pointer to the file stream.
- Return Value:
- None.
- --*/
- LIBC_API
- FILE *
- popen (
- const char *Command,
- const char *Mode
- );
- /*++
- Routine Description:
- This routine executes the command specified by the given string. It shall
- create a pipe between the calling program and the executed command, and
- shall return a pointer to a stream that can be used to either read from or
- write to the pipe. Streams returned by this function should be closed with
- the pclose function.
- Arguments:
- Command - Supplies a pointer to a null terminated string containing the
- command to execute.
- Mode - Supplies a pointer to a null terminated string containing the mode
- information of the returned string. If the first character of the
- given string is 'r', then the file stream returned can be read to
- retrieve the standard output of the executed process. Otherwise, the
- file stream returned can be written to to send data to the standard
- input of the executed process.
- Return Value:
- Returns a pointer to a stream wired up to the standard in or standard out
- of the executed process.
- NULL on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- int
- pclose (
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine closes a stream opened by the popen function, wait for the
- command to terminate, and return the termination status of the process
- that was running the command language interpreter.
- Arguments:
- Stream - Supplies a pointer to the stream opened with popen.
- Return Value:
- Returns the execution status of the opened process.
- 127 if the command language intepreter cannot be executed.
- -1 if an intervening call to wait or waitpid caused the termination status
- to be unavailable. In this case, errno will be set to ECHLD.
- --*/
- LIBC_API
- char *
- tmpnam (
- char *Buffer
- );
- /*++
- Routine Description:
- This routine generates a string that is a valid filename and is not the
- name of an existing file. This routine returns a different name each time
- it is called. Note that between the time the name is returned and when an
- application goes to create the file, the file may already be created.
- Applications may find the tmpfile function more robust and useful.
- Arguments:
- Buffer - Supplies an optional pointer to a buffer where the name will be
- returned. This buffer is assumed to be at least L_tmpnam bytes large.
- If this buffer is not supplied, then a pointer to a global buffer will
- be returned. Subsequent calls to this routine will overwrite the
- contents of that returned buffer.
- Return Value:
- Returns a pointer to a string containing the name of a temporary file. This
- returns the buffer if it is supplied, or a pointer to a global buffer
- otherwise.
- --*/
- LIBC_API
- char *
- tempnam (
- const char *Directory,
- const char *Prefix
- );
- /*++
- Routine Description:
- This routine generates path name that may be used for a temporary file.
- Arguments:
- Directory - Supplies an optional pointer to a string containing the name of
- the directory in which the temporary file is to be created. If the
- directory is not supplied or is not an appropriate directory, then the
- path prefix defined as P_tmpdir in stdio.h shall be used.
- Prefix - Supplies a pointer to a string containing up to a five character
- prefix on the temporary file name.
- Return Value:
- Returns a pointer to a string containing the name of a temporary file. The
- caller must call free when finished with this buffer to reclaim the memory
- allocated by this routine.
- NULL on failure, and errno will be set to contain more information.
- --*/
- LIBC_API
- FILE *
- tmpfile (
- void
- );
- /*++
- Routine Description:
- This routine creates a file and opens a corresponding stream. The file
- shall be automatically deleted when all references to the file are closed.
- The file is opened as in fopen for update ("w+").
- Arguments:
- None.
- Return Value:
- Returns an open file stream on success.
- NULL if a temporary file could not be created.
- --*/
- LIBC_API
- void
- perror (
- const char *String
- );
- /*++
- Routine Description:
- This routine maps the error number accessed through the symbol errno to
- a language-dependent error message, and prints that out to standard error
- with the given parameter.
- Arguments:
- String - Supplies an optional pointer to a string to print before the
- error message. If this is supplied and of non-zero length, the format
- will be "<string>: <errno string>\n". Otherwise, the format will be
- "<errno string>\n".
- Return Value:
- None.
- --*/
- LIBC_API
- int
- printf (
- const char *Format,
- ...
- );
- /*++
- Routine Description:
- This routine prints a formatted string to the standard output file stream.
- Arguments:
- Format - Supplies the printf format string.
- ... - Supplies a variable number of arguments, as required by the printf
- format string argument.
- Return Value:
- Returns the number of bytes successfully converted, not including the null
- terminator.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- fprintf (
- FILE *Stream,
- const char *Format,
- ...
- );
- /*++
- Routine Description:
- This routine prints a formatted string to the given file stream.
- Arguments:
- Stream - Supplies the file stream to print to.
- Format - Supplies the printf format string.
- ... - Supplies a variable number of arguments, as required by the printf
- format string argument.
- Return Value:
- Returns the number of bytes successfully converted, not including the null
- terminator.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- fprintf_unlocked (
- FILE *Stream,
- const char *Format,
- ...
- );
- /*++
- Routine Description:
- This routine prints a formatted string to the given file stream. This
- routine does not acquire the stream lock.
- Arguments:
- Stream - Supplies the file stream to print to.
- Format - Supplies the printf format string.
- ... - Supplies a variable number of arguments, as required by the printf
- format string argument.
- Return Value:
- Returns the number of bytes successfully converted, not including the null
- terminator.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- vfprintf (
- FILE *File,
- const char *Format,
- va_list Arguments
- );
- /*++
- Routine Description:
- This routine prints a formatted string to the given file pointer.
- Arguments:
- File - Supplies a pointer to the file stream to output to.
- Format - Supplies the printf format string.
- Arguments - Supplies the argument list to the format string. The va_end
- macro is not invoked on this list.
- Return Value:
- Returns the number of bytes successfully converted. A null terminator is
- not written.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- vfprintf_unlocked (
- FILE *File,
- const char *Format,
- va_list Arguments
- );
- /*++
- Routine Description:
- This routine prints a formatted string to the given file pointer. This
- routine does not acquire the stream lock.
- Arguments:
- File - Supplies a pointer to the file stream to output to.
- Format - Supplies the printf format string.
- Arguments - Supplies the argument list to the format string. The va_end
- macro is not invoked on this list.
- Return Value:
- Returns the number of bytes successfully converted. A null terminator is
- not written.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- vprintf (
- const char *Format,
- va_list Arguments
- );
- /*++
- Routine Description:
- This routine prints a formatted string to the standard output file stream.
- Arguments:
- Format - Supplies the printf format string.
- Arguments - Supplies the argument list to the format string. The va_end
- macro is not invoked on this list.
- Return Value:
- Returns the number of bytes successfully converted, not including the null
- terminator.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- dprintf (
- int FileDescriptor,
- const char *Format,
- ...
- );
- /*++
- Routine Description:
- This routine prints a formatted string to the given file descriptor.
- Arguments:
- FileDescriptor - Supplies the file descriptor to print to.
- Format - Supplies the printf format string.
- ... - Supplies a variable number of arguments, as required by the printf
- format string argument.
- Return Value:
- Returns the number of bytes successfully converted, not including the null
- terminator.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- vdprintf (
- int FileDescriptor,
- const char *Format,
- va_list Arguments
- );
- /*++
- Routine Description:
- This routine prints a formatted string to the given file descriptor.
- Arguments:
- FileDescriptor - Supplies the file descriptor to print to.
- Format - Supplies the printf format string.
- Arguments - Supplies the argument list to the format string. The va_end
- macro is not invoked on this list.
- Return Value:
- Returns the number of bytes successfully converted. A null terminator is
- not written.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- sprintf (
- char *OutputString,
- const char *Format,
- ...
- );
- /*++
- Routine Description:
- This routine prints a formatted string to the given buffer. This routine
- should be avoided if possible as it can be the cause of buffer overflow
- issues. Use snprintf instead, a function that explicitly bounds the output
- buffer.
- Arguments:
- OutputString - Supplies the buffer where the formatted string will be
- returned. It is the caller's responsibility to ensure this buffer is
- large enough to hold the formatted string.
- Format - Supplies the printf format string.
- ... - Supplies a variable number of arguments, as required by the printf
- format string argument.
- Return Value:
- Returns the number of bytes successfully converted, not including the null
- terminator.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- snprintf (
- char *OutputString,
- size_t OutputStringSize,
- const char *Format,
- ...
- );
- /*++
- Routine Description:
- This routine prints a formatted string to the given bounded buffer.
- Arguments:
- OutputString - Supplies the buffer where the formatted string will be
- returned.
- OutputStringSize - Supplies the number of bytes in the output buffer.
- Format - Supplies the printf format string.
- ... - Supplies a variable number of arguments, as required by the printf
- format string argument.
- Return Value:
- Returns the number of bytes that would have been converted had
- OutputStringSize been large enough, not including the null terminator.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- vsnprintf (
- char *OutputString,
- size_t OutputStringSize,
- const char *Format,
- va_list Arguments
- );
- /*++
- Routine Description:
- This routine implements the core string print format function.
- Arguments:
- OutputString - Supplies a pointer to the buffer where the resulting string
- will be written.
- OutputStringSize - Supplies the size of the output string buffer, in bytes.
- If the format is too long for the output buffer, the resulting string
- will be truncated and the last byte will always be a null terminator.
- Format - Supplies the printf format string.
- Arguments - Supplies the argument list to the format string. The va_end
- macro is not invoked on this list.
- Return Value:
- Returns the number of bytes that would have been converted had
- OutputStringSize been large enough, not including the null terminator.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- vsprintf (
- char *OutputString,
- const char *Format,
- va_list Arguments
- );
- /*++
- Routine Description:
- This routine implements the core string print format function.
- Arguments:
- OutputString - Supplies a pointer to the buffer where the resulting string
- will be written.
- Format - Supplies the printf format string.
- Arguments - Supplies the argument list to the format string. The va_end
- macro is not invoked on this list.
- Return Value:
- Returns the number of bytes successfully converted, not including the null
- terminator.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- asprintf (
- char **OutputString,
- const char *Format,
- ...
- );
- /*++
- Routine Description:
- This routine prints a formatting string to a string similar to vsnprintf,
- except the destination string is allocated by this function using malloc.
- Arguments:
- OutputString - Supplies a pointer where a pointer to a newly allocated
- buffer containing the formatted string result (including the null
- terminator) will be returned. The caller is reponsible for freeing this
- string.
- Format - Supplies the printf format string.
- ... - Supplies the argument list to the format string.
- Return Value:
- Returns the number of bytes successfully converted, not including the null
- terminator.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- vasprintf (
- char **OutputString,
- const char *Format,
- va_list Arguments
- );
- /*++
- Routine Description:
- This routine prints a formatting string to a string similar to vsnprintf,
- except the destination string is allocated by this function using malloc.
- Arguments:
- OutputString - Supplies a pointer where a pointer to a newly allocated
- buffer containing the formatted string result (including the null
- terminator) will be returned. The caller is reponsible for freeing this
- string.
- Format - Supplies the printf format string.
- Arguments - Supplies the argument list to the format string. The va_end
- macro is not invoked on this list.
- Return Value:
- Returns the number of bytes successfully converted, not including the null
- terminator.
- Returns a negative number if an error was encountered.
- --*/
- LIBC_API
- int
- sscanf (
- const char *Input,
- const char *Format,
- ...
- );
- /*++
- Routine Description:
- This routine scans in a string and converts it to a number of arguments
- based on a format string.
- Arguments:
- Input - Supplies a pointer to the input string to scan.
- Format - Supplies the format string that specifies how to convert the input
- to the arguments.
- ... - Supplies the remaining pointer arguments where the scanned data will
- be returned.
- Return Value:
- Returns the number of successfully matched items on success. If the input
- ends before the first matching failure or conversion, EOF is returned. If
- a read error occurs, EOF shall be returned and errno shall be set to
- indicate the error.
- --*/
- LIBC_API
- int
- vsscanf (
- const char *String,
- const char *Format,
- va_list ArgumentList
- );
- /*++
- Routine Description:
- This routine scans in a string and converts it to a number of arguments
- based on a format string.
- Arguments:
- String - Supplies a pointer to the input string to scan.
- Format - Supplies the format string that specifies how to convert the input
- to the arguments.
- ArgumentList - Supplies the remaining arguments, which are all pointers to
- various types to be scanned.
- Return Value:
- Returns the number of successfully matched items on success. If the input
- ends before the first matching failure or conversion, EOF is returned. If
- a read error occurs, EOF shall be returned and errno shall be set to
- indicate the error.
- --*/
- LIBC_API
- int
- fscanf (
- FILE *Stream,
- const char *Format,
- ...
- );
- /*++
- Routine Description:
- This routine scans in a string from a stream and converts it to a number of
- arguments based on a format string.
- Arguments:
- Stream - Supplies a pointer to the input stream.
- Format - Supplies the format string that specifies how to convert the input
- to the arguments.
- ... - Supplies the remaining arguments, which are all pointers to
- various types to be scanned.
- Return Value:
- Returns the number of successfully matched items on success. If the input
- ends before the first matching failure or conversion, EOF is returned. If
- a read error occurs, EOF shall be returned and errno shall be set to
- indicate the error.
- --*/
- LIBC_API
- int
- vfscanf (
- FILE *Stream,
- const char *Format,
- va_list ArgumentList
- );
- /*++
- Routine Description:
- This routine scans in a string from a stream and converts it to a number
- of arguments based on a format string.
- Arguments:
- Stream - Supplies a pointer to the input stream.
- Format - Supplies the format string that specifies how to convert the input
- to the arguments.
- ArgumentList - Supplies the remaining arguments, which are all pointers to
- various types to be scanned.
- Return Value:
- Returns the number of successfully matched items on success. If the input
- ends before the first matching failure or conversion, EOF is returned. If
- a read error occurs, EOF shall be returned and errno shall be set to
- indicate the error.
- --*/
- LIBC_API
- int
- vfscanf_unlocked (
- FILE *Stream,
- const char *Format,
- va_list ArgumentList
- );
- /*++
- Routine Description:
- This routine scans in a string from a stream and converts it to a number
- of arguments based on a format string. This routine does not acquire the
- stream's lock.
- Arguments:
- Stream - Supplies a pointer to the input stream.
- Format - Supplies the format string that specifies how to convert the input
- to the arguments.
- ArgumentList - Supplies the remaining arguments, which are all pointers to
- various types to be scanned.
- Return Value:
- Returns the number of successfully matched items on success. If the input
- ends before the first matching failure or conversion, EOF is returned. If
- a read error occurs, EOF shall be returned and errno shall be set to
- indicate the error.
- --*/
- LIBC_API
- int
- scanf (
- const char *Format,
- ...
- );
- /*++
- Routine Description:
- This routine scans in a string from standard in and converts it to a number
- of arguments based on a format string.
- Arguments:
- Format - Supplies the format string that specifies how to convert the input
- to the arguments.
- ... - Supplies the remaining arguments, which are all pointers to
- various types to be scanned.
- Return Value:
- Returns the number of successfully matched items on success. If the input
- ends before the first matching failure or conversion, EOF is returned. If
- a read error occurs, EOF shall be returned and errno shall be set to
- indicate the error.
- --*/
- LIBC_API
- int
- vscanf (
- const char *Format,
- va_list ArgumentList
- );
- /*++
- Routine Description:
- This routine scans in a string from standard in and converts it to a number
- of arguments based on a format string.
- Arguments:
- Format - Supplies the format string that specifies how to convert the input
- to the arguments.
- ArgumentList - Supplies the remaining arguments, which are all pointers to
- various types to be scanned.
- Return Value:
- Returns the number of successfully matched items on success. If the input
- ends before the first matching failure or conversion, EOF is returned. If
- a read error occurs, EOF shall be returned and errno shall be set to
- indicate the error.
- --*/
- LIBC_API
- ssize_t
- getline (
- char **LinePointer,
- size_t *Size,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine reads an entire line from the given stream. This routine will
- allocate or reallocate the given buffer so that the buffer is big enough.
- Arguments:
- LinePointer - Supplies a pointer that on input contains an optional pointer
- to a buffer to use to read the line. If the buffer ends up being not
- big enough, it will be reallocated. If no buffer is supplied, one will
- be allocated. On output, contains a pointer to the buffer containing
- the read line on success.
- Size - Supplies a pointer that on input contains the size in bytes of the
- supplied line pointer. On output, this value will be updated to contain
- the size of the buffer returned in the line buffer parameter.
- Stream - Supplies the stream to read the line from.
- Return Value:
- On success, returns the number of characters read, including the delimiter
- character, but not including the null terminator.
- Returns -1 on failure (including an end of file condition), and errno will
- be set to contain more information.
- --*/
- LIBC_API
- ssize_t
- getdelim (
- char **LinePointer,
- size_t *Size,
- int Delimiter,
- FILE *Stream
- );
- /*++
- Routine Description:
- This routine reads an entire line from the given stream, delimited by the
- given delimiter character. This routine will allocate or reallocate the
- given buffer so that the buffer is big enough.
- Arguments:
- LinePointer - Supplies a pointer that on input contains an optional pointer
- to a buffer to use to read the line. If the buffer ends up being not
- big enough, it will be reallocated. If no buffer is supplied, one will
- be allocated. On output, contains a pointer to the buffer containing
- the read line on success.
- Size - Supplies a pointer that on input contains the size in bytes of the
- supplied line pointer. On output, this value will be updated to contain
- the size of the buffer returned in the line buffer parameter.
- Delimiter - Supplies the delimiter to split the line on.
- Stream - Supplies the stream to read the line from.
- Return Value:
- On success, returns the number of characters read, including the delimiter
- character, but not including the null terminator.
- Returns -1 on failure (including an end of file condition), and errno will
- be set to contain more information.
- --*/
- #ifdef __cplusplus
- }
- #endif
- #endif
|