.\" -*- coding: UTF-8 -*- '\" t .\" Copyright (c) 2001 John Levon .\" Based in part on GNU libc documentation .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH getline 3 "5 Febrero 2023" "Páginas de manual de Linux 6.03" .SH NOMBRE getline, getdelim \- entrada de cadena delimitada .SH BIBLIOTECA Biblioteca Estándar C (\fIlibc\fP, \fI\-lc\fP) .SH SINOPSIS .nf \fB#include \fP .PP \fBssize_t getline(char **restrict \fP\fIlineptr\fP\fB, size_t *restrict \fP\fIn\fP\fB,\fP \fB FILE *restrict \fP\fIstream\fP\fB);\fP \fBssize_t getdelim(char **restrict \fP\fIlineptr\fP\fB, size_t *restrict \fP\fIn\fP\fB,\fP \fB int \fP\fIdelim\fP\fB, FILE *restrict \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 \fBgetline\fP(), \fBgetdelim\fP(): .nf Desde glibc 2.10: _POSIX_C_SOURCE >= 200809L Antes de glibc 2.10: _GNU_SOURCE .fi .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 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 a failure, \fIerrno\fP is set to indicate the error. .PP If \fI*lineptr\fP was set to NULL before the call, then the buffer should be freed by the user program even on failure. .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). .ad l .nh .TS allbox; lbx lb lb l l l. Interfaz Atributo Valor T{ \fBgetline\fP(), \fBgetdelim\fP() T} Seguridad del hilo Multi\-hilo seguro .TE .hy .ad .sp 1 .SH ESTÁNDARES Both \fBgetline\fP() and \fBgetdelim\fP() were originally GNU extensions. They were standardized in POSIX.1\-2008. .SH EJEMPLOS .\" SRC BEGIN (getline.c) .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 .\" SRC END .SH "VÉASE TAMBIÉN" \fBread\fP(2), \fBfgets\fP(3), \fBfopen\fP(3), \fBfread\fP(3), \fBscanf\fP(3) .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 .