Remove hdrVerifyFile, unusable as was (#58576).
authorjbj <devnull@localhost>
Wed, 7 Aug 2002 23:19:10 +0000 (23:19 +0000)
committerjbj <devnull@localhost>
Wed, 7 Aug 2002 23:19:10 +0000 (23:19 +0000)
CVS patchset: 5614
CVS date: 2002/08/07 23:19:10

python/header-py.c

index 422bc36..9a25855 100644 (file)
@@ -180,234 +180,6 @@ static PyObject * hdrUnload(hdrObject * s, PyObject * args, PyObject *keywords)
 }
 
 /** \ingroup python
- * Returns a list of these tuples for each item that failed:
- *     (attr_name, correctValue, currentValue)
- * It should be passed the file number to verify.
- */
-static PyObject * hdrVerifyFile(hdrObject * s, PyObject * args)
-       /*@*/
-{
-    int fileNumber;
-    rpmVerifyAttrs verifyResult = 0;
-    PyObject * list, * tuple, * attrName;
-    int type, count;
-    struct stat sb;
-    char buf[2048];
-    int i;
-    time_t timeInt;
-    struct tm * timeStruct;
-
-    if (!PyInt_Check(args)) {
-       PyErr_SetString(PyExc_TypeError, "integer expected");
-       return NULL;
-    }
-
-    fileNumber = (int) PyInt_AsLong(args);
-
-    {  rpmts ts;
-       int scareMem = 1;
-       rpmfi fi;
-       int rc;
-
-       ts = rpmtsCreate();
-       fi = rpmfiNew(ts, NULL, s->h, RPMTAG_BASENAMES, scareMem);
-       fi = rpmfiInit(fi, fileNumber);
-       if (fi != NULL && rpmfiNext(fi) >= 0) {
-           /* XXX this routine might use callbacks intelligently. */
-           rc = rpmVerifyFile(ts, fi, &verifyResult, RPMVERIFY_NONE);
-       } else
-           rc = 1;
-
-       fi = rpmfiFree(fi, 1);
-       rpmtsFree(ts);
-
-       if (rc) {
-           Py_INCREF(Py_None);
-           return Py_None;
-       }
-    }
-
-    list = PyList_New(0);
-
-    if (!verifyResult) return list;
-
-    /* XXX Legacy tag needs to go away. */
-    if (!s->fileList) {
-       headerGetEntry(s->h, RPMTAG_OLDFILENAMES, &type, (void **) &s->fileList,
-                &count);
-    }
-
-    lstat(s->fileList[fileNumber], &sb);
-
-    if (verifyResult & RPMVERIFY_MD5) {
-       if (!s->md5list) {
-           headerGetEntry(s->h, RPMTAG_FILEMD5S, &type, (void **) &s->md5list,
-                    &count);
-       }
-
-       if (domd5(s->fileList[fileNumber], buf, 1, NULL)) {
-           strcpy(buf, "00000000000000000000000000000000");
-       }
-
-       tuple = PyTuple_New(3);
-       attrName = PyString_FromString("checksum");
-       PyTuple_SetItem(tuple, 0, attrName);
-       PyTuple_SetItem(tuple, 1, PyString_FromString(s->md5list[fileNumber]));
-       PyTuple_SetItem(tuple, 2, PyString_FromString(buf));
-       PyList_Append(list, tuple);
-       Py_DECREF(tuple);
-    }
-
-    if (verifyResult & RPMVERIFY_FILESIZE) {
-       if (!s->fileSizes) {
-           headerGetEntry(s->h, RPMTAG_FILESIZES, &type, (void **) &s->fileSizes,
-                    &count);
-
-       }
-
-       tuple = PyTuple_New(3);
-       attrName = PyString_FromString("size");
-       PyTuple_SetItem(tuple, 0, attrName);
-
-       sprintf(buf, "%d", 100);
-       PyTuple_SetItem(tuple, 1, PyString_FromString(buf));
-       sprintf(buf, "%ld", (long)sb.st_size);
-       PyTuple_SetItem(tuple, 2, PyString_FromString(buf));
-       PyList_Append(list, tuple);
-       Py_DECREF(tuple);
-    }
-
-    if (verifyResult & RPMVERIFY_LINKTO) {
-       if (!s->linkList) {
-           headerGetEntry(s->h, RPMTAG_FILELINKTOS, &type, (void **) &s->linkList,
-                    &count);
-       }
-
-       i = readlink(s->fileList[fileNumber], buf, sizeof(buf));
-       if (i <= 0)
-           strcpy(buf, "(unknown)");
-       else
-           buf[i] = '\0';
-
-       tuple = PyTuple_New(3);
-       attrName = PyString_FromString("link");
-       PyTuple_SetItem(tuple, 0, attrName);
-       PyTuple_SetItem(tuple, 1, PyString_FromString(s->linkList[fileNumber]));
-       PyTuple_SetItem(tuple, 2, PyString_FromString(buf));
-       PyList_Append(list, tuple);
-       Py_DECREF(tuple);
-    }
-
-    if (verifyResult & RPMVERIFY_MTIME) {
-       if (!s->mtimes) {
-           headerGetEntry(s->h, RPMTAG_FILEMTIMES, &type, (void **) &s->mtimes,
-                    &count);
-       }
-
-       tuple = PyTuple_New(3);
-       attrName = PyString_FromString("time");
-       PyTuple_SetItem(tuple, 0, attrName);
-
-       timeInt = sb.st_mtime;
-       timeStruct = localtime(&timeInt);
-       strftime(buf, sizeof(buf) - 1, "%c", timeStruct);
-       PyTuple_SetItem(tuple, 1, PyString_FromString(buf));
-
-       timeInt = s->mtimes[fileNumber];
-       timeStruct = localtime(&timeInt);
-       strftime(buf, sizeof(buf) - 1, "%c", timeStruct);
-
-       PyTuple_SetItem(tuple, 2, PyString_FromString(buf));
-
-       PyList_Append(list, tuple);
-       Py_DECREF(tuple);
-    }
-
-    if (verifyResult & RPMVERIFY_RDEV) {
-       if (!s->rdevs) {
-           headerGetEntry(s->h, RPMTAG_FILERDEVS, &type, (void **) &s->rdevs,
-                    &count);
-       }
-
-       tuple = PyTuple_New(3);
-       attrName = PyString_FromString("device");
-
-       PyTuple_SetItem(tuple, 0, attrName);
-       sprintf(buf, "0x%-4x", s->rdevs[fileNumber]);
-       PyTuple_SetItem(tuple, 1, PyString_FromString(buf));
-       sprintf(buf, "0x%-4x", (unsigned int) sb.st_rdev);
-       PyTuple_SetItem(tuple, 2, PyString_FromString(buf));
-       PyList_Append(list, tuple);
-       Py_DECREF(tuple);
-    }
-
-    /*
-     * RPMVERIFY_USER and RPM_VERIFY_GROUP are handled wrong here, but rpmlib.a
-     * doesn't do these correctly either. At least this is consistent.
-     *
-     * XXX Consistent? rpmlib.a verifies user/group quite well, thank you.
-     * XXX The code below does nothing useful. FILEUSERNAME needs to be
-     * XXX retrieved and looked up.
-     */
-    if (verifyResult & RPMVERIFY_USER) {
-       if (!s->uids) {
-           headerGetEntry(s->h, RPMTAG_FILEUIDS, &type, (void **) &s->uids,
-                    &count);
-       }
-
-       tuple = PyTuple_New(3);
-       attrName = PyString_FromString("uid");
-       PyTuple_SetItem(tuple, 0, attrName);
-       sprintf(buf, "%d", s->uids[fileNumber]);
-       PyTuple_SetItem(tuple, 1, PyString_FromString(buf));
-       sprintf(buf, "%d", sb.st_uid);
-       PyTuple_SetItem(tuple, 2, PyString_FromString(buf));
-       PyList_Append(list, tuple);
-       Py_DECREF(tuple);
-    }
-
-    /*
-     * XXX The code below does nothing useful. FILEGROUPNAME needs to be
-     * XXX retrieved and looked up.
-     */
-    if (verifyResult & RPMVERIFY_GROUP) {
-       if (!s->gids) {
-           headerGetEntry(s->h, RPMTAG_FILEGIDS, &type, (void **) &s->gids,
-                    &count);
-       }
-
-       tuple = PyTuple_New(3);
-       attrName = PyString_FromString("gid");
-       PyTuple_SetItem(tuple, 0, attrName);
-       sprintf(buf, "%d", s->gids[fileNumber]);
-       PyTuple_SetItem(tuple, 1, PyString_FromString(buf));
-       sprintf(buf, "%d", sb.st_gid);
-       PyTuple_SetItem(tuple, 2, PyString_FromString(buf));
-       PyList_Append(list, tuple);
-       Py_DECREF(tuple);
-    }
-
-    if (verifyResult & RPMVERIFY_MODE) {
-       if (!s->modes) {
-           headerGetEntry(s->h, RPMTAG_FILEMODES, &type, (void **) &s->modes,
-                    &count);
-       }
-
-       tuple = PyTuple_New(3);
-       attrName = PyString_FromString("permissions");
-       PyTuple_SetItem(tuple, 0, attrName);
-       sprintf(buf, "0%-4o", s->modes[fileNumber]);
-       PyTuple_SetItem(tuple, 1, PyString_FromString(buf));
-       sprintf(buf, "0%-4o", sb.st_mode);
-       PyTuple_SetItem(tuple, 2, PyString_FromString(buf));
-       PyList_Append(list, tuple);
-       Py_DECREF(tuple);
-    }
-
-    return list;
-}
-
-/** \ingroup python
  */
 static PyObject * hdrExpandFilelist(hdrObject * s, PyObject * args)
        /*@*/
@@ -572,8 +344,6 @@ static struct PyMethodDef hdr_methods[] = {
        NULL },
     {"unload",         (PyCFunction) hdrUnload,        METH_VARARGS|METH_KEYWORDS,
        NULL },
-    {"verifyFile",     (PyCFunction) hdrVerifyFile,    METH_VARARGS,
-       NULL },
     {"expandFilelist", (PyCFunction) hdrExpandFilelist,METH_VARARGS,
        NULL },
     {"compressFilelist",(PyCFunction) hdrCompressFilelist,METH_VARARGS,