<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1.2//EN"
  "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">


<refentry id="gfs-pio-gets.3">

<refentryinfo><date>13 May 2004</date></refentryinfo>

<refmeta>
<refentrytitle>gfs_pio_gets</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>Gfarm</refmiscinfo>
</refmeta>

<refnamediv id="name">
<refname>gfs_pio_gets</refname>
<refpurpose>read one line</refpurpose>
</refnamediv>
<refsynopsisdiv id="synopsis">
<funcsynopsis>
<funcsynopsisinfo format="linespecific">
#include &lt;gfarm/gfarm.h&gt;
</funcsynopsisinfo>

<funcprototype>
  <funcdef><function moreinfo="none"><returnvalue>char *</returnvalue>gfs_pio_gets</function></funcdef>
    <paramdef>GFS_File <parameter moreinfo="none">f</parameter></paramdef>
    <paramdef>char * <parameter moreinfo="none">s</parameter></paramdef>
    <paramdef>size_t <parameter moreinfo="none">size</parameter></paramdef>
</funcprototype>


</funcsynopsis>
</refsynopsisdiv>

<!-- body begins here -->

<refsect1 id="description"><title>DESCRIPTION</title>
<para><function moreinfo="none">gfs_pio_gets()</function> reads one line from
the file specified by the parameter
<parameter moreinfo="none">gf</parameter>
to the buffer specified by the parameter
<parameter moreinfo="none">s</parameter>.
You need to specify the size of the buffer by the parameter
<parameter moreinfo="none">size</parameter>.
</para>

<para>
Unlike gfs_pio_getline(3), this function doesn't remove newline
character at the end of the buffer. But if whole contents of the 
line cannot be stored to the buffer due to its length, or if the
file reaches the end without newline, there will be no newline
at the end of the buffer. In any case, one '\0' character is
appended to the end of the buffer.
</para>

<para>
If the file reaches its end, the length of the string in the buffer
becomes 0.
</para>

</refsect1>

<refsect1 id="return-values"><title>RETURN VALUES</title>
<variablelist>
<varlistentry>
<term><constant>NULL</constant></term>
<listitem>
<para>The function terminated successfully.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>GFARM_ERR_NO_MEMORY</constant></term>
<listitem>
<para>Insufficient memory was available.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Others</term>
<listitem>
<para>An error except the above occurred.  The reason is shown by its
pointed strings.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 id="examples"><title>EXAMPLES</title>

<example role="example">
<title>Example of <function moreinfo="none">gfs_pio_gets</function> function</title>
<para><programlisting format="linespecific">
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;gfarm/gfarm.h&gt;

int
main(int argc, char **argv)
{
	char *e;
	GFS_File gf;
	char buffer[512];

	e = gfarm_initialize(&amp;argc, &amp;argv);
	if (e != NULL) {
		fprintf(stderr, "gfarm_initialize: %s\n", e);
		return (EXIT_FAILURE);
	}
	if (argc &lt;= 1) {
		fprintf(stderr, "missing gfarm filename\n");
		return (EXIT_FAILURE);
	}
	e = gfs_pio_open(argv[1], GFARM_FILE_RDONLY, &amp;gf);
	if (e != NULL) {
		fprintf(stderr, "%s: %s\n", argv[1], e);
		return (EXIT_FAILURE);
	}
	e = gfs_pio_set_view_global(gf, 0);
	if (e != NULL) {
		fprintf(stderr, "%s: gfs_pio_set_view_global: %s\n",
		    argv[1], e);
		return (EXIT_FAILURE);
	}

	while ((e = gfs_pio_gets(gf, buffer, sizeof buffer)) != NULL &amp;&amp;
	    *buffer != '\0') {
		printf("got: %s", buffer);
	}
	if (e != NULL) {
		fprintf(stderr, "ERROR: %s\n", e);
		return (EXIT_FAILURE);
	}
	e = gfs_pio_close(gf);
	if (e != NULL) {
		fprintf(stderr, "gfs_pio_close: %s\n", e);
		return (EXIT_FAILURE);
	}
	e = gfarm_terminate();
	if (e != NULL) {
		fprintf(stderr, "gfarm_initialize: %s\n", e);
		return (EXIT_FAILURE);
	}
	return (EXIT_SUCCESS);
}
</programlisting></para>
</example>

</refsect1>


<refsect1 id="see-also"><title>SEE ALSO</title>
<para>
<citerefentry><refentrytitle>gfs_pio_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>gfs_pio_getline</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>gfs_pio_readline</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>gfs_pio_readdelim</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>
