Make rpmps generic number field 64bit, rename getter method
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 11 Jun 2008 07:31:14 +0000 (10:31 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 11 Jun 2008 07:31:14 +0000 (10:31 +0300)
- rename the parameters + internal use to more generic "number"
- rename ugly and dumb rpmProblemGetLong() to rpmProblemGetDiskNeed()
  and return rpm_loff_t
- the number field is used for some other purposes too (whether dep problem
  is for installed package), work around this for now by just defining
  rpmProblemGetDiskNeed() result value as undefined on non-disk related
  problems ;)

lib/rpmps.c
lib/rpmps.h
python/rpmts-py.c

index 92bf8bd..5762cb1 100644 (file)
@@ -18,7 +18,7 @@ struct rpmProblem_s {
     rpmProblemType type;
     int ignoreProblem;
     char * str1;
-    unsigned long ulong1;
+    uint64_t num1;
 };
 
 /**
@@ -153,12 +153,12 @@ void rpmpsAppendProblem(rpmps ps, rpmProblem prob)
 void rpmpsAppend(rpmps ps, rpmProblemType type,
                const char * pkgNEVR, fnpyKey key,
                const char * dn, const char * bn,
-               const char * altNEVR, unsigned long ulong1)
+               const char * altNEVR, uint64_t number)
 {
     rpmProblem p = NULL;
     if (ps == NULL) return;
 
-    p = rpmProblemCreate(type, pkgNEVR, key, dn, bn, altNEVR, ulong1);
+    p = rpmProblemCreate(type, pkgNEVR, key, dn, bn, altNEVR, number);
     rpmpsAppendProblem(ps, p);
 }
 
@@ -213,14 +213,14 @@ rpmProblem rpmProblemCreate(rpmProblemType type,
                             fnpyKey key,
                             const char * dn, const char * bn,
                             const char * altNEVR,
-                            unsigned long ulong1)
+                            uint64_t number)
 {
     rpmProblem p = xcalloc(1, sizeof(*p));
     char *t;
 
     p->type = type;
     p->key = key;
-    p->ulong1 = ulong1;
+    p->num1 = number;
     p->ignoreProblem = 0;
 
     p->pkgNEVR = (pkgNEVR ? xstrdup(pkgNEVR) : NULL);
@@ -271,9 +271,9 @@ const char * rpmProblemGetStr(const rpmProblem p)
     return (p->str1);
 }
 
-unsigned long rpmProblemGetLong(const rpmProblem p)
+rpm_loff_t rpmProblemGetDiskNeed(const rpmProblem p)
 {
-    return (p->ulong1);
+    return (p->num1);
 }
 
 char * rpmProblemString(const rpmProblem prob)
@@ -321,26 +321,26 @@ char * rpmProblemString(const rpmProblem prob)
        rc = rasprintf(&buf,
            _("installing package %s needs %ld%cB on the %s filesystem"),
                pkgNEVR,
-               prob->ulong1 > (1024*1024)
-                   ? (prob->ulong1 + 1024 * 1024 - 1) / (1024 * 1024)
-                   : (prob->ulong1 + 1023) / 1024,
-               prob->ulong1 > (1024*1024) ? 'M' : 'K',
+               prob->num1 > (1024*1024)
+                   ? (prob->num1 + 1024 * 1024 - 1) / (1024 * 1024)
+                   : (prob->num1 + 1023) / 1024,
+               prob->num1 > (1024*1024) ? 'M' : 'K',
                str1);
        break;
     case RPMPROB_DISKNODES:
        rc = rasprintf(&buf,
-           _("installing package %s needs %ld inodes on the %s filesystem"),
-               pkgNEVR, (long)prob->ulong1, str1);
+           _("installing package %s needs %llu inodes on the %s filesystem"),
+               pkgNEVR, (long long)prob->num1, str1);
        break;
     case RPMPROB_REQUIRES:
        rc = rasprintf(&buf, _("%s is needed by %s%s"),
                altNEVR+2,
-               (prob->ulong1 ? "" : _("(installed) ")), pkgNEVR);
+               (prob->num1 ? "" : _("(installed) ")), pkgNEVR);
        break;
     case RPMPROB_CONFLICT:
        rc = rasprintf(&buf, _("%s conflicts with %s%s"),
                altNEVR+2,
-               (prob->ulong1 ? "" : _("(installed) ")), pkgNEVR);
+               (prob->num1 ? "" : _("(installed) ")), pkgNEVR);
        break;
     default:
        rc = rasprintf(&buf,
@@ -366,7 +366,7 @@ static int sameProblem(const rpmProblem ap, const rpmProblem bp)
        if (bp->str1 && strcmp(ap->str1, bp->str1))
            return 1;
 
-    if (ap->ulong1 != bp->ulong1)
+    if (ap->num1 != bp->num1)
        return 1;
 
     return 0;
index f0d5783..0fc800d 100644 (file)
@@ -68,7 +68,7 @@ typedef enum rpmProblemType_e {
  * @param dn           directory name
  * @param bn           file base name
  * @param altNEVR      related (e.g. through a dependency) package name
- * @param ulong1       generic pointer/long attribute
+ * @param number       generic number attribute
  * @return             rpmProblem
  */
 rpmProblem rpmProblemCreate(rpmProblemType type,
@@ -76,7 +76,7 @@ rpmProblem rpmProblemCreate(rpmProblemType type,
                             fnpyKey key,
                             const char * dn, const char * bn,
                             const char * altNEVR,
-                            unsigned long ulong1);
+                            uint64_t number);
 
 /** \ingroup rpmps
  * Destroy a problem item.
@@ -120,13 +120,15 @@ fnpyKey rpmProblemGetKey(const rpmProblem prob);
  * @todo               needs a better name
  */
 const char * rpmProblemGetStr(const rpmProblem prob);
+
 /** \ingroup rpmps
- * Return generic pointer/long attribute from a problem
+ * Return disk requirement (needed disk space / number of inodes)
+ * depending on problem type. On problem types other than RPMPROB_DISKSPACE
+ * and RPMPROB_DISKNODES return value is undefined.
  * @param prob         rpm problem
- * @return             a generic pointer/long attribute
- * @todo               needs a better name
+ * @return             disk requirement
  */
-unsigned long rpmProblemGetLong(const rpmProblem prob);
+rpm_loff_t rpmProblemGetDiskNeed(const rpmProblem prob);
 
 /** \ingroup rpmps
  * Return formatted string representation of a problem.
@@ -223,14 +225,14 @@ void rpmpsAppendProblem(rpmps ps, rpmProblem prob);
  * @param dn           directory name
  * @param bn           file base name
  * @param altNEVR      related (e.g. through a dependency) package name
- * @param ulong1       generic pointer/long attribute
+ * @param number       generic number attribute
  */
 void rpmpsAppend(rpmps ps, rpmProblemType type,
                const char * pkgNEVR,
                fnpyKey key,
                const char * dn, const char * bn,
                const char * altNEVR,
-               unsigned long ulong1);
+               uint64_t number);
 
 /** \ingroup rpmps
  * Filter a problem set.
index 422436b..3e84a82 100644 (file)
@@ -1020,7 +1020,7 @@ fprintf(stderr, "*** rpmts_Run(%p) ts %p ignore %x\n", s, s->ts, s->ignoreSet);
        PyObject * prob = Py_BuildValue("s(isN)", ps,
                             rpmProblemGetType(p),
                             rpmProblemGetStr(p),
-                            PyLong_FromLongLong(rpmProblemGetLong(p)));
+                            PyLong_FromLongLong(rpmProblemGetDiskNeed(p)));
        PyList_Append(list, prob);
        free(ps);
        Py_DECREF(prob);