Author: jcrouse Date: 2008-05-20 22:09:42 +0200 (Tue, 20 May 2008) New Revision: 3337
Modified: trunk/payloads/libpayload/include/libpayload.h trunk/payloads/libpayload/libc/lar.c Log: libpayload: Add larfptr function
Add a function to get a pointer to the start of a LAR entry.
Signed-off-by: Jordan Crouse jordan.crouse@amd.com Acked-by: Myles Watson mylesgw@gmail.com
Modified: trunk/payloads/libpayload/include/libpayload.h =================================================================== --- trunk/payloads/libpayload/include/libpayload.h 2008-05-20 20:08:11 UTC (rev 3336) +++ trunk/payloads/libpayload/include/libpayload.h 2008-05-20 20:09:42 UTC (rev 3337) @@ -247,6 +247,7 @@ struct larent *readlar(struct LAR *lar); void rewindlar(struct LAR *lar); int larstat(struct LAR *lar, const char *path, struct larstat *buf); +void *larfptr(struct LAR *lar, const char *filename); struct LFILE * lfopen(struct LAR *lar, const char *filename); int lfread(void *ptr, size_t size, size_t nmemb, struct LFILE *stream);
Modified: trunk/payloads/libpayload/libc/lar.c =================================================================== --- trunk/payloads/libpayload/libc/lar.c 2008-05-20 20:08:11 UTC (rev 3336) +++ trunk/payloads/libpayload/libc/lar.c 2008-05-20 20:09:42 UTC (rev 3337) @@ -218,6 +218,16 @@ return 0; }
+void * larfptr(struct LAR *lar, const char *filename) +{ + struct lar_header *header = get_header_by_name(lar, filename); + + if (header == NULL) + return NULL; + + return (void *) ((u8 *) header + ntohl(header->offset)); +} + struct LFILE * lfopen(struct LAR *lar, const char *filename) { struct LFILE *file;