Skip to content

Commit

Permalink
- clean up function names for shared library
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed May 2, 2011
1 parent ac09948 commit 31d9370
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 44 deletions.
36 changes: 24 additions & 12 deletions src/bitmap.h
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Novell Inc.
* Copyright (c) 2007-2011, Novell Inc.
*
* This program is licensed under the BSD license, read LICENSE.BSD
* for further information
Expand All @@ -13,27 +13,39 @@
#ifndef SATSOLVER_BITMAP_H
#define SATSOLVER_BITMAP_H

#include <string.h>

typedef struct _Map {
unsigned char *map;
int size;
} Map;

#define MAPZERO(m) (memset((m)->map, 0, (m)->size))
#define MAPSET(m, n) ((m)->map[(n) >> 3] |= 1 << ((n) & 7)) // Set Bit
#define MAPCLR(m, n) ((m)->map[(n) >> 3] &= ~(1 << ((n) & 7))) // Reset Bit
#define MAPTST(m, n) ((m)->map[(n) >> 3] & (1 << ((n) & 7))) // Test Bit

static inline void
map_empty(Map *m)
{
MAPZERO(m);
}
/* set bit */
#define MAPSET(m, n) ((m)->map[(n) >> 3] |= 1 << ((n) & 7))
/* clear bit */
#define MAPCLR(m, n) ((m)->map[(n) >> 3] &= ~(1 << ((n) & 7)))
/* test bit */
#define MAPTST(m, n) ((m)->map[(n) >> 3] & (1 << ((n) & 7)))

extern void map_init(Map *m, int n);
extern void map_init_clone(Map *t, Map *s);
extern void map_grow(Map *m, int n);
extern void map_free(Map *m);

static inline void map_empty(Map *m)
{
MAPZERO(m);
}
static inline void map_set(Map *m, int n)
{
MAPSET(m, n);
}
static inline void map_clr(Map *m, int n)
{
MAPCLR(m, n);
}
static inline int map_tst(Map *m, int n)
{
return MAPTST(m, n);
}

#endif /* SATSOLVER_BITMAP_H */
17 changes: 8 additions & 9 deletions src/evr.c
Expand Up @@ -21,12 +21,12 @@
#if defined(DEBIAN_SEMANTICS) || defined(MULTI_SEMANTICS)

#ifdef MULTI_SEMANTICS
# define vercmp vercmp_deb
# define sat_vercmp sat_vercmp_deb
#endif

/* debian type version compare */
int
vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
sat_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
{
int r, c1, c2;
while (1)
Expand Down Expand Up @@ -65,7 +65,7 @@ vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
}

#ifdef MULTI_SEMANTICS
# undef vercmp
# undef sat_vercmp
#endif

#endif
Expand All @@ -76,7 +76,7 @@ vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
/* note: the code assumes that *q1 and *q2 are not alphanumeric! */

int
vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
sat_vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
{
int r = 0;
const char *e1, *e2;
Expand Down Expand Up @@ -135,12 +135,12 @@ vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
#endif

#if defined(MULTI_SEMANTICS)
# define vercmp (*(pool->disttype == DISTTYPE_DEB ? &vercmp_deb : &ver##cmp))
# define sat_vercmp (*(pool->disttype == DISTTYPE_DEB ? &sat_vercmp_deb : &sat_ver##cmp))
#endif

/* edition (e:v-r) compare */
int
evrcmp_str(const Pool *pool, const char *evr1, const char *evr2, int mode)
pool_evrcmp_str(const Pool *pool, const char *evr1, const char *evr2, int mode)
{
int r;
const char *s1, *s2;
Expand Down Expand Up @@ -228,7 +228,7 @@ evrcmp_str(const Pool *pool, const char *evr1, const char *evr2, int mode)
}

int
evrcmp(const Pool *pool, Id evr1id, Id evr2id, int mode)
pool_evrcmp(const Pool *pool, Id evr1id, Id evr2id, int mode)
{
const char *evr1, *evr2;
if (evr1id == evr2id)
Expand All @@ -239,7 +239,7 @@ evrcmp(const Pool *pool, Id evr1id, Id evr2id, int mode)
}

int
evrmatch(const Pool *pool, Id evrid, const char *epoch, const char *version, const char *release)
pool_evrmatch(const Pool *pool, Id evrid, const char *epoch, const char *version, const char *release)
{
const char *evr1;
const char *s1;
Expand Down Expand Up @@ -286,4 +286,3 @@ evrmatch(const Pool *pool, Id evrid, const char *epoch, const char *version, con
return 0;
}

// EOF
27 changes: 23 additions & 4 deletions src/evr.h
Expand Up @@ -24,10 +24,29 @@ extern "C" {
#define EVRCMP_MATCH 2
#define EVRCMP_COMPARE_EVONLY 3

extern int vercmp(const char *s1, const char *q1, const char *s2, const char *q2);
extern int evrcmp_str(const Pool *pool, const char *evr1, const char *evr2, int mode);
extern int evrcmp(const Pool *pool, Id evr1id, Id evr2id, int mode);
extern int evrmatch(const Pool *pool, Id evrid, const char *epoch, const char *version, const char *release);
extern int sat_vercmp(const char *s1, const char *q1, const char *s2, const char *q2);

extern int pool_evrcmp_str(const Pool *pool, const char *evr1, const char *evr2, int mode);
extern int pool_evrcmp(const Pool *pool, Id evr1id, Id evr2id, int mode);
extern int pool_evrmatch(const Pool *pool, Id evrid, const char *epoch, const char *version, const char *release);

/* obsolete, do not use in new code */
static inline int vercmp(const char *s1, const char *q1, const char *s2, const char *q2)
{
return sat_vercmp(s1, q1, s2, q2);
}
static inline int evrcmp_str(const Pool *pool, const char *evr1, const char *evr2, int mode)
{
return pool_evrcmp_str(pool, evr1, evr2, mode);
}
static inline int evrcmp(const Pool *pool, Id evr1id, Id evr2id, int mode)
{
return pool_evrcmp(pool, evr1id, evr2id, mode);
}
static inline int evrmatch(const Pool *pool, Id evrid, const char *epoch, const char *version, const char *release)
{
return pool_evrmatch(pool, evrid, epoch, version, release);
}

#ifdef __cplusplus
}
Expand Down
14 changes: 12 additions & 2 deletions src/pool.h
Expand Up @@ -219,10 +219,20 @@ static inline Solvable *pool_id2solvable(const Pool *pool, Id p)
return pool->solvables + p;
}

extern const char *solvable2str(Pool *pool, Solvable *s);
extern const char *pool_solvable2str(Pool *pool, Solvable *s);
static inline const char *pool_solvid2str(Pool *pool, Id p)
{
return pool_solvable2str(pool, pool->solvables + p);
}

/* obsolete, do not use anymore */
static inline const char *solvable2str(Pool *pool, Solvable *s)
{
return pool_solvable2str(pool, s);
}
static inline const char *solvid2str(Pool *pool, Id p)
{
return solvable2str(pool, pool->solvables + p);
return pool_solvable2str(pool, pool->solvables + p);
}

void pool_set_languages(Pool *pool, const char **languages, int nlanguages);
Expand Down
14 changes: 7 additions & 7 deletions src/poolid.c
Expand Up @@ -24,7 +24,7 @@
/* intern string into pool, return id */

Id
str2id(Pool *pool, const char *str, int create)
pool_str2id(Pool *pool, const char *str, int create)
{
int oldnstrings = pool->ss.nstrings;
Id id = stringpool_str2id(&pool->ss, str, create);
Expand All @@ -38,7 +38,7 @@ str2id(Pool *pool, const char *str, int create)
}

Id
strn2id(Pool *pool, const char *str, unsigned int len, int create)
pool_strn2id(Pool *pool, const char *str, unsigned int len, int create)
{
int oldnstrings = pool->ss.nstrings;
Id id = stringpool_strn2id(&pool->ss, str, len, create);
Expand All @@ -52,7 +52,7 @@ strn2id(Pool *pool, const char *str, unsigned int len, int create)
}

Id
rel2id(Pool *pool, Id name, Id evr, int flags, int create)
pool_rel2id(Pool *pool, Id name, Id evr, int flags, int create)
{
Hashval h;
unsigned int hh;
Expand Down Expand Up @@ -121,7 +121,7 @@ rel2id(Pool *pool, Id name, Id evr, int flags, int create)
// for rels (returns name only) and strings
//
const char *
id2str(const Pool *pool, Id id)
pool_id2str(const Pool *pool, Id id)
{
if (ISRELDEP(id))
{
Expand Down Expand Up @@ -155,7 +155,7 @@ static const char *rels[] = {

// get operator for RelId
const char *
id2rel(const Pool *pool, Id id)
pool_id2rel(const Pool *pool, Id id)
{
Reldep *rd;
if (!ISRELDEP(id))
Expand Down Expand Up @@ -188,7 +188,7 @@ id2rel(const Pool *pool, Id id)
// get e:v.r for Id
//
const char *
id2evr(const Pool *pool, Id id)
pool_id2evr(const Pool *pool, Id id)
{
Reldep *rd;
if (!ISRELDEP(id))
Expand Down Expand Up @@ -256,7 +256,7 @@ dep2strcpy(const Pool *pool, char *p, Id id, int oldrel)
}

const char *
dep2str(Pool *pool, Id id)
pool_dep2str(Pool *pool, Id id)
{
char *p;
if (!ISRELDEP(id))
Expand Down
50 changes: 41 additions & 9 deletions src/poolid.h
Expand Up @@ -16,25 +16,57 @@
#include "pooltypes.h"
#include "hash.h"

//-----------------------------------------------
// Id's with relation
/*-----------------------------------------------
* Ids with relation
*/

typedef struct _Reldep {
Id name; // "package"
Id evr; // "0:42-3"
int flags; // operation/relation, see REL_x in pool.h
} Reldep;

extern Id str2id(Pool *pool, const char *, int);
extern Id strn2id(Pool *pool, const char *, unsigned int, int);
extern Id rel2id(Pool *pool, Id, Id, int, int);
extern const char *id2str(const Pool *pool, Id);
extern const char *dep2str(Pool *pool, Id); /* might alloc tmpspace */
extern const char *id2rel(const Pool *pool, Id);
extern const char *id2evr(const Pool *pool, Id);
extern Id pool_str2id(Pool *pool, const char *, int);
extern Id pool_strn2id(Pool *pool, const char *, unsigned int, int);
extern Id pool_rel2id(Pool *pool, Id, Id, int, int);
extern const char *pool_id2str(const Pool *pool, Id);
extern const char *pool_id2rel(const Pool *pool, Id);
extern const char *pool_id2evr(const Pool *pool, Id);
extern const char *pool_dep2str(Pool *pool, Id); /* might alloc tmpspace */

extern void pool_shrink_strings(Pool *pool);
extern void pool_shrink_rels(Pool *pool);
extern void pool_freeidhashes(Pool *pool);


/* deprecated names, do not use in new code */
static inline Id str2id(Pool *pool, const char *str, int create)
{
return pool_str2id(pool, str, create);
}
static inline Id strn2id(Pool *pool, const char *str, unsigned int len, int create)
{
return pool_strn2id(pool, str, len, create);
}
static inline Id rel2id(Pool *pool, Id name, Id evr, int flags, int create)
{
return pool_rel2id(pool, name, evr, flags, create);
}
static inline const char *id2str(const Pool *pool, Id id)
{
return pool_id2str(pool, id);
}
static inline const char *id2rel(const Pool *pool, Id id)
{
return pool_id2rel(pool, id);
}
static inline const char *id2evr(const Pool *pool, Id id)
{
return pool_id2evr(pool, id);
}
static inline const char *dep2str(Pool *pool, Id id)
{
return pool_dep2str(pool, id);
}

#endif /* SATSOLVER_POOLID_H */
2 changes: 1 addition & 1 deletion src/solvable.c
Expand Up @@ -23,7 +23,7 @@
#include "chksum.h"

const char *
solvable2str(Pool *pool, Solvable *s)
pool_solvable2str(Pool *pool, Solvable *s)
{
const char *n, *e, *a;
char *p;
Expand Down

0 comments on commit 31d9370

Please sign in to comment.