summaryrefslogtreecommitdiff
path: root/lib/rpmlead.h
blob: 768ea28f49779a623ce48e2a38ba8970e97d1258 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef _H_RPMLEAD
#define _H_RPMLEAD

/** \ingroup lead
 * \file lib/rpmlead.h
 * Routines to read and write an rpm lead structure for a a package.
 */
#ifdef __cplusplus
extern "C" {
#endif

#define RPMLEAD_BINARY 0
#define RPMLEAD_SOURCE 1

#define RPMLEAD_MAGIC0 0xed
#define RPMLEAD_MAGIC1 0xab
#define RPMLEAD_MAGIC2 0xee
#define RPMLEAD_MAGIC3 0xdb

#define RPMLEAD_SIZE 96         /*!< Don't rely on sizeof(struct) */

typedef struct rpmlead_s * rpmlead;


/** \ingroup lead
 * Initialize a lead structure
 * @return		Pointer to empty lead structure
 */
rpmlead rpmLeadNew(void);

/** \ingroup lead
 * Initialize a lead structure from header
 * param h		Header
 * @return		Pointer to populated lead structure (malloced)
 */
rpmlead rpmLeadFromHeader(Header h);

/** \ingroup lead
 * Free a lead structure
 * @param lead		Pointer to lead structure
 * @return		NULL always
 */
rpmlead rpmLeadFree(rpmlead lead);

/** \ingroup lead
 * Write lead to file handle.
 * @param fd		file handle
 * @param lead		package lead
 * @return		RPMRC_OK on success, RPMRC_FAIL on error
 */
rpmRC rpmLeadWrite(FD_t fd, rpmlead lead);

/** \ingroup lead
 * Read lead from file handle.
 * @param fd		file handle
 * @retval lead		package lead
 * @return		RPMRC_OK on success, RPMRC_FAIL/RPMRC_NOTFOUND on error
 */
rpmRC rpmLeadRead(FD_t fd, rpmlead lead);

/** \ingroup lead
 * Check lead for compatibility.
 * @param lead		Pointer to lead handle
 * @retval fn		Pointer to error message, NULL on success
 * @return		RPMRC_OK on success, 
 * 			RPMRC_NOTFOUND if not an rpm,
 * 			RPMRC_FAIL on invalid/incompatible rpm
 */
rpmRC rpmLeadCheck(rpmlead lead, const char **msg);

/** \ingroup lead
 * Returen type (source vs binary) of lead
 * @param lead		Pointer to lead handle
 * @return		RPMLEAD_BINARY or RPMLEAD_SOURCE, -1 on invalid
 */
int rpmLeadType(rpmlead lead);

#ifdef __cplusplus
}
#endif

#endif	/* _H_RPMLEAD */