From 2fc0cb31a2010d70f3f9197189730400edbd6ef4 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Mon, 22 May 2023 10:28:01 +0200 Subject: [PATCH] Clean up header files Move type declarations of Repo/Repodata/Solvable into pooltypes.h. --- src/dataiterator.h | 12 +++++------- src/pool.h | 32 +++++++++++++++----------------- src/pooltypes.h | 9 +++++++++ src/repo.h | 4 ++-- src/repodata.h | 11 +++++------ src/rules.h | 6 ++---- src/transaction.h | 7 +++---- 7 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/dataiterator.h b/src/dataiterator.h index 0649258f..357ae598 100644 --- a/src/dataiterator.h +++ b/src/dataiterator.h @@ -20,8 +20,6 @@ extern "C" { #endif -struct s_Repo; - typedef struct s_KeyValue { Id id; const char *str; @@ -106,8 +104,8 @@ typedef struct s_Dataiterator int flags; Pool *pool; - struct s_Repo *repo; - struct s_Repodata *data; + Repo *repo; + Repodata *data; /* data pointers */ unsigned char *dp; @@ -165,9 +163,9 @@ typedef struct s_Dataiterator * keyname: if non-null, limit search to this keyname * match: if non-null, limit search to this match */ -int dataiterator_init(Dataiterator *di, Pool *pool, struct s_Repo *repo, Id p, Id keyname, const char *match, int flags); +int dataiterator_init(Dataiterator *di, Pool *pool, Repo *repo, Id p, Id keyname, const char *match, int flags); void dataiterator_init_clone(Dataiterator *di, Dataiterator *from); -void dataiterator_set_search(Dataiterator *di, struct s_Repo *repo, Id p); +void dataiterator_set_search(Dataiterator *di, Repo *repo, Id p); void dataiterator_set_keyname(Dataiterator *di, Id keyname); int dataiterator_set_match(Dataiterator *di, const char *match, int flags); @@ -181,7 +179,7 @@ void dataiterator_skip_attribute(Dataiterator *di); void dataiterator_skip_solvable(Dataiterator *di); void dataiterator_skip_repo(Dataiterator *di); void dataiterator_jump_to_solvid(Dataiterator *di, Id solvid); -void dataiterator_jump_to_repo(Dataiterator *di, struct s_Repo *repo); +void dataiterator_jump_to_repo(Dataiterator *di, Repo *repo); void dataiterator_entersub(Dataiterator *di); void dataiterator_clonepos(Dataiterator *di, Dataiterator *from); void dataiterator_seek(Dataiterator *di, int whence); diff --git a/src/pool.h b/src/pool.h index 60878cf2..08cf1d06 100644 --- a/src/pool.h +++ b/src/pool.h @@ -36,13 +36,11 @@ extern "C" { /*----------------------------------------------- */ -struct s_Repo; -struct s_Repodata; struct s_Repokey; struct s_KeyValue; typedef struct s_Datapos { - struct s_Repo *repo; + Repo *repo; Id solvid; Id repodataid; Id schema; @@ -66,16 +64,16 @@ struct s_Pool_tmpspace { struct s_Pool { void *appdata; /* application private pointer */ - struct s_Stringpool ss; + Stringpool ss; Reldep *rels; /* table of rels: Id -> Reldep */ int nrels; /* number of unique rels */ - struct s_Repo **repos; + Repo **repos; int nrepos; /* repos allocated */ int urepos; /* repos in use */ - struct s_Repo *installed; /* packages considered installed */ + Repo *installed; /* packages considered installed */ Solvable *solvables; int nsolvables; /* solvables allocated */ @@ -109,16 +107,16 @@ struct s_Pool { Map *considered; /* callback for REL_NAMESPACE dependencies handled by the application */ - Id (*nscallback)(struct s_Pool *, void *data, Id name, Id evr); + Id (*nscallback)(Pool *, void *data, Id name, Id evr); void *nscallbackdata; /* debug mask and callback */ int debugmask; - void (*debugcallback)(struct s_Pool *, void *data, int type, const char *str); + void (*debugcallback)(Pool *, void *data, int type, const char *str); void *debugcallbackdata; /* load callback */ - int (*loadcallback)(struct s_Pool *, struct s_Repodata *, void *); + int (*loadcallback)(Pool *, Repodata *, void *); void *loadcallbackdata; /* search position */ @@ -155,7 +153,7 @@ struct s_Pool { char *rootdir; - int (*custom_vendorcheck)(struct s_Pool *, Solvable *, Solvable *); + int (*custom_vendorcheck)(Pool *, Solvable *, Solvable *); int addfileprovidesfiltered; /* 1: only use filtered file list for addfileprovides */ int addedfileprovides; /* true: application called addfileprovides */ @@ -251,14 +249,14 @@ extern int pool_set_flag(Pool *pool, int flag, int value); extern int pool_get_flag(Pool *pool, int flag); extern void pool_debug(Pool *pool, int type, const char *format, ...) __attribute__((format(printf, 3, 4))); -extern void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct s_Pool *, void *data, int type, const char *str), void *debugcallbackdata); +extern void pool_setdebugcallback(Pool *pool, void (*debugcallback)(Pool *pool, void *data, int type, const char *str), void *debugcallbackdata); extern void pool_setdebugmask(Pool *pool, int mask); -extern void pool_setloadcallback(Pool *pool, int (*cb)(struct s_Pool *, struct s_Repodata *, void *), void *loadcbdata); -extern void pool_setnamespacecallback(Pool *pool, Id (*cb)(struct s_Pool *, void *, Id, Id), void *nscbdata); +extern void pool_setloadcallback(Pool *pool, int (*cb)(Pool *, Repodata *, void *), void *loadcbdata); +extern void pool_setnamespacecallback(Pool *pool, Id (*cb)(Pool *, void *, Id, Id), void *nscbdata); extern void pool_flush_namespaceproviders(Pool *pool, Id ns, Id evr); -extern void pool_set_custom_vendorcheck(Pool *pool, int (*vendorcheck)(struct s_Pool *, Solvable *, Solvable *)); -extern int (*pool_get_custom_vendorcheck(Pool *pool))(struct s_Pool *, Solvable *, Solvable *); +extern void pool_set_custom_vendorcheck(Pool *pool, int (*vendorcheck)(Pool *, Solvable *, Solvable *)); +extern int (*pool_get_custom_vendorcheck(Pool *pool))(Pool *, Solvable *, Solvable *); extern char *pool_alloctmpspace(Pool *pool, int len); extern void pool_freetmpspace(Pool *pool, const char *space); @@ -266,7 +264,7 @@ extern char *pool_tmpjoin(Pool *pool, const char *str1, const char *str2, const extern char *pool_tmpappend(Pool *pool, const char *str1, const char *str2, const char *str3); extern const char *pool_bin2hex(Pool *pool, const unsigned char *buf, int len); -extern void pool_set_installed(Pool *pool, struct s_Repo *repo); +extern void pool_set_installed(Pool *pool, Repo *repo); extern int pool_error(Pool *pool, int ret, const char *format, ...) __attribute__((format(printf, 3, 4))); extern char *pool_errstr(Pool *pool); @@ -363,7 +361,7 @@ void pool_set_whatprovides(Pool *pool, Id id, Id providers); * key - search only this key * match - key must match this string */ -void pool_search(Pool *pool, Id p, Id key, const char *match, int flags, int (*callback)(void *cbdata, Solvable *s, struct s_Repodata *data, struct s_Repokey *key, struct s_KeyValue *kv), void *cbdata); +void pool_search(Pool *pool, Id p, Id key, const char *match, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, struct s_Repokey *key, struct s_KeyValue *kv), void *cbdata); void pool_clear_pos(Pool *pool); diff --git a/src/pooltypes.h b/src/pooltypes.h index 3d686ed0..bccdfc12 100644 --- a/src/pooltypes.h +++ b/src/pooltypes.h @@ -40,6 +40,15 @@ typedef struct s_Stringpool Stringpool; struct s_Pool; typedef struct s_Pool Pool; +struct s_Repo; +typedef struct s_Repo Repo; + +struct s_Repodata; +typedef struct s_Repodata Repodata; + +struct s_Solvable; +typedef struct s_Solvable Solvable; + /* identifier for string values */ typedef int Id; /* must be signed!, since negative Id is used in solver rules to denote negation */ diff --git a/src/repo.h b/src/repo.h index b503431a..1f270d72 100644 --- a/src/repo.h +++ b/src/repo.h @@ -24,7 +24,7 @@ extern "C" { #endif -typedef struct s_Repo { +struct s_Repo { const char *name; /* name pointer */ Id repoid; /* our id */ void *appdata; /* application private pointer */ @@ -56,7 +56,7 @@ typedef struct s_Repo { int lastmarker; Offset lastmarkerpos; #endif /* LIBSOLV_INTERNAL */ -} Repo; +}; extern Repo *repo_create(Pool *pool, const char *name); extern void repo_free(Repo *repo, int reuseids); diff --git a/src/repodata.h b/src/repodata.h index 2504f2ae..fda463e7 100644 --- a/src/repodata.h +++ b/src/repodata.h @@ -34,7 +34,6 @@ extern "C" { #define SIZEOF_SHA384 48 #define SIZEOF_SHA512 64 -struct s_Repo; struct s_KeyValue; typedef struct s_Repokey { @@ -67,13 +66,13 @@ struct dircache; #define REPODATA_FILELIST_FILTERED 1 #define REPODATA_FILELIST_EXTENSION 2 -typedef struct s_Repodata { +struct s_Repodata { Id repodataid; /* our id */ - struct s_Repo *repo; /* back pointer to repo */ + Repo *repo; /* back pointer to repo */ int state; /* available, stub or error */ - void (*loadcallback)(struct s_Repodata *); + void (*loadcallback)(Repodata *); int start; /* start of solvables this repodata is valid for */ int end; /* last solvable + 1 of this repodata */ @@ -140,7 +139,7 @@ typedef struct s_Repodata { struct dircache *dircache; #endif -} Repodata; +}; #define SOLVID_META -1 #define SOLVID_POS -2 @@ -149,7 +148,7 @@ typedef struct s_Repodata { /*----- * management functions */ -void repodata_initdata(Repodata *data, struct s_Repo *repo, int localpool); +void repodata_initdata(Repodata *data, Repo *repo, int localpool); void repodata_freedata(Repodata *data); void repodata_free(Repodata *data); diff --git a/src/rules.h b/src/rules.h index 895462a5..17af2dfc 100644 --- a/src/rules.h +++ b/src/rules.h @@ -14,15 +14,13 @@ #define LIBSOLV_RULES_H #include "pooltypes.h" +#include "bitmap.h" +#include "queue.h" #ifdef __cplusplus extern "C" { #endif -typedef struct s_Solvable Solvable; -typedef struct s_Map Map; -typedef struct s_Queue Queue; - /* ---------------------------------------------- * Rule diff --git a/src/transaction.h b/src/transaction.h index 001412d2..8b8fe6de 100644 --- a/src/transaction.h +++ b/src/transaction.h @@ -21,12 +21,11 @@ extern "C" { #endif -struct s_Pool; struct s_DUChanges; struct s_TransactionOrderdata; typedef struct s_Transaction { - struct s_Pool *pool; /* back pointer to pool */ + Pool *pool; /* back pointer to pool */ Queue steps; /* the transaction steps */ @@ -93,8 +92,8 @@ typedef struct s_Transaction { #define SOLVER_ORDERCYCLE_NORMAL 1 #define SOLVER_ORDERCYCLE_CRITICAL 2 -extern Transaction *transaction_create(struct s_Pool *pool); -extern Transaction *transaction_create_decisionq(struct s_Pool *pool, Queue *decisionq, Map *multiversionmap); +extern Transaction *transaction_create(Pool *pool); +extern Transaction *transaction_create_decisionq(Pool *pool, Queue *decisionq, Map *multiversionmap); extern Transaction *transaction_create_clone(Transaction *srctrans); extern void transaction_free(Transaction *trans); -- 2.47.2