~noskcaj/ubuntu/trusty/libextractor/merge

« back to all changes in this revision

Viewing changes to src/plugins/rpm/rpmextractor.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-11-17 20:27:32 UTC
  • mfrom: (1.10.4 upstream) (5.2.5 sid)
  • Revision ID: james.westby@ubuntu.com-20091117202732-ipm2h3gks5bdw2vx
Tags: 0.5.23+dfsg-3
* Building against libltdl7.
* Updating to standards version 3.8.3.
* Adding maintainer homepage field to control.
* Marking maintainer homepage field to be also included in binary
  packages and changelog.
* Adding README.source.
* Simplifying autotools handling in rules.
* Updating README.source.
* Moving maintainer homepage field from control to copyright.
* Dropping la files.
* Simplyfing debhelper install files.
* Bumping versioned build-depends on debhelper.
* Adding depends to dpkg install info.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "platform.h"
22
22
#include "extractor.h"
 
23
#include <stdint.h>
23
24
#include <rpm/rpmlib.h>
24
25
#include <rpm/rpmts.h>
25
26
#include <pthread.h>
77
78
 
78
79
typedef struct
79
80
{
80
 
  int_32 rtype;
 
81
  int32_t rtype;
81
82
  EXTRACTOR_KeywordType type;
82
83
} Matches;
83
84
 
91
92
  {RPMTAG_SUMMARY, EXTRACTOR_SUMMARY},
92
93
  {RPMTAG_PACKAGER, EXTRACTOR_PACKAGER},
93
94
  {RPMTAG_BUILDTIME, EXTRACTOR_CREATION_DATE},
 
95
#ifdef RPMTAG_COPYRIGHT
94
96
  {RPMTAG_COPYRIGHT, EXTRACTOR_COPYRIGHT},
 
97
#endif
95
98
  {RPMTAG_LICENSE, EXTRACTOR_LICENSE},
96
99
  {RPMTAG_DISTRIBUTION, EXTRACTOR_DISTRIBUTION},
97
100
  {RPMTAG_BUILDHOST, EXTRACTOR_BUILDHOST},
114
117
  struct PipeArgs parg;
115
118
  pthread_t pthr;
116
119
  void * unused;
 
120
  const char *str;
117
121
  Header hdr;
118
122
  HeaderIterator hi;
119
 
  int_32 tag;
120
 
  int_32 type;
121
 
  int_32 c;
122
 
  hPTR_t p;
 
123
  rpmtd p;
123
124
  int i;
124
125
  FD_t fdi;
125
126
  rpmRC rc;
161
162
  prev = addKeyword (EXTRACTOR_MIMETYPE,
162
163
                     "application/x-rpm", prev);
163
164
  hi = headerInitIterator (hdr);
164
 
  while (1 == headerNextIterator (hi, &tag, &type, &p, &c))
 
165
  p = rpmtdNew ();
 
166
  while (1 == headerNext (hi, p))
165
167
    {
166
168
      i = 0;
167
169
      while (tests[i].rtype != 0)
168
170
        {
169
 
          if (tests[i].rtype == tag)
 
171
          if (tests[i].rtype == p->tag)
170
172
            {
171
 
              switch (type)
 
173
              switch (p->type)
172
174
                {
173
175
                case RPM_STRING_ARRAY_TYPE:
174
 
                  {
175
 
                    char *tmp;
176
 
                    const char *p2;
177
 
                    int c2;
178
 
                    int size;
179
 
 
180
 
                    c2 = c;
181
 
                    p2 = p;
182
 
                    size = 0;
183
 
                    while (c2--)
184
 
                      {
185
 
                        size += strlen (p2);
186
 
                        p2 = strchr (p2, 0);
187
 
                        p2++;
188
 
                      }
189
 
 
190
 
                    tmp = malloc (size + 1);
191
 
                    tmp[0] = '\0';
192
 
                    while (c--)
193
 
                      {
194
 
                        strcat (tmp, p);
195
 
                        p = strchr (p, 0);
196
 
                        p++;
197
 
                      }
198
 
                    prev = addKeyword (tests[i].type, tmp, prev);
199
 
                    free (tmp);
200
 
                    break;
201
 
                  }
202
176
                case RPM_I18NSTRING_TYPE:
203
 
                  {
204
 
                    char *tmp;
205
 
                    const char *p2;
206
 
                    int c2;
207
 
                    int size;
208
 
 
209
 
                    c2 = c;
210
 
                    p2 = p;
211
 
                    p2 += sizeof (char *) * c;
212
 
                    size = 0;
213
 
                    while (c2--)
214
 
                      {
215
 
                        size += strlen (p2);
216
 
                        p2 = strchr (p2, 0);
217
 
                        p2++;
218
 
                      }
219
 
 
220
 
                    tmp = malloc (size + 1);
221
 
                    tmp[0] = '\0';
222
 
                    p2 = p;
223
 
                    p2 += sizeof (char *) * c;
224
 
                    while (c--)
225
 
                      {
226
 
                        strcat (tmp, p2);
227
 
                        p2 = strchr (p2, 0);
228
 
                        p2++;
229
 
                      }
230
 
                    prev = addKeyword (tests[i].type, tmp, prev);
231
 
                    free (tmp);
232
 
                    break;
233
 
                  }
234
177
                case RPM_STRING_TYPE:
235
 
                  prev = addKeyword (tests[i].type, (char *) p, prev);
236
 
                  break;
 
178
                    while (NULL != (str = rpmtdNextString (p))) 
 
179
                      prev = addKeyword (tests[i].type, str, prev);
 
180
                    break;
237
181
                case RPM_INT32_TYPE:
238
182
                  {
239
 
                    if (tag == RPMTAG_BUILDTIME)
 
183
                    if (p->tag == RPMTAG_BUILDTIME)
240
184
                      {
241
185
                        char tmp[30];
242
186
 
257
201
            }
258
202
          i++;
259
203
        }
260
 
      if (((type == RPM_BIN_TYPE) ||
261
 
           (type == RPM_I18NSTRING_TYPE) ||
262
 
           (type == RPM_STRING_ARRAY_TYPE)) && (p != NULL))
263
 
        {
264
 
          free ((void *) p);
265
 
        }
266
204
    }
 
205
  rpmtdFree (p);
267
206
  headerFreeIterator (hi);
268
207
  headerFree (hdr);
269
208
  rpmtsFree(ts);