rpm  5.4.15
rpmiotypes.h
Go to the documentation of this file.
1 #ifndef _H_RPMIOTYPES_
2 #define _H_RPMIOTYPES_
3 
4 #include <stdlib.h> /* XXX NULL typedef */
5 #include <sys/types.h> /* XXX size_t typedef */
6 
14 typedef enum rpmRC_e {
15  RPMRC_OK = 0,
17  RPMRC_FAIL = 2,
21 } rpmRC;
22 
26 typedef /*@unsignedintegraltype@*/ unsigned char rpmuint8_t;
27 typedef /*@unsignedintegraltype@*/ unsigned short rpmuint16_t;
28 typedef /*@unsignedintegraltype@*/ unsigned int rpmuint32_t;
29 typedef /*@unsignedintegraltype@*/ unsigned long long rpmuint64_t;
30 
33 typedef /*@signedintegraltype@*/ int rpmint32_t;
34 
37 typedef struct yarnLock_s * yarnLock;
38 
41 typedef /*@refcounted@*/ struct rpmioItem_s * rpmioItem;
42 struct rpmioItem_s {
43 /*@null@*/
44  yarnLock use;
45 /*@kept@*/ /*@null@*/
46  void *pool;
47  void *next;
48 #if defined(__LCLINT__)
49 /*@refs@*/
50  int nrefs;
51 #endif
52 };
53 
56 typedef struct rpmioPool_s * rpmioPool;
57 
60 typedef /*@abstract@*/ /*@refcounted@*/ struct rpmiob_s * rpmiob;
61 
64 /*@unchecked@*/
65 extern size_t _rpmiob_chunk;
66 
69 typedef struct rpmioP_s {
70  char * str;
71  char * next;
72  const char ** av;
73  int ac;
74 } * rpmioP;
75 
76 #if defined(_RPMIOB_INTERNAL)
77 
79 struct rpmiob_s {
80  struct rpmioItem_s _item;
81  rpmuint8_t * b;
82  size_t blen;
83  size_t allocated;
84 #if defined(__LCLINT__)
85 /*@refs@*/
86  int nrefs;
87 #endif
88 };
89 #endif
90 
93 typedef /*@abstract@*/ struct pgpPkt_s * pgpPkt;
94 
97 typedef /*@abstract@*/ /*@refcounted@*/ struct pgpDig_s * pgpDig;
98 
101 typedef /*@abstract@*/ struct pgpDigParams_s * pgpDigParams;
102 
106 
110 
114 typedef enum pgpVSFlags_e {
116  RPMVSF_NOHDRCHK = (1 << 0),
117  RPMVSF_NEEDPAYLOAD = (1 << 1),
118  /* bit(s) 2-7 unused */
120  RPMVSF_NOMD5HEADER = (1 << 9), /* unimplemented */
121  RPMVSF_NODSAHEADER = (1 << 10),
122  RPMVSF_NORSAHEADER = (1 << 11),
124  /* bit(s) 13-15 unused */
125  RPMVSF_NOSHA1 = (1 << 16), /* unimplemented */
126  RPMVSF_NOMD5 = (1 << 17),
127  RPMVSF_NODSA = (1 << 18),
128  RPMVSF_NORSA = (1 << 19),
129  RPMVSF_NOECDSA = (1 << 20)
130  /* bit(s) 21-31 unused */
131 } pgpVSFlags;
132 
133 /*@-redef@*/ /* LCL: ??? */
134 typedef /*@abstract@*/ const void * fnpyKey;
135 /*@=redef@*/
136 
140 typedef enum rpmCallbackType_e {
159 
162 typedef void * rpmCallbackData;
163 
166 typedef /*@abstract@*/ struct CIPHER_CTX_s * CIPHER_CTX;
167 
193 /*@-typeuse@*/
194 typedef enum pgpSymkeyAlgo_e {
211 } pgpSymkeyAlgo;
212 /*@=typeuse@*/
213 
217 typedef enum rpmCryptFlags_e {
222 
223 #ifdef __cplusplus
224 extern "C" {
225 #endif
226 
227 void * _cphParam(/*@null@*/ CIPHER_CTX cph);
228 
236 /*@only@*/ /*@null@*/
237 CIPHER_CTX rpmCipherInit(pgpSymkeyAlgo symkeyalgo, rpmCipherFlags flags)
238  /*@*/;
239 
247 int rpmCipherNext(/*@null@*/ CIPHER_CTX cph, void * data, size_t len)
248  /*@modifies ctx @*/;
249 
255 int rpmCipherFinal(/*@only@*/ /*@null@*/ CIPHER_CTX cph)
256  /*@*/;
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 
264 typedef /*@abstract@*/ struct DIGEST_CTX_s * DIGEST_CTX;
265 
286 typedef enum pgpHashAlgo_e {
422 } pgpHashAlgo;
423 
427 typedef enum rpmDigestFlags_e {
430 
431 #ifdef __cplusplus
432 extern "C" {
433 #endif
434 
440 pgpHashAlgo rpmDigestAlgo(DIGEST_CTX ctx)
441  /*@*/;
442 
448 rpmDigestFlags rpmDigestF(DIGEST_CTX ctx)
449  /*@*/;
450 
456 /*@observer@*/
457 const char * rpmDigestName(DIGEST_CTX ctx)
458  /*@*/;
459 
466 /*@observer@*/ /*@null@*/
467 const char * rpmDigestASN1(DIGEST_CTX ctx)
468  /*@*/;
469 
475 /*@only@*/
476 DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
477  /*@*/;
478 
486 /*@only@*/ /*@null@*/
488  /*@*/;
489 
497 int rpmDigestUpdate(/*@null@*/ DIGEST_CTX ctx, const void * data, size_t len)
498  /*@modifies ctx @*/;
499 
509 int rpmDigestFinal(/*@only@*/ /*@null@*/ DIGEST_CTX ctx,
510  /*@null@*/ /*@out@*/ void * datap,
511  /*@null@*/ /*@out@*/ size_t * lenp, int asAscii)
512  /*@modifies *datap, *lenp @*/;
513 
522 int rpmHmacInit(DIGEST_CTX ctx, const void * key, size_t keylen)
523  /*@*/;
524 
527 typedef void * (*rpmCallbackFunction)
528  (/*@null@*/ const void * h,
529  const rpmCallbackType what,
530  const rpmuint64_t amount,
531  const rpmuint64_t total,
532  /*@null@*/ fnpyKey key,
533  /*@null@*/ rpmCallbackData data)
534  /*@globals internalState@*/
535  /*@modifies internalState@*/;
536 
537 /*@unused@*/ static inline int xislower(int c) /*@*/ {
538  return (c >= (int)'a' && c <= (int)'z');
539 }
540 /*@unused@*/ static inline int xisupper(int c) /*@*/ {
541  return (c >= (int)'A' && c <= (int)'Z');
542 }
543 /*@unused@*/ static inline int xisalpha(int c) /*@*/ {
544  return (xislower(c) || xisupper(c));
545 }
546 /*@unused@*/ static inline int xisdigit(int c) /*@*/ {
547  return (c >= (int)'0' && c <= (int)'9');
548 }
549 /*@unused@*/ static inline int xisalnum(int c) /*@*/ {
550  return (xisalpha(c) || xisdigit(c));
551 }
552 /*@unused@*/ static inline int xisblank(int c) /*@*/ {
553  return (c == (int)' ' || c == (int)'\t');
554 }
555 /*@unused@*/ static inline int xisspace(int c) /*@*/ {
556  return (xisblank(c) || c == (int)'\n' || c == (int)'\r' || c == (int)'\f' || c == (int)'\v');
557 }
558 /*@unused@*/ static inline int xiscntrl(int c) /*@*/ {
559  return (c < (int)' ');
560 }
561 /*@unused@*/ static inline int xisascii(int c) /*@*/ {
562  return ((c & 0x80) != 0x80);
563 }
564 /*@unused@*/ static inline int xisprint(int c) /*@*/ {
565  return (c >= (int)' ' && xisascii(c));
566 }
567 /*@unused@*/ static inline int xisgraph(int c) /*@*/ {
568  return (c > (int)' ' && xisascii(c));
569 }
570 /*@unused@*/ static inline int xispunct(int c) /*@*/ {
571  return (xisgraph(c) && !xisalnum(c));
572 }
573 
574 /*@unused@*/ static inline int xtolower(int c) /*@*/ {
575  return ((xisupper(c)) ? (c | ('a' - 'A')) : c);
576 }
577 /*@unused@*/ static inline int xtoupper(int c) /*@*/ {
578  return ((xislower(c)) ? (c & ~('a' - 'A')) : c);
579 }
580 
584 int xstrcasecmp(const char * s1, const char * s2) /*@*/;
585 
589 int xstrncasecmp(const char *s1, const char * s2, size_t n) /*@*/;
590 
594 /*@only@*/ /*@null@*/
595 const char * xstrtolocale(/*@only@*/ const char *str)
596  /*@modifies *str @*/;
597 
603 /*@unused@*/ /*@null@*/
604 rpmiob rpmiobUnlink (/*@killref@*/ /*@null@*/ rpmiob iob)
605  /*@globals fileSystem @*/
606  /*@modifies iob, fileSystem @*/;
607 #define rpmiobUnlink(_iob) \
608  ((rpmiob)rpmioUnlinkPoolItem((rpmioItem)(_iob), __FUNCTION__, __FILE__, __LINE__))
609 
615 /*@unused@*/ /*@newref@*/ /*@null@*/
616 rpmiob rpmiobLink (/*@null@*/ rpmiob iob)
617  /*@globals fileSystem @*/
618  /*@modifies iob, fileSystem @*/;
619 #define rpmiobLink(_iob) \
620  ((rpmiob)rpmioLinkPoolItem((rpmioItem)(_iob), __FUNCTION__, __FILE__, __LINE__))
621 
627 /*@null@*/
628 rpmiob rpmiobFree( /*@killref@*/ rpmiob iob)
629  /*@globals fileSystem @*/
630  /*@modifies iob, fileSystem @*/;
631 #define rpmiobFree(_iob) \
632  ((rpmiob)rpmioFreePoolItem((rpmioItem)(_iob), __FUNCTION__, __FILE__, __LINE__))
633 
639 /*@newref@*/ /*@null@*/
640 rpmiob rpmiobNew(size_t len)
641  /*@globals fileSystem @*/
642  /*@modifies fileSystem @*/;
643 
649 rpmiob rpmiobEmpty(/*@returned@*/ rpmiob iob)
650  /*@modifies iob @*/;
651 
657 rpmiob rpmiobRTrim(/*@returned@*/ rpmiob iob)
658  /*@modifies iob @*/;
659 
667 rpmiob rpmiobAppend(/*@returned@*/ rpmiob iob, const char * s, size_t nl)
668  /*@modifies iob @*/;
669 
676  /*@*/;
677 
683 char * rpmiobStr(rpmiob iob)
684  /*@*/;
685 
691 size_t rpmiobLen(rpmiob iob)
692  /*@*/;
693 
694 #if defined(_RPMIOB_INTERNAL)
695 
701 int rpmiobSlurp(const char * fn, rpmiob * iobp)
702  /*@globals h_errno, fileSystem, internalState @*/
703  /*@modifies *iobp, fileSystem, internalState @*/;
704 #endif
705 
711 /*@null@*/
712 rpmioP rpmioPFree(/*@only@*/ /*@null@*/ rpmioP P)
713  /*@modifies P @*/;
714 
721 rpmRC rpmioParse(rpmioP *Pptr, const char * str)
722  /*@modifies *Pptr @*/;
723 
724 #ifdef __cplusplus
725 }
726 #endif
727 
728 #if !defined(SWIG)
729 
734 #if defined(WITH_DMALLOC)
735 #define _free(p) ((p) != NULL ? free((void *)(p)) : (void)0, NULL)
736 #else
737 
738 #ifdef __cplusplus
739 
740 #define GENfree(_t) \
741  static inline _t _free(_t p) { if (p) free((void *)p); return (_t)NULL; }
742 #define GENpair(_t) \
743  GENfree(const _t) \
744  GENfree( _t)
745 
746 GENpair(void *)
747 GENpair(char *)
748 GENpair(char **)
749 GENpair(unsigned char *)
750 GENfree(DIGEST_CTX)
751 GENfree(DIGEST_CTX *)
752 
753 #else /* __cplusplus */
754 
755 /*@unused@*/ static inline /*@null@*/
756 void * _free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
757  /*@modifies p @*/
758 {
759  if (p != NULL) free((void *)p);
760  return NULL;
761 }
762 #endif /* __cplusplus */
763 
764 #endif /* defined(WITH_DMALLOC) */
765 #endif /* !defined(SWIG) */
766 
767 #endif /* _H_RPMIOTYPES_ */
const bson * b
Definition: bson.h:280
static int xislower(int c)
Definition: rpmiotypes.h:537
const char ** av
Definition: rpmiotypes.h:72
rpmRC_e
RPM return codes.
Definition: rpmiotypes.h:14
rpmiob rpmiobAppend(rpmiob iob, const char *s, size_t nl)
Append string to I/O buffer.
Definition: rpmiob.c:77
pgpSymkeyAlgo_e
9.2.
Definition: rpmiotypes.h:194
const char const char size_t len
Definition: bson.h:823
void * _cphParam(CIPHER_CTX cph)
const char * xstrtolocale(const char *str)
Force encoding of string.
Definition: strtolocale.c:15
struct rpmioP_s * rpmioP
static int xtoupper(int c)
Definition: rpmiotypes.h:577
void * next
Definition: rpmiotypes.h:47
rpmuint8_t * rpmiobBuf(rpmiob iob)
Return I/O buffer.
Definition: rpmiob.c:102
static int xisalnum(int c)
Definition: rpmiotypes.h:549
yarnLock use
Definition: rpmiotypes.h:44
struct pgpDigParams_s * pgpDigParams
Definition: rpmiotypes.h:101
size_t _rpmiob_chunk
Definition: rpmiob.c:11
int rpmCipherFinal(CIPHER_CTX cph)
Destroy cipher context.
int xstrncasecmp(const char *s1, const char *s2, size_t n)
Locale insensitive strncasecmp(3).
Definition: strcasecmp.c:30
enum pgpHashAlgo_e pgpHashAlgo
9.4.
int rpmDigestUpdate(DIGEST_CTX ctx, const void *data, size_t len)
Update context with next plain text buffer.
Definition: digest.c:986
rpmDigestFlags rpmDigestF(DIGEST_CTX ctx)
Return digest flags.
Definition: digest.c:196
enum rpmCallbackType_e rpmCallbackType
Bit(s) to identify progress callbacks.
static int xisascii(int c)
Definition: rpmiotypes.h:561
unsigned short rpmuint16_t
Definition: rpmiotypes.h:27
pgpVSFlags_e
Bit(s) to control digest and signature verification.
Definition: rpmiotypes.h:114
rpmCallbackType_e
Bit(s) to identify progress callbacks.
Definition: rpmiotypes.h:140
void * pool
Definition: rpmiotypes.h:46
static int xisalpha(int c)
Definition: rpmiotypes.h:543
enum rpmDigestFlags_e rpmDigestFlags
Bit(s) to control digest operation.
struct CIPHER_CTX_s * CIPHER_CTX
Definition: rpmiotypes.h:166
const char * rpmDigestName(DIGEST_CTX ctx)
Return digest name.
Definition: digest.c:201
CIPHER_CTX rpmCipherInit(pgpSymkeyAlgo symkeyalgo, rpmCipherFlags flags)
Initialize cipher context.
int rpmiobSlurp(const char *fn, rpmiob *iobp)
Definition: rpmiob.c:129
static int xisgraph(int c)
Definition: rpmiotypes.h:567
int rpmDigestFinal(DIGEST_CTX ctx, void *datap, size_t *lenp, int asAscii)
Return digest and destroy context.
Definition: digest.c:1000
rpmioP rpmioPFree(rpmioP P)
Destroy a rpmioP object.
Definition: poptIO.c:956
static int xtolower(int c)
Definition: rpmiotypes.h:574
rpmCryptFlags_e
Bit(s) to control cipher operation.
Definition: rpmiotypes.h:217
const char * str
Definition: bson.h:593
static int xisprint(int c)
Definition: rpmiotypes.h:564
unsigned int rpmuint32_t
Definition: rpmiotypes.h:28
#define rpmiobLink(_iob)
Definition: rpmiotypes.h:619
unsigned char rpmuint8_t
Private int typedefs to avoid C99 portability issues.
Definition: rpmiotypes.h:26
struct rpmioPool_s * rpmioPool
Definition: rpmiotypes.h:56
const char const bson * data
Definition: mongo.h:463
static int xisspace(int c)
Definition: rpmiotypes.h:555
unsigned long long rpmuint64_t
Definition: rpmiotypes.h:29
enum rpmCryptFlags_e rpmCipherFlags
Bit(s) to control cipher operation.
enum pgpVSFlags_e pgpVSFlags
Bit(s) to control digest and signature verification.
struct pgpPkt_s * pgpPkt
Definition: rpmiotypes.h:93
char * str
Definition: rpmiotypes.h:70
Digest private data.
Definition: digest.c:130
static int xisupper(int c)
Definition: rpmiotypes.h:540
pgpHashAlgo hashalgo
Definition: digest.c:143
char * rpmiobStr(rpmiob iob)
Return I/O buffer (as string).
Definition: rpmiob.c:112
struct pgpDig_s * pgpDig
Definition: rpmiotypes.h:97
char * next
Definition: rpmiotypes.h:71
int xstrcasecmp(const char *s1, const char *s2)
Locale insensitive strcasecmp(3).
Definition: strcasecmp.c:9
static int xiscntrl(int c)
Definition: rpmiotypes.h:558
#define rpmiobFree(_iob)
Definition: rpmiotypes.h:631
#define rpmiobUnlink(_iob)
Definition: rpmiotypes.h:607
const char * rpmDigestASN1(DIGEST_CTX ctx)
Return digest ASN1 oid string.
Definition: digest.c:206
const char const bson int mongo_write_concern int flags
Definition: mongo.h:485
enum pgpSymkeyAlgo_e pgpSymkeyAlgo
9.2.
rpmRC rpmioParse(rpmioP *Pptr, const char *str)
Parse next command out of a string incrementally.
Definition: poptIO.c:966
void * rpmCallbackData
Definition: rpmiotypes.h:162
pgpHashAlgo rpmDigestAlgo(DIGEST_CTX ctx)
Return digest algorithm identifier.
Definition: digest.c:191
enum rpmRC_e rpmRC
RPM return codes.
int rpmint32_t
Definition: rpmiotypes.h:33
DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
Duplicate a digest context.
Definition: digest.c:212
static int xisdigit(int c)
Definition: rpmiotypes.h:546
const char const bson * key
Definition: mongo.h:717
DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
Initialize digest context.
Definition: digest.c:247
struct rpmioItem_s * rpmioItem
Definition: rpmiotypes.h:41
rpmiob rpmiobEmpty(rpmiob iob)
Empty an I/O buffer.
Definition: rpmiob.c:57
struct DIGEST_CTX_s * DIGEST_CTX
Definition: rpmiotypes.h:264
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
Definition: rpmiotypes.h:756
struct rpmiob_s * rpmiob
Definition: rpmiotypes.h:60
const void * fnpyKey
Definition: rpmiotypes.h:134
rpmDigestFlags_e
Bit(s) to control digest operation.
Definition: rpmiotypes.h:427
rpmiob rpmiobRTrim(rpmiob iob)
Trim trailing white space.
Definition: rpmiob.c:67
pgpHashAlgo_e
9.4.
Definition: rpmiotypes.h:286
static int xisblank(int c)
Definition: rpmiotypes.h:552
struct yarnLock_s * yarnLock
Definition: rpmiotypes.h:37
rpmuint8_t pgpTime_t[4]
Definition: rpmiotypes.h:109
int rpmHmacInit(DIGEST_CTX ctx, const void *key, size_t keylen)
Compute key material and add to digest context.
Definition: digest.c:1062
rpmiob rpmiobNew(size_t len)
Create an I/O buffer.
Definition: rpmiob.c:44
rpmuint8_t pgpKeyID_t[8]
Definition: rpmiotypes.h:105
int rpmCipherNext(CIPHER_CTX cph, void *data, size_t len)
Encrypt/Decrypt a block of data.
size_t rpmiobLen(rpmiob iob)
Return I/O buffer len.
Definition: rpmiob.c:122
int ac
Definition: rpmiotypes.h:73
static int xispunct(int c)
Definition: rpmiotypes.h:570