1*5ac3bc71Schristos.\" $NetBSD: elf_next.3,v 1.6 2024/03/03 17:37:33 christos Exp $ 2e81373b4Schristos.\" 39dd9d0cfSchristos.\" Copyright (c) 2006,2008 Joseph Koshy. All rights reserved. 49dd9d0cfSchristos.\" 59dd9d0cfSchristos.\" Redistribution and use in source and binary forms, with or without 69dd9d0cfSchristos.\" modification, are permitted provided that the following conditions 79dd9d0cfSchristos.\" are met: 89dd9d0cfSchristos.\" 1. Redistributions of source code must retain the above copyright 99dd9d0cfSchristos.\" notice, this list of conditions and the following disclaimer. 109dd9d0cfSchristos.\" 2. Redistributions in binary form must reproduce the above copyright 119dd9d0cfSchristos.\" notice, this list of conditions and the following disclaimer in the 129dd9d0cfSchristos.\" documentation and/or other materials provided with the distribution. 139dd9d0cfSchristos.\" 149dd9d0cfSchristos.\" This software is provided by Joseph Koshy ``as is'' and 159dd9d0cfSchristos.\" any express or implied warranties, including, but not limited to, the 169dd9d0cfSchristos.\" implied warranties of merchantability and fitness for a particular purpose 179dd9d0cfSchristos.\" are disclaimed. in no event shall Joseph Koshy be liable 189dd9d0cfSchristos.\" for any direct, indirect, incidental, special, exemplary, or consequential 199dd9d0cfSchristos.\" damages (including, but not limited to, procurement of substitute goods 209dd9d0cfSchristos.\" or services; loss of use, data, or profits; or business interruption) 219dd9d0cfSchristos.\" however caused and on any theory of liability, whether in contract, strict 229dd9d0cfSchristos.\" liability, or tort (including negligence or otherwise) arising in any way 239dd9d0cfSchristos.\" out of the use of this software, even if advised of the possibility of 249dd9d0cfSchristos.\" such damage. 259dd9d0cfSchristos.\" 263f622274Sjkoshy.\" Id: elf_next.3 3957 2022-03-12 14:11:52Z jkoshy 279dd9d0cfSchristos.\" 28c5261b83Sjkoshy.Dd February 27, 2019 299dd9d0cfSchristos.Dt ELF_NEXT 3 30c5261b83Sjkoshy.Os 319dd9d0cfSchristos.Sh NAME 329dd9d0cfSchristos.Nm elf_next 339dd9d0cfSchristos.Nd provide sequential access to the next archive member 349dd9d0cfSchristos.Sh LIBRARY 359dd9d0cfSchristos.Lb libelf 369dd9d0cfSchristos.Sh SYNOPSIS 379dd9d0cfSchristos.In libelf.h 389dd9d0cfSchristos.Ft Elf_Cmd 399dd9d0cfSchristos.Fn elf_next "Elf *elf" 409dd9d0cfSchristos.Sh DESCRIPTION 419dd9d0cfSchristosThe 429dd9d0cfSchristos.Fn elf_next 439dd9d0cfSchristosfunction causes the ELF archive descriptor corresponding to argument 443f622274Sjkoshy.Fa elf 459dd9d0cfSchristosto be adjusted to provide access to the next member in 469dd9d0cfSchristosthe archive on a subsequent call to 479dd9d0cfSchristos.Fn elf_begin . 489dd9d0cfSchristos.Pp 499dd9d0cfSchristosThe return value of 509dd9d0cfSchristos.Fn elf_next 519dd9d0cfSchristosis suitable for use in a loop invoking 529dd9d0cfSchristos.Fn elf_begin . 539dd9d0cfSchristos.Sh RETURN VALUES 549dd9d0cfSchristosIf successful, function 559dd9d0cfSchristos.Fn elf_next 569dd9d0cfSchristosreturns the value 579dd9d0cfSchristos.Dv ELF_C_READ . 589dd9d0cfSchristosOtherwise, if argument 593f622274Sjkoshy.Fa elf 609dd9d0cfSchristoswas not associated with an archive, or if it was 619dd9d0cfSchristos.Dv NULL , 629dd9d0cfSchristosor if any other error occurred, the value 639dd9d0cfSchristos.Dv ELF_C_NULL 649dd9d0cfSchristosis returned. 659dd9d0cfSchristos.Sh EXAMPLES 669dd9d0cfSchristosTo process all the members of an archive use: 679dd9d0cfSchristos.Bd -literal -offset indent 689dd9d0cfSchristosElf_Cmd cmd; 699dd9d0cfSchristosElf *archive, *e; 709dd9d0cfSchristos\&... 719dd9d0cfSchristoscmd = ELF_C_READ; 729dd9d0cfSchristosarchive = elf_begin(fd, cmd, NULL); 739dd9d0cfSchristoswhile ((e = elf_begin(fd, cmd, archive)) != (Elf *) 0) 749dd9d0cfSchristos{ 759dd9d0cfSchristos ... process `e' here ... 769dd9d0cfSchristos 779dd9d0cfSchristos cmd = elf_next(e); 789dd9d0cfSchristos elf_end(e); 799dd9d0cfSchristos} 809dd9d0cfSchristoself_end(archive); 819dd9d0cfSchristos.Ed 829dd9d0cfSchristos.Sh ERRORS 839dd9d0cfSchristosFunction 849dd9d0cfSchristos.Fn elf_next 859dd9d0cfSchristosmay fail with the following error: 869dd9d0cfSchristos.Bl -tag -width "[ELF_E_RESOURCE]" 879dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT 889dd9d0cfSchristosArgument 893f622274Sjkoshy.Fa elf 909dd9d0cfSchristoswas not associated with a containing 919dd9d0cfSchristos.Xr ar 1 929dd9d0cfSchristosarchive. 93c5261b83Sjkoshy.It Bq Er ELF_E_ARGUMENT 94c5261b83SjkoshyAn error was encountered while parsing the archive containing argument 953f622274Sjkoshy.Fa elf . 969dd9d0cfSchristos.El 979dd9d0cfSchristos.Sh SEE ALSO 989dd9d0cfSchristos.Xr elf 3 , 999dd9d0cfSchristos.Xr elf_begin 3 , 1009dd9d0cfSchristos.Xr elf_end 3 , 1019dd9d0cfSchristos.Xr elf_rand 3 102