.\" -*- coding: UTF-8 -*- .\" Copyright (c) 2001 John Levon .\" Based in part on GNU libc documentation .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH GETLINE 3 "1 Noviembre 2020" GNU "Manual del Programador de Linux" .SH NOMBRE getline, getdelim \- entrada de cadena delimitada .SH SINOPSIS .nf \fB#include \fP .PP \fBssize_t getline(char **\fP\fIlineptr\fP\fB, size_t *\fP\fIn\fP\fB, FILE *\fP\fIstream\fP\fB);\fP .PP \fBssize_t getdelim(char **\fP\fIlineptr\fP\fB, size_t *\fP\fIn\fP\fB, int \fP\fIdelim\fP\fB, FILE *\fP\fIstream\fP\fB);\fP .fi .PP .RS -4 Requisitos de Macros de Prueba de Características para glibc (véase \fBfeature_test_macros\fP(7)): .RE .PP .ad l \fBgetline\fP(), \fBgetdelim\fP(): .PD 0 .RS 4 .TP 4 Desde glibc 2.10: _POSIX_C_SOURCE\ >=\ 200809L .TP Antes de glibc 2.10: _GNU_SOURCE .RE .PD .ad .SH DESCRIPCIÓN \fBgetline\fP() reads an entire line from \fIstream\fP, storing the address of the buffer containing the text into \fI*lineptr\fP. The buffer is null\-terminated and includes the newline character, if one was found. .PP If \fI*lineptr\fP is set to NULL and \fI*n\fP is set 0 before the call, then \fBgetline\fP() will allocate a buffer for storing the line. This buffer should be freed by the user program even if \fBgetline\fP() failed. .PP Alternatively, before calling \fBgetline\fP(), \fI*lineptr\fP can contain a pointer to a \fBmalloc\fP(3)\-allocated buffer \fI*n\fP bytes in size. If the buffer is not large enough to hold the line, \fBgetline\fP() resizes it with \fBrealloc\fP(3), updating \fI*lineptr\fP and \fI*n\fP as necessary. .PP In either case, on a successful call, \fI*lineptr\fP and \fI*n\fP will be updated to reflect the buffer address and allocated size respectively. .PP \fBgetdelim\fP() funciona como \fBgetline\fP(), salvo que se puede especificar otro delimitador de línea distinto de nueva línea en el argumento \fIdelimiter\fP. Como con \fBgetline\fP(), no se añade un carácter delimitador si no hay ninguno presente en la entrada antes de que se alcanze el fin del fichero. .SH "VALOR DEVUELTO" On success, \fBgetline\fP() and \fBgetdelim\fP() return the number of characters read, including the delimiter character, but not including the terminating null byte (\(aq\e0\(aq). This value can be used to handle embedded null bytes in the line read. .PP Both functions return \-1 on failure to read a line (including end\-of\-file condition). In the event of an error, \fIerrno\fP is set to indicate the cause. .SH ERRORES .TP \fBEINVAL\fP Parámetros incorrectos (\fIn\fP o \fIlineptr\fP son NULL, o \fIstream\fP no es válido). .TP \fBENOMEM\fP Allocation or reallocation of the line buffer failed. .SH ATRIBUTOS Para obtener una explicación de los términos usados en esta sección, véase \fBattributes\fP(7). .TS allbox; lbw21 lb lb l l l. Interfaz Atributo Valor T{ \fBgetline\fP(), \fBgetdelim\fP() T} Seguridad del hilo Multi\-hilo seguro .TE .sp 1 .SH "CONFORME A" Both \fBgetline\fP() and \fBgetdelim\fP() were originally GNU extensions. They were standardized in POSIX.1\-2008. .SH EJEMPLOS .EX #define _GNU_SOURCE #include #include int main(int argc, char *argv[]) { FILE *stream; char *line = NULL; size_t len = 0; ssize_t nread; if (argc != 2) { fprintf(stderr, "Usage: %s \en", argv[0]); exit(EXIT_FAILURE); } stream = fopen(argv[1], "r"); if (stream == NULL) { perror("fopen"); exit(EXIT_FAILURE); } while ((nread = getline(&line, &len, stream)) != \-1) { printf("Retrieved line of length %zd:\en", nread); fwrite(line, nread, 1, stdout); } free(line); fclose(stream); exit(EXIT_SUCCESS); } .EE .SH "VÉASE TAMBIÉN" \fBread\fP(2), \fBfgets\fP(3), \fBfopen\fP(3), \fBfread\fP(3), \fBscanf\fP(3) .SH COLOFÓN Esta página es parte de la versión 5.10 del proyecto Linux \fIman\-pages\fP. Puede encontrar una descripción del proyecto, información sobre cómo informar errores y la última versión de esta página en \%https://www.kernel.org/doc/man\-pages/. .PP .SH TRADUCCIÓN La traducción al español de esta página del manual fue creada por Miguel Pérez Ibars y Marcos Fouces . .PP Esta traducción es documentación libre; lea la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. .PP Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a .MT debian-l10n-spanish@lists.debian.org .ME .