csomh / source-git / rpm

Forked from source-git/rpm 4 years ago
Clone
2ff057
#ifndef H_CPIO
2ff057
#define H_CPIO
2ff057
2ff057
/** \ingroup payload
2ff057
 * \file lib/cpio.h
2ff057
 *  Structures used to handle cpio payloads within rpm packages.
2ff057
 *
2ff057
 *  @warning Rpm's cpio implementation may be different than standard cpio.
2ff057
 *  The implementation is pretty close, but it has some behaviors which are
2ff057
 *  more to RPM's liking. I tried to document the differing behavior in cpio.c,
2ff057
 *  but I may have missed some (ewt).
2ff057
 *
2ff057
 */
2ff057
2ff057
typedef struct rpmcpio_s * rpmcpio_t;
2ff057
2ff057
#ifdef __cplusplus
2ff057
extern "C" {
2ff057
#endif
2ff057
2ff057
/**
2ff057
 * Create CPIO file object
2ff057
 * @param fd		file
2ff057
 * @param mode		XXX
2ff057
 * @return CPIO object
2ff057
 **/
2ff057
rpmcpio_t rpmcpioOpen(FD_t fd, char mode);
2ff057
2ff057
int rpmcpioClose(rpmcpio_t cpio);
2ff057
2ff057
off_t rpmcpioTell(rpmcpio_t cpio);
2ff057
2ff057
rpmcpio_t rpmcpioFree(rpmcpio_t cpio);
2ff057
2ff057
/**
2ff057
 * Write cpio header.
2ff057
 * @param cpio		cpio archive
2ff057
 * @param path		file name
2ff057
 * @param st		stat struct with meta data
2ff057
 * @return		0 on success
2ff057
 */
2ff057
RPM_GNUC_INTERNAL
2ff057
int rpmcpioHeaderWrite(rpmcpio_t cpio, char * path, struct stat * st);
2ff057
RPM_GNUC_INTERNAL
2ff057
int rpmcpioStrippedHeaderWrite(rpmcpio_t cpio, int fx, off_t fsize);
2ff057
2ff057
ssize_t rpmcpioWrite(rpmcpio_t cpio, const void * buf, size_t size);
2ff057
2ff057
/**
2ff057
 * Read cpio header. Iff fx is returned as -1 a cpio header was read
2ff057
 * and the file name is found in path. Otherwise a stripped header was read
2ff057
 * and the fx is the number of the file in the header/rpmfi. In this case
2ff057
 * rpmcpioSetExpectedFileSize() needs to be called with the file size of the
2ff057
 * payload content - with may be zero for hard links, directory or other
2ff057
 * special files.
2ff057
 * @retval fsm		file path and stat info
2ff057
 * @retval path		path of the file
2ff057
 * @retval fx		number in the header of the file read
2ff057
 * @return		0 on success
2ff057
 */
2ff057
RPM_GNUC_INTERNAL
2ff057
int rpmcpioHeaderRead(rpmcpio_t cpio, char ** path, int * fx);
2ff057
2ff057
/**
2ff057
 * Tell the cpio object the expected file size in the payload.
2ff057
 * The size must be zero for all but the last of hard linked files,
2ff057
 * directories and special files.
2ff057
 * This is needed after reading a stripped cpio header! See above.
2ff057
 */
2ff057
RPM_GNUC_INTERNAL
2ff057
void rpmcpioSetExpectedFileSize(rpmcpio_t cpio, off_t fsize);
2ff057
2ff057
ssize_t rpmcpioRead(rpmcpio_t cpio, void * buf, size_t size);
2ff057
2ff057
#ifdef __cplusplus
2ff057
}
2ff057
#endif
2ff057
2ff057
#endif	/* H_CPIO */