Current Path : /usr/opt/openssl11/share/doc/openssl/html/man3/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/opt/openssl11/share/doc/openssl/html/man3/BIO_get_fp.html |
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>BIO_s_file</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rev="made" href="mailto:root@hsxx.drive.ne.jp" /> </head> <body style="background-color: white"> <!-- INDEX BEGIN --> <div name="index"> <p><a name="__index__"></a></p> <ul> <li><a href="#name">NAME</a></li> <li><a href="#synopsis">SYNOPSIS</a></li> <li><a href="#description">DESCRIPTION</a></li> <li><a href="#notes">NOTES</a></li> <li><a href="#return_values">RETURN VALUES</a></li> <li><a href="#examples">EXAMPLES</a></li> <li><a href="#bugs">BUGS</a></li> <li><a href="#see_also">SEE ALSO</a></li> <li><a href="#copyright">COPYRIGHT</a></li> </ul> <hr name="index" /> </div> <!-- INDEX END --> <p> </p> <hr /> <h1><a name="name">NAME</a></h1> <p>BIO_s_file, BIO_new_file, BIO_new_fp, BIO_set_fp, BIO_get_fp, BIO_read_filename, BIO_write_filename, BIO_append_filename, BIO_rw_filename - FILE bio</p> <p> </p> <hr /> <h1><a name="synopsis">SYNOPSIS</a></h1> <pre> #include <openssl/bio.h></pre> <pre> const BIO_METHOD *BIO_s_file(void); BIO *BIO_new_file(const char *filename, const char *mode); BIO *BIO_new_fp(FILE *stream, int flags);</pre> <pre> BIO_set_fp(BIO *b, FILE *fp, int flags); BIO_get_fp(BIO *b, FILE **fpp);</pre> <pre> int BIO_read_filename(BIO *b, char *name) int BIO_write_filename(BIO *b, char *name) int BIO_append_filename(BIO *b, char *name) int BIO_rw_filename(BIO *b, char *name)</pre> <p> </p> <hr /> <h1><a name="description">DESCRIPTION</a></h1> <p><code>BIO_s_file()</code> returns the BIO file method. As its name implies it is a wrapper round the stdio FILE structure and it is a source/sink BIO.</p> <p>Calls to <code>BIO_read_ex()</code> and <code>BIO_write_ex()</code> read and write data to the underlying stream. <code>BIO_gets()</code> and <code>BIO_puts()</code> are supported on file BIOs.</p> <p><code>BIO_flush()</code> on a file BIO calls the <code>fflush()</code> function on the wrapped stream.</p> <p><code>BIO_reset()</code> attempts to change the file pointer to the start of file using fseek(stream, 0, 0).</p> <p><code>BIO_seek()</code> sets the file pointer to position <strong>ofs</strong> from start of file using fseek(stream, ofs, 0).</p> <p><code>BIO_eof()</code> calls <code>feof()</code>.</p> <p>Setting the BIO_CLOSE flag calls <code>fclose()</code> on the stream when the BIO is freed.</p> <p><code>BIO_new_file()</code> creates a new file BIO with mode <strong>mode</strong> the meaning of <strong>mode</strong> is the same as the stdio function <code>fopen()</code>. The BIO_CLOSE flag is set on the returned BIO.</p> <p><code>BIO_new_fp()</code> creates a file BIO wrapping <strong>stream</strong>. Flags can be: BIO_CLOSE, BIO_NOCLOSE (the close flag) BIO_FP_TEXT (sets the underlying stream to text mode, default is binary: this only has any effect under Win32).</p> <p><code>BIO_set_fp()</code> sets the fp of a file BIO to <strong>fp</strong>. <strong>flags</strong> has the same meaning as in <code>BIO_new_fp()</code>, it is a macro.</p> <p><code>BIO_get_fp()</code> retrieves the fp of a file BIO, it is a macro.</p> <p><code>BIO_seek()</code> is a macro that sets the position pointer to <strong>offset</strong> bytes from the start of file.</p> <p><code>BIO_tell()</code> returns the value of the position pointer.</p> <p><code>BIO_read_filename()</code>, <code>BIO_write_filename()</code>, <code>BIO_append_filename()</code> and <code>BIO_rw_filename()</code> set the file BIO <strong>b</strong> to use file <strong>name</strong> for reading, writing, append or read write respectively.</p> <p> </p> <hr /> <h1><a name="notes">NOTES</a></h1> <p>When wrapping stdout, stdin or stderr the underlying stream should not normally be closed so the BIO_NOCLOSE flag should be set.</p> <p>Because the file BIO calls the underlying stdio functions any quirks in stdio behaviour will be mirrored by the corresponding BIO.</p> <p>On Windows BIO_new_files reserves for the filename argument to be UTF-8 encoded. In other words if you have to make it work in multi- lingual environment, encode filenames in UTF-8.</p> <p> </p> <hr /> <h1><a name="return_values">RETURN VALUES</a></h1> <p><code>BIO_s_file()</code> returns the file BIO method.</p> <p><code>BIO_new_file()</code> and <code>BIO_new_fp()</code> return a file BIO or NULL if an error occurred.</p> <p><code>BIO_set_fp()</code> and <code>BIO_get_fp()</code> return 1 for success or 0 for failure (although the current implementation never return 0).</p> <p><code>BIO_seek()</code> returns the same value as the underlying <code>fseek()</code> function: 0 for success or -1 for failure.</p> <p><code>BIO_tell()</code> returns the current file position.</p> <p><code>BIO_read_filename()</code>, <code>BIO_write_filename()</code>, <code>BIO_append_filename()</code> and <code>BIO_rw_filename()</code> return 1 for success or 0 for failure.</p> <p> </p> <hr /> <h1><a name="examples">EXAMPLES</a></h1> <p>File BIO "hello world":</p> <pre> BIO *bio_out;</pre> <pre> bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); BIO_printf(bio_out, "Hello World\n");</pre> <p>Alternative technique:</p> <pre> BIO *bio_out;</pre> <pre> bio_out = BIO_new(BIO_s_file()); if (bio_out == NULL) /* Error */ if (!BIO_set_fp(bio_out, stdout, BIO_NOCLOSE)) /* Error */ BIO_printf(bio_out, "Hello World\n");</pre> <p>Write to a file:</p> <pre> BIO *out;</pre> <pre> out = BIO_new_file("filename.txt", "w"); if (!out) /* Error */ BIO_printf(out, "Hello World\n"); BIO_free(out);</pre> <p>Alternative technique:</p> <pre> BIO *out;</pre> <pre> out = BIO_new(BIO_s_file()); if (out == NULL) /* Error */ if (!BIO_write_filename(out, "filename.txt")) /* Error */ BIO_printf(out, "Hello World\n"); BIO_free(out);</pre> <p> </p> <hr /> <h1><a name="bugs">BUGS</a></h1> <p><code>BIO_reset()</code> and <code>BIO_seek()</code> are implemented using <code>fseek()</code> on the underlying stream. The return value for <code>fseek()</code> is 0 for success or -1 if an error occurred this differs from other types of BIO which will typically return 1 for success and a non positive value if an error occurred.</p> <p> </p> <hr /> <h1><a name="see_also">SEE ALSO</a></h1> <p><em>BIO_seek(3)</em>, <em>BIO_tell(3)</em>, <em>BIO_reset(3)</em>, <em>BIO_flush(3)</em>, <em>BIO_read_ex(3)</em>, <em>BIO_write_ex(3)</em>, <em>BIO_puts(3)</em>, <em>BIO_gets(3)</em>, <em>BIO_printf(3)</em>, <em>BIO_set_close(3)</em>, <em>BIO_get_close(3)</em></p> <p> </p> <hr /> <h1><a name="copyright">COPYRIGHT</a></h1> <p>Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.</p> <p>Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p> </body> </html>